From d5dbfb98b031b2ddaabaedad2dca97634483a28f Mon Sep 17 00:00:00 2001 From: Maxim Barulin Date: Tue, 4 Apr 2017 11:35:48 +0300 Subject: [PATCH] add support for contextualSpacing attribute issue #1037 --- src/PhpWord/Style/Paragraph.php | 26 +++++++++++++++++++ .../Writer/Word2007/Style/Paragraph.php | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index c6e60efb..ec23dce3 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -157,6 +157,13 @@ class Paragraph extends Border * @var \PhpOffice\PhpWord\Style\Shading */ private $shading; + + /** + * Do not add an interval between paragraphs of the same style + * + * @var bool + */ + private $contextualSpacing = true; /** * Set Style value @@ -208,6 +215,7 @@ class Paragraph extends Border ), 'tabs' => $this->getTabs(), 'shading' => $this->getShading(), + 'contextualSpacing' => $this->getContextualSpacing(), ); return $styles; @@ -731,4 +739,22 @@ class Paragraph extends Border return $this; } + + /** + * @return bool + */ + public function getContextualSpacing() + { + return $this->contextualSpacing; + } + + /** + * @param bool $contextualSpacing + */ + public function setContextualSpacing($contextualSpacing) + { + $this->contextualSpacing = $contextualSpacing; + + return $this; + } } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 2cb08bee..787f2a5f 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -106,6 +106,9 @@ class Paragraph extends AbstractStyle } $xmlWriter->endElement(); } + + //Paragraph contextualSpacing + $xmlWriter->writeElementIf($styles['contextualSpacing'] === true, 'w:contextualSpacing'); // Child style: alignment, indentation, spacing, and shading $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);