Skip to content

Commit

Permalink
Merge pull request #771 from Progi1984/pr754
Browse files Browse the repository at this point in the history
PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0
  • Loading branch information
Progi1984 authored Dec 4, 2023
2 parents f6f0120 + 5472c1a commit ea33980
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/changes/1.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
## Bugfixes

- Fixed CI - [@Progi1984](https://github.com/Progi1984) in [#766](https://github.com/PHPOffice/PHPPresentation/pull/766)
- 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 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)
4 changes: 2 additions & 2 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2284,13 +2284,13 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->writeAttribute('val', $orientation);
$objWriter->endElement();

if (null != $oAxis->getMaxBounds()) {
if (null !== $oAxis->getMaxBounds()) {
$objWriter->startElement('c:max');
$objWriter->writeAttribute('val', $oAxis->getMaxBounds());
$objWriter->endElement();
}

if (null != $oAxis->getMinBounds()) {
if (null !== $oAxis->getMinBounds()) {
$objWriter->startElement('c:min');
$objWriter->writeAttribute('val', $oAxis->getMinBounds());
$objWriter->endElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,56 @@ public function testAxisBounds(): void
$this->assertIsSchemaECMA376Valid();
}

public function testAxisBoundsIfZero(): void
{
$value = 0;

$oSeries = new Series('Downloads', $this->seriesData);
$oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
$oLine = new Line();
$oLine->addSeries($oSeries);
$oShape = $this->oPresentation->getActiveSlide()->createChartShape();
$oShape->getPlotArea()->setType($oLine);

$elementMax = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:max';
$elementMin = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:min';

$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);

$this->assertIsSchemaECMA376Valid();

$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
$this->resetPresentationFile();

$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);

$this->assertIsSchemaECMA376Valid();

$oShape->getPlotArea()->getAxisX()->setMinBounds(null);
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
$this->resetPresentationFile();

$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);

$this->assertIsSchemaECMA376Valid();

$oShape->getPlotArea()->getAxisX()->setMinBounds($value);
$oShape->getPlotArea()->getAxisX()->setMaxBounds($value);
$this->resetPresentationFile();

$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);

$this->assertIsSchemaECMA376Valid();
}

public function testAxisCrosses(): void
{
$oSeries = new Series('Downloads', $this->seriesData);
Expand Down

0 comments on commit ea33980

Please sign in to comment.