Skip to content

Commit 73717df

Browse files
PakkuProgi1984
authored andcommitted
PowerPoint2007 Writer : Outline : Fixed the base unit
1 parent ea33980 commit 73717df

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

docs/changes/1.1.0.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515

1616
- Fixed CI - [@Progi1984](https://github.com/Progi1984) in [#766](https://github.com/PHPOffice/PHPPresentation/pull/766)
1717
- 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)
18-
- 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)
18+
- 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)
19+
- PowerPoint2007 Writer : Outline : Fixed the base unit - [@Pakku](https://github.com/Pakku) in [#772](https://github.com/PHPOffice/PHPPresentation/pull/772)
20+
21+
## BC Breaks
22+
- `PhpOffice\PhpPresentation\Style\Outline` : the width is now based on pixels (before in points)

src/PhpPresentation/Style/Outline.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Outline
3030
protected $fill;
3131

3232
/**
33-
* @var float
33+
* @var int
3434
*/
3535
protected $width = 1;
3636

@@ -51,15 +51,18 @@ public function setFill(Fill $fill): self
5151
return $this;
5252
}
5353

54-
public function getWidth(): float
54+
/**
55+
* Value in pixels.
56+
*/
57+
public function getWidth(): int
5558
{
5659
return $this->width;
5760
}
5861

5962
/**
60-
* Value in points.
63+
* Value in pixels.
6164
*/
62-
public function setWidth(float $pValue = 1): self
65+
public function setWidth(int $pValue = 1): self
6366
{
6467
$this->width = $pValue;
6568

src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ protected function writeSeriesStyle(Chart $chart, Chart\Series $series): void
775775
if ($oOutline instanceof Outline) {
776776
$outlineWidth = $oOutline->getWidth();
777777
if (!empty($outlineWidth)) {
778-
$outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
778+
$outlineWidth = number_format(CommonDrawing::pixelsToCentimeters($outlineWidth), 3, '.', '');
779779
}
780780
$outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
781781
}

src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected function writeOutline(XMLWriter $objWriter, ?Outline $oOutline): void
263263
return;
264264
}
265265
// Width : pts
266-
$width = CommonDrawing::pointsToEmu($oOutline->getWidth());
266+
$width = CommonDrawing::pixelsToEmu($oOutline->getWidth());
267267

268268
// a:ln
269269
$objWriter->startElement('a:ln');

tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ public function testTypeLineMarker(): void
982982
public function testTypeLineSeriesOutline(): void
983983
{
984984
$expectedWidth = mt_rand(1, 100);
985-
$expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
985+
$expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
986986

987987
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
988988

@@ -1155,7 +1155,7 @@ public function testTypeRadar(): void
11551155
public function testTypeRadarSeriesOutline(): void
11561156
{
11571157
$expectedWidth = mt_rand(1, 100);
1158-
$expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
1158+
$expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
11591159

11601160
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
11611161

@@ -1273,7 +1273,7 @@ public function testTypeScatterMarker(): void
12731273
public function testTypeScatterSeriesOutline(): void
12741274
{
12751275
$expectedWidth = mt_rand(1, 100);
1276-
$expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
1276+
$expectedWidthCm = number_format(CommonDrawing::pixelsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
12771277

12781278
$expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
12791279

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,15 @@ public function testAxisOutline(): void
469469
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
470470
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln';
471471
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
472-
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthX));
472+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthX));
473473
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
474474
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
475475
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorX);
476476
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr';
477477
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
478478
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln';
479479
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
480-
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pointsToEmu($expectedWidthY));
480+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu($expectedWidthY));
481481
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
482482
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
483483
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY);
@@ -949,7 +949,7 @@ public function testTypeLineGridlines(): void
949949
$expectedColor = new Color(Color::COLOR_BLUE);
950950
foreach ($arrayTests as $arrayTest) {
951951
$expectedSizePts = mt_rand(1, 100);
952-
$expectedSizeEmu = Drawing::pointsToEmu($expectedSizePts);
952+
$expectedSizeEmu = Drawing::pixelsToEmu($expectedSizePts);
953953

954954
$this->oPresentation->removeSlideByIndex()->createSlide();
955955
$oShape = $this->oPresentation->getActiveSlide()->createChartShape();
@@ -1076,7 +1076,7 @@ public function testTypeLineMarkerFill(): void
10761076
public function testTypeLineSeriesOutline(): void
10771077
{
10781078
$expectedWidth = mt_rand(1, 100);
1079-
$expectedWidthEmu = Drawing::pointsToEmu($expectedWidth);
1079+
$expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth);
10801080
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:spPr/a:ln';
10811081

10821082
$oOutline = new Outline();
@@ -1483,7 +1483,7 @@ public function testTypeScatterSeparator(): void
14831483
public function testTypeScatterSeriesOutline(): void
14841484
{
14851485
$expectedWidth = mt_rand(1, 100);
1486-
$expectedWidthEmu = Drawing::pointsToEmu($expectedWidth);
1486+
$expectedWidthEmu = Drawing::pixelsToEmu($expectedWidth);
14871487
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:spPr/a:ln';
14881488

14891489
$oOutline = new Outline();

0 commit comments

Comments
 (0)