From 9cd38dde032bbde8f5b296d9665d067bf8bfec94 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Jul 2025 11:55:38 +0100 Subject: [PATCH 01/15] add rotation --- .idea/.gitignore | 8 +++++ .idea/PHPPresentation.iml | 11 ++++++ .idea/modules.xml | 8 +++++ .idea/php.xml | 22 ++++++++++++ .idea/vcs.xml | 6 ++++ .../Shape/Chart/Type/Doughnut.php | 36 +++++++++++++++++++ .../Writer/PowerPoint2007/PptCharts.php | 7 +++- 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/PHPPresentation.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/PHPPresentation.iml b/.idea/PHPPresentation.iml new file mode 100644 index 000000000..4563b42b9 --- /dev/null +++ b/.idea/PHPPresentation.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..2c5dcbb4d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 000000000..29059d00f --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index 6f2437f67..bf0b4ebe1 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -34,6 +34,16 @@ class Doughnut extends AbstractTypePie implements ComparableInterface */ protected $holeSize = 50; + /** + * Chart Direction & Rotation + * + * @var string + */ + public const DIR_CLOCKWISE = 'clockWise'; + public const DIR_COUNTERCLOCKWISE = 'counterClockwise'; + private ?int $firstSliceAngle = null; // 0-359 + private string $pieDirection = self::DIR_CLOCKWISE; + /** * @return int */ @@ -71,4 +81,30 @@ public function getHashCode(): string { return md5(parent::getHashCode() . __CLASS__); } + + public function setFirstSliceAngle(int $angle): self + { + $this->firstSliceAngle = (($angle % 360) + 360) % 360; + return $this; + } + + public function getFirstSliceAngle(): ?int + { + return $this->firstSliceAngle; + } + + public function setPieDirection(string $dir): self + { + if (!in_array($dir, [self::DIR_CLOCKWISE, self::DIR_COUNTERCLOCKWISE], true)) { + throw new \InvalidArgumentException('Invalid pie direction'); + } + $this->pieDirection = $dir; + + return $this; + } + + public function getPieDirection(): string + { + return $this->pieDirection; + } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index a9a0ec758..e9b88d92f 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -1213,6 +1213,12 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->writeAttribute('val', '1'); $objWriter->endElement(); + if (($angle = $subject->getFirstSliceAngle()) !== null) { + $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', (string) $angle); + } + // Always emit pieDir; default is clockWise + $this->writeElementWithValAttribute($objWriter, 'c:pieDir', $subject->getPieDirection()); + // Write series $seriesIndex = 0; foreach ($subject->getSeries() as $series) { @@ -1352,7 +1358,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->endElement(); } - $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', '0'); $this->writeElementWithValAttribute($objWriter, 'c:holeSize', (string) $subject->getHoleSize()); $objWriter->endElement(); From 1c42c92e2943d64e1b4013bb25314f09f9f43dd8 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Jul 2025 12:20:12 +0100 Subject: [PATCH 02/15] remove .idea --- .gitignore | 2 ++ .idea/.gitignore | 8 -------- .idea/PHPPresentation.iml | 11 ----------- .idea/modules.xml | 8 -------- .idea/php.xml | 22 ---------------------- .idea/vcs.xml | 6 ------ 6 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/PHPPresentation.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index d0a44e14a..d26f282fa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ .Trashes Thumbs.db Desktop.ini +.idea/ +*.iml ### Continuous Integration build/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/PHPPresentation.iml b/.idea/PHPPresentation.iml deleted file mode 100644 index 4563b42b9..000000000 --- a/.idea/PHPPresentation.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 2c5dcbb4d..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 29059d00f..000000000 --- a/.idea/php.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfb..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 988f7b4a6b3f68c38130fc5a5a270ee3f5b59daf Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Jul 2025 15:50:20 +0100 Subject: [PATCH 03/15] set view3D conditionally to enable angle offset --- .../Writer/PowerPoint2007/PptCharts.php | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index e9b88d92f..ae005f011 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -115,38 +115,40 @@ protected function writeChart(Chart $chart): string $objWriter->endElement(); // c:view3D - $objWriter->startElement('c:view3D'); + if ($chart->getPlotArea()->getType() instanceof Bar3D || $chart->getPlotArea()->getType() instanceof Pie3D) { + $objWriter->startElement('c:view3D'); - // c:rotX - $objWriter->startElement('c:rotX'); - $objWriter->writeAttribute('val', $chart->getView3D()->getRotationX()); - $objWriter->endElement(); + // c:rotX + $objWriter->startElement('c:rotX'); + $objWriter->writeAttribute('val', $chart->getView3D()->getRotationX()); + $objWriter->endElement(); - // c:hPercent - $hPercent = $chart->getView3D()->getHeightPercent(); - $objWriter->writeElementIf(null != $hPercent, 'c:hPercent', 'val', $hPercent); + // c:hPercent + $hPercent = $chart->getView3D()->getHeightPercent(); + $objWriter->writeElementIf(null != $hPercent, 'c:hPercent', 'val', $hPercent); - // c:rotY - $objWriter->startElement('c:rotY'); - $objWriter->writeAttribute('val', $chart->getView3D()->getRotationY()); - $objWriter->endElement(); + // c:rotY + $objWriter->startElement('c:rotY'); + $objWriter->writeAttribute('val', $chart->getView3D()->getRotationY()); + $objWriter->endElement(); - // c:depthPercent - $objWriter->startElement('c:depthPercent'); - $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent()); - $objWriter->endElement(); + // c:depthPercent + $objWriter->startElement('c:depthPercent'); + $objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent()); + $objWriter->endElement(); - // c:rAngAx - $objWriter->startElement('c:rAngAx'); - $objWriter->writeAttribute('val', $chart->getView3D()->hasRightAngleAxes() ? '1' : '0'); - $objWriter->endElement(); + // c:rAngAx + $objWriter->startElement('c:rAngAx'); + $objWriter->writeAttribute('val', $chart->getView3D()->hasRightAngleAxes() ? '1' : '0'); + $objWriter->endElement(); - // c:perspective - $objWriter->startElement('c:perspective'); - $objWriter->writeAttribute('val', $chart->getView3D()->getPerspective()); - $objWriter->endElement(); + // c:perspective + $objWriter->startElement('c:perspective'); + $objWriter->writeAttribute('val', $chart->getView3D()->getPerspective()); + $objWriter->endElement(); - $objWriter->endElement(); + $objWriter->endElement(); + } // Write plot area $this->writePlotArea($objWriter, $chart->getPlotArea(), $chart); @@ -1358,6 +1360,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->endElement(); } + // $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', '0'); $this->writeElementWithValAttribute($objWriter, 'c:holeSize', (string) $subject->getHoleSize()); $objWriter->endElement(); From 7a3419ded1363298320e2ec37bb30a049a35d165 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Jul 2025 15:52:27 +0100 Subject: [PATCH 04/15] make pie-direction conditional --- .../Writer/PowerPoint2007/PptCharts.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index ae005f011..ffe4c704b 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -1218,8 +1218,14 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo if (($angle = $subject->getFirstSliceAngle()) !== null) { $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', (string) $angle); } - // Always emit pieDir; default is clockWise - $this->writeElementWithValAttribute($objWriter, 'c:pieDir', $subject->getPieDirection()); + + if ($subject->getPieDirection() === Doughnut::DIR_COUNTERCLOCKWISE) { + $this->writeElementWithValAttribute( + $objWriter, + 'c:pieDir', + Doughnut::DIR_COUNTERCLOCKWISE + ); + } // Write series $seriesIndex = 0; From e073d13efd868fa0da13bbe5d40c8c4e7289b720 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 10 Jul 2025 15:58:18 +0100 Subject: [PATCH 05/15] remove comment --- src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index ffe4c704b..5e821c5b5 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -1366,7 +1366,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->endElement(); } - // $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', '0'); $this->writeElementWithValAttribute($objWriter, 'c:holeSize', (string) $subject->getHoleSize()); $objWriter->endElement(); From 60032a195ce9ab1ed1f4ddaa8c4226295d61ca32 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 10:55:05 +0100 Subject: [PATCH 06/15] remove direction --- .../Shape/Chart/Type/Doughnut.php | 24 +++---------------- .../Writer/PowerPoint2007/PptCharts.php | 8 ------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index bf0b4ebe1..d14a69d7a 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -35,14 +35,11 @@ class Doughnut extends AbstractTypePie implements ComparableInterface protected $holeSize = 50; /** - * Chart Direction & Rotation + * Chart Rotation * - * @var string + * @var string (0-395)) */ - public const DIR_CLOCKWISE = 'clockWise'; - public const DIR_COUNTERCLOCKWISE = 'counterClockwise'; - private ?int $firstSliceAngle = null; // 0-359 - private string $pieDirection = self::DIR_CLOCKWISE; + private $firstSliceAngle = 0; /** * @return int @@ -92,19 +89,4 @@ public function getFirstSliceAngle(): ?int { return $this->firstSliceAngle; } - - public function setPieDirection(string $dir): self - { - if (!in_array($dir, [self::DIR_CLOCKWISE, self::DIR_COUNTERCLOCKWISE], true)) { - throw new \InvalidArgumentException('Invalid pie direction'); - } - $this->pieDirection = $dir; - - return $this; - } - - public function getPieDirection(): string - { - return $this->pieDirection; - } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 5e821c5b5..015bb5e0c 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -1219,14 +1219,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', (string) $angle); } - if ($subject->getPieDirection() === Doughnut::DIR_COUNTERCLOCKWISE) { - $this->writeElementWithValAttribute( - $objWriter, - 'c:pieDir', - Doughnut::DIR_COUNTERCLOCKWISE - ); - } - // Write series $seriesIndex = 0; foreach ($subject->getSeries() as $series) { From 4245b2796bfe102f67072b4a5cfb5821a8183781 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 15:56:03 +0100 Subject: [PATCH 07/15] fix tests --- .../Shape/Chart/Type/Doughnut.php | 6 ++-- .../Writer/PowerPoint2007/PptCharts.php | 8 ++--- .../Writer/PowerPoint2007/PptChartsTest.php | 34 ++++++++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index d14a69d7a..e4774bcf8 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -35,11 +35,11 @@ class Doughnut extends AbstractTypePie implements ComparableInterface protected $holeSize = 50; /** - * Chart Rotation + * Starting angle of the first slice * - * @var string (0-395)) + * @var int */ - private $firstSliceAngle = 0; + private int $firstSliceAngle = 0; /** * @return int diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 015bb5e0c..e9f508b5c 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -1215,10 +1215,6 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->writeAttribute('val', '1'); $objWriter->endElement(); - if (($angle = $subject->getFirstSliceAngle()) !== null) { - $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', (string) $angle); - } - // Write series $seriesIndex = 0; foreach ($subject->getSeries() as $series) { @@ -1358,6 +1354,10 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo $objWriter->endElement(); } + if (($angle = $subject->getFirstSliceAngle()) !== null) { + $this->writeElementWithValAttribute($objWriter, 'c:firstSliceAng', (string) $angle); + } + $this->writeElementWithValAttribute($objWriter, 'c:holeSize', (string) $subject->getHoleSize()); $objWriter->endElement(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index 21ff6c5ac..c72c7cfa5 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -1809,20 +1809,38 @@ public function testTypeScatterSuperScript(): void public function testView3D(): void { $oSlide = $this->oPresentation->getActiveSlide(); - $oLine = new Line(); - $oLine->addSeries(new Series('Downloads', $this->seriesData)); - $oShape = $oSlide->createChartShape(); - $oShape->getPlotArea()->setType($oLine); + $shape3d = $oSlide->createChartShape(); + $shape3d->getPlotArea()->setType(new Bar3D()); $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->assertZipXmlElementExists('ppt/charts/' . $shape3d->getIndexedFilename(), $element); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $shape3d->getIndexedFilename(), $element, 'val', '100'); $this->assertIsSchemaECMA376Valid(); - $oShape->getView3D()->setHeightPercent(null); + $shape3d->getView3D()->setHeightPercent(null); $this->resetPresentationFile(); - $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); + $this->assertZipXmlElementNotExists('ppt/charts/' . $shape3d->getIndexedFilename(), $element); + $this->assertIsSchemaECMA376Valid(); + } + + public function testDoughnutFirstSliceAngle(): void + { + $slide = $this->oPresentation->getActiveSlide(); + $shape = $slide->createChartShape(); + + $doughnut = new Doughnut(); + $doughnut->setFirstSliceAngle(90); // rotate quarter-turn + $doughnut->addSeries(new Series('Downloads', $this->seriesData)); + + $shape->getPlotArea()->setType($doughnut); + + $path = 'ppt/charts/' . $shape->getIndexedFilename(); + $elt = '/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:firstSliceAng'; + + $this->assertZipXmlElementExists($path, $elt); + $this->assertZipXmlAttributeEquals($path, $elt, 'val', '90'); + $this->assertIsSchemaECMA376Valid(); } From 9b4fe2f66a6b2244b8f9c68b0d041a6d6ba0296c Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:08:28 +0100 Subject: [PATCH 08/15] remove comment --- .../Tests/Writer/PowerPoint2007/PptChartsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index c72c7cfa5..fbb56cec8 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -1830,7 +1830,7 @@ public function testDoughnutFirstSliceAngle(): void $shape = $slide->createChartShape(); $doughnut = new Doughnut(); - $doughnut->setFirstSliceAngle(90); // rotate quarter-turn + $doughnut->setFirstSliceAngle(90); $doughnut->addSeries(new Series('Downloads', $this->seriesData)); $shape->getPlotArea()->setType($doughnut); From 9f7528a3a07f89032fc08963d1751e9316edca58 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:27:24 +0100 Subject: [PATCH 09/15] update changelog --- docs/changes/1.2.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes/1.2.0.md b/docs/changes/1.2.0.md index 0c03ba6bc..8b5b18324 100644 --- a/docs/changes/1.2.0.md +++ b/docs/changes/1.2.0.md @@ -16,6 +16,7 @@ - PowerPoint2007 Reader : Support for BarChart by [@Progi1984](https://github.com/Progi1984) fixing [#824](https://github.com/PHPOffice/PHPPresentation/pull/824) in [#856](https://github.com/PHPOffice/PHPPresentation/pull/856) - `phpoffice/phpspreadsheet`: Allow version 4.0 by [@nreynis](https://github.com/nreynis) in [#861](https://github.com/PHPOffice/PHPPresentation/pull/861) - Smaller package size by [@nreynis](https://github.com/nreynis) in [#862](https://github.com/PHPOffice/PHPPresentation/pull/862) +- Added setFirstSliceAngle to Doughnut Chart to offset the chart in [#872](https://github.com/PHPOffice/PHPPresentation/pull/872) ## Bug fixes From 48c1576665a3c96641df6571e97465fd8d349397 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:28:18 +0100 Subject: [PATCH 10/15] update changelog --- docs/changes/1.2.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changes/1.2.0.md b/docs/changes/1.2.0.md index 8b5b18324..4247f38b8 100644 --- a/docs/changes/1.2.0.md +++ b/docs/changes/1.2.0.md @@ -16,7 +16,7 @@ - PowerPoint2007 Reader : Support for BarChart by [@Progi1984](https://github.com/Progi1984) fixing [#824](https://github.com/PHPOffice/PHPPresentation/pull/824) in [#856](https://github.com/PHPOffice/PHPPresentation/pull/856) - `phpoffice/phpspreadsheet`: Allow version 4.0 by [@nreynis](https://github.com/nreynis) in [#861](https://github.com/PHPOffice/PHPPresentation/pull/861) - Smaller package size by [@nreynis](https://github.com/nreynis) in [#862](https://github.com/PHPOffice/PHPPresentation/pull/862) -- Added setFirstSliceAngle to Doughnut Chart to offset the chart in [#872](https://github.com/PHPOffice/PHPPresentation/pull/872) +- Added setFirstSliceAngle to Doughnut Chart by [@seanlynchwv](http://github.com/seanlynchwv) in [#872](https://github.com/PHPOffice/PHPPresentation/pull/872) ## Bug fixes From 12202f0ad4cf6a7de1d297f8c78de80f2a944115 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:29:44 +0100 Subject: [PATCH 11/15] update gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index d26f282fa..bf0d32476 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ Thumbs.db Desktop.ini .idea/ -*.iml ### Continuous Integration build/ From 047a32b033aa3d736831bc062fde474a42fb4fea Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:33:57 +0100 Subject: [PATCH 12/15] remove int type --- src/PhpPresentation/Shape/Chart/Type/Doughnut.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index e4774bcf8..5d843751b 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -39,7 +39,7 @@ class Doughnut extends AbstractTypePie implements ComparableInterface * * @var int */ - private int $firstSliceAngle = 0; + private $firstSliceAngle = 0; /** * @return int From 7fe3de5f5a94641ee3bb42269f1d9a27df036cf8 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:41:44 +0100 Subject: [PATCH 13/15] fix cs-fixer --- src/PhpPresentation/Shape/Chart/Type/Doughnut.php | 3 ++- .../Tests/Writer/PowerPoint2007/PptChartsTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index 5d843751b..847676d6a 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -35,7 +35,7 @@ class Doughnut extends AbstractTypePie implements ComparableInterface protected $holeSize = 50; /** - * Starting angle of the first slice + * Starting angle of the first slice. * * @var int */ @@ -82,6 +82,7 @@ public function getHashCode(): string public function setFirstSliceAngle(int $angle): self { $this->firstSliceAngle = (($angle % 360) + 360) % 360; + return $this; } diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index fbb56cec8..9bcb97bf5 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -1836,7 +1836,7 @@ public function testDoughnutFirstSliceAngle(): void $shape->getPlotArea()->setType($doughnut); $path = 'ppt/charts/' . $shape->getIndexedFilename(); - $elt = '/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:firstSliceAng'; + $elt = '/c:chartSpace/c:chart/c:plotArea/c:doughnutChart/c:firstSliceAng'; $this->assertZipXmlElementExists($path, $elt); $this->assertZipXmlAttributeEquals($path, $elt, 'val', '90'); From deaec5eb7166632764bfd41b4c0a9a4f4b938a01 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Jul 2025 16:44:19 +0100 Subject: [PATCH 14/15] fix cs-fixer --- .../Tests/Writer/PowerPoint2007/PptChartsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index 9bcb97bf5..7f6694375 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -1826,8 +1826,8 @@ public function testView3D(): void public function testDoughnutFirstSliceAngle(): void { - $slide = $this->oPresentation->getActiveSlide(); - $shape = $slide->createChartShape(); + $slide = $this->oPresentation->getActiveSlide(); + $shape = $slide->createChartShape(); $doughnut = new Doughnut(); $doughnut->setFirstSliceAngle(90); From a580424f90c0b356f06f93f1ab7310efa9307842 Mon Sep 17 00:00:00 2001 From: seanlynchwv Date: Mon, 28 Jul 2025 09:17:35 +0100 Subject: [PATCH 15/15] Update src/PhpPresentation/Shape/Chart/Type/Doughnut.php Co-authored-by: Progi1984 --- src/PhpPresentation/Shape/Chart/Type/Doughnut.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php index 847676d6a..77074e051 100644 --- a/src/PhpPresentation/Shape/Chart/Type/Doughnut.php +++ b/src/PhpPresentation/Shape/Chart/Type/Doughnut.php @@ -86,7 +86,7 @@ public function setFirstSliceAngle(int $angle): self return $this; } - public function getFirstSliceAngle(): ?int + public function getFirstSliceAngle(): int { return $this->firstSliceAngle; }