PSR2 Fixes
This commit is contained in:
parent
4d65197b03
commit
1d842ed218
|
@ -58,7 +58,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
|
|||
*/
|
||||
protected $_charSet = 'UTF-8';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel2003XML
|
||||
*/
|
||||
|
|
|
@ -992,11 +992,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
|
||||
$filters = $filterColumn->filters;
|
||||
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
|
||||
$column->createRule()->setRule(
|
||||
null,// Operator is undefined, but always treated as EQUAL
|
||||
''
|
||||
)
|
||||
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
|
||||
// Operator is undefined, but always treated as EQUAL
|
||||
$column->createRule()->setRule(null, '')->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
|
||||
}
|
||||
// Standard filters are always an OR join, so no join rule needs to be set
|
||||
// Entries can be either filter elements
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
*/
|
||||
class PHPExcel_Reader_Excel2007_Chart
|
||||
{
|
||||
private static function _getAttribute($component, $name, $format) {
|
||||
private static function _getAttribute($component, $name, $format)
|
||||
{
|
||||
$attributes = $component->attributes();
|
||||
if (isset($attributes[$name])) {
|
||||
if ($format == 'string') {
|
||||
|
@ -51,7 +52,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
} // function _getAttribute()
|
||||
|
||||
|
||||
private static function _readColor($color, $background=false) {
|
||||
private static function _readColor($color, $background = false)
|
||||
{
|
||||
if (isset($color["rgb"])) {
|
||||
return (string)$color["rgb"];
|
||||
} else if (isset($color["indexed"])) {
|
||||
|
@ -59,13 +61,13 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static function readChart($chartElements, $chartName) {
|
||||
public static function readChart($chartElements, $chartName)
|
||||
{
|
||||
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
||||
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
||||
|
||||
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
|
||||
$dispBlanksAs = $plotVisOnly = NULL;
|
||||
$XaxisLabel = $YaxisLabel = $legend = $title = null;
|
||||
$dispBlanksAs = $plotVisOnly = null;
|
||||
|
||||
foreach ($chartElementsC as $chartElementKey => $chartElement) {
|
||||
switch ($chartElementKey) {
|
||||
|
@ -158,7 +160,7 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ($plotAreaLayout == NULL) {
|
||||
if ($plotAreaLayout == null) {
|
||||
$plotAreaLayout = new PHPExcel_Chart_Layout();
|
||||
}
|
||||
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
|
||||
|
@ -201,8 +203,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return $chart;
|
||||
} // function readChart()
|
||||
|
||||
|
||||
private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) {
|
||||
private static function _chartTitle($titleDetails, $namespacesChartMeta, $type)
|
||||
{
|
||||
$caption = array();
|
||||
$titleLayout = null;
|
||||
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
|
||||
|
@ -226,8 +228,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return new PHPExcel_Chart_Title($caption, $titleLayout);
|
||||
} // function _chartTitle()
|
||||
|
||||
|
||||
private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) {
|
||||
private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta)
|
||||
{
|
||||
if (!isset($chartDetail->manualLayout)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -243,9 +245,9 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return new PHPExcel_Chart_Layout($layout);
|
||||
} // function _chartLayoutDetails()
|
||||
|
||||
|
||||
private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) {
|
||||
$multiSeriesType = NULL;
|
||||
private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType)
|
||||
{
|
||||
$multiSeriesType = null;
|
||||
$smoothLine = false;
|
||||
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
|
||||
|
||||
|
@ -256,7 +258,7 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
|
||||
break;
|
||||
case "ser":
|
||||
$marker = NULL;
|
||||
$marker = null;
|
||||
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
|
||||
switch ($seriesKey) {
|
||||
case "idx":
|
||||
|
@ -294,8 +296,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
|
||||
} // function _chartDataSeries()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
|
||||
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false)
|
||||
{
|
||||
if (isset($seriesDetail->strRef)) {
|
||||
$seriesSource = (string) $seriesDetail->strRef->f;
|
||||
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
|
||||
|
@ -322,8 +324,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return null;
|
||||
} // function _chartDataSeriesValueSet()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValues($seriesValueSet, $dataType='n') {
|
||||
private static function _chartDataSeriesValues($seriesValueSet, $dataType = 'n')
|
||||
{
|
||||
$seriesVal = array();
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
@ -348,17 +350,18 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
}
|
||||
|
||||
if (empty($seriesVal)) {
|
||||
$seriesVal = NULL;
|
||||
$seriesVal = null;
|
||||
}
|
||||
|
||||
return array( 'formatCode' => $formatCode,
|
||||
return array(
|
||||
'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
} // function _chartDataSeriesValues()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') {
|
||||
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType = 'n')
|
||||
{
|
||||
$seriesVal = array();
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
@ -384,13 +387,15 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'formatCode' => $formatCode,
|
||||
return array(
|
||||
'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
} // function _chartDataSeriesValuesMultiLevel()
|
||||
|
||||
private static function _parseRichText($titleDetailPart = null) {
|
||||
private static function _parseRichText($titleDetailPart = null)
|
||||
{
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
|
||||
|
@ -456,7 +461,8 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
return $value;
|
||||
}
|
||||
|
||||
private static function _readChartAttributes($chartDetail) {
|
||||
private static function _readChartAttributes($chartDetail)
|
||||
{
|
||||
$plotAttributes = array();
|
||||
if (isset($chartDetail->dLbls)) {
|
||||
if (isset($chartDetail->dLbls->howLegendKey)) {
|
||||
|
@ -513,5 +519,4 @@ class PHPExcel_Reader_Excel2007_Chart
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ class PHPExcel_Reader_Excel2007_Theme
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourSchemeName() {
|
||||
public function getColourSchemeName()
|
||||
{
|
||||
return $this->_colourSchemeName;
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,8 @@ class PHPExcel_Reader_Excel2007_Theme
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourByIndex($index=0) {
|
||||
public function getColourByIndex($index = 0)
|
||||
{
|
||||
if (isset($this->_colourMap[$index])) {
|
||||
return $this->_colourMap[$index];
|
||||
}
|
||||
|
@ -111,7 +113,8 @@ class PHPExcel_Reader_Excel2007_Theme
|
|||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ((is_object($value)) && ($key != '_parent')) {
|
||||
|
|
|
@ -1113,7 +1113,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
if ($this->_version == self::XLS_BIFF8) {
|
||||
foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($cell);
|
||||
if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) {
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle())) {
|
||||
$formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell);
|
||||
$this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
|
||||
}
|
||||
|
@ -1156,7 +1156,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
|
||||
$sheetName = trim($explodes[0], "'");
|
||||
if (count($explodes) == 2) {
|
||||
if (strpos($explodes[1], ':') === FALSE) {
|
||||
if (strpos($explodes[1], ':') === false) {
|
||||
$explodes[1] = $explodes[1] . ':' . $explodes[1];
|
||||
}
|
||||
$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
|
||||
|
@ -1221,7 +1221,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
|
||||
$scope = ($definedName['scope'] == 0) ? null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);
|
||||
|
||||
$this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) );
|
||||
$this->_phpExcel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope));
|
||||
}
|
||||
} else {
|
||||
// Named Value
|
||||
|
@ -1647,13 +1647,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
|
||||
if ($extension) {
|
||||
// Concatenate this extension with the currently set comment for the cell
|
||||
$comment = $this->_phpSheet->getComment( $cellAddress );
|
||||
$comment = $this->_phpSheet->getComment($cellAddress);
|
||||
$commentText = $comment->getText()->getPlainText();
|
||||
$comment->setText($this->_parseRichText($commentText.$noteText) );
|
||||
$comment->setText($this->_parseRichText($commentText.$noteText));
|
||||
} else {
|
||||
// Set comment for the cell
|
||||
$this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText));
|
||||
// ->setAuthor( $author )
|
||||
// ->setAuthor($author)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2410,7 +2410,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
|
||||
$fill->getStartColor()->setRGB($rgb);
|
||||
unset($fill->startcolorIndex); // normal color index does not apply, discard
|
||||
|
@ -2425,7 +2425,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
|
||||
$fill->getEndColor()->setRGB($rgb);
|
||||
unset($fill->endcolorIndex); // normal color index does not apply, discard
|
||||
|
@ -2440,7 +2440,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop();
|
||||
$top->getColor()->setRGB($rgb);
|
||||
unset($top->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -2455,7 +2455,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom();
|
||||
$bottom->getColor()->setRGB($rgb);
|
||||
unset($bottom->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -2470,7 +2470,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft();
|
||||
$left->getColor()->setRGB($rgb);
|
||||
unset($left->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -2485,7 +2485,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight();
|
||||
$right->getColor()->setRGB($rgb);
|
||||
unset($right->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -2500,7 +2500,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
|
||||
$diagonal->getColor()->setRGB($rgb);
|
||||
unset($diagonal->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -2515,7 +2515,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
|
||||
|
||||
// modify the relevant style property
|
||||
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
|
||||
if (isset($this->_mapCellXfIndex[$ixfe])) {
|
||||
$font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont();
|
||||
$font->getColor()->setRGB($rgb);
|
||||
unset($font->colorIndex); // normal color index does not apply, discard
|
||||
|
@ -3652,7 +3652,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
|
||||
|
||||
// Read cell?
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) {
|
||||
// offset: 4; size: 2; index to XF record
|
||||
$xfIndex = self::_GetInt2d($recordData, 4);
|
||||
|
||||
|
@ -4125,7 +4125,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i);
|
||||
|
||||
// Read cell?
|
||||
if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) {
|
||||
$xfIndex = self::_GetInt2d($recordData, 4 + 2 * $i);
|
||||
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -4162,7 +4162,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
|
||||
|
||||
// Read cell?
|
||||
if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) {
|
||||
// offset: 4; size: 2; XF index
|
||||
$xfIndex = self::_GetInt2d($recordData, 4);
|
||||
|
||||
|
@ -4528,7 +4528,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
|
||||
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData);
|
||||
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
|
||||
if ((strpos($cellRangeAddress,':') !== FALSE) &&
|
||||
if ((strpos($cellRangeAddress,':') !== false) &&
|
||||
($this->_includeCellRangeFiltered($cellRangeAddress))) {
|
||||
$this->_phpSheet->mergeCells($cellRangeAddress);
|
||||
}
|
||||
|
@ -7468,7 +7468,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
|
||||
$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
|
||||
$mantissalow2 = ($rknumlow & 0x7fffffff);
|
||||
$value = $mantissa / pow( 2 , (20 - $exp));
|
||||
$value = $mantissa / pow(2 , (20 - $exp));
|
||||
|
||||
if ($mantissalow1 != 0) {
|
||||
$value += 1 / pow (2 , (21 - $exp));
|
||||
|
@ -7496,7 +7496,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$sign = ($rknum & 0x80000000) >> 31;
|
||||
$exp = ($rknum & 0x7ff00000) >> 20;
|
||||
$mantissa = (0x100000 | ($rknum & 0x000ffffc));
|
||||
$value = $mantissa / pow( 2 , (20- ($exp - 1023)));
|
||||
$value = $mantissa / pow(2 , (20- ($exp - 1023)));
|
||||
if ($sign) {
|
||||
$value = -1 * $value;
|
||||
}
|
||||
|
@ -8043,8 +8043,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
private function _parseRichText($is = '')
|
||||
{
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
|
|
@ -107,7 +107,6 @@ class PHPExcel_Reader_Excel5_Escher
|
|||
|
||||
// Parse Escher stream
|
||||
while ($this->_pos < $this->_dataSize) {
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
|
||||
|
||||
|
|
|
@ -60,16 +60,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
|
||||
private $_referenceHelper = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Gnumeric
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
|
@ -101,7 +100,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
|
||||
*
|
||||
|
@ -116,9 +114,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
$xml->xml(
|
||||
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2,true);
|
||||
|
||||
$worksheetNames = array();
|
||||
|
@ -135,7 +131,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
|
@ -150,10 +145,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
$xml->xml(
|
||||
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
$xml->setParserProperty(2,true);
|
||||
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2, true);
|
||||
|
||||
$worksheetInfo = array();
|
||||
while ($xml->read()) {
|
||||
|
@ -188,8 +181,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
private function _gzfileGetContents($filename) {
|
||||
private function _gzfileGetContents($filename)
|
||||
{
|
||||
$file = @gzopen($filename, 'rb');
|
||||
if ($file !== false) {
|
||||
$data = '';
|
||||
|
@ -201,7 +194,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
|
@ -218,7 +210,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
|
@ -258,7 +249,6 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$officeDocMetaXML = $officeDocXML->meta;
|
||||
|
||||
foreach ($officeDocMetaXML as $officePropertyData) {
|
||||
|
||||
$officePropertyDC = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
|
@ -266,22 +256,22 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
foreach ($officePropertyDC as $propertyName => $propertyValue) {
|
||||
$propertyValue = (string) $propertyValue;
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
case 'title':
|
||||
$docProps->setTitle(trim($propertyValue));
|
||||
break;
|
||||
case 'subject' :
|
||||
case 'subject':
|
||||
$docProps->setSubject(trim($propertyValue));
|
||||
break;
|
||||
case 'creator' :
|
||||
case 'creator':
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'date' :
|
||||
case 'date':
|
||||
$creationDate = strtotime(trim($propertyValue));
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
break;
|
||||
case 'description' :
|
||||
case 'description':
|
||||
$docProps->setDescription(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
|
@ -294,28 +284,28 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$attributes = $propertyValue->attributes($namespacesMeta['meta']);
|
||||
$propertyValue = (string) $propertyValue;
|
||||
switch ($propertyName) {
|
||||
case 'keyword' :
|
||||
case 'keyword':
|
||||
$docProps->setKeywords(trim($propertyValue));
|
||||
break;
|
||||
case 'initial-creator' :
|
||||
case 'initial-creator':
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'creation-date' :
|
||||
case 'creation-date':
|
||||
$creationDate = strtotime(trim($propertyValue));
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
break;
|
||||
case 'user-defined' :
|
||||
case 'user-defined':
|
||||
list(, $attrName) = explode(':', $attributes['name']);
|
||||
switch ($attrName) {
|
||||
case 'publisher' :
|
||||
case 'publisher':
|
||||
$docProps->setCompany(trim($propertyValue));
|
||||
break;
|
||||
case 'category' :
|
||||
case 'category':
|
||||
$docProps->setCategory(trim($propertyValue));
|
||||
break;
|
||||
case 'manager' :
|
||||
case 'manager':
|
||||
$docProps->setManager(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
|
@ -328,26 +318,26 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$propertyName = $summaryItem->name;
|
||||
$propertyValue = $summaryItem->{'val-string'};
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
case 'title':
|
||||
$docProps->setTitle(trim($propertyValue));
|
||||
break;
|
||||
case 'comments' :
|
||||
case 'comments':
|
||||
$docProps->setDescription(trim($propertyValue));
|
||||
break;
|
||||
case 'keywords' :
|
||||
case 'keywords':
|
||||
$docProps->setKeywords(trim($propertyValue));
|
||||
break;
|
||||
case 'category' :
|
||||
case 'category':
|
||||
$docProps->setCategory(trim($propertyValue));
|
||||
break;
|
||||
case 'manager' :
|
||||
case 'manager':
|
||||
$docProps->setManager(trim($propertyValue));
|
||||
break;
|
||||
case 'author' :
|
||||
case 'author':
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'company' :
|
||||
case 'company':
|
||||
$docProps->setCompany(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
|
@ -370,35 +360,35 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
||||
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
||||
// name in line with the formula, not the reverse
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
|
||||
if (isset($sheet->PrintInformation->Margins)) {
|
||||
foreach ($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
|
||||
foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) {
|
||||
$marginAttributes = $margin->attributes();
|
||||
$marginSize = 72 / 100; // Default
|
||||
switch ($marginAttributes['PrefUnit']) {
|
||||
case 'mm' :
|
||||
case 'mm':
|
||||
$marginSize = intval($marginAttributes['Points']) / 100;
|
||||
break;
|
||||
}
|
||||
switch ($key) {
|
||||
case 'top' :
|
||||
case 'top':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
|
||||
break;
|
||||
case 'bottom' :
|
||||
case 'bottom':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize);
|
||||
break;
|
||||
case 'left' :
|
||||
case 'left':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize);
|
||||
break;
|
||||
case 'right' :
|
||||
case 'right':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize);
|
||||
break;
|
||||
case 'header' :
|
||||
case 'header':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize);
|
||||
break;
|
||||
case 'footer' :
|
||||
case 'footer':
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize);
|
||||
break;
|
||||
}
|
||||
|
@ -411,13 +401,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$row = (int) $cellAttributes->Row + 1;
|
||||
$column = (int) $cellAttributes->Col;
|
||||
|
||||
if ($row > $maxRow) $maxRow = $row;
|
||||
if ($column > $maxCol) $maxCol = $column;
|
||||
if ($row > $maxRow) {
|
||||
$maxRow = $row;
|
||||
}
|
||||
if ($column > $maxCol) {
|
||||
$maxCol = $column;
|
||||
}
|
||||
|
||||
$column = PHPExcel_Cell::stringFromColumnIndex($column);
|
||||
|
||||
// Read cell?
|
||||
if ($this->getReadFilter() !== NULL) {
|
||||
if ($this->getReadFilter() !== null) {
|
||||
if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -431,8 +425,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
if ($ExprID > '') {
|
||||
if (((string) $cell) > '') {
|
||||
|
||||
$this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col,
|
||||
$this->_expressions[$ExprID] = array(
|
||||
'column' => $cellAttributes->Col,
|
||||
'row' => $cellAttributes->Row,
|
||||
'formula' => (string) $cell
|
||||
);
|
||||
|
@ -440,38 +434,33 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
} else {
|
||||
$expression = $this->_expressions[$ExprID];
|
||||
|
||||
$cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'],
|
||||
'A1',
|
||||
$cellAttributes->Col - $expression['column'],
|
||||
$cellAttributes->Row - $expression['row'],
|
||||
$worksheetName
|
||||
);
|
||||
$cell = $this->_referenceHelper->updateFormulaReferences($expression['formula'], 'A1', $cellAttributes->Col - $expression['column'], $cellAttributes->Row - $expression['row'], $worksheetName);
|
||||
// echo 'SHARED EXPRESSION ', $ExprID,'<br />';
|
||||
// echo 'New Value is ', $cell,'<br />';
|
||||
}
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
} else {
|
||||
switch ($ValueType) {
|
||||
case '10' : // NULL
|
||||
case '10': // NULL
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
break;
|
||||
case '20' : // Boolean
|
||||
case '20': // Boolean
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$cell = ($cell == 'TRUE') ? True : False;
|
||||
$cell = ($cell == 'TRUE') ? true: false;
|
||||
break;
|
||||
case '30' : // Integer
|
||||
case '30': // Integer
|
||||
$cell = intval($cell);
|
||||
case '40' : // Float
|
||||
case '40': // Float
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
break;
|
||||
case '50' : // Error
|
||||
case '50': // Error
|
||||
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
break;
|
||||
case '60' : // String
|
||||
case '60': // String
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
break;
|
||||
case '70' : // Cell Range
|
||||
case '80' : // Array
|
||||
case '70': // Cell Range
|
||||
case '80': // Array
|
||||
}
|
||||
}
|
||||
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type);
|
||||
|
@ -482,9 +471,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$commentAttributes = $comment->attributes();
|
||||
// Only comment objects are handled at the moment
|
||||
if ($commentAttributes->Text) {
|
||||
$objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound )
|
||||
->setAuthor( (string)$commentAttributes->Author )
|
||||
->setText($this->_parseRichText((string)$commentAttributes->Text) );
|
||||
$objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->_parseRichText((string)$commentAttributes->Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,44 +504,44 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
// If _readDataOnly is false, we set all formatting information
|
||||
if (!$this->_readDataOnly) {
|
||||
switch ($styleAttributes['HAlign']) {
|
||||
case '1' :
|
||||
case '1':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
break;
|
||||
case '2' :
|
||||
case '2':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
|
||||
break;
|
||||
case '4' :
|
||||
case '4':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
|
||||
break;
|
||||
case '8' :
|
||||
case '8':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
|
||||
break;
|
||||
case '16' :
|
||||
case '64' :
|
||||
case '16':
|
||||
case '64':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
|
||||
break;
|
||||
case '32' :
|
||||
case '32':
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($styleAttributes['VAlign']) {
|
||||
case '1' :
|
||||
case '1':
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
|
||||
break;
|
||||
case '2' :
|
||||
case '2':
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
break;
|
||||
case '4' :
|
||||
case '4':
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
|
||||
break;
|
||||
case '8' :
|
||||
case '8':
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
|
||||
break;
|
||||
}
|
||||
|
||||
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False;
|
||||
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False;
|
||||
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
|
||||
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
|
||||
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
|
||||
|
||||
$RGB = self::_parseGnumericColour($styleAttributes["Fore"]);
|
||||
|
@ -566,64 +553,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
|
||||
$styleArray['fill']['endcolor']['rgb'] = $RGB2;
|
||||
switch ($shade) {
|
||||
case '1' :
|
||||
case '1':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
|
||||
break;
|
||||
case '2' :
|
||||
case '2':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR;
|
||||
break;
|
||||
case '3' :
|
||||
case '3':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH;
|
||||
break;
|
||||
case '4' :
|
||||
case '4':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
|
||||
break;
|
||||
case '5' :
|
||||
case '5':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
|
||||
break;
|
||||
case '6' :
|
||||
case '6':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
|
||||
break;
|
||||
case '7' :
|
||||
case '7':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
|
||||
break;
|
||||
case '8' :
|
||||
case '8':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
|
||||
break;
|
||||
case '9' :
|
||||
case '9':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
|
||||
break;
|
||||
case '10' :
|
||||
case '10':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
|
||||
break;
|
||||
case '11' :
|
||||
case '11':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
|
||||
break;
|
||||
case '12' :
|
||||
case '12':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
|
||||
break;
|
||||
case '13' :
|
||||
case '13':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
|
||||
break;
|
||||
case '14' :
|
||||
case '14':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
|
||||
break;
|
||||
case '15' :
|
||||
case '15':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
|
||||
break;
|
||||
case '16' :
|
||||
case '16':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
|
||||
break;
|
||||
case '17' :
|
||||
case '17':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
|
||||
break;
|
||||
case '18' :
|
||||
case '18':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
|
||||
break;
|
||||
case '19' :
|
||||
case '19':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
|
||||
break;
|
||||
case '20' :
|
||||
case '20':
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
|
||||
break;
|
||||
}
|
||||
|
@ -634,32 +621,32 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
// echo '<br />';
|
||||
$styleArray['font']['name'] = (string) $styleRegion->Style->Font;
|
||||
$styleArray['font']['size'] = intval($fontAttributes['Unit']);
|
||||
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False;
|
||||
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False;
|
||||
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
|
||||
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false;
|
||||
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false;
|
||||
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;
|
||||
switch ($fontAttributes['Underline']) {
|
||||
case '1' :
|
||||
case '1':
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
|
||||
break;
|
||||
case '2' :
|
||||
case '2':
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case '3' :
|
||||
case '3':
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING;
|
||||
break;
|
||||
case '4' :
|
||||
case '4':
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING;
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
switch ($fontAttributes['Script']) {
|
||||
case '1' :
|
||||
$styleArray['font']['superScript'] = True;
|
||||
case '1':
|
||||
$styleArray['font']['superScript'] = true;
|
||||
break;
|
||||
case '-1' :
|
||||
$styleArray['font']['subScript'] = True;
|
||||
case '-1':
|
||||
$styleArray['font']['subScript'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -761,7 +748,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
// Handle Merged Cells in this worksheet
|
||||
if (isset($sheet->MergedRegions)) {
|
||||
foreach ($sheet->MergedRegions->Merge as $mergeCells) {
|
||||
if (strpos($mergeCells,':') !== FALSE) {
|
||||
if (strpos($mergeCells,':') !== false) {
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
|
||||
}
|
||||
}
|
||||
|
@ -783,17 +770,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
$range[0] = trim($range[0],"'");;
|
||||
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
|
||||
$extractedRange = str_replace('$', '', $range[1]);
|
||||
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) );
|
||||
$objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
private static function _parseBorderAttributes($borderAttributes)
|
||||
{
|
||||
$styleArray = array();
|
||||
|
@ -804,54 +789,54 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
}
|
||||
|
||||
switch ($borderAttributes["Style"]) {
|
||||
case '0' :
|
||||
case '0':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE;
|
||||
break;
|
||||
case '1' :
|
||||
case '1':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case '2' :
|
||||
case '2':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
|
||||
break;
|
||||
case '4' :
|
||||
case '4':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
|
||||
break;
|
||||
case '5' :
|
||||
case '5':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
|
||||
break;
|
||||
case '6' :
|
||||
case '6':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
|
||||
break;
|
||||
case '7' :
|
||||
case '7':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
|
||||
break;
|
||||
case '9' :
|
||||
case '9':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
|
||||
break;
|
||||
case '10' :
|
||||
case '10':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
|
||||
break;
|
||||
case '11' :
|
||||
case '11':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
|
||||
break;
|
||||
case '12' :
|
||||
case '12':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
break;
|
||||
case '13' :
|
||||
case '13':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
break;
|
||||
case '3' :
|
||||
case '3':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
|
||||
break;
|
||||
case '8' :
|
||||
case '8':
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
|
||||
break;
|
||||
}
|
||||
return $styleArray;
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
private function _parseRichText($is = '')
|
||||
{
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
@ -859,15 +844,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
|
|||
return $value;
|
||||
}
|
||||
|
||||
|
||||
private static function _parseGnumericColour($gnmColour) {
|
||||
list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
|
||||
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
$gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
$gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
|
||||
$RGB = $gnmR.$gnmG.$gnmB;
|
||||
// echo 'Excel Colour: ', $RGB,'<br />';
|
||||
return $RGB;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
*/
|
||||
private $_styles = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_OOCalc
|
||||
*/
|
||||
|
@ -59,7 +58,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
|
@ -77,7 +75,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$zipClass = PHPExcel_Settings::getZipClass();
|
||||
|
||||
// Check if zip class exists
|
||||
// if (!class_exists($zipClass, FALSE)) {
|
||||
// if (!class_exists($zipClass, false)) {
|
||||
// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
|
||||
// }
|
||||
|
||||
|
@ -109,7 +107,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,18 +135,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
|
||||
$xml = new XMLReader();
|
||||
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2,true);
|
||||
$xml->setParserProperty(2, true);
|
||||
|
||||
// Step into the first level of content of the XML
|
||||
$xml->read();
|
||||
while ($xml->read()) {
|
||||
// Quickly jump through to the office:body node
|
||||
while ($xml->name !== 'office:body') {
|
||||
if ($xml->isEmptyElement)
|
||||
if ($xml->isEmptyElement) {
|
||||
$xml->read();
|
||||
else
|
||||
} else {
|
||||
$xml->next();
|
||||
}
|
||||
}
|
||||
// Now read each node until we find our first table:table node
|
||||
while ($xml->read()) {
|
||||
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
|
@ -164,7 +163,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
|
@ -189,18 +187,19 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
|
||||
$xml = new XMLReader();
|
||||
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
|
||||
$xml->setParserProperty(2,true);
|
||||
$xml->setParserProperty(2, true);
|
||||
|
||||
// Step into the first level of content of the XML
|
||||
$xml->read();
|
||||
while ($xml->read()) {
|
||||
// Quickly jump through to the office:body node
|
||||
while ($xml->name !== 'office:body') {
|
||||
if ($xml->isEmptyElement)
|
||||
if ($xml->isEmptyElement) {
|
||||
$xml->read();
|
||||
else
|
||||
} else {
|
||||
$xml->next();
|
||||
}
|
||||
}
|
||||
// Now read each node until we find our first table:table node
|
||||
while ($xml->read()) {
|
||||
if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
|
@ -289,7 +288,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
|
@ -306,8 +304,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue)
|
||||
{
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach ($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
|
@ -318,7 +316,6 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
|
@ -407,15 +404,15 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
} elseif ($key == 'value-type') {
|
||||
switch ($value) {
|
||||
case 'date' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'boolean' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool');
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'float' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4');
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
|
||||
break;
|
||||
default :
|
||||
|
@ -470,7 +467,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
// echo '<b>'.$key.'</b><br />';
|
||||
switch ($key) {
|
||||
case 'table-header-rows':
|
||||
foreach ($rowData as $key=>$cellData) {
|
||||
foreach ($rowData as $key => $cellData) {
|
||||
$rowData = $cellData;
|
||||
break;
|
||||
}
|
||||
|
@ -480,7 +477,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
$rowDataTableAttributes['number-rows-repeated'] : 1;
|
||||
$columnID = 'A';
|
||||
foreach ($rowData as $key => $cellData) {
|
||||
if ($this->getReadFilter() !== NULL) {
|
||||
if ($this->getReadFilter() !== null) {
|
||||
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -524,7 +521,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
}
|
||||
}
|
||||
$text = implode("\n", $textArray);
|
||||
// echo $text,'<br />';
|
||||
// echo $text, '<br />';
|
||||
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
|
||||
// ->setAuthor( $author )
|
||||
->setText($this->_parseRichText($text) );
|
||||
|
@ -564,7 +561,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
break;
|
||||
case 'boolean' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
|
||||
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
|
||||
break;
|
||||
case 'percentage' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
@ -606,33 +603,33 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
break;
|
||||
case 'time' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
|
||||
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS'))));
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
|
||||
break;
|
||||
}
|
||||
// echo 'Data value is '.$dataValue.'<br />';
|
||||
// if ($hyperlink !== NULL) {
|
||||
// if ($hyperlink !== null) {
|
||||
// echo 'Hyperlink is '.$hyperlink.'<br />';
|
||||
// }
|
||||
} else {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
$dataValue = NULL;
|
||||
$dataValue = null;
|
||||
}
|
||||
|
||||
if ($hasCalculatedValue) {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
// echo 'Formula: ', $cellDataFormula, PHP_EOL;
|
||||
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
|
||||
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula, ':=')+1);
|
||||
$temp = explode('"', $cellDataFormula);
|
||||
$tKey = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($tKey = !$tKey) {
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2', $value); // Cell reference in another sheet
|
||||
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference
|
||||
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference
|
||||
$value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces);
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet
|
||||
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference
|
||||
$value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference
|
||||
$value = PHPExcel_Calculation::_translateSeparator(';', ',', $value, $inBraces);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
@ -641,9 +638,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
|
||||
}
|
||||
|
||||
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
|
||||
$cellDataTableAttributes['number-columns-repeated'] : 1;
|
||||
if ($type !== NULL) {
|
||||
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ? $cellDataTableAttributes['number-columns-repeated'] : 1;
|
||||
if ($type !== null) {
|
||||
for ($i = 0; $i < $colRepeats; ++$i) {
|
||||
if ($i > 0) {
|
||||
++$columnID;
|
||||
|
@ -656,12 +652,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
// echo 'Forumla result is '.$dataValue.'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
|
||||
}
|
||||
if ($formatting !== NULL) {
|
||||
if ($formatting !== null) {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
|
||||
} else {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
|
||||
}
|
||||
if ($hyperlink !== NULL) {
|
||||
if ($hyperlink !== null) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
|
||||
}
|
||||
}
|
||||
|
@ -699,13 +695,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
private function _parseRichText($is = '')
|
||||
{
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
/**
|
||||
* Create a new PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
|
||||
// Analyze first line looking for ID; signature
|
||||
$lines = explode("\n", $data);
|
||||
if (substr($lines[0],0,4) != 'ID;P') {
|
||||
if (substr($lines[0], 0, 4) != 'ID;P') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -136,7 +137,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
fclose($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
|
@ -162,20 +163,20 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
if ($dataType == 'C') {
|
||||
// Read cell value data
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' :
|
||||
$columnIndex = substr($rowDatum,1) - 1;
|
||||
case 'C':
|
||||
case 'X':
|
||||
$columnIndex = substr($rowDatum, 1) - 1;
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' :
|
||||
$rowIndex = substr($rowDatum,1);
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$rowIndex = substr($rowDatum, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -223,7 +224,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
// Open file
|
||||
$this->_openFile($pFilename);
|
||||
if (!$this->_isValidFormat()) {
|
||||
fclose ($this->_fileHandle);
|
||||
fclose($this->_fileHandle);
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
$fileHandle = $this->_fileHandle;
|
||||
|
@ -233,7 +234,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
||||
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
@ -244,13 +245,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowData = fgets($fileHandle)) !== false) {
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
|
@ -270,7 +270,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
break;
|
||||
case 'S':
|
||||
$styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
for ($i=0; $i<strlen($styleSettings); ++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I':
|
||||
$formatArray['font']['italic'] = true;
|
||||
|
@ -321,7 +321,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
foreach ($temp as &$value) {
|
||||
// Only count/replace in alternate array entries
|
||||
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
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// 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
|
||||
if ($columnReference{0} == '[') {
|
||||
$columnReference = $column + trim($columnReference,'[]');
|
||||
$columnReference = $column + trim($columnReference, '[]');
|
||||
}
|
||||
$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));
|
||||
break;
|
||||
case 'S':
|
||||
$styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
$styleSettings = substr($rowDatum, 1);
|
||||
for ($i=0; $i<strlen($styleSettings); ++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I':
|
||||
$styleData['font']['italic'] = true;
|
||||
|
@ -444,11 +444,11 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||
switch ($rowDatum{0}) {
|
||||
case 'C':
|
||||
case 'X':
|
||||
$column = substr($rowDatum,1);
|
||||
$column = substr($rowDatum, 1);
|
||||
break;
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$row = substr($rowDatum,1);
|
||||
$row = substr($rowDatum, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* @author Michael Bommarito
|
||||
* @version 1.2
|
||||
*/
|
||||
class CholeskyDecomposition {
|
||||
|
||||
class CholeskyDecomposition
|
||||
{
|
||||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
|
@ -38,21 +38,21 @@ class CholeskyDecomposition {
|
|||
*/
|
||||
private $isspd = true;
|
||||
|
||||
|
||||
/**
|
||||
* CholeskyDecomposition
|
||||
*
|
||||
* Class constructor - decomposes 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) {
|
||||
$this->L = $A->getArray();
|
||||
$this->m = $A->getRowDimension();
|
||||
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = $i; $j < $this->m; ++$j) {
|
||||
for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = $i; $j < $this->m; ++$j) {
|
||||
for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
|
||||
$sum -= $this->L[$i][$k] * $this->L[$j][$k];
|
||||
}
|
||||
if ($i == $j) {
|
||||
|
@ -77,35 +77,35 @@ class CholeskyDecomposition {
|
|||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Is the matrix symmetric and positive definite?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSPD() {
|
||||
public function isSPD()
|
||||
{
|
||||
return $this->isspd;
|
||||
} // function isSPD()
|
||||
|
||||
|
||||
/**
|
||||
* getL
|
||||
*
|
||||
* Return triangular factor.
|
||||
* @return Matrix Lower triangular matrix
|
||||
*/
|
||||
public function getL() {
|
||||
public function getL()
|
||||
{
|
||||
return new Matrix($this->L);
|
||||
} // function getL()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
*
|
||||
* @param $B Row-equal matrix
|
||||
* @return Matrix L * L' * X = B
|
||||
*/
|
||||
public function solve($B = null) {
|
||||
public function solve($B = null)
|
||||
{
|
||||
if ($B instanceof Matrix) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isspd) {
|
||||
|
@ -145,5 +145,4 @@ class CholeskyDecomposition {
|
|||
throw new PHPExcel_Calculation_Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
} // class CholeskyDecomposition
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
* @license PHP v3.0
|
||||
* @version 1.1
|
||||
*/
|
||||
class EigenvalueDecomposition {
|
||||
|
||||
class EigenvalueDecomposition
|
||||
{
|
||||
/**
|
||||
* Row and column dimension (square matrix).
|
||||
* @var int
|
||||
|
@ -67,13 +67,13 @@ class EigenvalueDecomposition {
|
|||
private $cdivr;
|
||||
private $cdivi;
|
||||
|
||||
|
||||
/**
|
||||
* Symmetric Householder reduction to tridiagonal form.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function tred2 () {
|
||||
private function tred2 ()
|
||||
{
|
||||
// This is derived from the Algol procedures tred2 by
|
||||
// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
|
||||
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
|
||||
|
@ -171,7 +171,6 @@ class EigenvalueDecomposition {
|
|||
$this->e[0] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Symmetric tridiagonal QL algorithm.
|
||||
*
|
||||
|
@ -182,7 +181,8 @@ class EigenvalueDecomposition {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
private function tql2() {
|
||||
private function tql2()
|
||||
{
|
||||
for ($i = 1; $i < $this->n; ++$i) {
|
||||
$this->e[$i-1] = $this->e[$i];
|
||||
}
|
||||
|
@ -196,8 +196,9 @@ class EigenvalueDecomposition {
|
|||
$tst1 = max($tst1, abs($this->d[$l]) + abs($this->e[$l]));
|
||||
$m = $l;
|
||||
while ($m < $this->n) {
|
||||
if (abs($this->e[$m]) <= $eps * $tst1)
|
||||
if (abs($this->e[$m]) <= $eps * $tst1) {
|
||||
break;
|
||||
}
|
||||
++$m;
|
||||
}
|
||||
// If m == l, $this->d[l] is an eigenvalue,
|
||||
|
@ -211,14 +212,16 @@ class EigenvalueDecomposition {
|
|||
$g = $this->d[$l];
|
||||
$p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]);
|
||||
$r = hypo($p, 1.0);
|
||||
if ($p < 0)
|
||||
if ($p < 0) {
|
||||
$r *= -1;
|
||||
}
|
||||
$this->d[$l] = $this->e[$l] / ($p + $r);
|
||||
$this->d[$l+1] = $this->e[$l] * ($p + $r);
|
||||
$dl1 = $this->d[$l+1];
|
||||
$h = $g - $this->d[$l];
|
||||
for ($i = $l + 2; $i < $this->n; ++$i)
|
||||
for ($i = $l + 2; $i < $this->n; ++$i) {
|
||||
$this->d[$i] -= $h;
|
||||
}
|
||||
$f += $h;
|
||||
// Implicit QL transformation.
|
||||
$p = $this->d[$m];
|
||||
|
@ -277,7 +280,6 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nonsymmetric reduction to Hessenberg form.
|
||||
*
|
||||
|
@ -288,7 +290,8 @@ class EigenvalueDecomposition {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
private function orthes () {
|
||||
private function orthes()
|
||||
{
|
||||
$low = 0;
|
||||
$high = $this->n-1;
|
||||
|
||||
|
@ -364,13 +367,13 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs complex division.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function cdiv($xr, $xi, $yr, $yi) {
|
||||
private function cdiv($xr, $xi, $yr, $yi)
|
||||
{
|
||||
if (abs($yr) > abs($yi)) {
|
||||
$r = $yi / $yr;
|
||||
$d = $yr + $r * $yi;
|
||||
|
@ -384,7 +387,6 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nonsymmetric reduction from Hessenberg to real Schur form.
|
||||
*
|
||||
|
@ -395,7 +397,8 @@ class EigenvalueDecomposition {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
private function hqr2 () {
|
||||
private function hqr2()
|
||||
{
|
||||
// Initialize
|
||||
$nn = $this->n;
|
||||
$n = $nn - 1;
|
||||
|
@ -408,7 +411,7 @@ class EigenvalueDecomposition {
|
|||
$norm = 0.0;
|
||||
|
||||
for ($i = 0; $i < $nn; ++$i) {
|
||||
if (($i < $low) OR ($i > $high)) {
|
||||
if (($i < $low) or ($i > $high)) {
|
||||
$this->d[$i] = $this->H[$i][$i];
|
||||
$this->e[$i] = 0.0;
|
||||
}
|
||||
|
@ -477,7 +480,7 @@ class EigenvalueDecomposition {
|
|||
$this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z;
|
||||
}
|
||||
// Column modification
|
||||
for ($i = 0; $i <= n; ++$i) {
|
||||
for ($i = 0; $i <= $n; ++$i) {
|
||||
$z = $this->H[$i][$n-1];
|
||||
$this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n];
|
||||
$this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z;
|
||||
|
@ -771,7 +774,6 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
} // end hqr2
|
||||
|
||||
|
||||
/**
|
||||
* Constructor: Check for symmetry, then construct the eigenvalue decomposition
|
||||
*
|
||||
|
@ -779,7 +781,8 @@ class EigenvalueDecomposition {
|
|||
* @param A Square matrix
|
||||
* @return Structure to access D and V.
|
||||
*/
|
||||
public function __construct($Arg) {
|
||||
public function __construct($Arg)
|
||||
{
|
||||
$this->A = $Arg->getArray();
|
||||
$this->n = $Arg->getColumnDimension();
|
||||
|
||||
|
@ -806,47 +809,47 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the eigenvector matrix
|
||||
*
|
||||
* @access public
|
||||
* @return V
|
||||
*/
|
||||
public function getV() {
|
||||
public function getV()
|
||||
{
|
||||
return new Matrix($this->V, $this->n, $this->n);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the real parts of the eigenvalues
|
||||
*
|
||||
* @access public
|
||||
* @return real(diag(D))
|
||||
*/
|
||||
public function getRealEigenvalues() {
|
||||
public function getRealEigenvalues()
|
||||
{
|
||||
return $this->d;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the imaginary parts of the eigenvalues
|
||||
*
|
||||
* @access public
|
||||
* @return imag(diag(D))
|
||||
*/
|
||||
public function getImagEigenvalues() {
|
||||
public function getImagEigenvalues()
|
||||
{
|
||||
return $this->e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the block diagonal eigenvalue matrix
|
||||
*
|
||||
* @access public
|
||||
* @return D
|
||||
*/
|
||||
public function getD() {
|
||||
public function getD()
|
||||
{
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
$D[$i] = array_fill(0, $this->n, 0.0);
|
||||
$D[$i][$i] = $this->d[$i];
|
||||
|
@ -858,5 +861,4 @@ class EigenvalueDecomposition {
|
|||
}
|
||||
return new Matrix($D);
|
||||
}
|
||||
|
||||
} // class EigenvalueDecomposition
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
* @version 1.1
|
||||
* @license PHP v3.0
|
||||
*/
|
||||
class PHPExcel_Shared_JAMA_LUDecomposition {
|
||||
|
||||
class PHPExcel_Shared_JAMA_LUDecomposition
|
||||
{
|
||||
const MatrixSingularException = "Can only perform operation on singular matrix.";
|
||||
const MatrixSquareException = "Mismatched Row dimension";
|
||||
|
||||
|
@ -53,14 +53,14 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
*/
|
||||
private $piv = array();
|
||||
|
||||
|
||||
/**
|
||||
* LU Decomposition constructor.
|
||||
*
|
||||
* @param $A Rectangular matrix
|
||||
* @return Structure to access L, U and piv.
|
||||
*/
|
||||
public function __construct($A) {
|
||||
public function __construct($A)
|
||||
{
|
||||
if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
|
||||
$this->LU = $A->getArray();
|
||||
|
@ -119,13 +119,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Get lower triangular factor.
|
||||
*
|
||||
* @return array Lower triangular factor
|
||||
*/
|
||||
public function getL() {
|
||||
public function getL()
|
||||
{
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i > $j) {
|
||||
|
@ -140,13 +140,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
return new PHPExcel_Shared_JAMA_Matrix($L);
|
||||
} // function getL()
|
||||
|
||||
|
||||
/**
|
||||
* Get upper triangular factor.
|
||||
*
|
||||
* @return array Upper triangular factor
|
||||
*/
|
||||
public function getU() {
|
||||
public function getU()
|
||||
{
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i <= $j) {
|
||||
|
@ -159,33 +159,33 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
return new PHPExcel_Shared_JAMA_Matrix($U);
|
||||
} // function getU()
|
||||
|
||||
|
||||
/**
|
||||
* Return pivot permutation vector.
|
||||
*
|
||||
* @return array Pivot vector
|
||||
*/
|
||||
public function getPivot() {
|
||||
public function getPivot()
|
||||
{
|
||||
return $this->piv;
|
||||
} // function getPivot()
|
||||
|
||||
|
||||
/**
|
||||
* Alias for getPivot
|
||||
*
|
||||
* @see getPivot
|
||||
*/
|
||||
public function getDoublePivot() {
|
||||
public function getDoublePivot()
|
||||
{
|
||||
return $this->getPivot();
|
||||
} // function getDoublePivot()
|
||||
|
||||
|
||||
/**
|
||||
* Is the matrix nonsingular?
|
||||
*
|
||||
* @return true if U, and hence A, is nonsingular.
|
||||
*/
|
||||
public function isNonsingular() {
|
||||
public function isNonsingular()
|
||||
{
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($this->LU[$j][$j] == 0) {
|
||||
return false;
|
||||
|
@ -194,13 +194,13 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
return true;
|
||||
} // function isNonsingular()
|
||||
|
||||
|
||||
/**
|
||||
* Count determinants
|
||||
*
|
||||
* @return array d matrix deterninat
|
||||
*/
|
||||
public function det() {
|
||||
public function det()
|
||||
{
|
||||
if ($this->m == $this->n) {
|
||||
$d = $this->pivsign;
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
|
@ -212,7 +212,6 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
}
|
||||
} // function det()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
*
|
||||
|
@ -221,7 +220,8 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
* @PHPExcel_Calculation_Exception IllegalArgumentException Matrix row dimensions must agree.
|
||||
* @PHPExcel_Calculation_Exception RuntimeException Matrix is singular.
|
||||
*/
|
||||
public function solve($B) {
|
||||
public function solve($B)
|
||||
{
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isNonsingular()) {
|
||||
// Copy right hand side with pivoting
|
||||
|
@ -254,5 +254,4 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
|
|||
throw new PHPExcel_Calculation_Exception(self::MatrixSquareException);
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
} // class PHPExcel_Shared_JAMA_LUDecomposition
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
* @license PHP v3.0
|
||||
* @see http://math.nist.gov/javanumerics/jama/
|
||||
*/
|
||||
class PHPExcel_Shared_JAMA_Matrix {
|
||||
|
||||
|
||||
class PHPExcel_Shared_JAMA_Matrix
|
||||
{
|
||||
const PolymorphicArgumentException = "Invalid argument pattern for polymorphic function.";
|
||||
const ArgumentTypeException = "Invalid argument type.";
|
||||
const ArgumentBoundsException = "Invalid argument range.";
|
||||
|
@ -57,13 +56,13 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
*/
|
||||
private $n;
|
||||
|
||||
|
||||
/**
|
||||
* Polymorphic constructor
|
||||
*
|
||||
* As PHP has no support for polymorphic constructors, we hack our own sort of polymorphism using func_num_args, func_get_arg, and gettype. In essence, we're just implementing a simple RTTI filter and calling the appropriate constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
@ -114,37 +113,36 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* getArray
|
||||
*
|
||||
* @return array Matrix array
|
||||
*/
|
||||
public function getArray() {
|
||||
public function getArray()
|
||||
{
|
||||
return $this->A;
|
||||
} // function getArray()
|
||||
|
||||
|
||||
/**
|
||||
* getRowDimension
|
||||
*
|
||||
* @return int Row dimension
|
||||
*/
|
||||
public function getRowDimension() {
|
||||
public function getRowDimension()
|
||||
{
|
||||
return $this->m;
|
||||
} // function getRowDimension()
|
||||
|
||||
|
||||
/**
|
||||
* getColumnDimension
|
||||
*
|
||||
* @return int Column dimension
|
||||
*/
|
||||
public function getColumnDimension() {
|
||||
public function getColumnDimension()
|
||||
{
|
||||
return $this->n;
|
||||
} // function getColumnDimension()
|
||||
|
||||
|
||||
/**
|
||||
* get
|
||||
*
|
||||
|
@ -153,11 +151,11 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param int $j Column position
|
||||
* @return mixed Element (int/float/double)
|
||||
*/
|
||||
public function get($i = null, $j = null) {
|
||||
public function get($i = null, $j = null)
|
||||
{
|
||||
return $this->A[$i][$j];
|
||||
} // function get()
|
||||
|
||||
|
||||
/**
|
||||
* getMatrix
|
||||
*
|
||||
|
@ -168,7 +166,8 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param int $jF Final column index
|
||||
* @return Matrix Submatrix
|
||||
*/
|
||||
public function getMatrix() {
|
||||
public function getMatrix()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
@ -261,7 +260,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function getMatrix()
|
||||
|
||||
|
||||
/**
|
||||
* checkMatrixDimensions
|
||||
*
|
||||
|
@ -269,7 +267,8 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param Matrix $B Matrix B
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkMatrixDimensions($B = null) {
|
||||
public function checkMatrixDimensions($B = null)
|
||||
{
|
||||
if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
|
||||
return true;
|
||||
|
@ -281,8 +280,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function checkMatrixDimensions()
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* set
|
||||
*
|
||||
|
@ -292,12 +289,12 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $c Int/float/double value
|
||||
* @return mixed Element (int/float/double)
|
||||
*/
|
||||
public function set($i = null, $j = null, $c = null) {
|
||||
public function set($i = null, $j = null, $c = null)
|
||||
{
|
||||
// Optimized set version just has this
|
||||
$this->A[$i][$j] = $c;
|
||||
} // function set()
|
||||
|
||||
|
||||
/**
|
||||
* identity
|
||||
*
|
||||
|
@ -306,11 +303,11 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param int $n Column dimension
|
||||
* @return Matrix Identity matrix
|
||||
*/
|
||||
public function identity($m = null, $n = null) {
|
||||
public function identity($m = null, $n = null)
|
||||
{
|
||||
return $this->diagonal($m, $n, 1);
|
||||
} // function identity()
|
||||
|
||||
|
||||
/**
|
||||
* diagonal
|
||||
*
|
||||
|
@ -320,7 +317,8 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $c Diagonal value
|
||||
* @return Matrix Diagonal matrix
|
||||
*/
|
||||
public function diagonal($m = null, $n = null, $c = 1) {
|
||||
public function diagonal($m = null, $n = null, $c = 1)
|
||||
{
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
|
||||
for($i = 0; $i < $m; ++$i) {
|
||||
$R->set($i, $i, $c);
|
||||
|
@ -328,7 +326,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
return $R;
|
||||
} // function diagonal()
|
||||
|
||||
|
||||
/**
|
||||
* getMatrixByRow
|
||||
*
|
||||
|
@ -337,7 +334,8 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param int $iF Final row index
|
||||
* @return Matrix Submatrix
|
||||
*/
|
||||
public function getMatrixByRow($i0 = null, $iF = null) {
|
||||
public function getMatrixByRow($i0 = null, $iF = null)
|
||||
{
|
||||
if (is_int($i0)) {
|
||||
if (is_int($iF)) {
|
||||
return $this->getMatrix($i0, 0, $iF + 1, $this->n);
|
||||
|
@ -349,7 +347,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function getMatrixByRow()
|
||||
|
||||
|
||||
/**
|
||||
* getMatrixByCol
|
||||
*
|
||||
|
@ -358,7 +355,8 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param int $iF Final column index
|
||||
* @return Matrix Submatrix
|
||||
*/
|
||||
public function getMatrixByCol($j0 = null, $jF = null) {
|
||||
public function getMatrixByCol($j0 = null, $jF = null)
|
||||
{
|
||||
if (is_int($j0)) {
|
||||
if (is_int($jF)) {
|
||||
return $this->getMatrix(0, $j0, $this->m, $jF + 1);
|
||||
|
@ -370,14 +368,14 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function getMatrixByCol()
|
||||
|
||||
|
||||
/**
|
||||
* transpose
|
||||
*
|
||||
* Tranpose matrix
|
||||
* @return Matrix Transposed matrix
|
||||
*/
|
||||
public function transpose() {
|
||||
public function transpose()
|
||||
{
|
||||
$R = new PHPExcel_Shared_JAMA_Matrix($this->n, $this->m);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
|
@ -387,14 +385,14 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
return $R;
|
||||
} // function transpose()
|
||||
|
||||
|
||||
/**
|
||||
* trace
|
||||
*
|
||||
* Sum of diagonal elements
|
||||
* @return float Sum of diagonal elements
|
||||
*/
|
||||
public function trace() {
|
||||
public function trace()
|
||||
{
|
||||
$s = 0;
|
||||
$n = min($this->m, $this->n);
|
||||
for($i = 0; $i < $n; ++$i) {
|
||||
|
@ -403,17 +401,16 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
return $s;
|
||||
} // function trace()
|
||||
|
||||
|
||||
/**
|
||||
* uminus
|
||||
*
|
||||
* Unary minus matrix -A
|
||||
* @return Matrix Unary minus matrix
|
||||
*/
|
||||
public function uminus() {
|
||||
public function uminus()
|
||||
{
|
||||
} // function uminus()
|
||||
|
||||
|
||||
/**
|
||||
* plus
|
||||
*
|
||||
|
@ -421,14 +418,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function plus() {
|
||||
public function plus()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -449,7 +451,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function plus()
|
||||
|
||||
|
||||
/**
|
||||
* plusEquals
|
||||
*
|
||||
|
@ -457,14 +458,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function plusEquals() {
|
||||
public function plusEquals()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -476,7 +482,7 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$validValues = True;
|
||||
$validValues = true;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
|
@ -499,7 +505,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function plusEquals()
|
||||
|
||||
|
||||
/**
|
||||
* minus
|
||||
*
|
||||
|
@ -507,14 +512,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function minus() {
|
||||
public function minus()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -535,7 +545,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function minus()
|
||||
|
||||
|
||||
/**
|
||||
* minusEquals
|
||||
*
|
||||
|
@ -543,14 +552,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function minusEquals() {
|
||||
public function minusEquals()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -562,7 +576,7 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$validValues = True;
|
||||
$validValues = true;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
|
@ -585,7 +599,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function minusEquals()
|
||||
|
||||
|
||||
/**
|
||||
* arrayTimes
|
||||
*
|
||||
|
@ -594,14 +607,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Matrix Cij
|
||||
*/
|
||||
public function arrayTimes() {
|
||||
public function arrayTimes()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -622,7 +640,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function arrayTimes()
|
||||
|
||||
|
||||
/**
|
||||
* arrayTimesEquals
|
||||
*
|
||||
|
@ -631,14 +648,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Matrix Aij
|
||||
*/
|
||||
public function arrayTimesEquals() {
|
||||
public function arrayTimesEquals()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -650,7 +672,7 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$validValues = True;
|
||||
$validValues = true;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
|
@ -673,7 +695,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function arrayTimesEquals()
|
||||
|
||||
|
||||
/**
|
||||
* arrayRightDivide
|
||||
*
|
||||
|
@ -682,14 +703,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param Matrix $B Matrix B
|
||||
* @return Matrix Division result
|
||||
*/
|
||||
public function arrayRightDivide() {
|
||||
public function arrayRightDivide()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -701,7 +727,7 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$validValues = True;
|
||||
$validValues = true;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
|
@ -738,14 +764,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Matrix Aij
|
||||
*/
|
||||
public function arrayRightDivideEquals() {
|
||||
public function arrayRightDivideEquals()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -775,14 +806,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param Matrix $B Matrix B
|
||||
* @return Matrix Division result
|
||||
*/
|
||||
public function arrayLeftDivide() {
|
||||
public function arrayLeftDivide()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -812,14 +848,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Matrix Aij
|
||||
*/
|
||||
public function arrayLeftDivideEquals() {
|
||||
public function arrayLeftDivideEquals()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -848,14 +889,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $n Matrix/Array/Scalar
|
||||
* @return Matrix Product
|
||||
*/
|
||||
public function times() {
|
||||
public function times()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$B = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
if ($this->n == $B->m) {
|
||||
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
|
||||
for($j = 0; $j < $B->n; ++$j) {
|
||||
|
@ -931,7 +977,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function times()
|
||||
|
||||
|
||||
/**
|
||||
* power
|
||||
*
|
||||
|
@ -939,14 +984,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function power() {
|
||||
public function power()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
|
@ -958,7 +1008,7 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$validValues = True;
|
||||
$validValues = true;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
|
@ -981,7 +1031,6 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function power()
|
||||
|
||||
|
||||
/**
|
||||
* concat
|
||||
*
|
||||
|
@ -989,14 +1038,19 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
* @param mixed $B Matrix/Array
|
||||
* @return Matrix Sum
|
||||
*/
|
||||
public function concat() {
|
||||
public function concat()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$args = func_get_args();
|
||||
$match = implode(",", array_map('gettype', $args));
|
||||
|
||||
switch ($match) {
|
||||
case 'object':
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
|
||||
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
$M = $args[0];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
|
||||
}
|
||||
case 'array':
|
||||
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
|
||||
break;
|
||||
|
@ -1016,14 +1070,14 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function concat()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B.
|
||||
*
|
||||
* @param Matrix $B Right hand side
|
||||
* @return Matrix ... Solution if A is square, least squares solution otherwise
|
||||
*/
|
||||
public function solve($B) {
|
||||
public function solve($B)
|
||||
{
|
||||
if ($this->m == $this->n) {
|
||||
$LU = new PHPExcel_Shared_JAMA_LUDecomposition($this);
|
||||
return $LU->solve($B);
|
||||
|
@ -1033,24 +1087,24 @@ class PHPExcel_Shared_JAMA_Matrix {
|
|||
}
|
||||
} // function solve()
|
||||
|
||||
|
||||
/**
|
||||
* Matrix inverse or pseudoinverse.
|
||||
*
|
||||
* @return Matrix ... Inverse(A) if A is square, pseudoinverse otherwise.
|
||||
*/
|
||||
public function inverse() {
|
||||
public function inverse()
|
||||
{
|
||||
return $this->solve($this->identity($this->m, $this->m));
|
||||
} // function inverse()
|
||||
|
||||
|
||||
/**
|
||||
* det
|
||||
*
|
||||
* Calculate determinant
|
||||
* @return float Determinant
|
||||
*/
|
||||
public function det() {
|
||||
public function det()
|
||||
{
|
||||
$L = new PHPExcel_Shared_JAMA_LUDecomposition($this);
|
||||
return $L->det();
|
||||
} // function det()
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* @license PHP v3.0
|
||||
* @version 1.1
|
||||
*/
|
||||
class PHPExcel_Shared_JAMA_QRDecomposition {
|
||||
|
||||
class PHPExcel_Shared_JAMA_QRDecomposition
|
||||
{
|
||||
const MatrixRankException = "Can only perform operation on full-rank matrix.";
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
* @param matrix $A Rectangular matrix
|
||||
* @return Structure to access R and the Householder vectors and compute Q.
|
||||
*/
|
||||
public function __construct($A) {
|
||||
public function __construct($A)
|
||||
{
|
||||
if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
|
||||
// Initialize.
|
||||
$this->QR = $A->getArrayCopy();
|
||||
|
@ -98,7 +99,8 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
*
|
||||
* @return boolean true if R, and hence A, has full rank, else false.
|
||||
*/
|
||||
public function isFullRank() {
|
||||
public function isFullRank()
|
||||
{
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($this->Rdiag[$j] == 0) {
|
||||
return false;
|
||||
|
@ -107,13 +109,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
return true;
|
||||
} // function isFullRank()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Householder vectors
|
||||
*
|
||||
* @return Matrix Lower trapezoidal matrix whose columns define the reflections
|
||||
*/
|
||||
public function getH() {
|
||||
public function getH()
|
||||
{
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i >= $j) {
|
||||
|
@ -126,13 +128,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
return new PHPExcel_Shared_JAMA_Matrix($H);
|
||||
} // function getH()
|
||||
|
||||
|
||||
/**
|
||||
* Return the upper triangular factor
|
||||
*
|
||||
* @return Matrix upper triangular factor
|
||||
*/
|
||||
public function getR() {
|
||||
public function getR()
|
||||
{
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i < $j) {
|
||||
|
@ -147,13 +149,13 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
return new PHPExcel_Shared_JAMA_Matrix($R);
|
||||
} // function getR()
|
||||
|
||||
|
||||
/**
|
||||
* Generate and return the (economy-sized) orthogonal factor
|
||||
*
|
||||
* @return Matrix orthogonal factor
|
||||
*/
|
||||
public function getQ() {
|
||||
public function getQ()
|
||||
{
|
||||
for ($k = $this->n-1; $k >= 0; --$k) {
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
$Q[$i][$k] = 0.0;
|
||||
|
@ -184,14 +186,14 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
return new PHPExcel_Shared_JAMA_Matrix($Q);
|
||||
} // function getQ()
|
||||
|
||||
|
||||
/**
|
||||
* Least squares solution of A*X = B
|
||||
*
|
||||
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
|
||||
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
|
||||
*/
|
||||
public function solve($B) {
|
||||
public function solve($B)
|
||||
{
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isFullRank()) {
|
||||
// Copy right hand side
|
||||
|
@ -230,5 +232,5 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
|
|||
throw new PHPExcel_Calculation_Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException);
|
||||
}
|
||||
} // function solve()
|
||||
}
|
||||
|
||||
} // PHPExcel_Shared_JAMA_class QRDecomposition
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* @license PHP v3.0
|
||||
* @version 1.1
|
||||
*/
|
||||
class SingularValueDecomposition {
|
||||
|
||||
class SingularValueDecomposition
|
||||
{
|
||||
/**
|
||||
* Internal storage of U.
|
||||
* @var array
|
||||
|
@ -49,7 +49,6 @@ class SingularValueDecomposition {
|
|||
*/
|
||||
private $n;
|
||||
|
||||
|
||||
/**
|
||||
* Construct the singular value decomposition
|
||||
*
|
||||
|
@ -58,8 +57,8 @@ class SingularValueDecomposition {
|
|||
* @param $A Rectangular matrix
|
||||
* @return Structure to access U, S and V.
|
||||
*/
|
||||
public function __construct($Arg) {
|
||||
|
||||
public function __construct($Arg)
|
||||
{
|
||||
// Initialize.
|
||||
$A = $Arg->getArrayCopy();
|
||||
$this->m = $Arg->getRowDimension();
|
||||
|
@ -75,7 +74,6 @@ class SingularValueDecomposition {
|
|||
// Reduce A to bidiagonal form, storing the diagonal elements
|
||||
// in s and the super-diagonal elements in e.
|
||||
for ($k = 0; $k < max($nct, $nrt); ++$k) {
|
||||
|
||||
if ($k < $nct) {
|
||||
// Compute the transformation for the k-th column and
|
||||
// place the k-th diagonal in s[$k].
|
||||
|
@ -113,7 +111,7 @@ class SingularValueDecomposition {
|
|||
}
|
||||
}
|
||||
|
||||
if ($wantu AND ($k < $nct)) {
|
||||
if ($wantu and ($k < $nct)) {
|
||||
// Place the transformation in U for subsequent back
|
||||
// multiplication.
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
|
@ -139,7 +137,7 @@ class SingularValueDecomposition {
|
|||
$e[$k+1] += 1.0;
|
||||
}
|
||||
$e[$k] = -$e[$k];
|
||||
if (($k+1 < $this->m) AND ($e[$k] != 0.0)) {
|
||||
if (($k+1 < $this->m) and ($e[$k] != 0.0)) {
|
||||
// Apply the transformation.
|
||||
for ($i = $k+1; $i < $this->m; ++$i) {
|
||||
$work[$i] = 0.0;
|
||||
|
@ -198,7 +196,7 @@ class SingularValueDecomposition {
|
|||
$this->U[$i][$j] += $t * $this->U[$i][$k];
|
||||
}
|
||||
}
|
||||
for ($i = $k; $i < $this->m; ++$i ) {
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$this->U[$i][$k] = -$this->U[$i][$k];
|
||||
}
|
||||
$this->U[$k][$k] = 1.0 + $this->U[$k][$k];
|
||||
|
@ -217,7 +215,7 @@ class SingularValueDecomposition {
|
|||
// If required, generate V.
|
||||
if ($wantv) {
|
||||
for ($k = $this->n - 1; $k >= 0; --$k) {
|
||||
if (($k < $nrt) AND ($e[$k] != 0.0)) {
|
||||
if (($k < $nrt) and ($e[$k] != 0.0)) {
|
||||
for ($j = $k + 1; $j < $nu; ++$j) {
|
||||
$t = 0;
|
||||
for ($i = $k + 1; $i < $this->n; ++$i) {
|
||||
|
@ -331,9 +329,7 @@ class SingularValueDecomposition {
|
|||
// Perform one qr step.
|
||||
case 3:
|
||||
// Calculate the shift.
|
||||
$scale = max(max(max(max(
|
||||
abs($this->s[$p-1]),abs($this->s[$p-2])),abs($e[$p-2])),
|
||||
abs($this->s[$k])), abs($e[$k]));
|
||||
$scale = max(max(max(max(abs($this->s[$p-1]), abs($this->s[$p-2])), abs($e[$p-2])), abs($this->s[$k])), abs($e[$k]));
|
||||
$sp = $this->s[$p-1] / $scale;
|
||||
$spm1 = $this->s[$p-2] / $scale;
|
||||
$epm1 = $e[$p-2] / $scale;
|
||||
|
@ -408,14 +404,14 @@ class SingularValueDecomposition {
|
|||
$t = $this->s[$k];
|
||||
$this->s[$k] = $this->s[$k+1];
|
||||
$this->s[$k+1] = $t;
|
||||
if ($wantv AND ($k < $this->n - 1)) {
|
||||
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)) {
|
||||
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];
|
||||
|
@ -439,7 +435,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return U
|
||||
*/
|
||||
public function getU() {
|
||||
public function getU()
|
||||
{
|
||||
return new Matrix($this->U, $this->m, min($this->m + 1, $this->n));
|
||||
}
|
||||
|
||||
|
@ -450,7 +447,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return V
|
||||
*/
|
||||
public function getV() {
|
||||
public function getV()
|
||||
{
|
||||
return new Matrix($this->V);
|
||||
}
|
||||
|
||||
|
@ -461,7 +459,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return diagonal of S.
|
||||
*/
|
||||
public function getSingularValues() {
|
||||
public function getSingularValues()
|
||||
{
|
||||
return $this->s;
|
||||
}
|
||||
|
||||
|
@ -472,7 +471,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return S
|
||||
*/
|
||||
public function getS() {
|
||||
public function getS()
|
||||
{
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
$S[$i][$j] = 0.0;
|
||||
|
@ -489,7 +489,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return max(S)
|
||||
*/
|
||||
public function norm2() {
|
||||
public function norm2()
|
||||
{
|
||||
return $this->s[0];
|
||||
}
|
||||
|
||||
|
@ -500,7 +501,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return max(S)/min(S)
|
||||
*/
|
||||
public function cond() {
|
||||
public function cond()
|
||||
{
|
||||
return $this->s[0] / $this->s[min($this->m, $this->n) - 1];
|
||||
}
|
||||
|
||||
|
@ -511,7 +513,8 @@ class SingularValueDecomposition {
|
|||
* @access public
|
||||
* @return Number of nonnegligible singular values.
|
||||
*/
|
||||
public function rank() {
|
||||
public function rank()
|
||||
{
|
||||
$eps = pow(2.0, -52.0);
|
||||
$tol = max($this->m, $this->n) * $this->s[0] * $eps;
|
||||
$r = 0;
|
||||
|
@ -522,5 +525,4 @@ class SingularValueDecomposition {
|
|||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
} // class SingularValueDecomposition
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ $error['EN'][RowLengthException] = "All rows must have the same length.";
|
|||
* Custom error handler
|
||||
* @param int $num Error number
|
||||
*/
|
||||
function JAMAError($errorNumber = null) {
|
||||
function JAMAError($errorNumber = null)
|
||||
{
|
||||
global $error;
|
||||
|
||||
if (isset($errorNumber)) {
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
*
|
||||
* r = sqrt(a^2 + b^2) without under/overflow.
|
||||
*/
|
||||
function hypo($a, $b) {
|
||||
function hypo($a, $b)
|
||||
{
|
||||
if (abs($a) > abs($b)) {
|
||||
$r = $b / $a;
|
||||
$r = abs($a) * sqrt(1 + $r * $r);
|
||||
|
|
|
@ -73,8 +73,9 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
if (is_resource($filename)) {
|
||||
$this->_FILEH_ = $filename;
|
||||
} else if ($filename == '-' || $filename == '') {
|
||||
if ($this->_tmp_dir === null)
|
||||
if ($this->_tmp_dir === null) {
|
||||
$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
}
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
||||
if ($this->_FILEH_ == false) {
|
||||
|
@ -199,7 +200,8 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
}
|
||||
|
||||
// Save Header
|
||||
fwrite($FILE,
|
||||
fwrite(
|
||||
$FILE,
|
||||
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
|
@ -222,9 +224,10 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL) {
|
||||
fwrite($FILE,
|
||||
fwrite(
|
||||
$FILE,
|
||||
pack("V", -2) // Extra BDList Start
|
||||
. pack("V", 0) // Extra BDList Count
|
||||
. pack("V", 0)// Extra BDList Count
|
||||
);
|
||||
} else {
|
||||
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
|
||||
|
@ -258,9 +261,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
for ($i = 0; $i < $iCount; ++$i) {
|
||||
if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) {
|
||||
$raList[$i]->Size = $raList[$i]->_DataLen();
|
||||
if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) ||
|
||||
(($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
|
||||
{
|
||||
if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) || (($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data))) {
|
||||
// Write Data
|
||||
//if (isset($raList[$i]->_PPS_FILE)) {
|
||||
// $iLen = 0;
|
||||
|
@ -366,7 +367,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
$iCnt = count($raList);
|
||||
$iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE;
|
||||
if ($iCnt % $iBCnt) {
|
||||
fwrite($this->_FILEH_, str_repeat("\x00",($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE));
|
||||
fwrite($this->_FILEH_, str_repeat("\x00", ($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
defined('IDENTIFIER_OLE') ||
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
|
||||
class PHPExcel_Shared_OLERead {
|
||||
class PHPExcel_Shared_OLERead
|
||||
{
|
||||
private $data = '';
|
||||
|
||||
// OLE identifier
|
||||
|
|
|
@ -3136,7 +3136,7 @@ class PclZip
|
|||
$v_extract = true;
|
||||
}
|
||||
}
|
||||
}else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
||||
} else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
|
||||
// ----- Look for extract by preg rule
|
||||
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
|
||||
$v_extract = true;
|
||||
|
@ -3167,7 +3167,6 @@ class PclZip
|
|||
|
||||
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
|
||||
if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
|
||||
|
||||
$this->privSwapBackMagicQuotes();
|
||||
|
||||
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is compressed by an unsupported compression method (".$v_header['compression'].") ");
|
||||
|
@ -3249,9 +3248,8 @@ class PclZip
|
|||
if ($v_result1 == 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_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
|
||||
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
|
||||
if ($v_result1 < 1) {
|
||||
|
@ -3369,7 +3367,7 @@ class PclZip
|
|||
if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
|
||||
$v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']);
|
||||
if ($v_inclusion == 0) {
|
||||
PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,"Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
|
||||
PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '".$p_entry['filename']."' is outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
|
||||
|
||||
return PclZip::errorCode();
|
||||
}
|
||||
|
@ -3410,7 +3408,6 @@ class PclZip
|
|||
if (file_exists($p_entry['filename'])) {
|
||||
// ----- Look if file is a directory
|
||||
if (is_dir($p_entry['filename'])) {
|
||||
|
||||
// ----- Change the file status
|
||||
$p_entry['status'] = "already_a_directory";
|
||||
|
||||
|
@ -3454,11 +3451,9 @@ class PclZip
|
|||
// ----- Check the directory availability and create it if necessary
|
||||
if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
|
||||
$v_dir_to_check = $p_entry['filename'];
|
||||
}
|
||||
else if (!strstr($p_entry['filename'], "/")) {
|
||||
} else if (!strstr($p_entry['filename'], "/")) {
|
||||
$v_dir_to_check = "";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$v_dir_to_check = dirname($p_entry['filename']);
|
||||
}
|
||||
|
||||
|
@ -3530,7 +3525,6 @@ class PclZip
|
|||
$v_file_content = @gzinflate($v_buffer);
|
||||
unset($v_buffer);
|
||||
if ($v_file_content === false) {
|
||||
|
||||
// ----- Change the file status
|
||||
// TBC
|
||||
$p_entry['status'] = "error";
|
||||
|
@ -3540,7 +3534,6 @@ class PclZip
|
|||
|
||||
// ----- Opening destination file
|
||||
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
|
||||
|
||||
// ----- Change the file status
|
||||
$p_entry['status'] = "write_error";
|
||||
|
||||
|
@ -3723,7 +3716,6 @@ class PclZip
|
|||
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
|
||||
// ----- Look for not compressed file
|
||||
if ($p_entry['compressed_size'] == $p_entry['size']) {
|
||||
|
||||
// ----- Read the file in a buffer (one shot)
|
||||
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
|
||||
|
||||
|
@ -3731,7 +3723,6 @@ class PclZip
|
|||
echo $v_buffer;
|
||||
unset($v_buffer);
|
||||
} else {
|
||||
|
||||
// ----- Read the compressed file in a buffer (one shot)
|
||||
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
|
||||
|
||||
|
@ -3830,11 +3821,9 @@ class PclZip
|
|||
// ----- Look for not compressed file
|
||||
// if ($p_entry['compressed_size'] == $p_entry['size'])
|
||||
if ($p_entry['compression'] == 0) {
|
||||
|
||||
// ----- Reading the file
|
||||
$p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
|
||||
} else {
|
||||
|
||||
// ----- Reading the file
|
||||
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
|
||||
|
||||
|
@ -4037,8 +4026,7 @@ class PclZip
|
|||
// ----- Get comment
|
||||
if ($p_header['comment_len'] != 0) {
|
||||
$p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$p_header['comment'] = '';
|
||||
}
|
||||
|
||||
|
@ -4171,8 +4159,9 @@ class PclZip
|
|||
// ----- Go back to the maximum possible size of the Central Dir End Record
|
||||
if (!$v_found) {
|
||||
$v_maximum_size = 65557; // 0xFFFF + 22;
|
||||
if ($v_maximum_size > $v_size)
|
||||
if ($v_maximum_size > $v_size) {
|
||||
$v_maximum_size = $v_size;
|
||||
}
|
||||
@fseek($this->zip_fd, $v_size-$v_maximum_size);
|
||||
if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) {
|
||||
// ----- Error log
|
||||
|
@ -4196,8 +4185,7 @@ class PclZip
|
|||
$v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
|
||||
|
||||
// ----- Compare the bytes
|
||||
if ($v_bytes == 0x504b0506)
|
||||
{
|
||||
if ($v_bytes == 0x504b0506) {
|
||||
$v_pos++;
|
||||
break;
|
||||
}
|
||||
|
@ -4342,27 +4330,13 @@ class PclZip
|
|||
} elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
|
||||
$v_found = true;
|
||||
}
|
||||
}
|
||||
} elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
||||
// ----- Look for a filename
|
||||
elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
|
||||
$v_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----- Look for extract by ereg rule
|
||||
// ereg() is deprecated with PHP 5.3
|
||||
/*
|
||||
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
|
||||
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
|
||||
|
||||
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
|
||||
$v_found = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
|
||||
} else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($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'])) {
|
||||
$v_found = true;
|
||||
}
|
||||
|
@ -4376,7 +4350,6 @@ class PclZip
|
|||
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
|
||||
$j_start = $j+1;
|
||||
}
|
||||
|
||||
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
|
||||
break;
|
||||
}
|
||||
|
@ -4608,7 +4581,6 @@ class PclZip
|
|||
|
||||
// ----- Look if the archive_to_add exists
|
||||
if (!is_file($p_archive_to_add->zipname)) {
|
||||
|
||||
// ----- Nothing to merge, so merge is a success
|
||||
$v_result = 1;
|
||||
|
||||
|
@ -4618,7 +4590,6 @@ class PclZip
|
|||
|
||||
// ----- Look if the archive exists
|
||||
if (!is_file($this->zipname)) {
|
||||
|
||||
// ----- Do a duplicate
|
||||
$v_result = $this->privDuplicate($p_archive_to_add->zipname);
|
||||
|
||||
|
@ -4781,7 +4752,6 @@ class PclZip
|
|||
|
||||
// ----- Look if the $p_archive_filename exists
|
||||
if (!is_file($p_archive_filename)) {
|
||||
|
||||
// ----- Nothing to duplicate, so duplicate is a success.
|
||||
$v_result = 1;
|
||||
|
||||
|
@ -4970,8 +4940,7 @@ function PclZipUtilPathReduction($p_dir)
|
|||
// ----- Look for item to skip
|
||||
if ($v_skip > 0) {
|
||||
$v_skip--;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
|
||||
}
|
||||
}
|
||||
|
@ -5051,8 +5020,12 @@ function PclZipUtilPathInclusion($p_dir, $p_path)
|
|||
// ----- Look if everything seems to be the same
|
||||
if ($v_result) {
|
||||
// ----- Skip all the empty items
|
||||
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
|
||||
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
|
||||
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
|
||||
$j++;
|
||||
}
|
||||
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
|
||||
// ----- There are exactly the same
|
||||
|
@ -5160,7 +5133,6 @@ function PclZipUtilRename($p_src, $p_dest)
|
|||
// --------------------------------------------------------------------------------
|
||||
function PclZipUtilOptionText($p_option)
|
||||
{
|
||||
|
||||
$v_list = get_defined_constants();
|
||||
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
|
||||
$v_prefix = substr($v_key, 0, 10);
|
||||
|
@ -5194,10 +5166,9 @@ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
|
|||
$p_path = substr($p_path, $v_position+1);
|
||||
}
|
||||
// ----- 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, '\\', '/');
|
||||
}
|
||||
}
|
||||
return $p_path;
|
||||
}
|
||||
// --------------------------------------------------------------------------------
|
Loading…
Reference in New Issue