From 0a8635ece80dbb6f2dcf94f808f0fa8769be4546 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Mon, 22 Sep 2014 16:58:00 -0600 Subject: [PATCH 1/3] 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 fd59f1b4..ae02544b 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -239,6 +239,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 * @@ -249,6 +256,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 e5a3d01835cc28923ba92a47722ed037f56aa0c7 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 08:33:53 -0600 Subject: [PATCH 2/3] 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 dd7273cb..954494b2 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -96,6 +96,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 ecaeb96376d4e0ac5a924a6d3547c935d5fd87e1 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 09:04:45 -0600 Subject: [PATCH 3/3] Update pageSizeW and pageSizeH docs --- docs/containers.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/containers.rst b/docs/containers.rst index 30566df6..3cb48792 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -34,6 +34,8 @@ Section settings Below are the available settings 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 @@ -56,12 +58,6 @@ Below are the available settings for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two settings are automatically set by the use of the -``orientation`` setting. You can alter them but that's not recommended. - -- ``pageSizeW`` Page width in twips -- ``pageSizeH`` Page height in twips - Page number ~~~~~~~~~~~