Skip to content

Commit e1c938c

Browse files
Merge remote-tracking branch 'origin/develop' into feat-axis-options
2 parents 7f17f8e + 47046dd commit e1c938c

File tree

120 files changed

+1474
-1160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+1474
-1160
lines changed

.github/workflows/php.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
php: ['7.1', '7.2', '7.3', '7.4', '8.0'] #, '8.1'
50+
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
5151
steps:
5252
- name: Setup PHP
5353
uses: shivammathur/setup-php@v2
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
php: ['7.1', '7.2', '7.3', '7.4', '8.0'] #, '8.1'
71+
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
7272
steps:
7373
- name: Setup PHP
7474
uses: shivammathur/setup-php@v2
@@ -93,3 +93,26 @@ jobs:
9393
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
9494
chmod +x php-coveralls.phar
9595
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
96+
97+
samples:
98+
name: Check samples
99+
runs-on: ubuntu-latest
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
104+
steps:
105+
- name: Setup PHP
106+
uses: shivammathur/setup-php@v2
107+
with:
108+
php-version: ${{ matrix.php }}
109+
extensions: gd, xml, zip
110+
coverage: xdebug
111+
112+
- uses: actions/checkout@v2
113+
114+
- name: Composer Install
115+
run: composer install --ansi --prefer-dist --no-interaction --no-progress
116+
117+
- name: Generate samples files
118+
run: composer run samples

composer.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
"php": "^7.1|^8.0",
2323
"ext-xml": "*",
2424
"ext-zip": "*",
25-
"phpoffice/common": "dev-develop",
25+
"phpoffice/common": "^1",
2626
"phpoffice/phpspreadsheet": "^1.9.0"
2727
},
2828
"require-dev": {
2929
"phpunit/phpunit": ">=7.0",
3030
"phpmd/phpmd": "2.*",
31-
"phpstan/phpstan": "^0.12.88"
31+
"phpstan/phpstan": "^0.12.88 || ^1.0.0"
3232
},
3333
"suggest": {
3434
"ext-gd": "Required to add images"
@@ -37,5 +37,31 @@
3737
"psr-4": {
3838
"PhpOffice\\PhpPresentation\\": "src/PhpPresentation/"
3939
}
40+
},
41+
"scripts": {
42+
"samples": [
43+
"php samples/Sample_01_Complex.php",
44+
"php samples/Sample_01_Simple.php",
45+
"php samples/Sample_03_Image.php",
46+
"php samples/Sample_03_Video.php",
47+
"php samples/Sample_04_Table.php",
48+
"php samples/Sample_05_Chart_Line.php",
49+
"php samples/Sample_05_Chart.php",
50+
"php samples/Sample_05_Chart_with_PhpSpreadsheet.php",
51+
"php samples/Sample_06_Fill.php",
52+
"php samples/Sample_07_Border.php",
53+
"php samples/Sample_08_Group.php",
54+
"php samples/Sample_09_SlideNote.php",
55+
"php samples/Sample_10_Transition.php",
56+
"php samples/Sample_11_Shape.php",
57+
"php samples/Sample_13_MarkAsFinal.php",
58+
"php samples/Sample_14_Zoom.php",
59+
"php samples/Sample_15_Background.php",
60+
"php samples/Sample_16_Thumbnail.php",
61+
"php samples/Sample_17_Comment.php",
62+
"php samples/Sample_18_Animation.php",
63+
"php samples/Sample_19_SlideMaster.php",
64+
"php samples/Sample_20_ExternalSlide.php"
65+
]
4066
}
4167
}

docs/changes/1.0.0.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
# 1.0.0 - WIP
1+
# 1.0.0
22

