From 88753ebe2ef5100849161c6ebb063c49f7cab754 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Sun, 8 Jan 2017 18:13:23 +0100 Subject: [PATCH 01/31] add ppt 2007 xsd schema test and use percentage format --- .../AbstractDecoratorWriter.php | 6 +- .../PowerPoint2007/LayoutPack/PackDefault.php | 20 +- .../Writer/PowerPoint2007/PptCharts.php | 24 +- .../Writer/PowerPoint2007/PptSlides.php | 2 +- .../Writer/PowerPoint2007/PptTheme.php | 94 +- .../Tests/Shape/Chart/AxisTest.php | 2 +- .../Tests/Shape/Chart/GridlinesTest.php | 2 +- .../Tests/Shape/CommentTest.php | 2 +- .../Writer/PowerPoint2007/PptSlidesTest.php | 21 +- .../Writer/PowerPoint2007/SchemaTest.php | 482 ++ .../Tests/Writer/PowerPoint2007Test.php | 2 +- tests/resources/schema/ooxml/dml-chart.xsd | 1449 ++++++ .../schema/ooxml/dml-chartDrawing.xsd | 144 + tests/resources/schema/ooxml/dml-diagram.xsd | 1084 ++++ .../schema/ooxml/dml-lockedCanvas.xsd | 9 + tests/resources/schema/ooxml/dml-main.xsd | 3041 ++++++++++++ tests/resources/schema/ooxml/dml-picture.xsd | 22 + .../schema/ooxml/dml-spreadsheetDrawing.xsd | 184 + .../ooxml/dml-wordprocessingDrawing.xsd | 283 ++ tests/resources/schema/ooxml/pml.xsd | 1617 ++++++ .../shared-additionalCharacteristics.xsd | 28 + .../schema/ooxml/shared-bibliography.xsd | 144 + .../schema/ooxml/shared-commonSimpleTypes.xsd | 125 + .../ooxml/shared-customXmlDataProperties.xsd | 25 + .../shared-customXmlSchemaProperties.xsd | 18 + .../ooxml/shared-documentPropertiesCustom.xsd | 59 + .../shared-documentPropertiesExtended.xsd | 56 + .../shared-documentPropertiesVariantTypes.xsd | 195 + tests/resources/schema/ooxml/shared-math.xsd | 582 +++ .../ooxml/shared-relationshipReference.xsd | 23 + tests/resources/schema/ooxml/sml.xsd | 4404 +++++++++++++++++ tests/resources/schema/ooxml/wml.xsd | 3460 +++++++++++++ 32 files changed, 17521 insertions(+), 88 deletions(-) create mode 100644 tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php create mode 100644 tests/resources/schema/ooxml/dml-chart.xsd create mode 100644 tests/resources/schema/ooxml/dml-chartDrawing.xsd create mode 100644 tests/resources/schema/ooxml/dml-diagram.xsd create mode 100644 tests/resources/schema/ooxml/dml-lockedCanvas.xsd create mode 100644 tests/resources/schema/ooxml/dml-main.xsd create mode 100644 tests/resources/schema/ooxml/dml-picture.xsd create mode 100644 tests/resources/schema/ooxml/dml-spreadsheetDrawing.xsd create mode 100644 tests/resources/schema/ooxml/dml-wordprocessingDrawing.xsd create mode 100644 tests/resources/schema/ooxml/pml.xsd create mode 100644 tests/resources/schema/ooxml/shared-additionalCharacteristics.xsd create mode 100644 tests/resources/schema/ooxml/shared-bibliography.xsd create mode 100644 tests/resources/schema/ooxml/shared-commonSimpleTypes.xsd create mode 100644 tests/resources/schema/ooxml/shared-customXmlDataProperties.xsd create mode 100644 tests/resources/schema/ooxml/shared-customXmlSchemaProperties.xsd create mode 100644 tests/resources/schema/ooxml/shared-documentPropertiesCustom.xsd create mode 100644 tests/resources/schema/ooxml/shared-documentPropertiesExtended.xsd create mode 100644 tests/resources/schema/ooxml/shared-documentPropertiesVariantTypes.xsd create mode 100644 tests/resources/schema/ooxml/shared-math.xsd create mode 100644 tests/resources/schema/ooxml/shared-relationshipReference.xsd create mode 100644 tests/resources/schema/ooxml/sml.xsd create mode 100644 tests/resources/schema/ooxml/wml.xsd diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php index 6338b2a94..0b8ce2c09 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php @@ -130,7 +130,7 @@ protected function writeColor(XMLWriter $objWriter, Color $color, $alpha = null) // a:alpha $objWriter->startElement('a:alpha'); - $objWriter->writeAttribute('val', $alpha * 1000); + $objWriter->writeAttribute('val', $alpha . '%'); $objWriter->endElement(); $objWriter->endElement(); @@ -201,13 +201,13 @@ protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill) $objWriter->startElement('a:gsLst'); // a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', '0'); + $objWriter->writeAttribute('pos', '0%'); $this->writeColor($objWriter, $pFill->getStartColor()); $objWriter->endElement(); // a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', '100000'); + $objWriter->writeAttribute('pos', '100%'); $this->writeColor($objWriter, $pFill->getEndColor()); $objWriter->endElement(); diff --git a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php b/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php index d1bd3b8ed..0df0c01ce 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/PackDefault.php @@ -306,7 +306,7 @@ public function __construct() - + @@ -321,7 +321,7 @@ public function __construct() - + @@ -336,7 +336,7 @@ public function __construct() - + @@ -351,7 +351,7 @@ public function __construct() - + @@ -366,7 +366,7 @@ public function __construct() - + @@ -381,7 +381,7 @@ public function __construct() - + @@ -396,7 +396,7 @@ public function __construct() - + @@ -411,7 +411,7 @@ public function __construct() - + @@ -426,7 +426,7 @@ public function __construct() - + @@ -794,7 +794,7 @@ public function __construct() - + diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index c8b9ee0e6..968012130 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -99,7 +99,7 @@ public function writeChart(Chart $chart) // c:hPercent $objWriter->startElement('c:hPercent'); - $objWriter->writeAttribute('val', $chart->getView3D()->getHeightPercent()); + $objWriter->writeAttribute('val', $chart->getView3D()->getHeightPercent() . '%'); $objWriter->endElement(); // c:rotY @@ -109,7 +109,7 @@ public function writeChart(Chart $chart) // c:depthPercent $objWriter->startElement('c:depthPercent'); - $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent()); + $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent() . '%'); $objWriter->endElement(); // c:rAngAx @@ -1629,6 +1629,15 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, $includeSh $this->writeSingleValueOrReference($objWriter, $includeSheet, $series->getTitle(), $coords); $objWriter->endElement(); + // c:spPr + $objWriter->startElement('c:spPr'); + // Write fill + $this->writeFill($objWriter, $series->getFill()); + // Write outline + $this->writeOutline($objWriter, $series->getOutline()); + // ## c:spPr + $objWriter->endElement(); + // Marker $this->writeSeriesMarker($objWriter, $series->getMarker()); @@ -1705,15 +1714,6 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, $includeSh // > c:dLbls $objWriter->endElement(); - // c:spPr - $objWriter->startElement('c:spPr'); - // Write fill - $this->writeFill($objWriter, $series->getFill()); - // Write outline - $this->writeOutline($objWriter, $series->getOutline()); - // ## c:spPr - $objWriter->endElement(); - // Write X axis data $axisXData = array_keys($series->getValues()); @@ -2164,7 +2164,7 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis) // c:lblOffset $objWriter->startElement('c:lblOffset'); - $objWriter->writeAttribute('val', '100'); + $objWriter->writeAttribute('val', '100%'); $objWriter->endElement(); } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php index b104b4c80..16e959ef2 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php @@ -1446,7 +1446,7 @@ protected function writeParagraphs(XMLWriter $objWriter, $paragraphs, $bIsPlaceh $objWriter->startElement('a:lnSpc'); $objWriter->startElement('a:spcPct'); - $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000); + $objWriter->writeAttribute('val', $paragraph->getLineSpacing() . '%'); $objWriter->endElement(); $objWriter->endElement(); diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php b/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php index 68082f30e..81dd52153 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php @@ -199,7 +199,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 0); + $objWriter->writeAttribute('pos', '0%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -207,12 +207,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:tint $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 50000); + $objWriter->writeAttribute('val', '50%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 300000); + $objWriter->writeAttribute('val', '300%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -223,7 +223,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 35000); + $objWriter->writeAttribute('pos', '35%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -231,12 +231,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:tint $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 37000); + $objWriter->writeAttribute('val', '37%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 300000); + $objWriter->writeAttribute('val', '300%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -247,7 +247,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 100000); + $objWriter->writeAttribute('pos', '100%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -255,12 +255,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:tint $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 15000); + $objWriter->writeAttribute('val', '15%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 350000); + $objWriter->writeAttribute('val', '350%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -290,7 +290,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 0); + $objWriter->writeAttribute('pos', '0%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -298,12 +298,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 51000); + $objWriter->writeAttribute('val', '51%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 130000); + $objWriter->writeAttribute('val', '130%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -314,7 +314,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 80000); + $objWriter->writeAttribute('pos', '80%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -322,12 +322,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 93000); + $objWriter->writeAttribute('val', '93%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 130000); + $objWriter->writeAttribute('val', '130%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -338,7 +338,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 100000); + $objWriter->writeAttribute('pos', '100%'); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -346,12 +346,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 94000); + $objWriter->writeAttribute('val', '94%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 135000); + $objWriter->writeAttribute('val', '135%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -394,12 +394,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 95000); + $objWriter->writeAttribute('val', '95%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:fillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 105000); + $objWriter->writeAttribute('val', '105%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:lnStyleLst/a:ln/a:solidFill/a:schemeClr/ @@ -497,7 +497,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha $objWriter->startElement('a:alpha'); - $objWriter->writeAttribute('val', 38000); + $objWriter->writeAttribute('val', '38%'); // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha/ $objWriter->endElement(); @@ -533,7 +533,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha $objWriter->startElement('a:alpha'); - $objWriter->writeAttribute('val', 35000); + $objWriter->writeAttribute('val', '35%'); // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha/ $objWriter->endElement(); @@ -569,7 +569,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha $objWriter->startElement('a:alpha'); - $objWriter->writeAttribute('val', 35000); + $objWriter->writeAttribute('val', '35%'); // a:theme/a:themeElements/a:fmtScheme/a:effectStyleLst/a:effectStyle/a:effectLst/a:outerShdw/a:srgbClr/a:alpha/ $objWriter->endElement(); @@ -661,7 +661,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 0); + $objWriter->writeAttribute('pos', '0%'); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -669,12 +669,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:tint $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 40000); + $objWriter->writeAttribute('val', '40%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 350000); + $objWriter->writeAttribute('val', '350%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -685,7 +685,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 40000); + $objWriter->writeAttribute('pos', '40%'); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -693,17 +693,17 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 45000); + $objWriter->writeAttribute('val', '45%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 99000); + $objWriter->writeAttribute('val', '99%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 350000); + $objWriter->writeAttribute('val', '350%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -714,7 +714,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 100000); + $objWriter->writeAttribute('pos', '100%'); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -722,12 +722,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 20000); + $objWriter->writeAttribute('val', '20%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 255000); + $objWriter->writeAttribute('val', '255%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -745,10 +745,10 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:path/a:fillToRect $objWriter->startElement('a:fillToRect'); - $objWriter->writeAttribute('b', 180000); - $objWriter->writeAttribute('l', 50000); - $objWriter->writeAttribute('r', 50000); - $objWriter->writeAttribute('t', -80000); + $objWriter->writeAttribute('b', '180%'); + $objWriter->writeAttribute('l', '50%'); + $objWriter->writeAttribute('r', '50%'); + $objWriter->writeAttribute('t', '-80%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:path/ @@ -766,7 +766,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 0); + $objWriter->writeAttribute('pos', '0%'); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -774,12 +774,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:tint $objWriter->startElement('a:tint'); - $objWriter->writeAttribute('val', 80000); + $objWriter->writeAttribute('val', '80%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 300000); + $objWriter->writeAttribute('val', '300%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -790,7 +790,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs $objWriter->startElement('a:gs'); - $objWriter->writeAttribute('pos', 100000); + $objWriter->writeAttribute('pos', '100%'); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr $objWriter->startElement('a:schemeClr'); @@ -798,12 +798,12 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:shade $objWriter->startElement('a:shade'); - $objWriter->writeAttribute('val', 30000); + $objWriter->writeAttribute('val', '30%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/a:satMod $objWriter->startElement('a:satMod'); - $objWriter->writeAttribute('val', 200000); + $objWriter->writeAttribute('val', '200%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:gsLst/a:gs/a:schemeClr/ @@ -821,10 +821,10 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide) // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:path/a:fillToRect $objWriter->startElement('a:fillToRect'); - $objWriter->writeAttribute('b', 50000); - $objWriter->writeAttribute('l', 50000); - $objWriter->writeAttribute('r', 50000); - $objWriter->writeAttribute('t', 50000); + $objWriter->writeAttribute('b', '50%'); + $objWriter->writeAttribute('l', '50%'); + $objWriter->writeAttribute('r', '50%'); + $objWriter->writeAttribute('t', '50%'); $objWriter->endElement(); // a:theme/a:themeElements/a:fmtScheme/a:bgFillStyleLst/a:gradFill/a:path/ diff --git a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php index bb23a2f14..996894846 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php @@ -60,7 +60,7 @@ public function testGridLines() { $object = new Axis(); - $oMock = $this->getMock('PhpOffice\PhpPresentation\Shape\Chart\Gridlines'); + $oMock = $this->getMockBuilder('PhpOffice\PhpPresentation\Shape\Chart\Gridlines')->getMock(); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->setMajorGridlines($oMock)); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines', $object->getMajorGridlines()); diff --git a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php index 658062945..6a4fd4ea0 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php @@ -17,7 +17,7 @@ public function testGetSetOutline() { $object = new Gridlines(); - $oStub = $this->getMock('PhpOffice\PhpPresentation\Style\Outline'); + $oStub = $this->getMockBuilder('PhpOffice\PhpPresentation\Style\Outline')->getMock(); $this->assertInstanceOf('PhpOffice\PhpPresentation\Style\Outline', $object->getOutline()); $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Gridlines', $object->setOutline($oStub)); diff --git a/tests/PhpPresentation/Tests/Shape/CommentTest.php b/tests/PhpPresentation/Tests/Shape/CommentTest.php index 8223b7a6e..84391c163 100644 --- a/tests/PhpPresentation/Tests/Shape/CommentTest.php +++ b/tests/PhpPresentation/Tests/Shape/CommentTest.php @@ -41,7 +41,7 @@ public function testGetSetAuthor() { $object = new Comment(); - $oStub = $this->getMock('PhpOffice\PhpPresentation\Shape\Comment\Author'); + $oStub = $this->getMockBuilder('PhpOffice\PhpPresentation\Shape\Comment\Author')->getMock(); $this->assertNull($object->getAuthor()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setAuthor($oStub)); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php index 194f6cbca..2877f702a 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php @@ -237,10 +237,10 @@ public function testFillGradientLinearTable() $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); - $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="0"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="0%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected1, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); - $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="100000"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="100%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected2, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); } @@ -262,10 +262,10 @@ public function testFillGradientLinearRichText() $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); - $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="0"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="0%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected1, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); - $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="100000"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="100%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected2, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); } @@ -287,10 +287,10 @@ public function testFillGradientPathTable() $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); - $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="0"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="0%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected1, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); - $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="100000"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr/a:gradFill/a:gsLst/a:gs[@pos="100%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected2, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); } @@ -312,10 +312,10 @@ public function testFillGradientPathText() $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007'); - $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="0"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="0%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected1, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); - $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="100000"]/a:srgbClr'; + $element = '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill/a:gsLst/a:gs[@pos="100%"]/a:srgbClr'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); $this->assertEquals($expected2, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); } @@ -427,8 +427,7 @@ public function testListBullet() $oExpectedFont = $oRichText->getActiveParagraph()->getBulletStyle()->getBulletFont(); $oExpectedChar = $oRichText->getActiveParagraph()->getBulletStyle()->getBulletChar(); $oExpectedColor = $oRichText->getActiveParagraph()->getBulletStyle()->getBulletColor()->getRGB(); - $oExpectedAlpha = $oRichText->getActiveParagraph()->getBulletStyle()->getBulletColor()->getAlpha(); - $oExpectedAlpha *= 1000; + $oExpectedAlpha = $oRichText->getActiveParagraph()->getBulletStyle()->getBulletColor()->getAlpha() . "%"; $oRichText->createTextRun('Alpha'); $oRichText->createParagraph()->createTextRun('Beta'); @@ -640,7 +639,7 @@ public function testRichTextLineSpacing() $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:lnSpc/a:spcPct'; $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml')); - $this->assertEquals($expectedLineSpacing * 1000, $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); + $this->assertEquals($expectedLineSpacing . "%", $pres->getElementAttribute($element, 'val', 'ppt/slides/slide1.xml')); } public function testRichTextRunLanguage() diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php new file mode 100644 index 000000000..6a0e2f761 --- /dev/null +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -0,0 +1,482 @@ +internalErrors = libxml_use_internal_errors(true); + } + + protected function tearDown() + { + libxml_use_internal_errors($this->internalErrors); + TestHelperDOCX::clear(); + } + + /** + * Test whether the generated XML validates against the Office Open XML File Formats schema + * + * @see http://www.ecma-international.org/publications/standards/Ecma-376.htm + * @dataProvider pptProvider + */ + public function testSchema(PhpPresentation $presentation) + { + $xml = TestHelperDOCX::getDocument($presentation, 'PowerPoint2007'); + + // validate all XML files + $path = realpath($xml->getPath() . '/ppt'); + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); + + foreach ($iterator as $file) { + /** @var SplFileInfo $file */ + if ($file->getExtension() !== "xml") { + continue; + } + + $fileName = str_replace('\\', '/', substr($file->getRealPath(), strlen($path) + 1)); + $dom = $xml->getFileDom('ppt/' . $fileName); + $xmlSource = $dom->saveXML(); + + // In the ISO/ECMA standard the namespace has changed from + // http://schemas.openxmlformats.org/ to http://purl.oclc.org/ooxml/ + // We need to use the http://purl.oclc.org/ooxml/ namespace to validate + // the xml against the current schema + $xmlSource = str_replace([ + "http://schemas.openxmlformats.org/drawingml/2006/main", + "http://schemas.openxmlformats.org/drawingml/2006/chart", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + "http://schemas.openxmlformats.org/presentationml/2006/main", + ], [ + "http://purl.oclc.org/ooxml/drawingml/main", + "http://purl.oclc.org/ooxml/drawingml/chart", + "http://purl.oclc.org/ooxml/officeDocument/relationships", + "http://purl.oclc.org/ooxml/presentationml/main", + ], $xmlSource); + + $dom->loadXML($xmlSource); + $dom->schemaValidate(__DIR__ . '/../../../../resources/schema/ooxml/pml.xsd'); + + $error = libxml_get_last_error(); + if ($error) { + $this->fail(sprintf("Validation error: %s in file %s on line %s", $error->message, $file, $error->line)); + } + } + } + + public function pptProvider() + { + return [ + [$this->generatePresentation01()], + [$this->generatePresentation02()], + ]; + } + + /** + * Generates a ppt which contains different elements per slide i.e. shape, table, etc. + * + * @return PhpPresentation + */ + private function generatePresentation01() + { + $objPHPPresentation = new PhpPresentation(); + + $objPHPPresentation->getDocumentProperties() + ->setCreator('PHPOffice') + ->setLastModifiedBy('PHPPresentation Team') + ->setTitle('Sample 02 Title') + ->setSubject('Sample 02 Subject') + ->setDescription('Sample 02 Description') + ->setKeywords('office 2007 openxml libreoffice odt php') + ->setCategory('Sample Category'); + + $currentSlide = $objPHPPresentation->getActiveSlide(); + + // text shape + $shape = $currentSlide->createRichTextShape() + ->setHeight(300) + ->setWidth(600) + ->setOffsetX(170) + ->setOffsetY(180); + $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); + $textRun = $shape->createTextRun('Thank you for using PHPPresentation!'); + $textRun->getFont()->setBold(true) + ->setSize(60) + ->setColor(new Color('FFE06B20')); + + // image + $currentSlide = $objPHPPresentation->createSlide(); + $gdImage = @imagecreatetruecolor(140, 20) or die('Cannot Initialize new GD image stream'); + $textColor = imagecolorallocate($gdImage, 255, 255, 255); + imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor); + + $shape = new Drawing\Gd(); + $shape->setName('Sample image') + ->setDescription('Sample image') + ->setImageResource($gdImage) + ->setRenderingFunction(Drawing\Gd::RENDERING_JPEG) + ->setMimeType(Drawing\Gd::MIMETYPE_DEFAULT) + ->setHeight(36) + ->setOffsetX(10) + ->setOffsetY(10); + $currentSlide->addShape($shape); + + // table + $currentSlide = $objPHPPresentation->createSlide(); + $shape = $currentSlide->createTableShape(3); + $shape->setHeight(200); + $shape->setWidth(600); + $shape->setOffsetX(150); + $shape->setOffsetY(300); + + $row = $shape->createRow(); + $row->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR) + ->setRotation(90) + ->setStartColor(new Color('FFE06B20')) + ->setEndColor(new Color('FFFFFFFF')); + $cell = $row->nextCell(); + $cell->setColSpan(3); + $cell->createTextRun('Title row')->getFont()->setBold(true)->setSize(16); + $cell->getBorders()->getBottom()->setLineWidth(4) + ->setLineStyle(Border::LINE_SINGLE) + ->setDashStyle(Border::DASH_DASH); + + $row = $shape->createRow(); + $row->setHeight(20); + $row->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR) + ->setRotation(90) + ->setStartColor(new Color('FFE06B20')) + ->setEndColor(new Color('FFFFFFFF')); + $row->nextCell()->createTextRun('R1C1')->getFont()->setBold(true); + $row->nextCell()->createTextRun('R1C2')->getFont()->setBold(true); + $row->nextCell()->createTextRun('R1C3')->getFont()->setBold(true); + + foreach ($row->getCells() as $cell) { + $cell->getBorders()->getTop()->setLineWidth(4) + ->setLineStyle(Border::LINE_SINGLE) + ->setDashStyle(Border::DASH_DASH); + } + + // chart + $currentSlide = $objPHPPresentation->createSlide(); + + $oFill = new Fill(); + $oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20')); + + $oShadow = new Shadow(); + $oShadow->setVisible(true)->setDirection(45)->setDistance(10); + + $seriesData = array( + 'Monday' => 12, + 'Tuesday' => 15, + 'Wednesday' => 13, + 'Thursday' => 17, + 'Friday' => 14, + 'Saturday' => 9, + 'Sunday' => 7 + ); + + $lineChart = new Line(); + $series = new Series('Downloads', $seriesData); + $series->setShowSeriesName(true); + $series->setShowValue(true); + $lineChart->addSeries($series); + + $shape = $currentSlide->createChartShape(); + $shape->setName('PHPPresentation Daily Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); + $shape->setShadow($oShadow); + $shape->setFill($oFill); + $shape->getBorder()->setLineStyle(Border::LINE_SINGLE); + $shape->getTitle()->setText('PHPPresentation Daily Downloads'); + $shape->getTitle()->getFont()->setItalic(true); + $shape->getPlotArea()->setType($lineChart); + $shape->getView3D()->setRotationX(30); + $shape->getView3D()->setPerspective(30); + $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE); + $shape->getLegend()->getFont()->setItalic(true); + + // fill + $currentSlide = $objPHPPresentation->createSlide(); + + for($inc = 1 ; $inc <= 4 ; $inc++){ + // Create a shape (text) + $shape = $currentSlide->createRichTextShape() + ->setHeight(200) + ->setWidth(300); + if($inc == 1 || $inc == 3){ + $shape->setOffsetX(10); + } else { + $shape->setOffsetX(320); + } + if($inc == 1 || $inc == 2){ + $shape->setOffsetY(10); + } else { + $shape->setOffsetY(220); + } + $shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + + switch ($inc) { + case 1 : + $shape->getFill()->setFillType(Fill::FILL_NONE); + break; + case 2 : + $shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF000000' )); + break; + case 3 : + $shape->getFill()->setFillType(Fill::FILL_GRADIENT_PATH)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF000000' )); + break; + case 4 : + $shape->getFill()->setFillType(Fill::FILL_SOLID)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF4672A8' )); + break; + } + + $textRun = $shape->createTextRun('Use PHPPresentation!'); + $textRun->getFont()->setBold(true) + ->setSize(30) + ->setColor( new Color('FFE06B20') ); + } + + // slide note + $currentSlide = $objPHPPresentation->createSlide(); + + $shape = $currentSlide->createDrawingShape(); + $shape->setName('PHPPresentation logo') + ->setDescription('PHPPresentation logo') + ->setPath(__DIR__ . '/../../../../../samples/resources/phppowerpoint_logo.gif') + ->setHeight(36) + ->setOffsetX(10) + ->setOffsetY(10); + $shape->getShadow()->setVisible(true) + ->setDirection(45) + ->setDistance(10); + $shape->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation'); + + $shape = $currentSlide->createRichTextShape() + ->setHeight(300) + ->setWidth(600) + ->setOffsetX(170) + ->setOffsetY(180); + $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); + $textRun = $shape->createTextRun('Thank you for using PHPPresentation!'); + $textRun->getFont()->setBold(true) + ->setSize(60) + ->setColor(new Color('FFE06B20')); + + $oNote = $currentSlide->getNote(); + $oLayout = $objPHPPresentation->getLayout(); + $oRichText = $oNote->createRichTextShape() + ->setHeight($oLayout->getCY($oLayout::UNIT_PIXEL)) + ->setWidth($oLayout->getCX($oLayout::UNIT_PIXEL)) + ->setOffsetX(170) + ->setOffsetY(180); + $oRichText->createTextRun('A class library'); + $oRichText->createParagraph()->createTextRun('Written in PHP'); + $oRichText->createParagraph()->createTextRun('Representing a presentation'); + $oRichText->createParagraph()->createTextRun('Supports writing to different file formats'); + + // transition + $currentSlide = $objPHPPresentation->createSlide(); + + $shapeDrawing = $currentSlide->createDrawingShape(); + $shapeDrawing->setName('PHPPresentation logo') + ->setDescription('PHPPresentation logo') + ->setPath(__DIR__ . '/../../../../../samples/resources/phppowerpoint_logo.gif') + ->setHeight(36) + ->setOffsetX(10) + ->setOffsetY(10); + $shapeDrawing->getShadow()->setVisible(true) + ->setDirection(45) + ->setDistance(10); + $shapeDrawing->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation'); + + $shapeRichText = $currentSlide->createRichTextShape() + ->setHeight(300) + ->setWidth(600) + ->setOffsetX(170) + ->setOffsetY(180); + $shapeRichText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + $textRun = $shapeRichText->createTextRun('Thank you for using PHPPresentation!'); + $textRun->getFont()->setBold(true) + ->setSize(60) + ->setColor( new Color( 'FFE06B20' ) ); + + $oTransition = new Transition(); + $oTransition->setManualTrigger(false); + $oTransition->setTimeTrigger(true, 4000); + $oTransition->setTransitionType(Transition::TRANSITION_SPLIT_IN_VERTICAL); + $currentSlide->setTransition($oTransition); + + // comment + $currentSlide = $objPHPPresentation->createSlide(); + + $oShapeDrawing = new Drawing\File(); + $oShapeDrawing->setName('PHPPresentation logo') + ->setDescription('PHPPresentation logo') + ->setPath(__DIR__ . '/../../../../../samples/resources/phppowerpoint_logo.gif') + ->setHeight(36) + ->setOffsetX(10) + ->setOffsetY(10); + $oShapeDrawing->getShadow()->setVisible(true) + ->setDirection(45) + ->setDistance(10); + $oShapeDrawing->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation'); + + $oShapeRichText = new RichText(); + $oShapeRichText->setHeight(300) + ->setWidth(600) + ->setOffsetX(170) + ->setOffsetY(180); + $oShapeRichText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + $textRun = $oShapeRichText->createTextRun('Thank you for using PHPPresentation!'); + $textRun->getFont()->setBold(true) + ->setSize(60) + ->setColor( new Color( 'FFE06B20' ) ); + + $currentSlide->addShape(clone $oShapeDrawing); + $currentSlide->addShape(clone $oShapeRichText); + + $oAuthor = new \PhpOffice\PhpPresentation\Shape\Comment\Author(); + $oAuthor->setName('Progi1984'); + $oAuthor->setInitials('P'); + + $oComment1 = new \PhpOffice\PhpPresentation\Shape\Comment(); + $oComment1->setText('Text A'); + $oComment1->setOffsetX(10); + $oComment1->setOffsetY(55); + $oComment1->setDate(time()); + $oComment1->setAuthor($oAuthor); + $currentSlide->addShape($oComment1); + + $oComment2 = new \PhpOffice\PhpPresentation\Shape\Comment(); + $oComment2->setText('Text B'); + $oComment2->setOffsetX(170); + $oComment2->setOffsetY(180); + $oComment2->setDate(time()); + $oComment2->setAuthor($oAuthor); + $currentSlide->addShape($oComment2); + + // animation + $currentSlide = $objPHPPresentation->createSlide(); + + $oDrawing1 = clone $oShapeDrawing; + $oRichText1 = clone $oShapeRichText; + + $oSlide1 = $objPHPPresentation->getActiveSlide(); + $oSlide1->addShape($oDrawing1); + $oSlide1->addShape($oRichText1); + + $oAnimation1 = new Animation(); + $oAnimation1->addShape($oDrawing1); + $oSlide1->addAnimation($oAnimation1); + + $oAnimation2 = new Animation(); + $oAnimation2->addShape($oRichText1); + $oSlide1->addAnimation($oAnimation2); + + $oDrawing2 = clone $oShapeDrawing; + $oRichText2 = clone $oShapeRichText; + + $oSlide2 = $objPHPPresentation->createSlide(); + $oSlide2->addShape($oDrawing2); + $oSlide2->addShape($oRichText2); + + $oAnimation4 = new Animation(); + $oAnimation4->addShape($oRichText2); + $oSlide2->addAnimation($oAnimation4); + + $oAnimation3 = new Animation(); + $oAnimation3->addShape($oDrawing2); + $oSlide2->addAnimation($oAnimation3); + + $oDrawing3 = clone $oShapeDrawing; + $oRichText3 = clone $oShapeRichText; + + $currentSlide->addShape($oDrawing3); + $currentSlide->addShape($oRichText3); + + $oAnimation5 = new Animation(); + $oAnimation5->addShape($oRichText3); + $oAnimation5->addShape($oDrawing3); + $currentSlide->addAnimation($oAnimation5); + + // @TODO add more complex elements + + return $objPHPPresentation; + } + + /** + * Generates a ppt containing placeholder in the master and the slide + * + * @return PhpPresentation + */ + private function generatePresentation02() + { + $objPHPPresentation = new PhpPresentation(); + + $objPHPPresentation->getDocumentProperties() + ->setCreator('PHPOffice') + ->setLastModifiedBy('PHPPresentation Team') + ->setTitle('Sample 02 Title') + ->setSubject('Sample 02 Subject') + ->setDescription('Sample 02 Description') + ->setKeywords('office 2007 openxml libreoffice odt php') + ->setCategory('Sample Category'); + + // master slide + $masterSlides = $objPHPPresentation->getAllMasterSlides(); + /** @var Slide $objMaster */ + $objMaster = reset($masterSlides); + + $objShape = $objMaster->createRichTextShape(); + $objShape->setWidthAndHeight(270, 30)->setOffsetX(600)->setOffsetY(655); + $objShape->createTextRun("Footer") + ->getFont() + ->setName("Arial") + ->setSize(7); + $objShape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); + + $objShape = $objMaster->createRichTextShape(); + $objShape->setWidthAndHeight(50, 30)->setOffsetX(870)->setOffsetY(655); + $objShape->createTextRun("") + ->getFont() + ->setName("Arial") + ->setSize(7); + $objShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM)); + + // slide with placeholder + $currentSlide = $objPHPPresentation->getActiveSlide(); + + $objShape = $currentSlide->createRichTextShape(); + $objShape->setWidthAndHeight(50, 30)->setOffsetX(870)->setOffsetY(655); + $objShape->createTextRun("") + ->getFont() + ->setName("Arial") + ->setSize(7); + $objShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM)); + + return $objPHPPresentation; + } +} diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php index 6ea379f99..89cb0e6ed 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007Test.php @@ -133,7 +133,7 @@ public function testCachingException() */ public function testLayoutPack() { - $oLayoutPack = $this->getMock('PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007\\LayoutPack\\AbstractLayoutPack'); + $oLayoutPack = $this->getMockBuilder('PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007\\LayoutPack\\AbstractLayoutPack')->getMock(); $object = new PowerPoint2007(); diff --git a/tests/resources/schema/ooxml/dml-chart.xsd b/tests/resources/schema/ooxml/dml-chart.xsd new file mode 100644 index 000000000..01d369352 --- /dev/null +++ b/tests/resources/schema/ooxml/dml-chart.xsd @@ -0,0 +1,1449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-chartDrawing.xsd b/tests/resources/schema/ooxml/dml-chartDrawing.xsd new file mode 100644 index 000000000..f4228987a --- /dev/null +++ b/tests/resources/schema/ooxml/dml-chartDrawing.xsd @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-diagram.xsd b/tests/resources/schema/ooxml/dml-diagram.xsd new file mode 100644 index 000000000..615be6a8a --- /dev/null +++ b/tests/resources/schema/ooxml/dml-diagram.xsd @@ -0,0 +1,1084 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-lockedCanvas.xsd b/tests/resources/schema/ooxml/dml-lockedCanvas.xsd new file mode 100644 index 000000000..0e264c8db --- /dev/null +++ b/tests/resources/schema/ooxml/dml-lockedCanvas.xsd @@ -0,0 +1,9 @@ + + + + + diff --git a/tests/resources/schema/ooxml/dml-main.xsd b/tests/resources/schema/ooxml/dml-main.xsd new file mode 100644 index 000000000..862f7c180 --- /dev/null +++ b/tests/resources/schema/ooxml/dml-main.xsd @@ -0,0 +1,3041 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-picture.xsd b/tests/resources/schema/ooxml/dml-picture.xsd new file mode 100644 index 000000000..560ce68e6 --- /dev/null +++ b/tests/resources/schema/ooxml/dml-picture.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-spreadsheetDrawing.xsd b/tests/resources/schema/ooxml/dml-spreadsheetDrawing.xsd new file mode 100644 index 000000000..d1ae13ba4 --- /dev/null +++ b/tests/resources/schema/ooxml/dml-spreadsheetDrawing.xsd @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/dml-wordprocessingDrawing.xsd b/tests/resources/schema/ooxml/dml-wordprocessingDrawing.xsd new file mode 100644 index 000000000..bf11d9a4c --- /dev/null +++ b/tests/resources/schema/ooxml/dml-wordprocessingDrawing.xsd @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/pml.xsd b/tests/resources/schema/ooxml/pml.xsd new file mode 100644 index 000000000..29f8e4c76 --- /dev/null +++ b/tests/resources/schema/ooxml/pml.xsd @@ -0,0 +1,1617 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-additionalCharacteristics.xsd b/tests/resources/schema/ooxml/shared-additionalCharacteristics.xsd new file mode 100644 index 000000000..05c0d6935 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-additionalCharacteristics.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-bibliography.xsd b/tests/resources/schema/ooxml/shared-bibliography.xsd new file mode 100644 index 000000000..961753523 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-bibliography.xsd @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-commonSimpleTypes.xsd b/tests/resources/schema/ooxml/shared-commonSimpleTypes.xsd new file mode 100644 index 000000000..d34d1a8cb --- /dev/null +++ b/tests/resources/schema/ooxml/shared-commonSimpleTypes.xsd @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-customXmlDataProperties.xsd b/tests/resources/schema/ooxml/shared-customXmlDataProperties.xsd new file mode 100644 index 000000000..70a95139a --- /dev/null +++ b/tests/resources/schema/ooxml/shared-customXmlDataProperties.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-customXmlSchemaProperties.xsd b/tests/resources/schema/ooxml/shared-customXmlSchemaProperties.xsd new file mode 100644 index 000000000..fed636b27 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-customXmlSchemaProperties.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-documentPropertiesCustom.xsd b/tests/resources/schema/ooxml/shared-documentPropertiesCustom.xsd new file mode 100644 index 000000000..897ccfab8 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-documentPropertiesCustom.xsd @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-documentPropertiesExtended.xsd b/tests/resources/schema/ooxml/shared-documentPropertiesExtended.xsd new file mode 100644 index 000000000..4ef88e7ca --- /dev/null +++ b/tests/resources/schema/ooxml/shared-documentPropertiesExtended.xsd @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-documentPropertiesVariantTypes.xsd b/tests/resources/schema/ooxml/shared-documentPropertiesVariantTypes.xsd new file mode 100644 index 000000000..fad199274 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-documentPropertiesVariantTypes.xsd @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-math.xsd b/tests/resources/schema/ooxml/shared-math.xsd new file mode 100644 index 000000000..6f5e6d09a --- /dev/null +++ b/tests/resources/schema/ooxml/shared-math.xsd @@ -0,0 +1,582 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/shared-relationshipReference.xsd b/tests/resources/schema/ooxml/shared-relationshipReference.xsd new file mode 100644 index 000000000..a6af5ff28 --- /dev/null +++ b/tests/resources/schema/ooxml/shared-relationshipReference.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/sml.xsd b/tests/resources/schema/ooxml/sml.xsd new file mode 100644 index 000000000..4346d37b9 --- /dev/null +++ b/tests/resources/schema/ooxml/sml.xsd @@ -0,0 +1,4404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/schema/ooxml/wml.xsd b/tests/resources/schema/ooxml/wml.xsd new file mode 100644 index 000000000..578157ea8 --- /dev/null +++ b/tests/resources/schema/ooxml/wml.xsd @@ -0,0 +1,3460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4097ba4b8556e52da468434210dc0c303d3623ca Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 9 Jan 2017 09:12:53 +0100 Subject: [PATCH 02/31] remove exit expression --- .../PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php index 6a0e2f761..59c2d0fc7 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -129,7 +129,7 @@ private function generatePresentation01() // image $currentSlide = $objPHPPresentation->createSlide(); - $gdImage = @imagecreatetruecolor(140, 20) or die('Cannot Initialize new GD image stream'); + $gdImage = @imagecreatetruecolor(140, 20); $textColor = imagecolorallocate($gdImage, 255, 255, 255); imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor); From 891769fc58b846175dbdd286f852098f2c93fa00 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 9 Jan 2017 09:16:06 +0100 Subject: [PATCH 03/31] fix code style --- .../Writer/PowerPoint2007/SchemaTest.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php index 59c2d0fc7..3bbf39d20 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -131,7 +131,7 @@ private function generatePresentation01() $currentSlide = $objPHPPresentation->createSlide(); $gdImage = @imagecreatetruecolor(140, 20); $textColor = imagecolorallocate($gdImage, 255, 255, 255); - imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor); + imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor); $shape = new Drawing\Gd(); $shape->setName('Sample image') @@ -221,42 +221,42 @@ private function generatePresentation01() // fill $currentSlide = $objPHPPresentation->createSlide(); - for($inc = 1 ; $inc <= 4 ; $inc++){ + for ($inc = 1; $inc <= 4; $inc++) { // Create a shape (text) $shape = $currentSlide->createRichTextShape() ->setHeight(200) ->setWidth(300); - if($inc == 1 || $inc == 3){ + if ($inc == 1 || $inc == 3) { $shape->setOffsetX(10); } else { $shape->setOffsetX(320); } - if($inc == 1 || $inc == 2){ + if ($inc == 1 || $inc == 2) { $shape->setOffsetY(10); } else { $shape->setOffsetY(220); } - $shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); switch ($inc) { - case 1 : + case 1: $shape->getFill()->setFillType(Fill::FILL_NONE); break; - case 2 : - $shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF000000' )); + case 2: + $shape->getFill()->setFillType(Fill::FILL_GRADIENT_LINEAR)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF000000')); break; - case 3 : - $shape->getFill()->setFillType(Fill::FILL_GRADIENT_PATH)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF000000' )); + case 3: + $shape->getFill()->setFillType(Fill::FILL_GRADIENT_PATH)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF000000')); break; - case 4 : - $shape->getFill()->setFillType(Fill::FILL_SOLID)->setRotation(90)->setStartColor(new Color( 'FF4672A8' ))->setEndColor(new Color( 'FF4672A8' )); + case 4: + $shape->getFill()->setFillType(Fill::FILL_SOLID)->setRotation(90)->setStartColor(new Color('FF4672A8'))->setEndColor(new Color('FF4672A8')); break; } $textRun = $shape->createTextRun('Use PHPPresentation!'); $textRun->getFont()->setBold(true) ->setSize(30) - ->setColor( new Color('FFE06B20') ); + ->setColor(new Color('FFE06B20')); } // slide note @@ -317,11 +317,11 @@ private function generatePresentation01() ->setWidth(600) ->setOffsetX(170) ->setOffsetY(180); - $shapeRichText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + $shapeRichText->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $textRun = $shapeRichText->createTextRun('Thank you for using PHPPresentation!'); $textRun->getFont()->setBold(true) ->setSize(60) - ->setColor( new Color( 'FFE06B20' ) ); + ->setColor(new Color('FFE06B20')); $oTransition = new Transition(); $oTransition->setManualTrigger(false); @@ -349,11 +349,11 @@ private function generatePresentation01() ->setWidth(600) ->setOffsetX(170) ->setOffsetY(180); - $oShapeRichText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); + $oShapeRichText->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $textRun = $oShapeRichText->createTextRun('Thank you for using PHPPresentation!'); $textRun->getFont()->setBold(true) ->setSize(60) - ->setColor( new Color( 'FFE06B20' ) ); + ->setColor(new Color('FFE06B20')); $currentSlide->addShape(clone $oShapeDrawing); $currentSlide->addShape(clone $oShapeRichText); From dcfc99cde5e2edfa72214bdf735ad979c8c1d156 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 12:36:45 +0200 Subject: [PATCH 04/31] use precentage format --- src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index 4f48c650d..6f99f3dd7 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -521,7 +521,7 @@ protected function writeParagraphs(XMLWriter $objWriter, $paragraphs, $bIsPlaceh $objWriter->startElement('a:lnSpc'); $objWriter->startElement('a:spcPct'); - $objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000); + $objWriter->writeAttribute('val', $paragraph->getLineSpacing() . "%"); $objWriter->endElement(); $objWriter->endElement(); From 39ce62f1f79805fc9f241180e1d9228cc0e337fe Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 12:37:24 +0200 Subject: [PATCH 05/31] use PhpPresentationTestCase and make getXmlDom protected --- .../Writer/PowerPoint2007/SchemaTest.php | 19 +++++++++++-------- .../_includes/PhpPresentationTestCase.php | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php index 3bbf39d20..d03d01de4 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -16,25 +16,28 @@ use PhpOffice\PhpPresentation\Style\Color; use PhpOffice\PhpPresentation\Style\Fill; use PhpOffice\PhpPresentation\Style\Shadow; -use PhpOffice\PhpPresentation\Tests\TestHelperDOCX; +use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase; use PhpOffice\PhpPresentation\Shape\Drawing; use PhpOffice\PhpPresentation\Shape\Media; use Symfony\Component\Finder\SplFileInfo; -class SchemaTest extends \PHPUnit_Framework_TestCase +class SchemaTest extends PhpPresentationTestCase { private $internalErrors; - protected function setUp() + public function setUp() { + parent::setUp(); + libxml_clear_errors(); $this->internalErrors = libxml_use_internal_errors(true); } - protected function tearDown() + public function tearDown() { + parent::tearDown(); + libxml_use_internal_errors($this->internalErrors); - TestHelperDOCX::clear(); } /** @@ -45,10 +48,10 @@ protected function tearDown() */ public function testSchema(PhpPresentation $presentation) { - $xml = TestHelperDOCX::getDocument($presentation, 'PowerPoint2007'); + $this->writePresentationFile($presentation, 'PowerPoint2007'); // validate all XML files - $path = realpath($xml->getPath() . '/ppt'); + $path = realpath($this->workDirectory . '/ppt'); $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); foreach ($iterator as $file) { @@ -58,7 +61,7 @@ public function testSchema(PhpPresentation $presentation) } $fileName = str_replace('\\', '/', substr($file->getRealPath(), strlen($path) + 1)); - $dom = $xml->getFileDom('ppt/' . $fileName); + $dom = $this->getXmlDom('ppt/' . $fileName); $xmlSource = $dom->saveXML(); // In the ISO/ECMA standard the namespace has changed from diff --git a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php index cd512ad27..2d5d97a12 100644 --- a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php +++ b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php @@ -89,7 +89,7 @@ private function deleteDir($dir) rmdir($dir); } - private function getXmlDom($file) + protected function getXmlDom($file) { $baseFile = $file; if (null !== $this->xmlDom && $file === $this->xmlFile) { From f192573bdc10751052d22f13cc9057c3c3455056 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 12:53:13 +0200 Subject: [PATCH 06/31] adjust chart writer according to schema --- .../Writer/PowerPoint2007/PptCharts.php | 64 +++++++++---------- .../Writer/PowerPoint2007/SchemaTest.php | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 9958aafe3..46e373665 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -97,15 +97,15 @@ public function writeChart(Chart $chart) $objWriter->writeAttribute('val', $chart->getView3D()->getRotationX()); $objWriter->endElement(); + // c:hPercent + $hPercent = $chart->getView3D()->getHeightPercent(); + $objWriter->writeElementIf($hPercent != null, 'c:hPercent', 'val', $hPercent . '%'); + // c:rotY $objWriter->startElement('c:rotY'); $objWriter->writeAttribute('val', $chart->getView3D()->getRotationY()); $objWriter->endElement(); - // c:hPercent - $hPercent = $chart->getView3D()->getHeightPercent(); - $objWriter->writeElementIf($hPercent != null, 'c:hPercent', 'val', $hPercent); - // c:depthPercent $objWriter->startElement('c:depthPercent'); $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent() . '%'); @@ -2033,34 +2033,6 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis, $objWriter->endElement(); } - // c:numFmt - $objWriter->startElement('c:numFmt'); - $objWriter->writeAttribute('formatCode', $oAxis->getFormatCode()); - $objWriter->writeAttribute('sourceLinked', '1'); - $objWriter->endElement(); - - // c:majorTickMark - $objWriter->startElement('c:majorTickMark'); - $objWriter->writeAttribute('val', $oAxis->getMajorTickMark()); - $objWriter->endElement(); - - // c:minorTickMark - $objWriter->startElement('c:minorTickMark'); - $objWriter->writeAttribute('val', $oAxis->getMinorTickMark()); - $objWriter->endElement(); - - // c:tickLblPos - $objWriter->startElement('c:tickLblPos'); - $objWriter->writeAttribute('val', 'nextTo'); - $objWriter->endElement(); - - // c:spPr - $objWriter->startElement('c:spPr'); - // Outline - $this->writeOutline($objWriter, $oAxis->getOutline()); - // ##c:spPr - $objWriter->endElement(); - if ($oAxis->getTitle() != '') { // c:title $objWriter->startElement('c:title'); @@ -2143,6 +2115,34 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis, $objWriter->endElement(); } + // c:numFmt + $objWriter->startElement('c:numFmt'); + $objWriter->writeAttribute('formatCode', $oAxis->getFormatCode()); + $objWriter->writeAttribute('sourceLinked', '1'); + $objWriter->endElement(); + + // c:majorTickMark + $objWriter->startElement('c:majorTickMark'); + $objWriter->writeAttribute('val', $oAxis->getMajorTickMark()); + $objWriter->endElement(); + + // c:minorTickMark + $objWriter->startElement('c:minorTickMark'); + $objWriter->writeAttribute('val', $oAxis->getMinorTickMark()); + $objWriter->endElement(); + + // c:tickLblPos + $objWriter->startElement('c:tickLblPos'); + $objWriter->writeAttribute('val', 'nextTo'); + $objWriter->endElement(); + + // c:spPr + $objWriter->startElement('c:spPr'); + // Outline + $this->writeOutline($objWriter, $oAxis->getOutline()); + // ##c:spPr + $objWriter->endElement(); + // c:crossAx $objWriter->startElement('c:crossAx'); $objWriter->writeAttribute('val', $crossAxVal); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php index d03d01de4..d9300a453 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -85,7 +85,7 @@ public function testSchema(PhpPresentation $presentation) $error = libxml_get_last_error(); if ($error) { - $this->fail(sprintf("Validation error: %s in file %s on line %s", $error->message, $file, $error->line)); + $this->fail(sprintf("Validation error: %s in file %s on line %s\n%s", $error->message, $file, $error->line, $dom->saveXML())); } } } From f64f7bdc28af0a504ef6200c733b28307a58a167 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 13:07:43 +0200 Subject: [PATCH 07/31] fix test --- .../Tests/Writer/PowerPoint2007/PptChartsTest.php | 2 +- .../Tests/Writer/PowerPoint2007/PptSlidesTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index 81e6d2439..d67e46905 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -891,7 +891,7 @@ public function testView3D() $element = '/c:chartSpace/c:chart/c:view3D/c:hPercent'; $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); - $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 100); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '100%'); $oShape->getView3D()->setHeightPercent(null); $this->resetPresentationFile(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php index 47bd85483..c773ec1c9 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php @@ -541,7 +541,7 @@ public function testRichTextLineSpacing() $element = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:lnSpc/a:spcPct'; $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); - $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'val', $expectedLineSpacing * 1000); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'val', $expectedLineSpacing . '%'); } public function testRichTextRunLanguage() From 7eea2e56f3065a80656bbb93517af1c6b652d860 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 13:19:22 +0200 Subject: [PATCH 08/31] use array() instead of [] to support PHP 5.3 --- .../Tests/Writer/PowerPoint2007/SchemaTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php index d9300a453..b7ee6fbb9 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/SchemaTest.php @@ -68,17 +68,17 @@ public function testSchema(PhpPresentation $presentation) // http://schemas.openxmlformats.org/ to http://purl.oclc.org/ooxml/ // We need to use the http://purl.oclc.org/ooxml/ namespace to validate // the xml against the current schema - $xmlSource = str_replace([ + $xmlSource = str_replace(array( "http://schemas.openxmlformats.org/drawingml/2006/main", "http://schemas.openxmlformats.org/drawingml/2006/chart", "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "http://schemas.openxmlformats.org/presentationml/2006/main", - ], [ + ), array( "http://purl.oclc.org/ooxml/drawingml/main", "http://purl.oclc.org/ooxml/drawingml/chart", "http://purl.oclc.org/ooxml/officeDocument/relationships", "http://purl.oclc.org/ooxml/presentationml/main", - ], $xmlSource); + ), $xmlSource); $dom->loadXML($xmlSource); $dom->schemaValidate(__DIR__ . '/../../../../resources/schema/ooxml/pml.xsd'); @@ -92,10 +92,10 @@ public function testSchema(PhpPresentation $presentation) public function pptProvider() { - return [ - [$this->generatePresentation01()], - [$this->generatePresentation02()], - ]; + return array( + array($this->generatePresentation01()), + array($this->generatePresentation02()), + ); } /** From 00241e36d37637dbe81339000245d436c61d6bb4 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Mon, 10 Apr 2017 17:21:22 +0200 Subject: [PATCH 09/31] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1e77d8bf..6937396c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.9.0 - WIP + +### Changes +- PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307 + +### Features +- PowerPoint2007 Writer : Implemented XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307 + ## 0.8.0 - 2017-04-03 ### Bugfix From ed3b9f9fa59e6f49e61ac67c894a98fe17d912c8 Mon Sep 17 00:00:00 2001 From: Philipp Roos Date: Tue, 25 Apr 2017 14:15:24 +0200 Subject: [PATCH 10/31] Add Option to delete an axis. --- src/PhpPresentation/Shape/Chart/Axis.php | 27 +++++++++++++++++++ .../Writer/PowerPoint2007/PptCharts.php | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index 8f716bcc6..60a9dc139 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -100,6 +100,11 @@ class Axis implements ComparableInterface */ protected $outline; + /** + * @var int + */ + protected $deleted; + /** * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance * @@ -386,4 +391,26 @@ public function setHashIndex($value) $this->hashIndex = $value; return $this; } + + /** + * Axis deleted and not visible? + * + * @return int Hash index + */ + public function getDelete() + { + return $this->delete; + } + + /** + * Remove an axis. + * 0 not deleted, 1 = deleted and not visible + * + * @param int $value delete + */ + public function setDelete($value) + { + $this->delete = $value; + return $this; + } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 46e373665..e94df6f8f 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -2010,6 +2010,11 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis, // $mainElement > ##c:scaling $objWriter->endElement(); + // $mainElement > c:delete + $objWriter->startElement('c:delete'); + $objWriter->writeAttribute('val', $oAxis->getDelete()); + $objWriter->endElement(); + // $mainElement > c:axPos $objWriter->startElement('c:axPos'); $objWriter->writeAttribute('val', $axPosVal); From d08f0db161a1e963e86fe27050ba879b13c542da Mon Sep 17 00:00:00 2001 From: Philipp Roos Date: Tue, 25 Apr 2017 14:54:11 +0200 Subject: [PATCH 11/31] delete = 0 as default. --- src/PhpPresentation/Shape/Chart/Axis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index 60a9dc139..1cceeb169 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -103,7 +103,7 @@ class Axis implements ComparableInterface /** * @var int */ - protected $deleted; + protected $deleted = 0; /** * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance From 4b77302bea38291f0a01ce66fd07e7e77dcb92e9 Mon Sep 17 00:00:00 2001 From: Philipp Roos Date: Tue, 25 Apr 2017 17:16:46 +0200 Subject: [PATCH 12/31] Bugfix: deleted => delete --- src/PhpPresentation/Shape/Chart/Axis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index 1cceeb169..3819939dd 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -103,7 +103,7 @@ class Axis implements ComparableInterface /** * @var int */ - protected $deleted = 0; + protected $delete = 0; /** * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance From a5a270775173615d07f670380196c6663c4583f1 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 20 May 2017 14:19:52 +0200 Subject: [PATCH 13/31] #356 : PowerPoint2007 Writer : Implement visibility for axis --- CHANGELOG.md | 3 +- src/PhpPresentation/Shape/Chart/Axis.php | 24 +++++++------- .../Writer/PowerPoint2007/PptCharts.php | 2 +- .../Tests/Shape/Chart/AxisTest.php | 10 ++++++ .../Writer/PowerPoint2007/PptChartsTest.php | 32 +++++++++++++++++++ 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6937396c8..91dc36d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ - PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307 ### Features -- PowerPoint2007 Writer : Implemented XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307 +- PowerPoint2007 Writer : Implement XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307 +- PowerPoint2007 Writer : Implement visibility for axis - @kw-pr @Progi1984 GH-356 ## 0.8.0 - 2017-04-03 diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index 3819939dd..a224ed1a7 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -101,9 +101,9 @@ class Axis implements ComparableInterface protected $outline; /** - * @var int + * @var boolean */ - protected $delete = 0; + protected $isVisible = true; /** * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance @@ -385,6 +385,7 @@ public function getHashIndex() * while doing a write of a workbook and when changes are not allowed. * * @param string $value Hash index + * @return $this */ public function setHashIndex($value) { @@ -393,24 +394,23 @@ public function setHashIndex($value) } /** - * Axis deleted and not visible? - * - * @return int Hash index + * Axis is hidden ? + * @return boolean */ - public function getDelete() + public function isVisible() { - return $this->delete; + return $this->isVisible; } /** - * Remove an axis. - * 0 not deleted, 1 = deleted and not visible + * Hide an axis * - * @param int $value delete + * @param boolean $value delete + * @return $this */ - public function setDelete($value) + public function setIsVisible($value) { - $this->delete = $value; + $this->isVisible = boolval($value); return $this; } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index e94df6f8f..e914090ae 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -2012,7 +2012,7 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis, // $mainElement > c:delete $objWriter->startElement('c:delete'); - $objWriter->writeAttribute('val', $oAxis->getDelete()); + $objWriter->writeAttribute('val', $oAxis->isVisible() ? '0' : '1'); $objWriter->endElement(); // $mainElement > c:axPos diff --git a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php index 6ecf0a18c..f29046416 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php @@ -96,6 +96,16 @@ public function testHashIndex() $this->assertEquals($value, $object->getHashIndex()); } + public function testIsVisible() + { + $object = new Axis(); + $this->assertTrue($object->isVisible()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->setIsVisible(false)); + $this->assertFalse($object->isVisible()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->setIsVisible(true)); + $this->assertTrue($object->isVisible()); + } + public function testTitle() { $object = new Axis(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index d67e46905..618ae8fcb 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -165,6 +165,38 @@ public function testAxisOutline() $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY); } + public function testAxisVisibilityFalse() + { + $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete'; + + $oSlide = $this->oPresentation->getActiveSlide(); + $oShape = $oSlide->createChartShape(); + $oLine = new Line(); + $oShape->getPlotArea()->setType($oLine); + + // Set Visible : FALSE + $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(false)); + $this->assertFalse($oShape->getPlotArea()->getAxisX()->isVisible()); + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1'); + } + + public function testAxisVisibilityTrue() + { + $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete'; + + $oSlide = $this->oPresentation->getActiveSlide(); + $oShape = $oSlide->createChartShape(); + $oLine = new Line(); + $oShape->getPlotArea()->setType($oLine); + + // Set Visible : TRUE + $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(true)); + $this->assertTrue($oShape->getPlotArea()->getAxisX()->isVisible()); + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0'); + } + public function testTypeArea() { $oSlide = $this->oPresentation->getActiveSlide(); From f48da012acb2d785d7662fa05c4db1dd39c4f2bf Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 20 May 2017 14:39:07 +0200 Subject: [PATCH 14/31] #356 : PowerPoint2007 Writer : Implement visibility for axis --- src/PhpPresentation/Shape/Chart/Axis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index a224ed1a7..b2559bd2d 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -410,7 +410,7 @@ public function isVisible() */ public function setIsVisible($value) { - $this->isVisible = boolval($value); + $this->isVisible = (bool)$value; return $this; } } From 2465f9961d654fc76057f55a35d4486d16d1e268 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 21 May 2017 14:00:54 +0200 Subject: [PATCH 15/31] #356 : PowerPoint2007 Writer : Implement visibility for axis (Fix for charts) --- src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php | 2 +- tests/resources/schema/ooxml/dml-chart.xsd | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index e94df6f8f..ef1fd6d94 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -108,7 +108,7 @@ public function writeChart(Chart $chart) // c:depthPercent $objWriter->startElement('c:depthPercent'); - $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent() . '%'); + $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent()); $objWriter->endElement(); // c:rAngAx diff --git a/tests/resources/schema/ooxml/dml-chart.xsd b/tests/resources/schema/ooxml/dml-chart.xsd index 01d369352..91559f2ce 100644 --- a/tests/resources/schema/ooxml/dml-chart.xsd +++ b/tests/resources/schema/ooxml/dml-chart.xsd @@ -214,13 +214,19 @@ - + + + + + + + From 5c8e4b6e7a5afcc101a7afc7b24d716eb31c74dc Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 21 May 2017 14:12:37 +0200 Subject: [PATCH 16/31] #356 : PowerPoint2007 Writer : Implement visibility for axis (Docs) --- docs/shapes_chart.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/shapes_chart.rst b/docs/shapes_chart.rst index 8838cfda7..77ec22944 100644 --- a/docs/shapes_chart.rst +++ b/docs/shapes_chart.rst @@ -87,6 +87,16 @@ For resetting them, you pass null as parameter to these methods. $oShape->getPlotArea()->getAxisY()->setMinorUnit(null); $oShape->getPlotArea()->getAxisY()->setMajorUnit(0.05); +You can define visibility for each axis (X & Y). + +.. code-block:: php + + $oLine = new Line(); + + $oShape = $oSlide->createChartShape(); + $oShape->getPlotArea()->setType($oLine); + $oShape->getPlotArea()->getAxisX()->setIsVisible(false); + Title ^^^^^ From 28bd7e8f002ce3b5a24e11359c54a4fb194d5579 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 21 May 2017 15:25:52 +0200 Subject: [PATCH 17/31] #358 : PowerPoint2007 Writer : Implement gap width in Bar(3D) Charts --- CHANGELOG.md | 1 + docs/shapes_chart.rst | 11 +++++++ samples/Sample_05_Chart.php | 1 + .../Shape/Chart/Type/AbstractTypeBar.php | 32 +++++++++++++++++++ .../Writer/PowerPoint2007/PptCharts.php | 4 +-- .../Tests/Shape/Chart/Type/Bar3DTest.php | 13 ++++++++ .../Tests/Shape/Chart/Type/BarTest.php | 13 ++++++++ .../Writer/PowerPoint2007/PptChartsTest.php | 8 +++++ 8 files changed, 81 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6937396c8..26ba2350d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Features - PowerPoint2007 Writer : Implemented XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307 +- PowerPoint2007 Writer : Implement gap width in Bar(3D) Charts - @Progi1984 GH-358 ## 0.8.0 - 2017-04-03 diff --git a/docs/shapes_chart.rst b/docs/shapes_chart.rst index 8838cfda7..61be333d3 100644 --- a/docs/shapes_chart.rst +++ b/docs/shapes_chart.rst @@ -176,6 +176,17 @@ TODO Bar & Bar3D ^^^^^^^^^^^ +Gap Width +""""""""" + +You can define the gap width between bar or columns clusters. It is defined in percent. +The default value is 150%. The value must be defined between 0 and 500. + +.. code-block:: php + + $oBarChart = new Bar(); + $oBarChart->setGapWidthPercent(250); + Stacking """""""" diff --git a/samples/Sample_05_Chart.php b/samples/Sample_05_Chart.php index e80ca0403..bb28ec65c 100644 --- a/samples/Sample_05_Chart.php +++ b/samples/Sample_05_Chart.php @@ -82,6 +82,7 @@ function fnSlide_Bar(PhpPresentation $objPHPPresentation) { // Create a bar chart (that should be inserted in a shape) echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)'.EOL; $barChart = new Bar(); + $barChart->setGapWidthPercent(158); $series1 = new Series('2009', $series1Data); $series1->setShowSeriesName(true); $series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD')); diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php index e4015b3a3..4b2357b69 100644 --- a/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php +++ b/src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php @@ -48,6 +48,14 @@ class AbstractTypeBar extends AbstractType protected $barGrouping = self::GROUPING_CLUSTERED; + /** + * Space between bar or columns clusters + * + * @var int + */ + protected $gapWidthPercent = 150; + + /** * Set bar orientation * @@ -91,6 +99,30 @@ public function getBarGrouping() { return $this->barGrouping; } + + /** + * @return int + */ + public function getGapWidthPercent() + { + return $this->gapWidthPercent; + } + + /** + * @param int $gapWidthPercent + * @return $this + */ + public function setGapWidthPercent($gapWidthPercent) + { + if ($gapWidthPercent < 0) { + $gapWidthPercent = 0; + } + if ($gapWidthPercent > 500) { + $gapWidthPercent = 500; + } + $this->gapWidthPercent = $gapWidthPercent; + return $this; + } /** * Get hash code diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index ef1fd6d94..1bdde2194 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -972,7 +972,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, $includeShee // c:gapWidth $objWriter->startElement('c:gapWidth'); - $objWriter->writeAttribute('val', '75'); + $objWriter->writeAttribute('val', $subject->getGapWidthPercent()); $objWriter->endElement(); // c:shape @@ -1174,7 +1174,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, $include // c:gapWidth $objWriter->startElement('c:gapWidth'); - $objWriter->writeAttribute('val', '75'); + $objWriter->writeAttribute('val', $subject->getGapWidthPercent()); $objWriter->endElement(); // c:shape diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php index 1853a1bad..1fdbc092f 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/Bar3DTest.php @@ -75,6 +75,19 @@ public function testBarGrouping() $this->assertEquals(Bar3D::GROUPING_PERCENTSTACKED, $object->getBarGrouping()); } + public function testGapWidthPercent() + { + $value = rand(0, 500); + $object = new Bar3D(); + $this->assertEquals(150, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent($value)); + $this->assertEquals($value, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(-1)); + $this->assertEquals(0, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar3D', $object->setGapWidthPercent(501)); + $this->assertEquals(500, $object->getGapWidthPercent()); + } + public function testHashCode() { $oSeries = new Series(); diff --git a/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php b/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php index 302991811..382684ead 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/Type/BarTest.php @@ -75,6 +75,19 @@ public function testBarGrouping() $this->assertEquals(Bar::GROUPING_PERCENTSTACKED, $object->getBarGrouping()); } + public function testGapWidthPercent() + { + $value = rand(0, 500); + $object = new Bar(); + $this->assertEquals(150, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent($value)); + $this->assertEquals($value, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(-1)); + $this->assertEquals(0, $object->getGapWidthPercent()); + $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar', $object->setGapWidthPercent(501)); + $this->assertEquals(500, $object->getGapWidthPercent()); + } + public function testHashCode() { $oSeries = new Series(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index d67e46905..c14cde667 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -316,10 +316,12 @@ public function testTypeAxisUnit() public function testTypeBar() { + $valueGapWidthPercent = rand(0, 500); $oSlide = $this->oPresentation->getActiveSlide(); $oShape = $oSlide->createChartShape(); $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $oBar = new Bar(); + $oBar->setGapWidthPercent($valueGapWidthPercent); $oSeries = new Series('Downloads', $this->seriesData); $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE)); $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE)); @@ -339,14 +341,18 @@ public function testTypeBar() $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v'; $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle()); + $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:gapWidth'; + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueGapWidthPercent); } public function testTypeBar3D() { + $valueGapWidthPercent = rand(0, 500); $oSlide = $this->oPresentation->getActiveSlide(); $oShape = $oSlide->createChartShape(); $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $oBar3D = new Bar3D(); + $oBar3D->setGapWidthPercent($valueGapWidthPercent); $oSeries = new Series('Downloads', $this->seriesData); $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE)); $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE)); @@ -366,6 +372,8 @@ public function testTypeBar3D() $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:tx/c:v'; $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle()); + $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:gapWidth'; + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueGapWidthPercent); } public function testTypeBar3DSubScript() From 97c0126db05b3cd0af73ee721cb9549af3906bb6 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 21 May 2017 16:23:56 +0200 Subject: [PATCH 18/31] #347 : PowerPoint2007 Writer : Margins in table cell --- CHANGELOG.md | 3 ++ docs/shapes_table.rst | 1 + samples/Sample_04_Table.php | 38 +++++++++++++------ .../Writer/PowerPoint2007/AbstractSlide.php | 8 ++-- .../Writer/PowerPoint2007/PptSlidesTest.php | 8 ++-- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffe307b7..2bd80ae4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.9.0 - WIP +### Bugfix +- PowerPoint2007 Writer : Margins in table cell - @Progi1984 GH-347 + ### Changes - PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307 diff --git a/docs/shapes_table.rst b/docs/shapes_table.rst index fbb8b185d..32be173f4 100644 --- a/docs/shapes_table.rst +++ b/docs/shapes_table.rst @@ -51,6 +51,7 @@ You can access cell object directly. Define margins of a cell ~~~~~~~~~~~~~~~~~~~~~~~~ Margins of cells are defined by margins of the first paragraph of cell. +Margins of cells are defined in pixels. For defining margins of cell, you can use the `setMargin*` method of a Alignment object of the active paragraph of a Cell object. diff --git a/samples/Sample_04_Table.php b/samples/Sample_04_Table.php index 863fbcc47..6cc6f3bff 100644 --- a/samples/Sample_04_Table.php +++ b/samples/Sample_04_Table.php @@ -61,10 +61,13 @@ ->setRotation(90) ->setStartColor(new Color('FFE06B20')) ->setEndColor(new Color('FFFFFFFF')); -$row->nextCell()->createTextRun('R1C1')->getFont()->setBold(true); -$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(20); -$row->nextCell()->createTextRun('R1C2')->getFont()->setBold(true); -$row->nextCell()->createTextRun('R1C3')->getFont()->setBold(true); +$oCell = $row->nextCell(); +$oCell->createTextRun('R1C1')->getFont()->setBold(true); +$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(20); +$oCell = $row->nextCell(); +$oCell->createTextRun('R1C2')->getFont()->setBold(true); +$oCell = $row->nextCell(); +$oCell->createTextRun('R1C3')->getFont()->setBold(true); foreach ($row->getCells() as $cell) { $cell->getBorders()->getTop()->setLineWidth(4) @@ -78,12 +81,20 @@ $row->getFill()->setFillType(Fill::FILL_SOLID) ->setStartColor(new Color('FFE06B20')) ->setEndColor(new Color('FFE06B20')); -$row->nextCell()->createTextRun('R2C1'); -$row->getCell()->getActiveParagraph()->getAlignment() +$oCell = $row->nextCell(); +$oCell->createTextRun('R2C1'); +$oCell->getActiveParagraph()->getAlignment() ->setMarginLeft(30) ->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270); -$row->nextCell()->createTextRun('R2C2'); -$row->nextCell()->createTextRun('R2C3'); +$oCell = $row->nextCell(); +$oCell->createTextRun('R2C2'); +$oCell->getActiveParagraph()->getAlignment() + ->setMarginBottom(10) + ->setMarginTop(20) + ->setMarginRight(30) + ->setMarginLeft(40); +$oCell = $row->nextCell(); +$oCell->createTextRun('R2C3'); // Add row echo date('H:i:s') . ' Add row'.EOL; @@ -91,10 +102,13 @@ $row->getFill()->setFillType(Fill::FILL_SOLID) ->setStartColor(new Color('FFE06B20')) ->setEndColor(new Color('FFE06B20')); -$row->nextCell()->createTextRun('R3C1'); -$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(40); -$row->nextCell()->createTextRun('R3C2'); -$row->nextCell()->createTextRun('R3C3'); +$oCell = $row->nextCell(); +$oCell->createTextRun('R3C1'); +$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(40); +$oCell = $row->nextCell(); +$oCell->createTextRun('R3C2'); +$oCell = $row->nextCell(); +$oCell->createTextRun('R3C3'); // Add row echo date('H:i:s') . ' Add row'.EOL; diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index 6f99f3dd7..aae6457c4 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -451,10 +451,10 @@ protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, $sha } // Margins - $objWriter->writeAttribute('marL', $firstParagraphAlignment->getMarginLeft()); - $objWriter->writeAttribute('marR', $firstParagraphAlignment->getMarginRight()); - $objWriter->writeAttribute('marT', $firstParagraphAlignment->getMarginTop()); - $objWriter->writeAttribute('marB', $firstParagraphAlignment->getMarginBottom()); + $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginLeft())); + $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginRight())); + $objWriter->writeAttribute('marT', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginTop())); + $objWriter->writeAttribute('marB', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginBottom())); // Determine borders $borderLeft = $currentCell->getBorders()->getLeft(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php index c773ec1c9..d4fe82a56 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php @@ -724,10 +724,10 @@ public function testTableWithCellMargin() $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc/a:tcPr'; $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element); - $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marB', 10); - $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marL', 20); - $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marR', 30); - $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marT', 40); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marB', Drawing::pixelsToEmu(10)); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marL', Drawing::pixelsToEmu(20)); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marR', Drawing::pixelsToEmu(30)); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'marT', Drawing::pixelsToEmu(40)); } public function testTableWithColspan() From 9b5a51f586c4bee4b9ebe6f0ce8d551bc1ea1678 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Thu, 8 Jun 2017 14:20:33 +0200 Subject: [PATCH 19/31] Fixing bugs in writing out presentations: - images in master slides are not saved - duplicate IDs in relationships for master slides --- src/PhpPresentation/Writer/AbstractWriter.php | 5 +++-- .../Writer/PowerPoint2007/PptSlideMasters.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PhpPresentation/Writer/AbstractWriter.php b/src/PhpPresentation/Writer/AbstractWriter.php index 2304c0675..b3a6b6985 100644 --- a/src/PhpPresentation/Writer/AbstractWriter.php +++ b/src/PhpPresentation/Writer/AbstractWriter.php @@ -96,11 +96,12 @@ protected function allDrawings() // Get an array of all drawings $aDrawings = array(); - // Loop trough PhpPresentation - foreach ($this->getPhpPresentation()->getAllSlides() as $oSlide) { + // Loop through PhpPresentation + foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $this->getPhpPresentation()->getAllMasterSlides()) as $oSlide) { $arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator()); $aDrawings = array_merge($aDrawings, $arrayReturn); } + return $aDrawings; } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index 44dfeee8e..1bbc65300 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -55,7 +55,7 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) $slideLayout->relationId = 'rId' . $relId; } // Write drawing relationships? - $this->writeDrawingRelations($oMasterSlide, $objWriter, $relId); + $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId); // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml From 418a3029a76a3853fbd99cb79947d491251edfb4 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Thu, 8 Jun 2017 15:02:50 +0200 Subject: [PATCH 20/31] adding test for allDrawings function in AbstractWriter --- .../Tests/Writer/AbstractWriter.php | 37 +++++++++++++++++++ .../Tests/Writer/AbstractWriterTest.php | 23 ++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/PhpPresentation/Tests/Writer/AbstractWriter.php diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php new file mode 100644 index 000000000..6b9b2b431 --- /dev/null +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php @@ -0,0 +1,37 @@ +assertInstanceOf('PhpOffice\\PhpPresentation\\Writer\\AbstractWriter', $oStubWriter->setZipAdapter($oStubZip)); $this->assertInstanceOf('PhpOffice\\Common\\Adapter\\Zip\\ZipInterface', $oStubWriter->getZipAdapter()); } + + /** + * Test all drawings method + */ + public function testAllDrawings_includesMasterSlides() + { + $presentation = new PhpPresentation(); + + $activeSlide = $presentation->getActiveSlide(); + $activeSlide->createDrawingShape(); + + $masterSlide = $presentation->getAllMasterSlides()[0]; + $masterSlide->createDrawingShape(); + + $writer = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Tests\\Writer\\AbstractWriter'); + $writer->setPhpPresentation($presentation); + + $drawings = $writer->allDrawings(); + $this->assertEquals(2, count($drawings), 'Number of drawings should equal two: one from normal slide and one from master slide'); + } } From d6731abf0bbd75bfc1f72c8c53e37a06caed5aff Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Thu, 8 Jun 2017 15:47:07 +0200 Subject: [PATCH 21/31] first part of ppt slidemasters test --- .../PowerPoint2007/PptSlideMastersTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php new file mode 100644 index 000000000..250a9cdfb --- /dev/null +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php @@ -0,0 +1,34 @@ +getMockBuilder('PhpOffice\\PhpPresentation\\Slide\\SlideMaster') + ->setMethods(['getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection']) + ->getMock(); + + $layouts = [new SlideLayout($slideMaster)]; + + $slideMaster->expects($this->once()) + ->method('getAllSlideLayouts') + ->will($this->returnValue($layouts)); + + $slideMaster->expects($this->exactly(2)) + ->method('getShapeCollection') + ->will($this->returnValue(new \ArrayObject())); + + $data = $writer->writeSlideMasterRelationships($slideMaster); + } +} From f46c79caab0036d75736b50a2dc063544f4a10b7 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Thu, 8 Jun 2017 21:04:25 +0200 Subject: [PATCH 22/31] fixing bug in assigning relationship ids in master slide --- .../Writer/PowerPoint2007/AbstractSlide.php | 2 ++ .../Writer/PowerPoint2007/PptSlideMasters.php | 6 +++-- .../PowerPoint2007/PptSlideMastersTest.php | 23 ++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index aae6457c4..483c23aa8 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -108,6 +108,8 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, $objW $iterator->next(); } } + + return $relId; } /** diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index 1bbc65300..f0150dac5 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -54,12 +54,14 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) // Save the used relationId $slideLayout->relationId = 'rId' . $relId; } + // Write drawing relationships? - $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId); + $relId = $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId); + // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml - $this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml'); + $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml'); $objWriter->endElement(); // Return return $objWriter->getData(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php index 250a9cdfb..803c51a99 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php @@ -4,6 +4,7 @@ use PhpOffice\PhpPresentation\Writer\PowerPoint2007\PptSlideMasters; use PhpOffice\PhpPresentation\Slide\SlideLayout; +use PhpOffice\PhpPresentation\Shape\Drawing\File as ShapeDrawingFile; /** * Test class for PowerPoint2007 @@ -25,10 +26,30 @@ public function testWriteSlideMasterRelationships() ->method('getAllSlideLayouts') ->will($this->returnValue($layouts)); + $collection = new \ArrayObject(); + $collection[] = new ShapeDrawingFile(); + $collection[] = new ShapeDrawingFile(); + $collection[] = new ShapeDrawingFile(); + $slideMaster->expects($this->exactly(2)) ->method('getShapeCollection') - ->will($this->returnValue(new \ArrayObject())); + ->will($this->returnValue($collection)); $data = $writer->writeSlideMasterRelationships($slideMaster); + + $dom = new \DomDocument(); + $dom->loadXml($data); + + $xpath = new \DomXpath($dom); + $xpath->registerNamespace('r', 'http://schemas.openxmlformats.org/package/2006/relationships'); + $list = $xpath->query('//r:Relationship'); + + $this->assertEquals(5, $list->length); + + $this->assertEquals('rId1', $list->item(0)->getAttribute('Id')); + $this->assertEquals('rId2', $list->item(1)->getAttribute('Id')); + $this->assertEquals('rId3', $list->item(2)->getAttribute('Id')); + $this->assertEquals('rId4', $list->item(3)->getAttribute('Id')); + $this->assertEquals('rId5', $list->item(4)->getAttribute('Id')); } } From 87b646fca02f79640db0adc8a254e4928b932228 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 09:24:37 +0200 Subject: [PATCH 23/31] fixing issue #330: background images do not work for master slides --- .../Writer/PowerPoint2007/PptSlideMasters.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index f0150dac5..25b0f4d4e 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -11,6 +11,7 @@ use PhpOffice\PhpPresentation\Slide; use PhpOffice\PhpPresentation\Slide\SlideMaster; use PhpOffice\PhpPresentation\Style\SchemeColor; +use PhpOffice\PhpPresentation\Slide\Background\Image; class PptSlideMasters extends AbstractSlide { @@ -24,6 +25,13 @@ public function render() $this->oZip->addFromString('ppt/slideMasters/_rels/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml.rels', $this->writeSlideMasterRelationships($oMasterSlide)); // Add the information from the masterSlide to the ZIP file $this->oZip->addFromString('ppt/slideMasters/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml', $this->writeSlideMaster($oMasterSlide)); + + // Add background image slide + $oBkgImage = $oMasterSlide->getBackground(); + if ($oBkgImage instanceof Image) { + $this->oZip->addFromString('ppt/media/' . $oBkgImage->getIndexedFilename($oMasterSlide->getRelsIndex()), file_get_contents($oBkgImage->getPath())); + } + } return $this->oZip; @@ -58,6 +66,13 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) // Write drawing relationships? $relId = $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId); + // Write background relationships? + $oBackground = $oMasterSlide->getBackground(); + if ($oBackground instanceof Image) { + $this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($oMasterSlide->getRelsIndex())); + $oBackground->relationId = 'rId' . $relId; + } + // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml From aeb09c50a7c26a6695d058f5ec9d6c2a29d3cc47 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 09:24:37 +0200 Subject: [PATCH 24/31] fixing issue #330: background images do not work for master slides --- .../Writer/PowerPoint2007/PptSlideMasters.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index 44dfeee8e..e8b82ffca 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -11,6 +11,7 @@ use PhpOffice\PhpPresentation\Slide; use PhpOffice\PhpPresentation\Slide\SlideMaster; use PhpOffice\PhpPresentation\Style\SchemeColor; +use PhpOffice\PhpPresentation\Slide\Background\Image; class PptSlideMasters extends AbstractSlide { @@ -24,6 +25,13 @@ public function render() $this->oZip->addFromString('ppt/slideMasters/_rels/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml.rels', $this->writeSlideMasterRelationships($oMasterSlide)); // Add the information from the masterSlide to the ZIP file $this->oZip->addFromString('ppt/slideMasters/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml', $this->writeSlideMaster($oMasterSlide)); + + // Add background image slide + $oBkgImage = $oMasterSlide->getBackground(); + if ($oBkgImage instanceof Image) { + $this->oZip->addFromString('ppt/media/' . $oBkgImage->getIndexedFilename($oMasterSlide->getRelsIndex()), file_get_contents($oBkgImage->getPath())); + } + } return $this->oZip; @@ -55,7 +63,16 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) $slideLayout->relationId = 'rId' . $relId; } // Write drawing relationships? + $this->writeDrawingRelations($oMasterSlide, $objWriter, $relId); + + // Write background relationships? + $oBackground = $oMasterSlide->getBackground(); + if ($oBackground instanceof Image) { + $this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($oMasterSlide->getRelsIndex())); + $oBackground->relationId = 'rId' . $relId; + } + // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml From d24e74e4fd51277e7b99bc5f99e37d0f96b58b00 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 09:44:36 +0200 Subject: [PATCH 25/31] Revert "fixing issue #330: background images do not work for master slides" This reverts commit 87b646fca02f79640db0adc8a254e4928b932228. --- .../Writer/PowerPoint2007/PptSlideMasters.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index 25b0f4d4e..f0150dac5 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -11,7 +11,6 @@ use PhpOffice\PhpPresentation\Slide; use PhpOffice\PhpPresentation\Slide\SlideMaster; use PhpOffice\PhpPresentation\Style\SchemeColor; -use PhpOffice\PhpPresentation\Slide\Background\Image; class PptSlideMasters extends AbstractSlide { @@ -25,13 +24,6 @@ public function render() $this->oZip->addFromString('ppt/slideMasters/_rels/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml.rels', $this->writeSlideMasterRelationships($oMasterSlide)); // Add the information from the masterSlide to the ZIP file $this->oZip->addFromString('ppt/slideMasters/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml', $this->writeSlideMaster($oMasterSlide)); - - // Add background image slide - $oBkgImage = $oMasterSlide->getBackground(); - if ($oBkgImage instanceof Image) { - $this->oZip->addFromString('ppt/media/' . $oBkgImage->getIndexedFilename($oMasterSlide->getRelsIndex()), file_get_contents($oBkgImage->getPath())); - } - } return $this->oZip; @@ -66,13 +58,6 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) // Write drawing relationships? $relId = $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId); - // Write background relationships? - $oBackground = $oMasterSlide->getBackground(); - if ($oBackground instanceof Image) { - $this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($oMasterSlide->getRelsIndex())); - $oBackground->relationId = 'rId' . $relId; - } - // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml From 022fdb107e76c3b41e3309e97fb7231fc266206e Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 09:50:12 +0200 Subject: [PATCH 26/31] reverting separate fix for another issue cleaning code according to PSR2 standard --- tests/PhpPresentation/Tests/Writer/AbstractWriter.php | 1 + tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php index 6b9b2b431..2b94d31d9 100644 --- a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php @@ -16,6 +16,7 @@ */ namespace PhpOffice\PhpPresentation\Tests\Writer; + use PhpOffice\PhpPresentation\Writer; /** diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php index b88898390..76553869a 100644 --- a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php @@ -16,6 +16,7 @@ */ namespace PhpOffice\PhpPresentation\Tests\Writer; + use PhpOffice\PhpPresentation\PhpPresentation; require 'AbstractWriter.php'; @@ -43,7 +44,7 @@ public function testConstruct() /** * Test all drawings method */ - public function testAllDrawings_includesMasterSlides() + public function testAllDrawingsIncludesMasterSlides() { $presentation = new PhpPresentation(); From f5852aba3a98b8f53a89d1b3485aa8edf2ea4a4a Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 09:52:37 +0200 Subject: [PATCH 27/31] cleaning code according to PSR2 code standard --- src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index e8b82ffca..30cf742e3 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -31,7 +31,6 @@ public function render() if ($oBkgImage instanceof Image) { $this->oZip->addFromString('ppt/media/' . $oBkgImage->getIndexedFilename($oMasterSlide->getRelsIndex()), file_get_contents($oBkgImage->getPath())); } - } return $this->oZip; From ccd068df28df132ff55ac4a899e49b446c2dd10e Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 10:11:28 +0200 Subject: [PATCH 28/31] changing new test to allow running on php 5.3 --- tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php index 76553869a..2606d41b8 100644 --- a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php @@ -51,7 +51,8 @@ public function testAllDrawingsIncludesMasterSlides() $activeSlide = $presentation->getActiveSlide(); $activeSlide->createDrawingShape(); - $masterSlide = $presentation->getAllMasterSlides()[0]; + $masterSlides = $presentation->getAllMasterSlides(); + $masterSlide = $masterSlides[0]; $masterSlide->createDrawingShape(); $writer = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Tests\\Writer\\AbstractWriter'); From 6e8bda5b9daa38125fd98b11c841337dd7f88162 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Fri, 9 Jun 2017 10:29:23 +0200 Subject: [PATCH 29/31] adjusting test code to work with php 5.3 --- .../Tests/Writer/PowerPoint2007/PptSlideMastersTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php index 803c51a99..d19136d7c 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlideMastersTest.php @@ -17,10 +17,10 @@ public function testWriteSlideMasterRelationships() { $writer = new PptSlideMasters(); $slideMaster = $this->getMockBuilder('PhpOffice\\PhpPresentation\\Slide\\SlideMaster') - ->setMethods(['getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection']) + ->setMethods(array('getAllSlideLayouts', 'getRelsIndex', 'getShapeCollection')) ->getMock(); - $layouts = [new SlideLayout($slideMaster)]; + $layouts = array(new SlideLayout($slideMaster)); $slideMaster->expects($this->once()) ->method('getAllSlideLayouts') From a9d4bf4b0265d5b3a709b5d70da47622b040ea25 Mon Sep 17 00:00:00 2001 From: Peter Lind Date: Sun, 11 Jun 2017 12:30:27 +0200 Subject: [PATCH 30/31] fixing relationship ids to be sequential in writing out powerpoint master slides --- src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php index 2a3b17cb3..b8ce79cab 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php @@ -70,12 +70,14 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide) if ($oBackground instanceof Image) { $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($oMasterSlide->getRelsIndex())); $oBackground->relationId = 'rId' . $relId; + + $relId++; } // TODO: Write hyperlink relationships? // TODO: Write comment relationships // Relationship theme/theme1.xml - $this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml'); + $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml'); $objWriter->endElement(); // Return return $objWriter->getData(); From f71a4a2a17f73c2f591f713494b85137347f0200 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 5 Jul 2017 12:17:40 +0200 Subject: [PATCH 31/31] #349 : Version 0.9.0 : Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd80ae4a..4f2b08b5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 0.9.0 - WIP +## 0.9.0 - 2017-07-05 ### Bugfix - PowerPoint2007 Writer : Margins in table cell - @Progi1984 GH-347