From 8e4ed9f93d404fdb89b96fc07c7034a183985b41 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 Jul 2021 23:21:56 +0200 Subject: [PATCH] #634 : Removed deprecated methods/classes --- docs/changes/1.0.0.md | 32 +- src/PhpPresentation/PhpPresentation.php | 60 - .../Shape/Chart/Type/AbstractType.php | 26 - src/PhpPresentation/Writer/PowerPoint2007.php | 42 - .../LayoutPack/AbstractLayoutPack.php | 222 -- .../PowerPoint2007/LayoutPack/PackDefault.php | 3294 ----------------- .../LayoutPack/TemplateBased.php | 204 - .../Tests/PhpPresentationTest.php | 33 - .../Tests/Shape/Chart/Type/AbstractTest.php | 18 +- .../LayoutPack/TemplateBasedTest.php | 93 - .../Tests/Writer/PowerPoint2007Test.php | 23 - 11 files changed, 40 insertions(+), 4007 deletions(-) delete mode 100644 src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/AbstractLayoutPack.php delete mode 100644 src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php delete mode 100644 src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/TemplateBased.php delete mode 100644 tests/PhpPresentation/Tests/Writer/PowerPoint2007/LayoutPack/TemplateBasedTest.php diff --git a/docs/changes/1.0.0.md b/docs/changes/1.0.0.md index 6cf8a5292..97b5a2b64 100644 --- a/docs/changes/1.0.0.md +++ b/docs/changes/1.0.0.md @@ -7,6 +7,8 @@ ## Changes - Dropped support for HHVM - @sunspikes GH-556 - PHP 7.1 is now supported - @Progi1984 GH-355 +- Added support PHP 7.4 to 8.0 & Removed support PHP < 7.1 - @Progi1984 GH-636 +- Removed deprecated methods/classes - @Progi1984 GH-650 - PhpOffice\PhpPresentation\Style\Color : Define only the transparency - @Progi1984 GH-370 - PowerPoint2007 Reader : Background Color based on SchemeColor - @Progi1984 GH-397 - PowerPoint2007 Reader : Support for hyperlinks under pictures - @ulziibuyan @@ -19,4 +21,32 @@ - ODPresentation Reader : Support for fill for image - @Progi1984 GH-370 - PowerPoint2007 Reader : Support for fill for image - @Progi1984 GH-370 - ODPresentation Writer : Support for fill for transparent image - @Progi1984 GH-370 -- PowerPoint2007 Writer : Support for fill for transparent image - @JewrassicPark GH-370 \ No newline at end of file +- PowerPoint2007 Writer : Support for fill for transparent image - @JewrassicPark GH-370 + +## Project Management +- Migrated from Travis CI to Github Actions - @Progi1984 GH-635 +- Enabled PHPStan - @Progi1984 GH-639 +- Enabled PHPCSFixer - @Progi1984 GH-637 / GH-640 +- Added link to Coveralls - @Progi1984 GH-648 +- Migrated from ReadTheDocs to MkDocs & Github Actions - @Progi1984 GH-647 +- Added Changelog to MkDocs - @Progi1984 GH-649 + +## BC Breaks +* Classes have been strict typed +* `PhpOffice\PhpPresentation\PhpPresentation` + * Removed method `getProperties()` (replaced by `getDocumentProperties()`) + * Removed method `getZoom()` (replaced by `getPresentationProperties()->getZoom()`) + * Removed method `isMarkedAsFinal()` (replaced by `getPresentationProperties()->isMarkedAsFinal()`) + * Removed method `markAsFinal($state)` (replaced by `getPresentationProperties()->markAsFinal($state)`) + * Removed method `setProperties($value)` (replaced by `setDocumentProperties()`) + * Removed method `setZoom($zoom)` (replaced by `getPresentationProperties()->setZoom($zoom)`) +* `PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType` + * Removed method `getData()` (replaced by `getSeries()`) + * Removed method `setData($value)` (replaced by `setSeries($value)`) +* `PhpOffice\PhpPresentation\Writer\PowerPoint2007` + * Removed method `getLayoutPack()` + * Removed method `setLayoutPack($pValue)` +* Removed classes : + * `PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack` + * `PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\PackDefault` + * `PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\TemplateBased` \ No newline at end of file diff --git a/src/PhpPresentation/PhpPresentation.php b/src/PhpPresentation/PhpPresentation.php index 0577bf623..91adcb8c3 100644 --- a/src/PhpPresentation/PhpPresentation.php +++ b/src/PhpPresentation/PhpPresentation.php @@ -87,26 +87,6 @@ public function __construct() $this->setLayout(new DocumentLayout()); } - /** - * Get properties. - * - * @deprecated for getDocumentProperties - */ - public function getProperties(): DocumentProperties - { - return $this->getDocumentProperties(); - } - - /** - * Set properties. - * - * @deprecated for setDocumentProperties - */ - public function setProperties(DocumentProperties $value): self - { - return $this->setDocumentProperties($value); - } - /** * Get properties. */ @@ -360,46 +340,6 @@ public function copy(): PhpPresentation return $copied; } - /** - * Mark a document as final. - * - * @deprecated for getPresentationProperties()->markAsFinal() - */ - public function markAsFinal(bool $state = true): PresentationProperties - { - return $this->getPresentationProperties()->markAsFinal($state); - } - - /** - * Return if this document is marked as final. - * - * @deprecated for getPresentationProperties()->isMarkedAsFinal() - */ - public function isMarkedAsFinal(): bool - { - return $this->getPresentationProperties()->isMarkedAsFinal(); - } - - /** - * Set the zoom of the document (in percentage). - * - * @deprecated for getPresentationProperties()->setZoom() - */ - public function setZoom(float $zoom = 1.0): PresentationProperties - { - return $this->getPresentationProperties()->setZoom($zoom); - } - - /** - * Return the zoom (in percentage). - * - * @deprecated for getPresentationProperties()->getZoom() - */ - public function getZoom(): float - { - return $this->getPresentationProperties()->getZoom(); - } - /** * @return array|ArrayObject */ diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php index 07065f0f2..99b42c430 100644 --- a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php +++ b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php @@ -134,32 +134,6 @@ public function setSeries(array $series = []) return $this; } - /** - * Get Data. - * - * @deprecated getSeries - * - * @return array - */ - public function getData(): array - { - return $this->getSeries(); - } - - /** - * Set Data. - * - * @deprecated setSeries - * - * @param array $value - * - * @return AbstractType - */ - public function setData(array $value = []) - { - return $this->setSeries($value); - } - /** * @see http://php.net/manual/en/language.oop5.cloning.php */ diff --git a/src/PhpPresentation/Writer/PowerPoint2007.php b/src/PhpPresentation/Writer/PowerPoint2007.php index 727e90efc..f3ff5f418 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007.php +++ b/src/PhpPresentation/Writer/PowerPoint2007.php @@ -22,8 +22,6 @@ use PhpOffice\Common\Adapter\Zip\ZipArchiveAdapter; use PhpOffice\PhpPresentation\HashTable; use PhpOffice\PhpPresentation\PhpPresentation; -use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack; -use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\PackDefault; /** * \PhpOffice\PhpPresentation\Writer\PowerPoint2007. @@ -44,15 +42,6 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface */ protected $diskCachingDir; - /** - * Layout pack to use. - * - * @deprecated 0.7 - * - * @var \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack - */ - protected $layoutPack; - /** * Create a new PowerPoint2007 file. * @@ -68,9 +57,6 @@ public function __construct(PhpPresentation $pPhpPresentation = null) // Set up disk caching location $this->diskCachingDir = './'; - // Set layout pack - $this->layoutPack = new PackDefault(); - // Set HashTable variables $this->oDrawingHashTable = new HashTable(); @@ -188,32 +174,4 @@ public function getDiskCachingDirectory() { return $this->diskCachingDir; } - - /** - * Get layout pack to use. - * - * @deprecated 0.7 - * - * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack - */ - public function getLayoutPack() - { - return $this->layoutPack; - } - - /** - * Set layout pack to use. - * - * @deprecated 0.7 - * - * @param \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack $pValue - * - * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007 - */ - public function setLayoutPack(AbstractLayoutPack $pValue = null) - { - $this->layoutPack = $pValue; - - return $this; - } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/AbstractLayoutPack.php b/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/AbstractLayoutPack.php deleted file mode 100644 index 101066ce3..000000000 --- a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/AbstractLayoutPack.php +++ /dev/null @@ -1,222 +0,0 @@ - - */ - protected $masterSlides = []; - - /** - * Master slide relations. - * - * Structure: - * - master id - * - id (relation id) - * - type - * - contentType - * - target (full path in OpenXML package) - * - contents (body) - * - * @var array> - */ - protected $masterSlideRels = []; - - /** - * Themes. - * - * Structure: - * - masterid - * - body - * - * @var array - */ - protected $themes = []; - - /** - * Theme relations. - * - * Structure: - * - masterid - * - id (relation id) - * - type - * - contentType - * - target (full path in OpenXML package) - * - contents (body) - * - * @var array> - */ - protected $themeRelations = []; - - /** - * Array of slide layouts. - * - * These are all an array consisting of: - * - id (int) - * - masterid (int) - * - name (string) - * - body (string) - * - * @var array - */ - protected $layouts = []; - - /** - * Layout relations. - * - * Structure: - * - layoutId (referencing layout id in layouts array) - * - id (relation id) - * - type - * - contentType - * - target (full path in OpenXML package) - * - contents (body) - * - * @var array> - */ - protected $layoutRelations = []; - - /** - * Get master slides. - * - * @return array - */ - public function getMasterSlides(): array - { - return $this->masterSlides; - } - - /** - * Get master slide relations. - * - * @return array> - */ - public function getMasterSlideRelations(): array - { - return $this->masterSlideRels; - } - - /** - * Get themes. - * - * @return array - */ - public function getThemes(): array - { - return $this->themes; - } - - /** - * Get theme relations. - * - * @return array> - */ - public function getThemeRelations(): array - { - return $this->themeRelations; - } - - /** - * Get array of slide layouts. - * - * @return array - */ - public function getLayouts() - { - return $this->layouts; - } - - /** - * Get array of slide layout relations. - * - * @return array> - */ - public function getLayoutRelations(): array - { - return $this->layoutRelations; - } - - /** - * Find specific slide layout. - * - * This is an array consisting of: - * - masterid - * - name (string) - * - body (string) - * - * @return array{'id': int, 'masterid': int, 'name': string, 'body': string} - * - * @throws \Exception - */ - public function findLayout(string $name = '', int $masterId = 1): array - { - foreach ($this->layouts as $layout) { - if ($layout['name'] == $name && $layout['masterid'] == $masterId) { - return $layout; - } - } - - throw new \Exception("Could not find slide layout $name in current layout pack."); - } - - /** - * Find specific slide layout id. - * - * @throws \Exception - */ - public function findLayoutId(string $name = ''): int - { - foreach ($this->layouts as $layoutId => $layout) { - if ($layout['name'] == $name) { - return $layoutId; - } - } - - throw new \Exception("Could not find slide layout $name in current layout pack."); - } - - /** - * Find specific slide layout name. - * - * @throws \Exception - */ - public function findLayoutName(int $idLayout): string - { - foreach ($this->layouts as $layoutId => $layout) { - if ($layoutId == $idLayout) { - return $layout['name']; - } - } - - throw new \Exception("Could not find slide layout $idLayout in current layout pack."); - } -} diff --git a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php b/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php deleted file mode 100644 index 61950932b..000000000 --- a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php +++ /dev/null @@ -1,3294 +0,0 @@ -masterSlides = [ - [ - 'masterid' => 1, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <#> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -', ], ]; - - // Master slide relations - $this->masterSlideRels = [ - //array('masterid' => '', 'id' => '', 'type' => '', 'contentType' => '', 'target' => '', 'contents' => '') - ]; - - // Theme - $this->themes = [ - [ - 'masterid' => 1, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -', ], ]; - - // Theme relations - $this->themeRelations = [ - //array('masterid' => 1, 'id' => '', 'type' => '', 'contentType' => '', 'target' => '', 'contents' => '') - ]; - - // Layouts - Layout::TITLE_SLIDE - $this->layouts[1] = [ - 'id' => 1, - 'masterid' => 1, - 'name' => Layout::TITLE_SLIDE, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master subtitle style - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::TITLE_AND_CONTENT - $this->layouts[2] = [ - 'id' => 2, - 'masterid' => 1, - 'name' => Layout::TITLE_AND_CONTENT, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::SECTION_HEADER - $this->layouts[3] = [ - 'id' => 3, - 'masterid' => 1, - 'name' => Layout::SECTION_HEADER, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::TWO_CONTENT - $this->layouts[4] = [ - 'id' => 4, - 'masterid' => 1, - 'name' => Layout::TWO_CONTENT, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::COMPARISON - $this->layouts[5] = [ - 'id' => 5, - 'masterid' => 1, - 'name' => Layout::COMPARISON, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::TITLE_ONLY - $this->layouts[6] = [ - 'id' => 6, - 'masterid' => 1, - 'name' => Layout::TITLE_ONLY, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::BLANK - $this->layouts[7] = [ - 'id' => 7, - 'masterid' => 1, - 'name' => Layout::BLANK, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::CONTENT_WITH_CAPTION - $this->layouts[8] = [ - 'id' => 8, - 'masterid' => 1, - 'name' => Layout::CONTENT_WITH_CAPTION, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::PICTURE_WITH_CAPTION - $this->layouts[9] = [ - 'id' => 9, - 'masterid' => 1, - 'name' => Layout::PICTURE_WITH_CAPTION, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::TITLE_AND_VERTICAL_TEXT - $this->layouts[10] = [ - 'id' => 10, - 'masterid' => 1, - 'name' => Layout::TITLE_AND_VERTICAL_TEXT, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layouts - Layout::VERTICAL_TITLE_AND_TEXT - $this->layouts[11] = [ - 'id' => 11, - 'masterid' => 1, - 'name' => Layout::VERTICAL_TITLE_AND_TEXT, - 'body' => ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master title style - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Click to edit Master text styles - - - - - - - Second level - - - - - - - Third level - - - - - - - Fourth level - - - - - - - Fifth level - - - - - - - - - - - - - - - - - - - - - - - 16/04/2009 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ‹#› - - - - - - - - - - -', ]; - - // Layout relations - $this->layoutRelations = [ - //array('layoutId' => 0, 'id' => '', 'type' => '', 'contentType' => '', 'target' => '', 'contents' => '') - ]; - } -} diff --git a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/TemplateBased.php b/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/TemplateBased.php deleted file mode 100644 index bd63803ed..000000000 --- a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/TemplateBased.php +++ /dev/null @@ -1,204 +0,0 @@ -masterSlideRels = []; - - // Theme relations - $this->themeRelations = []; - - // Layout relations - $this->layoutRelations = []; - - // Open package - $package = new \ZipArchive(); - $package->open($fileName); - - // Read relations and search for officeDocument - $relations = simplexml_load_string($package->getFromName('_rels/.rels')); - foreach ($relations->Relationship as $rel) { - if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument' == $rel['Type']) { - // Found office document! Search for master slide... - $presentationRels = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/_rels/' . basename($rel['Target']) . '.rels'))); - foreach ($presentationRels->Relationship as $presRel) { - if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster' == $presRel['Type']) { - // Found slide master! - $slideMasterId = str_replace('slideMaster', '', basename($presRel['Target'], '.xml')); - $this->masterSlides[] = [ - 'masterid' => (int) $slideMasterId, - 'body' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . basename($presRel['Target']))), - ]; - - // Search for theme & slide layouts - $masterRelations = simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/_rels/' . basename($presRel['Target']) . '.rels'))); - foreach ($masterRelations->Relationship as $masterRel) { - if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' == $masterRel['Type']) { - // Found theme! - $themeId = (int) str_replace('theme', '', basename($masterRel['Target'], '.xml')); - $this->themes[$themeId - 1] = [ - 'masterid' => (int) $slideMasterId, - 'body' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/' . basename($masterRel['Target']))), - ]; - - // Search for theme relations - $themeRelations = @simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/_rels/' . basename($masterRel['Target']) . '.rels'))); - if ($themeRelations && $themeRelations->Relationship) { - foreach ($themeRelations->Relationship as $themeRel) { - if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster' != $themeRel['Type'] && 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' != $themeRel['Type'] && 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' != $themeRel['Type']) { - // Theme relation - $this->themeRelations[] = [ - 'masterid' => $slideMasterId, - 'id' => $themeRel['Id'], - 'type' => $themeRel['Type'], - 'contentType' => '', - 'target' => $themeRel['Target'], - 'contents' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/' . dirname($themeRel['Target']) . '/' . basename($themeRel['Target']))), - ]; - } - } - } - } elseif ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' == $masterRel['Type']) { - // Found slide layout! - $layoutId = str_replace('slideLayout', '', basename($masterRel['Target'], '.xml')); - $layout = [ - 'id' => (int) $layoutId, - 'masterid' => (int) $slideMasterId, - 'name' => '-unknown-', - 'body' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/' . basename($masterRel['Target']))), - ]; - if (utf8_encode(utf8_decode($layout['body'])) == $layout['body']) { - $layoutXml = simplexml_load_string($layout['body']); - } else { - $layoutXml = simplexml_load_string(utf8_encode($layout['body'])); - } - $layoutXml->registerXPathNamespace('p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); - $slide = $layoutXml->xpath('/p:sldLayout/p:cSld'); - $layout['name'] = (string) $slide[0]['name']; - $this->layouts[(int) $layoutId] = $layout; - - // Search for slide layout relations - $layoutRelations = @simplexml_load_string($package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/_rels/' . basename($masterRel['Target']) . '.rels'))); - if ($layoutRelations && $layoutRelations->Relationship) { - foreach ($layoutRelations->Relationship as $layoutRel) { - if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster' != $layoutRel['Type'] && 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' != $layoutRel['Type'] && 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' != $layoutRel['Type']) { - // Layout relation - $this->layoutRelations[] = [ - 'layoutId' => $layoutId, - 'id' => $layoutRel['Id'], - 'type' => $layoutRel['Type'], - 'contentType' => '', - 'target' => $layoutRel['Target'], - 'contents' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/' . dirname($layoutRel['Target']) . '/' . basename($layoutRel['Target']))), - ]; - } - } - } - } else { - // Master slide relation - $this->masterSlideRels[] = [ - 'masterid' => $slideMasterId, - 'id' => $masterRel['Id'], - 'type' => $masterRel['Type'], - 'contentType' => '', - 'target' => $masterRel['Target'], - 'contents' => $package->getFromName($this->absoluteZipPath(dirname($rel['Target']) . '/' . dirname($presRel['Target']) . '/' . dirname($masterRel['Target']) . '/' . basename($masterRel['Target']))), - ]; - } - } - } - } - - break; - } - } - - // Sort master slides - usort($this->masterSlides, [ - "\PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\TemplateBased", - 'cmpMaster', - ]); - - // Close package - $package->close(); - } - - /** - * Compare master slides. - * - * @param array $firstSlide - * @param array $secondSlide - */ - public static function cmpMaster(array $firstSlide, array $secondSlide): int - { - if ($firstSlide['masterid'] == $secondSlide['masterid']) { - return 0; - } - - return ($firstSlide['masterid'] < $secondSlide['masterid']) ? -1 : 1; - } - - /** - * Determine absolute zip path. - */ - protected function absoluteZipPath(string $path): string - { - $path = str_replace([ - '/', - '\\', - ], DIRECTORY_SEPARATOR, $path); - $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), function (string $var) { - return (bool) strlen($var); - }); - $absolutes = []; - foreach ($parts as $part) { - if ('.' == $part) { - continue; - } - if ('..' == $part) { - array_pop($absolutes); - } else { - $absolutes[] = $part; - } - } - - return implode('/', $absolutes); - } -} diff --git a/tests/PhpPresentation/Tests/PhpPresentationTest.php b/tests/PhpPresentation/Tests/PhpPresentationTest.php index e9dd9001f..83232f0f8 100644 --- a/tests/PhpPresentation/Tests/PhpPresentationTest.php +++ b/tests/PhpPresentation/Tests/PhpPresentationTest.php @@ -52,13 +52,8 @@ public function testConstruct(): void public function testProperties(): void { $object = new PhpPresentation(); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setProperties(new DocumentProperties())); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setDocumentProperties(new DocumentProperties())); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties()); } @@ -127,32 +122,4 @@ public function testSetActiveSlideIndexException(): void $object = new PhpPresentation(); $object->setActiveSlideIndex(1); } - - /** - * @deprecated - */ - public function testMarkAsFinal(): void - { - $object = new PhpPresentation(); - $this->assertFalse($object->isMarkedAsFinal()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal(true)); - $this->assertTrue($object->isMarkedAsFinal()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal(false)); - $this->assertFalse($object->isMarkedAsFinal()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal()); - $this->assertTrue($object->isMarkedAsFinal()); - } - - /** - * @deprecated - */ - public function testZoom(): void - { - $object = new PhpPresentation(); - $this->assertEquals(1, $object->getZoom()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setZoom(0.3)); - $this->assertEquals(0.3, $object->getZoom()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setZoom()); - $this->assertEquals(1, $object->getZoom()); - } } diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php index 3e96a83b2..7cb5e0e49 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/AbstractTest.php @@ -48,20 +48,20 @@ public function testHashIndex(): void $this->assertEquals($value, $object->getHashIndex()); } - public function testData(): void + public function testSeries(): void { /** @var AbstractType $stub */ $stub = $this->getMockForAbstractClass(AbstractType::class); - $this->assertEmpty($stub->getData()); - $this->assertIsArray($stub->getData()); + $this->assertEmpty($stub->getSeries()); + $this->assertIsArray($stub->getSeries()); $arraySeries = [ new Series(), new Series(), ]; - $this->assertInstanceOf(AbstractType::class, $stub->setData($arraySeries)); - $this->assertIsArray($stub->getData()); - $this->assertCount(count($arraySeries), $stub->getData()); + $this->assertInstanceOf(AbstractType::class, $stub->setSeries($arraySeries)); + $this->assertIsArray($stub->getSeries()); + $this->assertCount(count($arraySeries), $stub->getSeries()); } public function testClone(): void @@ -75,11 +75,11 @@ public function testClone(): void /** @var AbstractType $stub */ $stub = $this->getMockForAbstractClass(AbstractType::class); - $stub->setData($arraySeries); + $stub->setSeries($arraySeries); $clone = clone $stub; $this->assertInstanceOf(AbstractType::class, $clone); - $this->assertIsArray($stub->getData()); - $this->assertCount(count($arraySeries), $stub->getData()); + $this->assertIsArray($stub->getSeries()); + $this->assertCount(count($arraySeries), $stub->getSeries()); } } diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/LayoutPack/TemplateBasedTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/LayoutPack/TemplateBasedTest.php deleted file mode 100644 index 2373ef47e..000000000 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/LayoutPack/TemplateBasedTest.php +++ /dev/null @@ -1,93 +0,0 @@ -getLayouts(); - - foreach ($layouts as $layout) { - $foundLayout = $templateBased->findLayout($layout['name']); - $this->assertEquals($layout, $foundLayout); - } - } - - public function testFindLayoutException(): void - { - $this->expectException(\Exception::class); - - $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.pptx'; - $templateBased = new TemplateBased($file); - $name = 'Invalid'; - $templateBased->findLayout($name); - } - - public function testFindLayoutId(): void - { - $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.pptx'; - $templateBased = new TemplateBased($file); - $layouts = $templateBased->getLayouts(); - - foreach ($layouts as $layout) { - $foundLayoutId = $templateBased->findLayoutId($layout['name']); - $this->assertEquals($layout['id'], $foundLayoutId); - } - } - - public function testFindLayoutIdException(): void - { - $this->expectException(\Exception::class); - - $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.pptx'; - $templateBased = new TemplateBased($file); - $name = 'Invalid'; - $templateBased->findLayoutId($name); - } - - public function testFindLayoutName(): void - { - $oLayout = new PackDefault(); - foreach ($oLayout->getLayouts() as $keyLayout => $layout) { - $foundLayoutName = $oLayout->findLayoutName($keyLayout); - $this->assertEquals($layout['name'], $foundLayoutName); - } - } - - public function testFindLayoutNameException(): void - { - $this->expectException(\Exception::class); - - $oLayout = new PackDefault(); - $oLayout->findLayoutName(1000); - } -} diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php index 564e5ba63..9ce81f02e 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php @@ -4,7 +4,6 @@ use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase; use PhpOffice\PhpPresentation\Writer\PowerPoint2007; -use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack; /** * Test class for PowerPoint2007. @@ -20,13 +19,10 @@ class PowerPoint2007Test extends PhpPresentationTestCase */ public function testConstruct(): void { - $objectPrefix = 'PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007\\'; - $object = new PowerPoint2007($this->oPresentation); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation()); $this->assertEquals('./', $object->getDiskCachingDirectory()); - $this->assertInstanceOf("{$objectPrefix}LayoutPack\\PackDefault", $object->getLayoutPack()); } /** @@ -109,25 +105,6 @@ public function testCachingException(): void $object->setUseDiskCaching(true, 'foo'); } - /** - * Test LayoutPack. - * - * @deprecated 0.7 - */ - public function testLayoutPack(): void - { - /** @var AbstractLayoutPack $oLayoutPack */ - $oLayoutPack = $this->getMockBuilder(AbstractLayoutPack::class)->getMock(); - - $object = new PowerPoint2007(); - - $this->assertInstanceOf(AbstractLayoutPack::class, $object->getLayoutPack()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007', $object->setLayoutPack()); - $this->assertNull($object->getLayoutPack()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007', $object->setLayoutPack($oLayoutPack)); - $this->assertInstanceOf(AbstractLayoutPack::class, $object->getLayoutPack()); - } - public function testZoom(): void { $this->assertZipXmlElementExists('ppt/viewProps.xml', '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx');