Skip to content

Commit 8b483ae

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 4460305 + d7bbf5c commit 8b483ae

34 files changed

+1143
-244
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
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
1515
- Internal Structure for Drawing Shape - @Progi1984 GH-192
16+
- Documentation about manual installation - @danielbair GH-254
1617

1718
### Features
1819
- ODPresentation & PowerPoint2007 Writer : Add support for Comment - @Progi1984 GH-116

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ PHPPresentation requires the following:
4848

4949
### Installation
5050

51+
#### Composer method
52+
5153
It is recommended that you install the PHPPresentation library [through composer](http://getcomposer.org/). To do so, add
5254
the following lines to your ``composer.json``.
5355

@@ -59,14 +61,25 @@ the following lines to your ``composer.json``.
5961
}
6062
```
6163

62-
Alternatively, you can download the latest release from the [releases page](https://github.com/PHPOffice/PHPPresentation/releases).
63-
In this case, you will have to register the autoloader. Register autoloading is required only if you do not use composer in your project.
64+
#### Manual download method
65+
66+
Alternatively, you can download the latest release from the [releases page](https://github.com/PHPOffice/PHPPresentation/releases).
67+
In this case, you will have to register the autoloader.
68+
(Register autoloading is required only if you do not use composer in your project.)
6469

6570
```php
6671
require_once 'path/to/PhpPresentation/src/PhpPresentation/Autoloader.php';
6772
\PhpOffice\PhpPresentation\Autoloader::register();
6873
```
6974

75+
You will also need to download the latest PHPOffice/Common release from its [releases page](https://github.com/PHPOffice/Common/releases).
76+
And you will also have to register its autoloader, too.
77+
78+
```php
79+
require_once 'path/to/PhpOffice/Common/src/Common/Autoloader.php';
80+
\PhpOffice\Common\Autoloader::register();
81+
```
82+
7083
## Getting started
7184

7285
The following is a basic usage example of the PHPPresentation library.
@@ -75,6 +88,8 @@ The following is a basic usage example of the PHPPresentation library.
7588
// with your own install
7689
require_once 'src/PhpPresentation/Autoloader.php';
7790
\PhpOffice\PhpPresentation\Autoloader::register();
91+
require_once 'src/Common/Autoloader.php';
92+
\PhpOffice\Common\Autoloader::register();
7893

7994
// with Composer
8095
require_once 'vendor/autoload.php';

docs/credits.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
Credits
44
=======
55

6-
Images from chart page come from the `LibreOffice Core <https://github.com/LibreOffice/core/tree/master/icon-themes/galaxy/chart2/res>`.
6+
Images from chart page come from the `LibreOffice Core <https://github.com/LibreOffice/core/tree/master/icon-themes/galaxy/chart2/res>`.
7+
8+
Some definitions come from the `Office Open XML <http://officeopenxml.com/>`.

docs/slides_layout.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _slides_layout:
2+
3+
Slides Layout
4+
=============
5+
6+
A slide is a hierarchy of three components :
7+
- The master slide upon which the slide is based : it specifies such properties as the font styles for the title, body, and footer, placeholder positions for text and objects, bullets styles, and background ;
8+
- The slide layout which is applied to the the slide : it permits to override what is specified in the master slide ;
9+
- The slide itself : it contains content and formatting that is not already specified by the master slide and the slide layout
10+
11+
Placeholders permit to link these three components together in order that the override is possible.
12+
13+
Master slides
14+
-------------
15+
16+
You can access to all master slides with the method ``getAllMasterSlides`` or create one with ``createMasterSlide``.
17+
18+
.. code-block:: php
19+
20+
$arraySlideMasters = $oPHPPresentation->getAllMasterSlides();
21+
$oMasterSlide = $oPHPPresentation->createMasterSlide();
22+
23+
Slides Layout
24+
-------------
25+
26+
You can access to all slide layout from a master with the method ``getAllSlideLayouts`` or create one with ``createSlideLayout``.
27+
28+
.. code-block:: php
29+
30+
$arraySlideLayouts = $oMasterSlide->getAllSlideLayouts();
31+
$oSlideLayout = $oMasterSlide->createSlideLayout();
32+
33+
Placeholders
34+
------------
35+
36+
For each master slide or slide layout, you can add any shape like on a slide.
37+
38+
.. code-block:: php
39+
40+
$oShape = $oMasterSlide->createChartShape();
41+
$oShape = $oSlideLayout->createTableShape();
42+
43+
You can define a shape as a placeholder for each level with the method ``setPlaceHolder``.
44+
A shape defined in each level will have an override for its formatting in each level.
45+
46+
.. code-block:: php
47+
48+
use PhpOffice\PhpPresentation\Shape\Placeholder;
49+
$oShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_TITLE));
50+

phpmd.xml.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
<rule ref="rulesets/design.xml/DepthOfInheritance" />
1919
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
2020
<!-- PptSlides needs more coupling (default: 13) -->
21-
<properties>
22-
<property name="minimum" value="30" />
21+
<!-- Writer/Office2007/AbstractSlide needs more coupling (default: 13) -->
22+
<properties>
23+
<property name="minimum" value="31" />
2324
</properties>
2425
</rule>
2526
<rule ref="rulesets/design.xml/NumberOfChildren">

samples/Sample_19_SlideMaster.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
$currentSlide = $objPHPPresentation->getActiveSlide();
2727

