From 21cce674c8866131f5bc3263eedea1fb2ff95a94 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 17 Jan 2012 21:57:06 +0000 Subject: [PATCH] Fix to inappropriate replacement of count() with empty().... there may be others I've not spotted yet. Improved debuglog in calculation engine. git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85403 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Calculation.php | 14 ++++++++------ Classes/PHPExcel/ReferenceHelper.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index df6c68b..78dbe43 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -2504,13 +2504,15 @@ class PHPExcel_Calculation { $pad = $rpad = ', '; foreach($value as $row) { if (is_array($row)) { - $returnMatrix[] = implode($pad,$row); + $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row)); $rpad = '; '; } else { - $returnMatrix[] = $row; + $returnMatrix[] = $this->_showValue($row); } } return '{ '.implode($rpad,$returnMatrix).' }'; + } elseif(is_string($value) && (trim($value,'"') == $value)) { + return '"'.$value.'"'; } elseif(is_bool($value)) { return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE']; } @@ -3428,14 +3430,14 @@ class PHPExcel_Calculation { $result = array(); if ((is_array($operand1)) && (!is_array($operand2))) { foreach($operand1 as $x => $operandData) { - $this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2)); + $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2)); $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) { - $this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData)); + $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData)); $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack); $r = $stack->pop(); $result[$x] = $r['value']; @@ -3443,14 +3445,14 @@ class PHPExcel_Calculation { } else { if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); } foreach($operand1 as $x => $operandData) { - $this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x])); + $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x])); $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true); $r = $stack->pop(); $result[$x] = $r['value']; } } // Log the result details - $this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); + $this->_writeDebug('Comparison Evaluation Result is '.$this->_showTypeDetails($result)); // And push the result onto the stack $stack->push('Array',$result); return true; diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 8f006d4..e4c091a 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -340,7 +340,7 @@ class PHPExcel_ReferenceHelper // Update workbook: named ranges - if (!empty($pSheet->getParent()->getNamedRanges())) { + if (count($pSheet->getParent()->getNamedRanges()) > 0) { foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) { if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) { $namedRange->setRange(