add support for contextualSpacing attribute issue #1037

This commit is contained in:
Maxim Barulin 2017-04-04 11:35:48 +03:00 committed by troosan
parent fd418e0746
commit d5dbfb98b0
2 changed files with 29 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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']);