PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-17 14:16:53 +02:00
parent 4d65197b03
commit 1d842ed218
20 changed files with 1197 additions and 1183 deletions

View File

@ -58,7 +58,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*/ */
protected $_charSet = 'UTF-8'; protected $_charSet = 'UTF-8';
/** /**
* Create a new PHPExcel_Reader_Excel2003XML * Create a new PHPExcel_Reader_Excel2003XML
*/ */

View File

@ -992,11 +992,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
$filters = $filterColumn->filters; $filters = $filterColumn->filters;
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
$column->createRule()->setRule( // Operator is undefined, but always treated as EQUAL
null,// Operator is undefined, but always treated as EQUAL $column->createRule()->setRule(null, '')->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
''
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
} }
// Standard filters are always an OR join, so no join rule needs to be set // Standard filters are always an OR join, so no join rule needs to be set
// Entries can be either filter elements // Entries can be either filter elements

View File

@ -34,7 +34,8 @@
*/ */
class PHPExcel_Reader_Excel2007_Chart class PHPExcel_Reader_Excel2007_Chart
{ {
private static function _getAttribute($component, $name, $format) { private static function _getAttribute($component, $name, $format)
{
$attributes = $component->attributes(); $attributes = $component->attributes();
if (isset($attributes[$name])) { if (isset($attributes[$name])) {
if ($format == 'string') { if ($format == 'string') {
@ -51,7 +52,8 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _getAttribute() } // function _getAttribute()
private static function _readColor($color, $background=false) { private static function _readColor($color, $background = false)
{
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } 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); $namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']); $chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = NULL; $XaxisLabel = $YaxisLabel = $legend = $title = null;
$dispBlanksAs = $plotVisOnly = NULL; $dispBlanksAs = $plotVisOnly = null;
foreach ($chartElementsC as $chartElementKey => $chartElement) { foreach ($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) { switch ($chartElementKey) {
@ -74,124 +76,124 @@ class PHPExcel_Reader_Excel2007_Chart
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']); $chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
switch ($chartDetailsKey) { switch ($chartDetailsKey) {
case "plotArea": case "plotArea":
$plotAreaLayout = $XaxisLable = $YaxisLable = null; $plotAreaLayout = $XaxisLable = $YaxisLable = null;
$plotSeries = $plotAttributes = array(); $plotSeries = $plotAttributes = array();
foreach ($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "layout": case "layout":
$plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea'); $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea');
break; break;
case "catAx": case "catAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "dateAx": case "dateAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "valAx": case "valAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat'); $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "barChart": case "barChart":
case "bar3DChart": case "bar3DChart":
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string'); $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotDirection($barDirection); $plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "lineChart": case "lineChart":
case "line3DChart": case "line3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "areaChart": case "areaChart":
case "area3DChart": case "area3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "doughnutChart": case "doughnutChart":
case "pieChart": case "pieChart":
case "pie3DChart": case "pie3DChart":
$explosion = isset($chartDetail->ser->explosion); $explosion = isset($chartDetail->ser->explosion);
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($explosion); $plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "scatterChart": case "scatterChart":
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string'); $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($scatterStyle); $plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "bubbleChart": case "bubbleChart":
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer'); $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($bubbleScale); $plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "radarChart": case "radarChart":
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string'); $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($radarStyle); $plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "surfaceChart": case "surfaceChart":
case "surface3DChart": case "surface3DChart":
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean'); $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($wireFrame); $plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "stockChart": case "stockChart":
$plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($plotAreaLayout); $plotAttributes = self::_readChartAttributes($plotAreaLayout);
break; break;
}
} }
if ($plotAreaLayout == NULL) { }
$plotAreaLayout = new PHPExcel_Chart_Layout(); if ($plotAreaLayout == null) {
} $plotAreaLayout = new PHPExcel_Chart_Layout();
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries); }
self::_setChartAttributes($plotAreaLayout, $plotAttributes); $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
break; self::_setChartAttributes($plotAreaLayout, $plotAttributes);
break;
case "plotVisOnly": case "plotVisOnly":
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string'); $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
break; break;
case "dispBlanksAs": case "dispBlanksAs":
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
break; break;
case "title": case "title":
$title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title'); $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title');
break; break;
case "legend": case "legend":
$legendPos = 'r'; $legendPos = 'r';
$legendLayout = null; $legendLayout = null;
$legendOverlay = false; $legendOverlay = false;
foreach ($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "legendPos": case "legendPos":
$legendPos = self::_getAttribute($chartDetail, 'val', 'string'); $legendPos = self::_getAttribute($chartDetail, 'val', 'string');
break; break;
case "overlay": case "overlay":
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean'); $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
break; break;
case "layout": case "layout":
$legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend'); $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend');
break; 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; return $chart;
} // function readChart() } // function readChart()
private static function _chartTitle($titleDetails, $namespacesChartMeta, $type)
private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) { {
$caption = array(); $caption = array();
$titleLayout = null; $titleLayout = null;
foreach ($titleDetails as $titleDetailKey => $chartDetail) { foreach ($titleDetails as $titleDetailKey => $chartDetail) {
@ -226,8 +228,8 @@ class PHPExcel_Reader_Excel2007_Chart
return new PHPExcel_Chart_Title($caption, $titleLayout); return new PHPExcel_Chart_Title($caption, $titleLayout);
} // function _chartTitle() } // function _chartTitle()
private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta)
private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) { {
if (!isset($chartDetail->manualLayout)) { if (!isset($chartDetail->manualLayout)) {
return null; return null;
} }
@ -243,9 +245,9 @@ class PHPExcel_Reader_Excel2007_Chart
return new PHPExcel_Chart_Layout($layout); return new PHPExcel_Chart_Layout($layout);
} // function _chartLayoutDetails() } // function _chartLayoutDetails()
private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType)
private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) { {
$multiSeriesType = NULL; $multiSeriesType = null;
$smoothLine = false; $smoothLine = false;
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array(); $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
@ -256,7 +258,7 @@ class PHPExcel_Reader_Excel2007_Chart
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string'); $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
break; break;
case "ser": case "ser":
$marker = NULL; $marker = null;
foreach ($seriesDetails as $seriesKey => $seriesDetail) { foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) { switch ($seriesKey) {
case "idx": case "idx":
@ -294,8 +296,8 @@ class PHPExcel_Reader_Excel2007_Chart
return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
} // function _chartDataSeries() } // 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)) { if (isset($seriesDetail->strRef)) {
$seriesSource = (string) $seriesDetail->strRef->f; $seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
@ -322,8 +324,8 @@ class PHPExcel_Reader_Excel2007_Chart
return null; return null;
} // function _chartDataSeriesValueSet() } // function _chartDataSeriesValueSet()
private static function _chartDataSeriesValues($seriesValueSet, $dataType = 'n')
private static function _chartDataSeriesValues($seriesValueSet, $dataType='n') { {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
@ -348,17 +350,18 @@ class PHPExcel_Reader_Excel2007_Chart
} }
if (empty($seriesVal)) { if (empty($seriesVal)) {
$seriesVal = NULL; $seriesVal = null;
} }
return array( 'formatCode' => $formatCode, return array(
'pointCount' => $pointCount, 'formatCode' => $formatCode,
'dataValues' => $seriesVal 'pointCount' => $pointCount,
); 'dataValues' => $seriesVal
);
} // function _chartDataSeriesValues() } // function _chartDataSeriesValues()
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') { {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
@ -384,13 +387,15 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
return array( 'formatCode' => $formatCode, return array(
'pointCount' => $pointCount, 'formatCode' => $formatCode,
'dataValues' => $seriesVal 'pointCount' => $pointCount,
); 'dataValues' => $seriesVal
);
} // function _chartDataSeriesValuesMultiLevel() } // function _chartDataSeriesValuesMultiLevel()
private static function _parseRichText($titleDetailPart = null) { private static function _parseRichText($titleDetailPart = null)
{
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
@ -456,7 +461,8 @@ class PHPExcel_Reader_Excel2007_Chart
return $value; return $value;
} }
private static function _readChartAttributes($chartDetail) { private static function _readChartAttributes($chartDetail)
{
$plotAttributes = array(); $plotAttributes = array();
if (isset($chartDetail->dLbls)) { if (isset($chartDetail->dLbls)) {
if (isset($chartDetail->dLbls->howLegendKey)) { if (isset($chartDetail->dLbls->howLegendKey)) {
@ -513,5 +519,4 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
} }
} }

View File

@ -72,9 +72,9 @@ class PHPExcel_Reader_Excel2007_Theme
public function __construct($themeName, $colourSchemeName, $colourMap) public function __construct($themeName, $colourSchemeName, $colourMap)
{ {
// Initialise values // Initialise values
$this->_themeName = $themeName; $this->_themeName = $themeName;
$this->_colourSchemeName = $colourSchemeName; $this->_colourSchemeName = $colourSchemeName;
$this->_colourMap = $colourMap; $this->_colourMap = $colourMap;
} }
/** /**
@ -92,7 +92,8 @@ class PHPExcel_Reader_Excel2007_Theme
* *
* @return string * @return string
*/ */
public function getColourSchemeName() { public function getColourSchemeName()
{
return $this->_colourSchemeName; return $this->_colourSchemeName;
} }
@ -101,7 +102,8 @@ class PHPExcel_Reader_Excel2007_Theme
* *
* @return string * @return string
*/ */
public function getColourByIndex($index=0) { public function getColourByIndex($index = 0)
{
if (isset($this->_colourMap[$index])) { if (isset($this->_colourMap[$index])) {
return $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. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) { if ((is_object($value)) && ($key != '_parent')) {

View File

@ -1113,7 +1113,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
if ($this->_version == self::XLS_BIFF8) { if ($this->_version == self::XLS_BIFF8) {
foreach ($this->_sharedFormulaParts as $cell => $baseCell) { foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
list($column, $row) = PHPExcel_Cell::coordinateFromString($cell); 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); $formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell);
$this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA); $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? $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
$sheetName = trim($explodes[0], "'"); $sheetName = trim($explodes[0], "'");
if (count($explodes) == 2) { if (count($explodes) == 2) {
if (strpos($explodes[1], ':') === FALSE) { if (strpos($explodes[1], ':') === false) {
$explodes[1] = $explodes[1] . ':' . $explodes[1]; $explodes[1] = $explodes[1] . ':' . $explodes[1];
} }
$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 $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']); $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 { } else {
// Named Value // Named Value
@ -1624,7 +1624,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// //
$this->_cellNotes[$noteObjID] = array( $this->_cellNotes[$noteObjID] = array(
'cellRef' => $cellAddress, 'cellRef' => $cellAddress,
'objectID' => $noteObjID, 'objectID' => $noteObjID,
'author' => $noteAuthor 'author' => $noteAuthor
); );
} else { } else {
@ -1647,13 +1647,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
if ($extension) { if ($extension) {
// Concatenate this extension with the currently set comment for the cell // 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(); $commentText = $comment->getText()->getPlainText();
$comment->setText($this->_parseRichText($commentText.$noteText) ); $comment->setText($this->_parseRichText($commentText.$noteText));
} else { } else {
// Set comment for the cell // Set comment for the cell
$this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText)); $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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) { if (isset($this->_mapCellXfIndex[$ixfe])) {
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
$fill->getStartColor()->setRGB($rgb); $fill->getStartColor()->setRGB($rgb);
unset($fill->startcolorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) { if (isset($this->_mapCellXfIndex[$ixfe])) {
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill(); $fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
$fill->getEndColor()->setRGB($rgb); $fill->getEndColor()->setRGB($rgb);
unset($fill->endcolorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // 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 = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop();
$top->getColor()->setRGB($rgb); $top->getColor()->setRGB($rgb);
unset($top->colorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // 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 = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom();
$bottom->getColor()->setRGB($rgb); $bottom->getColor()->setRGB($rgb);
unset($bottom->colorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // 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 = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft();
$left->getColor()->setRGB($rgb); $left->getColor()->setRGB($rgb);
unset($left->colorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // 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 = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight();
$right->getColor()->setRGB($rgb); $right->getColor()->setRGB($rgb);
unset($right->colorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // 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 = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
$diagonal->getColor()->setRGB($rgb); $diagonal->getColor()->setRGB($rgb);
unset($diagonal->colorIndex); // normal color index does not apply, discard 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})); $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property // modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) { if (isset($this->_mapCellXfIndex[$ixfe])) {
$font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont(); $font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont();
$font->getColor()->setRGB($rgb); $font->getColor()->setRGB($rgb);
unset($font->colorIndex); // normal color index does not apply, discard 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); $columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell? // 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 // offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4); $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); $columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i);
// Read cell? // 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); $xfIndex = self::_GetInt2d($recordData, 4 + 2 * $i);
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]); $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); $columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell? // 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 // offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4); $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) { if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData); $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData);
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
if ((strpos($cellRangeAddress,':') !== FALSE) && if ((strpos($cellRangeAddress,':') !== false) &&
($this->_includeCellRangeFiltered($cellRangeAddress))) { ($this->_includeCellRangeFiltered($cellRangeAddress))) {
$this->_phpSheet->mergeCells($cellRangeAddress); $this->_phpSheet->mergeCells($cellRangeAddress);
} }
@ -5743,203 +5743,203 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$size = 3; $size = 3;
// offset: 1; size: 2; index to built-in sheet function // offset: 1; size: 2; index to built-in sheet function
switch (self::_GetInt2d($formulaData, 1)) { switch (self::_GetInt2d($formulaData, 1)) {
case 2: case 2:
$function = 'ISNA'; $function = 'ISNA';
$args = 1; $args = 1;
break; break;
case 3: case 3:
$function = 'ISERROR'; $function = 'ISERROR';
$args = 1; $args = 1;
break; break;
case 10: case 10:
$function = 'NA'; $function = 'NA';
$args = 0; $args = 0;
break; break;
case 15: case 15:
$function = 'SIN'; $function = 'SIN';
$args = 1; $args = 1;
break; break;
case 16: case 16:
$function = 'COS'; $function = 'COS';
$args = 1; $args = 1;
break; break;
case 17: case 17:
$function = 'TAN'; $function = 'TAN';
$args = 1; $args = 1;
break; break;
case 18: case 18:
$function = 'ATAN'; $function = 'ATAN';
$args = 1; $args = 1;
break; break;
case 19: case 19:
$function = 'PI'; $function = 'PI';
$args = 0; $args = 0;
break; break;
case 20: case 20:
$function = 'SQRT'; $function = 'SQRT';
$args = 1; $args = 1;
break; break;
case 21: case 21:
$function = 'EXP'; $function = 'EXP';
$args = 1; $args = 1;
break; break;
case 22: case 22:
$function = 'LN'; $function = 'LN';
$args = 1; $args = 1;
break; break;
case 23: case 23:
$function = 'LOG10'; $function = 'LOG10';
$args = 1; $args = 1;
break; break;
case 24: case 24:
$function = 'ABS'; $function = 'ABS';
$args = 1; $args = 1;
break; break;
case 25: case 25:
$function = 'INT'; $function = 'INT';
$args = 1; $args = 1;
break; break;
case 26: case 26:
$function = 'SIGN'; $function = 'SIGN';
$args = 1; $args = 1;
break; break;
case 27: case 27:
$function = 'ROUND'; $function = 'ROUND';
$args = 2; $args = 2;
break; break;
case 30: case 30:
$function = 'REPT'; $function = 'REPT';
$args = 2; $args = 2;
break; break;
case 31: case 31:
$function = 'MID'; $function = 'MID';
$args = 3; $args = 3;
break; break;
case 32: case 32:
$function = 'LEN'; $function = 'LEN';
$args = 1; $args = 1;
break; break;
case 33: case 33:
$function = 'VALUE'; $function = 'VALUE';
$args = 1; $args = 1;
break; break;
case 34: case 34:
$function = 'TRUE'; $function = 'TRUE';
$args = 0; $args = 0;
break; break;
case 35: case 35:
$function = 'FALSE'; $function = 'FALSE';
$args = 0; $args = 0;
break; break;
case 38: case 38:
$function = 'NOT'; $function = 'NOT';
$args = 1; $args = 1;
break; break;
case 39: case 39:
$function = 'MOD'; $function = 'MOD';
$args = 2; $args = 2;
break; break;
case 40: case 40:
$function = 'DCOUNT'; $function = 'DCOUNT';
$args = 3; $args = 3;
break; break;
case 41: case 41:
$function = 'DSUM'; $function = 'DSUM';
$args = 3; $args = 3;
break; break;
case 42: case 42:
$function = 'DAVERAGE'; $function = 'DAVERAGE';
$args = 3; $args = 3;
break; break;
case 43: case 43:
$function = 'DMIN'; $function = 'DMIN';
$args = 3; $args = 3;
break; break;
case 44: case 44:
$function = 'DMAX'; $function = 'DMAX';
$args = 3; $args = 3;
break; break;
case 45: case 45:
$function = 'DSTDEV'; $function = 'DSTDEV';
$args = 3; $args = 3;
break; break;
case 48: case 48:
$function = 'TEXT'; $function = 'TEXT';
$args = 2; $args = 2;
break; break;
case 61: case 61:
$function = 'MIRR'; $function = 'MIRR';
$args = 3; $args = 3;
break; break;
case 63: case 63:
$function = 'RAND'; $function = 'RAND';
$args = 0; $args = 0;
break; break;
case 65: case 65:
$function = 'DATE'; $function = 'DATE';
$args = 3; $args = 3;
break; break;
case 66: case 66:
$function = 'TIME'; $function = 'TIME';
$args = 3; $args = 3;
break; break;
case 67: case 67:
$function = 'DAY'; $function = 'DAY';
$args = 1; $args = 1;
break; break;
case 68: case 68:
$function = 'MONTH'; $function = 'MONTH';
$args = 1; $args = 1;
break; break;
case 69: case 69:
$function = 'YEAR'; $function = 'YEAR';
$args = 1; $args = 1;
break; break;
case 71: case 71:
$function = 'HOUR'; $function = 'HOUR';
$args = 1; $args = 1;
break; break;
case 72: case 72:
$function = 'MINUTE'; $function = 'MINUTE';
$args = 1; $args = 1;
break; break;
case 73: case 73:
$function = 'SECOND'; $function = 'SECOND';
$args = 1; $args = 1;
break; break;
case 74: case 74:
$function = 'NOW'; $function = 'NOW';
$args = 0; $args = 0;
break; break;
case 75: case 75:
$function = 'AREAS'; $function = 'AREAS';
$args = 1; $args = 1;
break; break;
case 76: case 76:
$function = 'ROWS'; $function = 'ROWS';
$args = 1; $args = 1;
break; break;
case 77: case 77:
$function = 'COLUMNS'; $function = 'COLUMNS';
$args = 1; $args = 1;
break; break;
case 83: case 83:
$function = 'TRANSPOSE'; $function = 'TRANSPOSE';
$args = 1; $args = 1;
break; break;
case 86: case 86:
$function = 'TYPE'; $function = 'TYPE';
$args = 1; $args = 1;
break; break;
case 97: case 97:
$function = 'ATAN2'; $function = 'ATAN2';
$args = 2; $args = 2;
break; break;
case 98: case 98:
$function = 'ASIN'; $function = 'ASIN';
$args = 1; $args = 1;
break; break;
case 99: case 99:
$function = 'ACOS'; $function = 'ACOS';
$args = 1; $args = 1;
break; 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 // offset: 2: size: 2; index to built-in sheet function
$index = self::_GetInt2d($formulaData, 2); $index = self::_GetInt2d($formulaData, 2);
switch ($index) { switch ($index) {
case 0: case 0:
$function = 'COUNT'; $function = 'COUNT';
break; break;
case 1: case 1:
$function = 'IF'; $function = 'IF';
break; break;
case 4: case 4:
$function = 'SUM'; $function = 'SUM';
break; break;
case 5: case 5:
$function = 'AVERAGE'; $function = 'AVERAGE';
break; break;
case 6: case 6:
$function = 'MIN'; $function = 'MIN';
break; break;
case 7: case 7:
$function = 'MAX'; $function = 'MAX';
break; break;
case 8: case 8:
$function = 'ROW'; $function = 'ROW';
break; break;
case 9: case 9:
$function = 'COLUMN'; $function = 'COLUMN';
break; break;
case 11: case 11:
$function = 'NPV'; $function = 'NPV';
break; break;
case 12: case 12:
$function = 'STDEV'; $function = 'STDEV';
break; break;
case 13: case 13:
$function = 'DOLLAR'; $function = 'DOLLAR';
break; break;
case 14: case 14:
$function = 'FIXED'; $function = 'FIXED';
break; break;
case 28: case 28:
$function = 'LOOKUP'; $function = 'LOOKUP';
break; break;
case 29: case 29:
$function = 'INDEX'; $function = 'INDEX';
break; break;
case 36: case 36:
$function = 'AND'; $function = 'AND';
break; break;
case 37: case 37:
$function = 'OR'; $function = 'OR';
break; break;
case 46: case 46:
$function = 'VAR'; $function = 'VAR';
break; break;
case 49: case 49:
$function = 'LINEST'; $function = 'LINEST';
break; break;
case 50: case 50:
$function = 'TREND'; $function = 'TREND';
break; break;
case 51: case 51:
$function = 'LOGEST'; $function = 'LOGEST';
break; break;
case 52: case 52:
$function = 'GROWTH'; $function = 'GROWTH';
break; break;
case 56: case 56:
$function = 'PV'; $function = 'PV';
break; break;
case 57: case 57:
$function = 'FV'; $function = 'FV';
break; break;
case 58: case 58:
$function = 'NPER'; $function = 'NPER';
break; break;
case 59: case 59:
$function = 'PMT'; $function = 'PMT';
break; break;
case 60: case 60:
$function = 'RATE'; $function = 'RATE';
break; break;
case 62: case 62:
$function = 'IRR'; $function = 'IRR';
break; break;
case 64: case 64:
$function = 'MATCH'; $function = 'MATCH';
break; break;
case 70: case 70:
$function = 'WEEKDAY'; $function = 'WEEKDAY';
break; break;
case 78: case 78:
$function = 'OFFSET'; $function = 'OFFSET';
break; break;
case 82: case 82:
$function = 'SEARCH'; $function = 'SEARCH';
break; break;
case 100: case 100:
@ -7468,7 +7468,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff)); $mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
$mantissalow1 = ($rknumlow & 0x80000000) >> 31; $mantissalow1 = ($rknumlow & 0x80000000) >> 31;
$mantissalow2 = ($rknumlow & 0x7fffffff); $mantissalow2 = ($rknumlow & 0x7fffffff);
$value = $mantissa / pow( 2 , (20 - $exp)); $value = $mantissa / pow(2 , (20 - $exp));
if ($mantissalow1 != 0) { if ($mantissalow1 != 0) {
$value += 1 / pow (2 , (21 - $exp)); $value += 1 / pow (2 , (21 - $exp));
@ -7496,7 +7496,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$sign = ($rknum & 0x80000000) >> 31; $sign = ($rknum & 0x80000000) >> 31;
$exp = ($rknum & 0x7ff00000) >> 20; $exp = ($rknum & 0x7ff00000) >> 20;
$mantissa = (0x100000 | ($rknum & 0x000ffffc)); $mantissa = (0x100000 | ($rknum & 0x000ffffc));
$value = $mantissa / pow( 2 , (20- ($exp - 1023))); $value = $mantissa / pow(2 , (20- ($exp - 1023)));
if ($sign) { if ($sign) {
$value = -1 * $value; $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 = new PHPExcel_RichText();
$value->createText($is); $value->createText($is);

View File

@ -107,7 +107,6 @@ class PHPExcel_Reader_Excel5_Escher
// Parse Escher stream // Parse Escher stream
while ($this->_pos < $this->_dataSize) { while ($this->_pos < $this->_dataSize) {
// offset: 2; size: 2: Record Type // offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2); $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);

View File

@ -60,16 +60,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private $_referenceHelper = null; private $_referenceHelper = null;
/** /**
* Create a new PHPExcel_Reader_Gnumeric * Create a new PHPExcel_Reader_Gnumeric
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * 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; return true;
} }
/** /**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * 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 = new XMLReader();
$xml->xml( $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2,true); $xml->setParserProperty(2,true);
$worksheetNames = array(); $worksheetNames = array();
@ -135,7 +131,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $worksheetNames; return $worksheetNames;
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * 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 = new XMLReader();
$xml->xml( $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() $xml->setParserProperty(2, true);
);
$xml->setParserProperty(2,true);
$worksheetInfo = array(); $worksheetInfo = array();
while ($xml->read()) { while ($xml->read()) {
@ -188,8 +181,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $worksheetInfo; return $worksheetInfo;
} }
private function _gzfileGetContents($filename)
private function _gzfileGetContents($filename) { {
$file = @gzopen($filename, 'rb'); $file = @gzopen($filename, 'rb');
if ($file !== false) { if ($file !== false) {
$data = ''; $data = '';
@ -201,7 +194,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $data; return $data;
} }
/** /**
* Loads PHPExcel from file * Loads PHPExcel from file
* *
@ -218,7 +210,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
} }
/** /**
* Loads PHPExcel from file into PHPExcel instance * Loads PHPExcel from file into PHPExcel instance
* *
@ -258,7 +249,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$officeDocMetaXML = $officeDocXML->meta; $officeDocMetaXML = $officeDocXML->meta;
foreach ($officeDocMetaXML as $officePropertyData) { foreach ($officeDocMetaXML as $officePropertyData) {
$officePropertyDC = array(); $officePropertyDC = array();
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($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) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title':
$docProps->setTitle(trim($propertyValue)); $docProps->setTitle(trim($propertyValue));
break; break;
case 'subject' : case 'subject':
$docProps->setSubject(trim($propertyValue)); $docProps->setSubject(trim($propertyValue));
break; break;
case 'creator' : case 'creator':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'date' : case 'date':
$creationDate = strtotime(trim($propertyValue)); $creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'description' : case 'description':
$docProps->setDescription(trim($propertyValue)); $docProps->setDescription(trim($propertyValue));
break; break;
} }
} }
$officePropertyMeta = array(); $officePropertyMeta = array();
@ -294,32 +284,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$attributes = $propertyValue->attributes($namespacesMeta['meta']); $attributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'keyword' : case 'keyword':
$docProps->setKeywords(trim($propertyValue)); $docProps->setKeywords(trim($propertyValue));
break; break;
case 'initial-creator' : case 'initial-creator':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'creation-date' : case 'creation-date':
$creationDate = strtotime(trim($propertyValue)); $creationDate = strtotime(trim($propertyValue));
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'user-defined' : case 'user-defined':
list(, $attrName) = explode(':', $attributes['name']); list(, $attrName) = explode(':', $attributes['name']);
switch ($attrName) { switch ($attrName) {
case 'publisher' : case 'publisher':
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
break; break;
case 'category' : case 'category':
$docProps->setCategory(trim($propertyValue)); $docProps->setCategory(trim($propertyValue));
break; break;
case 'manager' : case 'manager':
$docProps->setManager(trim($propertyValue)); $docProps->setManager(trim($propertyValue));
break; break;
} }
break; break;
} }
} }
} }
@ -328,26 +318,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$propertyName = $summaryItem->name; $propertyName = $summaryItem->name;
$propertyValue = $summaryItem->{'val-string'}; $propertyValue = $summaryItem->{'val-string'};
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title':
$docProps->setTitle(trim($propertyValue)); $docProps->setTitle(trim($propertyValue));
break; break;
case 'comments' : case 'comments':
$docProps->setDescription(trim($propertyValue)); $docProps->setDescription(trim($propertyValue));
break; break;
case 'keywords' : case 'keywords':
$docProps->setKeywords(trim($propertyValue)); $docProps->setKeywords(trim($propertyValue));
break; break;
case 'category' : case 'category':
$docProps->setCategory(trim($propertyValue)); $docProps->setCategory(trim($propertyValue));
break; break;
case 'manager' : case 'manager':
$docProps->setManager(trim($propertyValue)); $docProps->setManager(trim($propertyValue));
break; break;
case 'author' : case 'author':
$docProps->setCreator(trim($propertyValue)); $docProps->setCreator(trim($propertyValue));
$docProps->setLastModifiedBy(trim($propertyValue)); $docProps->setLastModifiedBy(trim($propertyValue));
break; break;
case 'company' : case 'company':
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
break; 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 // 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 // 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 // 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 ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) { 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(); $marginAttributes = $margin->attributes();
$marginSize = 72 / 100; // Default $marginSize = 72 / 100; // Default
switch ($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm' : case 'mm':
$marginSize = intval($marginAttributes['Points']) / 100; $marginSize = intval($marginAttributes['Points']) / 100;
break; break;
} }
switch ($key) { switch ($key) {
case 'top' : case 'top':
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
break; break;
case 'bottom' : case 'bottom':
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize);
break; break;
case 'left' : case 'left':
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize);
break; break;
case 'right' : case 'right':
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize);
break; break;
case 'header' : case 'header':
$objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize);
break; break;
case 'footer' : case 'footer':
$objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize);
break; break;
} }
@ -411,13 +401,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$row = (int) $cellAttributes->Row + 1; $row = (int) $cellAttributes->Row + 1;
$column = (int) $cellAttributes->Col; $column = (int) $cellAttributes->Col;
if ($row > $maxRow) $maxRow = $row; if ($row > $maxRow) {
if ($column > $maxCol) $maxCol = $column; $maxRow = $row;
}
if ($column > $maxCol) {
$maxCol = $column;
}
$column = PHPExcel_Cell::stringFromColumnIndex($column); $column = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell? // Read cell?
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) { if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
continue; continue;
} }
@ -431,47 +425,42 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
if ($ExprID > '') { if ($ExprID > '') {
if (((string) $cell) > '') { if (((string) $cell) > '') {
$this->_expressions[$ExprID] = array(
$this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col, 'column' => $cellAttributes->Col,
'row' => $cellAttributes->Row, 'row' => $cellAttributes->Row,
'formula' => (string) $cell 'formula' => (string) $cell
); );
// echo 'NEW EXPRESSION ', $ExprID,'<br />'; // echo 'NEW EXPRESSION ', $ExprID,'<br />';
} else { } else {
$expression = $this->_expressions[$ExprID]; $expression = $this->_expressions[$ExprID];
$cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'], $cell = $this->_referenceHelper->updateFormulaReferences($expression['formula'], 'A1', $cellAttributes->Col - $expression['column'], $cellAttributes->Row - $expression['row'], $worksheetName);
'A1',
$cellAttributes->Col - $expression['column'],
$cellAttributes->Row - $expression['row'],
$worksheetName
);
// echo 'SHARED EXPRESSION ', $ExprID,'<br />'; // echo 'SHARED EXPRESSION ', $ExprID,'<br />';
// echo 'New Value is ', $cell,'<br />'; // echo 'New Value is ', $cell,'<br />';
} }
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
} else { } else {
switch ($ValueType) { switch ($ValueType) {
case '10' : // NULL case '10': // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = PHPExcel_Cell_DataType::TYPE_NULL;
break; break;
case '20' : // Boolean case '20': // Boolean
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? True : False; $cell = ($cell == 'TRUE') ? true: false;
break; break;
case '30' : // Integer case '30': // Integer
$cell = intval($cell); $cell = intval($cell);
case '40' : // Float case '40': // Float
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
break; break;
case '50' : // Error case '50': // Error
$type = PHPExcel_Cell_DataType::TYPE_ERROR; $type = PHPExcel_Cell_DataType::TYPE_ERROR;
break; break;
case '60' : // String case '60': // String
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
break; break;
case '70' : // Cell Range case '70': // Cell Range
case '80' : // Array case '80': // Array
} }
} }
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type); $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(); $commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment // Only comment objects are handled at the moment
if ($commentAttributes->Text) { if ($commentAttributes->Text) {
$objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound ) $objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->_parseRichText((string)$commentAttributes->Text));
->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 _readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
switch ($styleAttributes['HAlign']) { switch ($styleAttributes['HAlign']) {
case '1' : case '1':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
break; break;
case '2' : case '2':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
break; break;
case '4' : case '4':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
break; break;
case '8' : case '8':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
break; break;
case '16' : case '16':
case '64' : case '64':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
break; break;
case '32' : case '32':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
break; break;
} }
switch ($styleAttributes['VAlign']) { switch ($styleAttributes['VAlign']) {
case '1' : case '1':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
break; break;
case '2' : case '2':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
break; break;
case '4' : case '4':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
break; break;
case '8' : case '8':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
break; break;
} }
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False; $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False; $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0; $styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
$RGB = self::_parseGnumericColour($styleAttributes["Fore"]); $RGB = self::_parseGnumericColour($styleAttributes["Fore"]);
@ -566,64 +553,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
$styleArray['fill']['endcolor']['rgb'] = $RGB2; $styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch ($shade) { switch ($shade) {
case '1' : case '1':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
break; break;
case '2' : case '2':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR;
break; break;
case '3' : case '3':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH;
break; break;
case '4' : case '4':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
break; break;
case '5' : case '5':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
break; break;
case '6' : case '6':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
break; break;
case '7' : case '7':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
break; break;
case '8' : case '8':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
break; break;
case '9' : case '9':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
break; break;
case '10' : case '10':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
break; break;
case '11' : case '11':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
break; break;
case '12' : case '12':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
break; break;
case '13' : case '13':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
break; break;
case '14' : case '14':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
break; break;
case '15' : case '15':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
break; break;
case '16' : case '16':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
break; break;
case '17' : case '17':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
break; break;
case '18' : case '18':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
break; break;
case '19' : case '19':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
break; break;
case '20' : case '20':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
break; break;
} }
@ -634,32 +621,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo '<br />'; // echo '<br />';
$styleArray['font']['name'] = (string) $styleRegion->Style->Font; $styleArray['font']['name'] = (string) $styleRegion->Style->Font;
$styleArray['font']['size'] = intval($fontAttributes['Unit']); $styleArray['font']['size'] = intval($fontAttributes['Unit']);
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;
switch ($fontAttributes['Underline']) { switch ($fontAttributes['Underline']) {
case '1' : case '1':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
break; break;
case '2' : case '2':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
break; break;
case '3' : case '3':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING;
break; break;
case '4' : case '4':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING;
break; break;
default : default:
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
break; break;
} }
switch ($fontAttributes['Script']) { switch ($fontAttributes['Script']) {
case '1' : case '1':
$styleArray['font']['superScript'] = True; $styleArray['font']['superScript'] = true;
break; break;
case '-1' : case '-1':
$styleArray['font']['subScript'] = True; $styleArray['font']['subScript'] = true;
break; break;
} }
@ -761,7 +748,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Handle Merged Cells in this worksheet // Handle Merged Cells in this worksheet
if (isset($sheet->MergedRegions)) { if (isset($sheet->MergedRegions)) {
foreach ($sheet->MergedRegions->Merge as $mergeCells) { foreach ($sheet->MergedRegions->Merge as $mergeCells) {
if (strpos($mergeCells,':') !== FALSE) { if (strpos($mergeCells,':') !== false) {
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells); $objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
} }
} }
@ -783,17 +770,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$range[0] = trim($range[0],"'");; $range[0] = trim($range[0],"'");;
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); $objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange));
} }
} }
} }
// Return // Return
return $objPHPExcel; return $objPHPExcel;
} }
private static function _parseBorderAttributes($borderAttributes) private static function _parseBorderAttributes($borderAttributes)
{ {
$styleArray = array(); $styleArray = array();
@ -804,54 +789,54 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
switch ($borderAttributes["Style"]) { switch ($borderAttributes["Style"]) {
case '0' : case '0':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE; $styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE;
break; break;
case '1' : case '1':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN; $styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN;
break; break;
case '2' : case '2':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
break; break;
case '4' : case '4':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
break; break;
case '5' : case '5':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK; $styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
break; break;
case '6' : case '6':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
break; break;
case '7' : case '7':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
break; break;
case '9' : case '9':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
break; break;
case '10' : case '10':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
break; break;
case '11' : case '11':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
break; break;
case '12' : case '12':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '13' : case '13':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '3' : case '3':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
break; break;
case '8' : case '8':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
break; break;
} }
return $styleArray; return $styleArray;
} }
private function _parseRichText($is = '')
private function _parseRichText($is = '') { {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText($is); $value->createText($is);
@ -859,15 +844,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $value; return $value;
} }
private static function _parseGnumericColour($gnmColour) { private static function _parseGnumericColour($gnmColour) {
list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR,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); $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
$RGB = $gnmR.$gnmG.$gnmB; $RGB = $gnmR.$gnmG.$gnmB;
// echo 'Excel Colour: ', $RGB,'<br />'; // echo 'Excel Colour: ', $RGB,'<br />';
return $RGB; return $RGB;
} }
} }

View File

@ -51,7 +51,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
*/ */
private $_styles = array(); private $_styles = array();
/** /**
* Create a new PHPExcel_Reader_OOCalc * 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(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * 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(); $zipClass = PHPExcel_Settings::getZipClass();
// Check if zip class exists // 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"); // 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 ($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(); $xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $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 // Step into the first level of content of the XML
$xml->read(); $xml->read();
while ($xml->read()) { while ($xml->read()) {
// Quickly jump through to the office:body node // Quickly jump through to the office:body node
while ($xml->name !== 'office:body') { while ($xml->name !== 'office:body') {
if ($xml->isEmptyElement) if ($xml->isEmptyElement) {
$xml->read(); $xml->read();
else } else {
$xml->next(); $xml->next();
}
} }
// Now read each node until we find our first table:table node // Now read each node until we find our first table:table node
while ($xml->read()) { while ($xml->read()) {
@ -164,7 +163,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $worksheetNames; return $worksheetNames;
} }
/** /**
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * 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(); $xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $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 // Step into the first level of content of the XML
$xml->read(); $xml->read();
while ($xml->read()) { while ($xml->read()) {
// Quickly jump through to the office:body node // Quickly jump through to the office:body node
while ($xml->name !== 'office:body') { while ($xml->name !== 'office:body') {
if ($xml->isEmptyElement) if ($xml->isEmptyElement) {
$xml->read(); $xml->read();
else } else {
$xml->next(); $xml->next();
}
} }
// Now read each node until we find our first table:table node // Now read each node until we find our first table:table node
while ($xml->read()) { while ($xml->read()) {
@ -289,7 +288,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $worksheetInfo; return $worksheetInfo;
} }
/** /**
* Loads PHPExcel from file * Loads PHPExcel from file
* *
@ -306,8 +304,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
} }
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue)
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach ($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
@ -318,7 +316,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return false; return false;
} }
/** /**
* Loads PHPExcel from file into PHPExcel instance * Loads PHPExcel from file into PHPExcel instance
* *
@ -362,23 +359,23 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title' :
$docProps->setTitle($propertyValue); $docProps->setTitle($propertyValue);
break; break;
case 'subject' : case 'subject' :
$docProps->setSubject($propertyValue); $docProps->setSubject($propertyValue);
break; break;
case 'creator' : case 'creator' :
$docProps->setCreator($propertyValue); $docProps->setCreator($propertyValue);
$docProps->setLastModifiedBy($propertyValue); $docProps->setLastModifiedBy($propertyValue);
break; break;
case 'date' : case 'date' :
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'description' : case 'description' :
$docProps->setDescription($propertyValue); $docProps->setDescription($propertyValue);
break; break;
} }
} }
$officePropertyMeta = array(); $officePropertyMeta = array();
@ -390,41 +387,41 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'initial-creator' : case 'initial-creator' :
$docProps->setCreator($propertyValue); $docProps->setCreator($propertyValue);
break; break;
case 'keyword' : case 'keyword' :
$docProps->setKeywords($propertyValue); $docProps->setKeywords($propertyValue);
break; break;
case 'creation-date' : case 'creation-date' :
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'user-defined' : case 'user-defined' :
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
foreach ($propertyValueAttributes as $key => $value) { foreach ($propertyValueAttributes as $key => $value) {
if ($key == 'name') { if ($key == 'name') {
$propertyValueName = (string) $value; $propertyValueName = (string) $value;
} elseif ($key == 'value-type') { } elseif ($key == 'value-type') {
switch ($value) { switch ($value) {
case 'date' : case 'date' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
break; break;
case 'boolean' : case 'boolean' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool'); $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
break; break;
case 'float' : case 'float' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4'); $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4');
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
break; break;
default : default :
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $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 '<b>'.$key.'</b><br />'; // echo '<b>'.$key.'</b><br />';
switch ($key) { switch ($key) {
case 'table-header-rows': case 'table-header-rows':
foreach ($rowData as $key=>$cellData) { foreach ($rowData as $key => $cellData) {
$rowData = $cellData; $rowData = $cellData;
break; break;
} }
@ -480,7 +477,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowDataTableAttributes['number-rows-repeated'] : 1; $rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A'; $columnID = 'A';
foreach ($rowData as $key => $cellData) { foreach ($rowData as $key => $cellData) {
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue; continue;
} }
@ -524,13 +521,13 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
} }
$text = implode("\n", $textArray); $text = implode("\n", $textArray);
// echo $text,'<br />'; // echo $text, '<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
// ->setAuthor( $author ) // ->setAuthor( $author )
->setText($this->_parseRichText($text) ); ->setText($this->_parseRichText($text) );
} }
if (isset($cellDataText->p)) { if (isset($cellDataText->p)) {
// Consolidate if there are multiple p records (maybe with spans as well) // Consolidate if there are multiple p records (maybe with spans as well)
$dataArray = array(); $dataArray = array();
// Text can have multiple text:p and within those, multiple text:span. // 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'].'<br />'; // echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
switch ($cellDataOfficeAttributes['value-type']) { switch ($cellDataOfficeAttributes['value-type']) {
case 'string' : case 'string' :
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
$dataValue = $allCellDataText; $dataValue = $allCellDataText;
if (isset($dataValue->a)) { if (isset($dataValue->a)) {
$dataValue = $dataValue->a; $dataValue = $dataValue->a;
$cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']); $cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
$hyperlink = $cellXLinkAttributes['href']; $hyperlink = $cellXLinkAttributes['href'];
} }
break; break;
case 'boolean' : case 'boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? True : False; $dataValue = ($allCellDataText == 'TRUE') ? true : false;
break; break;
case 'percentage' : case 'percentage' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (integer) $dataValue;
} }
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00; $formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
break; break;
case 'currency' : case 'currency' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue; $dataValue = (integer) $dataValue;
} }
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break; break;
case 'float' : case 'float' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value']; $dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) { if (floor($dataValue) == $dataValue) {
if ($dataValue == (integer) $dataValue) if ($dataValue == (integer) $dataValue)
$dataValue = (integer) $dataValue; $dataValue = (integer) $dataValue;
else else
$dataValue = (float) $dataValue; $dataValue = (float) $dataValue;
} }
break; break;
case 'date' : case 'date' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj); $dateObj->setTimeZone($timezoneObj);
list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s')); 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); $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
if ($dataValue != floor($dataValue)) { if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
} else { } else {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15; $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15;
} }
break; break;
case 'time' : case 'time' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS')))); $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; $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
break; break;
} }
// echo 'Data value is '.$dataValue.'<br />'; // echo 'Data value is '.$dataValue.'<br />';
// if ($hyperlink !== NULL) { // if ($hyperlink !== null) {
// echo 'Hyperlink is '.$hyperlink.'<br />'; // echo 'Hyperlink is '.$hyperlink.'<br />';
// } // }
} else { } else {
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = PHPExcel_Cell_DataType::TYPE_NULL;
$dataValue = NULL; $dataValue = null;
} }
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
// echo 'Formula: ', $cellDataFormula, PHP_EOL; // echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula, ':=')+1);
$temp = explode('"', $cellDataFormula); $temp = explode('"', $cellDataFormula);
$tKey = false; $tKey = false;
foreach ($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet $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 reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference $value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference
$value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces); $value = PHPExcel_Calculation::_translateSeparator(';', ',', $value, $inBraces);
} }
} }
unset($value); unset($value);
@ -641,9 +638,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
} }
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $cellDataTableAttributes['number-columns-repeated'] : 1;
$cellDataTableAttributes['number-columns-repeated'] : 1; if ($type !== null) {
if ($type !== NULL) {
for ($i = 0; $i < $colRepeats; ++$i) { for ($i = 0; $i < $colRepeats; ++$i) {
if ($i > 0) { if ($i > 0) {
++$columnID; ++$columnID;
@ -656,12 +652,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Forumla result is '.$dataValue.'<br />'; // echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
} }
if ($formatting !== NULL) { if ($formatting !== null) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting); $objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
} else { } else {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL); $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); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
} }
} }
@ -699,13 +695,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
return $objPHPExcel; return $objPHPExcel;
} }
private function _parseRichText($is = '')
private function _parseRichText($is = '') { {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText($is); $value->createText($is);
return $value; return $value;
} }
} }

View File

@ -75,7 +75,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
/** /**
* Create a new PHPExcel_Reader_SYLK * Create a new PHPExcel_Reader_SYLK
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $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 // Analyze first line looking for ID; signature
$lines = explode("\n", $data); $lines = explode("\n", $data);
if (substr($lines[0],0,4) != 'ID;P') { if (substr($lines[0], 0, 4) != 'ID;P') {
return false; return false;
} }
@ -136,7 +137,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// Open file // Open file
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $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 (;) // explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;) // 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); $dataType = array_shift($rowData);
if ($dataType == 'C') { if ($dataType == 'C') {
// Read cell value data // Read cell value data
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C':
case 'X' : case 'X':
$columnIndex = substr($rowDatum,1) - 1; $columnIndex = substr($rowDatum, 1) - 1;
break; break;
case 'R' : case 'R':
case 'Y' : case 'Y':
$rowIndex = substr($rowDatum,1); $rowIndex = substr($rowDatum, 1);
break; break;
} }
@ -223,7 +224,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// Open file // Open file
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
@ -233,7 +234,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
} }
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
$fromFormats = array('\-', '\ '); $fromFormats = array('\-', '\ ');
$toFormats = 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 // loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== false) { while (($rowData = fgets($fileHandle)) !== false) {
// convert SYLK encoded $rowData to UTF-8 // convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData); $rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;) // explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;) // 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); $dataType = array_shift($rowData);
// Read shared styles // Read shared styles
@ -270,7 +270,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'S': case 'S':
$styleSettings = substr($rowDatum,1); $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) { for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) { switch ($styleSettings{$i}) {
case 'I': case 'I':
$formatArray['font']['italic'] = true; $formatArray['font']['italic'] = true;
@ -305,7 +305,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum, 1); $column = substr($rowDatum, 1);
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$row = substr($rowDatum, 1); $row = substr($rowDatum, 1);
@ -321,7 +321,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
foreach ($temp as &$value) { foreach ($temp as &$value) {
// Only count/replace in alternate array entries // Only count/replace in alternate array entries
if ($key = !$key) { if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through // through the formula from left to right. Reversing means that we work right to left.through
// the formula // the formula
@ -345,7 +345,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') { if ($columnReference{0} == '[') {
$columnReference = $column + trim($columnReference,'[]'); $columnReference = $column + trim($columnReference, '[]');
} }
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
@ -390,8 +390,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1));
break; break;
case 'S': case 'S':
$styleSettings = substr($rowDatum,1); $styleSettings = substr($rowDatum, 1);
for ($i=0;$i<strlen($styleSettings);++$i) { for ($i=0; $i<strlen($styleSettings); ++$i) {
switch ($styleSettings{$i}) { switch ($styleSettings{$i}) {
case 'I': case 'I':
$styleData['font']['italic'] = true; $styleData['font']['italic'] = true;
@ -444,11 +444,11 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
switch ($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C': case 'C':
case 'X': case 'X':
$column = substr($rowDatum,1); $column = substr($rowDatum, 1);
break; break;
case 'R': case 'R':
case 'Y': case 'Y':
$row = substr($rowDatum,1); $row = substr($rowDatum, 1);
break; break;
} }
} }

View File

@ -15,8 +15,8 @@
* @author Michael Bommarito * @author Michael Bommarito
* @version 1.2 * @version 1.2
*/ */
class CholeskyDecomposition { class CholeskyDecomposition
{
/** /**
* Decomposition storage * Decomposition storage
* @var array * @var array
@ -38,21 +38,21 @@ class CholeskyDecomposition {
*/ */
private $isspd = true; private $isspd = true;
/** /**
* CholeskyDecomposition * CholeskyDecomposition
* *
* Class constructor - decomposes symmetric positive definite matrix * Class constructor - decomposes symmetric positive definite matrix
* @param mixed Matrix square symmetric positive definite matrix * @param mixed Matrix square symmetric positive definite matrix
*/ */
public function __construct($A = null) { public function __construct($A = null)
{
if ($A instanceof Matrix) { if ($A instanceof Matrix) {
$this->L = $A->getArray(); $this->L = $A->getArray();
$this->m = $A->getRowDimension(); $this->m = $A->getRowDimension();
for($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
for($j = $i; $j < $this->m; ++$j) { for ($j = $i; $j < $this->m; ++$j) {
for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
$sum -= $this->L[$i][$k] * $this->L[$j][$k]; $sum -= $this->L[$i][$k] * $this->L[$j][$k];
} }
if ($i == $j) { if ($i == $j) {
@ -77,35 +77,35 @@ class CholeskyDecomposition {
} }
} // function __construct() } // function __construct()
/** /**
* Is the matrix symmetric and positive definite? * Is the matrix symmetric and positive definite?
* *
* @return boolean * @return boolean
*/ */
public function isSPD() { public function isSPD()
{
return $this->isspd; return $this->isspd;
} // function isSPD() } // function isSPD()
/** /**
* getL * getL
* *
* Return triangular factor. * Return triangular factor.
* @return Matrix Lower triangular matrix * @return Matrix Lower triangular matrix
*/ */
public function getL() { public function getL()
{
return new Matrix($this->L); return new Matrix($this->L);
} // function getL() } // function getL()
/** /**
* Solve A*X = B * Solve A*X = B
* *
* @param $B Row-equal matrix * @param $B Row-equal matrix
* @return Matrix L * L' * X = B * @return Matrix L * L' * X = B
*/ */
public function solve($B = null) { public function solve($B = null)
{
if ($B instanceof Matrix) { if ($B instanceof Matrix) {
if ($B->getRowDimension() == $this->m) { if ($B->getRowDimension() == $this->m) {
if ($this->isspd) { if ($this->isspd) {
@ -145,5 +145,4 @@ class CholeskyDecomposition {
throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException)); throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException));
} }
} // function solve() } // function solve()
}
} // class CholeskyDecomposition

View File

@ -21,8 +21,8 @@
* @license PHP v3.0 * @license PHP v3.0
* @version 1.1 * @version 1.1
*/ */
class EigenvalueDecomposition { class EigenvalueDecomposition
{
/** /**
* Row and column dimension (square matrix). * Row and column dimension (square matrix).
* @var int * @var int
@ -67,13 +67,13 @@ class EigenvalueDecomposition {
private $cdivr; private $cdivr;
private $cdivi; private $cdivi;
/** /**
* Symmetric Householder reduction to tridiagonal form. * Symmetric Householder reduction to tridiagonal form.
* *
* @access private * @access private
*/ */
private function tred2 () { private function tred2 ()
{
// This is derived from the Algol procedures tred2 by // This is derived from the Algol procedures tred2 by
// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
@ -171,7 +171,6 @@ class EigenvalueDecomposition {
$this->e[0] = 0.0; $this->e[0] = 0.0;
} }
/** /**
* Symmetric tridiagonal QL algorithm. * Symmetric tridiagonal QL algorithm.
* *
@ -182,7 +181,8 @@ class EigenvalueDecomposition {
* *
* @access private * @access private
*/ */
private function tql2() { private function tql2()
{
for ($i = 1; $i < $this->n; ++$i) { for ($i = 1; $i < $this->n; ++$i) {
$this->e[$i-1] = $this->e[$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])); $tst1 = max($tst1, abs($this->d[$l]) + abs($this->e[$l]));
$m = $l; $m = $l;
while ($m < $this->n) { while ($m < $this->n) {
if (abs($this->e[$m]) <= $eps * $tst1) if (abs($this->e[$m]) <= $eps * $tst1) {
break; break;
}
++$m; ++$m;
} }
// If m == l, $this->d[l] is an eigenvalue, // If m == l, $this->d[l] is an eigenvalue,
@ -211,14 +212,16 @@ class EigenvalueDecomposition {
$g = $this->d[$l]; $g = $this->d[$l];
$p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]); $p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]);
$r = hypo($p, 1.0); $r = hypo($p, 1.0);
if ($p < 0) if ($p < 0) {
$r *= -1; $r *= -1;
}
$this->d[$l] = $this->e[$l] / ($p + $r); $this->d[$l] = $this->e[$l] / ($p + $r);
$this->d[$l+1] = $this->e[$l] * ($p + $r); $this->d[$l+1] = $this->e[$l] * ($p + $r);
$dl1 = $this->d[$l+1]; $dl1 = $this->d[$l+1];
$h = $g - $this->d[$l]; $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; $this->d[$i] -= $h;
}
$f += $h; $f += $h;
// Implicit QL transformation. // Implicit QL transformation.
$p = $this->d[$m]; $p = $this->d[$m];
@ -277,7 +280,6 @@ class EigenvalueDecomposition {
} }
} }
/** /**
* Nonsymmetric reduction to Hessenberg form. * Nonsymmetric reduction to Hessenberg form.
* *
@ -288,7 +290,8 @@ class EigenvalueDecomposition {
* *
* @access private * @access private
*/ */
private function orthes () { private function orthes()
{
$low = 0; $low = 0;
$high = $this->n-1; $high = $this->n-1;
@ -364,13 +367,13 @@ class EigenvalueDecomposition {
} }
} }
/** /**
* Performs complex division. * Performs complex division.
* *
* @access private * @access private
*/ */
private function cdiv($xr, $xi, $yr, $yi) { private function cdiv($xr, $xi, $yr, $yi)
{
if (abs($yr) > abs($yi)) { if (abs($yr) > abs($yi)) {
$r = $yi / $yr; $r = $yi / $yr;
$d = $yr + $r * $yi; $d = $yr + $r * $yi;
@ -384,7 +387,6 @@ class EigenvalueDecomposition {
} }
} }
/** /**
* Nonsymmetric reduction from Hessenberg to real Schur form. * Nonsymmetric reduction from Hessenberg to real Schur form.
* *
@ -395,7 +397,8 @@ class EigenvalueDecomposition {
* *
* @access private * @access private
*/ */
private function hqr2 () { private function hqr2()
{
// Initialize // Initialize
$nn = $this->n; $nn = $this->n;
$n = $nn - 1; $n = $nn - 1;
@ -408,7 +411,7 @@ class EigenvalueDecomposition {
$norm = 0.0; $norm = 0.0;
for ($i = 0; $i < $nn; ++$i) { 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->d[$i] = $this->H[$i][$i];
$this->e[$i] = 0.0; $this->e[$i] = 0.0;
} }
@ -477,7 +480,7 @@ class EigenvalueDecomposition {
$this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z; $this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z;
} }
// Column modification // Column modification
for ($i = 0; $i <= n; ++$i) { for ($i = 0; $i <= $n; ++$i) {
$z = $this->H[$i][$n-1]; $z = $this->H[$i][$n-1];
$this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n]; $this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n];
$this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z; $this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z;
@ -771,7 +774,6 @@ class EigenvalueDecomposition {
} }
} // end hqr2 } // end hqr2
/** /**
* Constructor: Check for symmetry, then construct the eigenvalue decomposition * Constructor: Check for symmetry, then construct the eigenvalue decomposition
* *
@ -779,7 +781,8 @@ class EigenvalueDecomposition {
* @param A Square matrix * @param A Square matrix
* @return Structure to access D and V. * @return Structure to access D and V.
*/ */
public function __construct($Arg) { public function __construct($Arg)
{
$this->A = $Arg->getArray(); $this->A = $Arg->getArray();
$this->n = $Arg->getColumnDimension(); $this->n = $Arg->getColumnDimension();
@ -806,47 +809,47 @@ class EigenvalueDecomposition {
} }
} }
/** /**
* Return the eigenvector matrix * Return the eigenvector matrix
* *
* @access public * @access public
* @return V * @return V
*/ */
public function getV() { public function getV()
{
return new Matrix($this->V, $this->n, $this->n); return new Matrix($this->V, $this->n, $this->n);
} }
/** /**
* Return the real parts of the eigenvalues * Return the real parts of the eigenvalues
* *
* @access public * @access public
* @return real(diag(D)) * @return real(diag(D))
*/ */
public function getRealEigenvalues() { public function getRealEigenvalues()
{
return $this->d; return $this->d;
} }
/** /**
* Return the imaginary parts of the eigenvalues * Return the imaginary parts of the eigenvalues
* *
* @access public * @access public
* @return imag(diag(D)) * @return imag(diag(D))
*/ */
public function getImagEigenvalues() { public function getImagEigenvalues()
{
return $this->e; return $this->e;
} }
/** /**
* Return the block diagonal eigenvalue matrix * Return the block diagonal eigenvalue matrix
* *
* @access public * @access public
* @return D * @return D
*/ */
public function getD() { public function getD()
{
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
$D[$i] = array_fill(0, $this->n, 0.0); $D[$i] = array_fill(0, $this->n, 0.0);
$D[$i][$i] = $this->d[$i]; $D[$i][$i] = $this->d[$i];
@ -858,5 +861,4 @@ class EigenvalueDecomposition {
} }
return new Matrix($D); return new Matrix($D);
} }
}
} // class EigenvalueDecomposition

View File

@ -18,8 +18,8 @@
* @version 1.1 * @version 1.1
* @license PHP v3.0 * @license PHP v3.0
*/ */
class PHPExcel_Shared_JAMA_LUDecomposition { class PHPExcel_Shared_JAMA_LUDecomposition
{
const MatrixSingularException = "Can only perform operation on singular matrix."; const MatrixSingularException = "Can only perform operation on singular matrix.";
const MatrixSquareException = "Mismatched Row dimension"; const MatrixSquareException = "Mismatched Row dimension";
@ -53,14 +53,14 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
*/ */
private $piv = array(); private $piv = array();
/** /**
* LU Decomposition constructor. * LU Decomposition constructor.
* *
* @param $A Rectangular matrix * @param $A Rectangular matrix
* @return Structure to access L, U and piv. * @return Structure to access L, U and piv.
*/ */
public function __construct($A) { public function __construct($A)
{
if ($A instanceof PHPExcel_Shared_JAMA_Matrix) { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Use a "left-looking", dot-product, Crout/Doolittle algorithm. // Use a "left-looking", dot-product, Crout/Doolittle algorithm.
$this->LU = $A->getArray(); $this->LU = $A->getArray();
@ -119,13 +119,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
} }
} // function __construct() } // function __construct()
/** /**
* Get lower triangular factor. * Get lower triangular factor.
* *
* @return array Lower triangular factor * @return array Lower triangular factor
*/ */
public function getL() { public function getL()
{
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($i > $j) { if ($i > $j) {
@ -140,13 +140,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
return new PHPExcel_Shared_JAMA_Matrix($L); return new PHPExcel_Shared_JAMA_Matrix($L);
} // function getL() } // function getL()
/** /**
* Get upper triangular factor. * Get upper triangular factor.
* *
* @return array Upper triangular factor * @return array Upper triangular factor
*/ */
public function getU() { public function getU()
{
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($i <= $j) { if ($i <= $j) {
@ -159,33 +159,33 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
return new PHPExcel_Shared_JAMA_Matrix($U); return new PHPExcel_Shared_JAMA_Matrix($U);
} // function getU() } // function getU()
/** /**
* Return pivot permutation vector. * Return pivot permutation vector.
* *
* @return array Pivot vector * @return array Pivot vector
*/ */
public function getPivot() { public function getPivot()
{
return $this->piv; return $this->piv;
} // function getPivot() } // function getPivot()
/** /**
* Alias for getPivot * Alias for getPivot
* *
* @see getPivot * @see getPivot
*/ */
public function getDoublePivot() { public function getDoublePivot()
{
return $this->getPivot(); return $this->getPivot();
} // function getDoublePivot() } // function getDoublePivot()
/** /**
* Is the matrix nonsingular? * Is the matrix nonsingular?
* *
* @return true if U, and hence A, is nonsingular. * @return true if U, and hence A, is nonsingular.
*/ */
public function isNonsingular() { public function isNonsingular()
{
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($this->LU[$j][$j] == 0) { if ($this->LU[$j][$j] == 0) {
return false; return false;
@ -194,13 +194,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
return true; return true;
} // function isNonsingular() } // function isNonsingular()
/** /**
* Count determinants * Count determinants
* *
* @return array d matrix deterninat * @return array d matrix deterninat
*/ */
public function det() { public function det()
{
if ($this->m == $this->n) { if ($this->m == $this->n) {
$d = $this->pivsign; $d = $this->pivsign;
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
@ -212,7 +212,6 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
} }
} // function det() } // function det()
/** /**
* Solve A*X = B * 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 IllegalArgumentException Matrix row dimensions must agree.
* @PHPExcel_Calculation_Exception RuntimeException Matrix is singular. * @PHPExcel_Calculation_Exception RuntimeException Matrix is singular.
*/ */
public function solve($B) { public function solve($B)
{
if ($B->getRowDimension() == $this->m) { if ($B->getRowDimension() == $this->m) {
if ($this->isNonsingular()) { if ($this->isNonsingular()) {
// Copy right hand side with pivoting // Copy right hand side with pivoting
@ -254,5 +254,4 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
throw new PHPExcel_Calculation_Exception(self::MatrixSquareException); throw new PHPExcel_Calculation_Exception(self::MatrixSquareException);
} }
} // function solve() } // function solve()
}
} // class PHPExcel_Shared_JAMA_LUDecomposition

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,8 @@
* @license PHP v3.0 * @license PHP v3.0
* @version 1.1 * @version 1.1
*/ */
class PHPExcel_Shared_JAMA_QRDecomposition { class PHPExcel_Shared_JAMA_QRDecomposition
{
const MatrixRankException = "Can only perform operation on full-rank matrix."; const MatrixRankException = "Can only perform operation on full-rank matrix.";
/** /**
@ -51,7 +51,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
* @param matrix $A Rectangular matrix * @param matrix $A Rectangular matrix
* @return Structure to access R and the Householder vectors and compute Q. * @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) { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Initialize. // Initialize.
$this->QR = $A->getArrayCopy(); $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. * @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) { for ($j = 0; $j < $this->n; ++$j) {
if ($this->Rdiag[$j] == 0) { if ($this->Rdiag[$j] == 0) {
return false; return false;
@ -107,13 +109,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
return true; return true;
} // function isFullRank() } // function isFullRank()
/** /**
* Return the Householder vectors * Return the Householder vectors
* *
* @return Matrix Lower trapezoidal matrix whose columns define the reflections * @return Matrix Lower trapezoidal matrix whose columns define the reflections
*/ */
public function getH() { public function getH()
{
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($i >= $j) { if ($i >= $j) {
@ -126,13 +128,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
return new PHPExcel_Shared_JAMA_Matrix($H); return new PHPExcel_Shared_JAMA_Matrix($H);
} // function getH() } // function getH()
/** /**
* Return the upper triangular factor * Return the upper triangular factor
* *
* @return Matrix upper triangular factor * @return Matrix upper triangular factor
*/ */
public function getR() { public function getR()
{
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($i < $j) { if ($i < $j) {
@ -147,13 +149,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
return new PHPExcel_Shared_JAMA_Matrix($R); return new PHPExcel_Shared_JAMA_Matrix($R);
} // function getR() } // function getR()
/** /**
* Generate and return the (economy-sized) orthogonal factor * Generate and return the (economy-sized) orthogonal factor
* *
* @return Matrix orthogonal factor * @return Matrix orthogonal factor
*/ */
public function getQ() { public function getQ()
{
for ($k = $this->n-1; $k >= 0; --$k) { for ($k = $this->n-1; $k >= 0; --$k) {
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$Q[$i][$k] = 0.0; $Q[$i][$k] = 0.0;
@ -184,14 +186,14 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
return new PHPExcel_Shared_JAMA_Matrix($Q); return new PHPExcel_Shared_JAMA_Matrix($Q);
} // function getQ() } // function getQ()
/** /**
* Least squares solution of A*X = B * Least squares solution of A*X = B
* *
* @param Matrix $B A Matrix with as many rows as A and any number of columns. * @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. * @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 ($B->getRowDimension() == $this->m) {
if ($this->isFullRank()) { if ($this->isFullRank()) {
// Copy right hand side // Copy right hand side
@ -230,5 +232,5 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException); throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException);
} }
} // function solve() } // function solve()
}
} // PHPExcel_Shared_JAMA_class QRDecomposition

View File

@ -17,8 +17,8 @@
* @license PHP v3.0 * @license PHP v3.0
* @version 1.1 * @version 1.1
*/ */
class SingularValueDecomposition { class SingularValueDecomposition
{
/** /**
* Internal storage of U. * Internal storage of U.
* @var array * @var array
@ -49,7 +49,6 @@ class SingularValueDecomposition {
*/ */
private $n; private $n;
/** /**
* Construct the singular value decomposition * Construct the singular value decomposition
* *
@ -58,8 +57,8 @@ class SingularValueDecomposition {
* @param $A Rectangular matrix * @param $A Rectangular matrix
* @return Structure to access U, S and V. * @return Structure to access U, S and V.
*/ */
public function __construct($Arg) { public function __construct($Arg)
{
// Initialize. // Initialize.
$A = $Arg->getArrayCopy(); $A = $Arg->getArrayCopy();
$this->m = $Arg->getRowDimension(); $this->m = $Arg->getRowDimension();
@ -75,7 +74,6 @@ class SingularValueDecomposition {
// Reduce A to bidiagonal form, storing the diagonal elements // Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e. // in s and the super-diagonal elements in e.
for ($k = 0; $k < max($nct, $nrt); ++$k) { for ($k = 0; $k < max($nct, $nrt); ++$k) {
if ($k < $nct) { if ($k < $nct) {
// Compute the transformation for the k-th column and // Compute the transformation for the k-th column and
// place the k-th diagonal in s[$k]. // 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 // Place the transformation in U for subsequent back
// multiplication. // multiplication.
for ($i = $k; $i < $this->m; ++$i) { for ($i = $k; $i < $this->m; ++$i) {
@ -139,7 +137,7 @@ class SingularValueDecomposition {
$e[$k+1] += 1.0; $e[$k+1] += 1.0;
} }
$e[$k] = -$e[$k]; $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. // Apply the transformation.
for ($i = $k+1; $i < $this->m; ++$i) { for ($i = $k+1; $i < $this->m; ++$i) {
$work[$i] = 0.0; $work[$i] = 0.0;
@ -198,7 +196,7 @@ class SingularValueDecomposition {
$this->U[$i][$j] += $t * $this->U[$i][$k]; $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[$i][$k] = -$this->U[$i][$k];
} }
$this->U[$k][$k] = 1.0 + $this->U[$k][$k]; $this->U[$k][$k] = 1.0 + $this->U[$k][$k];
@ -217,7 +215,7 @@ class SingularValueDecomposition {
// If required, generate V. // If required, generate V.
if ($wantv) { if ($wantv) {
for ($k = $this->n - 1; $k >= 0; --$k) { 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) { for ($j = $k + 1; $j < $nu; ++$j) {
$t = 0; $t = 0;
for ($i = $k + 1; $i < $this->n; ++$i) { for ($i = $k + 1; $i < $this->n; ++$i) {
@ -288,145 +286,143 @@ class SingularValueDecomposition {
switch ($kase) { switch ($kase) {
// Deflate negligible s(p). // Deflate negligible s(p).
case 1: case 1:
$f = $e[$p-2]; $f = $e[$p-2];
$e[$p-2] = 0.0; $e[$p-2] = 0.0;
for ($j = $p - 2; $j >= $k; --$j) { for ($j = $p - 2; $j >= $k; --$j) {
$t = hypo($this->s[$j], $f); $t = hypo($this->s[$j], $f);
$cs = $this->s[$j] / $t; $cs = $this->s[$j] / $t;
$sn = $f / $t; $sn = $f / $t;
$this->s[$j] = $t; $this->s[$j] = $t;
if ($j != $k) { if ($j != $k) {
$f = -$sn * $e[$j-1]; $f = -$sn * $e[$j-1];
$e[$j-1] = $cs * $e[$j-1]; $e[$j-1] = $cs * $e[$j-1];
} }
if ($wantv) { if ($wantv) {
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
$t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1]; $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][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1];
$this->V[$i][$j] = $t; $this->V[$i][$j] = $t;
}
} }
} }
break; }
break;
// Split at negligible s(k). // Split at negligible s(k).
case 2: case 2:
$f = $e[$k-1]; $f = $e[$k-1];
$e[$k-1] = 0.0; $e[$k-1] = 0.0;
for ($j = $k; $j < $p; ++$j) { for ($j = $k; $j < $p; ++$j) {
$t = hypo($this->s[$j], $f); $t = hypo($this->s[$j], $f);
$cs = $this->s[$j] / $t; $cs = $this->s[$j] / $t;
$sn = $f / $t; $sn = $f / $t;
$this->s[$j] = $t; $this->s[$j] = $t;
$f = -$sn * $e[$j]; $f = -$sn * $e[$j];
$e[$j] = $cs * $e[$j]; $e[$j] = $cs * $e[$j];
if ($wantu) { if ($wantu) {
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1]; $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][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1];
$this->U[$i][$j] = $t; $this->U[$i][$j] = $t;
}
} }
} }
break; }
break;
// Perform one qr step. // Perform one qr step.
case 3: case 3:
// Calculate the shift. // Calculate the shift.
$scale = max(max(max(max( $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]));
abs($this->s[$p-1]),abs($this->s[$p-2])),abs($e[$p-2])), $sp = $this->s[$p-1] / $scale;
abs($this->s[$k])), abs($e[$k])); $spm1 = $this->s[$p-2] / $scale;
$sp = $this->s[$p-1] / $scale; $epm1 = $e[$p-2] / $scale;
$spm1 = $this->s[$p-2] / $scale; $sk = $this->s[$k] / $scale;
$epm1 = $e[$p-2] / $scale; $ek = $e[$k] / $scale;
$sk = $this->s[$k] / $scale; $b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0;
$ek = $e[$k] / $scale; $c = ($sp * $epm1) * ($sp * $epm1);
$b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0; $shift = 0.0;
$c = ($sp * $epm1) * ($sp * $epm1); if (($b != 0.0) || ($c != 0.0)) {
$shift = 0.0; $shift = sqrt($b * $b + $c);
if (($b != 0.0) || ($c != 0.0)) { if ($b < 0.0) {
$shift = sqrt($b * $b + $c); $shift = -$shift;
if ($b < 0.0) {
$shift = -$shift;
}
$shift = $c / ($b + $shift);
} }
$f = ($sk + $sp) * ($sk - $sp) + $shift; $shift = $c / ($b + $shift);
$g = $sk * $ek; }
// Chase zeros. $f = ($sk + $sp) * ($sk - $sp) + $shift;
for ($j = $k; $j < $p-1; ++$j) { $g = $sk * $ek;
$t = hypo($f, $g); // Chase zeros.
$cs = $f/$t; for ($j = $k; $j < $p-1; ++$j) {
$sn = $g/$t; $t = hypo($f, $g);
if ($j != $k) { $cs = $f/$t;
$e[$j-1] = $t; $sn = $g/$t;
} if ($j != $k) {
$f = $cs * $this->s[$j] + $sn * $e[$j]; $e[$j-1] = $t;
$e[$j] = $cs * $e[$j] - $sn * $this->s[$j]; }
$g = $sn * $this->s[$j+1]; $f = $cs * $this->s[$j] + $sn * $e[$j];
$this->s[$j+1] = $cs * $this->s[$j+1]; $e[$j] = $cs * $e[$j] - $sn * $this->s[$j];
if ($wantv) { $g = $sn * $this->s[$j+1];
for ($i = 0; $i < $this->n; ++$i) { $this->s[$j+1] = $cs * $this->s[$j+1];
$t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1]; if ($wantv) {
$this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1]; for ($i = 0; $i < $this->n; ++$i) {
$this->V[$i][$j] = $t; $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;
}
} }
} }
$e[$p-2] = $f; $t = hypo($f, $g);
$iter = $iter + 1; $cs = $f/$t;
break; $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. // Convergence.
case 4: case 4:
// Make the singular values positive. // Make the singular values positive.
if ($this->s[$k] <= 0.0) { if ($this->s[$k] <= 0.0) {
$this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0); $this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0);
if ($wantv) { if ($wantv) {
for ($i = 0; $i <= $pp; ++$i) { for ($i = 0; $i <= $pp; ++$i) {
$this->V[$i][$k] = -$this->V[$i][$k]; $this->V[$i][$k] = -$this->V[$i][$k];
}
} }
} }
// Order the singular values. }
while ($k < $pp) { // Order the singular values.
if ($this->s[$k] >= $this->s[$k+1]) { while ($k < $pp) {
break; 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;
} }
$iter = 0; $t = $this->s[$k];
--$p; $this->s[$k] = $this->s[$k+1];
break; $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 switch
} // end while } // end while
@ -439,7 +435,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return U * @return U
*/ */
public function getU() { public function getU()
{
return new Matrix($this->U, $this->m, min($this->m + 1, $this->n)); return new Matrix($this->U, $this->m, min($this->m + 1, $this->n));
} }
@ -450,7 +447,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return V * @return V
*/ */
public function getV() { public function getV()
{
return new Matrix($this->V); return new Matrix($this->V);
} }
@ -461,7 +459,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return diagonal of S. * @return diagonal of S.
*/ */
public function getSingularValues() { public function getSingularValues()
{
return $this->s; return $this->s;
} }
@ -472,7 +471,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return S * @return S
*/ */
public function getS() { public function getS()
{
for ($i = 0; $i < $this->n; ++$i) { for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
$S[$i][$j] = 0.0; $S[$i][$j] = 0.0;
@ -489,7 +489,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return max(S) * @return max(S)
*/ */
public function norm2() { public function norm2()
{
return $this->s[0]; return $this->s[0];
} }
@ -500,7 +501,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return max(S)/min(S) * @return max(S)/min(S)
*/ */
public function cond() { public function cond()
{
return $this->s[0] / $this->s[min($this->m, $this->n) - 1]; return $this->s[0] / $this->s[min($this->m, $this->n) - 1];
} }
@ -511,7 +513,8 @@ class SingularValueDecomposition {
* @access public * @access public
* @return Number of nonnegligible singular values. * @return Number of nonnegligible singular values.
*/ */
public function rank() { public function rank()
{
$eps = pow(2.0, -52.0); $eps = pow(2.0, -52.0);
$tol = max($this->m, $this->n) * $this->s[0] * $eps; $tol = max($this->m, $this->n) * $this->s[0] * $eps;
$r = 0; $r = 0;
@ -522,5 +525,4 @@ class SingularValueDecomposition {
} }
return $r; return $r;
} }
}
} // class SingularValueDecomposition

View File

@ -67,7 +67,8 @@ $error['EN'][RowLengthException] = "All rows must have the same length.";
* Custom error handler * Custom error handler
* @param int $num Error number * @param int $num Error number
*/ */
function JAMAError($errorNumber = null) { function JAMAError($errorNumber = null)
{
global $error; global $error;
if (isset($errorNumber)) { if (isset($errorNumber)) {

View File

@ -11,7 +11,8 @@
* *
* r = sqrt(a^2 + b^2) without under/overflow. * r = sqrt(a^2 + b^2) without under/overflow.
*/ */
function hypo($a, $b) { function hypo($a, $b)
{
if (abs($a) > abs($b)) { if (abs($a) > abs($b)) {
$r = $b / $a; $r = $b / $a;
$r = abs($a) * sqrt(1 + $r * $r); $r = abs($a) * sqrt(1 + $r * $r);

View File

@ -73,8 +73,9 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
if (is_resource($filename)) { if (is_resource($filename)) {
$this->_FILEH_ = $filename; $this->_FILEH_ = $filename;
} else if ($filename == '-' || $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_dir = PHPExcel_Shared_File::sys_get_temp_dir();
}
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); $this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
if ($this->_FILEH_ == false) { if ($this->_FILEH_ == false) {
@ -105,8 +106,8 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
if (!is_resource($filename)) { if (!is_resource($filename)) {
fclose($this->_FILEH_); fclose($this->_FILEH_);
} }
return true; return true;
} }
@ -199,33 +200,35 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
} }
// Save Header // Save Header
fwrite($FILE, fwrite(
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" $FILE,
. "\x00\x00\x00\x00" "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. pack("v", 0x3b) . "\x00\x00\x00\x00"
. pack("v", 0x03) . pack("v", 0x3b)
. pack("v", -2) . pack("v", 0x03)
. pack("v", 9) . pack("v", -2)
. pack("v", 6) . pack("v", 9)
. pack("v", 0) . pack("v", 6)
. "\x00\x00\x00\x00" . pack("v", 0)
. "\x00\x00\x00\x00" . "\x00\x00\x00\x00"
. pack("V", $iBdCnt) . "\x00\x00\x00\x00"
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START . pack("V", $iBdCnt)
. pack("V", 0) . pack("V", $iBBcnt+$iSBDcnt) //ROOT START
. pack("V", 0x1000) . pack("V", 0)
. pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot . pack("V", 0x1000)
. pack("V", $iSBDcnt) . pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot
. pack("V", $iSBDcnt)
); );
// Extra BDList Start, Count // Extra BDList Start, Count
if ($iBdCnt < $i1stBdL) { if ($iBdCnt < $i1stBdL) {
fwrite($FILE, fwrite(
pack("V", -2) // Extra BDList Start $FILE,
. pack("V", 0) // Extra BDList Count pack("V", -2) // Extra BDList Start
); . pack("V", 0)// Extra BDList Count
);
} else { } else {
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL)); 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) { for ($i = 0; $i < $iCount; ++$i) {
if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) { if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) {
$raList[$i]->Size = $raList[$i]->_DataLen(); $raList[$i]->Size = $raList[$i]->_DataLen();
if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || 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))) {
(($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
{
// Write Data // Write Data
//if (isset($raList[$i]->_PPS_FILE)) { //if (isset($raList[$i]->_PPS_FILE)) {
// $iLen = 0; // $iLen = 0;
@ -366,7 +367,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
$iCnt = count($raList); $iCnt = count($raList);
$iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE; $iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE;
if ($iCnt % $iBCnt) { 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));
} }
} }

View File

@ -28,7 +28,8 @@
defined('IDENTIFIER_OLE') || defined('IDENTIFIER_OLE') ||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
class PHPExcel_Shared_OLERead { class PHPExcel_Shared_OLERead
{
private $data = ''; private $data = '';
// OLE identifier // OLE identifier

View File

@ -3136,7 +3136,7 @@ class PclZip
$v_extract = true; $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 // ----- Look for extract by preg rule
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
$v_extract = true; $v_extract = true;
@ -3167,7 +3167,6 @@ class PclZip
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
$this->privSwapBackMagicQuotes(); $this->privSwapBackMagicQuotes();
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is compressed by an unsupported compression method (".$v_header['compression'].") "); 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) { if ($v_result1 == 2) {
break; break;
} }
} } elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
// ----- Look for extraction in standard output // ----- Look for extraction in standard output
elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
// ----- Extracting the file in standard output // ----- Extracting the file in standard output
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options); $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
if ($v_result1 < 1) { if ($v_result1 < 1) {
@ -3369,7 +3367,7 @@ class PclZip
if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
$v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']); $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']);
if ($v_inclusion == 0) { 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(); return PclZip::errorCode();
} }
@ -3410,7 +3408,6 @@ class PclZip
if (file_exists($p_entry['filename'])) { if (file_exists($p_entry['filename'])) {
// ----- Look if file is a directory // ----- Look if file is a directory
if (is_dir($p_entry['filename'])) { if (is_dir($p_entry['filename'])) {
// ----- Change the file status // ----- Change the file status
$p_entry['status'] = "already_a_directory"; $p_entry['status'] = "already_a_directory";
@ -3444,21 +3441,19 @@ class PclZip
// For historical reason first PclZip implementation does not stop // For historical reason first PclZip implementation does not stop
// when this kind of error occurs. // when this kind of error occurs.
if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { 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"); 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(); return PclZip::errorCode();
} }
} }
} else { } else {
} }
} 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) == '/')) { if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
$v_dir_to_check = $p_entry['filename']; $v_dir_to_check = $p_entry['filename'];
} } else if (!strstr($p_entry['filename'], "/")) {
else if (!strstr($p_entry['filename'], "/")) {
$v_dir_to_check = ""; $v_dir_to_check = "";
} } else {
else {
$v_dir_to_check = dirname($p_entry['filename']); $v_dir_to_check = dirname($p_entry['filename']);
} }
@ -3530,7 +3525,6 @@ class PclZip
$v_file_content = @gzinflate($v_buffer); $v_file_content = @gzinflate($v_buffer);
unset($v_buffer); unset($v_buffer);
if ($v_file_content === false) { if ($v_file_content === false) {
// ----- Change the file status // ----- Change the file status
// TBC // TBC
$p_entry['status'] = "error"; $p_entry['status'] = "error";
@ -3540,7 +3534,6 @@ class PclZip
// ----- Opening destination file // ----- Opening destination file
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
// ----- Change the file status // ----- Change the file status
$p_entry['status'] = "write_error"; $p_entry['status'] = "write_error";
@ -3723,7 +3716,6 @@ class PclZip
if (!(($p_entry['external']&0x00000010)==0x00000010)) { if (!(($p_entry['external']&0x00000010)==0x00000010)) {
// ----- Look for not compressed file // ----- Look for not compressed file
if ($p_entry['compressed_size'] == $p_entry['size']) { if ($p_entry['compressed_size'] == $p_entry['size']) {
// ----- Read the file in a buffer (one shot) // ----- Read the file in a buffer (one shot)
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
@ -3731,7 +3723,6 @@ class PclZip
echo $v_buffer; echo $v_buffer;
unset($v_buffer); unset($v_buffer);
} else { } else {
// ----- Read the compressed file in a buffer (one shot) // ----- Read the compressed file in a buffer (one shot)
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); $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 // ----- Check that the file header is coherent with $p_entry info
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
// TBC // TBC
} }
// ----- Look for pre-extract callback // ----- Look for pre-extract callback
@ -3830,17 +3821,15 @@ class PclZip
// ----- Look for not compressed file // ----- Look for not compressed file
// if ($p_entry['compressed_size'] == $p_entry['size']) // if ($p_entry['compressed_size'] == $p_entry['size'])
if ($p_entry['compression'] == 0) { if ($p_entry['compression'] == 0) {
// ----- Reading the file // ----- Reading the file
$p_string = @fread($this->zip_fd, $p_entry['compressed_size']); $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
} else { } else {
// ----- Reading the file // ----- Reading the file
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']); $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Decompress the file // ----- Decompress the file
if (($p_string = @gzinflate($v_data)) === false) { if (($p_string = @gzinflate($v_data)) === false) {
// TBC // TBC
} }
} }
// ----- Trace // ----- Trace
@ -4037,8 +4026,7 @@ class PclZip
// ----- Get comment // ----- Get comment
if ($p_header['comment_len'] != 0) { if ($p_header['comment_len'] != 0) {
$p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
} } else {
else {
$p_header['comment'] = ''; $p_header['comment'] = '';
} }
@ -4112,9 +4100,9 @@ class PclZip
// ----- Look for flag bit 3 // ----- Look for flag bit 3
if (($p_local_header['flag'] & 8) == 8) { if (($p_local_header['flag'] & 8) == 8) {
$p_local_header['size'] = $p_central_header['size']; $p_local_header['size'] = $p_central_header['size'];
$p_local_header['compressed_size'] = $p_central_header['compressed_size']; $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
$p_local_header['crc'] = $p_central_header['crc']; $p_local_header['crc'] = $p_central_header['crc'];
} }
// ----- Return // ----- Return
@ -4171,8 +4159,9 @@ class PclZip
// ----- Go back to the maximum possible size of the Central Dir End Record // ----- Go back to the maximum possible size of the Central Dir End Record
if (!$v_found) { if (!$v_found) {
$v_maximum_size = 65557; // 0xFFFF + 22; $v_maximum_size = 65557; // 0xFFFF + 22;
if ($v_maximum_size > $v_size) if ($v_maximum_size > $v_size) {
$v_maximum_size = $v_size; $v_maximum_size = $v_size;
}
@fseek($this->zip_fd, $v_size-$v_maximum_size); @fseek($this->zip_fd, $v_size-$v_maximum_size);
if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) { if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) {
// ----- Error log // ----- Error log
@ -4196,8 +4185,7 @@ class PclZip
$v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
// ----- Compare the bytes // ----- Compare the bytes
if ($v_bytes == 0x504b0506) if ($v_bytes == 0x504b0506) {
{
$v_pos++; $v_pos++;
break; 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])) { } 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; $v_found = true;
} }
} } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
// ----- Look for a filename // ----- Look for a filename
elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
$v_found = true; $v_found = true;
} }
} }
} } else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
// ----- Look for extract by ereg rule // ----- Look for extract by preg 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] != "")) {
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
$v_found = true; $v_found = true;
} }
@ -4371,14 +4345,13 @@ class PclZip
// ----- Look if the index is in the list // ----- Look if the index is in the list
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { if (($i>=$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']) { 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) { if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
break; break;
} }
} }
} else { } else {
@ -4608,7 +4581,6 @@ class PclZip
// ----- Look if the archive_to_add exists // ----- Look if the archive_to_add exists
if (!is_file($p_archive_to_add->zipname)) { if (!is_file($p_archive_to_add->zipname)) {
// ----- Nothing to merge, so merge is a success // ----- Nothing to merge, so merge is a success
$v_result = 1; $v_result = 1;
@ -4618,7 +4590,6 @@ class PclZip
// ----- Look if the archive exists // ----- Look if the archive exists
if (!is_file($this->zipname)) { if (!is_file($this->zipname)) {
// ----- Do a duplicate // ----- Do a duplicate
$v_result = $this->privDuplicate($p_archive_to_add->zipname); $v_result = $this->privDuplicate($p_archive_to_add->zipname);
@ -4781,7 +4752,6 @@ class PclZip
// ----- Look if the $p_archive_filename exists // ----- Look if the $p_archive_filename exists
if (!is_file($p_archive_filename)) { if (!is_file($p_archive_filename)) {
// ----- Nothing to duplicate, so duplicate is a success. // ----- Nothing to duplicate, so duplicate is a success.
$v_result = 1; $v_result = 1;
@ -4970,8 +4940,7 @@ function PclZipUtilPathReduction($p_dir)
// ----- Look for item to skip // ----- Look for item to skip
if ($v_skip > 0) { if ($v_skip > 0) {
$v_skip--; $v_skip--;
} } else {
else {
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); $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 // ----- Look if everything seems to be the same
if ($v_result) { if ($v_result) {
// ----- Skip all the empty items // ----- Skip all the empty items
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; $j++;
}
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
$i++;
}
if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
// ----- There are exactly the same // ----- There are exactly the same
@ -5160,7 +5133,6 @@ function PclZipUtilRename($p_src, $p_dest)
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function PclZipUtilOptionText($p_option) function PclZipUtilOptionText($p_option)
{ {
$v_list = get_defined_constants(); $v_list = get_defined_constants();
for (reset($v_list); $v_key = key($v_list); next($v_list)) { for (reset($v_list); $v_key = key($v_list); next($v_list)) {
$v_prefix = substr($v_key, 0, 10); $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')) { if (stristr(php_uname(), 'windows')) {
// ----- Look for potential disk letter // ----- Look for potential disk letter
if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { 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 // ----- Change potential windows directory separator
if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
$p_path = strtr($p_path, '\\', '/'); $p_path = strtr($p_path, '\\', '/');
} }
} }
return $p_path; return $p_path;
} }
// --------------------------------------------------------------------------------