From c3e6ad901abc98d1677aa6fc8af5c1f5b7d93c2d Mon Sep 17 00:00:00 2001 From: michael-roth Date: Sat, 14 Aug 2021 12:50:12 +0200 Subject: [PATCH] Revert xml element method in ChartTypes --- .../Shape/Chart/Type/AbstractType.php | 7 ------ src/PhpPresentation/Shape/Chart/Type/Area.php | 5 ---- src/PhpPresentation/Shape/Chart/Type/Bar.php | 5 ---- .../Shape/Chart/Type/Bar3D.php | 5 ---- .../Shape/Chart/Type/Doughnut.php | 5 ---- src/PhpPresentation/Shape/Chart/Type/Line.php | 5 ---- src/PhpPresentation/Shape/Chart/Type/Pie.php | 5 ---- .../Shape/Chart/Type/Pie3D.php | 5 ---- .../Shape/Chart/Type/Radar.php | 5 ---- .../Shape/Chart/Type/Scatter.php | 5 ---- .../Writer/PowerPoint2007/PptCharts.php | 18 ++++++------- .../Writer/PowerPoint2007/PptChartsTest.php | 25 +++++++++---------- 12 files changed, 21 insertions(+), 74 deletions(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php index d888b232c..99b42c430 100644 --- a/src/PhpPresentation/Shape/Chart/Type/AbstractType.php +++ b/src/PhpPresentation/Shape/Chart/Type/AbstractType.php @@ -52,13 +52,6 @@ abstract class AbstractType implements ComparableInterface */ private $series = []; - /** - * Returns xml element name for a chart type implementation - * - * @return string - */ - abstract public function getXmlElementName(): string; - /** * Has Axis X? */ diff --git a/src/PhpPresentation/Shape/Chart/Type/Area.php b/src/PhpPresentation/Shape/Chart/Type/Area.php index 817a49e33..a8c39ff00 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Area.php +++ b/src/PhpPresentation/Shape/Chart/Type/Area.php @@ -39,9 +39,4 @@ public function getHashCode(): string return md5($hash . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:areaChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Bar.php b/src/PhpPresentation/Shape/Chart/Type/Bar.php index 4b0a8338d..602b69d53 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Bar.php +++ b/src/PhpPresentation/Shape/Chart/Type/Bar.php @@ -34,9 +34,4 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:barChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Bar3D.php b/src/PhpPresentation/Shape/Chart/Type/Bar3D.php index 1ab79e094..b2127862d 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Bar3D.php +++ b/src/PhpPresentation/Shape/Chart/Type/Bar3D.php @@ -34,9 +34,4 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:bar3DChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index d09f0922a..33da681fd 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -69,9 +69,4 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:doughnutChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Line.php b/src/PhpPresentation/Shape/Chart/Type/Line.php index 20df71555..4d1f07cad 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Line.php +++ b/src/PhpPresentation/Shape/Chart/Type/Line.php @@ -36,9 +36,4 @@ public function getHashCode(): string return md5(parent::getHashCode() . $hash . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:lineChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Pie.php b/src/PhpPresentation/Shape/Chart/Type/Pie.php index 4e5e6a269..94c9ff20b 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Pie.php +++ b/src/PhpPresentation/Shape/Chart/Type/Pie.php @@ -34,9 +34,4 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:pieChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Pie3D.php b/src/PhpPresentation/Shape/Chart/Type/Pie3D.php index 6821748d1..1ee43bce9 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Pie3D.php +++ b/src/PhpPresentation/Shape/Chart/Type/Pie3D.php @@ -34,9 +34,4 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:pie3DChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Radar.php b/src/PhpPresentation/Shape/Chart/Type/Radar.php index e6e63852c..85525f10e 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Radar.php +++ b/src/PhpPresentation/Shape/Chart/Type/Radar.php @@ -36,9 +36,4 @@ public function getHashCode(): string return md5($hash . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:radarChart'; - } } diff --git a/src/PhpPresentation/Shape/Chart/Type/Scatter.php b/src/PhpPresentation/Shape/Chart/Type/Scatter.php index 60ef7eed4..3cb2bba43 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Scatter.php +++ b/src/PhpPresentation/Shape/Chart/Type/Scatter.php @@ -36,9 +36,4 @@ public function getHashCode(): string return md5(parent::getHashCode() . $hash . __CLASS__); } - - public function getXmlElementName(): string - { - return 'c:scatterChart'; - } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 2f57686f8..af0c64f99 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -701,7 +701,7 @@ protected function writeLayout(XMLWriter $objWriter, $subject): void protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $includeSheet = false): void { // c:lineChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:areaChart'); // c:grouping $objWriter->startElement('c:grouping'); @@ -804,7 +804,7 @@ protected function writeTypeArea(XMLWriter $objWriter, Area $subject, bool $incl protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includeSheet = false): void { // c:barChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:barChart'); // c:barDir $objWriter->startElement('c:barDir'); @@ -1017,7 +1017,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $includeSheet = false): void { // c:bar3DChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:bar3DChart'); // c:barDir $objWriter->startElement('c:barDir'); @@ -1210,7 +1210,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bool $includeSheet = false): void { // c:pieChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:doughnutChart'); // c:varyColors $objWriter->startElement('c:varyColors'); @@ -1369,7 +1369,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includeSheet = false): void { // c:pieChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:pieChart'); // c:varyColors $objWriter->startElement('c:varyColors'); @@ -1534,7 +1534,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $includeSheet = false): void { // c:pie3DChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:pie3DChart'); // c:varyColors $objWriter->startElement('c:varyColors'); @@ -1693,7 +1693,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $includeSheet = false): void { // c:lineChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:lineChart'); // c:grouping $objWriter->startElement('c:grouping'); @@ -1864,7 +1864,7 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $includeSheet = false): void { // c:scatterChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:radarChart'); // c:radarStyle $objWriter->startElement('c:radarStyle'); @@ -2028,7 +2028,7 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool $includeSheet = false): void { // c:scatterChart - $objWriter->startElement($subject->getXmlElementName()); + $objWriter->startElement('c:scatterChart'); // c:scatterStyle $objWriter->startElement('c:scatterStyle'); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index b55fc8764..88a284641 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -85,7 +85,7 @@ public function testChartDisplayBlankAs(): void /** * @dataProvider dataProviderIncludedSpreadsheet */ - public function testChartIncludeSpreadsheet(string $chartType): void + public function testChartIncludeSpreadsheet(string $chartType, string $chartElementName): void { $oSlide = $this->oPresentation->getActiveSlide(); $oShape = $oSlide->createChartShape(); @@ -96,7 +96,6 @@ public function testChartIncludeSpreadsheet(string $chartType): void $oChart->addSeries($oSeries); $oShape->getPlotArea()->setType($oChart); - $chartElementName = $oChart->getXmlElementName(); $chartBaseXmlPath = sprintf('/c:chartSpace/c:chart/c:plotArea/%s', $chartElementName); $this->assertTrue($oShape->hasIncludedSpreadsheet()); @@ -1497,23 +1496,23 @@ public function dataProviderMarkerSymbol(): iterable } /** - * @return array> + * @return array> */ public function dataProviderIncludedSpreadsheet(): iterable { $chartTypes = [ - Area::class, - Bar::class, - Bar3D::class, - Doughnut::class, - Pie::class, - Pie3D::class, - Line::class, - Radar::class, - Scatter::class, + [Area::class, 'c:areaChart'], + [Bar::class, 'c:barChart'], + [Bar3D::class, 'c:bar3DChart'], + [Doughnut::class, 'c:doughnutChart'], + [Pie::class, 'c:pieChart'], + [Pie3D::class, 'c:pie3DChart'], + [Line::class, 'c:lineChart'], + [Radar::class, 'c:radarChart'], + [Scatter::class, 'c:scatterChart'], ]; foreach ($chartTypes as $chartType) { - yield [$chartType]; + yield $chartType; } } }