2828
// Create a master layout
29-
echo date('H:i:s') . ' Create masterslide' . EOL;
29+
echo date('H:i:s') . ' Create masterslide layout' . EOL;
3030
// Some decorative lines
3131
$oMasterSlide = $objPHPPresentation->getAllMasterSlides()[0];
3232
$shape = $oMasterSlide->createLineShape(0, 670, 960, 670)->getBorder()->setColor(new Color(Color::COLOR_RED))->setLineWidth(2);
3333
$shape = $oMasterSlide->createLineShape(0, 672, 960, 672)->getBorder()->setColor(new Color(Color::COLOR_WHITE))->setLineWidth(2);
3434
$shape = $oMasterSlide->createLineShape(0, 674, 960, 674)->getBorder()->setColor(new Color(Color::COLOR_DARKBLUE))->setLineWidth(2);
3535
// Title placeholder
36-
$shape = $oMasterSlide->createRichTextShape()->setWidthAndHeight(960, 80)->setOffsetX(0)->setOffsetY(60);
36+
$shape = $oMasterSlide->createRichTextShape();
37+
$shape->setWidthAndHeight(960, 80)->setOffsetX(0)->setOffsetY(60);
3738
$shape->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
3839
$shape->getActiveParagraph()->getAlignment()
3940
->setHorizontal(Alignment::HORIZONTAL_RIGHT)->setMarginLeft(200)->setMarginRight(50)
@@ -46,23 +47,26 @@
4647
$textRun->getFont()->setBold(true)->setSize(30)->setColor(new Color(Color::COLOR_WHITE));
4748
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_TITLE));
4849
// Date placeholder
49-
$shape = $oMasterSlide->createRichTextShape()->setWidthAndHeight(140, 38)->setOffsetX(50)->setOffsetY(680);
50+
$shape = $oMasterSlide->createRichTextShape();
51+
$shape->setWidthAndHeight(140, 38)->setOffsetX(50)->setOffsetY(680);
5052
$shape->getActiveParagraph()->getAlignment()
5153
->setHorizontal(Alignment::HORIZONTAL_LEFT)
5254
->setVertical(Alignment::VERTICAL_BASE);
5355
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
5456
$textRun = $shape->createTextRun('01-02-2000')->getFont()->setSize(18);
5557
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME))->getPlaceholder()->setIdx(10);
5658
// Footer placeholder
57-
$shape = $oMasterSlide->createRichTextShape()->setWidthAndHeight(468, 38)->setOffsetX(246)->setOffsetY(680);
59+
$shape = $oMasterSlide->createRichTextShape();
60+
$shape->setWidthAndHeight(468, 38)->setOffsetX(246)->setOffsetY(680);
5861
$shape->getActiveParagraph()->getAlignment()
5962
->setHorizontal(Alignment::HORIZONTAL_CENTER)
6063
->setVertical(Alignment::VERTICAL_BASE);
6164
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
6265
$textRun = $shape->createTextRun('Placeholder for Footer')->getFont()->setSize(18);
6366
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER))->getPlaceholder()->setIdx(11);
6467
// Slidenumber placeholder
65-
$shape = $oMasterSlide->createRichTextShape()->setWidthAndHeight(140, 38)->setOffsetX(770)->setOffsetY(680);
68+
$shape = $oMasterSlide->createRichTextShape();
69+
$shape->setWidthAndHeight(140, 38)->setOffsetX(770)->setOffsetY(680);
6670
$shape->getActiveParagraph()->getAlignment()
6771
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
6872
->setVertical(Alignment::VERTICAL_BASE);
@@ -86,14 +90,20 @@
8690

8791
// Create a shape (text) linked to a PlaceHolder
8892
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
89-
$shape = $currentSlide->createRichTextShape()->setWidthAndHeight(960, 80)->setOffsetX(0)->setOffsetY(60);
93+
$shape = $currentSlide->createRichTextShape();
94+
$shape->setWidthAndHeight(960, 80)->setOffsetX(0)->setOffsetY(60);
9095
$shape->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
9196
$shape->getActiveParagraph()->getAlignment()
9297
->setHorizontal(Alignment::HORIZONTAL_RIGHT)->setMarginLeft(200)->setMarginRight(50)
9398
->setVertical(Alignment::VERTICAL_CENTER);
9499
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
95100
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_TITLE));
96101

102+
echo date('H:i:s') . ' Apply the shape collection of the slide master to the slide layout' . EOL;
103+
$oSlideLayout = $oMasterSlide->getAllSlideLayouts()[0];
104+
$oSlideLayout->setShapeCollection($oMasterSlide->getShapeCollection());
105+
$currentSlide->setSlideLayout($oSlideLayout);
106+
97107
// Save file
98108
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
99109
if (!CLI) {

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
namespace PhpOffice\PhpPresentation\Reader;
1919

20-
/** This file will be edited to also read slideLayout things */
21-
2220
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph;
2321
use PhpOffice\PhpPresentation\Slide\AbstractSlide;
2422
use PhpOffice\PhpPresentation\Shape\Placeholder;

src/PhpPresentation/Reader/ReaderInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function canRead($pFilename);
3434
* Loads PhpPresentation from file
3535
*
3636
* @param string $pFilename
37+
* @return \PhpOffice\PhpPresentation\PhpPresentation
3738
* @throws \Exception
3839
*/
3940
public function load($pFilename);

src/PhpPresentation/Shape/Line.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function __construct($fromX, $fromY, $toX, $toY)
4343
$this->setOffsetY($fromY);
4444
$this->setWidth($toX - $fromX);
4545
$this->setHeight($toY - $fromY);
46-
4746
}
4847

4948
/**

src/PhpPresentation/Slide/AbstractSlide.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ public function getShapeCollection()
106106
return $this->shapeCollection;
107107
}
108108

109+
/**
110+
* Get collection of shapes
111+
*
112+
* @return AbstractSlide
113+
*/
114+
public function setShapeCollection($shapeCollection = array())
115+
{
116+
$this->shapeCollection = $shapeCollection;
117+
return $this;
118+
}
119+
109120
/**
110121
* Add shape to slide
111122
*

0 commit comments

Comments
 (0)