From 69a42b0b47295832b63fc9e7cfd7655dd5f8de30 Mon Sep 17 00:00:00 2001 From: ling Date: Mon, 2 Sep 2024 10:14:49 +0800 Subject: [PATCH] Add support for the firstLineChars style in Word2007. --- src/PhpWord/Style/Indentation.php | 30 +++++++++++++++++++ .../Writer/Word2007/Style/Indentation.php | 3 ++ 2 files changed, 33 insertions(+) diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php index 42c6e11845..b204c1e4eb 100644 --- a/src/PhpWord/Style/Indentation.php +++ b/src/PhpWord/Style/Indentation.php @@ -46,6 +46,13 @@ class Indentation extends AbstractStyle */ private $firstLine = 0; + /** + * Additional first line chars indentation (twip). + * + * @var float|int + */ + private $firstLineChars = 0; + /** * Indentation removed from first line (twip). * @@ -135,6 +142,29 @@ public function setFirstLine($value) return $this; } + /** + * Get first line chars. + * + * @return float|int + */ + public function getFirstLineChars() + { + return $this->firstLineChars; + } + + /** + * Set first line chars. + * + * @param float|int $value + * + * @return $this + */ + public function setFirstLineChars($value) + { + $this->firstLineChars = $this->setNumericVal($value, $this->firstLineChars); + return $this; + } + /** * Get hanging. * diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index 63ffb6323a..944a7f2deb 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -43,6 +43,9 @@ public function write(): void $firstLine = $style->getFirstLine(); $xmlWriter->writeAttributeIf(null !== $firstLine, 'w:firstLine', $this->convertTwip($firstLine)); + $firstLineChars = $style->getFirstLineChars(); + $xmlWriter->writeAttributeIf(null !== $firstLineChars, 'w:firstLineChars', $this->convertTwip($firstLineChars)); + $hanging = $style->getHanging(); $xmlWriter->writeAttributeIf(null !== $hanging, 'w:hanging', $this->convertTwip($hanging));