Skip to content

Commit 3ed8e2b

Browse files
authored
Merge pull request #545 from Progi1984/issue117
#117 : Geometric form in PowerPoint2007 Writer
2 parents f996495 + 043fe79 commit 3ed8e2b

File tree

9 files changed

+613
-24
lines changed

9 files changed

+613
-24
lines changed

docs/changes/1.0.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
- ODPresentation Writer
7474
- PowerPoint2007 Reader
7575
- PowerPoint2007 Writer
76+
- Support for Geometric form/AutoShape - [@Progi1984](https://github.com/Progi1984) GH-545
77+
- PowerPoint2007 Writer
7678

7779
## Project Management
7880
- Migrated from Travis CI to Github Actions - [@Progi1984](https://github.com/Progi1984) GH-635

docs/index.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ Documentation.
2727
- Supports hyperlinks and rich-text strings
2828
- Add images with different styles (positioning, rotation, shadow)
2929
- Set printing options (header, footer, page margins, paper size, orientation)
30-
- Output to different file formats: PowerPoint 2007 (.pptx), OpenDocument Presentation (.odp), Serialized Spreadsheet)
30+
- Input from different file formats:
31+
- PowerPoint 97 (.ppt)
32+
- PowerPoint 2007 (.pptx)
33+
- OpenDocument Presentation (.odp)
34+
- Serialized Spreadsheet
35+
- Output to different file formats:
36+
- PowerPoint 2007 (.pptx)
37+
- OpenDocument Presentation (.odp)
38+
- Serialized Spreadsheet
3139
- ... and lots of other things!
3240

3341
## File formats
@@ -44,7 +52,8 @@ Below are the supported features for each file formats.
4452
| | Custom | | :material-check: | | :material-check: |
4553
| **Slides** | | | :material-check: | | :material-check: |
4654
| | Name | | :material-check: | | |
47-
| **Element Shape** | Image | | :material-check: | | :material-check: |
55+
| **Element Shape** | AutoShape | | | | :material-check: |
56+
| | Image | | :material-check: | | :material-check: |
4857
| | Hyperlink | | :material-check: | | :material-check: |
4958
| | Line | | :material-check: | | :material-check: |
5059
| | MemoryImage | | :material-check: | | :material-check: |
@@ -64,27 +73,28 @@ Below are the supported features for each file formats.
6473

6574
### Readers
6675

67-
| Features | | HTML | ODP | PDF | PPT | PPTX |
68-
|---------------------------|----------------------|--------|-------|-------|-------|-------|
69-
| **Document** | Mark as final | | | | | :material-check: |
70-
| **Document Properties** | Standard | | :material-check: | | | :material-check: |
71-
| | Custom | | :material-check: | | | :material-check: |
72-
| **Slides** | | | :material-check: | | | :material-check: |
73-
| | Name | | | | | | :material-check: | |
74-
| **Element Shape** | Image | | :material-check: | | :material-check: | :material-check: |
75-
| | Hyperlink | | :material-check: | | :material-check: | :material-check: |
76-
| | RichText | | :material-check: | | :material-check: | :material-check: |
77-
| | Table | | | | | |
78-
| | Text | | :material-check: | | :material-check: | :material-check: |
79-
| **Charts** | Area | | | | | |
80-
| | Bar | | | | | |
81-
| | Bar3D | | | | | |
82-
| | Doughnut | | | | | |
83-
| | Line | | | | | |
84-
| | Pie | | | | | |
85-
| | Pie3D | | | | | |
86-
| | Radar | | | | | |
87-
| | Scatter | | | | | |
76+
| Features | | ODP | PPT | PPTX |
77+
|---------------------------|----------------------|-------|-------|-------|
78+
| **Document** | Mark as final | | | :material-check: |
79+
| **Document Properties** | Standard | :material-check: | | :material-check: |
80+
| | Custom | :material-check: | | :material-check: |
81+
| **Slides** | | :material-check: | | :material-check: |
82+
| | Name | | | |
83+
| **Element Shape** | AutoShape | | | |
84+
| | Image | :material-check: | :material-check: | :material-check: |
85+
| | Hyperlink | :material-check: | :material-check: | :material-check: |
86+
| | RichText | :material-check: | :material-check: | :material-check: |
87+
| | Table | | | |
88+
| | Text | :material-check: | :material-check: | :material-check: |
89+
| **Charts** | Area | | | |
90+
| | Bar | | | |
91+
| | Bar3D | | | |
92+
| | Doughnut | | | |
93+
| | Line | | | |
94+
| | Pie | | | |
95+
| | Pie3D | | | |
96+
| | Radar | | | |
97+
| | Scatter | | | |
8898

8999

90100
## Contributing

docs/usage/shapes/autoshape.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# AutoShape
2+
3+
!!! warning
4+
Available only on the PowerPoint2007 Writer
5+
6+
To create a geometric form, create an object `AutoShape` and add it to slide.
7+
8+
``` php
9+
<?php
10+
11+
use PhpOffice\PhpPresentation\Shape\AutoShape;
12+
13+
$shape = new AutoShape();
14+
$slide->addShape($shape)
15+
```
16+
17+
## Text
18+
19+
You can define text of the geometric form with `setText` method.
20+
21+
``` php
22+
<?php
23+
24+
use PhpOffice\PhpPresentation\Shape\AutoShape;
25+
26+
$shape = new AutoShape();
27+
// Define the text
28+
$shape->setText('ABC');
29+
// Return the text
30+
$shape->getText();
31+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ nav:
5454
- Layouts: 'usage/slides/layout.md'
5555
- Shapes:
5656
- Introduction: 'usage/shapes/introduction.md'
57+
- AutoShape: 'usage/shapes/autoshape.md'
5758
- Chart: 'usage/shapes/chart.md'
5859
- Comment: 'usage/shapes/comment.md'
5960
- Drawing: 'usage/shapes/drawing.md'

samples/Sample_21_AutoShape.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
include_once 'Sample_Header.php';
4+
5+
use PhpOffice\PhpPresentation\PhpPresentation;
6+
use PhpOffice\PhpPresentation\Shape\AutoShape;
7+
use PhpOffice\PhpPresentation\Style\Color;
8+
use PhpOffice\PhpPresentation\Style\Fill;
9+
10+
// Create new PHPPresentation object
11+
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
12+
$objPHPPresentation = new PhpPresentation();
13+
// Set properties
14+
echo date('H:i:s') . ' Set properties' . EOL;
15+
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
16+
->setLastModifiedBy('PHPPresentation Team')
17+
->setTitle('Sample 21 AutoShape')
18+
->setSubject('Sample 21 Subject')
19+
->setDescription('Sample 21 Description')
20+
->setKeywords('office 2007 openxml libreoffice odt php')
21+
->setCategory('Sample Category');
22+
23+
// Create slide
24+
echo date('H:i:s') . ' Create slide' . EOL;
25+
$currentSlide = $objPHPPresentation->getActiveSlide();
26+
27+
$autoShape = new AutoShape();
28+
$autoShape->setType(AutoShape::TYPE_PENTAGON)
29+
->setText('Step 1')
30+
->setOffsetX(93)
31+
->setOffsetY(30)
32+
->setWidthAndHeight(175, 100);
33+
$autoShape->getOutline()
34+
->setWidth(0)
35+
->getFill()
36+
->setFillType(Fill::FILL_SOLID)
37+
->setStartColor(new Color(Color::COLOR_BLACK));
38+
$autoShape->getFill()
39+
->setFillType(Fill::FILL_SOLID)
40+
->setStartColor(new Color('804F81BD'));
41+
$currentSlide->addShape($autoShape);
42+
43+
for ($inc = 1; $inc < 5; ++$inc) {
44+
$autoShape = new AutoShape();
45+
$autoShape->setType(AutoShape::TYPE_CHEVRON)
46+
->setText('Step ' . ($inc + 1))
47+
->setOffsetX(93 + $inc * 100)
48+
->setOffsetY(30)
49+
->setWidthAndHeight(175, 100);
50+
$autoShape->getOutline()
51+
->setWidth($inc)
52+
->getFill()
53+
->setFillType(Fill::FILL_SOLID)
54+
->setStartColor(new Color(Color::COLOR_BLACK));
55+
$autoShape->getFill()
56+
->setFillType(Fill::FILL_SOLID)
57+
->setStartColor(new Color('FF4F81BD'));
58+
$currentSlide->addShape($autoShape);
59+
}
60+
61+
// Save file
62+
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
63+
if (!CLI) {
64+
include_once 'Sample_Footer.php';
65+
}

0 commit comments

Comments
 (0)