Skip to content

Commit

Permalink
PowerPoint2007 Writer : Outline : Fixed the base unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakku authored and Progi1984 committed Dec 4, 2023
1 parent ea33980 commit 73717df
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
6 changes: 5 additions & 1 deletion docs/changes/1.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- 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)
11 changes: 7 additions & 4 deletions src/PhpPresentation/Style/Outline.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Outline
protected $fill;

/**
* @var float
* @var int
*/
protected $width = 1;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ public function testTypeLineMarker(): void
public function testTypeLineSeriesOutline(): 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';

Expand Down Expand Up @@ -1155,7 +1155,7 @@ public function testTypeRadar(): void
public function testTypeRadarSeriesOutline(): 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';

Expand Down Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@ 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);
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr';
$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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 73717df

Please sign in to comment.