diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php
index b054fe2a..63a2ace4 100644
--- a/Classes/PHPExcel/Calculation.php
+++ b/Classes/PHPExcel/Calculation.php
@@ -1,6 +1,31 @@
=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
+ // Named Range of cells
+ define('CALCULATION_REGEXP_NAMEDRANGE', '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)');
+ } else {
+ // Cell reference (cell or range of cells, with or without a sheet reference)
+ define('CALCULATION_REGEXP_CELLREF', '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)');
+ // Named Range of cells
+ define('CALCULATION_REGEXP_NAMEDRANGE', '(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)');
+ }
+}
+
/**
- * PHPExcel
+ * PHPExcel_Calculation (Multiton)
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@@ -24,43 +49,8 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
-
-
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
- require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
-}
-
-
-if (!defined('CALCULATION_REGEXP_CELLREF')) {
- // Test for support of \P (multibyte options) in PCRE
- if(defined('PREG_BAD_UTF8_ERROR')) {
- // Cell reference (cell or range of cells, with or without a sheet reference)
- define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
- // Named Range of cells
- define('CALCULATION_REGEXP_NAMEDRANGE','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)');
- } else {
- // Cell reference (cell or range of cells, with or without a sheet reference)
- define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)');
- // Named Range of cells
- define('CALCULATION_REGEXP_NAMEDRANGE','(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)');
- }
-}
-
-
-/**
- * PHPExcel_Calculation (Multiton)
- *
- * @category PHPExcel
- * @package PHPExcel_Calculation
- * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
- */
-class PHPExcel_Calculation {
-
+class PHPExcel_Calculation
+{
/** Constants */
/** Regular Expressions */
// Numeric operand
@@ -84,7 +74,7 @@ class PHPExcel_Calculation {
const RETURN_ARRAY_AS_VALUE = 'value';
const RETURN_ARRAY_AS_ARRAY = 'array';
- private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
+ private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
/**
@@ -127,7 +117,7 @@ class PHPExcel_Calculation {
* @access private
* @var boolean
*/
- private $_calculationCacheEnabled = TRUE;
+ private $_calculationCacheEnabled = true;
/**
@@ -137,12 +127,12 @@ class PHPExcel_Calculation {
* @access private
* @var array
*/
- private static $_operators = array('+' => TRUE, '-' => TRUE, '*' => TRUE, '/' => TRUE,
- '^' => TRUE, '&' => TRUE, '%' => FALSE, '~' => FALSE,
- '>' => TRUE, '<' => TRUE, '=' => TRUE, '>=' => TRUE,
- '<=' => TRUE, '<>' => TRUE, '|' => TRUE, ':' => TRUE
- );
-
+ private static $_operators = array(
+ '+' => true, '-' => true, '*' => true, '/' => true,
+ '^' => true, '&' => true, '%' => false, '~' => false,
+ '>' => true, '<' => true, '=' => true, '>=' => true,
+ '<=' => true, '<>' => true, '|' => true, ':' => true
+ );
/**
* List of binary operators (those that expect two operands)
@@ -150,11 +140,12 @@ class PHPExcel_Calculation {
* @access private
* @var array
*/
- private static $_binaryOperators = array('+' => TRUE, '-' => TRUE, '*' => TRUE, '/' => TRUE,
- '^' => TRUE, '&' => TRUE, '>' => TRUE, '<' => TRUE,
- '=' => TRUE, '>=' => TRUE, '<=' => TRUE, '<>' => TRUE,
- '|' => TRUE, ':' => TRUE
- );
+ private static $_binaryOperators = array(
+ '+' => true, '-' => true, '*' => true, '/' => true,
+ '^' => true, '&' => true, '>' => true, '<' => true,
+ '=' => true, '>=' => true, '<=' => true, '<>' => true,
+ '|' => true, ':' => true
+ );
/**
* The debug log generated by the calculation engine
@@ -174,7 +165,7 @@ class PHPExcel_Calculation {
* @var boolean
*
*/
- public $suppressFormulaErrors = FALSE;
+ public $suppressFormulaErrors = false;
/**
* Error message for any error that was raised/thrown by the calculation engine
@@ -183,7 +174,7 @@ class PHPExcel_Calculation {
* @var string
*
*/
- public $formulaError = NULL;
+ public $formulaError = null;
/**
* An array of the nested cell references accessed by the calculation engine, used for the debug log
@@ -240,8 +231,10 @@ class PHPExcel_Calculation {
* @var string[]
*
*/
- private static $_validLocaleLanguages = array( 'en' // English (default language)
- );
+ private static $_validLocaleLanguages = array(
+ 'en' // English (default language)
+ );
+
/**
* Locale-specific argument separator for function arguments
*
@@ -257,11 +250,11 @@ class PHPExcel_Calculation {
* @var string[]
*
*/
- public static $_localeBoolean = array( 'TRUE' => 'TRUE',
- 'FALSE' => 'FALSE',
- 'NULL' => 'NULL'
- );
-
+ public static $_localeBoolean = array(
+ 'TRUE' => 'TRUE',
+ 'FALSE' => 'FALSE',
+ 'NULL' => 'NULL'
+ );
/**
* Excel constant string translations to their PHP equivalents
@@ -270,10 +263,11 @@ class PHPExcel_Calculation {
* @var string[]
*
*/
- private static $_ExcelConstants = array('TRUE' => TRUE,
- 'FALSE' => FALSE,
- 'NULL' => NULL
- );
+ private static $_ExcelConstants = array(
+ 'TRUE' => true,
+ 'FALSE' => false,
+ 'NULL' => null
+ );
// PHPExcel functions
private static $_PHPExcelFunctions = array( // PHPExcel functions
@@ -444,7 +438,7 @@ class PHPExcel_Calculation {
'COLUMN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMN',
'argumentCount' => '-1',
- 'passByReference' => array(TRUE)
+ 'passByReference' => array(true)
),
'COLUMNS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::COLUMNS',
@@ -853,7 +847,7 @@ class PHPExcel_Calculation {
'HYPERLINK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::HYPERLINK',
'argumentCount' => '1,2',
- 'passCellReference'=> TRUE
+ 'passCellReference'=> true
),
'HYPGEOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
'functionCall' => 'PHPExcel_Calculation_Statistical::HYPGEOMDIST',
@@ -942,7 +936,7 @@ class PHPExcel_Calculation {
'INDIRECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::INDIRECT',
'argumentCount' => '1,2',
- 'passCellReference'=> TRUE
+ 'passCellReference'=> true
),
'INFO' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
@@ -1259,8 +1253,8 @@ class PHPExcel_Calculation {
'OFFSET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET',
'argumentCount' => '3,5',
- 'passCellReference'=> TRUE,
- 'passByReference' => array(TRUE)
+ 'passCellReference'=> true,
+ 'passByReference' => array(true)
),
'OR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
'functionCall' => 'PHPExcel_Calculation_Logical::LOGICAL_OR',
@@ -1405,7 +1399,7 @@ class PHPExcel_Calculation {
'ROW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::ROW',
'argumentCount' => '-1',
- 'passByReference' => array(TRUE)
+ 'passByReference' => array(true)
),
'ROWS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::ROWS',
@@ -1712,42 +1706,44 @@ class PHPExcel_Calculation {
// Internal functions used for special control purposes
private static $_controlFunctions = array(
- 'MKMATRIX' => array('argumentCount' => '*',
- 'functionCall' => 'self::_mkMatrix'
- )
- );
+ 'MKMATRIX' => array(
+ 'argumentCount' => '*',
+ 'functionCall' => 'self::_mkMatrix'
+ )
+ );
-
-
- private function __construct(PHPExcel $workbook = NULL) {
+ private function __construct(PHPExcel $workbook = null)
+ {
$setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16;
$this->_savedPrecision = ini_get('precision');
if ($this->_savedPrecision < $setPrecision) {
- ini_set('precision',$setPrecision);
+ ini_set('precision', $setPrecision);
}
$this->delta = 1 * pow(10, -$setPrecision);
- if ($workbook !== NULL) {
+ if ($workbook !== null) {
self::$_workbookSets[$workbook->getID()] = $this;
}
$this->_workbook = $workbook;
$this->_cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack();
$this->_debugLog = new PHPExcel_CalcEngine_Logger($this->_cyclicReferenceStack);
- } // function __construct()
+ }
- public function __destruct() {
+ public function __destruct()
+ {
if ($this->_savedPrecision != ini_get('precision')) {
- ini_set('precision',$this->_savedPrecision);
+ ini_set('precision', $this->_savedPrecision);
}
}
- private static function _loadLocales() {
+ private static function _loadLocales()
+ {
$localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
- foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
- $filename = substr($filename,strlen($localeFileDirectory)+1);
+ foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) {
+ $filename = substr($filename, strlen($localeFileDirectory)+1);
if ($filename != 'en') {
self::$_validLocaleLanguages[] = $filename;
}
@@ -1762,20 +1758,21 @@ class PHPExcel_Calculation {
* or NULL to create a standalone claculation engine
* @return PHPExcel_Calculation
*/
- public static function getInstance(PHPExcel $workbook = NULL) {
- if ($workbook !== NULL) {
+ public static function getInstance(PHPExcel $workbook = null)
+ {
+ if ($workbook !== null) {
if (isset(self::$_workbookSets[$workbook->getID()])) {
return self::$_workbookSets[$workbook->getID()];
}
return new PHPExcel_Calculation($workbook);
}
- if (!isset(self::$_instance) || (self::$_instance === NULL)) {
+ if (!isset(self::$_instance) || (self::$_instance === null)) {
self::$_instance = new PHPExcel_Calculation();
}
return self::$_instance;
- } // function getInstance()
+ }
/**
* Unset an instance of this class
@@ -1783,8 +1780,9 @@ class PHPExcel_Calculation {
* @access public
* @param PHPExcel $workbook Injected workbook identifying the instance to unset
*/
- public static function unsetInstance(PHPExcel $workbook = NULL) {
- if ($workbook !== NULL) {
+ public static function unsetInstance(PHPExcel $workbook = null)
+ {
+ if ($workbook !== null) {
if (isset(self::$_workbookSets[$workbook->getID()])) {
unset(self::$_workbookSets[$workbook->getID()]);
}
@@ -1798,9 +1796,10 @@ class PHPExcel_Calculation {
* @access public
* @return null
*/
- public function flushInstance() {
+ public function flushInstance()
+ {
$this->clearCalculationCache();
- } // function flushInstance()
+ }
/**
@@ -1809,7 +1808,8 @@ class PHPExcel_Calculation {
* @access public
* @return PHPExcel_CalcEngine_Logger
*/
- public function getDebugLog() {
+ public function getDebugLog()
+ {
return $this->_debugLog;
}
@@ -1819,9 +1819,10 @@ class PHPExcel_Calculation {
* @access public
* @throws PHPExcel_Calculation_Exception
*/
- public final function __clone() {
- throw new PHPExcel_Calculation_Exception ('Cloning the calculation engine is not allowed!');
- } // function __clone()
+ final public function __clone()
+ {
+ throw new PHPExcel_Calculation_Exception('Cloning the calculation engine is not allowed!');
+ }
/**
@@ -1830,7 +1831,8 @@ class PHPExcel_Calculation {
* @access public
* @return string locale-specific translation of TRUE
*/
- public static function getTRUE() {
+ public static function getTRUE()
+ {
return self::$_localeBoolean['TRUE'];
}
@@ -1840,7 +1842,8 @@ class PHPExcel_Calculation {
* @access public
* @return string locale-specific translation of FALSE
*/
- public static function getFALSE() {
+ public static function getFALSE()
+ {
return self::$_localeBoolean['FALSE'];
}
@@ -1851,15 +1854,16 @@ class PHPExcel_Calculation {
* @param string $returnType Array return type
* @return boolean Success or failure
*/
- public static function setArrayReturnType($returnType) {
+ public static function setArrayReturnType($returnType)
+ {
if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
($returnType == self::RETURN_ARRAY_AS_ERROR) ||
($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
self::$returnArrayAsType = $returnType;
- return TRUE;
+ return true;
}
- return FALSE;
- } // function setArrayReturnType()
+ return false;
+ }
/**
@@ -1868,9 +1872,10 @@ class PHPExcel_Calculation {
* @access public
* @return string $returnType Array return type
*/
- public static function getArrayReturnType() {
+ public static function getArrayReturnType()
+ {
return self::$returnArrayAsType;
- } // function getArrayReturnType()
+ }
/**
@@ -1879,9 +1884,10 @@ class PHPExcel_Calculation {
* @access public
* @return boolean
*/
- public function getCalculationCacheEnabled() {
+ public function getCalculationCacheEnabled()
+ {
return $this->_calculationCacheEnabled;
- } // function getCalculationCacheEnabled()
+ }
/**
* Enable/disable calculation cache
@@ -1889,45 +1895,50 @@ class PHPExcel_Calculation {
* @access public
* @param boolean $pValue
*/
- public function setCalculationCacheEnabled($pValue = TRUE) {
+ public function setCalculationCacheEnabled($pValue = true)
+ {
$this->_calculationCacheEnabled = $pValue;
$this->clearCalculationCache();
- } // function setCalculationCacheEnabled()
+ }
/**
* Enable calculation cache
*/
- public function enableCalculationCache() {
- $this->setCalculationCacheEnabled(TRUE);
- } // function enableCalculationCache()
+ public function enableCalculationCache()
+ {
+ $this->setCalculationCacheEnabled(true);
+ }
/**
* Disable calculation cache
*/
- public function disableCalculationCache() {
- $this->setCalculationCacheEnabled(FALSE);
- } // function disableCalculationCache()
+ public function disableCalculationCache()
+ {
+ $this->setCalculationCacheEnabled(false);
+ }
/**
* Clear calculation cache
*/
- public function clearCalculationCache() {
+ public function clearCalculationCache()
+ {
$this->_calculationCache = array();
- } // function clearCalculationCache()
+ }
/**
* Clear calculation cache for a specified worksheet
*
* @param string $worksheetName
*/
- public function clearCalculationCacheForWorksheet($worksheetName) {
+ public function clearCalculationCacheForWorksheet($worksheetName)
+ {
if (isset($this->_calculationCache[$worksheetName])) {
unset($this->_calculationCache[$worksheetName]);
}
- } // function clearCalculationCacheForWorksheet()
+ }
/**
* Rename calculation cache for a specified worksheet
@@ -1935,12 +1946,13 @@ class PHPExcel_Calculation {
* @param string $fromWorksheetName
* @param string $toWorksheetName
*/
- public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName) {
+ public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName)
+ {
if (isset($this->_calculationCache[$fromWorksheetName])) {
$this->_calculationCache[$toWorksheetName] = &$this->_calculationCache[$fromWorksheetName];
unset($this->_calculationCache[$fromWorksheetName]);
}
- } // function renameCalculationCacheForWorksheet()
+ }
/**
@@ -1948,9 +1960,10 @@ class PHPExcel_Calculation {
*
* @return string
*/
- public function getLocale() {
+ public function getLocale()
+ {
return self::$_localeLanguage;
- } // function getLocale()
+ }
/**
@@ -1959,18 +1972,19 @@ class PHPExcel_Calculation {
* @param string $locale The locale to use for formula translation
* @return boolean
*/
- public function setLocale($locale = 'en_us') {
+ public function setLocale($locale = 'en_us')
+ {
// Identify our locale and language
$language = $locale = strtolower($locale);
- if (strpos($locale,'_') !== FALSE) {
- list($language) = explode('_',$locale);
+ if (strpos($locale, '_') !== false) {
+ list($language) = explode('_', $locale);
}
- if (count(self::$_validLocaleLanguages) == 1)
+ if (count(self::$_validLocaleLanguages) == 1) {
self::_loadLocales();
-
+ }
// Test whether we have any language data for this language (any locale)
- if (in_array($language,self::$_validLocaleLanguages)) {
+ if (in_array($language, self::$_validLocaleLanguages)) {
// initialise language/locale settings
self::$_localeFunctions = array();
self::$_localeArgumentSeparator = ',';
@@ -1978,20 +1992,20 @@ class PHPExcel_Calculation {
// Default is English, if user isn't requesting english, then read the necessary data from the locale files
if ($locale != 'en_us') {
// Search for a file with a list of function names for locale
- $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'functions';
+ $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'functions';
if (!file_exists($functionNamesFile)) {
// If there isn't a locale specific function file, look for a language specific function file
$functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions';
if (!file_exists($functionNamesFile)) {
- return FALSE;
+ return false;
}
}
// Retrieve the list of locale or language specific function names
- $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeFunctions as $localeFunction) {
- list($localeFunction) = explode('##',$localeFunction); // Strip out comments
- if (strpos($localeFunction,'=') !== FALSE) {
- list($fName,$lfName) = explode('=',$localeFunction);
+ list($localeFunction) = explode('##', $localeFunction); // Strip out comments
+ if (strpos($localeFunction, '=') !== false) {
+ list($fName, $lfName) = explode('=', $localeFunction);
$fName = trim($fName);
$lfName = trim($lfName);
if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
@@ -2000,22 +2014,26 @@ class PHPExcel_Calculation {
}
}
// Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
- if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
- if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }
+ if (isset(self::$_localeFunctions['TRUE'])) {
+ self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE'];
+ }
+ if (isset(self::$_localeFunctions['FALSE'])) {
+ self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE'];
+ }
- $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'config';
+ $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config';
if (!file_exists($configFile)) {
$configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config';
}
if (file_exists($configFile)) {
- $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeSettings as $localeSetting) {
- list($localeSetting) = explode('##',$localeSetting); // Strip out comments
- if (strpos($localeSetting,'=') !== FALSE) {
- list($settingName,$settingValue) = explode('=',$localeSetting);
+ list($localeSetting) = explode('##', $localeSetting); // Strip out comments
+ if (strpos($localeSetting, '=') !== false) {
+ list($settingName, $settingValue) = explode('=', $localeSetting);
$settingName = strtoupper(trim($settingName));
switch ($settingName) {
- case 'ARGUMENTSEPARATOR' :
+ case 'ARGUMENTSEPARATOR':
self::$_localeArgumentSeparator = trim($settingValue);
break;
}
@@ -2025,127 +2043,136 @@ class PHPExcel_Calculation {
}
self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
- self::$functionReplaceFromLocale = self::$functionReplaceToLocale = NULL;
+ self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null;
self::$_localeLanguage = $locale;
- return TRUE;
+ return true;
}
- return FALSE;
- } // function setLocale()
+ return false;
+ }
- public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) {
+ public static function _translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces)
+ {
$strlen = mb_strlen($formula);
for ($i = 0; $i < $strlen; ++$i) {
- $chr = mb_substr($formula,$i,1);
+ $chr = mb_substr($formula, $i, 1);
switch ($chr) {
- case '{' : $inBraces = TRUE;
- break;
- case '}' : $inBraces = FALSE;
- break;
- case $fromSeparator :
- if (!$inBraces) {
- $formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1);
- }
+ case '{':
+ $inBraces = true;
+ break;
+ case '}':
+ $inBraces = false;
+ break;
+ case $fromSeparator:
+ if (!$inBraces) {
+ $formula = mb_substr($formula, 0, $i).$toSeparator.mb_substr($formula, $i+1);
+ }
}
}
return $formula;
}
- private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
+ private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator)
+ {
// Convert any Excel function names to the required language
if (self::$_localeLanguage !== 'en_us') {
- $inBraces = FALSE;
+ $inBraces = false;
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
- if (strpos($formula,'"') !== FALSE) {
+ if (strpos($formula, '"') !== false) {
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
// the formula
- $temp = explode('"',$formula);
- $i = FALSE;
- foreach($temp as &$value) {
+ $temp = explode('"', $formula);
+ $i = false;
+ foreach ($temp as &$value) {
// Only count/replace in alternating array entries
if ($i = !$i) {
- $value = preg_replace($from,$to,$value);
- $value = self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces);
+ $value = preg_replace($from, $to, $value);
+ $value = self::_translateSeparator($fromSeparator, $toSeparator, $value, $inBraces);
}
}
unset($value);
// Then rebuild the formula string
- $formula = implode('"',$temp);
+ $formula = implode('"', $temp);
} else {
// If there's no quoted strings, then we do a simple count/replace
- $formula = preg_replace($from,$to,$formula);
- $formula = self::_translateSeparator($fromSeparator,$toSeparator,$formula,$inBraces);
+ $formula = preg_replace($from, $to, $formula);
+ $formula = self::_translateSeparator($fromSeparator, $toSeparator, $formula, $inBraces);
}
}
return $formula;
}
- private static $functionReplaceFromExcel = NULL;
- private static $functionReplaceToLocale = NULL;
+ private static $functionReplaceFromExcel = null;
+ private static $functionReplaceToLocale = null;
- public function _translateFormulaToLocale($formula) {
- if (self::$functionReplaceFromExcel === NULL) {
+ public function _translateFormulaToLocale($formula)
+ {
+ if (self::$functionReplaceFromExcel === null) {
self::$functionReplaceFromExcel = array();
- foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
+ foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
}
- foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
+ foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
}
}
- if (self::$functionReplaceToLocale === NULL) {
+ if (self::$functionReplaceToLocale === null) {
self::$functionReplaceToLocale = array();
- foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
+ foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
}
- foreach(array_values(self::$_localeBoolean) as $localeBoolean) {
+ foreach (array_values(self::$_localeBoolean) as $localeBoolean) {
self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
}
}
- return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator);
- } // function _translateFormulaToLocale()
+ return self::_translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$_localeArgumentSeparator);
+ }
- private static $functionReplaceFromLocale = NULL;
- private static $functionReplaceToExcel = NULL;
+ private static $functionReplaceFromLocale = null;
+ private static $functionReplaceToExcel = null;
- public function _translateFormulaToEnglish($formula) {
- if (self::$functionReplaceFromLocale === NULL) {
+ public function _translateFormulaToEnglish($formula)
+ {
+ if (self::$functionReplaceFromLocale === null) {
self::$functionReplaceFromLocale = array();
- foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
+ foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
}
- foreach(array_values(self::$_localeBoolean) as $excelBoolean) {
+ foreach (array_values(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
}
}
- if (self::$functionReplaceToExcel === NULL) {
+ if (self::$functionReplaceToExcel === null) {
self::$functionReplaceToExcel = array();
- foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
+ foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
}
- foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
+ foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
}
}
- return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,',');
- } // function _translateFormulaToEnglish()
+ return self::_translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$_localeArgumentSeparator, ',');
+ }
- public static function _localeFunc($function) {
+ public static function _localeFunc($function)
+ {
if (self::$_localeLanguage !== 'en_us') {
- $functionName = trim($function,'(');
+ $functionName = trim($function, '(');
if (isset(self::$_localeFunctions[$functionName])) {
$brace = ($functionName != $function);
$function = self::$_localeFunctions[$functionName];
- if ($brace) { $function .= '('; }
+ if ($brace) {
+ $function .= '(';
+ }
}
}
return $function;
@@ -2160,7 +2187,8 @@ class PHPExcel_Calculation {
* @param mixed $value
* @return mixed
*/
- public static function _wrapResult($value) {
+ public static function _wrapResult($value)
+ {
if (is_string($value)) {
// Error values cannot be "wrapped"
if (preg_match('/^'.self::CALCULATION_REGEXP_ERROR.'$/i', $value, $match)) {
@@ -2170,12 +2198,12 @@ class PHPExcel_Calculation {
// Return strings wrapped in quotes
return '"'.$value.'"';
// Convert numeric errors to NaN error
- } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
+ } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return PHPExcel_Calculation_Functions::NaN();
}
return $value;
- } // function _wrapResult()
+ }
/**
@@ -2184,17 +2212,18 @@ class PHPExcel_Calculation {
* @param mixed $value
* @return mixed
*/
- public static function _unwrapResult($value) {
+ public static function _unwrapResult($value)
+ {
if (is_string($value)) {
- if ((isset($value{0})) && ($value{0} == '"') && (substr($value,-1) == '"')) {
- return substr($value,1,-1);
+ if ((isset($value{0})) && ($value{0} == '"') && (substr($value, -1) == '"')) {
+ return substr($value, 1, -1);
}
// Convert numeric errors to NaN error
- } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
+ } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return PHPExcel_Calculation_Functions::NaN();
}
return $value;
- } // function _unwrapResult()
+ }
@@ -2208,13 +2237,14 @@ class PHPExcel_Calculation {
* @return mixed
* @throws PHPExcel_Calculation_Exception
*/
- public function calculate(PHPExcel_Cell $pCell = NULL) {
+ public function calculate(PHPExcel_Cell $pCell = null)
+ {
try {
return $this->calculateCellValue($pCell);
} catch (PHPExcel_Exception $e) {
throw new PHPExcel_Calculation_Exception($e->getMessage());
}
- } // function calculate()
+ }
/**
@@ -2226,9 +2256,10 @@ class PHPExcel_Calculation {
* @return mixed
* @throws PHPExcel_Calculation_Exception
*/
- public function calculateCellValue(PHPExcel_Cell $pCell = NULL, $resetLog = TRUE) {
- if ($pCell === NULL) {
- return NULL;
+ public function calculateCellValue(PHPExcel_Cell $pCell = null, $resetLog = true)
+ {
+ if ($pCell === null) {
+ return null;
}
$returnArrayAsType = self::$returnArrayAsType;
@@ -2268,7 +2299,9 @@ class PHPExcel_Calculation {
// If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it
$r = array_keys($result);
$r = array_shift($r);
- if (!is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); }
+ if (!is_numeric($r)) {
+ return PHPExcel_Calculation_Functions::VALUE();
+ }
if (is_array($result[$r])) {
$c = array_keys($result[$r]);
$c = array_shift($c);
@@ -2282,13 +2315,13 @@ class PHPExcel_Calculation {
self::$returnArrayAsType = $returnArrayAsType;
- if ($result === NULL) {
+ if ($result === null) {
return 0;
- } elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
+ } elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
return PHPExcel_Calculation_Functions::NaN();
}
return $result;
- } // function calculateCellValue(
+ }
/**
@@ -2298,17 +2331,22 @@ class PHPExcel_Calculation {
* @return array
* @throws PHPExcel_Calculation_Exception
*/
- public function parseFormula($formula) {
+ public function parseFormula($formula)
+ {
// Basic validation that this is indeed a formula
// We return an empty array if not
$formula = trim($formula);
- if ((!isset($formula{0})) || ($formula{0} != '=')) return array();
- $formula = ltrim(substr($formula,1));
- if (!isset($formula{0})) return array();
+ if ((!isset($formula{0})) || ($formula{0} != '=')) {
+ return array();
+ }
+ $formula = ltrim(substr($formula, 1));
+ if (!isset($formula{0})) {
+ return array();
+ }
// Parse the formula and return the token stack
return $this->_parseFormula($formula);
- } // function parseFormula()
+ }
/**
@@ -2320,7 +2358,8 @@ class PHPExcel_Calculation {
* @return mixed
* @throws PHPExcel_Calculation_Exception
*/
- public function calculateFormula($formula, $cellID=NULL, PHPExcel_Cell $pCell = NULL) {
+ public function calculateFormula($formula, $cellID = null, PHPExcel_Cell $pCell = null)
+ {
// Initialise the logging settings
$this->formulaError = null;
$this->_debugLog->clearLog();
@@ -2329,7 +2368,7 @@ class PHPExcel_Calculation {
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
// But don't actually flush any cache
$resetCache = $this->getCalculationCacheEnabled();
- $this->_calculationCacheEnabled = FALSE;
+ $this->_calculationCacheEnabled = false;
// Execute the calculation
try {
$result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
@@ -2341,10 +2380,11 @@ class PHPExcel_Calculation {
$this->_calculationCacheEnabled = $resetCache;
return $result;
- } // function calculateFormula()
+ }
- public function getValueFromCache($cellReference, &$cellValue) {
+ public function getValueFromCache($cellReference, &$cellValue)
+ {
// Is calculation cacheing enabled?
// Is the value present in calculation cache?
$this->_debugLog->writeDebugLog('Testing cache value for cell ', $cellReference);
@@ -2352,12 +2392,13 @@ class PHPExcel_Calculation {
$this->_debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache');
// Return the cached result
$cellValue = $this->_calculationCache[$cellReference];
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
- public function saveValueToCache($cellReference, $cellValue) {
+ public function saveValueToCache($cellReference, $cellValue)
+ {
if ($this->_calculationCacheEnabled) {
$this->_calculationCache[$cellReference] = $cellValue;
}
@@ -2372,21 +2413,26 @@ class PHPExcel_Calculation {
* @return mixed
* @throws PHPExcel_Calculation_Exception
*/
- public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
+ public function _calculateFormulaValue($formula, $cellID = null, PHPExcel_Cell $pCell = null)
+ {
$cellValue = null;
// Basic validation that this is indeed a formula
// We simply return the cell value if not
$formula = trim($formula);
- if ($formula{0} != '=') return self::_wrapResult($formula);
+ if ($formula{0} != '=') {
+ return self::_wrapResult($formula);
+ }
$formula = ltrim(substr($formula, 1));
- if (!isset($formula{0})) return self::_wrapResult($formula);
+ if (!isset($formula{0})) {
+ return self::_wrapResult($formula);
+ }
- $pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
- $wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk";
+ $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null;
+ $wsTitle = ($pCellParent !== null) ? $pCellParent->getTitle() : "\x00Wrk";
$wsCellReference = $wsTitle . '!' . $cellID;
- if (($cellID !== NULL) && ($this->getValueFromCache($wsCellReference, $cellValue))) {
+ if (($cellID !== null) && ($this->getValueFromCache($wsCellReference, $cellValue))) {
return $cellValue;
}
@@ -2414,13 +2460,13 @@ class PHPExcel_Calculation {
$this->_cyclicReferenceStack->pop();
// Save to calculation cache
- if ($cellID !== NULL) {
+ if ($cellID !== null) {
$this->saveValueToCache($wsCellReference, $cellValue);
}
// Return the calculated value
return $cellValue;
- } // function _calculateFormulaValue()
+ }
/**
@@ -2435,34 +2481,35 @@ class PHPExcel_Calculation {
* 1 = shrink to fit
* 2 = extend to fit
*/
- private static function _checkMatrixOperands(&$operand1,&$operand2,$resize = 1) {
+ private static function _checkMatrixOperands(&$operand1, &$operand2, $resize = 1)
+ {
// Examine each of the two operands, and turn them into an array if they aren't one already
// Note that this function should only be called if one or both of the operand is already an array
if (!is_array($operand1)) {
- list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand2);
- $operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1));
+ list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand2);
+ $operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1));
$resize = 0;
} elseif (!is_array($operand2)) {
- list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand1);
- $operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2));
+ list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand1);
+ $operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2));
$resize = 0;
}
- list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($operand1);
- list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($operand2);
+ list($matrix1Rows, $matrix1Columns) = self::_getMatrixDimensions($operand1);
+ list($matrix2Rows, $matrix2Columns) = self::_getMatrixDimensions($operand2);
if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
$resize = 1;
}
if ($resize == 2) {
// Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
- self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
+ self::_resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
} elseif ($resize == 1) {
// Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
- self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
+ self::_resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
}
- return array( $matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
- } // function _checkMatrixOperands()
+ return array( $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
+ }
/**
@@ -2471,11 +2518,12 @@ class PHPExcel_Calculation {
* @param mixed &$matrix matrix operand
* @return array An array comprising the number of rows, and number of columns
*/
- public static function _getMatrixDimensions(&$matrix) {
+ public static function _getMatrixDimensions(&$matrix)
+ {
$matrixRows = count($matrix);
$matrixColumns = 0;
- foreach($matrix as $rowKey => $rowValue) {
- $matrixColumns = max(count($rowValue),$matrixColumns);
+ foreach ($matrix as $rowKey => $rowValue) {
+ $matrixColumns = max(count($rowValue), $matrixColumns);
if (!is_array($rowValue)) {
$matrix[$rowKey] = array($rowValue);
} else {
@@ -2483,8 +2531,8 @@ class PHPExcel_Calculation {
}
}
$matrix = array_values($matrix);
- return array($matrixRows,$matrixColumns);
- } // function _getMatrixDimensions()
+ return array($matrixRows, $matrixColumns);
+ }
/**
@@ -2497,7 +2545,8 @@ class PHPExcel_Calculation {
* @param integer $matrix2Rows Row size of second matrix operand
* @param integer $matrix2Columns Column size of second matrix operand
*/
- private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
+ private static function _resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns)
+ {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Rows < $matrix1Rows) {
for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) {
@@ -2527,7 +2576,7 @@ class PHPExcel_Calculation {
}
}
}
- } // function _resizeMatricesShrink()
+ }
/**
@@ -2540,7 +2589,8 @@ class PHPExcel_Calculation {
* @param integer $matrix2Rows Row size of second matrix operand
* @param integer $matrix2Columns Column size of second matrix operand
*/
- private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
+ private static function _resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns)
+ {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Columns < $matrix1Columns) {
for ($i = 0; $i < $matrix2Rows; ++$i) {
@@ -2574,7 +2624,7 @@ class PHPExcel_Calculation {
}
}
}
- } // function _resizeMatricesExtend()
+ }
/**
@@ -2583,7 +2633,8 @@ class PHPExcel_Calculation {
* @param mixed $value First matrix operand
* @return mixed
*/
- private function _showValue($value) {
+ private function _showValue($value)
+ {
if ($this->_debugLog->getWriteDebugLog()) {
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
if (count($testArray) == 1) {
@@ -2593,23 +2644,23 @@ class PHPExcel_Calculation {
if (is_array($value)) {
$returnMatrix = array();
$pad = $rpad = ', ';
- foreach($value as $row) {
+ foreach ($value as $row) {
if (is_array($row)) {
- $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row));
+ $returnMatrix[] = implode($pad, array_map(array($this, '_showValue'), $row));
$rpad = '; ';
} else {
$returnMatrix[] = $this->_showValue($row);
}
}
- return '{ '.implode($rpad,$returnMatrix).' }';
- } elseif(is_string($value) && (trim($value,'"') == $value)) {
+ return '{ '.implode($rpad, $returnMatrix).' }';
+ } elseif (is_string($value) && (trim($value, '"') == $value)) {
return '"'.$value.'"';
- } elseif(is_bool($value)) {
+ } elseif (is_bool($value)) {
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
}
}
return PHPExcel_Calculation_Functions::flattenSingleValue($value);
- } // function _showValue()
+ }
/**
@@ -2618,22 +2669,23 @@ class PHPExcel_Calculation {
* @param mixed $value First matrix operand
* @return mixed
*/
- private function _showTypeDetails($value) {
+ private function _showTypeDetails($value)
+ {
if ($this->_debugLog->getWriteDebugLog()) {
$testArray = PHPExcel_Calculation_Functions::flattenArray($value);
if (count($testArray) == 1) {
$value = array_pop($testArray);
}
- if ($value === NULL) {
+ if ($value === null) {
return 'a NULL value';
} elseif (is_float($value)) {
$typeString = 'a floating point number';
- } elseif(is_int($value)) {
+ } elseif (is_int($value)) {
$typeString = 'an integer number';
- } elseif(is_bool($value)) {
+ } elseif (is_bool($value)) {
$typeString = 'a boolean';
- } elseif(is_array($value)) {
+ } elseif (is_array($value)) {
$typeString = 'a matrix';
} else {
if ($value == '') {
@@ -2646,39 +2698,40 @@ class PHPExcel_Calculation {
}
return $typeString.' with a value of '.$this->_showValue($value);
}
- } // function _showTypeDetails()
+ }
- private function _convertMatrixReferences($formula) {
- static $matrixReplaceFrom = array('{',';','}');
- static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))');
+ private function _convertMatrixReferences($formula)
+ {
+ static $matrixReplaceFrom = array('{', ';', '}');
+ static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))');
// Convert any Excel matrix references to the MKMATRIX() function
- if (strpos($formula,'{') !== FALSE) {
+ if (strpos($formula, '{') !== false) {
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
- if (strpos($formula,'"') !== FALSE) {
+ if (strpos($formula, '"') !== false) {
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
// the formula
- $temp = explode('"',$formula);
+ $temp = explode('"', $formula);
// Open and Closed counts used for trapping mismatched braces in the formula
$openCount = $closeCount = 0;
- $i = FALSE;
- foreach($temp as &$value) {
+ $i = false;
+ foreach ($temp as &$value) {
// Only count/replace in alternating array entries
if ($i = !$i) {
- $openCount += substr_count($value,'{');
- $closeCount += substr_count($value,'}');
- $value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value);
+ $openCount += substr_count($value, '{');
+ $closeCount += substr_count($value, '}');
+ $value = str_replace($matrixReplaceFrom, $matrixReplaceTo, $value);
}
}
unset($value);
// Then rebuild the formula string
- $formula = implode('"',$temp);
+ $formula = implode('"', $temp);
} else {
// If there's no quoted strings, then we do a simple count/replace
- $openCount = substr_count($formula,'{');
- $closeCount = substr_count($formula,'}');
- $formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula);
+ $openCount = substr_count($formula, '{');
+ $closeCount = substr_count($formula, '}');
+ $formula = str_replace($matrixReplaceFrom, $matrixReplaceTo, $formula);
}
// Trap for mismatched braces and trigger an appropriate error
if ($openCount < $closeCount) {
@@ -2697,12 +2750,13 @@ class PHPExcel_Calculation {
}
return $formula;
- } // function _convertMatrixReferences()
+ }
- private static function _mkMatrix() {
+ private static function _mkMatrix()
+ {
return func_get_args();
- } // function _mkMatrix()
+ }
// Binary Operators
@@ -2719,7 +2773,7 @@ class PHPExcel_Calculation {
// Comparison (Boolean) Operators
// These operators work on two values, but always return a boolean result
- private static $_comparisonOperators = array('>' => TRUE, '<' => TRUE, '=' => TRUE, '>=' => TRUE, '<=' => TRUE, '<>' => TRUE);
+ private static $_comparisonOperators = array('>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true);
// Operator Precedence
// This list includes all valid operators, whether binary (including boolean) or unary (such as %)
@@ -2737,14 +2791,15 @@ class PHPExcel_Calculation {
);
// Convert infix to postfix notation
- private function _parseFormula($formula, PHPExcel_Cell $pCell = NULL) {
- if (($formula = $this->_convertMatrixReferences(trim($formula))) === FALSE) {
- return FALSE;
+ private function _parseFormula($formula, PHPExcel_Cell $pCell = null)
+ {
+ if (($formula = $this->_convertMatrixReferences(trim($formula))) === false) {
+ return false;
}
// If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
// so we store the parent worksheet so that we can re-attach it when necessary
- $pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
+ $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null;
$regexpMatchString = '/^('.self::CALCULATION_REGEXP_FUNCTION.
'|'.self::CALCULATION_REGEXP_CELLREF.
@@ -2759,16 +2814,16 @@ class PHPExcel_Calculation {
$index = 0;
$stack = new PHPExcel_Calculation_Token_Stack;
$output = array();
- $expectingOperator = FALSE; // We use this test in syntax-checking the expression to determine when a
+ $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
// - is a negation or + is a positive operator rather than an operation
- $expectingOperand = FALSE; // We use this test in syntax-checking the expression to determine whether an operand
+ $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand
// should be null in a function call
// The guts of the lexical parser
// Loop through the formula extracting each operator and operand in turn
- while(TRUE) {
-//echo 'Assessing Expression '.substr($formula, $index),PHP_EOL;
+ while (true) {
+//echo 'Assessing Expression '.substr($formula, $index), PHP_EOL;
$opCharacter = $formula{$index}; // Get the first character of the value at the current index position
-//echo 'Initial character of expression block is '.$opCharacter,PHP_EOL;
+//echo 'Initial character of expression block is '.$opCharacter, PHP_EOL;
if ((isset(self::$_comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$_comparisonOperators[$formula{$index+1}]))) {
$opCharacter .= $formula{++$index};
//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL;
@@ -2780,100 +2835,103 @@ class PHPExcel_Calculation {
//var_dump($match);
if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?
-//echo 'Element is a Negation operator',PHP_EOL;
- $stack->push('Unary Operator','~'); // Put a negation on the stack
+//echo 'Element is a Negation operator', PHP_EOL;
+ $stack->push('Unary Operator', '~'); // Put a negation on the stack
++$index; // and drop the negation symbol
} elseif ($opCharacter == '%' && $expectingOperator) {
-//echo 'Element is a Percentage operator',PHP_EOL;
- $stack->push('Unary Operator','%'); // Put a percentage on the stack
+//echo 'Element is a Percentage operator', PHP_EOL;
+ $stack->push('Unary Operator', '%'); // Put a percentage on the stack
++$index;
} elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded?
-//echo 'Element is a Positive number, not Plus operator',PHP_EOL;
+//echo 'Element is a Positive number, not Plus operator', PHP_EOL;
++$index; // Drop the redundant plus symbol
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
} elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
-//echo 'Element with value '.$opCharacter.' is an Operator',PHP_EOL;
- while($stack->count() > 0 &&
+//echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL;
+ while ($stack->count() > 0 &&
($o2 = $stack->last()) &&
isset(self::$_operators[$o2['value']]) &&
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
}
- $stack->push('Binary Operator',$opCharacter); // Finally put our current operator onto the stack
+ $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack
++$index;
- $expectingOperator = FALSE;
+ $expectingOperator = false;
} elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis?
-//echo 'Element is a Closing bracket',PHP_EOL;
- $expectingOperand = FALSE;
+//echo 'Element is a Closing bracket', PHP_EOL;
+ $expectingOperand = false;
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
- if ($o2 === NULL) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
- else $output[] = $o2;
+ if ($o2 === null) {
+ return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
+ } else {
+ $output[] = $o2;
+ }
}
$d = $stack->last(2);
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
$functionName = $matches[1]; // Get the function name
-//echo 'Closed Function is '.$functionName,PHP_EOL;
+//echo 'Closed Function is '.$functionName, PHP_EOL;
$d = $stack->pop();
$argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack)
//if ($argumentCount == 0) {
-// echo 'With no arguments',PHP_EOL;
+// echo 'With no arguments', PHP_EOL;
//} elseif ($argumentCount == 1) {
-// echo 'With 1 argument',PHP_EOL;
+// echo 'With 1 argument', PHP_EOL;
//} else {
-// echo 'With '.$argumentCount.' arguments',PHP_EOL;
+// echo 'With '.$argumentCount.' arguments', PHP_EOL;
//}
$output[] = $d; // Dump the argument count on the output
$output[] = $stack->pop(); // Pop the function and push onto the output
if (isset(self::$_controlFunctions[$functionName])) {
-//echo 'Built-in function '.$functionName,PHP_EOL;
+//echo 'Built-in function '.$functionName, PHP_EOL;
$expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
} elseif (isset(self::$_PHPExcelFunctions[$functionName])) {
-//echo 'PHPExcel function '.$functionName,PHP_EOL;
+//echo 'PHPExcel function '.$functionName, PHP_EOL;
$expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
} else { // did we somehow push a non-function on the stack? this should never happen
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
}
// Check the argument count
- $argumentCountError = FALSE;
+ $argumentCountError = false;
if (is_numeric($expectedArgumentCount)) {
if ($expectedArgumentCount < 0) {
-//echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount),PHP_EOL;
+//echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount), PHP_EOL;
if ($argumentCount > abs($expectedArgumentCount)) {
- $argumentCountError = TRUE;
+ $argumentCountError = true;
$expectedArgumentCountString = 'no more than '.abs($expectedArgumentCount);
}
} else {
-//echo '$expectedArgumentCount is numeric '.$expectedArgumentCount,PHP_EOL;
+//echo '$expectedArgumentCount is numeric '.$expectedArgumentCount, PHP_EOL;
if ($argumentCount != $expectedArgumentCount) {
- $argumentCountError = TRUE;
+ $argumentCountError = true;
$expectedArgumentCountString = $expectedArgumentCount;
}
}
} elseif ($expectedArgumentCount != '*') {
- $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch);
+ $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/', $expectedArgumentCount, $argMatch);
//print_r($argMatch);
//echo PHP_EOL;
switch ($argMatch[2]) {
- case '+' :
+ case '+':
if ($argumentCount < $argMatch[1]) {
- $argumentCountError = TRUE;
+ $argumentCountError = true;
$expectedArgumentCountString = $argMatch[1].' or more ';
}
break;
- case '-' :
+ case '-':
if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
- $argumentCountError = TRUE;
+ $argumentCountError = true;
$expectedArgumentCountString = 'between '.$argMatch[1].' and '.$argMatch[3];
}
break;
- case ',' :
+ case ',':
if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
- $argumentCountError = TRUE;
+ $argumentCountError = true;
$expectedArgumentCountString = 'either '.$argMatch[1].' or '.$argMatch[3];
}
break;
@@ -2886,25 +2944,29 @@ class PHPExcel_Calculation {
++$index;
} elseif ($opCharacter == ',') { // Is this the separator for function arguments?
-//echo 'Element is a Function argument separator',PHP_EOL;
+//echo 'Element is a Function argument separator', PHP_EOL;
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
- if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
- else $output[] = $o2; // pop the argument expression stuff and push onto the output
+ if ($o2 === null) {
+ return $this->_raiseFormulaError("Formula Error: Unexpected ,");
+ } else {
+ $output[] = $o2; // pop the argument expression stuff and push onto the output
+ }
}
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
// so push a null onto the stack
if (($expectingOperand) || (!$expectingOperator)) {
- $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
+ $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
}
// make sure there was a function
$d = $stack->last(2);
- if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches))
+ if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) {
return $this->_raiseFormulaError("Formula Error: Unexpected ,");
+ }
$d = $stack->pop();
- $stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count
+ $stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count
$stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again
- $expectingOperator = FALSE;
- $expectingOperand = TRUE;
+ $expectingOperator = false;
+ $expectingOperand = true;
++$index;
} elseif ($opCharacter == '(' && !$expectingOperator) {
@@ -2913,28 +2975,28 @@ class PHPExcel_Calculation {
++$index;
} elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number?
- $expectingOperator = TRUE;
- $expectingOperand = FALSE;
+ $expectingOperator = true;
+ $expectingOperand = false;
$val = $match[1];
$length = strlen($val);
// echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function
';
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
- $val = preg_replace('/\s/u','',$val);
+ $val = preg_replace('/\s/u', '', $val);
// echo 'Element '.$val.' is a Function
';
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function
$stack->push('Function', strtoupper($val));
$ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch);
if ($ax) {
$stack->push('Operand Count for Function '.strtoupper($val).')', 0);
- $expectingOperator = TRUE;
+ $expectingOperator = true;
} else {
$stack->push('Operand Count for Function '.strtoupper($val).')', 1);
- $expectingOperator = FALSE;
+ $expectingOperator = false;
}
$stack->push('Brace', '(');
} else { // it's a var w/ implicit multiplication
- $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => NULL);
+ $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => null);
}
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $val, $matches)) {
// echo 'Element '.$val.' is a Cell reference
';
@@ -2967,38 +3029,42 @@ class PHPExcel_Calculation {
if ($testPrevOp['value'] == ':') {
$startRowColRef = $output[count($output)-1]['value'];
$rangeWS1 = '';
- if (strpos('!',$startRowColRef) !== FALSE) {
- list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef);
+ if (strpos('!', $startRowColRef) !== false) {
+ list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef);
+ }
+ if ($rangeWS1 != '') {
+ $rangeWS1 .= '!';
}
- if ($rangeWS1 != '') $rangeWS1 .= '!';
$rangeWS2 = $rangeWS1;
- if (strpos('!',$val) !== FALSE) {
- list($rangeWS2,$val) = explode('!',$val);
+ if (strpos('!', $val) !== false) {
+ list($rangeWS2, $val) = explode('!', $val);
+ }
+ if ($rangeWS2 != '') {
+ $rangeWS2 .= '!';
}
- if ($rangeWS2 != '') $rangeWS2 .= '!';
if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)) {
// Row range
- $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
+ $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
$output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef;
$val = $rangeWS2.$endRowColRef.$val;
} elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
// Column range
- $endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
+ $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
$output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1';
$val = $rangeWS2.$val.$endRowColRef;
}
}
- $localeConstant = FALSE;
+ $localeConstant = false;
if ($opCharacter == '"') {
// echo 'Element is a String
';
// UnEscape any quotes within the string
- $val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val)));
+ $val = self::_wrapResult(str_replace('""', '"', self::_unwrapResult($val)));
} elseif (is_numeric($val)) {
// echo 'Element is a Number
';
- if ((strpos($val,'.') !== FALSE) || (stripos($val,'e') !== FALSE) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
+ if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
// echo 'Casting '.$val.' to float
';
$val = (float) $val;
} else {
@@ -3009,12 +3075,14 @@ class PHPExcel_Calculation {
$excelConstant = trim(strtoupper($val));
// echo 'Element '.$excelConstant.' is an Excel Constant
';
$val = self::$_ExcelConstants[$excelConstant];
- } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== FALSE) {
+ } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== false) {
// echo 'Element '.$localeConstant.' is an Excel Constant
';
$val = self::$_ExcelConstants[$localeConstant];
}
- $details = array('type' => 'Value', 'value' => $val, 'reference' => NULL);
- if ($localeConstant) { $details['localeValue'] = $localeConstant; }
+ $details = array('type' => 'Value', 'value' => $val, 'reference' => null);
+ if ($localeConstant) {
+ $details['localeValue'] = $localeConstant;
+ }
$output[] = $details;
}
$index += $length;
@@ -3023,9 +3091,9 @@ class PHPExcel_Calculation {
++$index;
} elseif ($opCharacter == ')') { // miscellaneous error checking
if ($expectingOperand) {
- $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
- $expectingOperand = FALSE;
- $expectingOperator = TRUE;
+ $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
+ $expectingOperand = false;
+ $expectingOperator = true;
} else {
return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
}
@@ -3058,31 +3126,32 @@ class PHPExcel_Calculation {
if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui', substr($formula, $index), $match)) &&
($output[count($output)-1]['type'] == 'Cell Reference')) {
// echo 'Element is an Intersect Operator
';
- while($stack->count() > 0 &&
+ while ($stack->count() > 0 &&
($o2 = $stack->last()) &&
isset(self::$_operators[$o2['value']]) &&
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
}
- $stack->push('Binary Operator','|'); // Put an Intersect Operator on the stack
- $expectingOperator = FALSE;
+ $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack
+ $expectingOperator = false;
}
}
}
- while (($op = $stack->pop()) !== NULL) { // pop everything off the stack and push onto output
- if ((is_array($op) && $op['value'] == '(') || ($op === '('))
+ while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output
+ if ((is_array($op) && $op['value'] == '(') || ($op === '(')) {
return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
+ }
$output[] = $op;
}
return $output;
- } // function _parseFormula()
+ }
private static function _dataTestReference(&$operandData)
{
$operand = $operandData['value'];
- if (($operandData['reference'] === NULL) && (is_array($operand))) {
+ if (($operandData['reference'] === null) && (is_array($operand))) {
$rKeys = array_keys($operand);
$rowKey = array_shift($rKeys);
$cKeys = array_keys(array_keys($operand[$rowKey]));
@@ -3095,13 +3164,16 @@ class PHPExcel_Calculation {
}
// evaluate postfix notation
- private function _processTokenStack($tokens, $cellID = NULL, PHPExcel_Cell $pCell = NULL) {
- if ($tokens == FALSE) return FALSE;
+ private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null)
+ {
+ if ($tokens == false) {
+ return false;
+ }
// If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent cell collection),
// so we store the parent cell collection so that we can re-attach it when necessary
- $pCellWorksheet = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
- $pCellParent = ($pCell !== NULL) ? $pCell->getParent() : null;
+ $pCellWorksheet = ($pCell !== null) ? $pCell->getWorksheet() : null;
+ $pCellParent = ($pCell !== null) ? $pCell->getParent() : null;
$stack = new PHPExcel_Calculation_Token_Stack;
// Loop through each token in turn
@@ -3114,8 +3186,12 @@ class PHPExcel_Calculation {
if (isset(self::$_binaryOperators[$token])) {
// echo 'Token is a binary operator
';
// We must have two operands, error if we don't
- if (($operand2Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
- if (($operand1Data = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ if (($operand2Data = $stack->pop()) === null) {
+ return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ }
+ if (($operand1Data = $stack->pop()) === null) {
+ return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ }
$operand1 = self::_dataTestReference($operand1Data);
$operand2 = self::_dataTestReference($operand2Data);
@@ -3130,29 +3206,29 @@ class PHPExcel_Calculation {
// Process the operation in the appropriate manner
switch ($token) {
// Comparison (Boolean) Operators
- case '>' : // Greater than
- case '<' : // Less than
- case '>=' : // Greater than or Equal to
- case '<=' : // Less than or Equal to
- case '=' : // Equality
- case '<>' : // Inequality
- $this->_executeBinaryComparisonOperation($cellID,$operand1,$operand2,$token,$stack);
+ case '>': // Greater than
+ case '<': // Less than
+ case '>=': // Greater than or Equal to
+ case '<=': // Less than or Equal to
+ case '=': // Equality
+ case '<>': // Inequality
+ $this->_executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);
break;
// Binary Operators
- case ':' : // Range
+ case ':': // Range
$sheet1 = $sheet2 = '';
- if (strpos($operand1Data['reference'],'!') !== FALSE) {
- list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']);
+ if (strpos($operand1Data['reference'], '!') !== false) {
+ list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']);
} else {
- $sheet1 = ($pCellParent !== NULL) ? $pCellWorksheet->getTitle() : '';
+ $sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : '';
}
- if (strpos($operand2Data['reference'],'!') !== FALSE) {
- list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']);
+ if (strpos($operand2Data['reference'], '!') !== false) {
+ list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']);
} else {
$sheet2 = $sheet1;
}
if ($sheet1 == $sheet2) {
- if ($operand1Data['reference'] === NULL) {
+ if ($operand1Data['reference'] === null) {
if ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) {
$operand1Data['reference'] = $pCell->getColumn().$operand1Data['value'];
} elseif (trim($operand1Data['reference']) == '') {
@@ -3161,7 +3237,7 @@ class PHPExcel_Calculation {
$operand1Data['reference'] = $operand1Data['value'].$pCell->getRow();
}
}
- if ($operand2Data['reference'] === NULL) {
+ if ($operand2Data['reference'] === null) {
if ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) {
$operand2Data['reference'] = $pCell->getColumn().$operand2Data['value'];
} elseif (trim($operand2Data['reference']) == '') {
@@ -3171,41 +3247,40 @@ class PHPExcel_Calculation {
}
}
- $oData = array_merge(explode(':',$operand1Data['reference']),explode(':',$operand2Data['reference']));
+ $oData = array_merge(explode(':', $operand1Data['reference']), explode(':', $operand2Data['reference']));
$oCol = $oRow = array();
- foreach($oData as $oDatum) {
+ foreach ($oData as $oDatum) {
$oCR = PHPExcel_Cell::coordinateFromString($oDatum);
$oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1;
$oRow[] = $oCR[1];
}
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
- if ($pCellParent !== NULL) {
- $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($sheet1), FALSE);
+ if ($pCellParent !== null) {
+ $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($sheet1), false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
}
- $stack->push('Cell Reference',$cellValue,$cellRef);
+ $stack->push('Cell Reference', $cellValue, $cellRef);
} else {
- $stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
+ $stack->push('Error', PHPExcel_Calculation_Functions::REF(), null);
}
-
break;
- case '+' : // Addition
- $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'plusEquals',$stack);
+ case '+': // Addition
+ $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'plusEquals', $stack);
break;
- case '-' : // Subtraction
- $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'minusEquals',$stack);
+ case '-': // Subtraction
+ $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'minusEquals', $stack);
break;
- case '*' : // Multiplication
- $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayTimesEquals',$stack);
+ case '*': // Multiplication
+ $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayTimesEquals', $stack);
break;
- case '/' : // Division
- $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayRightDivide',$stack);
+ case '/': // Division
+ $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'arrayRightDivide', $stack);
break;
- case '^' : // Exponential
- $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'power',$stack);
+ case '^': // Exponential
+ $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token, 'power', $stack);
break;
- case '&' : // Concatenation
+ case '&': // Concatenation
// If either of the operands is a matrix, we need to treat them both as matrices
// (converting the other operand to a matrix if need be); then perform the required
// matrix operation
@@ -3217,7 +3292,7 @@ class PHPExcel_Calculation {
}
if ((is_array($operand1)) || (is_array($operand2))) {
// Ensure that both operands are arrays/matrices
- self::_checkMatrixOperands($operand1,$operand2,2);
+ self::_checkMatrixOperands($operand1, $operand2, 2);
try {
// Convert operand 1 from a PHP array to a matrix
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
@@ -3229,31 +3304,33 @@ class PHPExcel_Calculation {
$result = '#VALUE!';
}
} else {
- $result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
+ $result = '"'.str_replace('""', '"', self::_unwrapResult($operand1, '"').self::_unwrapResult($operand2, '"')).'"';
}
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
- $stack->push('Value',$result);
+ $stack->push('Value', $result);
break;
- case '|' : // Intersect
- $rowIntersect = array_intersect_key($operand1,$operand2);
+ case '|': // Intersect
+ $rowIntersect = array_intersect_key($operand1, $operand2);
$cellIntersect = $oCol = $oRow = array();
- foreach(array_keys($rowIntersect) as $row) {
+ foreach (array_keys($rowIntersect) as $row) {
$oRow[] = $row;
- foreach($rowIntersect[$row] as $col => $data) {
+ foreach ($rowIntersect[$row] as $col => $data) {
$oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1;
- $cellIntersect[$row] = array_intersect_key($operand1[$row],$operand2[$row]);
+ $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]);
}
}
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($cellIntersect));
- $stack->push('Value',$cellIntersect,$cellRef);
+ $stack->push('Value', $cellIntersect, $cellRef);
break;
}
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
} elseif (($token === '~') || ($token === '%')) {
// echo 'Token is a unary operator
';
- if (($arg = $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ if (($arg = $stack->pop()) === null) {
+ return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
+ }
$arg = $arg['value'];
if ($token === '~') {
// echo 'Token is a negation operator
';
@@ -3265,7 +3342,7 @@ class PHPExcel_Calculation {
$multiplier = 0.01;
}
if (is_array($arg)) {
- self::_checkMatrixOperands($arg,$multiplier,2);
+ self::_checkMatrixOperands($arg, $multiplier, 2);
try {
$matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg);
$matrixResult = $matrix1->arrayTimesEquals($multiplier);
@@ -3275,32 +3352,32 @@ class PHPExcel_Calculation {
$result = '#VALUE!';
}
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
- $stack->push('Value',$result);
+ $stack->push('Value', $result);
} else {
- $this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack);
+ $this->_executeNumericBinaryOperation($cellID, $multiplier, $arg, '*', 'arrayTimesEquals', $stack);
}
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) {
- $cellRef = NULL;
+ $cellRef = null;
// echo 'Element '.$token.' is a Cell reference
';
if (isset($matches[8])) {
// echo 'Reference is a Range of cells
';
- if ($pCell === NULL) {
+ if ($pCell === null) {
// We can't access the range, so return a REF error
$cellValue = PHPExcel_Calculation_Functions::REF();
} else {
$cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10];
if ($matches[2] > '') {
- $matches[2] = trim($matches[2],"\"'");
- if ((strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) {
+ $matches[2] = trim($matches[2], "\"'");
+ if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) {
// It's a Reference to an external workbook (not currently supported)
return $this->_raiseFormulaError('Unable to access External Workbook');
}
- $matches[2] = trim($matches[2],"\"'");
+ $matches[2] = trim($matches[2], "\"'");
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
';
$this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in worksheet ', $matches[2]);
- if ($pCellParent !== NULL) {
- $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), FALSE);
+ if ($pCellParent !== null) {
+ $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
}
@@ -3309,8 +3386,8 @@ class PHPExcel_Calculation {
} else {
// echo '$cellRef='.$cellRef.' in current worksheet
';
$this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in current worksheet');
- if ($pCellParent !== NULL) {
- $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, FALSE);
+ if ($pCellParent !== null) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false);
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
}
@@ -3319,26 +3396,26 @@ class PHPExcel_Calculation {
}
} else {
// echo 'Reference is a single Cell
';
- if ($pCell === NULL) {
+ if ($pCell === null) {
// We can't access the cell, so return a REF error
$cellValue = PHPExcel_Calculation_Functions::REF();
} else {
$cellRef = $matches[6].$matches[7];
if ($matches[2] > '') {
- $matches[2] = trim($matches[2],"\"'");
- if ((strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) {
+ $matches[2] = trim($matches[2], "\"'");
+ if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) {
// It's a Reference to an external workbook (not currently supported)
return $this->_raiseFormulaError('Unable to access External Workbook');
}
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
';
$this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]);
- if ($pCellParent !== NULL) {
+ if ($pCellParent !== null) {
$cellSheet = $this->_workbook->getSheetByName($matches[2]);
if ($cellSheet && $cellSheet->cellExists($cellRef)) {
- $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), FALSE);
+ $cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), false);
$pCell->attach($pCellParent);
} else {
- $cellValue = NULL;
+ $cellValue = null;
}
} else {
return $this->_raiseFormulaError('Unable to access Cell Reference');
@@ -3349,16 +3426,16 @@ class PHPExcel_Calculation {
// echo '$cellRef='.$cellRef.' in current worksheet
';
$this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in current worksheet');
if ($pCellParent->isDataSet($cellRef)) {
- $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, FALSE);
+ $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false);
$pCell->attach($pCellParent);
} else {
- $cellValue = NULL;
+ $cellValue = null;
}
$this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' is ', $this->_showTypeDetails($cellValue));
}
}
}
- $stack->push('Value',$cellValue,$cellRef);
+ $stack->push('Value', $cellValue, $cellRef);
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) {
@@ -3388,16 +3465,22 @@ class PHPExcel_Calculation {
if (($passByReference) &&
(isset(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
- if ($arg['reference'] === NULL) {
+ if ($arg['reference'] === null) {
$args[] = $cellID;
- if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($cellID); }
+ if ($functionName != 'MKMATRIX') {
+ $argArrayVals[] = $this->_showValue($cellID);
+ }
} else {
$args[] = $arg['reference'];
- if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['reference']); }
+ if ($functionName != 'MKMATRIX') {
+ $argArrayVals[] = $this->_showValue($arg['reference']);
+ }
}
} else {
$args[] = self::_unwrapResult($arg['value']);
- if ($functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['value']); }
+ if ($functionName != 'MKMATRIX') {
+ $argArrayVals[] = $this->_showValue($arg['value']);
+ }
}
}
// Reverse the order of the arguments
@@ -3412,7 +3495,7 @@ class PHPExcel_Calculation {
if ($functionName != 'MKMATRIX') {
if ($this->_debugLog->getWriteDebugLog()) {
krsort($argArrayVals);
- $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', implode(self::$_localeArgumentSeparator.' ',PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )');
+ $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', implode(self::$_localeArgumentSeparator.' ', PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )');
}
}
// Process each argument in turn, building the return value as an array
@@ -3425,37 +3508,36 @@ class PHPExcel_Calculation {
// if (is_array($args)) {
// foreach($args as $arg) {
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )');
-// $r = call_user_func_array($functionCall,$arg);
+// $r = call_user_func_array($functionCall, $arg);
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
// $result[$row][] = $r;
// }
// ++$row;
// } else {
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )');
-// $r = call_user_func_array($functionCall,$args);
+// $r = call_user_func_array($functionCall, $args);
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
// $result[] = $r;
// }
// }
// } else {
// Process the argument with the appropriate function call
- if ($passCellReference) {
- $args[] = $pCell;
+ if ($passCellReference) {
+ $args[] = $pCell;
+ }
+ if (strpos($functionCall, '::') !== false) {
+ $result = call_user_func_array(explode('::', $functionCall), $args);
+ } else {
+ foreach ($args as &$arg) {
+ $arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg);
}
- if (strpos($functionCall,'::') !== FALSE) {
- $result = call_user_func_array(explode('::',$functionCall),$args);
- } else {
- foreach($args as &$arg) {
- $arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg);
- }
- unset($arg);
- $result = call_user_func_array($functionCall,$args);
- }
-// }
+ unset($arg);
+ $result = call_user_func_array($functionCall, $args);
+ }
if ($functionName != 'MKMATRIX') {
$this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($result));
}
- $stack->push('Value',self::_wrapResult($result));
+ $stack->push('Value', self::_wrapResult($result));
}
} else {
@@ -3463,28 +3545,30 @@ class PHPExcel_Calculation {
if (isset(self::$_ExcelConstants[strtoupper($token)])) {
$excelConstant = strtoupper($token);
// echo 'Token is a PHPExcel constant: '.$excelConstant.'
';
- $stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
+ $stack->push('Constant Value', self::$_ExcelConstants[$excelConstant]);
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
- } elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
+ } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
// echo 'Token is a number, boolean, string, null or an Excel error
';
- $stack->push('Value',$token);
+ $stack->push('Value', $token);
// if the token is a named range, push the named range name onto the stack
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) {
// echo 'Token is a named range
';
$namedRange = $matches[6];
// echo 'Named Range is '.$namedRange.'
';
$this->_debugLog->writeDebugLog('Evaluating Named Range ', $namedRange);
- $cellValue = $this->extractNamedRange($namedRange, ((NULL !== $pCell) ? $pCellWorksheet : NULL), FALSE);
+ $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellWorksheet : null), false);
$pCell->attach($pCellParent);
$this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->_showTypeDetails($cellValue));
- $stack->push('Named Range',$cellValue,$namedRange);
+ $stack->push('Named Range', $cellValue, $namedRange);
} else {
return $this->_raiseFormulaError("undefined variable '$token'");
}
}
}
// when we're out of tokens, the stack should have a single element, the final result
- if ($stack->count() != 1) return $this->_raiseFormulaError("internal error");
+ if ($stack->count() != 1) {
+ return $this->_raiseFormulaError("internal error");
+ }
$output = $stack->pop();
$output = $output['value'];
@@ -3492,10 +3576,11 @@ class PHPExcel_Calculation {
// return array_shift(PHPExcel_Calculation_Functions::flattenArray($output));
// }
return $output;
- } // function _processTokenStack()
+ }
- private function _validateBinaryOperand($cellID, &$operand, &$stack) {
+ private function _validateBinaryOperand($cellID, &$operand, &$stack)
+ {
if (is_array($operand)) {
if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) {
do {
@@ -3507,51 +3592,56 @@ class PHPExcel_Calculation {
if (is_string($operand)) {
// We only need special validations for the operand if it is a string
// Start by stripping off the quotation marks we use to identify true excel string values internally
- if ($operand > '' && $operand{0} == '"') { $operand = self::_unwrapResult($operand); }
+ if ($operand > '' && $operand{0} == '"') {
+ $operand = self::_unwrapResult($operand);
+ }
// If the string is a numeric value, we treat it as a numeric, so no further testing
if (!is_numeric($operand)) {
// If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
if ($operand > '' && $operand{0} == '#') {
$stack->push('Value', $operand);
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($operand));
- return FALSE;
+ return false;
} elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
// If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
$stack->push('Value', '#VALUE!');
$this->_debugLog->writeDebugLog('Evaluation Result is a ', $this->_showTypeDetails('#VALUE!'));
- return FALSE;
+ return false;
}
}
}
// return a true if the value of the operand is one that we can use in normal binary operations
- return TRUE;
- } // function _validateBinaryOperand()
+ return true;
+ }
- private function _executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays=FALSE) {
+ private function _executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false)
+ {
// If we're dealing with matrix operations, we want a matrix result
if ((is_array($operand1)) || (is_array($operand2))) {
$result = array();
if ((is_array($operand1)) && (!is_array($operand2))) {
- foreach($operand1 as $x => $operandData) {
+ foreach ($operand1 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2));
- $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
+ $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2, $operation, $stack);
$r = $stack->pop();
$result[$x] = $r['value'];
}
} elseif ((!is_array($operand1)) && (is_array($operand2))) {
- foreach($operand2 as $x => $operandData) {
+ foreach ($operand2 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operand1), ' ', $operation, ' ', $this->_showValue($operandData));
- $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
+ $this->_executeBinaryComparisonOperation($cellID, $operand1, $operandData, $operation, $stack);
$r = $stack->pop();
$result[$x] = $r['value'];
}
} else {
- if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
- foreach($operand1 as $x => $operandData) {
+ if (!$recursingArrays) {
+ self::_checkMatrixOperands($operand1, $operand2, 2);
+ }
+ foreach ($operand1 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2[$x]));
- $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,TRUE);
+ $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2[$x], $operation, $stack, true);
$r = $stack->pop();
$result[$x] = $r['value'];
}
@@ -3559,21 +3649,23 @@ class PHPExcel_Calculation {
// Log the result details
$this->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack
- $stack->push('Array',$result);
- return TRUE;
+ $stack->push('Array', $result);
+ return true;
}
// Simple validate the two operands if they are string values
- if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') { $operand1 = self::_unwrapResult($operand1); }
- if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') { $operand2 = self::_unwrapResult($operand2); }
+ if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') {
+ $operand1 = self::_unwrapResult($operand1);
+ }
+ if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') {
+ $operand2 = self::_unwrapResult($operand2);
+ }
// Use case insensitive comparaison if not OpenOffice mode
- if (PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE)
- {
+ if (PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
if (is_string($operand1)) {
$operand1 = strtoupper($operand1);
}
-
if (is_string($operand2)) {
$operand2 = strtoupper($operand2);
}
@@ -3640,7 +3732,7 @@ class PHPExcel_Calculation {
// Log the result details
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack
- $stack->push('Value',$result);
+ $stack->push('Value', $result);
return true;
}
@@ -3658,10 +3750,15 @@ class PHPExcel_Calculation {
return strcmp($inversedStr1, $inversedStr2);
}
- private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) {
+ private function _executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction, &$stack)
+ {
// Validate the two operands
- if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE;
- if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE;
+ if (!$this->_validateBinaryOperand($cellID, $operand1, $stack)) {
+ return false;
+ }
+ if (!$this->_validateBinaryOperand($cellID, $operand2, $stack)) {
+ return false;
+ }
// If either of the operands is a matrix, we need to treat them both as matrices
// (converting the other operand to a matrix if need be); then perform the required
@@ -3682,7 +3779,7 @@ class PHPExcel_Calculation {
}
} else {
if ((PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) &&
- ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1)>0) ||
+ ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1)>0) ||
(is_string($operand2) && !is_numeric($operand2) && strlen($operand2)>0))) {
$result = PHPExcel_Calculation_Functions::VALUE();
} else {
@@ -3704,9 +3801,9 @@ class PHPExcel_Calculation {
case '/':
if ($operand2 == 0) {
// Trap for Divide by Zero error
- $stack->push('Value','#DIV/0!');
+ $stack->push('Value', '#DIV/0!');
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails('#DIV/0!'));
- return FALSE;
+ return false;
} else {
$result = $operand1 / $operand2;
}
@@ -3722,18 +3819,21 @@ class PHPExcel_Calculation {
// Log the result details
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack
- $stack->push('Value',$result);
- return TRUE;
- } // function _executeNumericBinaryOperation()
+ $stack->push('Value', $result);
+ return true;
+ }
// trigger an error, but nicely, if need be
- protected function _raiseFormulaError($errorMessage) {
+ protected function _raiseFormulaError($errorMessage)
+ {
$this->formulaError = $errorMessage;
$this->_cyclicReferenceStack->clear();
- if (!$this->suppressFormulaErrors) throw new PHPExcel_Calculation_Exception($errorMessage);
+ if (!$this->suppressFormulaErrors) {
+ throw new PHPExcel_Calculation_Exception($errorMessage);
+ }
trigger_error($errorMessage, E_USER_ERROR);
- } // function _raiseFormulaError()
+ }
/**
@@ -3745,20 +3845,21 @@ class PHPExcel_Calculation {
* @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
* @throws PHPExcel_Calculation_Exception
*/
- public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = NULL, $resetLog = TRUE) {
+ public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true)
+ {
// Return value
$returnValue = array ();
-// echo 'extractCellRange('.$pRange.')',PHP_EOL;
- if ($pSheet !== NULL) {
+// echo 'extractCellRange('.$pRange.')', PHP_EOL;
+ if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle();
// echo 'Passed sheet name is '.$pSheetName.PHP_EOL;
// echo 'Range reference is '.$pRange.PHP_EOL;
- if (strpos ($pRange, '!') !== false) {
-// echo '$pRange reference includes sheet reference',PHP_EOL;
- list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
-// echo 'New sheet name is '.$pSheetName,PHP_EOL;
-// echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
+ if (strpos($pRange, '!') !== false) {
+// echo '$pRange reference includes sheet reference', PHP_EOL;
+ list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
+// echo 'New sheet name is '.$pSheetName, PHP_EOL;
+// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
$pSheet = $this->_workbook->getSheetByName($pSheetName);
}
@@ -3767,31 +3868,30 @@ class PHPExcel_Calculation {
$pRange = $pSheetName.'!'.$pRange;
if (!isset($aReferences[1])) {
// Single cell in range
- sscanf($aReferences[0],'%[A-Z]%d', $currentCol, $currentRow);
- $cellValue = NULL;
+ sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow);
+ $cellValue = null;
if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
} else {
- $returnValue[$currentRow][$currentCol] = NULL;
+ $returnValue[$currentRow][$currentCol] = null;
}
} else {
// Extract cell data for all cells in the range
foreach ($aReferences as $reference) {
// Extract range
- sscanf($reference,'%[A-Z]%d', $currentCol, $currentRow);
- $cellValue = NULL;
+ sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow);
+ $cellValue = null;
if ($pSheet->cellExists($reference)) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
} else {
- $returnValue[$currentRow][$currentCol] = NULL;
+ $returnValue[$currentRow][$currentCol] = null;
}
}
}
}
- // Return
return $returnValue;
- } // function extractCellRange()
+ }
/**
@@ -3803,26 +3903,27 @@ class PHPExcel_Calculation {
* @param boolean $resetLog Flag indicating whether calculation log should be reset or not
* @throws PHPExcel_Calculation_Exception
*/
- public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = NULL, $resetLog = TRUE) {
+ public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog = true)
+ {
// Return value
$returnValue = array ();
// echo 'extractNamedRange('.$pRange.')
';
- if ($pSheet !== NULL) {
+ if ($pSheet !== null) {
$pSheetName = $pSheet->getTitle();
// echo 'Current sheet name is '.$pSheetName.'
';
// echo 'Range reference is '.$pRange.'
';
- if (strpos ($pRange, '!') !== false) {
-// echo '$pRange reference includes sheet reference',PHP_EOL;
- list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
-// echo 'New sheet name is '.$pSheetName,PHP_EOL;
-// echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
+ if (strpos($pRange, '!') !== false) {
+// echo '$pRange reference includes sheet reference', PHP_EOL;
+ list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
+// echo 'New sheet name is '.$pSheetName, PHP_EOL;
+// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
$pSheet = $this->_workbook->getSheetByName($pSheetName);
}
// Named range?
$namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
- if ($namedRange !== NULL) {
+ if ($namedRange !== null) {
$pSheet = $namedRange->getWorksheet();
// echo 'Named Range '.$pRange.' (';
$pRange = $namedRange->getRange();
@@ -3830,7 +3931,7 @@ class PHPExcel_Calculation {
// Convert row and column references
if (ctype_alpha($splitRange[0][0])) {
$pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
- } elseif(ctype_digit($splitRange[0][0])) {
+ } elseif (ctype_digit($splitRange[0][0])) {
$pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
}
// echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'
';
@@ -3851,24 +3952,24 @@ class PHPExcel_Calculation {
// var_dump($aReferences);
if (!isset($aReferences[1])) {
// Single cell (or single column or row) in range
- list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
- $cellValue = NULL;
+ list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
+ $cellValue = null;
if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
} else {
- $returnValue[$currentRow][$currentCol] = NULL;
+ $returnValue[$currentRow][$currentCol] = null;
}
} else {
// Extract cell data for all cells in the range
foreach ($aReferences as $reference) {
// Extract range
- list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
+ list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
// echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'
';
- $cellValue = NULL;
+ $cellValue = null;
if ($pSheet->cellExists($reference)) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
} else {
- $returnValue[$currentRow][$currentCol] = NULL;
+ $returnValue[$currentRow][$currentCol] = null;
}
}
}
@@ -3876,9 +3977,8 @@ class PHPExcel_Calculation {
// echo '
';
}
- // Return
return $returnValue;
- } // function extractNamedRange()
+ }
/**
@@ -3887,14 +3987,15 @@ class PHPExcel_Calculation {
* @param string $pFunction Function Name
* @return boolean
*/
- public function isImplemented($pFunction = '') {
- $pFunction = strtoupper ($pFunction);
+ public function isImplemented($pFunction = '')
+ {
+ $pFunction = strtoupper($pFunction);
if (isset(self::$_PHPExcelFunctions[$pFunction])) {
return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
} else {
- return FALSE;
+ return false;
}
- } // function isImplemented()
+ }
/**
@@ -3902,22 +4003,22 @@ class PHPExcel_Calculation {
*
* @return array of PHPExcel_Calculation_Function
*/
- public function listFunctions() {
- // Return value
+ public function listFunctions()
+ {
$returnValue = array();
- // Loop functions
- foreach(self::$_PHPExcelFunctions as $functionName => $function) {
+
+ foreach (self::$_PHPExcelFunctions as $functionName => $function) {
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
- $returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'],
- $functionName,
- $function['functionCall']
- );
+ $returnValue[$functionName] = new PHPExcel_Calculation_Function(
+ $function['category'],
+ $functionName,
+ $function['functionCall']
+ );
}
}
- // Return
return $returnValue;
- } // function listFunctions()
+ }
/**
@@ -3925,27 +4026,25 @@ class PHPExcel_Calculation {
*
* @return array
*/
- public function listAllFunctionNames() {
+ public function listAllFunctionNames()
+ {
return array_keys(self::$_PHPExcelFunctions);
- } // function listAllFunctionNames()
+ }
/**
* Get a list of implemented Excel function names
*
* @return array
*/
- public function listFunctionNames() {
- // Return value
+ public function listFunctionNames()
+ {
$returnValue = array();
- // Loop functions
- foreach(self::$_PHPExcelFunctions as $functionName => $function) {
+ foreach (self::$_PHPExcelFunctions as $functionName => $function) {
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
$returnValue[] = $functionName;
}
}
- // Return
return $returnValue;
- } // function listFunctionNames()
-
-} // class PHPExcel_Calculation
+ }
+}
diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php
index 4ca7e532..5250cba5 100644
--- a/Classes/PHPExcel/Cell.php
+++ b/Classes/PHPExcel/Cell.php
@@ -585,7 +585,7 @@ class PHPExcel_Cell
{
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]);
- } elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) {
+ } elseif ((strpos($pCoordinateString, ':') !== false) || (strpos($pCoordinateString, ',') !== false)) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
@@ -868,7 +868,7 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) {
// Single cell?
- if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
+ if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) {
$returnValue[] = $cellBlock;
continue;
}
diff --git a/Classes/PHPExcel/Chart/Axis.php b/Classes/PHPExcel/Chart/Axis.php
index 8b5d1d54..b032bf4b 100644
--- a/Classes/PHPExcel/Chart/Axis.php
+++ b/Classes/PHPExcel/Chart/Axis.php
@@ -179,8 +179,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
{
$this->_axis_options['axis_labels'] = (string) $axis_labels;
- ($horizontal_crosses_value !== null)
- ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
+ ($horizontal_crosses_value !== null) ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
($horizontal_crosses !== null) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== null) ? $this->_axis_options['orientation'] = (string) $axis_orientation : null;
($major_tmt !== null) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : null;
@@ -265,306 +264,282 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
return $this->_line_properties[$property];
}
- /**
- * Set Line Style Properties
- *
- * @param float $line_width
- * @param string $compound_type
- * @param string $dash_type
- * @param string $cap_type
- * @param string $join_type
- * @param string $head_arrow_type
- * @param string $head_arrow_size
- * @param string $end_arrow_type
- * @param string $end_arrow_size
- *
- */
+ /**
+ * Set Line Style Properties
+ *
+ * @param float $line_width
+ * @param string $compound_type
+ * @param string $dash_type
+ * @param string $cap_type
+ * @param string $join_type
+ * @param string $head_arrow_type
+ * @param string $head_arrow_size
+ * @param string $end_arrow_type
+ * @param string $end_arrow_size
+ *
+ */
+ public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) {
+ (!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
+ (!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : null;
+ (!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : null;
+ (!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : null;
+ (!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : null;
+ (!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type : null;
+ (!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size : null;
+ (!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type : null;
+ (!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size : null;
+ }
- public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) {
- (!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width)
- : null;
- (!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : null;
- (!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : null;
- (!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : null;
- (!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : null;
- (!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type
- : null;
- (!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size
- : null;
- (!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type
- : null;
- (!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size
- : null;
- }
+ /**
+ * Get Line Style Property
+ *
+ * @param array|string $elements
+ *
+ * @return string
+ */
+ public function getLineStyleProperty($elements)
+ {
+ return $this->getArrayElementsValue($this->_line_style_properties, $elements);
+ }
- /**
- * Get Line Style Property
- *
- * @param array|string $elements
- *
- * @return string
- */
+ /**
+ * Get Line Style Arrow Excel Width
+ *
+ * @param string $arrow
+ *
+ * @return string
+ */
+ public function getLineStyleArrowWidth($arrow)
+ {
+ return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
+ }
- public function getLineStyleProperty($elements)
- {
- return $this->getArrayElementsValue($this->_line_style_properties, $elements);
- }
+ /**
+ * Get Line Style Arrow Excel Length
+ *
+ * @param string $arrow
+ *
+ * @return string
+ */
+ public function getLineStyleArrowLength($arrow)
+ {
+ return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
+ }
- /**
- * Get Line Style Arrow Excel Width
- *
- * @param string $arrow
- *
- * @return string
- */
+ /**
+ * Set Shadow Properties
+ *
+ * @param int $shadow_presets
+ * @param string $sh_color_value
+ * @param string $sh_color_type
+ * @param string $sh_color_alpha
+ * @param float $sh_blur
+ * @param int $sh_angle
+ * @param float $sh_distance
+ *
+ */
+ public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) {
+ $this->_setShadowPresetsProperties((int) $sh_presets)
+ ->_setShadowColor(
+ is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
+ , is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
+ , is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
+ ->_setShadowBlur($sh_blur)
+ ->_setShadowAngle($sh_angle)
+ ->_setShadowDistance($sh_distance);
+ }
- public function getLineStyleArrowWidth($arrow)
- {
- return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
- }
+ /**
+ * Set Shadow Color
+ *
+ * @param int $shadow_presets
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowPresetsProperties($shadow_presets) {
+ $this->_shadow_properties['presets'] = $shadow_presets;
+ $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
- /**
- * Get Line Style Arrow Excel Length
- *
- * @param string $arrow
- *
- * @return string
- */
+ return $this;
+ }
- public function getLineStyleArrowLength($arrow)
- {
- return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
- }
-
- /**
- * Set Shadow Properties
- *
- * @param int $shadow_presets
- * @param string $sh_color_value
- * @param string $sh_color_type
- * @param string $sh_color_alpha
- * @param float $sh_blur
- * @param int $sh_angle
- * @param float $sh_distance
- *
- */
-
- public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) {
- $this
- ->_setShadowPresetsProperties((int) $sh_presets)
- ->_setShadowColor(
- is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
- , is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
- , is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
- ->_setShadowBlur($sh_blur)
- ->_setShadowAngle($sh_angle)
- ->_setShadowDistance($sh_distance);
- }
-
- /**
- * Set Shadow Color
- *
- * @param int $shadow_presets
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowPresetsProperties($shadow_presets) {
- $this->_shadow_properties['presets'] = $shadow_presets;
- $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
-
- return $this;
- }
-
- /**
- * Set Shadow Properties from Maped Values
- *
- * @param array $properties_map
- * @param * $reference
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) {
- $base_reference = $reference;
- foreach ($properties_map as $property_key => $property_val) {
- if (is_array($property_val)) {
- if ($reference === null) {
- $reference = & $this->_shadow_properties[$property_key];
- } else {
- $reference = & $reference[$property_key];
+ /**
+ * Set Shadow Properties from Maped Values
+ *
+ * @param array $properties_map
+ * @param * $reference
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) {
+ $base_reference = $reference;
+ foreach ($properties_map as $property_key => $property_val) {
+ if (is_array($property_val)) {
+ if ($reference === null) {
+ $reference = & $this->_shadow_properties[$property_key];
+ } else {
+ $reference = & $reference[$property_key];
+ }
+ $this->_setShadowProperiesMapValues($property_val, $reference);
+ } else {
+ if ($base_reference === null) {
+ $this->_shadow_properties[$property_key] = $property_val;
+ } else {
+ $reference[$property_key] = $property_val;
+ }
+ }
}
- $this->_setShadowProperiesMapValues($property_val, $reference);
- } else {
- if ($base_reference === null) {
- $this->_shadow_properties[$property_key] = $property_val;
- } else {
- $reference[$property_key] = $property_val;
+
+ return $this;
+ }
+
+ /**
+ * Set Shadow Color
+ *
+ * @param string $color
+ * @param int $alpha
+ * @param string $type
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowColor($color, $alpha, $type) {
+ $this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
+
+ return $this;
+ }
+
+ /**
+ * Set Shadow Blur
+ *
+ * @param float $blur
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowBlur($blur) {
+ if ($blur !== null) {
+ $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
- }
+
+ return $this;
}
- return $this;
- }
+ /**
+ * Set Shadow Angle
+ *
+ * @param int $angle
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowAngle($angle) {
+ if ($angle !== null) {
+ $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
+ }
- /**
- * Set Shadow Color
- *
- * @param string $color
- * @param int $alpha
- * @param string $type
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowColor($color, $alpha, $type) {
- $this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
-
- return $this;
- }
-
- /**
- * Set Shadow Blur
- *
- * @param float $blur
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowBlur($blur) {
- if ($blur !== null) {
- $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
+ return $this;
}
- return $this;
- }
+ /**
+ * Set Shadow Distance
+ *
+ * @param float $distance
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setShadowDistance($distance) {
+ if ($distance !== null) {
+ $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
+ }
- /**
- * Set Shadow Angle
- *
- * @param int $angle
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowAngle($angle) {
- if ($angle !== null) {
- $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
+ return $this;
}
- return $this;
- }
-
- /**
- * Set Shadow Distance
- *
- * @param float $distance
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setShadowDistance($distance) {
- if ($distance !== null) {
- $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
+ /**
+ * Get Glow Property
+ *
+ * @param float $size
+ * @param string $color_value
+ * @param int $color_alpha
+ * @param string $color_type
+ */
+ public function getShadowProperty($elements) {
+ return $this->getArrayElementsValue($this->_shadow_properties, $elements);
}
- return $this;
- }
-
- /**
- * Get Glow Property
- *
- * @param float $size
- * @param string $color_value
- * @param int $color_alpha
- * @param string $color_type
- */
-
- public function getShadowProperty($elements) {
- return $this->getArrayElementsValue($this->_shadow_properties, $elements);
- }
-
- /**
- * Set Glow Properties
- *
- * @param float $size
- * @param string $color_value
- * @param int $color_alpha
- * @param string $color_type
- */
-
- public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) {
- $this
- ->_setGlowSize($size)
- ->_setGlowColor(
- is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
- , is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
- , is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type);
- }
-
- /**
- * Get Glow Property
- *
- * @param array|string $property
- *
- * @return string
- */
-
- public function getGlowProperty($property) {
- return $this->getArrayElementsValue($this->_glow_properties, $property);
- }
-
- /**
- * Set Glow Color
- *
- * @param float $size
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setGlowSize($size) {
- if (!is_null($size)) {
- $this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
+ /**
+ * Set Glow Properties
+ *
+ * @param float $size
+ * @param string $color_value
+ * @param int $color_alpha
+ * @param string $color_type
+ */
+ public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) {
+ $this->_setGlowSize($size)
+ ->_setGlowColor(
+ is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
+ , is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
+ , is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type
+ );
}
- return $this;
- }
-
- /**
- * Set Glow Color
- *
- * @param string $color
- * @param int $alpha
- * @param string $type
- *
- * @return PHPExcel_Chart_Axis
- */
-
- private function _setGlowColor($color, $alpha, $type) {
- $this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
-
- return $this;
- }
-
- /**
- * Set Soft Edges Size
- *
- * @param float $size
- */
-
- public function setSoftEdges($size) {
- if (!is_null($size)) {
- $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
+ /**
+ * Get Glow Property
+ *
+ * @param array|string $property
+ *
+ * @return string
+ */
+ public function getGlowProperty($property) {
+ return $this->getArrayElementsValue($this->_glow_properties, $property);
}
- }
- /**
- * Get Soft Edges Size
- *
- * @return string
- */
+ /**
+ * Set Glow Color
+ *
+ * @param float $size
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setGlowSize($size) {
+ if (!is_null($size)) {
+ $this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
+ }
- public function getSoftEdgesSize() {
- return $this->_soft_edges['size'];
- }
-}
\ No newline at end of file
+ return $this;
+ }
+
+ /**
+ * Set Glow Color
+ *
+ * @param string $color
+ * @param int $alpha
+ * @param string $type
+ *
+ * @return PHPExcel_Chart_Axis
+ */
+ private function _setGlowColor($color, $alpha, $type) {
+ $this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
+
+ return $this;
+ }
+
+ /**
+ * Set Soft Edges Size
+ *
+ * @param float $size
+ */
+ public function setSoftEdges($size) {
+ if (!is_null($size)) {
+ $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
+ }
+ }
+
+ /**
+ * Get Soft Edges Size
+ *
+ * @return string
+ */
+ public function getSoftEdgesSize() {
+ return $this->_soft_edges['size'];
+ }
+}
diff --git a/Classes/PHPExcel/Chart/DataSeries.php b/Classes/PHPExcel/Chart/DataSeries.php
index c5ddc095..617c8a91 100644
--- a/Classes/PHPExcel/Chart/DataSeries.php
+++ b/Classes/PHPExcel/Chart/DataSeries.php
@@ -371,21 +371,20 @@ class PHPExcel_Chart_DataSeries
public function refresh(PHPExcel_Worksheet $worksheet)
{
- foreach($this->_plotValues as $plotValues) {
+ foreach ($this->_plotValues as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, true);
}
}
- foreach($this->_plotLabel as $plotValues) {
+ foreach ($this->_plotLabel as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, true);
}
}
- foreach($this->_plotCategory as $plotValues) {
+ foreach ($this->_plotCategory as $plotValues) {
if ($plotValues !== null) {
$plotValues->refresh($worksheet, false);
}
}
}
-
}