From 1d842ed2188adc5c332b2db3ae7c20211399c459 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 17 May 2015 14:16:53 +0200 Subject: [PATCH] PSR2 Fixes --- Classes/PHPExcel/Reader/Excel2003XML.php | 1 - Classes/PHPExcel/Reader/Excel2007.php | 7 +- Classes/PHPExcel/Reader/Excel2007/Chart.php | 293 ++++---- Classes/PHPExcel/Reader/Excel2007/Theme.php | 13 +- Classes/PHPExcel/Reader/Excel5.php | 208 +++--- Classes/PHPExcel/Reader/Excel5/Escher.php | 1 - Classes/PHPExcel/Reader/Gnumeric.php | 329 +++++---- Classes/PHPExcel/Reader/OOCalc.php | 245 ++++--- Classes/PHPExcel/Reader/SYLK.php | 44 +- .../Shared/JAMA/CholeskyDecomposition.php | 29 +- .../Shared/JAMA/EigenvalueDecomposition.php | 60 +- .../PHPExcel/Shared/JAMA/LUDecomposition.php | 39 +- Classes/PHPExcel/Shared/JAMA/Matrix.php | 624 ++++++++++-------- .../PHPExcel/Shared/JAMA/QRDecomposition.php | 28 +- .../JAMA/SingularValueDecomposition.php | 286 ++++---- Classes/PHPExcel/Shared/JAMA/utils/Error.php | 3 +- Classes/PHPExcel/Shared/JAMA/utils/Maths.php | 3 +- Classes/PHPExcel/Shared/OLE/PPS/Root.php | 63 +- Classes/PHPExcel/Shared/OLERead.php | 3 +- Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php | 101 +-- 20 files changed, 1197 insertions(+), 1183 deletions(-) diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php index 29720aa9..c5360cfb 100644 --- a/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/Classes/PHPExcel/Reader/Excel2003XML.php @@ -58,7 +58,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P */ protected $_charSet = 'UTF-8'; - /** * Create a new PHPExcel_Reader_Excel2003XML */ diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index caf6c28e..6c1ded0d 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -992,11 +992,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); $filters = $filterColumn->filters; if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { - $column->createRule()->setRule( - null,// Operator is undefined, but always treated as EQUAL - '' - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, '')->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); } // Standard filters are always an OR join, so no join rule needs to be set // Entries can be either filter elements diff --git a/Classes/PHPExcel/Reader/Excel2007/Chart.php b/Classes/PHPExcel/Reader/Excel2007/Chart.php index 80ac4470..222c5466 100644 --- a/Classes/PHPExcel/Reader/Excel2007/Chart.php +++ b/Classes/PHPExcel/Reader/Excel2007/Chart.php @@ -34,7 +34,8 @@ */ class PHPExcel_Reader_Excel2007_Chart { - private static function _getAttribute($component, $name, $format) { + private static function _getAttribute($component, $name, $format) + { $attributes = $component->attributes(); if (isset($attributes[$name])) { if ($format == 'string') { @@ -51,7 +52,8 @@ class PHPExcel_Reader_Excel2007_Chart } // function _getAttribute() - private static function _readColor($color, $background=false) { + private static function _readColor($color, $background = false) + { if (isset($color["rgb"])) { return (string)$color["rgb"]; } else if (isset($color["indexed"])) { @@ -59,13 +61,13 @@ class PHPExcel_Reader_Excel2007_Chart } } - - public static function readChart($chartElements, $chartName) { + public static function readChart($chartElements, $chartName) + { $namespacesChartMeta = $chartElements->getNamespaces(true); $chartElementsC = $chartElements->children($namespacesChartMeta['c']); - $XaxisLabel = $YaxisLabel = $legend = $title = NULL; - $dispBlanksAs = $plotVisOnly = NULL; + $XaxisLabel = $YaxisLabel = $legend = $title = null; + $dispBlanksAs = $plotVisOnly = null; foreach ($chartElementsC as $chartElementKey => $chartElement) { switch ($chartElementKey) { @@ -74,124 +76,124 @@ class PHPExcel_Reader_Excel2007_Chart $chartDetailsC = $chartDetails->children($namespacesChartMeta['c']); switch ($chartDetailsKey) { case "plotArea": - $plotAreaLayout = $XaxisLable = $YaxisLable = null; - $plotSeries = $plotAttributes = array(); - foreach ($chartDetails as $chartDetailKey => $chartDetail) { - switch ($chartDetailKey) { - case "layout": - $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea'); - break; - case "catAx": - if (isset($chartDetail->title)) { - $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); - } - break; - case "dateAx": - if (isset($chartDetail->title)) { - $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); - } - break; - case "valAx": - if (isset($chartDetail->title)) { - $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); - } - break; - case "barChart": - case "bar3DChart": - $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string'); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotDirection($barDirection); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "lineChart": - case "line3DChart": - $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "areaChart": - case "area3DChart": - $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "doughnutChart": - case "pieChart": - case "pie3DChart": - $explosion = isset($chartDetail->ser->explosion); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotStyle($explosion); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "scatterChart": - $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string'); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotStyle($scatterStyle); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "bubbleChart": - $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer'); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotStyle($bubbleScale); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "radarChart": - $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string'); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotStyle($radarStyle); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "surfaceChart": - case "surface3DChart": - $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean'); - $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotSer->setPlotStyle($wireFrame); - $plotSeries[] = $plotSer; - $plotAttributes = self::_readChartAttributes($chartDetail); - break; - case "stockChart": - $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); - $plotAttributes = self::_readChartAttributes($plotAreaLayout); - break; - } + $plotAreaLayout = $XaxisLable = $YaxisLable = null; + $plotSeries = $plotAttributes = array(); + foreach ($chartDetails as $chartDetailKey => $chartDetail) { + switch ($chartDetailKey) { + case "layout": + $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea'); + break; + case "catAx": + if (isset($chartDetail->title)) { + $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); + } + break; + case "dateAx": + if (isset($chartDetail->title)) { + $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); + } + break; + case "valAx": + if (isset($chartDetail->title)) { + $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); + } + break; + case "barChart": + case "bar3DChart": + $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string'); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotDirection($barDirection); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "lineChart": + case "line3DChart": + $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "areaChart": + case "area3DChart": + $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "doughnutChart": + case "pieChart": + case "pie3DChart": + $explosion = isset($chartDetail->ser->explosion); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotStyle($explosion); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "scatterChart": + $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string'); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotStyle($scatterStyle); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "bubbleChart": + $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer'); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotStyle($bubbleScale); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "radarChart": + $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string'); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotStyle($radarStyle); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "surfaceChart": + case "surface3DChart": + $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean'); + $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotSer->setPlotStyle($wireFrame); + $plotSeries[] = $plotSer; + $plotAttributes = self::_readChartAttributes($chartDetail); + break; + case "stockChart": + $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); + $plotAttributes = self::_readChartAttributes($plotAreaLayout); + break; } - if ($plotAreaLayout == NULL) { - $plotAreaLayout = new PHPExcel_Chart_Layout(); - } - $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries); - self::_setChartAttributes($plotAreaLayout, $plotAttributes); - break; + } + if ($plotAreaLayout == null) { + $plotAreaLayout = new PHPExcel_Chart_Layout(); + } + $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries); + self::_setChartAttributes($plotAreaLayout, $plotAttributes); + break; case "plotVisOnly": - $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string'); - break; + $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string'); + break; case "dispBlanksAs": - $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); - break; + $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); + break; case "title": - $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title'); - break; + $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title'); + break; case "legend": - $legendPos = 'r'; - $legendLayout = null; - $legendOverlay = false; - foreach ($chartDetails as $chartDetailKey => $chartDetail) { - switch ($chartDetailKey) { - case "legendPos": - $legendPos = self::_getAttribute($chartDetail, 'val', 'string'); - break; - case "overlay": - $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean'); - break; - case "layout": - $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend'); - break; - } + $legendPos = 'r'; + $legendLayout = null; + $legendOverlay = false; + foreach ($chartDetails as $chartDetailKey => $chartDetail) { + switch ($chartDetailKey) { + case "legendPos": + $legendPos = self::_getAttribute($chartDetail, 'val', 'string'); + break; + case "overlay": + $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean'); + break; + case "layout": + $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend'); + break; } - $legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay); - break; + } + $legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay); + break; } } } @@ -201,8 +203,8 @@ class PHPExcel_Reader_Excel2007_Chart return $chart; } // function readChart() - - private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) { + private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) + { $caption = array(); $titleLayout = null; foreach ($titleDetails as $titleDetailKey => $chartDetail) { @@ -226,8 +228,8 @@ class PHPExcel_Reader_Excel2007_Chart return new PHPExcel_Chart_Title($caption, $titleLayout); } // function _chartTitle() - - private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) { + private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) + { if (!isset($chartDetail->manualLayout)) { return null; } @@ -243,9 +245,9 @@ class PHPExcel_Reader_Excel2007_Chart return new PHPExcel_Chart_Layout($layout); } // function _chartLayoutDetails() - - private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) { - $multiSeriesType = NULL; + private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) + { + $multiSeriesType = null; $smoothLine = false; $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array(); @@ -256,7 +258,7 @@ class PHPExcel_Reader_Excel2007_Chart $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string'); break; case "ser": - $marker = NULL; + $marker = null; foreach ($seriesDetails as $seriesKey => $seriesDetail) { switch ($seriesKey) { case "idx": @@ -294,8 +296,8 @@ class PHPExcel_Reader_Excel2007_Chart return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); } // function _chartDataSeries() - - private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) { + private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) + { if (isset($seriesDetail->strRef)) { $seriesSource = (string) $seriesDetail->strRef->f; $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s'); @@ -322,8 +324,8 @@ class PHPExcel_Reader_Excel2007_Chart return null; } // function _chartDataSeriesValueSet() - - private static function _chartDataSeriesValues($seriesValueSet, $dataType='n') { + private static function _chartDataSeriesValues($seriesValueSet, $dataType = 'n') + { $seriesVal = array(); $formatCode = ''; $pointCount = 0; @@ -348,17 +350,18 @@ class PHPExcel_Reader_Excel2007_Chart } if (empty($seriesVal)) { - $seriesVal = NULL; + $seriesVal = null; } - return array( 'formatCode' => $formatCode, - 'pointCount' => $pointCount, - 'dataValues' => $seriesVal - ); + return array( + 'formatCode' => $formatCode, + 'pointCount' => $pointCount, + 'dataValues' => $seriesVal + ); } // function _chartDataSeriesValues() - - private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') { + private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n') + { $seriesVal = array(); $formatCode = ''; $pointCount = 0; @@ -384,13 +387,15 @@ class PHPExcel_Reader_Excel2007_Chart } } - return array( 'formatCode' => $formatCode, - 'pointCount' => $pointCount, - 'dataValues' => $seriesVal - ); + return array( + 'formatCode' => $formatCode, + 'pointCount' => $pointCount, + 'dataValues' => $seriesVal + ); } // function _chartDataSeriesValuesMultiLevel() - private static function _parseRichText($titleDetailPart = null) { + private static function _parseRichText($titleDetailPart = null) + { $value = new PHPExcel_RichText(); foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { @@ -456,7 +461,8 @@ class PHPExcel_Reader_Excel2007_Chart return $value; } - private static function _readChartAttributes($chartDetail) { + private static function _readChartAttributes($chartDetail) + { $plotAttributes = array(); if (isset($chartDetail->dLbls)) { if (isset($chartDetail->dLbls->howLegendKey)) { @@ -513,5 +519,4 @@ class PHPExcel_Reader_Excel2007_Chart } } } - } diff --git a/Classes/PHPExcel/Reader/Excel2007/Theme.php b/Classes/PHPExcel/Reader/Excel2007/Theme.php index 2501c814..d5879ad4 100644 --- a/Classes/PHPExcel/Reader/Excel2007/Theme.php +++ b/Classes/PHPExcel/Reader/Excel2007/Theme.php @@ -72,9 +72,9 @@ class PHPExcel_Reader_Excel2007_Theme public function __construct($themeName, $colourSchemeName, $colourMap) { // Initialise values - $this->_themeName = $themeName; + $this->_themeName = $themeName; $this->_colourSchemeName = $colourSchemeName; - $this->_colourMap = $colourMap; + $this->_colourMap = $colourMap; } /** @@ -92,7 +92,8 @@ class PHPExcel_Reader_Excel2007_Theme * * @return string */ - public function getColourSchemeName() { + public function getColourSchemeName() + { return $this->_colourSchemeName; } @@ -101,7 +102,8 @@ class PHPExcel_Reader_Excel2007_Theme * * @return string */ - public function getColourByIndex($index=0) { + public function getColourByIndex($index = 0) + { if (isset($this->_colourMap[$index])) { return $this->_colourMap[$index]; } @@ -111,7 +113,8 @@ class PHPExcel_Reader_Excel2007_Theme /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ - public function __clone() { + public function __clone() + { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if ((is_object($value)) && ($key != '_parent')) { diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 15fa11b7..8b87bf3d 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -1113,7 +1113,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ($this->_version == self::XLS_BIFF8) { foreach ($this->_sharedFormulaParts as $cell => $baseCell) { list($column, $row) = PHPExcel_Cell::coordinateFromString($cell); - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle())) { $formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell); $this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA); } @@ -1156,7 +1156,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? $sheetName = trim($explodes[0], "'"); if (count($explodes) == 2) { - if (strpos($explodes[1], ':') === FALSE) { + if (strpos($explodes[1], ':') === false) { $explodes[1] = $explodes[1] . ':' . $explodes[1]; } $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 @@ -1221,7 +1221,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $scope = ($definedName['scope'] == 0) ? null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']); - $this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) ); + $this->_phpExcel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope)); } } else { // Named Value @@ -1624,7 +1624,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // $this->_cellNotes[$noteObjID] = array( 'cellRef' => $cellAddress, - 'objectID' => $noteObjID, + 'objectID' => $noteObjID, 'author' => $noteAuthor ); } else { @@ -1647,13 +1647,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ($extension) { // Concatenate this extension with the currently set comment for the cell - $comment = $this->_phpSheet->getComment( $cellAddress ); + $comment = $this->_phpSheet->getComment($cellAddress); $commentText = $comment->getText()->getPlainText(); - $comment->setText($this->_parseRichText($commentText.$noteText) ); + $comment->setText($this->_parseRichText($commentText.$noteText)); } else { // Set comment for the cell $this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText)); -// ->setAuthor( $author ) +// ->setAuthor($author) } } @@ -2410,7 +2410,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); $fill->getStartColor()->setRGB($rgb); unset($fill->startcolorIndex); // normal color index does not apply, discard @@ -2425,7 +2425,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); $fill->getEndColor()->setRGB($rgb); unset($fill->endcolorIndex); // normal color index does not apply, discard @@ -2440,7 +2440,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop(); $top->getColor()->setRGB($rgb); unset($top->colorIndex); // normal color index does not apply, discard @@ -2455,7 +2455,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom(); $bottom->getColor()->setRGB($rgb); unset($bottom->colorIndex); // normal color index does not apply, discard @@ -2470,7 +2470,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft(); $left->getColor()->setRGB($rgb); unset($left->colorIndex); // normal color index does not apply, discard @@ -2485,7 +2485,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight(); $right->getColor()->setRGB($rgb); unset($right->colorIndex); // normal color index does not apply, discard @@ -2500,7 +2500,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal(); $diagonal->getColor()->setRGB($rgb); unset($diagonal->colorIndex); // normal color index does not apply, discard @@ -2515,7 +2515,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2})); // modify the relevant style property - if ( isset($this->_mapCellXfIndex[$ixfe]) ) { + if (isset($this->_mapCellXfIndex[$ixfe])) { $font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont(); $font->getColor()->setRGB($rgb); unset($font->colorIndex); // normal color index does not apply, discard @@ -3652,7 +3652,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, 4); @@ -4125,7 +4125,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { $xfIndex = self::_GetInt2d($recordData, 4 + 2 * $i); $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]); } @@ -4162,7 +4162,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: 4; size: 2; XF index $xfIndex = self::_GetInt2d($recordData, 4); @@ -4528,7 +4528,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData); foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { - if ((strpos($cellRangeAddress,':') !== FALSE) && + if ((strpos($cellRangeAddress,':') !== false) && ($this->_includeCellRangeFiltered($cellRangeAddress))) { $this->_phpSheet->mergeCells($cellRangeAddress); } @@ -5743,203 +5743,203 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $size = 3; // offset: 1; size: 2; index to built-in sheet function switch (self::_GetInt2d($formulaData, 1)) { - case 2: + case 2: $function = 'ISNA'; $args = 1; break; - case 3: + case 3: $function = 'ISERROR'; $args = 1; break; - case 10: + case 10: $function = 'NA'; $args = 0; break; - case 15: + case 15: $function = 'SIN'; $args = 1; break; - case 16: + case 16: $function = 'COS'; $args = 1; break; - case 17: + case 17: $function = 'TAN'; $args = 1; break; - case 18: + case 18: $function = 'ATAN'; $args = 1; break; - case 19: + case 19: $function = 'PI'; $args = 0; break; - case 20: + case 20: $function = 'SQRT'; $args = 1; break; - case 21: + case 21: $function = 'EXP'; $args = 1; break; - case 22: + case 22: $function = 'LN'; $args = 1; break; - case 23: + case 23: $function = 'LOG10'; $args = 1; break; - case 24: + case 24: $function = 'ABS'; $args = 1; break; - case 25: + case 25: $function = 'INT'; $args = 1; break; - case 26: + case 26: $function = 'SIGN'; $args = 1; break; - case 27: + case 27: $function = 'ROUND'; $args = 2; break; - case 30: + case 30: $function = 'REPT'; $args = 2; break; - case 31: + case 31: $function = 'MID'; $args = 3; break; - case 32: + case 32: $function = 'LEN'; $args = 1; break; - case 33: + case 33: $function = 'VALUE'; $args = 1; break; - case 34: + case 34: $function = 'TRUE'; $args = 0; break; - case 35: + case 35: $function = 'FALSE'; $args = 0; break; - case 38: + case 38: $function = 'NOT'; $args = 1; break; - case 39: + case 39: $function = 'MOD'; $args = 2; break; - case 40: + case 40: $function = 'DCOUNT'; $args = 3; break; - case 41: + case 41: $function = 'DSUM'; $args = 3; break; - case 42: + case 42: $function = 'DAVERAGE'; $args = 3; break; - case 43: + case 43: $function = 'DMIN'; $args = 3; break; - case 44: + case 44: $function = 'DMAX'; $args = 3; break; - case 45: + case 45: $function = 'DSTDEV'; $args = 3; break; - case 48: + case 48: $function = 'TEXT'; $args = 2; break; - case 61: + case 61: $function = 'MIRR'; $args = 3; break; - case 63: + case 63: $function = 'RAND'; $args = 0; break; - case 65: + case 65: $function = 'DATE'; $args = 3; break; - case 66: + case 66: $function = 'TIME'; $args = 3; break; - case 67: + case 67: $function = 'DAY'; $args = 1; break; - case 68: + case 68: $function = 'MONTH'; $args = 1; break; - case 69: + case 69: $function = 'YEAR'; $args = 1; break; - case 71: + case 71: $function = 'HOUR'; $args = 1; break; - case 72: + case 72: $function = 'MINUTE'; $args = 1; break; - case 73: + case 73: $function = 'SECOND'; $args = 1; break; - case 74: + case 74: $function = 'NOW'; $args = 0; break; - case 75: + case 75: $function = 'AREAS'; $args = 1; break; - case 76: + case 76: $function = 'ROWS'; $args = 1; break; - case 77: + case 77: $function = 'COLUMNS'; $args = 1; break; - case 83: + case 83: $function = 'TRANSPOSE'; $args = 1; break; - case 86: + case 86: $function = 'TYPE'; $args = 1; break; - case 97: + case 97: $function = 'ATAN2'; $args = 2; break; - case 98: + case 98: $function = 'ASIN'; $args = 1; break; - case 99: + case 99: $function = 'ACOS'; $args = 1; break; @@ -6399,97 +6399,97 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 2: size: 2; index to built-in sheet function $index = self::_GetInt2d($formulaData, 2); switch ($index) { - case 0: + case 0: $function = 'COUNT'; break; - case 1: + case 1: $function = 'IF'; break; - case 4: + case 4: $function = 'SUM'; break; - case 5: + case 5: $function = 'AVERAGE'; break; - case 6: + case 6: $function = 'MIN'; break; - case 7: + case 7: $function = 'MAX'; break; - case 8: + case 8: $function = 'ROW'; break; - case 9: + case 9: $function = 'COLUMN'; break; - case 11: + case 11: $function = 'NPV'; break; - case 12: + case 12: $function = 'STDEV'; break; - case 13: + case 13: $function = 'DOLLAR'; break; - case 14: + case 14: $function = 'FIXED'; break; - case 28: + case 28: $function = 'LOOKUP'; break; - case 29: + case 29: $function = 'INDEX'; break; - case 36: + case 36: $function = 'AND'; break; - case 37: + case 37: $function = 'OR'; break; - case 46: + case 46: $function = 'VAR'; break; - case 49: + case 49: $function = 'LINEST'; break; - case 50: + case 50: $function = 'TREND'; break; - case 51: + case 51: $function = 'LOGEST'; break; - case 52: + case 52: $function = 'GROWTH'; break; - case 56: + case 56: $function = 'PV'; break; - case 57: + case 57: $function = 'FV'; break; - case 58: + case 58: $function = 'NPER'; break; - case 59: + case 59: $function = 'PMT'; break; - case 60: + case 60: $function = 'RATE'; break; - case 62: + case 62: $function = 'IRR'; break; - case 64: + case 64: $function = 'MATCH'; break; - case 70: + case 70: $function = 'WEEKDAY'; break; - case 78: + case 78: $function = 'OFFSET'; break; - case 82: + case 82: $function = 'SEARCH'; break; case 100: @@ -7468,7 +7468,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); $mantissalow1 = ($rknumlow & 0x80000000) >> 31; $mantissalow2 = ($rknumlow & 0x7fffffff); - $value = $mantissa / pow( 2 , (20 - $exp)); + $value = $mantissa / pow(2 , (20 - $exp)); if ($mantissalow1 != 0) { $value += 1 / pow (2 , (21 - $exp)); @@ -7496,7 +7496,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $sign = ($rknum & 0x80000000) >> 31; $exp = ($rknum & 0x7ff00000) >> 20; $mantissa = (0x100000 | ($rknum & 0x000ffffc)); - $value = $mantissa / pow( 2 , (20- ($exp - 1023))); + $value = $mantissa / pow(2 , (20- ($exp - 1023))); if ($sign) { $value = -1 * $value; } @@ -8043,8 +8043,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } - - private function _parseRichText($is = '') { + private function _parseRichText($is = '') + { $value = new PHPExcel_RichText(); $value->createText($is); diff --git a/Classes/PHPExcel/Reader/Excel5/Escher.php b/Classes/PHPExcel/Reader/Excel5/Escher.php index 3fd949a0..f7f45dcd 100644 --- a/Classes/PHPExcel/Reader/Excel5/Escher.php +++ b/Classes/PHPExcel/Reader/Excel5/Escher.php @@ -107,7 +107,6 @@ class PHPExcel_Reader_Excel5_Escher // Parse Escher stream while ($this->_pos < $this->_dataSize) { - // offset: 2; size: 2: Record Type $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); diff --git a/Classes/PHPExcel/Reader/Gnumeric.php b/Classes/PHPExcel/Reader/Gnumeric.php index 72a6755f..f67f3231 100644 --- a/Classes/PHPExcel/Reader/Gnumeric.php +++ b/Classes/PHPExcel/Reader/Gnumeric.php @@ -60,16 +60,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx private $_referenceHelper = null; - /** * Create a new PHPExcel_Reader_Gnumeric */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -101,7 +100,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return true; } - /** * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * @@ -116,9 +114,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->xml( - $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() - ); + $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2,true); $worksheetNames = array(); @@ -135,7 +131,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $worksheetNames; } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * @@ -150,10 +145,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->xml( - $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() - ); - $xml->setParserProperty(2,true); + $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml->setParserProperty(2, true); $worksheetInfo = array(); while ($xml->read()) { @@ -188,8 +181,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $worksheetInfo; } - - private function _gzfileGetContents($filename) { + private function _gzfileGetContents($filename) + { $file = @gzopen($filename, 'rb'); if ($file !== false) { $data = ''; @@ -201,7 +194,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $data; } - /** * Loads PHPExcel from file * @@ -218,7 +210,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $this->loadIntoExisting($pFilename, $objPHPExcel); } - /** * Loads PHPExcel from file into PHPExcel instance * @@ -258,7 +249,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $officeDocMetaXML = $officeDocXML->meta; foreach ($officeDocMetaXML as $officePropertyData) { - $officePropertyDC = array(); if (isset($namespacesMeta['dc'])) { $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); @@ -266,24 +256,24 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx foreach ($officePropertyDC as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'title' : - $docProps->setTitle(trim($propertyValue)); - break; - case 'subject' : - $docProps->setSubject(trim($propertyValue)); - break; - case 'creator' : - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); - break; - case 'date' : - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'description' : - $docProps->setDescription(trim($propertyValue)); - break; + case 'title': + $docProps->setTitle(trim($propertyValue)); + break; + case 'subject': + $docProps->setSubject(trim($propertyValue)); + break; + case 'creator': + $docProps->setCreator(trim($propertyValue)); + $docProps->setLastModifiedBy(trim($propertyValue)); + break; + case 'date': + $creationDate = strtotime(trim($propertyValue)); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'description': + $docProps->setDescription(trim($propertyValue)); + break; } } $officePropertyMeta = array(); @@ -294,32 +284,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $attributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValue = (string) $propertyValue; switch ($propertyName) { - case 'keyword' : - $docProps->setKeywords(trim($propertyValue)); - break; - case 'initial-creator' : - $docProps->setCreator(trim($propertyValue)); - $docProps->setLastModifiedBy(trim($propertyValue)); - break; - case 'creation-date' : - $creationDate = strtotime(trim($propertyValue)); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; - case 'user-defined' : - list(, $attrName) = explode(':', $attributes['name']); - switch ($attrName) { - case 'publisher' : - $docProps->setCompany(trim($propertyValue)); - break; - case 'category' : - $docProps->setCategory(trim($propertyValue)); - break; - case 'manager' : - $docProps->setManager(trim($propertyValue)); - break; - } - break; + case 'keyword': + $docProps->setKeywords(trim($propertyValue)); + break; + case 'initial-creator': + $docProps->setCreator(trim($propertyValue)); + $docProps->setLastModifiedBy(trim($propertyValue)); + break; + case 'creation-date': + $creationDate = strtotime(trim($propertyValue)); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; + case 'user-defined': + list(, $attrName) = explode(':', $attributes['name']); + switch ($attrName) { + case 'publisher': + $docProps->setCompany(trim($propertyValue)); + break; + case 'category': + $docProps->setCategory(trim($propertyValue)); + break; + case 'manager': + $docProps->setManager(trim($propertyValue)); + break; + } + break; } } } @@ -328,26 +318,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $propertyName = $summaryItem->name; $propertyValue = $summaryItem->{'val-string'}; switch ($propertyName) { - case 'title' : + case 'title': $docProps->setTitle(trim($propertyValue)); break; - case 'comments' : + case 'comments': $docProps->setDescription(trim($propertyValue)); break; - case 'keywords' : + case 'keywords': $docProps->setKeywords(trim($propertyValue)); break; - case 'category' : + case 'category': $docProps->setCategory(trim($propertyValue)); break; - case 'manager' : + case 'manager': $docProps->setManager(trim($propertyValue)); break; - case 'author' : + case 'author': $docProps->setCreator(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue)); break; - case 'company' : + case 'company': $docProps->setCompany(trim($propertyValue)); break; } @@ -370,35 +360,35 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula // cells... during the load, all formulae should be correct, and we're simply bringing the worksheet // name in line with the formula, not the reverse - $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { if (isset($sheet->PrintInformation->Margins)) { - foreach ($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { + foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) { $marginAttributes = $margin->attributes(); $marginSize = 72 / 100; // Default switch ($marginAttributes['PrefUnit']) { - case 'mm' : + case 'mm': $marginSize = intval($marginAttributes['Points']) / 100; break; } switch ($key) { - case 'top' : + case 'top': $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); break; - case 'bottom' : + case 'bottom': $objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize); break; - case 'left' : + case 'left': $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize); break; - case 'right' : + case 'right': $objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize); break; - case 'header' : + case 'header': $objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize); break; - case 'footer' : + case 'footer': $objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize); break; } @@ -411,13 +401,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $row = (int) $cellAttributes->Row + 1; $column = (int) $cellAttributes->Col; - if ($row > $maxRow) $maxRow = $row; - if ($column > $maxCol) $maxCol = $column; + if ($row > $maxRow) { + $maxRow = $row; + } + if ($column > $maxCol) { + $maxCol = $column; + } $column = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) { continue; } @@ -431,47 +425,42 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $type = PHPExcel_Cell_DataType::TYPE_FORMULA; if ($ExprID > '') { if (((string) $cell) > '') { - - $this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col, - 'row' => $cellAttributes->Row, - 'formula' => (string) $cell - ); + $this->_expressions[$ExprID] = array( + 'column' => $cellAttributes->Col, + 'row' => $cellAttributes->Row, + 'formula' => (string) $cell + ); // echo 'NEW EXPRESSION ', $ExprID,'
'; } else { $expression = $this->_expressions[$ExprID]; - $cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'], - 'A1', - $cellAttributes->Col - $expression['column'], - $cellAttributes->Row - $expression['row'], - $worksheetName - ); + $cell = $this->_referenceHelper->updateFormulaReferences($expression['formula'], 'A1', $cellAttributes->Col - $expression['column'], $cellAttributes->Row - $expression['row'], $worksheetName); // echo 'SHARED EXPRESSION ', $ExprID,'
'; // echo 'New Value is ', $cell,'
'; } $type = PHPExcel_Cell_DataType::TYPE_FORMULA; } else { switch ($ValueType) { - case '10' : // NULL + case '10': // NULL $type = PHPExcel_Cell_DataType::TYPE_NULL; break; - case '20' : // Boolean + case '20': // Boolean $type = PHPExcel_Cell_DataType::TYPE_BOOL; - $cell = ($cell == 'TRUE') ? True : False; + $cell = ($cell == 'TRUE') ? true: false; break; - case '30' : // Integer + case '30': // Integer $cell = intval($cell); - case '40' : // Float + case '40': // Float $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; break; - case '50' : // Error + case '50': // Error $type = PHPExcel_Cell_DataType::TYPE_ERROR; break; - case '60' : // String + case '60': // String $type = PHPExcel_Cell_DataType::TYPE_STRING; break; - case '70' : // Cell Range - case '80' : // Array + case '70': // Cell Range + case '80': // Array } } $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type); @@ -482,9 +471,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $commentAttributes = $comment->attributes(); // Only comment objects are handled at the moment if ($commentAttributes->Text) { - $objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound ) - ->setAuthor( (string)$commentAttributes->Author ) - ->setText($this->_parseRichText((string)$commentAttributes->Text) ); + $objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->_parseRichText((string)$commentAttributes->Text)); } } } @@ -517,44 +504,44 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // If _readDataOnly is false, we set all formatting information if (!$this->_readDataOnly) { switch ($styleAttributes['HAlign']) { - case '1' : + case '1': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; break; - case '2' : + case '2': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT; break; - case '4' : + case '4': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT; break; - case '8' : + case '8': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER; break; - case '16' : - case '64' : + case '16': + case '64': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS; break; - case '32' : + case '32': $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY; break; } switch ($styleAttributes['VAlign']) { - case '1' : + case '1': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; break; - case '2' : + case '2': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; break; - case '4' : + case '4': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER; break; - case '8' : + case '8': $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY; break; } - $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False; - $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False; + $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false; + $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0; $RGB = self::_parseGnumericColour($styleAttributes["Fore"]); @@ -566,64 +553,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $styleArray['fill']['endcolor']['rgb'] = $RGB2; switch ($shade) { - case '1' : + case '1': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; break; - case '2' : + case '2': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR; break; - case '3' : + case '3': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH; break; - case '4' : + case '4': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; break; - case '5' : + case '5': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; break; - case '6' : + case '6': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; break; - case '7' : + case '7': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; break; - case '8' : + case '8': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; break; - case '9' : + case '9': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; break; - case '10' : + case '10': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; break; - case '11' : + case '11': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; break; - case '12' : + case '12': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; break; - case '13' : + case '13': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; break; - case '14' : + case '14': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; break; - case '15' : + case '15': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; break; - case '16' : + case '16': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; break; - case '17' : + case '17': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; break; - case '18' : + case '18': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; break; - case '19' : + case '19': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; break; - case '20' : + case '20': $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; break; } @@ -634,32 +621,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // echo '
'; $styleArray['font']['name'] = (string) $styleRegion->Style->Font; $styleArray['font']['size'] = intval($fontAttributes['Unit']); - $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; - $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; - $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; + $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false; + $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false; + $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; switch ($fontAttributes['Underline']) { - case '1' : + case '1': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; break; - case '2' : + case '2': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE; break; - case '3' : + case '3': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING; break; - case '4' : + case '4': $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING; break; - default : + default: $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; break; } switch ($fontAttributes['Script']) { - case '1' : - $styleArray['font']['superScript'] = True; + case '1': + $styleArray['font']['superScript'] = true; break; - case '-1' : - $styleArray['font']['subScript'] = True; + case '-1': + $styleArray['font']['subScript'] = true; break; } @@ -761,7 +748,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // Handle Merged Cells in this worksheet if (isset($sheet->MergedRegions)) { foreach ($sheet->MergedRegions->Merge as $mergeCells) { - if (strpos($mergeCells,':') !== FALSE) { + if (strpos($mergeCells,':') !== false) { $objPHPExcel->getActiveSheet()->mergeCells($mergeCells); } } @@ -783,17 +770,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx $range[0] = trim($range[0],"'");; if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); - $objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); + $objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange)); } } } - // Return return $objPHPExcel; } - private static function _parseBorderAttributes($borderAttributes) { $styleArray = array(); @@ -804,54 +789,54 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } switch ($borderAttributes["Style"]) { - case '0' : + case '0': $styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE; break; - case '1' : + case '1': $styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN; break; - case '2' : + case '2': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; break; - case '4' : + case '4': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED; break; - case '5' : + case '5': $styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK; break; - case '6' : + case '6': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE; break; - case '7' : + case '7': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED; break; - case '9' : + case '9': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT; break; - case '10' : + case '10': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; break; - case '11' : + case '11': $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT; break; - case '12' : + case '12': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; break; - case '13' : + case '13': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; break; - case '3' : + case '3': $styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT; break; - case '8' : + case '8': $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED; break; } return $styleArray; } - - private function _parseRichText($is = '') { + private function _parseRichText($is = '') + { $value = new PHPExcel_RichText(); $value->createText($is); @@ -859,15 +844,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx return $value; } - private static function _parseGnumericColour($gnmColour) { list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); - $gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2); - $gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2); - $gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); + $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2); + $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2); + $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2); $RGB = $gnmR.$gnmG.$gnmB; // echo 'Excel Colour: ', $RGB,'
'; return $RGB; } - } diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index c212e9bc..21a35bf7 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -51,7 +51,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce */ private $_styles = array(); - /** * Create a new PHPExcel_Reader_OOCalc */ @@ -59,7 +58,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -77,7 +75,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $zipClass = PHPExcel_Settings::getZipClass(); // Check if zip class exists -// if (!class_exists($zipClass, FALSE)) { +// if (!class_exists($zipClass, false)) { // throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); // } @@ -109,7 +107,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet'); } - return FALSE; + return false; } @@ -137,17 +135,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $xml = new XMLReader(); $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); - $xml->setParserProperty(2,true); + $xml->setParserProperty(2, true); // Step into the first level of content of the XML $xml->read(); while ($xml->read()) { // Quickly jump through to the office:body node while ($xml->name !== 'office:body') { - if ($xml->isEmptyElement) + if ($xml->isEmptyElement) { $xml->read(); - else + } else { $xml->next(); + } } // Now read each node until we find our first table:table node while ($xml->read()) { @@ -164,7 +163,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $worksheetNames; } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * @@ -189,17 +187,18 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $xml = new XMLReader(); $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); - $xml->setParserProperty(2,true); + $xml->setParserProperty(2, true); // Step into the first level of content of the XML $xml->read(); while ($xml->read()) { // Quickly jump through to the office:body node while ($xml->name !== 'office:body') { - if ($xml->isEmptyElement) + if ($xml->isEmptyElement) { $xml->read(); - else + } else { $xml->next(); + } } // Now read each node until we find our first table:table node while ($xml->read()) { @@ -289,7 +288,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $worksheetInfo; } - /** * Loads PHPExcel from file * @@ -306,8 +304,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $this->loadIntoExisting($pFilename, $objPHPExcel); } - - private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { + private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) + { $styleAttributeValue = strtolower($styleAttributeValue); foreach ($styleList as $style) { if ($styleAttributeValue == strtolower($style)) { @@ -318,7 +316,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return false; } - /** * Loads PHPExcel from file into PHPExcel instance * @@ -362,23 +359,23 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $propertyValue = (string) $propertyValue; switch ($propertyName) { case 'title' : - $docProps->setTitle($propertyValue); - break; + $docProps->setTitle($propertyValue); + break; case 'subject' : - $docProps->setSubject($propertyValue); - break; + $docProps->setSubject($propertyValue); + break; case 'creator' : - $docProps->setCreator($propertyValue); - $docProps->setLastModifiedBy($propertyValue); - break; + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + break; case 'date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - break; + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + break; case 'description' : - $docProps->setDescription($propertyValue); - break; + $docProps->setDescription($propertyValue); + break; } } $officePropertyMeta = array(); @@ -390,41 +387,41 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $propertyValue = (string) $propertyValue; switch ($propertyName) { case 'initial-creator' : - $docProps->setCreator($propertyValue); - break; + $docProps->setCreator($propertyValue); + break; case 'keyword' : - $docProps->setKeywords($propertyValue); - break; + $docProps->setKeywords($propertyValue); + break; case 'creation-date' : - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - break; + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + break; case 'user-defined' : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - foreach ($propertyValueAttributes as $key => $value) { - if ($key == 'name') { - $propertyValueName = (string) $value; - } elseif ($key == 'value-type') { - switch ($value) { - case 'date' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; - break; - case 'boolean' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; - break; - case 'float' : - $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; - break; - default : - $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; - } + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; + foreach ($propertyValueAttributes as $key => $value) { + if ($key == 'name') { + $propertyValueName = (string) $value; + } elseif ($key == 'value-type') { + switch ($value) { + case 'date' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; + break; + case 'boolean' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; + break; + case 'float' : + $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4'); + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; + break; + default : + $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; } } - $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); - break; + } + $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); + break; } } } @@ -470,7 +467,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo ''.$key.'
'; switch ($key) { case 'table-header-rows': - foreach ($rowData as $key=>$cellData) { + foreach ($rowData as $key => $cellData) { $rowData = $cellData; break; } @@ -480,7 +477,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $rowDataTableAttributes['number-rows-repeated'] : 1; $columnID = 'A'; foreach ($rowData as $key => $cellData) { - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { continue; } @@ -524,13 +521,13 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce } } $text = implode("\n", $textArray); -// echo $text,'
'; +// echo $text, '
'; $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) // ->setAuthor( $author ) ->setText($this->_parseRichText($text) ); } - if (isset($cellDataText->p)) { + if (isset($cellDataText->p)) { // Consolidate if there are multiple p records (maybe with spans as well) $dataArray = array(); // Text can have multiple text:p and within those, multiple text:span. @@ -554,85 +551,85 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'
'; switch ($cellDataOfficeAttributes['value-type']) { case 'string' : - $type = PHPExcel_Cell_DataType::TYPE_STRING; - $dataValue = $allCellDataText; - if (isset($dataValue->a)) { - $dataValue = $dataValue->a; - $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); - $hyperlink = $cellXLinkAttributes['href']; - } - break; + $type = PHPExcel_Cell_DataType::TYPE_STRING; + $dataValue = $allCellDataText; + if (isset($dataValue->a)) { + $dataValue = $dataValue->a; + $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); + $hyperlink = $cellXLinkAttributes['href']; + } + break; case 'boolean' : $type = PHPExcel_Cell_DataType::TYPE_BOOL; - $dataValue = ($allCellDataText == 'TRUE') ? True : False; + $dataValue = ($allCellDataText == 'TRUE') ? true : false; break; case 'percentage' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - $dataValue = (integer) $dataValue; - } - $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; - break; + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + $dataValue = (integer) $dataValue; + } + $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; + break; case 'currency' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - $dataValue = (integer) $dataValue; - } - $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; - break; + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + $dataValue = (integer) $dataValue; + } + $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; + break; case 'float' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = (float) $cellDataOfficeAttributes['value']; - if (floor($dataValue) == $dataValue) { - if ($dataValue == (integer) $dataValue) - $dataValue = (integer) $dataValue; - else - $dataValue = (float) $dataValue; - } - break; + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = (float) $cellDataOfficeAttributes['value']; + if (floor($dataValue) == $dataValue) { + if ($dataValue == (integer) $dataValue) + $dataValue = (integer) $dataValue; + else + $dataValue = (float) $dataValue; + } + break; case 'date' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); - $dateObj->setTimeZone($timezoneObj); - list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); - $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second); - if ($dataValue != floor($dataValue)) { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; - } else { - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; - } - break; + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); + $dateObj->setTimeZone($timezoneObj); + list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); + $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second); + if ($dataValue != floor($dataValue)) { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + } else { + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; + } + break; case 'time' : - $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; - $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); - $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; - break; + $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; + $dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS')))); + $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; + break; } // echo 'Data value is '.$dataValue.'
'; -// if ($hyperlink !== NULL) { +// if ($hyperlink !== null) { // echo 'Hyperlink is '.$hyperlink.'
'; // } } else { $type = PHPExcel_Cell_DataType::TYPE_NULL; - $dataValue = NULL; + $dataValue = null; } if ($hasCalculatedValue) { $type = PHPExcel_Cell_DataType::TYPE_FORMULA; // echo 'Formula: ', $cellDataFormula, PHP_EOL; - $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); + $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula, ':=')+1); $temp = explode('"', $cellDataFormula); $tKey = false; foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($tKey = !$tKey) { - $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet - $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2', $value); // Cell reference in another sheet - $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference - $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference - $value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces); + $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet + $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet + $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference + $value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference + $value = PHPExcel_Calculation::_translateSeparator(';', ',', $value, $inBraces); } } unset($value); @@ -641,9 +638,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; } - $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? - $cellDataTableAttributes['number-columns-repeated'] : 1; - if ($type !== NULL) { + $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $cellDataTableAttributes['number-columns-repeated'] : 1; + if ($type !== null) { for ($i = 0; $i < $colRepeats; ++$i) { if ($i > 0) { ++$columnID; @@ -656,12 +652,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Forumla result is '.$dataValue.'
'; $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); } - if ($formatting !== NULL) { + if ($formatting !== null) { $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting); } else { $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL); } - if ($hyperlink !== NULL) { + if ($hyperlink !== null) { $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink); } } @@ -699,13 +695,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce return $objPHPExcel; } - - private function _parseRichText($is = '') { + private function _parseRichText($is = '') + { $value = new PHPExcel_RichText(); $value->createText($is); return $value; } - } diff --git a/Classes/PHPExcel/Reader/SYLK.php b/Classes/PHPExcel/Reader/SYLK.php index de712d63..51c80605 100644 --- a/Classes/PHPExcel/Reader/SYLK.php +++ b/Classes/PHPExcel/Reader/SYLK.php @@ -75,7 +75,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ /** * Create a new PHPExcel_Reader_SYLK */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } @@ -97,7 +98,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Analyze first line looking for ID; signature $lines = explode("\n", $data); - if (substr($lines[0],0,4) != 'ID;P') { + if (substr($lines[0], 0, 4) != 'ID;P') { return false; } @@ -136,7 +137,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -162,20 +163,20 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) - $rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData))))); + $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); $dataType = array_shift($rowData); if ($dataType == 'C') { // Read cell value data foreach ($rowData as $rowDatum) { switch ($rowDatum{0}) { - case 'C' : - case 'X' : - $columnIndex = substr($rowDatum,1) - 1; + case 'C': + case 'X': + $columnIndex = substr($rowDatum, 1) - 1; break; - case 'R' : - case 'Y' : - $rowIndex = substr($rowDatum,1); + case 'R': + case 'Y': + $rowIndex = substr($rowDatum, 1); break; } @@ -223,7 +224,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -233,7 +234,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { $objPHPExcel->createSheet(); } - $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); + $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); $fromFormats = array('\-', '\ '); $toFormats = array('-', ' '); @@ -244,13 +245,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ // 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); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) - $rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData))))); + $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); $dataType = array_shift($rowData); // Read shared styles @@ -270,7 +270,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_ break; case 'S': $styleSettings = substr($rowDatum,1); - for ($i=0;$iL = $A->getArray(); $this->m = $A->getRowDimension(); - for($i = 0; $i < $this->m; ++$i) { - for($j = $i; $j < $this->m; ++$j) { - for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = $i; $j < $this->m; ++$j) { + for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { $sum -= $this->L[$i][$k] * $this->L[$j][$k]; } if ($i == $j) { @@ -77,35 +77,35 @@ class CholeskyDecomposition { } } // function __construct() - /** * Is the matrix symmetric and positive definite? * * @return boolean */ - public function isSPD() { + public function isSPD() + { return $this->isspd; } // function isSPD() - /** * getL * * Return triangular factor. * @return Matrix Lower triangular matrix */ - public function getL() { + public function getL() + { return new Matrix($this->L); } // function getL() - /** * Solve A*X = B * * @param $B Row-equal matrix * @return Matrix L * L' * X = B */ - public function solve($B = null) { + public function solve($B = null) + { if ($B instanceof Matrix) { if ($B->getRowDimension() == $this->m) { if ($this->isspd) { @@ -145,5 +145,4 @@ class CholeskyDecomposition { throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); } } // function solve() - -} // class CholeskyDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php b/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php index 2f9a9ab6..9a19ba52 100644 --- a/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php @@ -21,8 +21,8 @@ * @license PHP v3.0 * @version 1.1 */ -class EigenvalueDecomposition { - +class EigenvalueDecomposition +{ /** * Row and column dimension (square matrix). * @var int @@ -67,13 +67,13 @@ class EigenvalueDecomposition { private $cdivr; private $cdivi; - /** * Symmetric Householder reduction to tridiagonal form. * * @access private */ - private function tred2 () { + private function tred2 () + { // This is derived from the Algol procedures tred2 by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding @@ -171,7 +171,6 @@ class EigenvalueDecomposition { $this->e[0] = 0.0; } - /** * Symmetric tridiagonal QL algorithm. * @@ -182,7 +181,8 @@ class EigenvalueDecomposition { * * @access private */ - private function tql2() { + private function tql2() + { for ($i = 1; $i < $this->n; ++$i) { $this->e[$i-1] = $this->e[$i]; } @@ -196,8 +196,9 @@ class EigenvalueDecomposition { $tst1 = max($tst1, abs($this->d[$l]) + abs($this->e[$l])); $m = $l; while ($m < $this->n) { - if (abs($this->e[$m]) <= $eps * $tst1) + if (abs($this->e[$m]) <= $eps * $tst1) { break; + } ++$m; } // If m == l, $this->d[l] is an eigenvalue, @@ -211,14 +212,16 @@ class EigenvalueDecomposition { $g = $this->d[$l]; $p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]); $r = hypo($p, 1.0); - if ($p < 0) + if ($p < 0) { $r *= -1; + } $this->d[$l] = $this->e[$l] / ($p + $r); $this->d[$l+1] = $this->e[$l] * ($p + $r); $dl1 = $this->d[$l+1]; $h = $g - $this->d[$l]; - for ($i = $l + 2; $i < $this->n; ++$i) + for ($i = $l + 2; $i < $this->n; ++$i) { $this->d[$i] -= $h; + } $f += $h; // Implicit QL transformation. $p = $this->d[$m]; @@ -277,7 +280,6 @@ class EigenvalueDecomposition { } } - /** * Nonsymmetric reduction to Hessenberg form. * @@ -288,7 +290,8 @@ class EigenvalueDecomposition { * * @access private */ - private function orthes () { + private function orthes() + { $low = 0; $high = $this->n-1; @@ -364,13 +367,13 @@ class EigenvalueDecomposition { } } - /** * Performs complex division. * * @access private */ - private function cdiv($xr, $xi, $yr, $yi) { + private function cdiv($xr, $xi, $yr, $yi) + { if (abs($yr) > abs($yi)) { $r = $yi / $yr; $d = $yr + $r * $yi; @@ -384,7 +387,6 @@ class EigenvalueDecomposition { } } - /** * Nonsymmetric reduction from Hessenberg to real Schur form. * @@ -395,7 +397,8 @@ class EigenvalueDecomposition { * * @access private */ - private function hqr2 () { + private function hqr2() + { // Initialize $nn = $this->n; $n = $nn - 1; @@ -408,7 +411,7 @@ class EigenvalueDecomposition { $norm = 0.0; for ($i = 0; $i < $nn; ++$i) { - if (($i < $low) OR ($i > $high)) { + if (($i < $low) or ($i > $high)) { $this->d[$i] = $this->H[$i][$i]; $this->e[$i] = 0.0; } @@ -477,7 +480,7 @@ class EigenvalueDecomposition { $this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z; } // Column modification - for ($i = 0; $i <= n; ++$i) { + for ($i = 0; $i <= $n; ++$i) { $z = $this->H[$i][$n-1]; $this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n]; $this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z; @@ -771,7 +774,6 @@ class EigenvalueDecomposition { } } // end hqr2 - /** * Constructor: Check for symmetry, then construct the eigenvalue decomposition * @@ -779,7 +781,8 @@ class EigenvalueDecomposition { * @param A Square matrix * @return Structure to access D and V. */ - public function __construct($Arg) { + public function __construct($Arg) + { $this->A = $Arg->getArray(); $this->n = $Arg->getColumnDimension(); @@ -806,47 +809,47 @@ class EigenvalueDecomposition { } } - /** * Return the eigenvector matrix * * @access public * @return V */ - public function getV() { + public function getV() + { return new Matrix($this->V, $this->n, $this->n); } - /** * Return the real parts of the eigenvalues * * @access public * @return real(diag(D)) */ - public function getRealEigenvalues() { + public function getRealEigenvalues() + { return $this->d; } - /** * Return the imaginary parts of the eigenvalues * * @access public * @return imag(diag(D)) */ - public function getImagEigenvalues() { + public function getImagEigenvalues() + { return $this->e; } - /** * Return the block diagonal eigenvalue matrix * * @access public * @return D */ - public function getD() { + public function getD() + { for ($i = 0; $i < $this->n; ++$i) { $D[$i] = array_fill(0, $this->n, 0.0); $D[$i][$i] = $this->d[$i]; @@ -858,5 +861,4 @@ class EigenvalueDecomposition { } return new Matrix($D); } - -} // class EigenvalueDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php b/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php index bffda2aa..64290fe7 100644 --- a/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/LUDecomposition.php @@ -18,8 +18,8 @@ * @version 1.1 * @license PHP v3.0 */ -class PHPExcel_Shared_JAMA_LUDecomposition { - +class PHPExcel_Shared_JAMA_LUDecomposition +{ const MatrixSingularException = "Can only perform operation on singular matrix."; const MatrixSquareException = "Mismatched Row dimension"; @@ -53,14 +53,14 @@ class PHPExcel_Shared_JAMA_LUDecomposition { */ private $piv = array(); - /** * LU Decomposition constructor. * * @param $A Rectangular matrix * @return Structure to access L, U and piv. */ - public function __construct($A) { + public function __construct($A) + { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) { // Use a "left-looking", dot-product, Crout/Doolittle algorithm. $this->LU = $A->getArray(); @@ -119,13 +119,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } } // function __construct() - /** * Get lower triangular factor. * * @return array Lower triangular factor */ - public function getL() { + public function getL() + { for ($i = 0; $i < $this->m; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i > $j) { @@ -140,13 +140,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return new PHPExcel_Shared_JAMA_Matrix($L); } // function getL() - /** * Get upper triangular factor. * * @return array Upper triangular factor */ - public function getU() { + public function getU() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i <= $j) { @@ -159,33 +159,33 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return new PHPExcel_Shared_JAMA_Matrix($U); } // function getU() - /** * Return pivot permutation vector. * * @return array Pivot vector */ - public function getPivot() { + public function getPivot() + { return $this->piv; } // function getPivot() - /** * Alias for getPivot * * @see getPivot */ - public function getDoublePivot() { + public function getDoublePivot() + { return $this->getPivot(); } // function getDoublePivot() - /** * Is the matrix nonsingular? * * @return true if U, and hence A, is nonsingular. */ - public function isNonsingular() { + public function isNonsingular() + { for ($j = 0; $j < $this->n; ++$j) { if ($this->LU[$j][$j] == 0) { return false; @@ -194,13 +194,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition { return true; } // function isNonsingular() - /** * Count determinants * * @return array d matrix deterninat */ - public function det() { + public function det() + { if ($this->m == $this->n) { $d = $this->pivsign; for ($j = 0; $j < $this->n; ++$j) { @@ -212,7 +212,6 @@ class PHPExcel_Shared_JAMA_LUDecomposition { } } // function det() - /** * Solve A*X = B * @@ -221,7 +220,8 @@ class PHPExcel_Shared_JAMA_LUDecomposition { * @PHPExcel_Calculation_Exception IllegalArgumentException Matrix row dimensions must agree. * @PHPExcel_Calculation_Exception RuntimeException Matrix is singular. */ - public function solve($B) { + public function solve($B) + { if ($B->getRowDimension() == $this->m) { if ($this->isNonsingular()) { // Copy right hand side with pivoting @@ -254,5 +254,4 @@ class PHPExcel_Shared_JAMA_LUDecomposition { throw new PHPExcel_Calculation_Exception(self::MatrixSquareException); } } // function solve() - -} // class PHPExcel_Shared_JAMA_LUDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/Matrix.php b/Classes/PHPExcel/Shared/JAMA/Matrix.php index 2ab40f22..c245cc86 100644 --- a/Classes/PHPExcel/Shared/JAMA/Matrix.php +++ b/Classes/PHPExcel/Shared/JAMA/Matrix.php @@ -24,9 +24,8 @@ if (!defined('PHPEXCEL_ROOT')) { * @license PHP v3.0 * @see http://math.nist.gov/javanumerics/jama/ */ -class PHPExcel_Shared_JAMA_Matrix { - - +class PHPExcel_Shared_JAMA_Matrix +{ const PolymorphicArgumentException = "Invalid argument pattern for polymorphic function."; const ArgumentTypeException = "Invalid argument type."; const ArgumentBoundsException = "Invalid argument range."; @@ -57,13 +56,13 @@ class PHPExcel_Shared_JAMA_Matrix { */ private $n; - /** * Polymorphic constructor * * As PHP has no support for polymorphic constructors, we hack our own sort of polymorphism using func_num_args, func_get_arg, and gettype. In essence, we're just implementing a simple RTTI filter and calling the appropriate constructor. */ - public function __construct() { + public function __construct() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); @@ -71,80 +70,79 @@ class PHPExcel_Shared_JAMA_Matrix { switch ($match) { //Rectangular matrix - m x n initialized from 2D array case 'array': - $this->m = count($args[0]); - $this->n = count($args[0][0]); - $this->A = $args[0]; - break; + $this->m = count($args[0]); + $this->n = count($args[0][0]); + $this->A = $args[0]; + break; //Square matrix - n x n case 'integer': - $this->m = $args[0]; - $this->n = $args[0]; - $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); - break; + $this->m = $args[0]; + $this->n = $args[0]; + $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); + break; //Rectangular matrix - m x n case 'integer,integer': - $this->m = $args[0]; - $this->n = $args[1]; - $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); - break; + $this->m = $args[0]; + $this->n = $args[1]; + $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); + break; //Rectangular matrix - m x n initialized from packed array case 'array,integer': - $this->m = $args[1]; - if ($this->m != 0) { - $this->n = count($args[0]) / $this->m; - } else { - $this->n = 0; - } - if (($this->m * $this->n) == count($args[0])) { - for($i = 0; $i < $this->m; ++$i) { - for($j = 0; $j < $this->n; ++$j) { - $this->A[$i][$j] = $args[0][$i + $j * $this->m]; - } + $this->m = $args[1]; + if ($this->m != 0) { + $this->n = count($args[0]) / $this->m; + } else { + $this->n = 0; + } + if (($this->m * $this->n) == count($args[0])) { + for($i = 0; $i < $this->m; ++$i) { + for($j = 0; $j < $this->n; ++$j) { + $this->A[$i][$j] = $args[0][$i + $j * $this->m]; } - } else { - throw new PHPExcel_Calculation_Exception(self::ArrayLengthException); } - break; + } else { + throw new PHPExcel_Calculation_Exception(self::ArrayLengthException); + } + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function __construct() - /** * getArray * * @return array Matrix array */ - public function getArray() { + public function getArray() + { return $this->A; } // function getArray() - /** * getRowDimension * * @return int Row dimension */ - public function getRowDimension() { + public function getRowDimension() + { return $this->m; } // function getRowDimension() - /** * getColumnDimension * * @return int Column dimension */ - public function getColumnDimension() { + public function getColumnDimension() + { return $this->n; } // function getColumnDimension() - /** * get * @@ -153,11 +151,11 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $j Column position * @return mixed Element (int/float/double) */ - public function get($i = null, $j = null) { + public function get($i = null, $j = null) + { return $this->A[$i][$j]; } // function get() - /** * getMatrix * @@ -168,7 +166,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $jF Final column index * @return Matrix Submatrix */ - public function getMatrix() { + public function getMatrix() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); @@ -176,92 +175,91 @@ class PHPExcel_Shared_JAMA_Matrix { switch ($match) { //A($i0...; $j0...) case 'integer,integer': - list($i0, $j0) = $args; - if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = $i0; $i < $this->m; ++$i) { - for($j = $j0; $j < $this->n; ++$j) { - $R->set($i, $j, $this->A[$i][$j]); - } + list($i0, $j0) = $args; + if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for($i = $i0; $i < $this->m; ++$i) { + for($j = $j0; $j < $this->n; ++$j) { + $R->set($i, $j, $this->A[$i][$j]); } - return $R; - break; + } + return $R; + break; //A($i0...$iF; $j0...$jF) case 'integer,integer,integer,integer': - list($i0, $iF, $j0, $jF) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1); - for($i = $i0; $i <= $iF; ++$i) { - for($j = $j0; $j <= $jF; ++$j) { - $R->set($i - $i0, $j - $j0, $this->A[$i][$j]); - } + list($i0, $iF, $j0, $jF) = $args; + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1); + for($i = $i0; $i <= $iF; ++$i) { + for($j = $j0; $j <= $jF; ++$j) { + $R->set($i - $i0, $j - $j0, $this->A[$i][$j]); } - return $R; - break; + } + return $R; + break; //$R = array of row indices; $C = array of column indices case 'array,array': - list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = 0; $i < $m; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]); - } + list($RL, $CL) = $args; + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for($i = 0; $i < $m; ++$i) { + for($j = 0; $j < $n; ++$j) { + $R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]); } - return $R; - break; + } + return $R; + break; //$RL = array of row indices; $CL = array of column indices case 'array,array': - list($RL, $CL) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = 0; $i < $m; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]); - } + list($RL, $CL) = $args; + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for($i = 0; $i < $m; ++$i) { + for($j = 0; $j < $n; ++$j) { + $R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]); } - return $R; - break; + } + return $R; + break; //A($i0...$iF); $CL = array of column indices case 'integer,integer,array': - list($i0, $iF, $CL) = $args; - if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); - for($i = $i0; $i < $iF; ++$i) { - for($j = 0; $j < $n; ++$j) { - $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]); - } + list($i0, $iF, $CL) = $args; + if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (count($CL) > 0) { $n = count($CL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); + for($i = $i0; $i < $iF; ++$i) { + for($j = 0; $j < $n; ++$j) { + $R->set($i - $i0, $j, $this->A[$RL[$i]][$j]); } - return $R; - break; + } + return $R; + break; //$RL = array of row indices case 'array,integer,integer': - list($RL, $j0, $jF) = $args; - if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } - $R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1); - for($i = 0; $i < $m; ++$i) { - for($j = $j0; $j <= $jF; ++$j) { - $R->set($i, $j - $j0, $this->A[$RL[$i]][$j]); - } + list($RL, $j0, $jF) = $args; + if (count($RL) > 0) { $m = count($RL); } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException); } + $R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1); + for($i = 0; $i < $m; ++$i) { + for($j = $j0; $j <= $jF; ++$j) { + $R->set($i, $j - $j0, $this->A[$RL[$i]][$j]); } - return $R; - break; + } + return $R; + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function getMatrix() - /** * checkMatrixDimensions * @@ -269,7 +267,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return boolean */ - public function checkMatrixDimensions($B = null) { + public function checkMatrixDimensions($B = null) + { if ($B instanceof PHPExcel_Shared_JAMA_Matrix) { if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) { return true; @@ -281,8 +280,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function checkMatrixDimensions() - - /** * set * @@ -292,12 +289,12 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $c Int/float/double value * @return mixed Element (int/float/double) */ - public function set($i = null, $j = null, $c = null) { + public function set($i = null, $j = null, $c = null) + { // Optimized set version just has this $this->A[$i][$j] = $c; } // function set() - /** * identity * @@ -306,11 +303,11 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $n Column dimension * @return Matrix Identity matrix */ - public function identity($m = null, $n = null) { + public function identity($m = null, $n = null) + { return $this->diagonal($m, $n, 1); } // function identity() - /** * diagonal * @@ -320,7 +317,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $c Diagonal value * @return Matrix Diagonal matrix */ - public function diagonal($m = null, $n = null, $c = 1) { + public function diagonal($m = null, $n = null, $c = 1) + { $R = new PHPExcel_Shared_JAMA_Matrix($m, $n); for($i = 0; $i < $m; ++$i) { $R->set($i, $i, $c); @@ -328,7 +326,6 @@ class PHPExcel_Shared_JAMA_Matrix { return $R; } // function diagonal() - /** * getMatrixByRow * @@ -337,7 +334,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $iF Final row index * @return Matrix Submatrix */ - public function getMatrixByRow($i0 = null, $iF = null) { + public function getMatrixByRow($i0 = null, $iF = null) + { if (is_int($i0)) { if (is_int($iF)) { return $this->getMatrix($i0, 0, $iF + 1, $this->n); @@ -349,7 +347,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function getMatrixByRow() - /** * getMatrixByCol * @@ -358,7 +355,8 @@ class PHPExcel_Shared_JAMA_Matrix { * @param int $iF Final column index * @return Matrix Submatrix */ - public function getMatrixByCol($j0 = null, $jF = null) { + public function getMatrixByCol($j0 = null, $jF = null) + { if (is_int($j0)) { if (is_int($jF)) { return $this->getMatrix(0, $j0, $this->m, $jF + 1); @@ -370,14 +368,14 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function getMatrixByCol() - /** * transpose * * Tranpose matrix * @return Matrix Transposed matrix */ - public function transpose() { + public function transpose() + { $R = new PHPExcel_Shared_JAMA_Matrix($this->n, $this->m); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { @@ -387,14 +385,14 @@ class PHPExcel_Shared_JAMA_Matrix { return $R; } // function transpose() - /** * trace * * Sum of diagonal elements * @return float Sum of diagonal elements */ - public function trace() { + public function trace() + { $s = 0; $n = min($this->m, $this->n); for($i = 0; $i < $n; ++$i) { @@ -403,17 +401,16 @@ class PHPExcel_Shared_JAMA_Matrix { return $s; } // function trace() - /** * uminus * * Unary minus matrix -A * @return Matrix Unary minus matrix */ - public function uminus() { + public function uminus() + { } // function uminus() - /** * plus * @@ -421,21 +418,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function plus() { + public function plus() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -449,7 +451,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function plus() - /** * plusEquals * @@ -457,26 +458,31 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function plusEquals() { + public function plusEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + $validValues = true; $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],'"'); @@ -499,7 +505,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function plusEquals() - /** * minus * @@ -507,21 +512,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function minus() { + public function minus() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -535,7 +545,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function minus() - /** * minusEquals * @@ -543,26 +552,31 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function minusEquals() { + public function minusEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + $validValues = true; $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],'"'); @@ -585,7 +599,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function minusEquals() - /** * arrayTimes * @@ -594,21 +607,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Cij */ - public function arrayTimes() { + public function arrayTimes() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -622,7 +640,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function arrayTimes() - /** * arrayTimesEquals * @@ -631,26 +648,31 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayTimesEquals() { + public function arrayTimesEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + $validValues = true; $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],'"'); @@ -673,7 +695,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function arrayTimesEquals() - /** * arrayRightDivide * @@ -682,26 +703,31 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return Matrix Division result */ - public function arrayRightDivide() { + public function arrayRightDivide() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + $validValues = true; $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],'"'); @@ -738,21 +764,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayRightDivideEquals() { + public function arrayRightDivideEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -775,21 +806,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param Matrix $B Matrix B * @return Matrix Division result */ - public function arrayLeftDivide() { + public function arrayLeftDivide() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -812,21 +848,26 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Matrix Aij */ - public function arrayLeftDivideEquals() { + public function arrayLeftDivideEquals() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -848,90 +889,94 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $n Matrix/Array/Scalar * @return Matrix Product */ - public function times() { + public function times() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - if ($this->n == $B->m) { - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); - for($j = 0; $j < $B->n; ++$j) { - for ($k = 0; $k < $this->n; ++$k) { - $Bcolj[$k] = $B->A[$k][$j]; - } - for($i = 0; $i < $this->m; ++$i) { - $Arowi = $this->A[$i]; - $s = 0; - for($k = 0; $k < $this->n; ++$k) { - $s += $Arowi[$k] * $Bcolj[$k]; - } - $C->A[$i][$j] = $s; - } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $B = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + if ($this->n == $B->m) { + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); + for($j = 0; $j < $B->n; ++$j) { + for ($k = 0; $k < $this->n; ++$k) { + $Bcolj[$k] = $B->A[$k][$j]; + } + for($i = 0; $i < $this->m; ++$i) { + $Arowi = $this->A[$i]; + $s = 0; + for($k = 0; $k < $this->n; ++$k) { + $s += $Arowi[$k] * $Bcolj[$k]; + } + $C->A[$i][$j] = $s; } - return $C; - } else { - throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } - break; + return $C; + } else { + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); + } + break; case 'array': - $B = new PHPExcel_Shared_JAMA_Matrix($args[0]); - if ($this->n == $B->m) { - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $s = "0"; - for($k = 0; $k < $C->n; ++$k) { - $s += $this->A[$i][$k] * $B->A[$k][$j]; - } - $C->A[$i][$j] = $s; + $B = new PHPExcel_Shared_JAMA_Matrix($args[0]); + if ($this->n == $B->m) { + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n); + for($i = 0; $i < $C->m; ++$i) { + for($j = 0; $j < $C->n; ++$j) { + $s = "0"; + for($k = 0; $k < $C->n; ++$k) { + $s += $this->A[$i][$k] * $B->A[$k][$j]; } + $C->A[$i][$j] = $s; } - return $C; - } else { - throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); } - return $M; - break; + return $C; + } else { + throw new PHPExcel_Calculation_Exception(JAMAError(MatrixDimensionMismatch)); + } + return $M; + break; case 'integer': - $C = new PHPExcel_Shared_JAMA_Matrix($this->A); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] *= $args[0]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->A); + for($i = 0; $i < $C->m; ++$i) { + for($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] *= $args[0]; } - return $C; - break; + } + return $C; + break; case 'double': - $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] = $args[0] * $this->A[$i][$j]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n); + for($i = 0; $i < $C->m; ++$i) { + for($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] = $args[0] * $this->A[$i][$j]; } - return $C; - break; + } + return $C; + break; case 'float': - $C = new PHPExcel_Shared_JAMA_Matrix($this->A); - for($i = 0; $i < $C->m; ++$i) { - for($j = 0; $j < $C->n; ++$j) { - $C->A[$i][$j] *= $args[0]; - } + $C = new PHPExcel_Shared_JAMA_Matrix($this->A); + for($i = 0; $i < $C->m; ++$i) { + for($j = 0; $j < $C->n; ++$j) { + $C->A[$i][$j] *= $args[0]; } - return $C; - break; + } + return $C; + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } } else { throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); } } // function times() - /** * power * @@ -939,26 +984,31 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function power() { + public function power() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } - break; + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } + break; case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { for($j = 0; $j < $this->n; ++$j) { - $validValues = True; + $validValues = true; $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],'"'); @@ -981,7 +1031,6 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function power() - /** * concat * @@ -989,20 +1038,25 @@ class PHPExcel_Shared_JAMA_Matrix { * @param mixed $B Matrix/Array * @return Matrix Sum */ - public function concat() { + public function concat() + { if (func_num_args() > 0) { $args = func_get_args(); $match = implode(",", array_map('gettype', $args)); switch ($match) { case 'object': - if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } + if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { + $M = $args[0]; + } else { + throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); + } case 'array': - $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); - break; + $M = new PHPExcel_Shared_JAMA_Matrix($args[0]); + break; default: - throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); - break; + throw new PHPExcel_Calculation_Exception(self::PolymorphicArgumentException); + break; } $this->checkMatrixDimensions($M); for($i = 0; $i < $this->m; ++$i) { @@ -1016,14 +1070,14 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function concat() - /** * Solve A*X = B. * * @param Matrix $B Right hand side * @return Matrix ... Solution if A is square, least squares solution otherwise */ - public function solve($B) { + public function solve($B) + { if ($this->m == $this->n) { $LU = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $LU->solve($B); @@ -1033,24 +1087,24 @@ class PHPExcel_Shared_JAMA_Matrix { } } // function solve() - /** * Matrix inverse or pseudoinverse. * * @return Matrix ... Inverse(A) if A is square, pseudoinverse otherwise. */ - public function inverse() { + public function inverse() + { return $this->solve($this->identity($this->m, $this->m)); } // function inverse() - /** * det * * Calculate determinant * @return float Determinant */ - public function det() { + public function det() + { $L = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $L->det(); } // function det() diff --git a/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php b/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php index fa832caf..c76f9235 100644 --- a/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/QRDecomposition.php @@ -16,8 +16,8 @@ * @license PHP v3.0 * @version 1.1 */ -class PHPExcel_Shared_JAMA_QRDecomposition { - +class PHPExcel_Shared_JAMA_QRDecomposition +{ const MatrixRankException = "Can only perform operation on full-rank matrix."; /** @@ -51,7 +51,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition { * @param matrix $A Rectangular matrix * @return Structure to access R and the Householder vectors and compute Q. */ - public function __construct($A) { + public function __construct($A) + { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) { // Initialize. $this->QR = $A->getArrayCopy(); @@ -98,7 +99,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition { * * @return boolean true if R, and hence A, has full rank, else false. */ - public function isFullRank() { + public function isFullRank() + { for ($j = 0; $j < $this->n; ++$j) { if ($this->Rdiag[$j] == 0) { return false; @@ -107,13 +109,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return true; } // function isFullRank() - /** * Return the Householder vectors * * @return Matrix Lower trapezoidal matrix whose columns define the reflections */ - public function getH() { + public function getH() + { for ($i = 0; $i < $this->m; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i >= $j) { @@ -126,13 +128,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($H); } // function getH() - /** * Return the upper triangular factor * * @return Matrix upper triangular factor */ - public function getR() { + public function getR() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { if ($i < $j) { @@ -147,13 +149,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($R); } // function getR() - /** * Generate and return the (economy-sized) orthogonal factor * * @return Matrix orthogonal factor */ - public function getQ() { + public function getQ() + { for ($k = $this->n-1; $k >= 0; --$k) { for ($i = 0; $i < $this->m; ++$i) { $Q[$i][$k] = 0.0; @@ -184,14 +186,14 @@ class PHPExcel_Shared_JAMA_QRDecomposition { return new PHPExcel_Shared_JAMA_Matrix($Q); } // function getQ() - /** * Least squares solution of A*X = B * * @param Matrix $B A Matrix with as many rows as A and any number of columns. * @return Matrix Matrix that minimizes the two norm of Q*R*X-B. */ - public function solve($B) { + public function solve($B) + { if ($B->getRowDimension() == $this->m) { if ($this->isFullRank()) { // Copy right hand side @@ -230,5 +232,5 @@ class PHPExcel_Shared_JAMA_QRDecomposition { throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); } } // function solve() +} -} // PHPExcel_Shared_JAMA_class QRDecomposition diff --git a/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php b/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php index f20668ac..3a36f299 100644 --- a/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php +++ b/Classes/PHPExcel/Shared/JAMA/SingularValueDecomposition.php @@ -17,8 +17,8 @@ * @license PHP v3.0 * @version 1.1 */ -class SingularValueDecomposition { - +class SingularValueDecomposition +{ /** * Internal storage of U. * @var array @@ -49,7 +49,6 @@ class SingularValueDecomposition { */ private $n; - /** * Construct the singular value decomposition * @@ -58,8 +57,8 @@ class SingularValueDecomposition { * @param $A Rectangular matrix * @return Structure to access U, S and V. */ - public function __construct($Arg) { - + public function __construct($Arg) + { // Initialize. $A = $Arg->getArrayCopy(); $this->m = $Arg->getRowDimension(); @@ -75,7 +74,6 @@ class SingularValueDecomposition { // Reduce A to bidiagonal form, storing the diagonal elements // in s and the super-diagonal elements in e. for ($k = 0; $k < max($nct, $nrt); ++$k) { - if ($k < $nct) { // Compute the transformation for the k-th column and // place the k-th diagonal in s[$k]. @@ -113,7 +111,7 @@ class SingularValueDecomposition { } } - if ($wantu AND ($k < $nct)) { + if ($wantu and ($k < $nct)) { // Place the transformation in U for subsequent back // multiplication. for ($i = $k; $i < $this->m; ++$i) { @@ -139,7 +137,7 @@ class SingularValueDecomposition { $e[$k+1] += 1.0; } $e[$k] = -$e[$k]; - if (($k+1 < $this->m) AND ($e[$k] != 0.0)) { + if (($k+1 < $this->m) and ($e[$k] != 0.0)) { // Apply the transformation. for ($i = $k+1; $i < $this->m; ++$i) { $work[$i] = 0.0; @@ -198,7 +196,7 @@ class SingularValueDecomposition { $this->U[$i][$j] += $t * $this->U[$i][$k]; } } - for ($i = $k; $i < $this->m; ++$i ) { + for ($i = $k; $i < $this->m; ++$i) { $this->U[$i][$k] = -$this->U[$i][$k]; } $this->U[$k][$k] = 1.0 + $this->U[$k][$k]; @@ -217,7 +215,7 @@ class SingularValueDecomposition { // If required, generate V. if ($wantv) { for ($k = $this->n - 1; $k >= 0; --$k) { - if (($k < $nrt) AND ($e[$k] != 0.0)) { + if (($k < $nrt) and ($e[$k] != 0.0)) { for ($j = $k + 1; $j < $nu; ++$j) { $t = 0; for ($i = $k + 1; $i < $this->n; ++$i) { @@ -288,145 +286,143 @@ class SingularValueDecomposition { switch ($kase) { // Deflate negligible s(p). case 1: - $f = $e[$p-2]; - $e[$p-2] = 0.0; - for ($j = $p - 2; $j >= $k; --$j) { - $t = hypo($this->s[$j], $f); - $cs = $this->s[$j] / $t; - $sn = $f / $t; - $this->s[$j] = $t; - if ($j != $k) { - $f = -$sn * $e[$j-1]; - $e[$j-1] = $cs * $e[$j-1]; - } - if ($wantv) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1]; - $this->V[$i][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1]; - $this->V[$i][$j] = $t; - } + $f = $e[$p-2]; + $e[$p-2] = 0.0; + for ($j = $p - 2; $j >= $k; --$j) { + $t = hypo($this->s[$j], $f); + $cs = $this->s[$j] / $t; + $sn = $f / $t; + $this->s[$j] = $t; + if ($j != $k) { + $f = -$sn * $e[$j-1]; + $e[$j-1] = $cs * $e[$j-1]; + } + if ($wantv) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1]; + $this->V[$i][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1]; + $this->V[$i][$j] = $t; } } - break; + } + break; // Split at negligible s(k). case 2: - $f = $e[$k-1]; - $e[$k-1] = 0.0; - for ($j = $k; $j < $p; ++$j) { - $t = hypo($this->s[$j], $f); - $cs = $this->s[$j] / $t; - $sn = $f / $t; - $this->s[$j] = $t; - $f = -$sn * $e[$j]; - $e[$j] = $cs * $e[$j]; - if ($wantu) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1]; - $this->U[$i][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1]; - $this->U[$i][$j] = $t; - } + $f = $e[$k-1]; + $e[$k-1] = 0.0; + for ($j = $k; $j < $p; ++$j) { + $t = hypo($this->s[$j], $f); + $cs = $this->s[$j] / $t; + $sn = $f / $t; + $this->s[$j] = $t; + $f = -$sn * $e[$j]; + $e[$j] = $cs * $e[$j]; + if ($wantu) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1]; + $this->U[$i][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1]; + $this->U[$i][$j] = $t; } } - break; + } + break; // Perform one qr step. case 3: - // Calculate the shift. - $scale = max(max(max(max( - abs($this->s[$p-1]),abs($this->s[$p-2])),abs($e[$p-2])), - abs($this->s[$k])), abs($e[$k])); - $sp = $this->s[$p-1] / $scale; - $spm1 = $this->s[$p-2] / $scale; - $epm1 = $e[$p-2] / $scale; - $sk = $this->s[$k] / $scale; - $ek = $e[$k] / $scale; - $b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0; - $c = ($sp * $epm1) * ($sp * $epm1); - $shift = 0.0; - if (($b != 0.0) || ($c != 0.0)) { - $shift = sqrt($b * $b + $c); - if ($b < 0.0) { - $shift = -$shift; - } - $shift = $c / ($b + $shift); + // Calculate the shift. + $scale = max(max(max(max(abs($this->s[$p-1]), abs($this->s[$p-2])), abs($e[$p-2])), abs($this->s[$k])), abs($e[$k])); + $sp = $this->s[$p-1] / $scale; + $spm1 = $this->s[$p-2] / $scale; + $epm1 = $e[$p-2] / $scale; + $sk = $this->s[$k] / $scale; + $ek = $e[$k] / $scale; + $b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0; + $c = ($sp * $epm1) * ($sp * $epm1); + $shift = 0.0; + if (($b != 0.0) || ($c != 0.0)) { + $shift = sqrt($b * $b + $c); + if ($b < 0.0) { + $shift = -$shift; } - $f = ($sk + $sp) * ($sk - $sp) + $shift; - $g = $sk * $ek; - // Chase zeros. - for ($j = $k; $j < $p-1; ++$j) { - $t = hypo($f, $g); - $cs = $f/$t; - $sn = $g/$t; - if ($j != $k) { - $e[$j-1] = $t; - } - $f = $cs * $this->s[$j] + $sn * $e[$j]; - $e[$j] = $cs * $e[$j] - $sn * $this->s[$j]; - $g = $sn * $this->s[$j+1]; - $this->s[$j+1] = $cs * $this->s[$j+1]; - if ($wantv) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1]; - $this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1]; - $this->V[$i][$j] = $t; - } - } - $t = hypo($f, $g); - $cs = $f/$t; - $sn = $g/$t; - $this->s[$j] = $t; - $f = $cs * $e[$j] + $sn * $this->s[$j+1]; - $this->s[$j+1] = -$sn * $e[$j] + $cs * $this->s[$j+1]; - $g = $sn * $e[$j+1]; - $e[$j+1] = $cs * $e[$j+1]; - if ($wantu && ($j < $this->m - 1)) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$j+1]; - $this->U[$i][$j+1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$j+1]; - $this->U[$i][$j] = $t; - } + $shift = $c / ($b + $shift); + } + $f = ($sk + $sp) * ($sk - $sp) + $shift; + $g = $sk * $ek; + // Chase zeros. + for ($j = $k; $j < $p-1; ++$j) { + $t = hypo($f, $g); + $cs = $f/$t; + $sn = $g/$t; + if ($j != $k) { + $e[$j-1] = $t; + } + $f = $cs * $this->s[$j] + $sn * $e[$j]; + $e[$j] = $cs * $e[$j] - $sn * $this->s[$j]; + $g = $sn * $this->s[$j+1]; + $this->s[$j+1] = $cs * $this->s[$j+1]; + if ($wantv) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1]; + $this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1]; + $this->V[$i][$j] = $t; } } - $e[$p-2] = $f; - $iter = $iter + 1; - break; + $t = hypo($f, $g); + $cs = $f/$t; + $sn = $g/$t; + $this->s[$j] = $t; + $f = $cs * $e[$j] + $sn * $this->s[$j+1]; + $this->s[$j+1] = -$sn * $e[$j] + $cs * $this->s[$j+1]; + $g = $sn * $e[$j+1]; + $e[$j+1] = $cs * $e[$j+1]; + if ($wantu && ($j < $this->m - 1)) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$j+1]; + $this->U[$i][$j+1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$j+1]; + $this->U[$i][$j] = $t; + } + } + } + $e[$p-2] = $f; + $iter = $iter + 1; + break; // Convergence. case 4: - // Make the singular values positive. - if ($this->s[$k] <= 0.0) { - $this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0); - if ($wantv) { - for ($i = 0; $i <= $pp; ++$i) { - $this->V[$i][$k] = -$this->V[$i][$k]; - } + // Make the singular values positive. + if ($this->s[$k] <= 0.0) { + $this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0); + if ($wantv) { + for ($i = 0; $i <= $pp; ++$i) { + $this->V[$i][$k] = -$this->V[$i][$k]; } } - // Order the singular values. - while ($k < $pp) { - if ($this->s[$k] >= $this->s[$k+1]) { - break; - } - $t = $this->s[$k]; - $this->s[$k] = $this->s[$k+1]; - $this->s[$k+1] = $t; - if ($wantv AND ($k < $this->n - 1)) { - for ($i = 0; $i < $this->n; ++$i) { - $t = $this->V[$i][$k+1]; - $this->V[$i][$k+1] = $this->V[$i][$k]; - $this->V[$i][$k] = $t; - } - } - if ($wantu AND ($k < $this->m-1)) { - for ($i = 0; $i < $this->m; ++$i) { - $t = $this->U[$i][$k+1]; - $this->U[$i][$k+1] = $this->U[$i][$k]; - $this->U[$i][$k] = $t; - } - } - ++$k; + } + // Order the singular values. + while ($k < $pp) { + if ($this->s[$k] >= $this->s[$k+1]) { + break; } - $iter = 0; - --$p; - break; + $t = $this->s[$k]; + $this->s[$k] = $this->s[$k+1]; + $this->s[$k+1] = $t; + if ($wantv and ($k < $this->n - 1)) { + for ($i = 0; $i < $this->n; ++$i) { + $t = $this->V[$i][$k+1]; + $this->V[$i][$k+1] = $this->V[$i][$k]; + $this->V[$i][$k] = $t; + } + } + if ($wantu and ($k < $this->m-1)) { + for ($i = 0; $i < $this->m; ++$i) { + $t = $this->U[$i][$k+1]; + $this->U[$i][$k+1] = $this->U[$i][$k]; + $this->U[$i][$k] = $t; + } + } + ++$k; + } + $iter = 0; + --$p; + break; } // end switch } // end while @@ -439,7 +435,8 @@ class SingularValueDecomposition { * @access public * @return U */ - public function getU() { + public function getU() + { return new Matrix($this->U, $this->m, min($this->m + 1, $this->n)); } @@ -450,7 +447,8 @@ class SingularValueDecomposition { * @access public * @return V */ - public function getV() { + public function getV() + { return new Matrix($this->V); } @@ -461,7 +459,8 @@ class SingularValueDecomposition { * @access public * @return diagonal of S. */ - public function getSingularValues() { + public function getSingularValues() + { return $this->s; } @@ -472,7 +471,8 @@ class SingularValueDecomposition { * @access public * @return S */ - public function getS() { + public function getS() + { for ($i = 0; $i < $this->n; ++$i) { for ($j = 0; $j < $this->n; ++$j) { $S[$i][$j] = 0.0; @@ -489,7 +489,8 @@ class SingularValueDecomposition { * @access public * @return max(S) */ - public function norm2() { + public function norm2() + { return $this->s[0]; } @@ -500,7 +501,8 @@ class SingularValueDecomposition { * @access public * @return max(S)/min(S) */ - public function cond() { + public function cond() + { return $this->s[0] / $this->s[min($this->m, $this->n) - 1]; } @@ -511,7 +513,8 @@ class SingularValueDecomposition { * @access public * @return Number of nonnegligible singular values. */ - public function rank() { + public function rank() + { $eps = pow(2.0, -52.0); $tol = max($this->m, $this->n) * $this->s[0] * $eps; $r = 0; @@ -522,5 +525,4 @@ class SingularValueDecomposition { } return $r; } - -} // class SingularValueDecomposition +} diff --git a/Classes/PHPExcel/Shared/JAMA/utils/Error.php b/Classes/PHPExcel/Shared/JAMA/utils/Error.php index ff51ccc5..155bcba0 100644 --- a/Classes/PHPExcel/Shared/JAMA/utils/Error.php +++ b/Classes/PHPExcel/Shared/JAMA/utils/Error.php @@ -67,7 +67,8 @@ $error['EN'][RowLengthException] = "All rows must have the same length."; * Custom error handler * @param int $num Error number */ -function JAMAError($errorNumber = null) { +function JAMAError($errorNumber = null) +{ global $error; if (isset($errorNumber)) { diff --git a/Classes/PHPExcel/Shared/JAMA/utils/Maths.php b/Classes/PHPExcel/Shared/JAMA/utils/Maths.php index 922784c5..6d4db65a 100644 --- a/Classes/PHPExcel/Shared/JAMA/utils/Maths.php +++ b/Classes/PHPExcel/Shared/JAMA/utils/Maths.php @@ -11,7 +11,8 @@ * * r = sqrt(a^2 + b^2) without under/overflow. */ -function hypo($a, $b) { +function hypo($a, $b) +{ if (abs($a) > abs($b)) { $r = $b / $a; $r = abs($a) * sqrt(1 + $r * $r); diff --git a/Classes/PHPExcel/Shared/OLE/PPS/Root.php b/Classes/PHPExcel/Shared/OLE/PPS/Root.php index b2278c4e..e2ae5328 100644 --- a/Classes/PHPExcel/Shared/OLE/PPS/Root.php +++ b/Classes/PHPExcel/Shared/OLE/PPS/Root.php @@ -73,8 +73,9 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS if (is_resource($filename)) { $this->_FILEH_ = $filename; } else if ($filename == '-' || $filename == '') { - if ($this->_tmp_dir === null) + if ($this->_tmp_dir === null) { $this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir(); + } $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); if ($this->_FILEH_ == false) { @@ -105,8 +106,8 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); if (!is_resource($filename)) { - fclose($this->_FILEH_); - } + fclose($this->_FILEH_); + } return true; } @@ -199,33 +200,35 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS } // Save Header - fwrite($FILE, - "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . pack("v", 0x3b) - . pack("v", 0x03) - . pack("v", -2) - . pack("v", 9) - . pack("v", 6) - . pack("v", 0) - . "\x00\x00\x00\x00" - . "\x00\x00\x00\x00" - . pack("V", $iBdCnt) - . pack("V", $iBBcnt+$iSBDcnt) //ROOT START - . pack("V", 0) - . pack("V", 0x1000) - . pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot - . pack("V", $iSBDcnt) + fwrite( + $FILE, + "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("v", 0x3b) + . pack("v", 0x03) + . pack("v", -2) + . pack("v", 9) + . pack("v", 6) + . pack("v", 0) + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("V", $iBdCnt) + . pack("V", $iBBcnt+$iSBDcnt) //ROOT START + . pack("V", 0) + . pack("V", 0x1000) + . pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot + . pack("V", $iSBDcnt) ); // Extra BDList Start, Count if ($iBdCnt < $i1stBdL) { - fwrite($FILE, - pack("V", -2) // Extra BDList Start - . pack("V", 0) // Extra BDList Count - ); + fwrite( + $FILE, + pack("V", -2) // Extra BDList Start + . pack("V", 0)// Extra BDList Count + ); } else { fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL)); } @@ -258,9 +261,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS for ($i = 0; $i < $iCount; ++$i) { if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) { $raList[$i]->Size = $raList[$i]->_DataLen(); - if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || - (($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) - { + if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || (($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) { // Write Data //if (isset($raList[$i]->_PPS_FILE)) { // $iLen = 0; @@ -366,7 +367,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS $iCnt = count($raList); $iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE; if ($iCnt % $iBCnt) { - fwrite($this->_FILEH_, str_repeat("\x00",($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE)); + fwrite($this->_FILEH_, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE)); } } diff --git a/Classes/PHPExcel/Shared/OLERead.php b/Classes/PHPExcel/Shared/OLERead.php index f43567d7..54b0fadd 100644 --- a/Classes/PHPExcel/Shared/OLERead.php +++ b/Classes/PHPExcel/Shared/OLERead.php @@ -28,7 +28,8 @@ defined('IDENTIFIER_OLE') || define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); -class PHPExcel_Shared_OLERead { +class PHPExcel_Shared_OLERead +{ private $data = ''; // OLE identifier diff --git a/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php b/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php index d0c772a5..3b557a06 100644 --- a/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php +++ b/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php @@ -3136,7 +3136,7 @@ class PclZip $v_extract = true; } } - }else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + } else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { // ----- Look for extract by preg rule if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { $v_extract = true; @@ -3167,7 +3167,6 @@ class PclZip // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { - $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is compressed by an unsupported compression method (".$v_header['compression'].") "); @@ -3249,9 +3248,8 @@ class PclZip if ($v_result1 == 2) { break; } - } - // ----- Look for extraction in standard output - elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + } elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Look for extraction in standard output // ----- Extracting the file in standard output $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); if ($v_result1 < 1) { @@ -3369,7 +3367,7 @@ class PclZip if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']); if ($v_inclusion == 0) { - PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,"Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); return PclZip::errorCode(); } @@ -3410,7 +3408,6 @@ class PclZip if (file_exists($p_entry['filename'])) { // ----- Look if file is a directory if (is_dir($p_entry['filename'])) { - // ----- Change the file status $p_entry['status'] = "already_a_directory"; @@ -3444,21 +3441,19 @@ class PclZip // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists and option PCLZIP_OPT_REPLACE_NEWER is not selected"); - return PclZip::errorCode(); - } + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + return PclZip::errorCode(); + } } } else { } } else { - // ----- Check the directory availability and create it if necessary + // ----- Check the directory availability and create it if necessary if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { $v_dir_to_check = $p_entry['filename']; - } - else if (!strstr($p_entry['filename'], "/")) { + } else if (!strstr($p_entry['filename'], "/")) { $v_dir_to_check = ""; - } - else { + } else { $v_dir_to_check = dirname($p_entry['filename']); } @@ -3530,7 +3525,6 @@ class PclZip $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === false) { - // ----- Change the file status // TBC $p_entry['status'] = "error"; @@ -3540,7 +3534,6 @@ class PclZip // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { - // ----- Change the file status $p_entry['status'] = "write_error"; @@ -3723,7 +3716,6 @@ class PclZip if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compressed_size'] == $p_entry['size']) { - // ----- Read the file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); @@ -3731,7 +3723,6 @@ class PclZip echo $v_buffer; unset($v_buffer); } else { - // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); @@ -3791,7 +3782,7 @@ class PclZip // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { - // TBC + // TBC } // ----- Look for pre-extract callback @@ -3830,17 +3821,15 @@ class PclZip // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { - // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { - // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === false) { - // TBC + // TBC } } // ----- Trace @@ -4037,8 +4026,7 @@ class PclZip // ----- Get comment if ($p_header['comment_len'] != 0) { $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); - } - else { + } else { $p_header['comment'] = ''; } @@ -4112,9 +4100,9 @@ class PclZip // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { - $p_local_header['size'] = $p_central_header['size']; - $p_local_header['compressed_size'] = $p_central_header['compressed_size']; - $p_local_header['crc'] = $p_central_header['crc']; + $p_local_header['size'] = $p_central_header['size']; + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + $p_local_header['crc'] = $p_central_header['crc']; } // ----- Return @@ -4171,8 +4159,9 @@ class PclZip // ----- Go back to the maximum possible size of the Central Dir End Record if (!$v_found) { $v_maximum_size = 65557; // 0xFFFF + 22; - if ($v_maximum_size > $v_size) + if ($v_maximum_size > $v_size) { $v_maximum_size = $v_size; + } @fseek($this->zip_fd, $v_size-$v_maximum_size); if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) { // ----- Error log @@ -4196,8 +4185,7 @@ class PclZip $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes - if ($v_bytes == 0x504b0506) - { + if ($v_bytes == 0x504b0506) { $v_pos++; break; } @@ -4342,27 +4330,13 @@ class PclZip } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { $v_found = true; } - } - // ----- Look for a filename - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + // ----- Look for a filename $v_found = true; } } - } - // ----- Look for extract by ereg rule - // ereg() is deprecated with PHP 5.3 - /* - else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) - && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { - - if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { - $v_found = true; - } - } - */ - else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) - // ----- Look for extract by preg rule - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + } else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + // ----- Look for extract by preg rule if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { $v_found = true; } @@ -4371,14 +4345,13 @@ class PclZip // ----- Look if the index is in the list for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { - $v_found = true; + $v_found = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { - $j_start = $j+1; + $j_start = $j+1; } - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { - break; + break; } } } else { @@ -4608,7 +4581,6 @@ class PclZip // ----- Look if the archive_to_add exists if (!is_file($p_archive_to_add->zipname)) { - // ----- Nothing to merge, so merge is a success $v_result = 1; @@ -4618,7 +4590,6 @@ class PclZip // ----- Look if the archive exists if (!is_file($this->zipname)) { - // ----- Do a duplicate $v_result = $this->privDuplicate($p_archive_to_add->zipname); @@ -4781,7 +4752,6 @@ class PclZip // ----- Look if the $p_archive_filename exists if (!is_file($p_archive_filename)) { - // ----- Nothing to duplicate, so duplicate is a success. $v_result = 1; @@ -4970,8 +4940,7 @@ function PclZipUtilPathReduction($p_dir) // ----- Look for item to skip if ($v_skip > 0) { $v_skip--; - } - else { + } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } @@ -5051,8 +5020,12 @@ function PclZipUtilPathInclusion($p_dir, $p_path) // ----- Look if everything seems to be the same if ($v_result) { // ----- Skip all the empty items - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { + $j++; + } + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { + $i++; + } if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { // ----- There are exactly the same @@ -5160,7 +5133,6 @@ function PclZipUtilRename($p_src, $p_dest) // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { - $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); @@ -5191,13 +5163,12 @@ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { - $p_path = substr($p_path, $v_position+1); + $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { - $p_path = strtr($p_path, '\\', '/'); + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } -// -------------------------------------------------------------------------------- \ No newline at end of file