Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerPoint2007 Writer : Fixed column indices for embedded spreadsheets #773

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/1.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- PowerPoint2077 Writer : Fixed broken PPT Presentations due to MS Office update 2309 - [@WFarmerEthisphere](https://github.com/WFarmerEthisphere) in [#770](https://github.com/PHPOffice/PHPPresentation/pull/770)
- PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0 - [@LilyEssence](https://github.com/LilyEssence) in [#771](https://github.com/PHPOffice/PHPPresentation/pull/771)
- PowerPoint2007 Writer : Outline : Fixed the base unit - [@Pakku](https://github.com/Pakku) in [#772](https://github.com/PHPOffice/PHPPresentation/pull/772)
- PowerPoint2007 Writer : Fixed column indices for embedded spreadsheets - [@michael-roth](https://github.com/michael-roth) in [#773](https://github.com/PHPOffice/PHPPresentation/pull/773)

## BC Breaks
- `PhpOffice\PhpPresentation\Style\Outline` : the width is now based on pixels (before in points)
2 changes: 1 addition & 1 deletion src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
*/
class AbstractTypeBar extends AbstractType
abstract class AbstractTypeBar extends AbstractType
{
/** Orientation of bars */
public const DIRECTION_VERTICAL = 'col';
Expand Down
2 changes: 1 addition & 1 deletion src/PhpPresentation/Shape/Chart/Type/AbstractTypeLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace PhpOffice\PhpPresentation\Shape\Chart\Type;

class AbstractTypeLine extends AbstractType
abstract class AbstractTypeLine extends AbstractType
{
/**
* Is Line Smooth?
Expand Down
2 changes: 1 addition & 1 deletion src/PhpPresentation/Shape/Chart/Type/AbstractTypePie.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar.
*/
class AbstractTypePie extends AbstractType
abstract class AbstractTypePie extends AbstractType
{
/**
* Create a new self instance.
Expand Down
81 changes: 38 additions & 43 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,20 @@ protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart,
$seriesIndex = 0;
foreach ($chart->getPlotArea()->getType()->getSeries() as $series) {
// Title
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, 1, $series->getTitle());
$sheet->setCellValueByColumnAndRow(2 + $seriesIndex, 1, $series->getTitle());

// X-axis
$axisXData = array_keys($series->getValues());
$numAxisXData = count($axisXData);
for ($i = 0; $i < $numAxisXData; ++$i) {
$sheet->setCellValueByColumnAndRow(0, $i + 2, $axisXData[$i]);
$sheet->setCellValueByColumnAndRow(1, $i + 2, $axisXData[$i]);
}

// Y-axis
$axisYData = array_values($series->getValues());
$numAxisYData = count($axisYData);
for ($i = 0; $i < $numAxisYData; ++$i) {
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, $i + 2, $axisYData[$i]);
$sheet->setCellValueByColumnAndRow(2 + $seriesIndex, $i + 2, $axisYData[$i]);
}

++$seriesIndex;
Expand Down Expand Up @@ -723,7 +723,7 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl

// c:ser > c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -768,7 +768,7 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -829,7 +829,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -965,7 +965,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1040,7 +1040,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1161,7 +1161,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1226,7 +1226,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1258,7 +1258,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand All @@ -1271,14 +1271,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:dLbls
$objWriter->startElement('c:dLbls');

$this->writeElementWithValAttribute($objWriter, 'c:showLegendKey', $series->hasShowLegendKey() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showBubbleSize', '0');
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0');

if ($series->hasDlblNumFormat()) {
//c:numFmt
$objWriter->startElement('c:numFmt');
Expand Down Expand Up @@ -1334,6 +1326,14 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
// c:dLbls\c:txPr\
$objWriter->endElement();

$this->writeElementWithValAttribute($objWriter, 'c:showLegendKey', $series->hasShowLegendKey() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showVal', $series->hasShowValue() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showCatName', $series->hasShowCategoryName() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showSerName', $series->hasShowSeriesName() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showPercent', $series->hasShowPercentage() ? '1' : '0');
$this->writeElementWithValAttribute($objWriter, 'c:showBubbleSize', '0');
$this->writeElementWithValAttribute($objWriter, 'c:showLeaderLines', $series->hasShowLeaderLines() ? '1' : '0');

$separator = $series->getSeparator();
if (!empty($separator) && PHP_EOL != $separator) {
// c:dLbls\c:separator
Expand Down Expand Up @@ -1383,7 +1383,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1501,7 +1501,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1546,7 +1546,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1658,7 +1658,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1703,7 +1703,7 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1805,7 +1805,7 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -1875,10 +1875,19 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

// c:spPr
$objWriter->startElement('c:spPr');
// Write fill
$this->writeFill($objWriter, $series->getFill());
// Write outline
$this->writeOutline($objWriter, $series->getOutline());
// ## c:spPr
$objWriter->endElement();

// Marker
$this->writeSeriesMarker($objWriter, $series->getMarker());

Expand Down Expand Up @@ -1957,15 +1966,6 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in

$objWriter->endElement();

// c:spPr
$objWriter->startElement('c:spPr');
// Write fill
$this->writeFill($objWriter, $series->getFill());
// Write outline
$this->writeOutline($objWriter, $series->getOutline());
// ## c:spPr
$objWriter->endElement();

// Write X axis data
$axisXData = array_keys($series->getValues());

Expand All @@ -1979,15 +1979,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in

// c:val
$objWriter->startElement('c:val');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

// c:smooth
$objWriter->startElement('c:smooth');
$objWriter->writeAttribute('val', '0');
$objWriter->endElement();

$objWriter->endElement();

++$seriesIndex;
Expand Down Expand Up @@ -2042,7 +2037,7 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool

// c:tx
$objWriter->startElement('c:tx');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(1 + $seriesIndex) . '$1' : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex(2 + $seriesIndex) . '$1' : '');
$this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords);
$objWriter->endElement();

Expand Down Expand Up @@ -2153,7 +2148,7 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool

// c:yVal
$objWriter->startElement('c:yVal');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 1) . '$' . (1 + count($axisYData)) : '');
$coords = ($includeSheet ? 'Sheet1!$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$2:$' . Coordinate::stringFromColumnIndex($seriesIndex + 2) . '$' . (1 + count($axisYData)) : '');
$this->writeMultipleValuesOrReference($objWriter, $includeSheet, $axisYData, $coords);
$objWriter->endElement();

Expand Down
Loading
Loading