From 66a4a85f58d197fe8d3b0f97876784b69f249f69 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 12 Dec 2023 11:11:36 +0100 Subject: [PATCH] PowerPoint2007 Writer : Fixed broken animation for first shape --- docs/changes/1.1.0.md | 1 + .../Writer/PowerPoint2007/AbstractSlide.php | 5 ++++- .../Tests/Writer/PowerPoint2007/PptSlidesTest.php | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/changes/1.1.0.md b/docs/changes/1.1.0.md index 37f09dacc..2ff907807 100644 --- a/docs/changes/1.1.0.md +++ b/docs/changes/1.1.0.md @@ -31,6 +31,7 @@ - PowerPoint2007 Writer : Fixed issue when first element in series is null - [@ksmeeks0001](https://github.com/ksmeeks0001) in [#778](https://github.com/PHPOffice/PHPPresentation/pull/778) - PowerPoint2007 & ODPresentation Writer : Use of the disk caching directory for temporary files - [@nhalle](https://github.com/nhalle) in [#781](https://github.com/PHPOffice/PHPPresentation/pull/781) - PowerPoint2007 Reader : Fixed reading of RichText shape in Note - [@aelliott1485](https://github.com/aelliott1485) in [#782](https://github.com/PHPOffice/PHPPresentation/pull/782) +- PowerPoint2007 Writer : Fixed broken animation for first shape - [@shannan1989](https://github.com/shannan1989) in [#783](https://github.com/PHPOffice/PHPPresentation/pull/783) ## Miscellaneous diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index 8b6a41400..45a4a35af 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -119,10 +119,13 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, XMLWr } /** + * Note : $shapeId needs to start to 1 + * The animation is applied to the shape which is next to the target shape. + * * @param array|ArrayObject $shapes * @param int $shapeId */ - protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 0): void + protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 1): void { if (0 == count($shapes)) { return; diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php index 8cd2c7f3a..2548bb9c3 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php @@ -130,7 +130,7 @@ public function testAnimation(): void { $oSlide = $this->oPresentation->getActiveSlide(); $oShape1 = $oSlide->createRichTextShape(); - $oShape2 = $oSlide->createRichTextShape(); + $oShape2 = $oSlide->createLineShape(10, 10, 10, 10); $oAnimation = new Animation(); $oAnimation->addShape($oShape1); $oAnimation->addShape($oShape2); @@ -142,6 +142,12 @@ public function testAnimation(): void $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); $element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par'; $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); + $element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par[1]/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt'; + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 2); + $element = '/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par[2]/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt'; + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 3); $this->assertIsSchemaECMA376Valid(); }