From 4e25283195a7b088a57b901d8b9731042e6bb004 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Mon, 22 Sep 2014 16:58:00 -0600 Subject: [PATCH 1/5] Add missing setters for pageSizeW and pageSizeH --- src/PhpWord/Style/Section.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index c56b0a19..e196dfbd 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -282,6 +282,13 @@ class Section extends Border return $this->pageSizeW; } + public function setPageSizeW($value = null) + { + $this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH); + + return $this; + } + /** * Get Page Size Height * @@ -292,6 +299,13 @@ class Section extends Border return $this->pageSizeH; } + public function setPageSizeH($value = null) + { + $this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT); + + return $this; + } + /** * Get Margin Top * From cf96ea0e18496ebd302562e4bbd2045d301b004e Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 08:33:53 -0600 Subject: [PATCH 2/5] Width/Height set/get tests --- tests/PhpWord/Tests/Style/SectionTest.php | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 8e8c1e87..6ad52a6c 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -97,6 +97,34 @@ class SettingsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($iVal, $oSettings->getMarginRight()); } + /** + * Set/get page width + */ + public function testPageWidth() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(11906, $oSettings->getPageSizeW()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeW', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeW()); + } + + /** + * Set/get page height + */ + public function testPageHeight() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(16838, $oSettings->getPageSizeH()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeH', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeH()); + } + /** * Set/get landscape orientation */ From cf5625b643d4887978102d1fb9d3c785806c42b5 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 09:04:45 -0600 Subject: [PATCH 3/5] Update pageSizeW and pageSizeH docs Conflicts: docs/containers.rst --- docs/styles.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/styles.rst b/docs/styles.rst index 91d5ed7a..f4c1e8eb 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -8,6 +8,8 @@ Section Below are the available styles for section: +- ``pageSizeW`` Page width in twips (the default is 11906/A4 size) +- ``pageSizeH`` Page height in twips (the default is 16838/A4 size) - ``orientation`` Page orientation, i.e. 'portrait' (default) or 'landscape' - ``marginTop`` Page margin top in twips @@ -30,12 +32,6 @@ Below are the available styles for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two styles are automatically set by the use of the -``orientation`` style. You can alter them but that's not recommended. - -- ``pageSizeW`` Page width in twips -- ``pageSizeH`` Page height in twips - Font ---- From cea15f3d2361ea4156976fe59ea540e00a4acd6c Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 10:50:50 -0600 Subject: [PATCH 4/5] Use page width and height default constants in tests --- tests/PhpWord/Tests/Style/SectionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 6ad52a6c..e5becd72 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -105,7 +105,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase // Section Settings $oSettings = new Section(); - $this->assertEquals(11906, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeW()); $iVal = rand(1, 1000); $oSettings->setSettingValue('pageSizeW', $iVal); $this->assertEquals($iVal, $oSettings->getPageSizeW()); @@ -119,7 +119,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase // Section Settings $oSettings = new Section(); - $this->assertEquals(16838, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeH()); $iVal = rand(1, 1000); $oSettings->setSettingValue('pageSizeH', $iVal); $this->assertEquals($iVal, $oSettings->getPageSizeH()); From 112712012e62fcf2aba742cb12cbb63f2143e295 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 11:06:14 -0600 Subject: [PATCH 5/5] Update Changelog for setPageSizeW and setPageSizeH --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77314485..1ad2d884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 - "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 - "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 +- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. ### Deprecated