Skip to content

Commit

Permalink
Add support for the firstLineChars style in Word2007.
Browse files Browse the repository at this point in the history
  • Loading branch information
ling committed Sep 2, 2024
1 parent 8392134 commit 69a42b0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/PhpWord/Style/Indentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*
Expand Down Expand Up @@ -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.
*
Expand Down
3 changes: 3 additions & 0 deletions src/PhpWord/Writer/Word2007/Style/Indentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 69a42b0

Please sign in to comment.