33
## Bugfix
4-
- PowerPoint2007 Writer : Text is subscripted when set superscript to false - [[@qmachard]](https://github.com/qmachard])(https://github.com/qmachard) GH-360
5-
- Core : Defining width & height of a shape don't return any error if width & height were equal to 0 - [[@surger]](https://github.com/surger])(https://github.com/surger) GH-555
6-
- ODPresentation Writer : Display axis title depending the visibility - [[@Progi1984]](https://github.com/Progi1984])(https://github.com/Progi1984) GH-410
4+
- PowerPoint2007 Writer : Text is subscripted when set superscript to false - [@qmachard](https://github.com/qmachard) GH-360
5+
- Core : Defining width & height of a shape don't return any error if width & height were equal to 0 - [@surger](https://github.com/surger) GH-555
6+
- ODPresentation Writer : Display axis title depending the visibility - [@Progi1984](https://github.com/Progi1984) GH-410
77

88
## Changes
99
- Dropped support for HHVM - [@sunspikes](https://github.com/sunspikes) GH-556
1010
- PHP 7.1 is now supported - [@Progi1984](https://github.com/Progi1984) GH-355
1111
- Added support PHP 7.4 to 8.0 & Removed support PHP < 7.1 - [@Progi1984](https://github.com/Progi1984) GH-636
12+
- Added support for PHP 8.1 - [@Progi1984](https://github.com/Progi1984) GH-661
1213
- Removed deprecated methods/classes - [@Progi1984](https://github.com/Progi1984) GH-650
1314
- Migrated use of PHPExcel to PhpSpreadsheet - [@Progi1984](https://github.com/Progi1984) GH-652
1415
- PhpOffice\PhpPresentation\Style\Color : Define only the transparency - [@Progi1984](https://github.com/Progi1984) GH-370

docs/changes/1.1.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 1.0.0 - WIP
2+
3+
## Features
4+
5+
- Support for Hyperlink Text Color - [@MartynasJanu](https://github.com/MartynasJanu) & [@Progi1984](https://github.com/Progi1984) GH-682
6+
- PowerPoint2007 Reader
7+
- PowerPoint2007 Writer

docs/usage/shapes/richtext.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,42 @@ $richText->setColumnSpacing(200);
5050
$columnSpacing = $richText->getColumnSpacing();
5151
```
5252

53+
## Hyperlink
54+
55+
For a rich text, you can define the hyperlink.
56+
57+
Example:
58+
59+
```php
60+
<?php
61+
62+
use PhpOffice\PhpPresentation\Shape\RichText;
63+
64+
$richText = new RichText();
65+
$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');
66+
67+
```
68+
69+
### Use of Text Color
70+
71+
!!! warning
72+
Available only on the PowerPoint2007 Reader/Writer
73+
74+
Hyperlinks can be set to use the text color instead of the default theme color.
75+
76+
Example:
77+
78+
```php
79+
<?php
80+
81+
use PhpOffice\PhpPresentation\Shape\RichText;
82+
83+
$richText = new RichText();
84+
$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');
85+
$richText->getHyperlink()->setIsTextColorUsed(true);
86+
87+
```
88+
5389
## Paragraph
5490
### Bullet
5591

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ nav:
6767
- FAQ: 'faq.md'
6868
- Credits: 'credits.md'
6969
- Releases:
70-
- '1.0.0 (WIP)': 'changes/1.0.0.md'
70+
- '1.1.0 (WIP)': 'changes/1.1.0.md'
71+
- '1.0.0': 'changes/1.0.0.md'
7172
- '0.9.0': 'changes/0.9.0.md'
7273
- '0.8.0': 'changes/0.8.0.md'
7374
- '0.7.0': 'changes/0.7.0.md'

samples/Sample_03_Video.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
$shape = new Media();
1818
$shape->setName('Video')
1919
->setDescription('Video')
20-
->setPath('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? './resources/sintel_trailer-480p.wmv' : './resources/sintel_trailer-480p.ogv')
20+
->setPath(
21+
__DIR__ . '/resources/sintel_trailer-480p' .
22+
('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? '.wmv' : '.ogv')
23+
)
2124
->setResizeProportional(false)
2225
->setHeight(90)
2326
->setWidth(90)

samples/Sample_08_Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
$shape = $currentGroup->createDrawingShape();
3030
$shape->setName('PHPPresentation logo')
3131
->setDescription('PHPPresentation logo')
32-
->setPath('./resources/phppowerpoint_logo.gif')
32+
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
3333
->setHeight(36)
3434
->setOffsetX(10)
3535
->setOffsetY(10);

samples/Sample_09_SlideNote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$shape = $currentSlide->createDrawingShape();
2525
$shape->setName('PHPPresentation logo')
2626
->setDescription('PHPPresentation logo')
27-
->setPath('./resources/phppowerpoint_logo.gif')
27+
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
2828
->setHeight(36)
2929
->setOffsetX(10)
3030
->setOffsetY(10);

samples/Sample_10_Transition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$shapeDrawing = $slide0->createDrawingShape();
3131
$shapeDrawing->setName('PHPPresentation logo')
3232
->setDescription('PHPPresentation logo')
33-
->setPath('./resources/phppowerpoint_logo.gif')
33+
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
3434
->setHeight(36)
3535
->setOffsetX(10)
3636
->setOffsetY(10);

samples/Sample_13_MarkAsFinal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$objPHPPresentation = new PhpPresentation();
1010

1111
// Mark the document as final
12-
$objPHPPresentation->markAsFinal(true);
12+
$objPHPPresentation->getPresentationProperties()->markAsFinal(true);
1313

1414
// Create slide
1515
echo date('H:i:s') . ' Create slide' . EOL;

samples/Sample_15_Background.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
3434
*/
3535
$oBkgImage = new Image();
36-
$oBkgImage->setPath('./resources/background.jpg');
36+
$oBkgImage->setPath(__DIR__ . '/resources/background.jpg');
3737
$oSlide2->setBackground($oBkgImage);
3838

3939
// Save file

samples/Sample_19_SlideMaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
$shape = $currentSlide->createDrawingShape();
8181
$shape->setName('PHPPresentation logo')
8282
->setDescription('PHPPresentation logo')
83-
->setPath('./resources/phppowerpoint_logo.gif')
83+
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
8484
->setHeight(36)
8585
->setOffsetX(10)
8686
->setOffsetY(10);

samples/Sample_Header.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
// Set writers
4646
$writers = ['PowerPoint2007' => 'pptx', 'ODPresentation' => 'odp'];
4747

48-
// Return to the caller script when runs by CLI
49-
if (CLI) {
50-
return;
51-
}
52-
5348
// Set titles and names
5449
$pageHeading = str_replace('_', ' ', SCRIPT_FILENAME);
5550
$pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - ";
@@ -59,7 +54,7 @@
5954
$oShapeDrawing = new Drawing\File();
6055
$oShapeDrawing->setName('PHPPresentation logo')
6156
->setDescription('PHPPresentation logo')
62-
->setPath('./resources/phppowerpoint_logo.gif')
57+
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
6358
->setHeight(36)
6459
->setOffsetX(10)
6560
->setOffsetY(10);
@@ -80,6 +75,11 @@
8075
->setSize(60)
8176
->setColor(new Color('FFE06B20'));
8277

78+
// Return to the caller script when runs by CLI
79+
if (CLI) {
80+
return;
81+
}
82+
8383
// Populate samples
8484
$files = [];
8585
if ($handle = opendir('.')) {
@@ -88,12 +88,17 @@
8888
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file));
8989
$group = substr($name, 0, 1);
9090
if (!isset($files[$group])) {
91-
$files[$group] = '';
91+
$files[$group] = [];
9292
}
93-
$files[$group] .= "<li><a href='{$file}'>{$name}</a></li>";
93+
$files[$group][$name] = "<li><a href='{$file}'>{$name}</a></li>";
9494
}
9595
}
9696
closedir($handle);
97+
98+
foreach ($files as $group => $a) {
99+
natsort($files[$group]);
100+
}
101+
ksort($files);
97102
}
98103

99104
/**
@@ -497,10 +502,10 @@ protected function getConstantName($class, $search, $startWith = '')
497502
</div>
498503
<div class="navbar-collapse collapse">
499504
<ul class="nav navbar-nav">
500-
<?php foreach ($files as $key => $fileStr) { ?>
505+
<?php foreach ($files as $key => $groupfiles) { ?>
501506
<li class="dropdown active">
502507
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-code fa-lg"></i>&nbsp;Samples <?php echo $key; ?>x<strong class="caret"></strong></a>
503-
<ul class="dropdown-menu"><?php echo $fileStr; ?></ul>
508+
<ul class="dropdown-menu"><?php echo implode('', $groupfiles); ?></ul>
504509
</li>
505510
<?php } ?>
506511
</ul>

samples/results/.gitkeep

Whitespace-only changes.

src/PhpPresentation/AbstractShape.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
namespace PhpOffice\PhpPresentation;
2222

23+
use PhpOffice\PhpPresentation\Exception\ShapeContainerAlreadyAssignedException;
2324
use PhpOffice\PhpPresentation\Shape\Hyperlink;
2425
use PhpOffice\PhpPresentation\Shape\Placeholder;
2526
use PhpOffice\PhpPresentation\Style\Border;
@@ -146,7 +147,7 @@ public function getContainer(): ?ShapeContainerInterface
146147
* @param ShapeContainerInterface $pValue
147148
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
148149
*
149-
* @throws \Exception
150+
* @throws ShapeContainerAlreadyAssignedException
150151
*
151152
* @return $this
152153
*/
@@ -175,7 +176,7 @@ public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideO
175176
// Set new \PhpOffice\PhpPresentation\Slide
176177
$this->setContainer($pValue);
177178
} else {
178-
throw new \Exception(sprintf('A %s has already been assigned. Shapes can only exist on one %s.', ShapeContainerInterface::class, ShapeContainerInterface::class));
179+
throw new ShapeContainerAlreadyAssignedException(self::class);
179180
}
180181
}
181182

@@ -328,8 +329,6 @@ public function getShadow(): ?Shadow
328329
}
329330

330331
/**
331-
* @throws \Exception
332-
*
333332
* @return $this
334333
*/
335334
public function setShadow(Shadow $pValue = null)
@@ -350,9 +349,7 @@ public function hasHyperlink()
350349
}
351350

352351
/**
353-
* Get Hyperlink.
354-
*
355-
* @throws \Exception
352+
* Get Hyperlink
356353
*/
357354
public function getHyperlink(): Hyperlink
358355
{
@@ -364,9 +361,7 @@ public function getHyperlink(): Hyperlink
364361
}
365362

366363
/**
367-
* Set Hyperlink.
368-
*
369-
* @throws \Exception
364+
* Set Hyperlink
370365
*/
371366
public function setHyperlink(Hyperlink $pHyperlink = null): self
372367
{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* This file is part of PHPPresentation - A pure PHP library for reading and writing
4+
* presentations documents.
5+
*
6+
* PHPPresentation is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12+
*
13+
* @see https://github.com/PHPOffice/PHPPresentation
14+
*
15+
* @copyright 2009-2015 PHPPresentation contributors
16+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace PhpOffice\PhpPresentation\Exception;
22+
23+
class DirectoryNotFoundException extends PhpPresentationException
24+
{
25+
public function __construct(string $path)
26+
{
27+
parent::__construct(sprintf(
28+
'The directory %s doesn\'t exist',
29+
$path
30+
));
31+
}
32+
}

0 commit comments

Comments
 (0)