diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ab0127..e545ce17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub. +## 0.13.0 - TBD + +Place announcement text here. + +### Bugfixes + +- It was discovered that ``alignment`` option value doesn't affect paragraph alignment at all. This was fixed. Note: ``getAlign()`` and ``setAlign()`` methods of ``Paragraph`` style are renamed. - @RomanSyroeshko + ## 0.12.0 - 3 January 2015 This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced. diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index 1a7de0a3..fc74b1dd 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -26,7 +26,6 @@ use PhpOffice\PhpWord\Style\Alignment; */ class Paragraph extends AbstractStyle { - /** * Depth of table container nested level; Primarily used for RTF writer/reader * @@ -55,7 +54,7 @@ class Paragraph extends AbstractStyle Alignment::ALIGN_BOTH => '\qj', ); - $align = $style->getAlign(); + $alignment = $style->getAlignment(); $spaceAfter = $style->getSpaceAfter(); $spaceBefore = $style->getSpaceBefore(); @@ -63,8 +62,8 @@ class Paragraph extends AbstractStyle if ($this->nestedLevel == 0) { $content .= '\pard\nowidctlpar '; } - if (isset($alignments[$align])) { - $content .= $alignments[$align]; + if (!is_null($alignment) && isset($alignments[$alignment->getValue()])) { + $content .= $alignments[$alignment->getValue()]; } $content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore); $content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter); diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 48d47172..e3550819 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -67,7 +67,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase $object = new Paragraph(); $attributes = array( - 'align' => 'justify', +// 'align' => 'justify', 'spaceAfter' => 240, 'spaceBefore' => 240, 'indent' => 1, @@ -85,11 +85,11 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase foreach ($attributes as $key => $value) { $get = "get{$key}"; $object->setStyleValue("$key", $value); - if ('align' == $key) { + /*if ('align' == $key) { if ('justify' == $value) { $value = 'both'; } - } elseif ('indent' == $key || 'hanging' == $key) { + } else*/if ('indent' == $key || 'hanging' == $key) { $value = $value * 720; } elseif ('spacing' == $key) { $value += 240; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index e5c41f09..6c68ec75 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -421,7 +421,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $section = $phpWord->addSection(); $attributes = array( - 'align' => 'right', + 'alignment' => 'right', 'widowControl' => false, 'keepNext' => true, 'keepLines' => true, @@ -436,9 +436,9 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $attributeCount = 0; foreach ($attributes as $key => $value) { $attributeCount++; - $nodeName = ($key == 'align') ? 'jc' : $key; + $nodeName = ($key == 'alignment') ? 'jc' : $key; $path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}"; - if ('align' != $key) { + if ('alignment' != $key) { $value = $value ? 1 : 0; } $element = $doc->getElement($path);