Skip to content

Commit 4d1b5b5

Browse files
committed
PowerPoint2007 Writer : Implement Animations
1 parent 95aba97 commit 4d1b5b5

File tree

10 files changed

+460
-275
lines changed

10 files changed

+460
-275
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- PhpOffice\PhpPresentation\Shape\Type\AbstracType\getData has been deprecated for PhpOffice\PhpPresentation\Shape\Type\AbstracType\getSeries - @Progi1984 GH-169
1313
- PhpOffice\PhpPresentation\Shape\Type\AbstracType\setData has been deprecated for PhpOffice\PhpPresentation\Shape\Type\AbstracType\setSeries - @Progi1984 GH-169
1414
- Added documentation for chart series (font, outline, marker) - @Progi1984 GH-169
15+
- Internal Structure for Drawing Shape - @Progi1984 GH-192
1516

1617
### Features
1718
- ODPresentation & PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116
@@ -27,6 +28,7 @@
2728
- ODPresentation & PowerPoint2007 Writer : Support for Visibility for slides - @Progi1984
2829
- PowerPoint2007 Writer : Presentation with predefined View Type - @Progi1984 GH-120
2930
- PowerPoint2007 Writer : Implement alpha channel to Fills - @Dayjo GH-203 / @Progi1984 GH-215
31+
- PowerPoint2007 Writer : Implement Animations - @JewrassicPark GH-214 / @Progi1984 GH-217
3032

3133
## 0.6.0 - 2016-01-24
3234

docs/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ PHPPresentation is a library written in pure PHP that provides a set of classes
2525
faq
2626
credits
2727
references
28-
28+
29+
.. _slidesdocs:
30+
31+
.. toctree::
32+
:maxdepth: 2
33+
:caption: Slides
34+
35+
slides_animation
36+
2937
.. _shapesdocs:
3038

3139
.. toctree::

docs/slides_animation.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _slides_animation:
2+
3+
Animation
4+
=========
5+
6+
You can create multiples animations in a slide.
7+
8+
.. code-block:: php
9+
10+
use PhpOffice\PhpPresentation\Slide\Animation;
11+
12+
$oAnimation1 = new Animation();
13+
$oAnimation1->addShape($oDrawing);
14+
$oSlide->addAnimation($oAnimation1);
15+
16+
$oAnimation2 = new Animation();
17+
$oAnimation2->addShape($oRichText);
18+
$oSlide->addAnimation($oAnimation2);
19+

samples/Sample_18_Animation.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
include_once 'Sample_Header.php';
4+
5+
use PhpOffice\PhpPresentation\PhpPresentation;
6+
use PhpOffice\PhpPresentation\Slide\Animation;
7+
8+
// Create new PHPPresentation object
9+
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
10+
$objPHPPresentation = new PhpPresentation();
11+
12+
$oDrawing1 = clone $oShapeDrawing;
13+
$oRichText1 = clone $oShapeRichText;
14+
15+
// Create slide
16+
echo date('H:i:s') . ' Create slide'.EOL;
17+
$oSlide1 = $objPHPPresentation->getActiveSlide();
18+
$oSlide1->addShape($oDrawing1);
19+
$oSlide1->addShape($oRichText1);
20+
21+
$oAnimation1 = new Animation();
22+
$oAnimation1->addShape($oDrawing1);
23+
$oSlide1->addAnimation($oAnimation1);
24+
25+
$oAnimation2 = new Animation();
26+
$oAnimation2->addShape($oRichText1);
27+
$oSlide1->addAnimation($oAnimation2);
28+
29+
$oDrawing2 = clone $oShapeDrawing;
30+
$oRichText2 = clone $oShapeRichText;
31+
32+
$oSlide2 = $objPHPPresentation->createSlide();
33+
$oSlide2->addShape($oDrawing2);
34+
$oSlide2->addShape($oRichText2);
35+
36+
$oAnimation4 = new Animation();
37+
$oAnimation4->addShape($oRichText2);
38+
$oSlide2->addAnimation($oAnimation4);
39+
40+
$oAnimation3 = new Animation();
41+
$oAnimation3->addShape($oDrawing2);
42+
$oSlide2->addAnimation($oAnimation3);
43+
44+
$oDrawing3 = clone $oShapeDrawing;
45+
$oRichText3 = clone $oShapeRichText;
46+
47+
$oSlide3 = $objPHPPresentation->createSlide();
48+
$oSlide3->addShape($oDrawing3);
49+
$oSlide3->addShape($oRichText3);
50+
51+
$oAnimation5 = new Animation();
52+
$oAnimation5->addShape($oRichText3);
53+
$oAnimation5->addShape($oDrawing3);
54+
$oSlide3->addAnimation($oAnimation5);
55+
56+
// Save file
57+
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
58+
if (!CLI) {
59+
include_once 'Sample_Footer.php';
60+
}

src/PhpPresentation/Slide.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ class Slide implements ComparableInterface, ShapeContainerInterface
8989

9090
/**
9191
*
92-
* @var \PhpOffice\PhpPresentation\Slide\Animation
92+
* @var \PhpOffice\PhpPresentation\Slide\Animation[]
9393
*/
94-
private $animations = array();
94+
protected $animations = array();
9595

9696
/**
9797
* Hash index
@@ -551,22 +551,32 @@ public function setIsVisible($value = true)
551551
* Add an animation to the slide
552552
*
553553
* @param \PhpOffice\PhpPresentation\Slide\Animation
554-
* @return \PhpOffice\PhpPresentation\Slide\Animation
554+
* @return Slide
555555
*/
556556
public function addAnimation($animation)
557557
{
558558
$this->animations[] = $animation;
559-
return $animation;
559+
return $this;
560560
}
561-
561+
562562
/**
563563
* Get collection of animations
564564
*
565565
* @return \PhpOffice\PhpPresentation\Slide\Animation
566566
*/
567-
568567
public function getAnimations()
569568
{
570569
return $this->animations;
571570
}
571+
572+
/**
573+
* Set collection of animations
574+
* @param \PhpOffice\PhpPresentation\Slide\Animation[] $array
575+
* @return Slide
576+
*/
577+
public function setAnimations(array $array = array())
578+
{
579+
$this->animations = $array;
580+
return $this;
581+
}
572582
}
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
<?php
22
namespace PhpOffice\PhpPresentation\Slide;
33

4+
use PhpOffice\PhpPresentation\AbstractShape;
5+
46
class Animation
57
{
6-
private $shapeCollection = array();
7-
8-
public function __construct()
9-
{
10-
11-
}
12-
13-
public function addShape($shape)
8+
/**
9+
* @var array
10+
*/
11+
protected $shapeCollection = array();
12+
13+
/**
14+
* @param AbstractShape $shape
15+
* @return Animation
16+
*/
17+
public function addShape(AbstractShape $shape)
1418
{
1519
$this->shapeCollection[] = $shape;
16-
17-
return $shape;
20+
return $this;
1821
}
19-
22+
23+
/**
24+
* @return array
25+
*/
2026
public function getShapeCollection()
2127
{
2228
return $this->shapeCollection;
2329
}
30+
31+
/**
32+
* @param array $array
33+
* @return Animation
34+
*/
35+
public function setShapeCollection(array $array = array())
36+
{
37+
$this->shapeCollection = $array;
38+
return $this;
39+
}
2440
}

0 commit comments

Comments
 (0)