Skip to content

Commit d5dbfb9

Browse files
postHawktroosan
authored andcommitted
add support for contextualSpacing attribute issue #1037
1 parent fd418e0 commit d5dbfb9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/PhpWord/Style/Paragraph.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ class Paragraph extends Border
157157
* @var \PhpOffice\PhpWord\Style\Shading
158158
*/
159159
private $shading;
160+
161+
/**
162+
* Do not add an interval between paragraphs of the same style
163+
*
164+
* @var bool
165+
*/
166+
private $contextualSpacing = true;
160167

161168
/**
162169
* Set Style value
@@ -208,6 +215,7 @@ public function getStyleValues()
208215
),
209216
'tabs' => $this->getTabs(),
210217
'shading' => $this->getShading(),
218+
'contextualSpacing' => $this->getContextualSpacing(),
211219
);
212220

213221
return $styles;
@@ -731,4 +739,22 @@ public function setShading($value = null)
731739

732740
return $this;
733741
}
742+
743+
/**
744+
* @return bool
745+
*/
746+
public function getContextualSpacing()
747+
{
748+
return $this->contextualSpacing;
749+
}
750+
751+
/**
752+
* @param bool $contextualSpacing
753+
*/
754+
public function setContextualSpacing($contextualSpacing)
755+
{
756+
$this->contextualSpacing = $contextualSpacing;
757+
758+
return $this;
759+
}
734760
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ private function writeStyle()
106106
}
107107
$xmlWriter->endElement();
108108
}
109+
110+
//Paragraph contextualSpacing
111+
$xmlWriter->writeElementIf($styles['contextualSpacing'] === true, 'w:contextualSpacing');
109112

110113
// Child style: alignment, indentation, spacing, and shading
111114
$this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);

0 commit comments

Comments
 (0)