From 15fe29d30ac0648fa0b1928b396d09733f727c15 Mon Sep 17 00:00:00 2001 From: Pakku Date: Tue, 29 Nov 2022 16:50:47 +0100 Subject: [PATCH] PowerPoint2007 Writer : Outline : Fixed the base unit --- docs/changes/1.1.0.md | 6 +++++- src/PhpPresentation/Style/Outline.php | 11 +++++++---- .../Writer/ODPresentation/ObjectsChart.php | 2 +- .../Writer/PowerPoint2007/AbstractDecoratorWriter.php | 2 +- .../Tests/Writer/ODPresentation/ObjectsChartTest.php | 2 +- .../Tests/Writer/PowerPoint2007/PptChartsTest.php | 10 +++++----- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/docs/changes/1.1.0.md b/docs/changes/1.1.0.md index a95d5ace1..1c4757927 100644 --- a/docs/changes/1.1.0.md +++ b/docs/changes/1.1.0.md @@ -15,4 +15,8 @@ - Fixed CI - [@Progi1984](https://github.com/Progi1984) in [#766](https://github.com/PHPOffice/PHPPresentation/pull/766) - PowerPoint2077 Writer : Fixed broken PPT Presentations due to MS Office update 2309 - [@WFarmerEthisphere](https://github.com/WFarmerEthisphere) in [#770](https://github.com/PHPOffice/PHPPresentation/pull/770) -- PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0 - [@LilyEssence](https://github.com/LilyEssence) in [#771](https://github.com/PHPOffice/PHPPresentation/pull/771) \ No newline at end of file +- PowerPoint2077 Writer : Fixed error when defining min/max bounds to 0 - [@LilyEssence](https://github.com/LilyEssence) in [#771](https://github.com/PHPOffice/PHPPresentation/pull/771) +- PowerPoint2007 Writer : Outline : Fixed the base unit - [@Pakku](https://github.com/Pakku) in [#772](https://github.com/PHPOffice/PHPPresentation/pull/772) + +## BC Breaks +- `PhpOffice\PhpPresentation\Style\Outline` : the width is now based on pixels (before in points) \ No newline at end of file diff --git a/src/PhpPresentation/Style/Outline.php b/src/PhpPresentation/Style/Outline.php index ed7ba1656..ab1cc9d69 100644 --- a/src/PhpPresentation/Style/Outline.php +++ b/src/PhpPresentation/Style/Outline.php @@ -30,7 +30,7 @@ class Outline protected $fill; /** - * @var float + * @var int */ protected $width = 1; @@ -51,15 +51,18 @@ public function setFill(Fill $fill): self return $this; } - public function getWidth(): float + /** + * Value in pixels. + */ + public function getWidth(): int { return $this->width; } /** - * Value in points. + * Value in pixels. */ - public function setWidth(float $pValue = 1): self + public function setWidth(int $pValue = 1): self { $this->width = $pValue; diff --git a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php index 41aa54b58..c58b25d60 100644 --- a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php +++ b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php @@ -775,7 +775,7 @@ protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void if ($oOutline instanceof Outline) { $outlineWidth = $oOutline->getWidth(); if (!empty($outlineWidth)) { - $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', ''); + $outlineWidth = number_format(CommonDrawing::pixelsToCentimeters($outlineWidth), 3, '.', ''); } $outlineColor = $oOutline->getFill()->getStartColor()->getRGB(); } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php index 0c77e9516..a96413c2d 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php @@ -263,7 +263,7 @@ protected function writeOutline(XMLWriter $objWriter, ?Outline $oOutline): void return; } // Width : pts - $width = CommonDrawing::pointsToEmu($oOutline->getWidth()); + $width = CommonDrawing::pixelsToEmu($oOutline->getWidth()); // a:ln $objWriter->startElement('a:ln'); diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php index b3b633d80..65d5de446 100644 --- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php +++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php @@ -1273,7 +1273,7 @@ public function testTypeScatterMarker(): void public function testTypeScatterSeriesOutline(): void { $expectedWidth = mt_rand(1, 100); - $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm'; + $expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm'; $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties'; diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index f1e5b4912..cfb193dcd 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -469,7 +469,7 @@ public function testAxisOutline(): void $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln'; $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); - $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthX)); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthX)); $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln/a:solidFill/a:srgbClr'; $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorX); @@ -477,7 +477,7 @@ public function testAxisOutline(): void $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln'; $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); - $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthY)); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthY)); $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln/a:solidFill/a:srgbClr'; $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element); $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY); @@ -949,7 +949,7 @@ public function testTypeLineGridlines(): void $expectedColor = new Color(Color::COLOR_BLUE); foreach ($arrayTests as $arrayTest) { $expectedSizePts = mt_rand(1, 100); - $expectedSizeEmu = Drawing::pointsToEmu($expectedSizePts); + $expectedSizeEmu = Drawing::pixelsToEmu($expectedSizePts); $this->oPresentation->removeSlideByIndex()->createSlide(); $oShape = $this->oPresentation->getActiveSlide()->createChartShape(); @@ -1076,7 +1076,7 @@ public function testTypeLineMarkerFill(): void public function testTypeLineSeriesOutline(): void { $expectedWidth = mt_rand(1, 100); - $expectedWidthEmu = Drawing::pointsToEmu($expectedWidth); + $expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth); $expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:spPr/a:ln'; $oOutline = new Outline(); @@ -1483,7 +1483,7 @@ public function testTypeScatterSeparator(): void public function testTypeScatterSeriesOutline(): void { $expectedWidth = mt_rand(1, 100); - $expectedWidthEmu = Drawing::pointsToEmu($expectedWidth); + $expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth); $expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:spPr/a:ln'; $oOutline = new Outline();