Section: Ability to define gutter and line numbering
This commit is contained in:
parent
9b1f2f210c
commit
1a1356a30b
|
|
@ -39,6 +39,7 @@ This release marked heavy refactorings on internal code structure with the creat
|
||||||
- ODT Writer: Basic image writing - @ivanlanin
|
- ODT Writer: Basic image writing - @ivanlanin
|
||||||
- ODT Writer: Link writing - @ivanlanin
|
- ODT Writer: Link writing - @ivanlanin
|
||||||
- ODT Reader: Basic ODText Reader - @ivanlanin GH-71
|
- ODT Reader: Basic ODText Reader - @ivanlanin GH-71
|
||||||
|
- Section: Ability to define gutter and line numbering
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ Below are the available settings for section:
|
||||||
- ``borderBottomColor`` Border bottom color
|
- ``borderBottomColor`` Border bottom color
|
||||||
- ``headerHeight`` Spacing to top of header
|
- ``headerHeight`` Spacing to top of header
|
||||||
- ``footerHeight`` Spacing to bottom of footer
|
- ``footerHeight`` Spacing to bottom of footer
|
||||||
|
- ``gutter`` Page gutter spacing
|
||||||
- ``colsNum`` Number of columns
|
- ``colsNum`` Number of columns
|
||||||
- ``colsSpace`` Spacing between columns
|
- ``colsSpace`` Spacing between columns
|
||||||
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
|
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
|
||||||
|
|
@ -92,6 +93,28 @@ using the ``breakType`` and ``colsNum`` property of the section.
|
||||||
$section->getSettings()->setBreakType('continuous');
|
$section->getSettings()->setBreakType('continuous');
|
||||||
$section->getSettings()->setColsNum(2);
|
$section->getSettings()->setColsNum(2);
|
||||||
|
|
||||||
|
|
||||||
|
### Line numbering
|
||||||
|
|
||||||
|
You can apply line numbering to a section by using the ``lineNumbering``
|
||||||
|
property of the section.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
// Method 1
|
||||||
|
$section = $phpWord->addSection(array('lineNumbering' => array()));
|
||||||
|
|
||||||
|
// Method 2
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
$section->getSettings()->setLineNumbering(array());
|
||||||
|
|
||||||
|
Below are the properties of the line numbering style.
|
||||||
|
|
||||||
|
- ``start`` Line numbering starting value
|
||||||
|
- ``increment`` Line number increments
|
||||||
|
- ``distance`` Distance between text and line numbering in twip
|
||||||
|
- ``restart`` Line numbering restart setting continuous|newPage|newSection
|
||||||
|
|
||||||
Headers
|
Headers
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -344,6 +344,7 @@ Below are the available settings for section:
|
||||||
- `borderBottomColor` Border bottom color
|
- `borderBottomColor` Border bottom color
|
||||||
- `headerHeight` Spacing to top of header
|
- `headerHeight` Spacing to top of header
|
||||||
- `footerHeight` Spacing to bottom of footer
|
- `footerHeight` Spacing to bottom of footer
|
||||||
|
- `gutter` Page gutter spacing
|
||||||
- `colsNum` Number of columns
|
- `colsNum` Number of columns
|
||||||
- `colsSpace` Spacing between columns
|
- `colsSpace` Spacing between columns
|
||||||
- `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage)
|
- `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage)
|
||||||
|
|
@ -380,6 +381,26 @@ $section->getSettings()->setBreakType('continuous');
|
||||||
$section->getSettings()->setColsNum(2);
|
$section->getSettings()->setColsNum(2);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Line numbering
|
||||||
|
|
||||||
|
You can apply line numbering to a section by using the `lineNumbering` property of the section.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Method 1
|
||||||
|
$section = $phpWord->addSection(array('lineNumbering' => array()));
|
||||||
|
|
||||||
|
// Method 2
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
$section->getSettings()->setLineNumbering(array());
|
||||||
|
```
|
||||||
|
|
||||||
|
Below are the properties of the line numbering style.
|
||||||
|
|
||||||
|
- `start` Line numbering starting value
|
||||||
|
- `increment` Line number increments
|
||||||
|
- `distance` Distance between text and line numbering in twip
|
||||||
|
- `restart` Line numbering restart setting continuous|newPage|newSection
|
||||||
|
|
||||||
## Headers
|
## Headers
|
||||||
|
|
||||||
Each section can have its own header reference. To create a header use the `addHeader` method:
|
Each section can have its own header reference. To create a header use the `addHeader` method:
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,37 @@ namespace PhpOffice\PhpWord;
|
||||||
*/
|
*/
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
/** Available Zip library classes */
|
/**
|
||||||
|
* Zip libraries
|
||||||
|
*/
|
||||||
const PCLZIP = 'PhpOffice\\PhpWord\\Shared\\ZipArchive';
|
const PCLZIP = 'PhpOffice\\PhpWord\\Shared\\ZipArchive';
|
||||||
const ZIPARCHIVE = 'ZipArchive';
|
const ZIPARCHIVE = 'ZipArchive';
|
||||||
|
|
||||||
/** Optional PDF Rendering libraries */
|
/**
|
||||||
|
* PDF rendering libraries
|
||||||
|
*/
|
||||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Measurement units multiplication factor
|
||||||
|
*
|
||||||
|
* Applied to:
|
||||||
|
* - Section: margins, header/footer height, gutter, column spacing
|
||||||
|
* - Tab: position
|
||||||
|
*
|
||||||
|
* @const int|float
|
||||||
|
*/
|
||||||
|
const UNIT_TWIP = 1; // = 1/20 point
|
||||||
|
const UNIT_CM = 567;
|
||||||
|
const UNIT_MM = 56.7;
|
||||||
|
const UNIT_INCH = 1440;
|
||||||
|
const UNIT_POINT = 20; // = 1/72 inch
|
||||||
|
const UNIT_PICA = 240; // = 1/6 inch = 12 points
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compatibility option for XMLWriter
|
* Compatibility option for XMLWriter
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private static $xmlWriterCompatibility = true;
|
private static $xmlWriterCompatibility = true;
|
||||||
|
|
||||||
|
|
@ -58,11 +78,20 @@ class Settings
|
||||||
*/
|
*/
|
||||||
private static $pdfRendererPath = null;
|
private static $pdfRendererPath = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Measurement unit
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $measurementUnit = self::UNIT_TWIP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the compatibility option used by the XMLWriter
|
* Set the compatibility option used by the XMLWriter
|
||||||
*
|
*
|
||||||
* @param boolean $compatibility This sets the setIndent and setIndentString for better compatibility
|
* This sets the setIndent and setIndentString for better compatibility
|
||||||
* @return boolean Success or failure
|
*
|
||||||
|
* @param bool $compatibility
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function setCompatibility($compatibility)
|
public static function setCompatibility($compatibility)
|
||||||
{
|
{
|
||||||
|
|
@ -70,13 +99,14 @@ class Settings
|
||||||
self::$xmlWriterCompatibility = $compatibility;
|
self::$xmlWriterCompatibility = $compatibility;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the compatibility option used by the XMLWriter
|
* Return the compatibility option used by the XMLWriter
|
||||||
*
|
*
|
||||||
* @return boolean Compatibility
|
* @return bool Compatibility
|
||||||
*/
|
*/
|
||||||
public static function getCompatibility()
|
public static function getCompatibility()
|
||||||
{
|
{
|
||||||
|
|
@ -84,11 +114,10 @@ class Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Zip handler Class that PHPWord should use for Zip file management (PCLZip or ZipArchive)
|
* Set zip handler class
|
||||||
*
|
*
|
||||||
* @param string $zipClass The Zip handler class that PHPWord should use for Zip file management
|
* @param string $zipClass
|
||||||
* e.g. Settings::PCLZip or Settings::ZipArchive
|
* @return bool
|
||||||
* @return boolean Success or failure
|
|
||||||
*/
|
*/
|
||||||
public static function setZipClass($zipClass)
|
public static function setZipClass($zipClass)
|
||||||
{
|
{
|
||||||
|
|
@ -97,16 +126,14 @@ class Settings
|
||||||
self::$zipClass = $zipClass;
|
self::$zipClass = $zipClass;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the Zip handler Class that PHPWord is configured to use (PCLZip or ZipArchive)
|
* Get zip handler class
|
||||||
* or Zip file management
|
|
||||||
*
|
*
|
||||||
* @return string Name of the Zip handler Class that PHPWord is configured to use
|
* @return string
|
||||||
* for Zip file management
|
|
||||||
* e.g. Settings::PCLZip or Settings::ZipArchive
|
|
||||||
*/
|
*/
|
||||||
public static function getZipClass()
|
public static function getZipClass()
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +145,7 @@ class Settings
|
||||||
*
|
*
|
||||||
* @param string $libraryName
|
* @param string $libraryName
|
||||||
* @param string $libraryBaseDir
|
* @param string $libraryBaseDir
|
||||||
* @return boolean Success or failure
|
* @return bool Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
||||||
{
|
{
|
||||||
|
|
@ -141,14 +168,13 @@ class Settings
|
||||||
* Identify the external library to use for rendering PDF files
|
* Identify the external library to use for rendering PDF files
|
||||||
*
|
*
|
||||||
* @param string $libraryName
|
* @param string $libraryName
|
||||||
* @return boolean Success or failure
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function setPdfRendererName($libraryName)
|
public static function setPdfRendererName($libraryName)
|
||||||
{
|
{
|
||||||
if (!in_array($libraryName, self::$pdfRenderers)) {
|
if (!in_array($libraryName, self::$pdfRenderers)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$pdfRendererName = $libraryName;
|
self::$pdfRendererName = $libraryName;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -167,7 +193,7 @@ class Settings
|
||||||
* Location of external library to use for rendering PDF files
|
* Location of external library to use for rendering PDF files
|
||||||
*
|
*
|
||||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||||
* @return boolean Success or failure
|
* @return bool Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setPdfRendererPath($libraryBaseDir)
|
public static function setPdfRendererPath($libraryBaseDir)
|
||||||
{
|
{
|
||||||
|
|
@ -178,4 +204,31 @@ class Settings
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get measurement unit
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public static function getMeasurementUnit()
|
||||||
|
{
|
||||||
|
return self::$measurementUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set measurement unit
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function setMeasurementUnit($value)
|
||||||
|
{
|
||||||
|
$units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH, self::UNIT_POINT, self::UNIT_PICA);
|
||||||
|
if (!in_array($value, $units)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self::$measurementUnit = $value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Border Top Size
|
* Border Top Size
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
protected $borderTopSize;
|
protected $borderTopSize;
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Border Left Size
|
* Border Left Size
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
protected $borderLeftSize;
|
protected $borderLeftSize;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Border Right Size
|
* Border Right Size
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
protected $borderRightSize;
|
protected $borderRightSize;
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Border Bottom Size
|
* Border Bottom Size
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
protected $borderBottomSize;
|
protected $borderBottomSize;
|
||||||
|
|
||||||
|
|
@ -73,67 +73,82 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border size
|
* Set border size
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderSize($pValue = null)
|
public function setBorderSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopSize = $pValue;
|
$this->setBorderTopSize($value);
|
||||||
$this->borderLeftSize = $pValue;
|
$this->setBorderLeftSize($value);
|
||||||
$this->borderRightSize = $pValue;
|
$this->setBorderRightSize($value);
|
||||||
$this->borderBottomSize = $pValue;
|
$this->setBorderBottomSize($value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border size
|
* Get border size
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize()
|
||||||
{
|
{
|
||||||
$top = $this->getBorderTopSize();
|
return array(
|
||||||
$left = $this->getBorderLeftSize();
|
$this->getBorderTopSize(),
|
||||||
$right = $this->getBorderRightSize();
|
$this->getBorderLeftSize(),
|
||||||
$bottom = $this->getBorderBottomSize();
|
$this->getBorderRightSize(),
|
||||||
|
$this->getBorderBottomSize(),
|
||||||
return array($top, $left, $right, $bottom);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set border color
|
* Set border color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderColor($pValue = null)
|
public function setBorderColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopColor = $pValue;
|
$this->setBorderTopColor($value);
|
||||||
$this->borderLeftColor = $pValue;
|
$this->setBorderLeftColor($value);
|
||||||
$this->borderRightColor = $pValue;
|
$this->setBorderRightColor($value);
|
||||||
$this->borderBottomColor = $pValue;
|
$this->setBorderBottomColor($value);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border color
|
* Get border color
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor()
|
||||||
{
|
{
|
||||||
$top = $this->getBorderTopColor();
|
return array(
|
||||||
$left = $this->getBorderLeftColor();
|
$this->getBorderTopColor(),
|
||||||
$right = $this->getBorderRightColor();
|
$this->getBorderLeftColor(),
|
||||||
$bottom = $this->getBorderBottomColor();
|
$this->getBorderRightColor(),
|
||||||
|
$this->getBorderBottomColor(),
|
||||||
return array($top, $left, $right, $bottom);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set border top size
|
* Set border top size
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderTopSize($pValue = null)
|
public function setBorderTopSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopSize = $pValue;
|
$this->borderTopSize = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border top size
|
* Get border top size
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
*/
|
*/
|
||||||
public function getBorderTopSize()
|
public function getBorderTopSize()
|
||||||
{
|
{
|
||||||
|
|
@ -143,15 +158,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border top color
|
* Set border top color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderTopColor($pValue = null)
|
public function setBorderTopColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderTopColor = $pValue;
|
$this->borderTopColor = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border top color
|
* Get border top color
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBorderTopColor()
|
public function getBorderTopColor()
|
||||||
{
|
{
|
||||||
|
|
@ -161,15 +181,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border left size
|
* Set border left size
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderLeftSize($pValue = null)
|
public function setBorderLeftSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderLeftSize = $pValue;
|
$this->borderLeftSize = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border left size
|
* Get border left size
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
*/
|
*/
|
||||||
public function getBorderLeftSize()
|
public function getBorderLeftSize()
|
||||||
{
|
{
|
||||||
|
|
@ -179,15 +204,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border left color
|
* Set border left color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderLeftColor($pValue = null)
|
public function setBorderLeftColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderLeftColor = $pValue;
|
$this->borderLeftColor = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border left color
|
* Get border left color
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBorderLeftColor()
|
public function getBorderLeftColor()
|
||||||
{
|
{
|
||||||
|
|
@ -197,15 +227,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border right size
|
* Set border right size
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderRightSize($pValue = null)
|
public function setBorderRightSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderRightSize = $pValue;
|
$this->borderRightSize = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border right size
|
* Get border right size
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
*/
|
*/
|
||||||
public function getBorderRightSize()
|
public function getBorderRightSize()
|
||||||
{
|
{
|
||||||
|
|
@ -215,15 +250,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border right color
|
* Set border right color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderRightColor($pValue = null)
|
public function setBorderRightColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderRightColor = $pValue;
|
$this->borderRightColor = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border right color
|
* Get border right color
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBorderRightColor()
|
public function getBorderRightColor()
|
||||||
{
|
{
|
||||||
|
|
@ -233,15 +273,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border bottom size
|
* Set border bottom size
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderBottomSize($pValue = null)
|
public function setBorderBottomSize($value = null)
|
||||||
{
|
{
|
||||||
$this->borderBottomSize = $pValue;
|
$this->borderBottomSize = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border bottom size
|
* Get border bottom size
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
*/
|
*/
|
||||||
public function getBorderBottomSize()
|
public function getBorderBottomSize()
|
||||||
{
|
{
|
||||||
|
|
@ -251,15 +296,20 @@ class Border extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set border bottom color
|
* Set border bottom color
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBorderBottomColor($pValue = null)
|
public function setBorderBottomColor($value = null)
|
||||||
{
|
{
|
||||||
$this->borderBottomColor = $pValue;
|
$this->borderBottomColor = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get border bottom color
|
* Get border bottom color
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBorderBottomColor()
|
public function getBorderBottomColor()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line numbering style
|
||||||
|
*
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class LineNumbering extends AbstractStyle
|
||||||
|
{
|
||||||
|
const LINE_NUMBERING_CONTINUOUS = 'continuous';
|
||||||
|
const LINE_NUMBERING_NEW_PAGE = 'newPage';
|
||||||
|
const LINE_NUMBERING_NEW_SECTION = 'newSection';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line numbering starting value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $start = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line number increments
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $increment = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Distance between text and line numbering in twip
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $distance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line numbering restart setting continuous|newPage|newSection
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html
|
||||||
|
*/
|
||||||
|
private $restart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance
|
||||||
|
*/
|
||||||
|
public function __construct($style = null)
|
||||||
|
{
|
||||||
|
$this->setStyleByArray($style);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get start
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getStart()
|
||||||
|
{
|
||||||
|
return $this->start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set start
|
||||||
|
*
|
||||||
|
* @param int $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setStart($value = null)
|
||||||
|
{
|
||||||
|
$this->start = $this->setIntVal($value, $this->start);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get increment
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getIncrement()
|
||||||
|
{
|
||||||
|
return $this->increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set increment
|
||||||
|
*
|
||||||
|
* @param int $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setIncrement($value = null)
|
||||||
|
{
|
||||||
|
$this->increment = $this->setIntVal($value, $this->increment);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get distance
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getDistance()
|
||||||
|
{
|
||||||
|
return $this->distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set distance
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setDistance($value = null)
|
||||||
|
{
|
||||||
|
$this->distance = $this->setNumericVal($value, $this->distance);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get restart
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRestart()
|
||||||
|
{
|
||||||
|
return $this->restart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set distance
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setRestart($value = null)
|
||||||
|
{
|
||||||
|
$enum = array(self::LINE_NUMBERING_CONTINUOUS, self::LINE_NUMBERING_NEW_PAGE, self::LINE_NUMBERING_NEW_SECTION);
|
||||||
|
$this->restart = $this->setEnumVal($value, $enum, $this->restart);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,67 +17,93 @@ use PhpOffice\PhpWord\Shared\String;
|
||||||
class Section extends Border
|
class Section extends Border
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default Page Size Width
|
* Page orientation
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
private $defaultPageSizeW = 11906;
|
const ORIENTATION_PORTRAIT = 'portrait';
|
||||||
|
const ORIENTATION_LANDSCAPE = 'landscape';
|
||||||
/**
|
/**
|
||||||
* Default Page Size Height
|
* Page default constants
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
private $defaultPageSizeH = 16838;
|
const DEFAULT_WIDTH = 11906; // In twip
|
||||||
|
const DEFAULT_HEIGHT = 16838; // In twip
|
||||||
|
const DEFAULT_MARGIN = 1440; // In twip
|
||||||
|
const DEFAULT_GUTTER = 0; // In twip
|
||||||
|
const DEFAULT_HEADER_HEIGHT = 720; // In twip
|
||||||
|
const DEFAULT_FOOTER_HEIGHT = 720; // In twip
|
||||||
|
const DEFAULT_COLUMN_COUNT = 1;
|
||||||
|
const DEFAULT_COLUMN_SPACING = 720; // In twip
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page Orientation
|
* Page Orientation
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_orient-1.html
|
||||||
*/
|
*/
|
||||||
private $orientation;
|
private $orientation = self::ORIENTATION_PORTRAIT;
|
||||||
|
|
||||||
/**
|
|
||||||
* Page Margin Top
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $marginTop;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Page Margin Left
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $marginLeft;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Page Margin Right
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $marginRight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Page Margin Bottom
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $marginBottom;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page Size Width
|
* Page Size Width
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
private $pageSizeW;
|
private $pageSizeW = self::DEFAULT_WIDTH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page Size Height
|
* Page Size Height
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
private $pageSizeH;
|
private $pageSizeH = self::DEFAULT_HEIGHT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Top margin spacing
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $marginTop = self::DEFAULT_MARGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Left margin spacing
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $marginLeft = self::DEFAULT_MARGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Right margin spacing
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $marginRight = self::DEFAULT_MARGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bottom margin spacing
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $marginBottom = self::DEFAULT_MARGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page gutter spacing
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/e-w_pgMar-1.html
|
||||||
|
*/
|
||||||
|
private $gutter = self::DEFAULT_GUTTER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header height
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $headerHeight = self::DEFAULT_HEADER_HEIGHT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Footer height
|
||||||
|
*
|
||||||
|
* @var int|float
|
||||||
|
*/
|
||||||
|
private $footerHeight = self::DEFAULT_FOOTER_HEIGHT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page Numbering Start
|
* Page Numbering Start
|
||||||
|
|
@ -86,33 +112,19 @@ class Section extends Border
|
||||||
*/
|
*/
|
||||||
private $pageNumberingStart;
|
private $pageNumberingStart;
|
||||||
|
|
||||||
/**
|
|
||||||
* Header height
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $headerHeight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Footer height
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $footerHeight;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section columns count
|
* Section columns count
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $colsNum;
|
private $colsNum = self::DEFAULT_COLUMN_COUNT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section spacing between columns
|
* Section spacing between columns
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int|float
|
||||||
*/
|
*/
|
||||||
private $colsSpace;
|
private $colsSpace = self::DEFAULT_COLUMN_SPACING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section break type
|
* Section break type
|
||||||
|
|
@ -129,181 +141,44 @@ class Section extends Border
|
||||||
private $breakType;
|
private $breakType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new Section Settings
|
* Line numbering
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $lineNumbering;
|
||||||
{
|
|
||||||
$this->orientation = null;
|
|
||||||
$this->marginTop = 1418;
|
|
||||||
$this->marginLeft = 1418;
|
|
||||||
$this->marginRight = 1418;
|
|
||||||
$this->marginBottom = 1134;
|
|
||||||
$this->pageSizeW = $this->defaultPageSizeW;
|
|
||||||
$this->pageSizeH = $this->defaultPageSizeH;
|
|
||||||
$this->borderTopSize = null;
|
|
||||||
$this->borderTopColor = null;
|
|
||||||
$this->borderLeftSize = null;
|
|
||||||
$this->borderLeftColor = null;
|
|
||||||
$this->borderRightSize = null;
|
|
||||||
$this->borderRightColor = null;
|
|
||||||
$this->borderBottomSize = null;
|
|
||||||
$this->borderBottomColor = null;
|
|
||||||
$this->headerHeight = 720; // set default header and footer to 720 twips (.5 inches)
|
|
||||||
$this->footerHeight = 720;
|
|
||||||
$this->colsNum = 1;
|
|
||||||
$this->colsSpace = 720;
|
|
||||||
$this->breakType = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Setting Value
|
* Set Setting Value
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSettingValue($key, $value)
|
public function setSettingValue($key, $value)
|
||||||
{
|
{
|
||||||
$key = String::removeUnderscorePrefix($key);
|
return $this->setStyleValue($key, $value);
|
||||||
if ($key == 'orientation' && $value == 'landscape') {
|
}
|
||||||
$this->setLandscape();
|
|
||||||
} elseif ($key == 'orientation' && is_null($value)) {
|
/**
|
||||||
$this->setPortrait();
|
* Set orientation
|
||||||
} elseif ($key == 'borderSize') {
|
*/
|
||||||
$this->setBorderSize($value);
|
public function setOrientation($value = null)
|
||||||
} elseif ($key == 'borderColor') {
|
{
|
||||||
$this->setBorderColor($value);
|
$enum = array(self::ORIENTATION_PORTRAIT, self::ORIENTATION_LANDSCAPE);
|
||||||
|
$this->orientation = $this->setEnumVal($value, $enum, $this->orientation);
|
||||||
|
$longSize = $this->pageSizeW >= $this->pageSizeH ? $this->pageSizeW : $this->pageSizeH;
|
||||||
|
$shortSize = $this->pageSizeW < $this->pageSizeH ? $this->pageSizeW : $this->pageSizeH;
|
||||||
|
|
||||||
|
if ($this->orientation == self::ORIENTATION_PORTRAIT) {
|
||||||
|
$this->pageSizeW = $shortSize;
|
||||||
|
$this->pageSizeH = $longSize;
|
||||||
} else {
|
} else {
|
||||||
$method = 'set' . $key;
|
$this->pageSizeW = $longSize;
|
||||||
if (method_exists($this, $method)) {
|
$this->pageSizeH = $shortSize;
|
||||||
$this->$method($value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Margin Top
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getMarginTop()
|
|
||||||
{
|
|
||||||
return $this->marginTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Margin Top
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setMarginTop($pValue = '')
|
|
||||||
{
|
|
||||||
$this->marginTop = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Margin Left
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getMarginLeft()
|
|
||||||
{
|
|
||||||
return $this->marginLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Margin Left
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setMarginLeft($pValue = '')
|
|
||||||
{
|
|
||||||
$this->marginLeft = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Margin Right
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getMarginRight()
|
|
||||||
{
|
|
||||||
return $this->marginRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Margin Right
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setMarginRight($pValue = '')
|
|
||||||
{
|
|
||||||
$this->marginRight = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Margin Bottom
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getMarginBottom()
|
|
||||||
{
|
|
||||||
return $this->marginBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Margin Bottom
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setMarginBottom($pValue = '')
|
|
||||||
{
|
|
||||||
$this->marginBottom = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Landscape Orientation
|
|
||||||
*/
|
|
||||||
public function setLandscape()
|
|
||||||
{
|
|
||||||
$this->orientation = 'landscape';
|
|
||||||
$this->pageSizeW = $this->defaultPageSizeH;
|
|
||||||
$this->pageSizeH = $this->defaultPageSizeW;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Portrait Orientation
|
|
||||||
*/
|
|
||||||
public function setPortrait()
|
|
||||||
{
|
|
||||||
$this->orientation = null;
|
|
||||||
$this->pageSizeW = $this->defaultPageSizeW;
|
|
||||||
$this->pageSizeH = $this->defaultPageSizeH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Page Size Width
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getPageSizeW()
|
|
||||||
{
|
|
||||||
return $this->pageSizeW;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Page Size Height
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getPageSizeH()
|
|
||||||
{
|
|
||||||
return $this->pageSizeH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Page Orientation
|
* Get Page Orientation
|
||||||
*
|
*
|
||||||
|
|
@ -314,6 +189,213 @@ class Section extends Border
|
||||||
return $this->orientation;
|
return $this->orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Portrait Orientation
|
||||||
|
*/
|
||||||
|
public function setPortrait()
|
||||||
|
{
|
||||||
|
$this->setOrientation(self::ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Landscape Orientation
|
||||||
|
*/
|
||||||
|
public function setLandscape()
|
||||||
|
{
|
||||||
|
$this->setOrientation(self::ORIENTATION_LANDSCAPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Page Size Width
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getPageSizeW()
|
||||||
|
{
|
||||||
|
return $this->pageSizeW;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Page Size Height
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getPageSizeH()
|
||||||
|
{
|
||||||
|
return $this->pageSizeH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Margin Top
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getMarginTop()
|
||||||
|
{
|
||||||
|
return $this->marginTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Margin Top
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setMarginTop($value = '')
|
||||||
|
{
|
||||||
|
$this->marginTop = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Margin Left
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getMarginLeft()
|
||||||
|
{
|
||||||
|
return $this->marginLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Margin Left
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setMarginLeft($value = '')
|
||||||
|
{
|
||||||
|
$this->marginLeft = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Margin Right
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getMarginRight()
|
||||||
|
{
|
||||||
|
return $this->marginRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Margin Right
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setMarginRight($value = '')
|
||||||
|
{
|
||||||
|
$this->marginRight = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Margin Bottom
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getMarginBottom()
|
||||||
|
{
|
||||||
|
return $this->marginBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Margin Bottom
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setMarginBottom($value = '')
|
||||||
|
{
|
||||||
|
$this->marginBottom = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get gutter
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getGutter()
|
||||||
|
{
|
||||||
|
return $this->gutter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set gutter
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setGutter($value = '')
|
||||||
|
{
|
||||||
|
$this->gutter = $this->setNumericVal($value, self::DEFAULT_GUTTER);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Header Height
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getHeaderHeight()
|
||||||
|
{
|
||||||
|
return $this->headerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Header Height
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setHeaderHeight($value = '')
|
||||||
|
{
|
||||||
|
$this->headerHeight = $this->setNumericVal($value, self::DEFAULT_HEADER_HEIGHT);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Footer Height
|
||||||
|
*
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
public function getFooterHeight()
|
||||||
|
{
|
||||||
|
return $this->footerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Footer Height
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setFooterHeight($value = '')
|
||||||
|
{
|
||||||
|
$this->footerHeight = $this->setNumericVal($value, self::DEFAULT_FOOTER_HEIGHT);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get page numbering start
|
||||||
|
*
|
||||||
|
* @return null|int
|
||||||
|
*/
|
||||||
|
public function getPageNumberingStart()
|
||||||
|
{
|
||||||
|
return $this->pageNumberingStart;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set page numbering start
|
* Set page numbering start
|
||||||
*
|
*
|
||||||
|
|
@ -326,78 +408,6 @@ class Section extends Border
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get page numbering start
|
|
||||||
*
|
|
||||||
* @return null|int
|
|
||||||
*/
|
|
||||||
public function getPageNumberingStart()
|
|
||||||
{
|
|
||||||
return $this->pageNumberingStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Header Height
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getHeaderHeight()
|
|
||||||
{
|
|
||||||
return $this->headerHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Header Height
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setHeaderHeight($pValue = '')
|
|
||||||
{
|
|
||||||
if (!is_numeric($pValue)) {
|
|
||||||
$pValue = 720;
|
|
||||||
}
|
|
||||||
$this->headerHeight = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Footer Height
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getFooterHeight()
|
|
||||||
{
|
|
||||||
return $this->footerHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Footer Height
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setFooterHeight($pValue = '')
|
|
||||||
{
|
|
||||||
if (!is_numeric($pValue)) {
|
|
||||||
$pValue = 720;
|
|
||||||
}
|
|
||||||
$this->footerHeight = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Section Columns Count
|
|
||||||
*
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setColsNum($pValue = '')
|
|
||||||
{
|
|
||||||
if (!is_numeric($pValue)) {
|
|
||||||
$pValue = 1;
|
|
||||||
}
|
|
||||||
$this->colsNum = $pValue;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Section Columns Count
|
* Get Section Columns Count
|
||||||
*
|
*
|
||||||
|
|
@ -409,23 +419,22 @@ class Section extends Border
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Section Space Between Columns
|
* Set Section Columns Count
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setColsSpace($pValue = '')
|
public function setColsNum($value = '')
|
||||||
{
|
{
|
||||||
if (!is_numeric($pValue)) {
|
$this->colsNum = $this->setIntVal($value, self::DEFAULT_COLUMN_COUNT);
|
||||||
$pValue = 720;
|
|
||||||
}
|
|
||||||
$this->colsSpace = $pValue;
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Section Space Between Columns
|
* Get Section Space Between Columns
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int|float
|
||||||
*/
|
*/
|
||||||
public function getColsSpace()
|
public function getColsSpace()
|
||||||
{
|
{
|
||||||
|
|
@ -433,13 +442,15 @@ class Section extends Border
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Break Type
|
* Set Section Space Between Columns
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param int|float $value
|
||||||
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBreakType($pValue = null)
|
public function setColsSpace($value = '')
|
||||||
{
|
{
|
||||||
$this->breakType = $pValue;
|
$this->colsSpace = $this->setNumericVal($value, self::DEFAULT_COLUMN_SPACING);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,4 +463,51 @@ class Section extends Border
|
||||||
{
|
{
|
||||||
return $this->breakType;
|
return $this->breakType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Break Type
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setBreakType($value = null)
|
||||||
|
{
|
||||||
|
$this->breakType = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get line numbering
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function getLineNumbering()
|
||||||
|
{
|
||||||
|
return $this->lineNumbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set line numbering
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setLineNumbering($value = null)
|
||||||
|
{
|
||||||
|
if ($this->lineNumbering instanceof LineNumbering) {
|
||||||
|
$this->lineNumbering->setStyleByArray($value);
|
||||||
|
} else {
|
||||||
|
$this->lineNumbering = new LineNumbering($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove line numbering
|
||||||
|
*/
|
||||||
|
public function removeLineNumbering()
|
||||||
|
{
|
||||||
|
$this->lineNumbering = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,56 +15,50 @@ namespace PhpOffice\PhpWord\Style;
|
||||||
class Tab extends AbstractStyle
|
class Tab extends AbstractStyle
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Tab Stop Type
|
* Tab stop types
|
||||||
|
*
|
||||||
|
* @const string
|
||||||
|
*/
|
||||||
|
const TAB_STOP_CLEAR = 'clear';
|
||||||
|
const TAB_STOP_LEFT = 'left';
|
||||||
|
const TAB_STOP_CENTER = 'center';
|
||||||
|
const TAB_STOP_RIGHT = 'right';
|
||||||
|
const TAB_STOP_DECIMAL = 'decimal';
|
||||||
|
const TAB_STOP_BAR = 'bar';
|
||||||
|
const TAB_STOP_NUM = 'num';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab leader types
|
||||||
|
*
|
||||||
|
* @const string
|
||||||
|
*/
|
||||||
|
const TAB_LEADER_NONE = 'none';
|
||||||
|
const TAB_LEADER_DOT = 'dot';
|
||||||
|
const TAB_LEADER_HYPHEN = 'hyphen';
|
||||||
|
const TAB_LEADER_UNDERSCORE = 'underscore';
|
||||||
|
const TAB_LEADER_HEAVY = 'heavy';
|
||||||
|
const TAB_LEADER_MIDDLEDOT = 'middleDot';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab stop type
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $val;
|
private $val = self::TAB_STOP_CLEAR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Leader Character
|
* Tab leader character
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $leader;
|
private $leader = self::TAB_LEADER_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Stop Position
|
* Tab stop position
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $position;
|
private $position = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Tab Stop Type
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type
|
|
||||||
*/
|
|
||||||
private static $possibleStopTypes = array(
|
|
||||||
'clear', // No Tab Stop
|
|
||||||
'left', // Left Tab Stop
|
|
||||||
'center', // Center Tab Stop
|
|
||||||
'right', // Right Tab Stop
|
|
||||||
'decimal', // Decimal Tab
|
|
||||||
'bar', // Bar Tab
|
|
||||||
'num' // List tab
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tab Leader Character
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character
|
|
||||||
*/
|
|
||||||
private static $possibleLeaders = array(
|
|
||||||
'none', // No tab stop leader
|
|
||||||
'dot', // Dotted leader line
|
|
||||||
'hyphen', // Dashed tab stop leader line
|
|
||||||
'underscore', // Solid leader line
|
|
||||||
'heavy', // Heavy solid leader line
|
|
||||||
'middleDot' // Middle dot leader line
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of Tab. Both $val and $leader
|
* Create a new instance of Tab. Both $val and $leader
|
||||||
|
|
@ -72,19 +66,23 @@ class Tab extends AbstractStyle
|
||||||
* they will be changed to default values.
|
* they will be changed to default values.
|
||||||
*
|
*
|
||||||
* @param string $val Defaults to 'clear' if value is not possible.
|
* @param string $val Defaults to 'clear' if value is not possible.
|
||||||
* @param int $position Must be an integer; otherwise defaults to 0.
|
* @param int $position Must be numeric; otherwise defaults to 0.
|
||||||
* @param string $leader Defaults to null if value is not possible.
|
* @param string $leader Defaults to null if value is not possible.
|
||||||
*/
|
*/
|
||||||
public function __construct($val = null, $position = 0, $leader = null)
|
public function __construct($val = null, $position = 0, $leader = null)
|
||||||
{
|
{
|
||||||
// Default to clear if the stop type is not matched
|
$stopTypes = array(
|
||||||
$this->val = (self::isStopType($val)) ? $val : 'clear';
|
self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT,self::TAB_STOP_CENTER,
|
||||||
|
self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM
|
||||||
|
);
|
||||||
|
$leaderTypes = array(
|
||||||
|
self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN,
|
||||||
|
self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT
|
||||||
|
);
|
||||||
|
|
||||||
// Default to 0 if the position is non-numeric
|
$this->val = $this->setEnumVal($val, $stopTypes, $this->val);
|
||||||
$this->position = (is_numeric($position)) ? intval($position) : 0;
|
$this->position = $this->setNumericVal($position, $this->position);
|
||||||
|
$this->leader = $this->setEnumVal($leader, $leaderTypes, $this->leader);
|
||||||
// Default to null if no tab leader
|
|
||||||
$this->leader = (self::isLeaderType($leader)) ? $leader : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,26 +114,4 @@ class Tab extends AbstractStyle
|
||||||
{
|
{
|
||||||
return $this->position;
|
return $this->position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if attribute is a valid stop type.
|
|
||||||
*
|
|
||||||
* @param string $attribute
|
|
||||||
* @return bool True if it is; false otherwise.
|
|
||||||
*/
|
|
||||||
private static function isStopType($attribute)
|
|
||||||
{
|
|
||||||
return in_array($attribute, self::$possibleStopTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test if attribute is a valid leader type.
|
|
||||||
*
|
|
||||||
* @param string $attribute
|
|
||||||
* @return bool True if it is; false otherwise.
|
|
||||||
*/
|
|
||||||
private static function isLeaderType($attribute)
|
|
||||||
{
|
|
||||||
return in_array($attribute, self::$possibleLeaders);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\Settings;
|
||||||
use PhpOffice\PhpWord\Element\AbstractElement;
|
use PhpOffice\PhpWord\Element\AbstractElement;
|
||||||
use PhpOffice\PhpWord\Element\TextBreak;
|
use PhpOffice\PhpWord\Element\TextBreak;
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use PhpOffice\PhpWord\PhpWord;
|
||||||
use PhpOffice\PhpWord\Element\Section;
|
use PhpOffice\PhpWord\Element\Section;
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 document part writer
|
* Word2007 document part writer
|
||||||
|
|
@ -32,6 +33,9 @@ class Document extends AbstractPart
|
||||||
throw new Exception("No PhpWord assigned.");
|
throw new Exception("No PhpWord assigned.");
|
||||||
}
|
}
|
||||||
$xmlWriter = $this->getXmlWriter();
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
$sections = $phpWord->getSections();
|
||||||
|
$sectionCount = count($sections);
|
||||||
|
$currentSection = 0;
|
||||||
|
|
||||||
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||||
$xmlWriter->startElement('w:document');
|
$xmlWriter->startElement('w:document');
|
||||||
|
|
@ -47,18 +51,13 @@ class Document extends AbstractPart
|
||||||
|
|
||||||
$xmlWriter->startElement('w:body');
|
$xmlWriter->startElement('w:body');
|
||||||
|
|
||||||
$sections = $phpWord->getSections();
|
|
||||||
$countSections = count($sections);
|
|
||||||
$pSection = 0;
|
|
||||||
|
|
||||||
if ($countSections > 0) {
|
if ($sectionCount > 0) {
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$pSection++;
|
$currentSection++;
|
||||||
|
|
||||||
$this->writeContainerElements($xmlWriter, $section);
|
$this->writeContainerElements($xmlWriter, $section);
|
||||||
|
if ($currentSection == $sectionCount) {
|
||||||
if ($pSection == $countSections) {
|
$this->writeSectionSettings($xmlWriter, $section);
|
||||||
$this->writeEndSection($xmlWriter, $section);
|
|
||||||
} else {
|
} else {
|
||||||
$this->writeSection($xmlWriter, $section);
|
$this->writeSection($xmlWriter, $section);
|
||||||
}
|
}
|
||||||
|
|
@ -66,10 +65,8 @@ class Document extends AbstractPart
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:body
|
$xmlWriter->endElement(); // w:body
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:document
|
$xmlWriter->endElement(); // w:document
|
||||||
|
|
||||||
// Return
|
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +80,7 @@ class Document extends AbstractPart
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('w:p');
|
$xmlWriter->startElement('w:p');
|
||||||
$xmlWriter->startElement('w:pPr');
|
$xmlWriter->startElement('w:pPr');
|
||||||
$this->writeEndSection($xmlWriter, $section);
|
$this->writeSectionSettings($xmlWriter, $section);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
@ -94,114 +91,38 @@ class Document extends AbstractPart
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param \PhpOffice\PhpWord\Element\Section $section
|
* @param \PhpOffice\PhpWord\Element\Section $section
|
||||||
*/
|
*/
|
||||||
private function writeEndSection(XMLWriter $xmlWriter, Section $section)
|
private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
|
||||||
{
|
{
|
||||||
$settings = $section->getSettings();
|
|
||||||
$headers = $section->getHeaders();
|
|
||||||
$footers = $section->getFooters();
|
|
||||||
$pgSzW = $settings->getPageSizeW();
|
|
||||||
$pgSzH = $settings->getPageSizeH();
|
|
||||||
$orientation = $settings->getOrientation();
|
|
||||||
|
|
||||||
$marginTop = $settings->getMarginTop();
|
|
||||||
$marginLeft = $settings->getMarginLeft();
|
|
||||||
$marginRight = $settings->getMarginRight();
|
|
||||||
$marginBottom = $settings->getMarginBottom();
|
|
||||||
|
|
||||||
$headerHeight = $settings->getHeaderHeight();
|
|
||||||
$footerHeight = $settings->getFooterHeight();
|
|
||||||
|
|
||||||
$borders = $settings->getBorderSize();
|
|
||||||
|
|
||||||
$colsNum = $settings->getColsNum();
|
|
||||||
$colsSpace = $settings->getColsSpace();
|
|
||||||
$breakType = $settings->getBreakType();
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:sectPr');
|
$xmlWriter->startElement('w:sectPr');
|
||||||
|
|
||||||
// Section break
|
|
||||||
if (!is_null($breakType)) {
|
|
||||||
$xmlWriter->startElement('w:type');
|
|
||||||
$xmlWriter->writeAttribute('w:val', $breakType);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Header reference
|
// Header reference
|
||||||
foreach ($headers as &$header) {
|
foreach ($section->getHeaders() as $header) {
|
||||||
$rId = $header->getRelationId();
|
$rId = $header->getRelationId();
|
||||||
$xmlWriter->startElement('w:headerReference');
|
$xmlWriter->startElement('w:headerReference');
|
||||||
$xmlWriter->writeAttribute('w:type', $header->getType());
|
$xmlWriter->writeAttribute('w:type', $header->getType());
|
||||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer reference
|
// Footer reference
|
||||||
foreach ($footers as &$footer) {
|
foreach ($section->getFooters() as $footer) {
|
||||||
$rId = $footer->getRelationId();
|
$rId = $footer->getRelationId();
|
||||||
$xmlWriter->startElement('w:footerReference');
|
$xmlWriter->startElement('w:footerReference');
|
||||||
$xmlWriter->writeAttribute('w:type', $footer->getType());
|
$xmlWriter->writeAttribute('w:type', $footer->getType());
|
||||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Different first page
|
// Different first page
|
||||||
if ($section->hasDifferentFirstPage()) {
|
if ($section->hasDifferentFirstPage()) {
|
||||||
$xmlWriter->startElement('w:titlePg');
|
$xmlWriter->startElement('w:titlePg');
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page size & orientation
|
// Section settings
|
||||||
$xmlWriter->startElement('w:pgSz');
|
$styleWriter = new SectionStyleWriter($xmlWriter, $section->getSettings());
|
||||||
$xmlWriter->writeAttribute('w:w', $pgSzW);
|
$styleWriter->write();
|
||||||
$xmlWriter->writeAttribute('w:h', $pgSzH);
|
|
||||||
if (!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
|
||||||
$xmlWriter->writeAttribute('w:orient', $orientation);
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement(); // w:pgSz
|
|
||||||
|
|
||||||
// Margins
|
$xmlWriter->endElement(); // w:sectPr
|
||||||
$xmlWriter->startElement('w:pgMar');
|
|
||||||
$xmlWriter->writeAttribute('w:top', $marginTop);
|
|
||||||
$xmlWriter->writeAttribute('w:right', $marginRight);
|
|
||||||
$xmlWriter->writeAttribute('w:bottom', $marginBottom);
|
|
||||||
$xmlWriter->writeAttribute('w:left', $marginLeft);
|
|
||||||
$xmlWriter->writeAttribute('w:header', $headerHeight);
|
|
||||||
$xmlWriter->writeAttribute('w:footer', $footerHeight);
|
|
||||||
$xmlWriter->writeAttribute('w:gutter', '0');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
// Borders
|
|
||||||
$hasBorders = false;
|
|
||||||
for ($i = 0; $i < 4; $i++) {
|
|
||||||
if (!is_null($borders[$i])) {
|
|
||||||
$hasBorders = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($hasBorders) {
|
|
||||||
$borderColor = $settings->getBorderColor();
|
|
||||||
$mbWriter = new \PhpOffice\PhpWord\Writer\Word2007\Style\MarginBorder($xmlWriter);
|
|
||||||
$mbWriter->setSizes($borders);
|
|
||||||
$mbWriter->setColors($borderColor);
|
|
||||||
$mbWriter->setAttributes(array('space' => '24'));
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:pgBorders');
|
|
||||||
$xmlWriter->writeAttribute('w:offsetFrom', 'page');
|
|
||||||
$mbWriter->write();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Page numbering
|
|
||||||
if (null !== $settings->getPageNumberingStart()) {
|
|
||||||
$xmlWriter->startElement('w:pgNumType');
|
|
||||||
$xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart());
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Columns
|
|
||||||
$xmlWriter->startElement('w:cols');
|
|
||||||
$xmlWriter->writeAttribute('w:num', $colsNum);
|
|
||||||
$xmlWriter->writeAttribute('w:space', $colsSpace);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Settings;
|
||||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,4 +48,21 @@ abstract class AbstractStyle
|
||||||
$this->xmlWriter = $xmlWriter;
|
$this->xmlWriter = $xmlWriter;
|
||||||
$this->style = $style;
|
$this->style = $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert twip value
|
||||||
|
*
|
||||||
|
* @param int|float $value
|
||||||
|
* @param int|float $default
|
||||||
|
* @return int|float
|
||||||
|
*/
|
||||||
|
protected function convertTwip($value, $default)
|
||||||
|
{
|
||||||
|
$unit = Settings::getMeasurementUnit();
|
||||||
|
if ($unit == Settings::UNIT_TWIP || $value == $default) {
|
||||||
|
return $value;
|
||||||
|
} else {
|
||||||
|
return $value * $unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line numbering style writer
|
||||||
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class LineNumbering extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*
|
||||||
|
* The w:start seems to be zero based so we have to decrement by one
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
if (!($this->style instanceof \PhpOffice\PhpWord\Style\LineNumbering)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->xmlWriter->startElement('w:lnNumType');
|
||||||
|
$this->xmlWriter->writeAttribute('w:start', $this->style->getStart() - 1);
|
||||||
|
$this->xmlWriter->writeAttribute('w:countBy', $this->style->getIncrement());
|
||||||
|
$this->xmlWriter->writeAttribute('w:distance', $this->style->getDistance());
|
||||||
|
$this->xmlWriter->writeAttribute('w:restart', $this->style->getRestart());
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Margin border style writer
|
* Margin border style writer
|
||||||
*
|
*
|
||||||
|
|
@ -44,6 +46,8 @@ class MarginBorder extends AbstractStyle
|
||||||
{
|
{
|
||||||
$sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV');
|
$sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV');
|
||||||
$sizeCount = count($this->sizes) - 1;
|
$sizeCount = count($this->sizes) - 1;
|
||||||
|
$unit = Settings::getMeasurementUnit();
|
||||||
|
|
||||||
for ($i = 0; $i < $sizeCount; $i++) {
|
for ($i = 0; $i < $sizeCount; $i++) {
|
||||||
if (!is_null($this->sizes[$i])) {
|
if (!is_null($this->sizes[$i])) {
|
||||||
$this->xmlWriter->startElement('w:' . $sides[$i]);
|
$this->xmlWriter->startElement('w:' . $sides[$i]);
|
||||||
|
|
@ -58,7 +62,7 @@ class MarginBorder extends AbstractStyle
|
||||||
$this->xmlWriter->writeAttribute('w:color', $this->colors[$i]);
|
$this->xmlWriter->writeAttribute('w:color', $this->colors[$i]);
|
||||||
if (!empty($this->attributes)) {
|
if (!empty($this->attributes)) {
|
||||||
if (array_key_exists('space', $this->attributes)) {
|
if (array_key_exists('space', $this->attributes)) {
|
||||||
$this->xmlWriter->writeAttribute('w:space', '24');
|
$this->xmlWriter->writeAttribute('w:space', $this->attributes['space']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\Tab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph style writer
|
* Paragraph style writer
|
||||||
*
|
*
|
||||||
|
|
@ -139,17 +141,13 @@ class Paragraph extends AbstractStyle
|
||||||
$this->xmlWriter->endElement();
|
$this->xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
if (!empty($tabs)) {
|
if (!empty($tabs)) {
|
||||||
$this->xmlWriter->startElement("w:tabs");
|
$this->xmlWriter->startElement("w:tabs");
|
||||||
foreach ($tabs as $tab) {
|
foreach ($tabs as $tab) {
|
||||||
$this->xmlWriter->startElement("w:tab");
|
$styleWriter = new Tab($this->xmlWriter, $tab);
|
||||||
$this->xmlWriter->writeAttribute("w:val", $tab->getStopType());
|
$styleWriter->write();
|
||||||
if (!is_null($tab->getLeader())) {
|
|
||||||
$this->xmlWriter->writeAttribute("w:leader", $tab->getLeader());
|
|
||||||
}
|
|
||||||
$this->xmlWriter->writeAttribute("w:pos", $tab->getPosition());
|
|
||||||
$this->xmlWriter->endElement();
|
|
||||||
}
|
}
|
||||||
$this->xmlWriter->endElement();
|
$this->xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\LineNumbering;
|
||||||
|
use PhpOffice\PhpWord\Writer\Word2007\Style\MarginBorder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Section style writer
|
||||||
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class Section extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
if (!($this->style instanceof \PhpOffice\PhpWord\Style\Section)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Section break
|
||||||
|
if (!is_null($this->style->getBreakType())) {
|
||||||
|
$this->xmlWriter->startElement('w:type');
|
||||||
|
$this->xmlWriter->writeAttribute('w:val', $this->style->getBreakType());
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page size & orientation
|
||||||
|
$this->xmlWriter->startElement('w:pgSz');
|
||||||
|
$this->xmlWriter->writeAttribute('w:orient', $this->style->getOrientation());
|
||||||
|
$this->xmlWriter->writeAttribute('w:w', $this->style->getPageSizeW());
|
||||||
|
$this->xmlWriter->writeAttribute('w:h', $this->style->getPageSizeH());
|
||||||
|
$this->xmlWriter->endElement(); // w:pgSz
|
||||||
|
|
||||||
|
// Margins
|
||||||
|
$this->xmlWriter->startElement('w:pgMar');
|
||||||
|
$this->xmlWriter->writeAttribute('w:top', $this->convertTwip($this->style->getMarginTop(), SectionStyle::DEFAULT_MARGIN));
|
||||||
|
$this->xmlWriter->writeAttribute('w:right', $this->convertTwip($this->style->getMarginRight(), SectionStyle::DEFAULT_MARGIN));
|
||||||
|
$this->xmlWriter->writeAttribute('w:bottom', $this->convertTwip($this->style->getMarginBottom(), SectionStyle::DEFAULT_MARGIN));
|
||||||
|
$this->xmlWriter->writeAttribute('w:left', $this->convertTwip($this->style->getMarginLeft(), SectionStyle::DEFAULT_MARGIN));
|
||||||
|
$this->xmlWriter->writeAttribute('w:header', $this->convertTwip($this->style->getHeaderHeight(), SectionStyle::DEFAULT_HEADER_HEIGHT));
|
||||||
|
$this->xmlWriter->writeAttribute('w:footer', $this->convertTwip($this->style->getFooterHeight(), SectionStyle::DEFAULT_FOOTER_HEIGHT));
|
||||||
|
$this->xmlWriter->writeAttribute('w:gutter', $this->convertTwip($this->style->getGutter(), SectionStyle::DEFAULT_GUTTER));
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
|
||||||
|
// Borders
|
||||||
|
$borders = $this->style->getBorderSize();
|
||||||
|
$hasBorders = false;
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
if (!is_null($borders[$i])) {
|
||||||
|
$hasBorders = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($hasBorders) {
|
||||||
|
$styleWriter = new MarginBorder($this->xmlWriter);
|
||||||
|
$styleWriter->setSizes($borders);
|
||||||
|
$styleWriter->setColors($this->style->getBorderColor());
|
||||||
|
$styleWriter->setAttributes(array('space' => '24'));
|
||||||
|
|
||||||
|
$this->xmlWriter->startElement('w:pgBorders');
|
||||||
|
$this->xmlWriter->writeAttribute('w:offsetFrom', 'page');
|
||||||
|
$styleWriter->write();
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page numbering
|
||||||
|
if (!is_null($this->style->getPageNumberingStart())) {
|
||||||
|
$this->xmlWriter->startElement('w:pgNumType');
|
||||||
|
$this->xmlWriter->writeAttribute('w:start', $this->style->getPageNumberingStart());
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
$this->xmlWriter->startElement('w:cols');
|
||||||
|
$this->xmlWriter->writeAttribute('w:num', $this->style->getColsNum());
|
||||||
|
$this->xmlWriter->writeAttribute('w:space', $this->convertTwip($this->style->getColsSpace(), SectionStyle::DEFAULT_COLUMN_SPACING));
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
|
||||||
|
// Line numbering
|
||||||
|
$styleWriter = new LineNumbering($this->xmlWriter, $this->style->getLineNumbering());
|
||||||
|
$styleWriter->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line numbering style writer
|
||||||
|
*
|
||||||
|
* @since 0.10.0
|
||||||
|
*/
|
||||||
|
class Tab extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
if (!($this->style instanceof \PhpOffice\PhpWord\Style\Tab)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->xmlWriter->startElement("w:tab");
|
||||||
|
$this->xmlWriter->writeAttribute("w:val", $this->style->getStopType());
|
||||||
|
$this->xmlWriter->writeAttribute("w:leader", $this->style->getLeader());
|
||||||
|
$this->xmlWriter->writeAttribute('w:pos', $this->convertTwip($this->style->getPosition(), 0));
|
||||||
|
$this->xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,25 +27,25 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
// Section Settings
|
// Section Settings
|
||||||
$oSettings = new Section();
|
$oSettings = new Section();
|
||||||
|
|
||||||
$oSettings->setSettingValue('_orientation', 'landscape');
|
$oSettings->setSettingValue('orientation', 'landscape');
|
||||||
$this->assertEquals('landscape', $oSettings->getOrientation());
|
$this->assertEquals('landscape', $oSettings->getOrientation());
|
||||||
$this->assertEquals(16838, $oSettings->getPageSizeW());
|
$this->assertEquals(16838, $oSettings->getPageSizeW());
|
||||||
$this->assertEquals(11906, $oSettings->getPageSizeH());
|
$this->assertEquals(11906, $oSettings->getPageSizeH());
|
||||||
|
|
||||||
$oSettings->setSettingValue('_orientation', null);
|
$oSettings->setSettingValue('orientation', null);
|
||||||
$this->assertNull($oSettings->getOrientation());
|
$this->assertEquals('portrait', $oSettings->getOrientation());
|
||||||
$this->assertEquals(11906, $oSettings->getPageSizeW());
|
$this->assertEquals(11906, $oSettings->getPageSizeW());
|
||||||
$this->assertEquals(16838, $oSettings->getPageSizeH());
|
$this->assertEquals(16838, $oSettings->getPageSizeH());
|
||||||
|
|
||||||
$iVal = rand(1, 1000);
|
$iVal = rand(1, 1000);
|
||||||
$oSettings->setSettingValue('_borderSize', $iVal);
|
$oSettings->setSettingValue('borderSize', $iVal);
|
||||||
$this->assertEquals(array($iVal, $iVal, $iVal, $iVal), $oSettings->getBorderSize());
|
$this->assertEquals(array($iVal, $iVal, $iVal, $iVal), $oSettings->getBorderSize());
|
||||||
$this->assertEquals($iVal, $oSettings->getBorderBottomSize());
|
$this->assertEquals($iVal, $oSettings->getBorderBottomSize());
|
||||||
$this->assertEquals($iVal, $oSettings->getBorderLeftSize());
|
$this->assertEquals($iVal, $oSettings->getBorderLeftSize());
|
||||||
$this->assertEquals($iVal, $oSettings->getBorderRightSize());
|
$this->assertEquals($iVal, $oSettings->getBorderRightSize());
|
||||||
$this->assertEquals($iVal, $oSettings->getBorderTopSize());
|
$this->assertEquals($iVal, $oSettings->getBorderTopSize());
|
||||||
|
|
||||||
$oSettings->setSettingValue('_borderColor', 'FF00AA');
|
$oSettings->setSettingValue('borderColor', 'FF00AA');
|
||||||
$this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor());
|
$this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor());
|
||||||
$this->assertEquals('FF00AA', $oSettings->getBorderBottomColor());
|
$this->assertEquals('FF00AA', $oSettings->getBorderBottomColor());
|
||||||
$this->assertEquals('FF00AA', $oSettings->getBorderLeftColor());
|
$this->assertEquals('FF00AA', $oSettings->getBorderLeftColor());
|
||||||
|
|
|
||||||
|
|
@ -499,4 +499,20 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test write gutter and line numbering
|
||||||
|
*/
|
||||||
|
public function testWriteGutterAndLineNumbering()
|
||||||
|
{
|
||||||
|
$pageMarginPath = '/w:document/w:body/w:sectPr/w:pgMar';
|
||||||
|
$lineNumberingPath = '/w:document/w:body/w:sectPr/w:lnNumType';
|
||||||
|
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$section = $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array()));
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter'));
|
||||||
|
$this->assertTrue($doc->elementExists($lineNumberingPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue