Skip to content

Commit e27e80c

Browse files
authored
Update Section.php - Add Columns and BreakTypes (and don't needlessly set Gutter if default)
1 parent 0ab0b49 commit e27e80c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/PhpWord/Writer/RTF/Style/Section.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,23 @@ public function write()
5353
$content .= $this->getValueIf($style->getMarginLeft() !== null, '\marglsxn' . round($style->getMarginLeft()));
5454
$content .= $this->getValueIf($style->getHeaderHeight() !== null, '\headery' . round($style->getHeaderHeight()));
5555
$content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . round($style->getFooterHeight()));
56-
$content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . round($style->getGutter()));
56+
$content .= $this->getValueIf($style->getGutter() !== null && $style->getGutter() !== SectionStyle::DEFAULT_GUTTER, '\guttersxn' . round($style->getGutter()));
5757
$content .= $this->getValueIf($style->getPageNumberingStart() !== null, '\pgnstarts' . $style->getPageNumberingStart() . '\pgnrestart');
58+
$content .= $this->getValueIf($style->getColsNum() !== null && $style->getColsNum() !== SectionStyle::DEFAULT_COLUMN_COUNT, '\cols' . $style->getColsNum());
59+
$content .= $this->getValueIf($style->getColsSpace() !== null && $style->getColsNum() !== SectionStyle::DEFAULT_COLUMN_COUNT, '\colsx' . round($style->getColsSpace()));
60+
61+
// Break Type
62+
$breakTypes = [
63+
'nextPage' => '\sbkpage',
64+
'nextColumn' => '\sbkcol',
65+
'continuous' => '\sbknone',
66+
'evenPage' => '\sbkeven',
67+
'oddPage' => '\sbkodd',
68+
];
69+
if (isset($breakTypes[$style->getBreakType()])) {
70+
$content .= $breakTypes[$style->getBreakType()];
71+
}
72+
5873
$content .= ' ';
5974

6075
// Borders

0 commit comments

Comments
 (0)