Fix tests on PHP 5.6
This commit is contained in:
parent
275c35c877
commit
d7751afbec
|
@ -137,9 +137,9 @@ class Xlsx extends BaseWriter
|
|||
}
|
||||
|
||||
$hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable',
|
||||
'bordersHashTable', 'numFmtHashTable', 'drawingHashTable',
|
||||
'styleHashTable',
|
||||
];
|
||||
'bordersHashTable', 'numFmtHashTable', 'drawingHashTable',
|
||||
'styleHashTable',
|
||||
];
|
||||
|
||||
// Set HashTable variables
|
||||
foreach ($hashTablesArray as $tableName) {
|
||||
|
@ -298,13 +298,14 @@ class Xlsx extends BaseWriter
|
|||
|
||||
// Add unparsedLoadedData
|
||||
$sheetCodeName = $this->spreadSheet->getSheet($i)->getCodeName();
|
||||
if (isset($this->spreadSheet->getUnparsedLoadedData()['sheets'][$sheetCodeName]['ctrlProps'])) {
|
||||
foreach ($this->spreadSheet->getUnparsedLoadedData()['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) {
|
||||
$unparsedLoadedData = $this->spreadSheet->getUnparsedLoadedData();
|
||||
if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'])) {
|
||||
foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) {
|
||||
$zip->addFromString($ctrlProp['filePath'], $ctrlProp['content']);
|
||||
}
|
||||
}
|
||||
if (isset($this->spreadSheet->getUnparsedLoadedData()['sheets'][$sheetCodeName]['printerSettings'])) {
|
||||
foreach ($this->spreadSheet->getUnparsedLoadedData()['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) {
|
||||
if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'])) {
|
||||
foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) {
|
||||
$zip->addFromString($ctrlProp['filePath'], $ctrlProp['content']);
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ class Xlsx extends BaseWriter
|
|||
|
||||
// Drawings
|
||||
$zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts));
|
||||
} elseif (isset($this->spreadSheet->getUnparsedLoadedData()['sheets'][$sheetCodeName]['drawingAlternateContents'])) {
|
||||
} elseif (isset($unparsedLoadedData['sheets'][$sheetCodeName]['drawingAlternateContents'])) {
|
||||
// Drawings
|
||||
$zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts));
|
||||
}
|
||||
|
@ -337,8 +338,8 @@ class Xlsx extends BaseWriter
|
|||
}
|
||||
|
||||
// Add unparsed relationship parts
|
||||
if (isset($this->spreadSheet->getUnparsedLoadedData()['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'])) {
|
||||
foreach ($this->spreadSheet->getUnparsedLoadedData()['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'] as $vmlDrawing) {
|
||||
if (isset($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'])) {
|
||||
foreach ($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'] as $vmlDrawing) {
|
||||
$zip->addFromString($vmlDrawing['filePath'], $vmlDrawing['content']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,12 +89,13 @@ class ContentTypes extends WriterPart
|
|||
$this->writeOverrideContentType($objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml');
|
||||
|
||||
// Add worksheet relationship content types
|
||||
$unparsedLoadedData = $spreadsheet->getUnparsedLoadedData();
|
||||
$chart = 1;
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$drawings = $spreadsheet->getSheet($i)->getDrawingCollection();
|
||||
$drawingCount = count($drawings);
|
||||
$chartCount = ($includeCharts) ? $spreadsheet->getSheet($i)->getChartCount() : 0;
|
||||
$hasUnparsedDrawing = isset($spreadsheet->getUnparsedLoadedData()['sheets'][$spreadsheet->getSheet($i)->getCodeName()]['drawingOriginalIds']);
|
||||
$hasUnparsedDrawing = isset($unparsedLoadedData['sheets'][$spreadsheet->getSheet($i)->getCodeName()]['drawingOriginalIds']);
|
||||
|
||||
// We need a drawing relationship for the worksheet if we have either drawings or charts
|
||||
if (($drawingCount > 0) || ($chartCount > 0) || $hasUnparsedDrawing) {
|
||||
|
@ -163,15 +164,15 @@ class ContentTypes extends WriterPart
|
|||
}
|
||||
|
||||
// unparsed defaults
|
||||
if (isset($spreadsheet->getUnparsedLoadedData()['default_content_types'])) {
|
||||
foreach ($spreadsheet->getUnparsedLoadedData()['default_content_types'] as $extName => $contentType) {
|
||||
if (isset($unparsedLoadedData['default_content_types'])) {
|
||||
foreach ($unparsedLoadedData['default_content_types'] as $extName => $contentType) {
|
||||
$this->writeDefaultContentType($objWriter, $extName, $contentType);
|
||||
}
|
||||
}
|
||||
|
||||
// unparsed overrides
|
||||
if (isset($spreadsheet->getUnparsedLoadedData()['override_content_types'])) {
|
||||
foreach ($spreadsheet->getUnparsedLoadedData()['override_content_types'] as $partName => $overrideType) {
|
||||
if (isset($unparsedLoadedData['override_content_types'])) {
|
||||
foreach ($unparsedLoadedData['override_content_types'] as $partName => $overrideType) {
|
||||
$this->writeOverrideContentType($objWriter, $partName, $overrideType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,9 @@ class Drawing extends WriterPart
|
|||
}
|
||||
|
||||
// unparsed AlternateContent
|
||||
if (isset($pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'])) {
|
||||
foreach ($pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'] as $drawingAlternateContent) {
|
||||
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
|
||||
if (isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'])) {
|
||||
foreach ($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'] as $drawingAlternateContent) {
|
||||
$objWriter->writeRaw($drawingAlternateContent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,8 +196,9 @@ class Rels extends WriterPart
|
|||
// Write drawing relationships?
|
||||
$d = 0;
|
||||
$drawingOriginalIds = [];
|
||||
if (isset($pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'])) {
|
||||
$drawingOriginalIds = $pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'];
|
||||
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
|
||||
if (isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'])) {
|
||||
$drawingOriginalIds = $unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'];
|
||||
}
|
||||
|
||||
if ($includeCharts) {
|
||||
|
@ -278,11 +279,12 @@ class Rels extends WriterPart
|
|||
|
||||
private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, XMLWriter $objWriter, $relationship, $type)
|
||||
{
|
||||
if (!isset($pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()][$relationship])) {
|
||||
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
|
||||
if (!isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()][$relationship])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($pWorksheet->getParent()->getUnparsedLoadedData()['sheets'][$pWorksheet->getCodeName()][$relationship] as $rId => $value) {
|
||||
foreach ($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()][$relationship] as $rId => $value) {
|
||||
$this->writeRelationship(
|
||||
$objWriter,
|
||||
$rId,
|
||||
|
|
|
@ -852,8 +852,9 @@ class Worksheet extends WriterPart
|
|||
$objWriter->writeAttribute('useFirstPageNumber', '1');
|
||||
}
|
||||
|
||||
if (isset($pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['pageSetupRelId'])) {
|
||||
$objWriter->writeAttribute('r:id', $pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['pageSetupRelId']);
|
||||
$getUnparsedLoadedData = $pSheet->getParent()->getUnparsedLoadedData();
|
||||
if (isset($getUnparsedLoadedData['sheets'][$pSheet->getCodeName()]['pageSetupRelId'])) {
|
||||
$objWriter->writeAttribute('r:id', $getUnparsedLoadedData['sheets'][$pSheet->getCodeName()]['pageSetupRelId']);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
@ -1157,7 +1158,8 @@ class Worksheet extends WriterPart
|
|||
*/
|
||||
private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $pSheet, $includeCharts = false)
|
||||
{
|
||||
$hasUnparsedDrawing = isset($pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['drawingOriginalIds']);
|
||||
$unparsedLoadedData = $pSheet->getParent()->getUnparsedLoadedData();
|
||||
$hasUnparsedDrawing = isset($unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds']);
|
||||
$chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0;
|
||||
if ($chartCount == 0 && $pSheet->getDrawingCollection()->count() == 0 && !$hasUnparsedDrawing) {
|
||||
return;
|
||||
|
@ -1167,8 +1169,8 @@ class Worksheet extends WriterPart
|
|||
$objWriter->startElement('drawing');
|
||||
|
||||
$rId = 'rId1';
|
||||
if (isset($pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['drawingOriginalIds'])) {
|
||||
$drawingOriginalIds = $pSheet->getParent()->getUnparsedLoadedData()['sheets'][$pSheet->getCodeName()]['drawingOriginalIds'];
|
||||
if (isset($unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds'])) {
|
||||
$drawingOriginalIds = $unparsedLoadedData['sheets'][$pSheet->getCodeName()]['drawingOriginalIds'];
|
||||
// take first. In future can be overriten
|
||||
$rId = reset($drawingOriginalIds);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue