Skip to content

Commit 33570f7

Browse files
committed
#294: Support for paragraph with borders
1 parent 689a737 commit 33570f7

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap
2121
- Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin
2222
- Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin
2323
- SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin
24+
- Paragraph: Support for paragraph with borders - @ivanlanin GH-294
2425

2526
### Bugfixes
2627

src/PhpWord/Style/Paragraph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*
4848
* @link http://www.schemacentral.com/sc/ooxml/t-w_CT_PPr.html
4949
*/
50-
class Paragraph extends AbstractStyle
50+
class Paragraph extends Border
5151
{
5252
/**
5353
* @const int One line height equals 240 twip

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ private function writeStyle()
108108
// Numbering
109109
$this->writeNumbering($xmlWriter, $styles['numbering']);
110110

111+
// Border
112+
if ($style->hasBorder()) {
113+
$xmlWriter->startElement('w:pBdr');
114+
115+
$styleWriter = new MarginBorder($xmlWriter);
116+
$styleWriter->setSizes($style->getBorderSize());
117+
$styleWriter->setColors($style->getBorderColor());
118+
$styleWriter->write();
119+
120+
$xmlWriter->endElement();
121+
}
122+
111123
if (!$this->withoutPPR) {
112124
$xmlWriter->endElement(); // w:pPr
113125
}

tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public function testElementStyles()
139139
'align' => 'center',
140140
'tabs' => $tabs,
141141
'shading' => array('fill' => 'FFFF99'),
142+
'borderSize' => 4,
142143
)); // Style #1
143144
$phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true,
144145
'scale' => 200, 'spacing' => 240, 'kerning' => 10)); // Style #2

0 commit comments

Comments
 (0)