Skip to content

Commit 3b1ab43

Browse files
authored
Merge pull request #783 from Progi1984/fix446
PowerPoint2007 Writer : Fixed broken animation for first shape
2 parents 9071151 + 66a4a85 commit 3b1ab43

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docs/changes/1.1.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- 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)
3232
- 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)
3333
- PowerPoint2007 Reader : Fixed reading of RichText shape in Note - [@aelliott1485](https://github.com/aelliott1485) in [#782](https://github.com/PHPOffice/PHPPresentation/pull/782)
34+
- PowerPoint2007 Writer : Fixed broken animation for first shape - [@shannan1989](https://github.com/shannan1989) in [#783](https://github.com/PHPOffice/PHPPresentation/pull/783)
3435

3536
## Miscellaneous
3637

src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,13 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, XMLWr
119119
}
120120

121121
/**
122+
* Note : $shapeId needs to start to 1
123+
* The animation is applied to the shape which is next to the target shape.
124+
*
122125
* @param array<int, AbstractShape>|ArrayObject<int, AbstractShape> $shapes
123126
* @param int $shapeId
124127
*/
125-
protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 0): void
128+
protected function writeShapeCollection(XMLWriter $objWriter, $shapes = [], &$shapeId = 1): void
126129
{
127130
if (0 == count($shapes)) {
128131
return;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testAnimation(): void
130130
{
131131
$oSlide = $this->oPresentation->getActiveSlide();
132132
$oShape1 = $oSlide->createRichTextShape();
133-
$oShape2 = $oSlide->createRichTextShape();
133+
$oShape2 = $oSlide->createLineShape(10, 10, 10, 10);
134134
$oAnimation = new Animation();
135135
$oAnimation->addShape($oShape1);
136136
$oAnimation->addShape($oShape2);
@@ -142,6 +142,12 @@ public function testAnimation(): void
142142
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
143143
$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';
144144
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
145+
$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';
146+
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
147+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 2);
148+
$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';
149+
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
150+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'spid', 3);
145151
$this->assertIsSchemaECMA376Valid();
146152
}
147153

0 commit comments

Comments
 (0)