Skip to content

Commit

Permalink
Revert xml element method in ChartTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-roth committed Aug 14, 2021
1 parent d7d3099 commit c3e6ad9
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 74 deletions.
7 changes: 0 additions & 7 deletions src/PhpPresentation/Shape/Chart/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
*/
Expand Down
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ public function getHashCode(): string

return md5($hash . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:areaChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ public function getHashCode(): string
{
return md5(parent::getHashCode() . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:barChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Bar3D.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ public function getHashCode(): string
{
return md5(parent::getHashCode() . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:bar3DChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Doughnut.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,4 @@ public function getHashCode(): string
{
return md5(parent::getHashCode() . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:doughnutChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ public function getHashCode(): string

return md5(parent::getHashCode() . $hash . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:lineChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Pie.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ public function getHashCode(): string
{
return md5(parent::getHashCode() . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:pieChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Pie3D.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ public function getHashCode(): string
{
return md5(parent::getHashCode() . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:pie3DChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Radar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ public function getHashCode(): string

return md5($hash . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:radarChart';
}
}
5 changes: 0 additions & 5 deletions src/PhpPresentation/Shape/Chart/Type/Scatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ public function getHashCode(): string

return md5(parent::getHashCode() . $hash . __CLASS__);
}

public function getXmlElementName(): string
{
return 'c:scatterChart';
}
}
18 changes: 9 additions & 9 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
25 changes: 12 additions & 13 deletions tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -1497,23 +1496,23 @@ public function dataProviderMarkerSymbol(): iterable
}

/**
* @return array<array<string>>
* @return array<array<string, string>>
*/
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;
}
}
}

0 comments on commit c3e6ad9

Please sign in to comment.