From 9b3ee4886a7b4c0c78a1cb08ec5008a21e2f7669 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 5 Sep 2024 09:19:55 +0200 Subject: [PATCH] Word2007 Reader: Fixed cast of spacing --- docs/changes/1.2.0.md | 2 ++ src/PhpPresentation/Reader/PowerPoint2007.php | 8 ++++---- src/PhpPresentation/Shape/RichText/Paragraph.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/changes/1.2.0.md b/docs/changes/1.2.0.md index b1f048265..daf2ed594 100644 --- a/docs/changes/1.2.0.md +++ b/docs/changes/1.2.0.md @@ -8,6 +8,8 @@ ## Bug fixes +- Word2007 Reader: Fixed cast of spacing fixing [#729](https://github.com/PHPOffice/PHPPresentation/pull/729), [#796](https://github.com/PHPOffice/PHPPresentation/pull/796) in [#818](https://github.com/PHPOffice/PHPPresentation/pull/818) + ## Miscellaneous ## BC Breaks diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php index 140c2f4a5..939f1c4ba 100644 --- a/src/PhpPresentation/Reader/PowerPoint2007.php +++ b/src/PhpPresentation/Reader/PowerPoint2007.php @@ -1205,20 +1205,20 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh $oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement); if ($oElementLineSpacingPoints instanceof DOMElement) { $oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT); - $oParagraph->setLineSpacing((int) $oElementLineSpacingPoints->getAttribute('val') / 100); + $oParagraph->setLineSpacing((int) ((int) $oElementLineSpacingPoints->getAttribute('val') / 100)); } $oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement); if ($oElementLineSpacingPercent instanceof DOMElement) { $oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT); - $oParagraph->setLineSpacing((int) $oElementLineSpacingPercent->getAttribute('val') / 1000); + $oParagraph->setLineSpacing((int) ((int) $oElementLineSpacingPercent->getAttribute('val') / 1000)); } $oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement); if ($oElementSpacingBefore instanceof DOMElement) { - $oParagraph->setSpacingBefore((int) $oElementSpacingBefore->getAttribute('val') / 100); + $oParagraph->setSpacingBefore((int) ((int) $oElementSpacingBefore->getAttribute('val') / 100)); } $oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement); if ($oElementSpacingAfter instanceof DOMElement) { - $oParagraph->setSpacingAfter((int) $oElementSpacingAfter->getAttribute('val') / 100); + $oParagraph->setSpacingAfter((int) ((int) $oElementSpacingAfter->getAttribute('val') / 100)); } $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE); diff --git a/src/PhpPresentation/Shape/RichText/Paragraph.php b/src/PhpPresentation/Shape/RichText/Paragraph.php index 2eb173a62..fdac68e8f 100644 --- a/src/PhpPresentation/Shape/RichText/Paragraph.php +++ b/src/PhpPresentation/Shape/RichText/Paragraph.php @@ -320,7 +320,7 @@ public function getLineSpacing(): int * * @param int $lineSpacing */ - public function setLineSpacing($lineSpacing): self + public function setLineSpacing(int $lineSpacing): self { $this->lineSpacing = $lineSpacing;