|
|
|
|
@ -181,8 +181,8 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
// embeds are doubled
|
|
|
|
|
// end marks token
|
|
|
|
|
if ($inString) {
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
|
|
|
|
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
|
|
|
|
if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
|
|
|
|
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
|
|
|
|
++$index;
|
|
|
|
|
} else {
|
|
|
|
|
@ -191,7 +191,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
$value = "";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
}
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
@ -201,15 +201,15 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
// embeds are double
|
|
|
|
|
// end does not mark a token
|
|
|
|
|
if ($inPath) {
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
|
|
|
|
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
|
|
|
|
if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
|
|
|
|
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
|
|
|
|
++$index;
|
|
|
|
|
} else {
|
|
|
|
|
$inPath = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
}
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
@ -219,10 +219,10 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
// no embeds (changed to "()" by Excel)
|
|
|
|
|
// end does not mark a token
|
|
|
|
|
if ($inRange) {
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
|
|
|
|
$inRange = false;
|
|
|
|
|
}
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
@ -230,7 +230,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
// error values
|
|
|
|
|
// end marks a token, determined from absolute list of values
|
|
|
|
|
if ($inError) {
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
++$index;
|
|
|
|
|
if (in_array($value, $ERRORS)) {
|
|
|
|
|
$inError = false;
|
|
|
|
|
@ -241,10 +241,10 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scientific notation check
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula{$index}) !== false) {
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula[$index]) !== false) {
|
|
|
|
|
if (strlen($value) > 1) {
|
|
|
|
|
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula[$index]) != 0) {
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
@ -254,7 +254,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
// independent character evaluation (order not important)
|
|
|
|
|
|
|
|
|
|
// establish state-dependent character evaluations
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
|
|
|
|
if (strlen($value > 0)) {
|
|
|
|
|
// unexpected
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
|
|
|
|
@ -265,7 +265,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
// unexpected
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
|
|
|
|
@ -276,14 +276,14 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
|
|
|
|
$inRange = true;
|
|
|
|
|
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
// unexpected
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
|
|
|
|
@ -296,7 +296,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mark start and end of arrays and array rows
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
// unexpected
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
|
|
|
|
@ -315,7 +315,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
@ -337,7 +337,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
@ -358,14 +358,14 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// trim white-space
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
}
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
|
|
|
|
++$index;
|
|
|
|
|
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
|
|
|
|
while (($this->formula[$index] == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
|
|
|
|
++$index;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
@ -385,29 +385,29 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// standard infix operators
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula{$index}) !== false) {
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula[$index]) !== false) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
}
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula[$index], PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// standard postfix operators (only one)
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
|
|
|
|
|
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula[$index]) !== false) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
}
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula[$index], PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
|
|
|
|
++$index;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// start subexpression or function
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
|
|
|
|
$tokens1[] = $tmp;
|
|
|
|
|
@ -423,7 +423,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// function, subexpression, or array parameters, or operand unions
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::COMMA) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
@ -444,7 +444,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stop subexpression
|
|
|
|
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
|
|
|
|
if ($this->formula[$index] == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
|
|
|
|
if (strlen($value) > 0) {
|
|
|
|
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
|
|
|
|
$value = "";
|
|
|
|
|
@ -460,7 +460,7 @@ class PHPExcel_Calculation_FormulaParser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// token accumulation
|
|
|
|
|
$value .= $this->formula{$index};
|
|
|
|
|
$value .= $this->formula[$index];
|
|
|
|
|
++$index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|