PSR2 Fixes

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

View File

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

View File

@ -992,11 +992,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
$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

View File

@ -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
}
}
}
}

View File

@ -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')) {

View File

@ -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
@ -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);
}
@ -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);

View File

@ -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);

View File

@ -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,9 +145,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);
$worksheetInfo = array();
@ -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']);
@ -374,7 +364,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
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']) {
@ -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,12 +434,7 @@ 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 />';
}
@ -457,7 +446,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
break;
case '20': // Boolean
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? True : False;
$cell = ($cell == 'TRUE') ? true: false;
break;
case '30': // Integer
$cell = intval($cell);
@ -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));
}
}
}
@ -553,8 +540,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
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"]);
@ -634,9 +621,9 @@ 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':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
@ -656,10 +643,10 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
switch ($fontAttributes['Script']) {
case '1':
$styleArray['font']['superScript'] = True;
$styleArray['font']['superScript'] = true;
break;
case '-1':
$styleArray['font']['subScript'] = True;
$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);
}
}
@ -788,12 +775,10 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
}
// Return
return $objPHPExcel;
}
private static function _parseBorderAttributes($borderAttributes)
{
$styleArray = array();
@ -850,8 +835,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $styleArray;
}
private function _parseRichText($is = '') {
private function _parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value->createText($is);
@ -859,7 +844,6 @@ 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);
@ -869,5 +853,4 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo 'Excel Colour: ', $RGB,'<br />';
return $RGB;
}
}

View File

@ -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;
}
@ -144,11 +142,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
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)
*
@ -196,11 +194,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
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
*
@ -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;
}
@ -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;
@ -611,12 +608,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
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) {
@ -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;
}
}

View File

@ -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();
}
@ -244,7 +245,6 @@ 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);

View File

@ -15,8 +15,8 @@
* @author Michael Bommarito
* @version 1.2
*/
class CholeskyDecomposition {
class CholeskyDecomposition
{
/**
* Decomposition storage
* @var array
@ -38,14 +38,14 @@ 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();
@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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()

View File

@ -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

View File

@ -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;
@ -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
}

View File

@ -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)) {

View File

@ -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);

View File

@ -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,7 +224,8 @@ 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
);
@ -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;

View File

@ -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

View File

@ -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) {
@ -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);
@ -5200,4 +5172,3 @@ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
}
return $p_path;
}
// --------------------------------------------------------------------------------