PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-13 13:15:55 +02:00
parent 2881bca443
commit 7d086fdbee
13 changed files with 1214 additions and 1237 deletions

View File

@ -199,7 +199,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE) public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -308,7 +308,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE) public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;

View File

@ -42,7 +42,8 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null) { public function writeRibbonRelationships(PHPExcel $pPHPExcel = null)
{
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -57,9 +58,9 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$localRels=$pPHPExcel->getRibbonBinObjects('names'); $localRels = $pPHPExcel->getRibbonBinObjects('names');
if (is_array($localRels)) { if (is_array($localRels)) {
foreach ($localRels as $aId=>$aTarget) { foreach ($localRels as $aId => $aTarget) {
$objWriter->startElement('Relationship'); $objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', $aId); $objWriter->writeAttribute('Id', $aId);
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'); $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
@ -71,7 +72,5 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
// Return // Return
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -42,7 +42,8 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeVBARelationships(PHPExcel $pPHPExcel = null) { public function writeVBARelationships(PHPExcel $pPHPExcel = null)
{
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -68,5 +69,4 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -45,14 +45,14 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/ */
public function createStringTable($pSheet = null, $pExistingTable = null) public function createStringTable($pSheet = null, $pExistingTable = null)
{ {
if ($pSheet !== NULL) { if ($pSheet !== null) {
// Create string lookup table // Create string lookup table
$aStringTable = array(); $aStringTable = array();
$cellCollection = null; $cellCollection = null;
$aFlippedStringTable = null; // For faster lookup $aFlippedStringTable = null; // For faster lookup
// Is an existing table given? // Is an existing table given?
if (($pExistingTable !== NULL) && is_array($pExistingTable)) { if (($pExistingTable !== null) && is_array($pExistingTable)) {
$aStringTable = $pExistingTable; $aStringTable = $pExistingTable;
} }
@ -64,14 +64,14 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$cell = $pSheet->getCell($cellID); $cell = $pSheet->getCell($cellID);
$cellValue = $cell->getValue(); $cellValue = $cell->getValue();
if (!is_object($cellValue) && if (!is_object($cellValue) &&
($cellValue !== NULL) && ($cellValue !== null) &&
$cellValue !== '' && $cellValue !== '' &&
!isset($aFlippedStringTable[$cellValue]) && !isset($aFlippedStringTable[$cellValue]) &&
($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) { ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue] = true; $aFlippedStringTable[$cellValue] = true;
} elseif ($cellValue instanceof PHPExcel_RichText && } elseif ($cellValue instanceof PHPExcel_RichText &&
($cellValue !== NULL) && ($cellValue !== null) &&
!isset($aFlippedStringTable[$cellValue->getHashCode()])) { !isset($aFlippedStringTable[$cellValue->getHashCode()])) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue->getHashCode()] = true; $aFlippedStringTable[$cellValue->getHashCode()] = true;
@ -94,7 +94,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/ */
public function writeStringTable($pStringTable = null) public function writeStringTable($pStringTable = null)
{ {
if ($pStringTable !== NULL) { if ($pStringTable !== null) {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -116,7 +116,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$objWriter->startElement('si'); $objWriter->startElement('si');
if (! $textElement instanceof PHPExcel_RichText) { if (! $textElement instanceof PHPExcel_RichText) {
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement ); $textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML($textElement);
$objWriter->startElement('t'); $objWriter->startElement('t');
if ($textToWrite !== trim($textToWrite)) { if ($textToWrite !== trim($textToWrite)) {
$objWriter->writeAttribute('xml:space', 'preserve'); $objWriter->writeAttribute('xml:space', 'preserve');
@ -147,10 +147,12 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* @param string $prefix Optional Namespace prefix * @param string $prefix Optional Namespace prefix
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL) public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix = null)
{ {
if ($prefix !== NULL) if ($prefix !== null) {
$prefix .= ':'; $prefix .= ':';
}
// Loop through rich text elements // Loop through rich text elements
$elements = $pRichText->getRichTextElements(); $elements = $pRichText->getRichTextElements();
foreach ($elements as $element) { foreach ($elements as $element) {
@ -214,7 +216,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// t // t
$objWriter->startElement($prefix.'t'); $objWriter->startElement($prefix.'t');
$objWriter->writeAttribute('xml:space', 'preserve'); $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() )); $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
@ -229,7 +231,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* @param string $prefix Optional Namespace prefix * @param string $prefix Optional Namespace prefix
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL) public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix = null)
{ {
if (!$pRichText instanceof PHPExcel_RichText) { if (!$pRichText instanceof PHPExcel_RichText) {
$textRun = $pRichText; $textRun = $pRichText;
@ -237,8 +239,10 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$pRichText->createTextRun($textRun); $pRichText->createTextRun($textRun);
} }
if ($prefix !== NULL) if ($prefix !== null) {
$prefix .= ':'; $prefix .= ':';
}
// Loop through rich text elements // Loop through rich text elements
$elements = $pRichText->getRichTextElements(); $elements = $pRichText->getRichTextElements();
foreach ($elements as $element) { foreach ($elements as $element) {
@ -287,7 +291,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// t // t
$objWriter->startElement($prefix.'t'); $objWriter->startElement($prefix.'t');
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains // $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() )); $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();

View File

@ -402,7 +402,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
} }
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) { if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) ); $objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164));
} else { } else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode()); $objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
} }

View File

@ -362,7 +362,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$range = PHPExcel_Cell::splitRange($autoFilterRange); $range = PHPExcel_Cell::splitRange($autoFilterRange);
$range = $range[0]; $range = $range[0];
// Strip any worksheet ref so we can make the cell ref absolute // Strip any worksheet ref so we can make the cell ref absolute
if (strpos($range[0],'!') !== false) { if (strpos($range[0], '!') !== false) {
list($ws, $range[0]) = explode('!', $range[0]); list($ws, $range[0]) = explode('!', $range[0]);
} }

View File

@ -44,7 +44,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = FALSE) public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false)
{ {
if (!is_null($pSheet)) { if (!is_null($pSheet)) {
// Create XML writer // Create XML writer
@ -205,16 +205,16 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @param PHPExcel_Worksheet $pSheet Worksheet * @param PHPExcel_Worksheet $pSheet Worksheet
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = NULL, PHPExcel_Worksheet $pSheet = NULL) private function _writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{ {
// sheetViews // sheetViews
$objWriter->startElement('sheetViews'); $objWriter->startElement('sheetViews');
// Sheet selected? // Sheet selected?
$sheetSelected = false; $sheetSelected = false;
if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) {
$sheetSelected = true; $sheetSelected = true;
}
// sheetView // sheetView
$objWriter->startElement('sheetView'); $objWriter->startElement('sheetView');
@ -282,8 +282,12 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
if (($xSplit > 1) && ($ySplit > 1)) { if (($xSplit > 1) && ($ySplit > 1)) {
// Write additional selections if more than two panes (ie both an X and a Y split) // Write additional selections if more than two panes (ie both an X and a Y split)
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'topRight'); $objWriter->endElement(); $objWriter->startElement('selection');
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'bottomLeft'); $objWriter->endElement(); $objWriter->writeAttribute('pane', 'topRight');
$objWriter->endElement();
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'bottomLeft');
$objWriter->endElement();
} }
} }
@ -327,7 +331,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Set Zero Height row // Set Zero Height row
if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' || if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' ||
strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true' ) { strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') {
$objWriter->writeAttribute('zeroHeight', '1'); $objWriter->writeAttribute('zeroHeight', '1');
} }
@ -473,7 +477,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) { foreach ($conditionalStyles as $conditional) {
// WHY was this again? // WHY was this again?
// if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() ) == '') { // if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()) == '') {
// continue; // continue;
// } // }
if ($conditional->getConditionType() != PHPExcel_Style_Conditional::CONDITION_NONE) { if ($conditional->getConditionType() != PHPExcel_Style_Conditional::CONDITION_NONE) {
@ -484,7 +488,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// cfRule // cfRule
$objWriter->startElement('cfRule'); $objWriter->startElement('cfRule');
$objWriter->writeAttribute('type', $conditional->getConditionType()); $objWriter->writeAttribute('type', $conditional->getConditionType());
$objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() )); $objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()));
$objWriter->writeAttribute('priority', $id++); $objWriter->writeAttribute('priority', $id++);
if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
@ -772,7 +776,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->startElement('filterColumn'); $objWriter->startElement('filterColumn');
$objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID)); $objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID));
$objWriter->startElement( $column->getFilterType()); $objWriter->startElement($column->getFilterType());
if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) { if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) {
$objWriter->writeAttribute('and', 1); $objWriter->writeAttribute('and', 1);
} }
@ -787,11 +791,11 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Dynamic Filter Rule // Dynamic Filter Rule
$objWriter->writeAttribute('type', $rule->getGrouping()); $objWriter->writeAttribute('type', $rule->getGrouping());
$val = $column->getAttribute('val'); $val = $column->getAttribute('val');
if ($val !== NULL) { if ($val !== null) {
$objWriter->writeAttribute('val', $val); $objWriter->writeAttribute('val', $val);
} }
$maxVal = $column->getAttribute('maxVal'); $maxVal = $column->getAttribute('maxVal');
if ($maxVal !== NULL) { if ($maxVal !== null) {
$objWriter->writeAttribute('maxVal', $maxVal); $objWriter->writeAttribute('maxVal', $maxVal);
} }
} elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) { } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) {
@ -984,12 +988,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$rowDimension = $pSheet->getRowDimension($currentRow); $rowDimension = $pSheet->getRowDimension($currentRow);
// Write current row? // Write current row?
$writeCurrentRow = isset($cellsByRow[$currentRow]) || $writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() == false || $rowDimension->getCollapsed() == true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null;
$rowDimension->getRowHeight() >= 0 ||
$rowDimension->getVisible() == false ||
$rowDimension->getCollapsed() == true ||
$rowDimension->getOutlineLevel() > 0 ||
$rowDimension->getXfIndex() !== null;
if ($writeCurrentRow) { if ($writeCurrentRow) {
// Start a new row // Start a new row
@ -1095,7 +1094,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
switch (strtolower($mappedType)) { switch (strtolower($mappedType)) {
case 'inlinestr': // Inline string case 'inlinestr': // Inline string
if (! $cellValue instanceof PHPExcel_RichText) { if (! $cellValue instanceof PHPExcel_RichText) {
$objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($cellValue) ) ); $objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML(htmlspecialchars($cellValue)));
} else if ($cellValue instanceof PHPExcel_RichText) { } else if ($cellValue instanceof PHPExcel_RichText) {
$objWriter->startElement('is'); $objWriter->startElement('is');
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue);
@ -1172,7 +1171,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts * @param boolean $includeCharts Flag indicating if we should include drawing details for charts
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = FALSE) private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = false)
{ {
$chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0; $chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0;
// If sheet contains drawings, add the relationships // If sheet contains drawings, add the relationships

View File

@ -467,7 +467,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
case 1: // GIF, not supported by BIFF8, we convert to PNG case 1: // GIF, not supported by BIFF8, we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start(); ob_start();
imagepng(imagecreatefromgif ($filename)); imagepng(imagecreatefromgif($filename));
$blipData = ob_get_contents(); $blipData = ob_get_contents();
ob_end_clean(); ob_end_clean();
break; break;

View File

@ -105,7 +105,8 @@ class PHPExcel_Writer_Excel5_Escher
// dgg data // dgg data
$dggData = $dggData =
pack('VVVV', pack(
'VVVV',
$this->_object->getSpIdMax(), // maximum shape identifier increased by one $this->_object->getSpIdMax(), // maximum shape identifier increased by one
$this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one $this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one
$this->_object->getCSpSaved(), $this->_object->getCSpSaved(),
@ -187,7 +188,7 @@ class PHPExcel_Writer_Excel5_Escher
$btMacOS = $this->_object->getBlipType(); $btMacOS = $this->_object->getBlipType();
$data .= pack('CC', $btWin32, $btMacOS); $data .= pack('CC', $btWin32, $btMacOS);
$rgbUid = pack('VVVV', 0,0,0,0); // todo $rgbUid = pack('VVVV', 0, 0, 0, 0); // todo
$data .= $rgbUid; $data .= $rgbUid;
$tag = 0; $tag = 0;
@ -226,7 +227,7 @@ class PHPExcel_Writer_Excel5_Escher
// initialize // initialize
$innerData = ''; $innerData = '';
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo $rgbUid1 = pack('VVVV', 0, 0, 0, 0); // todo
$innerData .= $rgbUid1; $innerData .= $rgbUid1;
$tag = 0xFF; // todo $tag = 0xFF; // todo
@ -253,7 +254,7 @@ class PHPExcel_Writer_Excel5_Escher
// initialize // initialize
$innerData = ''; $innerData = '';
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo $rgbUid1 = pack('VVVV', 0, 0, 0, 0); // todo
$innerData .= $rgbUid1; $innerData .= $rgbUid1;
$tag = 0xFF; // todo $tag = 0xFF; // todo
@ -387,7 +388,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$data .= $header . pack('VVVV', 0,0,0,0); $data .= $header . pack('VVVV', 0, 0, 0, 0);
} }
$this->_spTypes[] = ($this->_object->getSpType()); $this->_spTypes[] = ($this->_object->getSpType());

View File

@ -1130,60 +1130,39 @@ class PHPExcel_Writer_Excel5_Parser
break; break;
default: default:
// if it's a reference A1 or $A$1 or $A1 or A$1 // if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) {
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!')) {
return $token; return $token;
} } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token; return $token;
} }
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token; return $token;
} } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->_lookahead)) {
// if it's a range A1:A2 or $A$1:$A$2 // if it's a range A1:A2 or $A$1:$A$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) {
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) {
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (is_numeric($token) and (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and ($this->_lookahead != '!') and ($this->_lookahead != ':')) {
// If it's a number (check that it's not a sheet name or range) // If it's a number (check that it's not a sheet name or range)
elseif (is_numeric($token) and
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
($this->_lookahead != '!') and ($this->_lookahead != ':')) {
return $token; return $token;
} } elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) {
// If it's a string (of maximum 255 characters) // If it's a string (of maximum 255 characters)
elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) {
return $token; return $token;
} } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
// If it's an error code // If it's an error code
elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
return $token; return $token;
} } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) {
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) {
return $token; return $token;
} } elseif (substr($token, -1) == ')') {
// It's an argument of some description (e.g. a named range), // It's an argument of some description (e.g. a named range),
// precise nature yet to be determined // precise nature yet to be determined
elseif (substr($token,-1) == ')') {
return $token; return $token;
} }
return ''; return '';
@ -1266,7 +1245,10 @@ class PHPExcel_Writer_Excel5_Parser
// If it's a string return a string node // If it's a string return a string node
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) { if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) {
$tmp = str_replace('""', '"', $this->_current_token); $tmp = str_replace('""', '"', $this->_current_token);
if (($tmp == '"') || ($tmp == '')) $tmp = '""'; // Trap for "" that has been used for an empty string if (($tmp == '"') || ($tmp == '')) {
// Trap for "" that has been used for an empty string
$tmp = '""';
}
$result = $this->_createTree($tmp, '', ''); $result = $this->_createTree($tmp, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
@ -1375,38 +1357,33 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// if it's a reference // if it's a reference
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->_current_token)) if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// if it's a range A1:B2 or $A$1:$B$2 // if it's a range A1:B2 or $A$1:$B$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) {
{
// must be an error? // must be an error?
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2) // If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
{
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
@ -1414,8 +1391,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2) // If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
{
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
@ -1423,8 +1399,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// If it's a number or a percent // If it's a number or a percent
elseif (is_numeric($this->_current_token)) elseif (is_numeric($this->_current_token)) {
{
if ($this->_lookahead == '%') { if ($this->_lookahead == '%') {
$result = $this->_createTree('ptgPercent', $this->_current_token, ''); $result = $this->_createTree('ptgPercent', $this->_current_token, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree $this->_advance(); // Skip the percentage operator once we've pre-built that tree
@ -1435,8 +1410,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) {
{
$result = $this->_func(); $result = $this->_func();
return $result; return $result;
} }
@ -1462,13 +1436,10 @@ class PHPExcel_Writer_Excel5_Parser
while ($this->_current_token != ')') { while ($this->_current_token != ')') {
/**/ /**/
if ($num_args > 0) { if ($num_args > 0) {
if ($this->_current_token == "," or if ($this->_current_token == "," || $this->_current_token == ";") {
$this->_current_token == ";")
{
$this->_advance(); // eat the "," or ";" $this->_advance(); // eat the "," or ";"
} else { } else {
throw new PHPExcel_Writer_Exception("Syntax error: comma expected in ". throw new PHPExcel_Writer_Exception("Syntax error: comma expected in function $function, arg #{$num_args}");
"function $function, arg #{$num_args}");
} }
$result2 = $this->_condition(); $result2 = $this->_condition();
$result = $this->_createTree('arg', $result, $result2); $result = $this->_createTree('arg', $result, $result2);
@ -1560,8 +1531,7 @@ class PHPExcel_Writer_Excel5_Parser
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and
!is_numeric($tree['value']) and !is_numeric($tree['value']) and
!isset($this->ptg[$tree['value']])) !isset($this->ptg[$tree['value']])) {
{
// left subtree for a function is always an array. // left subtree for a function is always an array.
if ($tree['left'] != '') { if ($tree['left'] != '') {
$left_tree = $this->toReversePolish($tree['left']); $left_tree = $this->toReversePolish($tree['left']);

View File

@ -845,7 +845,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// option flags // option flags
$options = ($isHidden ? 0x21 : 0x00); $options = ($isHidden ? 0x21 : 0x00);
$extra = pack('Cvvvvv', $extra = pack(
'Cvvvvv',
0x3B, 0x3B,
$sheetIndex - 1, $sheetIndex - 1,
$rangeBounds[0][1] - 1, $rangeBounds[0][1] - 1,

View File

@ -2736,7 +2736,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($spTypes[$i] == 0x00C9) { if ($spTypes[$i] == 0x00C9) {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV', pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data 0x0012, // length of ftCmo data
0x0014, // object type, 0x0014 = filter 0x0014, // object type, 0x0014 = filter
@ -2756,7 +2757,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} else { } else {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV', pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data 0x0012, // length of ftCmo data
0x0008, // object type, 0x0008 = picture 0x0008, // object type, 0x0008 = picture
@ -2770,7 +2772,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// ftEnd // ftEnd
$objData .= $objData .=
pack('vv', pack(
'vv',
0x0000, // 0x0000 = ftEnd 0x0000, // 0x0000 = ftEnd
0x0000 // length of ftEnd data 0x0000 // length of ftEnd data
); );