Use section "style" instead of "settings" for consistency
This commit is contained in:
parent
a9c9c21d3b
commit
63d53ac910
|
|
@ -21,6 +21,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
- `Element\Link::getTarget()` replaced by `Element\Link::getSource()`
|
- `Element\Link::getTarget()` replaced by `Element\Link::getSource()`
|
||||||
|
- `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()`
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ section. Example:
|
||||||
Section settings
|
Section settings
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Below are the available settings for section:
|
Below are the available styles for section:
|
||||||
|
|
||||||
- ``orientation`` Page orientation, i.e. 'portrait' (default) or
|
- ``orientation`` Page orientation, i.e. 'portrait' (default) or
|
||||||
'landscape'
|
'landscape'
|
||||||
|
|
@ -56,8 +56,8 @@ Below are the available settings for section:
|
||||||
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
|
- ``breakType`` Section break type (nextPage, nextColumn, continuous,
|
||||||
evenPage, oddPage)
|
evenPage, oddPage)
|
||||||
|
|
||||||
The following two settings are automatically set by the use of the
|
The following two styles are automatically set by the use of the
|
||||||
``orientation`` setting. You can alter them but that's not recommended.
|
``orientation`` style. You can alter them but that's not recommended.
|
||||||
|
|
||||||
- ``pageSizeW`` Page width in twips
|
- ``pageSizeW`` Page width in twips
|
||||||
- ``pageSizeH`` Page height in twips
|
- ``pageSizeH`` Page height in twips
|
||||||
|
|
@ -66,7 +66,7 @@ Page number
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
You can change a section page number by using the ``pageNumberingStart``
|
You can change a section page number by using the ``pageNumberingStart``
|
||||||
property of the section.
|
style of the section.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
|
@ -75,13 +75,13 @@ property of the section.
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setPageNumberingStart(1);
|
$section->getStyle()->setPageNumberingStart(1);
|
||||||
|
|
||||||
Multicolumn
|
Multicolumn
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
You can change a section layout to multicolumn (like in a newspaper) by
|
You can change a section layout to multicolumn (like in a newspaper) by
|
||||||
using the ``breakType`` and ``colsNum`` property of the section.
|
using the ``breakType`` and ``colsNum`` style of the section.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
|
@ -90,14 +90,14 @@ using the ``breakType`` and ``colsNum`` property of the section.
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setBreakType('continuous');
|
$section->getStyle()->setBreakType('continuous');
|
||||||
$section->getSettings()->setColsNum(2);
|
$section->getStyle()->setColsNum(2);
|
||||||
|
|
||||||
|
|
||||||
### Line numbering
|
### Line numbering
|
||||||
|
|
||||||
You can apply line numbering to a section by using the ``lineNumbering``
|
You can apply line numbering to a section by using the ``lineNumbering``
|
||||||
property of the section.
|
style of the section.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ property of the section.
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setLineNumbering(array());
|
$section->getStyle()->setLineNumbering(array());
|
||||||
|
|
||||||
Below are the properties of the line numbering style.
|
Below are the properties of the line numbering style.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ points to twips.
|
||||||
);
|
);
|
||||||
|
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$sectionStyle = $section->getSettings();
|
$sectionStyle = $section->getStyle();
|
||||||
// half inch left margin
|
// half inch left margin
|
||||||
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
|
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
|
||||||
// 2 cm right margin
|
// 2 cm right margin
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ $phpWord->addParagraphStyle('My Style', array(
|
||||||
);
|
);
|
||||||
|
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$sectionStyle = $section->getSettings();
|
$sectionStyle = $section->getStyle();
|
||||||
// half inch left margin
|
// half inch left margin
|
||||||
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
|
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
|
||||||
// 2 cm right margin
|
// 2 cm right margin
|
||||||
|
|
@ -333,9 +333,9 @@ $sectionSettings = array(
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Section settings
|
### Section style
|
||||||
|
|
||||||
Below are the available settings for section:
|
Below are the available styles for section:
|
||||||
|
|
||||||
- `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape'
|
- `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape'
|
||||||
- `marginTop` Page margin top in twips
|
- `marginTop` Page margin top in twips
|
||||||
|
|
@ -357,14 +357,14 @@ Below are the available settings for section:
|
||||||
- `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)
|
||||||
|
|
||||||
The following two settings are automatically set by the use of the `orientation` setting. You can alter them but that's not recommended.
|
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
|
- `pageSizeW` Page width in twips
|
||||||
- `pageSizeH` Page height in twips
|
- `pageSizeH` Page height in twips
|
||||||
|
|
||||||
### Page number
|
### Page number
|
||||||
|
|
||||||
You can change a section page number by using the `pageNumberingStart` property of the section.
|
You can change a section page number by using the `pageNumberingStart` style of the section.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Method 1
|
// Method 1
|
||||||
|
|
@ -372,12 +372,12 @@ $section = $phpWord->addSection(array('pageNumberingStart' => 1));
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setPageNumberingStart(1);
|
$section->getStyle()->setPageNumberingStart(1);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multicolumn
|
### Multicolumn
|
||||||
|
|
||||||
You can change a section layout to multicolumn (like in a newspaper) by using the `breakType` and `colsNum` property of the section.
|
You can change a section layout to multicolumn (like in a newspaper) by using the `breakType` and `colsNum` style of the section.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Method 1
|
// Method 1
|
||||||
|
|
@ -385,13 +385,13 @@ $section = $phpWord->addSection(array('breakType' => 'continuous', 'colsNum' =>
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setBreakType('continuous');
|
$section->getStyle()->setBreakType('continuous');
|
||||||
$section->getSettings()->setColsNum(2);
|
$section->getStyle()->setColsNum(2);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Line numbering
|
### Line numbering
|
||||||
|
|
||||||
You can apply line numbering to a section by using the `lineNumbering` property of the section.
|
You can apply line numbering to a section by using the `lineNumbering` style of the section.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Method 1
|
// Method 1
|
||||||
|
|
@ -399,7 +399,7 @@ $section = $phpWord->addSection(array('lineNumbering' => array()));
|
||||||
|
|
||||||
// Method 2
|
// Method 2
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->getSettings()->setLineNumbering(array());
|
$section->getStyle()->setLineNumbering(array());
|
||||||
```
|
```
|
||||||
|
|
||||||
Below are the properties of the line numbering style.
|
Below are the properties of the line numbering style.
|
||||||
|
|
|
||||||
|
|
@ -343,14 +343,14 @@ abstract class AbstractElement
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set style value
|
* Set new style value
|
||||||
*
|
*
|
||||||
* @param mixed $styleObject Style object
|
* @param mixed $styleObject Style object
|
||||||
* @param mixed $styleValue Style value
|
* @param mixed $styleValue Style value
|
||||||
* @param bool $returnObject Always return object
|
* @param bool $returnObject Always return object
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function setStyle($styleObject, $styleValue = null, $returnObject = false)
|
protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false)
|
||||||
{
|
{
|
||||||
if (!is_null($styleValue) && is_array($styleValue)) {
|
if (!is_null($styleValue) && is_array($styleValue)) {
|
||||||
$styleObject->setStyleByArray($styleValue);
|
$styleObject->setStyleByArray($styleValue);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class Cell extends AbstractContainer
|
||||||
public function __construct($width = null, $style = null)
|
public function __construct($width = null, $style = null)
|
||||||
{
|
{
|
||||||
$this->width = $width;
|
$this->width = $width;
|
||||||
$this->style = $this->setStyle(new CellStyle(), $style, true);
|
$this->style = $this->setNewStyle(new CellStyle(), $style, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,6 @@ class Endnote extends Footnote
|
||||||
*/
|
*/
|
||||||
public function __construct($paragraphStyle = null)
|
public function __construct($paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class Footnote extends AbstractContainer
|
||||||
*/
|
*/
|
||||||
public function __construct($paragraphStyle = null)
|
public function __construct($paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
$this->setDocPart($this->container);
|
$this->setDocPart($this->container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ class Image extends AbstractElement
|
||||||
{
|
{
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
$this->setIsWatermark($watermark);
|
$this->setIsWatermark($watermark);
|
||||||
$this->style = $this->setStyle(new ImageStyle(), $style, true);
|
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||||
|
|
||||||
$this->checkImage($source);
|
$this->checkImage($source);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class Line extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($style = null)
|
public function __construct($style = null)
|
||||||
{
|
{
|
||||||
$this->style = $this->setStyle(new LineStyle(), $style);
|
$this->style = $this->setNewStyle(new LineStyle(), $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ class Link extends AbstractElement
|
||||||
{
|
{
|
||||||
$this->source = String::toUTF8($source);
|
$this->source = String::toUTF8($source);
|
||||||
$this->text = is_null($text) ? $this->source : String::toUTF8($text);
|
$this->text = is_null($text) ? $this->source : String::toUTF8($text);
|
||||||
$this->fontStyle = $this->setStyle(new Font('text'), $fontStyle);
|
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class ListItem extends AbstractElement
|
||||||
if (!is_null($listStyle) && is_string($listStyle)) {
|
if (!is_null($listStyle) && is_string($listStyle)) {
|
||||||
$this->style = new ListItemStyle($listStyle);
|
$this->style = new ListItemStyle($listStyle);
|
||||||
} else {
|
} else {
|
||||||
$this->style = $this->setStyle(new ListItemStyle(), $listStyle, true);
|
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ class ListItemRun extends TextRun
|
||||||
if (!is_null($listStyle) && is_string($listStyle)) {
|
if (!is_null($listStyle) && is_string($listStyle)) {
|
||||||
$this->style = new ListItemStyle($listStyle);
|
$this->style = new ListItemStyle($listStyle);
|
||||||
} else {
|
} else {
|
||||||
$this->style = $this->setStyle(new ListItemStyle(), $listStyle, true);
|
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
|
||||||
}
|
}
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class Object extends AbstractElement
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
$this->style = $this->setStyle(new ImageStyle(), $style, true);
|
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||||
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@ class PreserveText extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->fontStyle = $this->setStyle(new Font('text'), $fontStyle);
|
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
|
|
||||||
$this->text = String::toUTF8($text);
|
$this->text = String::toUTF8($text);
|
||||||
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class Row extends AbstractElement
|
||||||
public function __construct($height = null, $style = null)
|
public function __construct($height = null, $style = null)
|
||||||
{
|
{
|
||||||
$this->height = $height;
|
$this->height = $height;
|
||||||
$this->style = $this->setStyle(new RowStyle(), $style, true);
|
$this->style = $this->setNewStyle(new RowStyle(), $style, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
namespace PhpOffice\PhpWord\Element;
|
namespace PhpOffice\PhpWord\Element;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\Style\Section as SectionSettings;
|
use PhpOffice\PhpWord\Style\Section as SectionStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section
|
* Section
|
||||||
|
|
@ -31,11 +31,11 @@ class Section extends AbstractContainer
|
||||||
protected $container = 'Section';
|
protected $container = 'Section';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section settings
|
* Section style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Section
|
* @var \PhpOffice\PhpWord\Style\Section
|
||||||
*/
|
*/
|
||||||
private $settings;
|
private $style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section headers, indexed from 1, not zero
|
* Section headers, indexed from 1, not zero
|
||||||
|
|
@ -55,41 +55,36 @@ class Section extends AbstractContainer
|
||||||
* Create new instance
|
* Create new instance
|
||||||
*
|
*
|
||||||
* @param int $sectionCount
|
* @param int $sectionCount
|
||||||
* @param array $settings
|
* @param array $style
|
||||||
*/
|
*/
|
||||||
public function __construct($sectionCount, $settings = null)
|
public function __construct($sectionCount, $style = null)
|
||||||
{
|
{
|
||||||
$this->sectionId = $sectionCount;
|
$this->sectionId = $sectionCount;
|
||||||
$this->setDocPart($this->container, $this->sectionId);
|
$this->setDocPart($this->container, $this->sectionId);
|
||||||
$this->settings = new SectionSettings();
|
$this->style = new SectionStyle();
|
||||||
$this->setSettings($settings);
|
$this->setStyle($style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set section settings
|
* Set section style
|
||||||
*
|
*
|
||||||
* @param array $settings
|
* @param array $style
|
||||||
*/
|
*/
|
||||||
public function setSettings($settings = null)
|
public function setStyle($style = null)
|
||||||
{
|
{
|
||||||
if (!is_null($settings) && is_array($settings)) {
|
if (!is_null($style) && is_array($style)) {
|
||||||
foreach ($settings as $key => $value) {
|
$this->style->setStyleByArray($style);
|
||||||
if (is_null($value)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->settings->setSettingValue($key, $value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Section Settings
|
* Get section style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Section
|
* @return \PhpOffice\PhpWord\Style\Section
|
||||||
*/
|
*/
|
||||||
public function getSettings()
|
public function getStyle()
|
||||||
{
|
{
|
||||||
return $this->settings;
|
return $this->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,6 +179,30 @@ class Section extends AbstractContainer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set section style
|
||||||
|
*
|
||||||
|
* @param array $settings
|
||||||
|
* @deprecated 0.12.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function setSettings($settings = null)
|
||||||
|
{
|
||||||
|
$this->setStyle($settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get section style
|
||||||
|
*
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Section
|
||||||
|
* @deprecated 0.12.0
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
public function getSettings()
|
||||||
|
{
|
||||||
|
return $this->getStyle();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create header
|
* Create header
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class Shape extends AbstractElement
|
||||||
public function __construct($type, $style = null)
|
public function __construct($type, $style = null)
|
||||||
{
|
{
|
||||||
$this->setType($type);
|
$this->setType($type);
|
||||||
$this->style = $this->setStyle(new ShapeStyle(), $style);
|
$this->style = $this->setNewStyle(new ShapeStyle(), $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class Table extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function __construct($style = null)
|
public function __construct($style = null)
|
||||||
{
|
{
|
||||||
$this->style = $this->setStyle(new TableStyle(), $style);
|
$this->style = $this->setNewStyle(new TableStyle(), $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class TextBox extends AbstractContainer
|
||||||
*/
|
*/
|
||||||
public function __construct($style = null)
|
public function __construct($style = null)
|
||||||
{
|
{
|
||||||
$this->style = $this->setStyle(new TextBoxStyle(), $style);
|
$this->style = $this->setNewStyle(new TextBoxStyle(), $style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class TextRun extends AbstractContainer
|
||||||
*/
|
*/
|
||||||
public function __construct($paragraphStyle = null)
|
public function __construct($paragraphStyle = null)
|
||||||
{
|
{
|
||||||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle);
|
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,12 @@ class PhpWord
|
||||||
/**
|
/**
|
||||||
* Create new section
|
* Create new section
|
||||||
*
|
*
|
||||||
* @param array $settings
|
* @param array $style
|
||||||
* @return \PhpOffice\PhpWord\Element\Section
|
* @return \PhpOffice\PhpWord\Element\Section
|
||||||
*/
|
*/
|
||||||
public function addSection($settings = null)
|
public function addSection($style = null)
|
||||||
{
|
{
|
||||||
$section = new Section(count($this->sections) + 1, $settings);
|
$section = new Section(count($this->sections) + 1, $style);
|
||||||
$section->setPhpWord($this);
|
$section->setPhpWord($this);
|
||||||
$this->sections[] = $section;
|
$this->sections[] = $section;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,8 @@ class Document extends AbstractPart
|
||||||
*/
|
*/
|
||||||
private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section)
|
private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section)
|
||||||
{
|
{
|
||||||
$settings = $this->readSectionStyle($xmlReader, $node);
|
$style = $this->readSectionStyle($xmlReader, $node);
|
||||||
$section->setSettings($settings);
|
$section->setStyle($style);
|
||||||
$this->readHeaderFooter($settings, $section);
|
$this->readHeaderFooter($style, $section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ class Content extends AbstractPart
|
||||||
$paragraphStyleCount = 0;
|
$paragraphStyleCount = 0;
|
||||||
$fontStyleCount = 0;
|
$fontStyleCount = 0;
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$style = $section->getSettings();
|
$style = $section->getStyle();
|
||||||
$style->setStyleName("Section{$section->getSectionId()}");
|
$style->setStyleName("Section{$section->getSectionId()}");
|
||||||
$this->autoStyles['Section'][] = $style;
|
$this->autoStyles['Section'][] = $style;
|
||||||
$this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount);
|
$this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount);
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ class Document extends AbstractPart
|
||||||
|
|
||||||
$sections = $this->getParentWriter()->getPhpWord()->getSections();
|
$sections = $this->getParentWriter()->getPhpWord()->getSections();
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$styleWriter = new SectionStyleWriter($section->getSettings());
|
$styleWriter = new SectionStyleWriter($section->getStyle());
|
||||||
$styleWriter->setParentWriter($this->getParentWriter());
|
$styleWriter->setParentWriter($this->getParentWriter());
|
||||||
$content .= $styleWriter->write();
|
$content .= $styleWriter->write();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ class Header extends AbstractPart
|
||||||
$sections = $phpWord->getSections();
|
$sections = $phpWord->getSections();
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$elements = $section->getElements();
|
$elements = $section->getElements();
|
||||||
$this->registerBorderColor($section->getSettings());
|
$this->registerBorderColor($section->getStyle());
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if (method_exists($element, 'getFontStyle')) {
|
if (method_exists($element, 'getFontStyle')) {
|
||||||
$style = $element->getFontStyle();
|
$style = $element->getFontStyle();
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ class Document extends AbstractPart
|
||||||
}
|
}
|
||||||
|
|
||||||
// Section settings
|
// Section settings
|
||||||
$styleWriter = new SectionStyleWriter($xmlWriter, $section->getSettings());
|
$styleWriter = new SectionStyleWriter($xmlWriter, $section->getStyle());
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:sectPr
|
$xmlWriter->endElement(); // w:sectPr
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ use PhpOffice\PhpWord\Style;
|
||||||
class SectionTest extends \PHPUnit_Framework_TestCase
|
class SectionTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get settings
|
* Get style
|
||||||
*/
|
*/
|
||||||
public function testGetSettings()
|
public function testGetStyle()
|
||||||
{
|
{
|
||||||
$oSection = new Section(0);
|
$oSection = new Section(0);
|
||||||
$this->assertAttributeEquals($oSection->getSettings(), 'settings', new Section(0));
|
$this->assertAttributeEquals($oSection->getStyle(), 'style', new Section(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,12 +69,12 @@ class SectionTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* Set settings
|
* Set settings
|
||||||
*/
|
*/
|
||||||
public function testSetSettings()
|
public function testSetStyle()
|
||||||
{
|
{
|
||||||
$expected = 'landscape';
|
$expected = 'landscape';
|
||||||
$object = new Section(0);
|
$object = new Section(0);
|
||||||
$object->setSettings(array('orientation' => $expected, 'foo' => null));
|
$object->setStyle(array('orientation' => $expected, 'foo' => null));
|
||||||
$this->assertEquals($expected, $object->getSettings()->getOrientation());
|
$this->assertEquals($expected, $object->getStyle()->getOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
||||||
$section = $phpWord->addSection();
|
$section = $phpWord->addSection();
|
||||||
$section->addHeader();
|
$section->addHeader();
|
||||||
$section->addHeader('first');
|
$section->addHeader('first');
|
||||||
$settings = $section->getSettings();
|
$style = $section->getStyle();
|
||||||
$settings->setLandscape();
|
$style->setLandscape();
|
||||||
$settings->setPageNumberingStart(2);
|
$style->setPageNumberingStart(2);
|
||||||
$settings->setBorderSize(240);
|
$style->setBorderSize(240);
|
||||||
$settings->setBreakType('nextPage');
|
$style->setBreakType('nextPage');
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue