Skip to content

Commit ea33980

Browse files
authored
Merge pull request #771 from Progi1984/pr754
PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0
2 parents f6f0120 + 5472c1a commit ea33980

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

docs/changes/1.1.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
## Bugfixes
1515

1616
- Fixed CI - [@Progi1984](https://github.com/Progi1984) in [#766](https://github.com/PHPOffice/PHPPresentation/pull/766)
17-
- Fixed broken PPT Presentations due to MS Office update 2309 - [@WFarmerEthisphere](https://github.com/WFarmerEthisphere) in [#770](https://github.com/PHPOffice/PHPPresentation/pull/770)
17+
- 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)
18+
- 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)

src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,13 +2284,13 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
22842284
$objWriter->writeAttribute('val', $orientation);
22852285
$objWriter->endElement();
22862286

2287-
if (null != $oAxis->getMaxBounds()) {
2287+
if (null !== $oAxis->getMaxBounds()) {
22882288
$objWriter->startElement('c:max');
22892289
$objWriter->writeAttribute('val', $oAxis->getMaxBounds());
22902290
$objWriter->endElement();
22912291
}
22922292

2293-
if (null != $oAxis->getMinBounds()) {
2293+
if (null !== $oAxis->getMinBounds()) {
22942294
$objWriter->startElement('c:min');
22952295
$objWriter->writeAttribute('val', $oAxis->getMinBounds());
22962296
$objWriter->endElement();

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,56 @@ public function testAxisBounds(): void
275275
$this->assertIsSchemaECMA376Valid();
276276
}
277277

278+
public function testAxisBoundsIfZero(): void
279+
{
280+
$value = 0;
281+
282+
$oSeries = new Series('Downloads', $this->seriesData);
283+
$oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
284+
$oLine = new Line();
285+
$oLine->addSeries($oSeries);
286+
$oShape = $this->oPresentation->getActiveSlide()->createChartShape();
287+
$oShape->getPlotArea()->setType($oLine);
288+
289+
$elementMax = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:max';
290+
$elementMin = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:min';
291+
292+
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
293+
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
294+
295+
$this->assertIsSchemaECMA376Valid();
296+
297+
$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
298+
$this->resetPresentationFile();
299+
300+
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
301+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
302+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
303+
304+
$this->assertIsSchemaECMA376Valid();
305+
306+
$oShape->getPlotArea()->getAxisX()->setMinBounds(null);
307+
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
308+
$this->resetPresentationFile();
309+
310+
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
311+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
312+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);
313+
314+
$this->assertIsSchemaECMA376Valid();
315+
316+
$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
317+
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
318+
$this->resetPresentationFile();
319+
320+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
321+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
322+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
323+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);
324+
325+
$this->assertIsSchemaECMA376Valid();
326+
}
327+
278328
public function testAxisCrosses(): void
279329
{
280330
$oSeries = new Series('Downloads', $this->seriesData);

0 commit comments

Comments
 (0)