Skip to content

Commit f44ff4b

Browse files
author
lrobert
committed
Added shading to the paragraph style for full width shading
1 parent 38d3d7b commit f44ff4b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/PhpWord/Style/Paragraph.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ class Paragraph extends AbstractStyle
152152
*/
153153
private $tabs = array();
154154

155+
/**
156+
* Shading
157+
*
158+
* @var \PhpOffice\PhpWord\Style\Shading
159+
*/
160+
private $shading;
161+
155162
/**
156163
* Create new instance
157164
*/
@@ -209,6 +216,7 @@ public function getStyleValues()
209216
'level' => $this->getNumLevel(),
210217
),
211218
'tabs' => $this->getTabs(),
219+
'shading' => $this->getShading(),
212220
);
213221

214222
return $styles;
@@ -694,4 +702,27 @@ public function getPageBreakBefore()
694702
{
695703
return $this->hasPageBreakBefore();
696704
}
705+
706+
/**
707+
* Get shading
708+
*
709+
* @return \PhpOffice\PhpWord\Style\Shading
710+
*/
711+
public function getShading()
712+
{
713+
return $this->shading;
714+
}
715+
716+
/**
717+
* Set shading
718+
*
719+
* @param mixed $value
720+
* @return self
721+
*/
722+
public function setShading($value = null)
723+
{
724+
$this->setObjectVal($value, 'Shading', $this->shading);
725+
726+
return $this;
727+
}
697728
}

src/PhpWord/Writer/Word2007/Style/Paragraph.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ private function writeStyle()
9999
$this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);
100100
$this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']);
101101

102+
// Background-Color
103+
$shading = $style->getShading();
104+
if (!is_null($shading)) {
105+
$styleWriter = new Shading($xmlWriter, $shading);
106+
$styleWriter->write();
107+
}
108+
102109
// Tabs
103110
$this->writeTabs($xmlWriter, $styles['tabs']);
104111

0 commit comments

Comments
 (0)