diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index e1a99144..c16f6f30 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -2445,7 +2445,6 @@ class Calculation foreach (array_keys(self::$localeBoolean) as $excelBoolean) { self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; } - } if (self::$functionReplaceToLocale === null) { @@ -3183,7 +3182,6 @@ class Calculation ++$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 && @@ -3195,7 +3193,6 @@ class Calculation $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack ++$index; $expectingOperator = false; - } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis? //echo 'Element is a Closing bracket', PHP_EOL; $expectingOperand = false; @@ -3278,7 +3275,6 @@ class Calculation } } ++$index; - } elseif ($opCharacter == ',') { // Is this the separator for function arguments? //echo 'Element is a Function argument separator', PHP_EOL; while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( @@ -3304,12 +3300,10 @@ class Calculation $expectingOperator = false; $expectingOperand = true; ++$index; - } elseif ($opCharacter == '(' && !$expectingOperator) { // echo 'Element is an Opening Bracket
'; $stack->push('Brace', '('); ++$index; - } elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number? $expectingOperator = true; $expectingOperand = false; @@ -3422,7 +3416,6 @@ class Calculation $output[] = $details; } $index += $length; - } elseif ($opCharacter == '$') { // absolute row or column range ++$index; } elseif ($opCharacter == ')') { // miscellaneous error checking @@ -3692,7 +3685,6 @@ class Calculation } else { $this->executeNumericBinaryOperation($cellID, $multiplier, $arg, '*', 'arrayTimesEquals', $stack); } - } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) { $cellRef = null; // echo 'Element '.$token.' is a Cell reference
'; @@ -3875,7 +3867,6 @@ class Calculation } $stack->push('Value', self::wrapResult($result)); } - } else { // if the token is a number, boolean, string or an Excel error, push it onto the stack if (isset(self::$excelConstants[strtoupper($token)])) { diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 83f4ede8..6e56171a 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -294,9 +294,9 @@ class DateTime $day = \PHPExcel\Shared\Date::dayStringToNumber($day); } - $year = ($year !== null) ? \PHPExcel\Shared\String::testStringAsNumeric($year) : 0; - $month = ($month !== null) ? \PHPExcel\Shared\String::testStringAsNumeric($month) : 0; - $day = ($day !== null) ? \PHPExcel\Shared\String::testStringAsNumeric($day) : 0; + $year = ($year !== null) ? \PHPExcel\Shared\StringHelper::testStringAsNumeric($year) : 0; + $month = ($month !== null) ? \PHPExcel\Shared\StringHelper::testStringAsNumeric($month) : 0; + $day = ($day !== null) ? \PHPExcel\Shared\StringHelper::testStringAsNumeric($day) : 0; if ((!is_numeric($year)) || (!is_numeric($month)) || (!is_numeric($day))) { diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index b4f68801..ef7ebaf1 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -238,8 +238,8 @@ class TextData $haystack = ($haystack) ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE(); } - if (($offset > 0) && (\PHPExcel\Shared\String::CountCharacters($haystack) > $offset)) { - if (\PHPExcel\Shared\String::CountCharacters($needle) == 0) { + if (($offset > 0) && (\PHPExcel\Shared\StringHelper::CountCharacters($haystack) > $offset)) { + if (\PHPExcel\Shared\StringHelper::CountCharacters($needle) == 0) { return $offset; } if (function_exists('mb_strpos')) { @@ -275,8 +275,8 @@ class TextData $haystack = ($haystack) ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE(); } - if (($offset > 0) && (\PHPExcel\Shared\String::CountCharacters($haystack) > $offset)) { - if (\PHPExcel\Shared\String::CountCharacters($needle) == 0) { + if (($offset > 0) && (\PHPExcel\Shared\StringHelper::CountCharacters($haystack) > $offset)) { + if (\PHPExcel\Shared\StringHelper::CountCharacters($needle) == 0) { return $offset; } if (function_exists('mb_stripos')) { @@ -449,7 +449,7 @@ class TextData $mixedCaseString = ($mixedCaseString) ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE(); } - return \PHPExcel\Shared\String::StrToLower($mixedCaseString); + return \PHPExcel\Shared\StringHelper::StrToLower($mixedCaseString); } @@ -469,7 +469,7 @@ class TextData $mixedCaseString = ($mixedCaseString) ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE(); } - return \PHPExcel\Shared\String::StrToUpper($mixedCaseString); + return \PHPExcel\Shared\StringHelper::StrToUpper($mixedCaseString); } @@ -489,7 +489,7 @@ class TextData $mixedCaseString = ($mixedCaseString) ? \PHPExcel\Calculation::getTRUE() : \PHPExcel\Calculation::getFALSE(); } - return \PHPExcel\Shared\String::StrToTitle($mixedCaseString); + return \PHPExcel\Shared\StringHelper::StrToTitle($mixedCaseString); } @@ -612,9 +612,9 @@ class TextData if (!is_numeric($value)) { $numberValue = str_replace( - \PHPExcel\Shared\String::getThousandsSeparator(), + \PHPExcel\Shared\StringHelper::getThousandsSeparator(), '', - trim($value, " \t\n\r\0\x0B" . \PHPExcel\Shared\String::getCurrencyCode()) + trim($value, " \t\n\r\0\x0B" . \PHPExcel\Shared\StringHelper::getCurrencyCode()) ); if (is_numeric($numberValue)) { return (float) $numberValue; diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index 49ed0c6d..3d09f01f 100644 --- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -40,7 +40,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder { // sanitize UTF-8 strings if (is_string($value)) { - $value = \PHPExcel\Shared\String::SanitizeUTF8($value); + $value = \PHPExcel\Shared\StringHelper::SanitizeUTF8($value); } // Find out data type @@ -100,9 +100,9 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder } // Check for currency - $currencyCode = \PHPExcel\Shared\String::getCurrencyCode(); - $decimalSeparator = \PHPExcel\Shared\String::getDecimalSeparator(); - $thousandsSeparator = \PHPExcel\Shared\String::getThousandsSeparator(); + $currencyCode = \PHPExcel\Shared\StringHelper::getCurrencyCode(); + $decimalSeparator = \PHPExcel\Shared\StringHelper::getDecimalSeparator(); + $thousandsSeparator = \PHPExcel\Shared\StringHelper::getThousandsSeparator(); if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { // Convert value to number $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); @@ -165,7 +165,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder // Check for newline character "\n" if (strpos($value, "\n") !== false) { - $value = \PHPExcel\Shared\String::SanitizeUTF8($value); + $value = \PHPExcel\Shared\StringHelper::SanitizeUTF8($value); $cell->setValueExplicit($value, DataType::TYPE_STRING); // Set style $cell->getWorksheet()->getStyle($cell->getCoordinate()) diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index 9a729d46..8bb87d28 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -90,7 +90,7 @@ class DataType } // string must never be longer than 32,767 characters, truncate if necessary - $pValue = \PHPExcel\Shared\String::Substring($pValue, 0, 32767); + $pValue = \PHPExcel\Shared\StringHelper::Substring($pValue, 0, 32767); // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index d4cbaa00..3802590d 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -40,7 +40,7 @@ class DefaultValueBinder implements IValueBinder { // sanitize UTF-8 strings if (is_string($value)) { - $value = \PHPExcel\Shared\String::SanitizeUTF8($value); + $value = \PHPExcel\Shared\StringHelper::SanitizeUTF8($value); } elseif (is_object($value)) { // Handle any objects that might be injected if ($value instanceof \DateTime) { diff --git a/src/PhpSpreadsheet/Reader/CSV.php b/src/PhpSpreadsheet/Reader/CSV.php index aa044f4f..15a22e3a 100644 --- a/src/PhpSpreadsheet/Reader/CSV.php +++ b/src/PhpSpreadsheet/Reader/CSV.php @@ -281,7 +281,7 @@ class CSV extends BaseReader implements IReader // Convert encoding if necessary if ($this->inputEncoding !== 'UTF-8') { - $rowDatum = \PHPExcel\Shared\String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); + $rowDatum = \PHPExcel\Shared\StringHelper::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding); } // Set cell value diff --git a/src/PhpSpreadsheet/Reader/Excel2003XML.php b/src/PhpSpreadsheet/Reader/Excel2003XML.php index 733336f5..c54d67ed 100644 --- a/src/PhpSpreadsheet/Reader/Excel2003XML.php +++ b/src/PhpSpreadsheet/Reader/Excel2003XML.php @@ -789,7 +789,7 @@ class Excel2003XML extends BaseReader implements IReader protected static function convertStringEncoding($string, $charset) { if ($charset != 'UTF-8') { - return \PHPExcel\Shared\String::ConvertEncoding($string, 'UTF-8', $charset); + return \PHPExcel\Shared\StringHelper::ConvertEncoding($string, 'UTF-8', $charset); } return $string; } diff --git a/src/PhpSpreadsheet/Reader/Excel2007.php b/src/PhpSpreadsheet/Reader/Excel2007.php index 299ea4a2..b1e7fc65 100644 --- a/src/PhpSpreadsheet/Reader/Excel2007.php +++ b/src/PhpSpreadsheet/Reader/Excel2007.php @@ -93,7 +93,6 @@ class Excel2007 extends BaseReader implements IReader $xl = true; } break; - } } } @@ -526,7 +525,7 @@ class Excel2007 extends BaseReader implements IReader if (isset($xmlStrings) && isset($xmlStrings->si)) { foreach ($xmlStrings->si as $val) { if (isset($val->t)) { - $sharedStrings[] = \PHPExcel\Shared\String::ControlCharacterOOXML2PHP((string) $val->t); + $sharedStrings[] = \PHPExcel\Shared\StringHelper::ControlCharacterOOXML2PHP((string) $val->t); } elseif (isset($val->r)) { $sharedStrings[] = $this->parseRichText($val); } @@ -1533,7 +1532,6 @@ class Excel2007 extends BaseReader implements IReader } } } - } // TODO: Autoshapes from twoCellAnchors! @@ -2073,15 +2071,14 @@ class Excel2007 extends BaseReader implements IReader $value = new \PHPExcel\RichText(); if (isset($is->t)) { - $value->createText(\PHPExcel\Shared\String::ControlCharacterOOXML2PHP((string) $is->t)); + $value->createText(\PHPExcel\Shared\StringHelper::ControlCharacterOOXML2PHP((string) $is->t)); } else { if (is_object($is->r)) { foreach ($is->r as $run) { if (!isset($run->rPr)) { - $objText = $value->createText(\PHPExcel\Shared\String::ControlCharacterOOXML2PHP((string) $run->t)); - + $objText = $value->createText(\PHPExcel\Shared\StringHelper::ControlCharacterOOXML2PHP((string) $run->t)); } else { - $objText = $value->createTextRun(\PHPExcel\Shared\String::ControlCharacterOOXML2PHP((string) $run->t)); + $objText = $value->createTextRun(\PHPExcel\Shared\StringHelper::ControlCharacterOOXML2PHP((string) $run->t)); if (isset($run->rPr->rFont["val"])) { $objText->getFont()->setName((string) $run->rPr->rFont["val"]); diff --git a/src/PhpSpreadsheet/Reader/Excel5.php b/src/PhpSpreadsheet/Reader/Excel5.php index 2f9a2ed1..f30f2d59 100644 --- a/src/PhpSpreadsheet/Reader/Excel5.php +++ b/src/PhpSpreadsheet/Reader/Excel5.php @@ -981,7 +981,6 @@ class Excel5 extends BaseReader implements IReader $this->readDefault(); break; } - } // treat MSODRAWING records, sheet-level Escher @@ -1344,7 +1343,7 @@ class Excel5 extends BaseReader implements IReader case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::getInt4d($this->summaryInformation, $secOffset + 4 + $offset); $value = substr($this->summaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = \PHPExcel\Shared\String::ConvertEncoding($value, 'UTF-8', $codePage); + $value = \PHPExcel\Shared\StringHelper::ConvertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) @@ -1490,7 +1489,7 @@ class Excel5 extends BaseReader implements IReader case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::getInt4d($this->documentSummaryInformation, $secOffset + 4 + $offset); $value = substr($this->documentSummaryInformation, $secOffset + 8 + $offset, $byteLength); - $value = \PHPExcel\Shared\String::ConvertEncoding($value, 'UTF-8', $codePage); + $value = \PHPExcel\Shared\StringHelper::ConvertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) @@ -3689,13 +3688,13 @@ class Excel5 extends BaseReader implements IReader $sstCount = count($this->sst[$index]['fmtRuns']); for ($i = 0; $i <= $sstCount; ++$i) { if (isset($fmtRuns[$i])) { - $text = \PHPExcel\Shared\String::Substring($this->sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); + $text = \PHPExcel\Shared\StringHelper::Substring($this->sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos); $charPos = $fmtRuns[$i]['charPos']; } else { - $text = \PHPExcel\Shared\String::Substring($this->sst[$index]['value'], $charPos, \PHPExcel\Shared\String::CountCharacters($this->sst[$index]['value'])); + $text = \PHPExcel\Shared\StringHelper::Substring($this->sst[$index]['value'], $charPos, \PHPExcel\Shared\StringHelper::CountCharacters($this->sst[$index]['value'])); } - if (\PHPExcel\Shared\String::CountCharacters($text) > 0) { + if (\PHPExcel\Shared\StringHelper::CountCharacters($text) > 0) { if ($i == 0) { // first text run, no style $richText->createText($text); } else { @@ -3943,7 +3942,6 @@ class Excel5 extends BaseReader implements IReader } $formula = $this->getFormulaFromStructure($formulaStructure); // get formula in human language $cell->setValueExplicit('=' . $formula, \PHPExcel\Cell\DataType::TYPE_FORMULA); - } catch (\PHPExcel\Exception $e) { $cell->setValueExplicit($value, $dataType); } @@ -7504,7 +7502,7 @@ class Excel5 extends BaseReader implements IReader $string = self::uncompressByteString($string); } - return \PHPExcel\Shared\String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE'); + return \PHPExcel\Shared\StringHelper::ConvertEncoding($string, 'UTF-8', 'UTF-16LE'); } @@ -7534,7 +7532,7 @@ class Excel5 extends BaseReader implements IReader */ private function decodeCodepage($string) { - return \PHPExcel\Shared\String::ConvertEncoding($string, 'UTF-8', $this->codepage); + return \PHPExcel\Shared\StringHelper::ConvertEncoding($string, 'UTF-8', $this->codepage); } diff --git a/src/PhpSpreadsheet/Reader/SYLK.php b/src/PhpSpreadsheet/Reader/SYLK.php index 126a3650..d6d5d08b 100644 --- a/src/PhpSpreadsheet/Reader/SYLK.php +++ b/src/PhpSpreadsheet/Reader/SYLK.php @@ -144,7 +144,7 @@ class SYLK extends BaseReader implements IReader $columnIndex = 0; // convert SYLK encoded $rowData to UTF-8 - $rowData = \PHPExcel\Shared\String::SYLKtoUTF8($rowData); + $rowData = \PHPExcel\Shared\StringHelper::SYLKtoUTF8($rowData); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) @@ -231,7 +231,7 @@ class SYLK extends BaseReader implements IReader // loop through one row (line) at a time in the file while (($rowData = fgets($fileHandle)) !== false) { // convert SYLK encoded $rowData to UTF-8 - $rowData = \PHPExcel\Shared\String::SYLKtoUTF8($rowData); + $rowData = \PHPExcel\Shared\StringHelper::SYLKtoUTF8($rowData); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 462fb563..d4781e14 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -465,7 +465,6 @@ class ReferenceHelper // Formula should be adjusted $cell->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); } - } } @@ -492,7 +491,6 @@ class ReferenceHelper } } } - } } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 69833c5b..4b7a7965 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -564,7 +564,6 @@ class Font $columnWidth = $pPixels ? self::$defaultColumnWidths[$font->getName()][$font->getSize()]['px'] : self::$defaultColumnWidths[$font->getName()][$font->getSize()]['width']; - } else { // We don't have data for this particular font and size, use approximation by // extrapolating from Calibri 11 diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index 77b48d83..59a9a72d 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -523,11 +523,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($value); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] += $value; @@ -617,11 +617,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($value); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] -= $value; @@ -713,11 +713,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($value); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] *= $value; @@ -768,11 +768,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($value); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($value); } if ($validValues) { if ($value == 0) { @@ -1049,11 +1049,11 @@ class Matrix $value = $M->get($i, $j); if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) { $this->A[$i][$j] = trim($this->A[$i][$j], '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($this->A[$i][$j]); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($this->A[$i][$j]); } if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) { $value = trim($value, '"'); - $validValues &= \PHPExcel\Shared\String::convertToNumberIfFraction($value); + $validValues &= \PHPExcel\Shared\StringHelper::convertToNumberIfFraction($value); } if ($validValues) { $this->A[$i][$j] = pow($this->A[$i][$j], $value); diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 948bd2e1..6f70bc5d 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -225,7 +225,6 @@ class PPS $raList[$cnt]->PrevPps = self::_savePpsSetPnt($raList, $aPrev, $depth++); $raList[$cnt]->NextPps = self::_savePpsSetPnt($raList, $aNext, $depth++); $raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); - } return $cnt; } diff --git a/src/PhpSpreadsheet/Shared/PCLZip/PclZip.php b/src/PhpSpreadsheet/Shared/PCLZip/PclZip.php index 5a296ca7..119d2044 100644 --- a/src/PhpSpreadsheet/Shared/PCLZip/PclZip.php +++ b/src/PhpSpreadsheet/Shared/PCLZip/PclZip.php @@ -3951,7 +3951,6 @@ class PclZip // ----- Get UNIX date format $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); - } else { $p_header['mtime'] = time(); } @@ -4051,7 +4050,6 @@ class PclZip // ----- Get UNIX date format $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); - } else { $p_header['mtime'] = time(); } diff --git a/src/PhpSpreadsheet/Shared/String.php b/src/PhpSpreadsheet/Shared/StringHelper.php similarity index 99% rename from src/PhpSpreadsheet/Shared/String.php rename to src/PhpSpreadsheet/Shared/StringHelper.php index 741f7ea1..71bc9892 100644 --- a/src/PhpSpreadsheet/Shared/String.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -3,7 +3,7 @@ namespace PHPExcel\Shared; /** - * \PHPExcel\Shared\String + * \PHPExcel\Shared\StringHelper * * Copyright (c) 2006 - 2015 PHPExcel * @@ -27,7 +27,7 @@ namespace PHPExcel\Shared; * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ -class String +class StringHelper { /** Constants */ /** Regular Expressions */ diff --git a/src/PhpSpreadsheet/Style.php b/src/PhpSpreadsheet/Style.php index e12cb46d..1694c055 100644 --- a/src/PhpSpreadsheet/Style.php +++ b/src/PhpSpreadsheet/Style.php @@ -440,7 +440,6 @@ class Style extends Style\Supervisor implements IComparable } break; } - } else { // not a supervisor, just apply the style array directly on style object if (array_key_exists('fill', $pStyles)) { diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 6f86ae1b..807fef85 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -135,7 +135,6 @@ class Color extends Supervisor implements \PHPExcel\IComparable case 'startColor': $key = 'startcolor'; break; - } return $this->parent->getStyleArray(array($key => $array)); } diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index effc292b..42d6e787 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -687,7 +687,6 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable if ($value != (int)$value) { self::formatAsFraction($value, $format); } - } else { // Handle the number itself @@ -711,8 +710,8 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable $value = number_format( $value, strlen($right), - \PHPExcel\Shared\String::getDecimalSeparator(), - \PHPExcel\Shared\String::getThousandsSeparator() + \PHPExcel\Shared\StringHelper::getDecimalSeparator(), + \PHPExcel\Shared\StringHelper::getThousandsSeparator() ); $value = preg_replace($number_regex, $value, $format); } else { @@ -735,7 +734,7 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable $currencyCode = $m[1]; list($currencyCode) = explode('-', $currencyCode); if ($currencyCode == '') { - $currencyCode = \PHPExcel\Shared\String::getCurrencyCode(); + $currencyCode = \PHPExcel\Shared\StringHelper::getCurrencyCode(); } $value = preg_replace('/\[\$([^\]]*)\]/u', $currencyCode, $value); } diff --git a/src/PhpSpreadsheet/Writer/Excel2007/Chart.php b/src/PhpSpreadsheet/Writer/Excel2007/Chart.php index 03e9549d..5b17245a 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/Chart.php +++ b/src/PhpSpreadsheet/Writer/Excel2007/Chart.php @@ -460,7 +460,7 @@ class Chart extends WriterPart } $objWriter->startElement('a:t'); // $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(\PHPExcel\Shared\String::ControlCharacterPHP2OOXML($caption)); + $objWriter->writeRawData(\PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML($caption)); $objWriter->endElement(); $objWriter->endElement(); @@ -810,7 +810,7 @@ class Chart extends WriterPart $objWriter->startElement('a:t'); // $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(\PHPExcel\Shared\String::ControlCharacterPHP2OOXML($caption)); + $objWriter->writeRawData(\PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML($caption)); $objWriter->endElement(); $objWriter->endElement(); diff --git a/src/PhpSpreadsheet/Writer/Excel2007/Rels.php b/src/PhpSpreadsheet/Writer/Excel2007/Rels.php index c520ca73..271a5192 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/Rels.php +++ b/src/PhpSpreadsheet/Writer/Excel2007/Rels.php @@ -61,7 +61,6 @@ class Rels extends WriterPart 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', 'docProps/custom.xml' ); - } // Relationship docProps/app.xml diff --git a/src/PhpSpreadsheet/Writer/Excel2007/StringTable.php b/src/PhpSpreadsheet/Writer/Excel2007/StringTable.php index 76baaf37..9b7e7203 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Excel2007/StringTable.php @@ -109,7 +109,7 @@ class StringTable extends WriterPart $objWriter->startElement('si'); if (! $textElement instanceof \PHPExcel\RichText) { - $textToWrite = \PHPExcel\Shared\String::ControlCharacterPHP2OOXML($textElement); + $textToWrite = \PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML($textElement); $objWriter->startElement('t'); if ($textToWrite !== trim($textToWrite)) { $objWriter->writeAttribute('xml:space', 'preserve'); @@ -208,7 +208,7 @@ class StringTable extends WriterPart // t $objWriter->startElement($prefix.'t'); $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(\PHPExcel\Shared\String::ControlCharacterPHP2OOXML($element->getText())); + $objWriter->writeRawData(\PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML($element->getText())); $objWriter->endElement(); $objWriter->endElement(); @@ -283,7 +283,7 @@ class StringTable extends WriterPart // t $objWriter->startElement($prefix.'t'); // $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains - $objWriter->writeRawData(\PHPExcel\Shared\String::ControlCharacterPHP2OOXML($element->getText())); + $objWriter->writeRawData(\PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML($element->getText())); $objWriter->endElement(); $objWriter->endElement(); diff --git a/src/PhpSpreadsheet/Writer/Excel2007/Worksheet.php b/src/PhpSpreadsheet/Writer/Excel2007/Worksheet.php index 2eacf606..c9b25d77 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Excel2007/Worksheet.php @@ -327,7 +327,7 @@ class Worksheet extends WriterPart // Default row height if ($pSheet->getDefaultRowDimension()->getRowHeight() >= 0) { $objWriter->writeAttribute('customHeight', 'true'); - $objWriter->writeAttribute('defaultRowHeight', \PHPExcel\Shared\String::FormatNumber($pSheet->getDefaultRowDimension()->getRowHeight())); + $objWriter->writeAttribute('defaultRowHeight', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getDefaultRowDimension()->getRowHeight())); } else { $objWriter->writeAttribute('defaultRowHeight', '14.4'); } @@ -340,7 +340,7 @@ class Worksheet extends WriterPart // Default column width if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) { - $objWriter->writeAttribute('defaultColWidth', \PHPExcel\Shared\String::FormatNumber($pSheet->getDefaultColumnDimension()->getWidth())); + $objWriter->writeAttribute('defaultColWidth', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getDefaultColumnDimension()->getWidth())); } // Outline level - row @@ -391,7 +391,7 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('width', '9.10'); } else { // Width set - $objWriter->writeAttribute('width', \PHPExcel\Shared\String::FormatNumber($colDimension->getWidth())); + $objWriter->writeAttribute('width', \PHPExcel\Shared\StringHelper::FormatNumber($colDimension->getWidth())); } // Column visibility @@ -735,12 +735,12 @@ class Worksheet extends WriterPart { // pageMargins $objWriter->startElement('pageMargins'); - $objWriter->writeAttribute('left', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getLeft())); - $objWriter->writeAttribute('right', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getRight())); - $objWriter->writeAttribute('top', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getTop())); - $objWriter->writeAttribute('bottom', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getBottom())); - $objWriter->writeAttribute('header', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getHeader())); - $objWriter->writeAttribute('footer', \PHPExcel\Shared\String::FormatNumber($pSheet->getPageMargins()->getFooter())); + $objWriter->writeAttribute('left', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getLeft())); + $objWriter->writeAttribute('right', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getRight())); + $objWriter->writeAttribute('top', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getTop())); + $objWriter->writeAttribute('bottom', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getBottom())); + $objWriter->writeAttribute('header', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getHeader())); + $objWriter->writeAttribute('footer', \PHPExcel\Shared\StringHelper::FormatNumber($pSheet->getPageMargins()->getFooter())); $objWriter->endElement(); } @@ -1001,7 +1001,7 @@ class Worksheet extends WriterPart // Row dimensions if ($rowDimension->getRowHeight() >= 0) { $objWriter->writeAttribute('customHeight', '1'); - $objWriter->writeAttribute('ht', \PHPExcel\Shared\String::FormatNumber($rowDimension->getRowHeight())); + $objWriter->writeAttribute('ht', \PHPExcel\Shared\StringHelper::FormatNumber($rowDimension->getRowHeight())); } // Row visibility @@ -1096,7 +1096,7 @@ class Worksheet extends WriterPart switch (strtolower($mappedType)) { case 'inlinestr': // Inline string if (! $cellValue instanceof \PHPExcel\RichText) { - $objWriter->writeElement('t', \PHPExcel\Shared\String::ControlCharacterPHP2OOXML(htmlspecialchars($cellValue))); + $objWriter->writeElement('t', \PHPExcel\Shared\StringHelper::ControlCharacterPHP2OOXML(htmlspecialchars($cellValue))); } elseif ($cellValue instanceof \PHPExcel\RichText) { $objWriter->startElement('is'); $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); @@ -1131,7 +1131,7 @@ class Worksheet extends WriterPart if ($this->getParentWriter()->getPreCalculateFormulas()) { // $calculatedValue = $pCell->getCalculatedValue(); if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') { - $objWriter->writeElement('v', \PHPExcel\Shared\String::FormatNumber($calculatedValue)); + $objWriter->writeElement('v', \PHPExcel\Shared\StringHelper::FormatNumber($calculatedValue)); } else { $objWriter->writeElement('v', '0'); } diff --git a/src/PhpSpreadsheet/Writer/Excel5/Font.php b/src/PhpSpreadsheet/Writer/Excel5/Font.php index aad7d211..a490878e 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Font.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Font.php @@ -117,7 +117,7 @@ class Font $bCharSet, $reserved ); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($this->font->getName()); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeShort($this->font->getName()); $length = strlen($data); $header = pack("vv", $record, $length); diff --git a/src/PhpSpreadsheet/Writer/Excel5/Parser.php b/src/PhpSpreadsheet/Writer/Excel5/Parser.php index a41ab735..a96eb368 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Parser.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Parser.php @@ -510,48 +510,37 @@ class Parser { if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) { return $this->convertString($token); - } elseif (is_numeric($token)) { return $this->convertNumber($token); - // match references like A1 or $A$1 } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/', $token)) { return $this->convertRef2d($token); - // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1 } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { return $this->convertRef3d($token); - // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1 } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u", $token)) { return $this->convertRef3d($token); - // match ranges like A1:B2 or $A$1:$B$2 } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) { return $this->convertRange2d($token); - // match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { return $this->convertRange3d($token); - // match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u", $token)) { return $this->convertRange3d($token); - // operators (including parentheses) } elseif (isset($this->ptg[$token])) { return pack("C", $this->ptg[$token]); - // match error codes } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') { return $this->convertError($token); - // commented so argument number can be processed correctly. See toReversePolish(). /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/", $token)) { return($this->convertFunction($token, $this->_func_args)); }*/ - // if it's an argument, ignore the token (the argument remains) } elseif ($token == 'arg') { return ''; @@ -595,7 +584,7 @@ class Parser throw new \PHPExcel\Writer\Exception("String is too long"); } - return pack('C', $this->ptg['ptgStr']) . \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($string); + return pack('C', $this->ptg['ptgStr']) . \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeShort($string); } /** diff --git a/src/PhpSpreadsheet/Writer/Excel5/Workbook.php b/src/PhpSpreadsheet/Writer/Excel5/Workbook.php index fa9832ca..ae75fbcc 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Workbook.php @@ -480,7 +480,7 @@ class Workbook extends BIFFwriter // add size of Workbook globals part 2, the length of the SHEET records $total_worksheets = count($this->phpExcel->getAllSheets()); foreach ($this->phpExcel->getWorksheetIterator() as $sheet) { - $offset += $boundsheet_length + strlen(\PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($sheet->getTitle())); + $offset += $boundsheet_length + strlen(\PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheet->getTitle())); } // add the sizes of each of the Sheet substreams, respectively @@ -678,7 +678,6 @@ class Workbook extends BIFFwriter $scope = 0; } $chunk .= $this->writeData($this->writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false)); - } catch (\PHPExcel\Exception $e) { // do nothing } @@ -805,10 +804,10 @@ class Workbook extends BIFFwriter $options = $isBuiltIn ? 0x20 : 0x00; // length of the name, character count - $nlen = \PHPExcel\Shared\String::CountCharacters($name); + $nlen = \PHPExcel\Shared\StringHelper::CountCharacters($name); // name with stripped length field - $name = substr(\PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($name), 2); + $name = substr(\PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($name), 2); // size of the formula (in bytes) $sz = strlen($formulaData); @@ -939,7 +938,7 @@ class Workbook extends BIFFwriter $grbit = 0x0000; // Visibility and sheet type $data = pack("VCC", $offset, $ss, $st); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($sheetname); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheetname); $length = strlen($data); $header = pack("vv", $record, $length); @@ -1006,7 +1005,7 @@ class Workbook extends BIFFwriter { $record = 0x041E; // Record identifier - $numberFormatString = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($format); + $numberFormatString = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($format); $length = 2 + strlen($numberFormatString); // Number of bytes to follow diff --git a/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php b/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php index 86b070de..e88a0f8f 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php @@ -403,7 +403,7 @@ class Worksheet extends BIFFwriter if ($cVal instanceof \PHPExcel\RichText) { // $this->writeString($row, $column, $cVal->getPlainText(), $xfIndex); $arrcRun = array(); - $str_len = \PHPExcel\Shared\String::CountCharacters($cVal->getPlainText(), 'UTF-8'); + $str_len = \PHPExcel\Shared\StringHelper::CountCharacters($cVal->getPlainText(), 'UTF-8'); $str_pos = 0; $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { @@ -415,7 +415,7 @@ class Worksheet extends BIFFwriter } $arrcRun[] = array('strlen' => $str_pos, 'fontidx' => $str_fontidx); // Position FROM - $str_pos += \PHPExcel\Shared\String::CountCharacters($element->getText(), 'UTF-8'); + $str_pos += \PHPExcel\Shared\StringHelper::CountCharacters($element->getText(), 'UTF-8'); } $this->writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun); } else { @@ -446,7 +446,6 @@ class Worksheet extends BIFFwriter case \PHPExcel\Cell\DataType::TYPE_ERROR: $this->writeBoolErr($row, $column, self::mapErrorCode($cVal), 1, $xfIndex); break; - } } } @@ -481,11 +480,9 @@ class Worksheet extends BIFFwriter if (strpos($url, 'sheet://') !== false) { // internal to current workbook $url = str_replace('sheet://', 'internal:', $url); - } elseif (preg_match('/^(http:|https:|ftp:|mailto:)/', $url)) { // URL // $url = $url; - } else { // external (local file) $url = 'external:' . $url; @@ -662,7 +659,7 @@ class Worksheet extends BIFFwriter { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($str, $arrcRun); + $str = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -731,7 +728,7 @@ class Worksheet extends BIFFwriter $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($str); + $str = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($str); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -905,13 +902,10 @@ class Worksheet extends BIFFwriter if ($stringValue !== null) { $this->writeStringRecord($stringValue); } - return 0; - } catch (\PHPExcel\Exception $e) { // do nothing } - } /** @@ -922,7 +916,7 @@ class Worksheet extends BIFFwriter private function writeStringRecord($stringValue) { $record = 0x0207; // Record identifier - $data = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($stringValue); + $data = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($stringValue); $length = strlen($data); $header = pack('vv', $record, $length); @@ -1060,10 +1054,10 @@ class Worksheet extends BIFFwriter $url .= "\0"; // character count - $url_len = \PHPExcel\Shared\String::CountCharacters($url); + $url_len = \PHPExcel\Shared\StringHelper::CountCharacters($url); $url_len = pack('V', $url_len); - $url = \PHPExcel\Shared\String::ConvertEncoding($url, 'UTF-16LE', 'UTF-8'); + $url = \PHPExcel\Shared\StringHelper::ConvertEncoding($url, 'UTF-16LE', 'UTF-8'); // Calculate the data length $length = 0x24 + strlen($url); @@ -1623,7 +1617,7 @@ class Worksheet extends BIFFwriter hexdec($password) ); - $recordData .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); + $recordData .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); $length = strlen($recordData); @@ -1846,7 +1840,7 @@ class Worksheet extends BIFFwriter } */ - $recordData = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); + $recordData = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); $length = strlen($recordData); $header = pack("vv", $record, $length); @@ -1870,7 +1864,7 @@ class Worksheet extends BIFFwriter } */ - $recordData = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); + $recordData = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); $length = strlen($recordData); $header = pack("vv", $record, $length); @@ -2893,22 +2887,22 @@ class Worksheet extends BIFFwriter // prompt title $promptTitle = $dataValidation->getPromptTitle() !== '' ? $dataValidation->getPromptTitle() : chr(0); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($promptTitle); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($promptTitle); // error title $errorTitle = $dataValidation->getErrorTitle() !== '' ? $dataValidation->getErrorTitle() : chr(0); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($errorTitle); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($errorTitle); // prompt text $prompt = $dataValidation->getPrompt() !== '' ? $dataValidation->getPrompt() : chr(0); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($prompt); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($prompt); // error text $error = $dataValidation->getError() !== '' ? $dataValidation->getError() : chr(0); - $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($error); + $data .= \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($error); // formula 1 try { @@ -3184,7 +3178,7 @@ class Worksheet extends BIFFwriter $dataBlockFont = pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); $dataBlockFont .= pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); } else { - $dataBlockFont = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); + $dataBlockFont = \PHPExcel\Shared\StringHelper::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); } // Font Size if ($conditional->getStyle()->getFont()->getSize() == null) { diff --git a/src/PhpSpreadsheet/Writer/HTML.php b/src/PhpSpreadsheet/Writer/HTML.php index b3439fd9..d12119e2 100644 --- a/src/PhpSpreadsheet/Writer/HTML.php +++ b/src/PhpSpreadsheet/Writer/HTML.php @@ -4,7 +4,7 @@ namespace PHPExcel\Writer; use PHPExcel\Calculation; use PHPExcel\Shared\Font; -use PHPExcel\Shared\String; +use PHPExcel\Shared\StringHelper; use PHPExcel\Spreadsheet; /** diff --git a/unitTests/Classes/src/Calculation/TextDataTest.php b/unitTests/Classes/src/Calculation/TextDataTest.php index da3f8823..8bfadf7c 100644 --- a/unitTests/Classes/src/Calculation/TextDataTest.php +++ b/unitTests/Classes/src/Calculation/TextDataTest.php @@ -322,9 +322,9 @@ class TextDataTest extends \PHPUnit_Framework_TestCase public function testTEXT() { // Enforce decimal and thousands separator values to UK/US, and currency code to USD - call_user_func(array('\PHPExcel\Shared\String', 'setDecimalSeparator'), '.'); - call_user_func(array('\PHPExcel\Shared\String', 'setThousandsSeparator'), ','); - call_user_func(array('\PHPExcel\Shared\String', 'setCurrencyCode'), '$'); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setDecimalSeparator'), '.'); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setThousandsSeparator'), ','); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setCurrencyCode'), '$'); $args = func_get_args(); $expectedResult = array_pop($args); @@ -342,9 +342,9 @@ class TextDataTest extends \PHPUnit_Framework_TestCase */ public function testVALUE() { - call_user_func(array('\PHPExcel\Shared\String', 'setDecimalSeparator'), '.'); - call_user_func(array('\PHPExcel\Shared\String', 'setThousandsSeparator'), ' '); - call_user_func(array('\PHPExcel\Shared\String', 'setCurrencyCode'), '$'); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setDecimalSeparator'), '.'); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setThousandsSeparator'), ' '); + call_user_func(array('\PHPExcel\Shared\StringHelper', 'setCurrencyCode'), '$'); $args = func_get_args(); $expectedResult = array_pop($args); diff --git a/unitTests/Classes/src/Cell/AdvancedValueBinderTest.php b/unitTests/Classes/src/Cell/AdvancedValueBinderTest.php index 623c030c..62aad5b8 100644 --- a/unitTests/Classes/src/Cell/AdvancedValueBinderTest.php +++ b/unitTests/Classes/src/Cell/AdvancedValueBinderTest.php @@ -62,9 +62,9 @@ class AdvancedValueBinderTest extends \PHPUnit_Framework_TestCase ->method('getCellCacheController') ->will($this->returnValue($cache)); - \PHPExcel\Shared\String::setCurrencyCode($currencyCode); - \PHPExcel\Shared\String::setDecimalSeparator($decimalSeparator); - \PHPExcel\Shared\String::setThousandsSeparator($thousandsSeparator); + \PHPExcel\Shared\StringHelper::setCurrencyCode($currencyCode); + \PHPExcel\Shared\StringHelper::setDecimalSeparator($decimalSeparator); + \PHPExcel\Shared\StringHelper::setThousandsSeparator($thousandsSeparator); $cell = new \PHPExcel\Cell(null, \PHPExcel\Cell\DataType::TYPE_STRING, $sheet); diff --git a/unitTests/Classes/src/Shared/StringTest.php b/unitTests/Classes/src/Shared/StringTest.php index 7365ce29..34038608 100644 --- a/unitTests/Classes/src/Shared/StringTest.php +++ b/unitTests/Classes/src/Shared/StringTest.php @@ -8,13 +8,13 @@ class StringTest extends \PHPUnit_Framework_TestCase { public function testGetIsMbStringEnabled() { - $result = call_user_func(array('\PHPExcel\Shared\String','getIsMbstringEnabled')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getIsMbstringEnabled')); $this->assertTrue($result); } public function testGetIsIconvEnabled() { - $result = call_user_func(array('\PHPExcel\Shared\String','getIsIconvEnabled')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getIsIconvEnabled')); $this->assertTrue($result); } @@ -23,16 +23,16 @@ class StringTest extends \PHPUnit_Framework_TestCase $localeconv = localeconv(); $expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ','; - $result = call_user_func(array('\PHPExcel\Shared\String','getDecimalSeparator')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getDecimalSeparator')); $this->assertEquals($expectedResult, $result); } public function testSetDecimalSeparator() { $expectedResult = ','; - $result = call_user_func(array('\PHPExcel\Shared\String','setDecimalSeparator'), $expectedResult); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','setDecimalSeparator'), $expectedResult); - $result = call_user_func(array('\PHPExcel\Shared\String','getDecimalSeparator')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getDecimalSeparator')); $this->assertEquals($expectedResult, $result); } @@ -41,16 +41,16 @@ class StringTest extends \PHPUnit_Framework_TestCase $localeconv = localeconv(); $expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ','; - $result = call_user_func(array('\PHPExcel\Shared\String','getThousandsSeparator')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getThousandsSeparator')); $this->assertEquals($expectedResult, $result); } public function testSetThousandsSeparator() { $expectedResult = ' '; - $result = call_user_func(array('\PHPExcel\Shared\String','setThousandsSeparator'), $expectedResult); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','setThousandsSeparator'), $expectedResult); - $result = call_user_func(array('\PHPExcel\Shared\String','getThousandsSeparator')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getThousandsSeparator')); $this->assertEquals($expectedResult, $result); } @@ -59,16 +59,16 @@ class StringTest extends \PHPUnit_Framework_TestCase $localeconv = localeconv(); $expectedResult = (!empty($localeconv['currency_symbol'])) ? $localeconv['currency_symbol'] : '$'; - $result = call_user_func(array('\PHPExcel\Shared\String','getCurrencyCode')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getCurrencyCode')); $this->assertEquals($expectedResult, $result); } public function testSetCurrencyCode() { $expectedResult = '£'; - $result = call_user_func(array('\PHPExcel\Shared\String','setCurrencyCode'), $expectedResult); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','setCurrencyCode'), $expectedResult); - $result = call_user_func(array('\PHPExcel\Shared\String','getCurrencyCode')); + $result = call_user_func(array('\PHPExcel\Shared\StringHelper','getCurrencyCode')); $this->assertEquals($expectedResult, $result); } } diff --git a/unitTests/Classes/src/Style/NumberFormatDateTest.php b/unitTests/Classes/src/Style/NumberFormatDateTest.php index 998a7ce4..1aec99c7 100644 --- a/unitTests/Classes/src/Style/NumberFormatDateTest.php +++ b/unitTests/Classes/src/Style/NumberFormatDateTest.php @@ -9,8 +9,8 @@ class NumberFormatDateTest extends \PHPUnit_Framework_TestCase public function setUp() { - \PHPExcel\Shared\String::setDecimalSeparator('.'); - \PHPExcel\Shared\String::setThousandsSeparator(','); + \PHPExcel\Shared\StringHelper::setDecimalSeparator('.'); + \PHPExcel\Shared\StringHelper::setThousandsSeparator(','); } /** diff --git a/unitTests/Classes/src/Style/NumberFormatTest.php b/unitTests/Classes/src/Style/NumberFormatTest.php index 01b89fed..6b36fb7e 100644 --- a/unitTests/Classes/src/Style/NumberFormatTest.php +++ b/unitTests/Classes/src/Style/NumberFormatTest.php @@ -9,8 +9,8 @@ class NumberFormatTest extends \PHPUnit_Framework_TestCase public function setUp() { - \PHPExcel\Shared\String::setDecimalSeparator('.'); - \PHPExcel\Shared\String::setThousandsSeparator(','); + \PHPExcel\Shared\StringHelper::setDecimalSeparator('.'); + \PHPExcel\Shared\StringHelper::setThousandsSeparator(','); } /**