Refactor ODT writer to give enable some additional features
This commit is contained in:
parent
710e147668
commit
b91e3209fa
|
|
@ -16,8 +16,9 @@ tools:
|
||||||
external_code_coverage:
|
external_code_coverage:
|
||||||
enabled: true
|
enabled: true
|
||||||
timeout: 900
|
timeout: 900
|
||||||
php_sim:
|
php_cpd: true
|
||||||
min_mass: 40
|
# php_sim: # Temporarily disabled to allow focus on things other than duplicates
|
||||||
|
# min_mass: 40
|
||||||
php_pdepend: true
|
php_pdepend: true
|
||||||
php_analyzer: true
|
php_analyzer: true
|
||||||
sensiolabs_security_checker: true
|
sensiolabs_security_checker: true
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r
|
||||||
- RTF: Ability to add links and page breaks in RTF - @ivanlanin GH-196
|
- RTF: Ability to add links and page breaks in RTF - @ivanlanin GH-196
|
||||||
- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin
|
- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin
|
||||||
- Config: Ability to use a config file to store various common settings - @ivanlanin GH-200
|
- Config: Ability to use a config file to store various common settings - @ivanlanin GH-200
|
||||||
|
- ODT: Enable inline font style in TextRun - @ivanlanin
|
||||||
|
- ODT: Enable underline, strike/doublestrike, smallcaps/allcaps, superscript/subscript font style - @ivanlanin
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
<directory suffix=".php">./src</directory>
|
<directory suffix=".php">./src</directory>
|
||||||
<exclude>
|
<exclude>
|
||||||
<directory suffix=".php">./src/PhpWord/Shared/PCLZip</directory>
|
<directory suffix=".php">./src/PhpWord/Shared/PCLZip</directory>
|
||||||
<directory suffix=".php">./src/PhpWord/Shared/Spyc</directory>
|
|
||||||
</exclude>
|
</exclude>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -240,10 +240,11 @@ class PhpWord
|
||||||
* Set default paragraph style definition to styles.xml
|
* Set default paragraph style definition to styles.xml
|
||||||
*
|
*
|
||||||
* @param array $styles Paragraph style definition
|
* @param array $styles Paragraph style definition
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||||
*/
|
*/
|
||||||
public function setDefaultParagraphStyle($styles)
|
public function setDefaultParagraphStyle($styles)
|
||||||
{
|
{
|
||||||
Style::setDefaultParagraphStyle($styles);
|
return Style::setDefaultParagraphStyle($styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -251,10 +252,11 @@ class PhpWord
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $styles
|
* @param array $styles
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||||
*/
|
*/
|
||||||
public function addParagraphStyle($styleName, $styles)
|
public function addParagraphStyle($styleName, $styles)
|
||||||
{
|
{
|
||||||
Style::addParagraphStyle($styleName, $styles);
|
return Style::addParagraphStyle($styleName, $styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -263,10 +265,11 @@ class PhpWord
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
*/
|
*/
|
||||||
public function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
|
public function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
Style::addFontStyle($styleName, $fontStyle, $paragraphStyle);
|
return Style::addFontStyle($styleName, $fontStyle, $paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -275,10 +278,35 @@ class PhpWord
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param mixed $styleTable
|
* @param mixed $styleTable
|
||||||
* @param mixed $styleFirstRow
|
* @param mixed $styleFirstRow
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
*/
|
*/
|
||||||
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||||
{
|
{
|
||||||
Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
|
return Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a numbering style
|
||||||
|
*
|
||||||
|
* @param string $styleName
|
||||||
|
* @param mixed $styles
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Numbering
|
||||||
|
*/
|
||||||
|
public function addNumberingStyle($styleName, $styles)
|
||||||
|
{
|
||||||
|
return Style::addNumberingStyle($styleName, $styles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a hyperlink style to styles.xml
|
||||||
|
*
|
||||||
|
* @param string $styleName
|
||||||
|
* @param mixed $styles
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
|
*/
|
||||||
|
public function addLinkStyle($styleName, $styles)
|
||||||
|
{
|
||||||
|
return Style::addLinkStyle($styleName, $styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -287,32 +315,11 @@ class PhpWord
|
||||||
* @param int $depth
|
* @param int $depth
|
||||||
* @param mixed $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param mixed $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
*/
|
*/
|
||||||
public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
Style::addTitleStyle($depth, $fontStyle, $paragraphStyle);
|
return Style::addTitleStyle($depth, $fontStyle, $paragraphStyle);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a hyperlink style to styles.xml
|
|
||||||
*
|
|
||||||
* @param string $styleName
|
|
||||||
* @param mixed $styles
|
|
||||||
*/
|
|
||||||
public function addLinkStyle($styleName, $styles)
|
|
||||||
{
|
|
||||||
Style::addLinkStyle($styleName, $styles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a numbering style
|
|
||||||
*
|
|
||||||
* @param string $styleName
|
|
||||||
* @param mixed $styles
|
|
||||||
*/
|
|
||||||
public function addNumberingStyle($styleName, $styles)
|
|
||||||
{
|
|
||||||
Style::addNumberingStyle($styleName, $styles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -222,10 +222,11 @@ abstract class AbstractPart
|
||||||
$style = array();
|
$style = array();
|
||||||
$mapping = array(
|
$mapping = array(
|
||||||
'w:rStyle' => 'styleName',
|
'w:rStyle' => 'styleName',
|
||||||
'w:b' => 'bold', 'w:i' => 'italic', 'w:color' => 'color',
|
'w:b' => 'bold', 'w:i' => 'italic', 'w:color' => 'color', 'w:u' => 'underline',
|
||||||
'w:strike' => 'strikethrough', 'w:u' => 'underline',
|
'w:strike' => 'strikethrough', 'w:dstrike' => 'doubleStrikethrough',
|
||||||
'w:highlight' => 'fgColor', 'w:sz' => 'size',
|
'w:highlight' => 'fgColor', 'w:sz' => 'size',
|
||||||
'w:rFonts' => 'name', 'w:vertAlign' => 'superScript',
|
'w:rFonts' => 'name', 'w:vertAlign' => 'superScript',
|
||||||
|
'w:smallCaps' => 'smallCaps', 'w:caps' => 'allCaps',
|
||||||
);
|
);
|
||||||
|
|
||||||
$nodes = $xmlReader->getElements('w:rPr/*', $domNode);
|
$nodes = $xmlReader->getElements('w:rPr/*', $domNode);
|
||||||
|
|
@ -244,6 +245,9 @@ abstract class AbstractPart
|
||||||
case 'w:b':
|
case 'w:b':
|
||||||
case 'w:i':
|
case 'w:i':
|
||||||
case 'w:strike':
|
case 'w:strike':
|
||||||
|
case 'w:dstrike':
|
||||||
|
case 'w:smallCaps':
|
||||||
|
case 'w:caps':
|
||||||
$style[$property] = true;
|
$style[$property] = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord;
|
namespace PhpOffice\PhpWord;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Style\AbstractStyle;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Numbering;
|
use PhpOffice\PhpWord\Style\Numbering;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
@ -39,10 +40,11 @@ class Style
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $styles
|
* @param array $styles
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||||
*/
|
*/
|
||||||
public static function addParagraphStyle($styleName, $styles)
|
public static function addParagraphStyle($styleName, $styles)
|
||||||
{
|
{
|
||||||
self::setStyleValues($styleName, new Paragraph(), $styles);
|
return self::setStyleValues($styleName, new Paragraph(), $styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,10 +53,11 @@ class Style
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $fontStyle
|
* @param array $fontStyle
|
||||||
* @param array $paragraphStyle
|
* @param array $paragraphStyle
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
*/
|
*/
|
||||||
public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
|
public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
self::setStyleValues($styleName, new Font('text', $paragraphStyle), $fontStyle);
|
return self::setStyleValues($styleName, new Font('text', $paragraphStyle), $fontStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,22 +65,24 @@ class Style
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $styles
|
* @param array $styles
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
*/
|
*/
|
||||||
public static function addLinkStyle($styleName, $styles)
|
public static function addLinkStyle($styleName, $styles)
|
||||||
{
|
{
|
||||||
self::setStyleValues($styleName, new Font('link'), $styles);
|
return self::setStyleValues($styleName, new Font('link'), $styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add table style
|
* Add numbering style
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $styleTable
|
* @param array $styleValues
|
||||||
* @param array|null $styleFirstRow
|
* @return \PhpOffice\PhpWord\Style\Numbering
|
||||||
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
public static function addNumberingStyle($styleName, $styleValues)
|
||||||
{
|
{
|
||||||
self::setStyleValues($styleName, new Table($styleTable, $styleFirstRow), null);
|
return self::setStyleValues($styleName, new Numbering(), $styleValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -86,29 +91,30 @@ class Style
|
||||||
* @param int $depth
|
* @param int $depth
|
||||||
* @param array $fontStyle
|
* @param array $fontStyle
|
||||||
* @param array $paragraphStyle
|
* @param array $paragraphStyle
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Font
|
||||||
*/
|
*/
|
||||||
public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
self::setStyleValues("Heading_{$depth}", new Font('title', $paragraphStyle), $fontStyle);
|
return self::setStyleValues("Heading_{$depth}", new Font('title', $paragraphStyle), $fontStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add numbering style
|
* Add table style
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @param array $styleValues
|
* @param array $styleTable
|
||||||
* @return Numbering
|
* @param array|null $styleFirstRow
|
||||||
* @since 0.10.0
|
* @return \PhpOffice\PhpWord\Style\Table
|
||||||
*/
|
*/
|
||||||
public static function addNumberingStyle($styleName, $styleValues)
|
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||||
{
|
{
|
||||||
self::setStyleValues($styleName, new Numbering(), $styleValues);
|
return self::setStyleValues($styleName, new Table($styleTable, $styleFirstRow), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count styles
|
* Count styles
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
* @since 0.10.0
|
* @since 0.10.0
|
||||||
*/
|
*/
|
||||||
public static function countStyles()
|
public static function countStyles()
|
||||||
|
|
@ -129,16 +135,17 @@ class Style
|
||||||
* Set default paragraph style
|
* Set default paragraph style
|
||||||
*
|
*
|
||||||
* @param array $styles Paragraph style definition
|
* @param array $styles Paragraph style definition
|
||||||
|
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||||
*/
|
*/
|
||||||
public static function setDefaultParagraphStyle($styles)
|
public static function setDefaultParagraphStyle($styles)
|
||||||
{
|
{
|
||||||
self::addParagraphStyle('Normal', $styles);
|
return self::addParagraphStyle('Normal', $styles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all styles
|
* Get all styles
|
||||||
*
|
*
|
||||||
* @return array
|
* @return \PhpOffice\PhpWord\Style\AbstractStyle[]
|
||||||
*/
|
*/
|
||||||
public static function getStyles()
|
public static function getStyles()
|
||||||
{
|
{
|
||||||
|
|
@ -149,7 +156,7 @@ class Style
|
||||||
* Get style by name
|
* Get style by name
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* @param string $styleName
|
||||||
* @return Paragraph|Font|Table|Numbering|null
|
* @return \PhpOffice\PhpWord\Style\AbstractStyle Paragraph|Font|Table|Numbering
|
||||||
*/
|
*/
|
||||||
public static function getStyle($styleName)
|
public static function getStyle($styleName)
|
||||||
{
|
{
|
||||||
|
|
@ -163,21 +170,30 @@ class Style
|
||||||
/**
|
/**
|
||||||
* Set style values and put it to static style collection
|
* Set style values and put it to static style collection
|
||||||
*
|
*
|
||||||
* @param string $styleName
|
* The $styleValues could be an array or object
|
||||||
* @param Paragraph|Font|Table|Numbering $styleObject
|
*
|
||||||
* @param array|null $styleValues
|
* @param string $name
|
||||||
|
* @param \PhpOffice\PhpWord\Style\AbstractStyle $style
|
||||||
|
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $value
|
||||||
|
* @return \PhpOffice\PhpWord\Style\AbstractStyle
|
||||||
*/
|
*/
|
||||||
private static function setStyleValues($styleName, $styleObject, $styleValues = null)
|
private static function setStyleValues($name, $style, $value = null)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($styleName, self::$styles)) {
|
if (!array_key_exists($name, self::$styles)) {
|
||||||
if (!is_null($styleValues) && is_array($styleValues)) {
|
if ($value !== null) {
|
||||||
foreach ($styleValues as $key => $value) {
|
if (is_array($value)) {
|
||||||
$styleObject->setStyleValue($key, $value);
|
$style->setStyleByArray($value);
|
||||||
}
|
} elseif ($value instanceof AbstractStyle) {
|
||||||
}
|
if (get_class($style) == get_class($value)) {
|
||||||
$styleObject->setStyleName($styleName);
|
$style = $value;
|
||||||
$styleObject->setIndex(self::countStyles() + 1); // One based index
|
|
||||||
self::$styles[$styleName] = $styleObject;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$style->setStyleName($name);
|
||||||
|
$style->setIndex(self::countStyles() + 1); // One based index
|
||||||
|
self::$styles[$name] = $style;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::getStyle($name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,14 @@ abstract class AbstractStyle
|
||||||
*/
|
*/
|
||||||
protected $aliases = array();
|
protected $aliases = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this an automatic style? (Used primarily in OpenDocument driver)
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
private $isAuto = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get style name
|
* Get style name
|
||||||
*
|
*
|
||||||
|
|
@ -95,6 +103,29 @@ abstract class AbstractStyle
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get is automatic style flag
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isAuto()
|
||||||
|
{
|
||||||
|
return $this->isAuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set is automatic style flag
|
||||||
|
*
|
||||||
|
* @param bool $value
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setAuto($value = true)
|
||||||
|
{
|
||||||
|
$this->isAuto = $this->setBoolVal($value, $this->isAuto);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set style value template method
|
* Set style value template method
|
||||||
*
|
*
|
||||||
|
|
@ -123,12 +154,12 @@ abstract class AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set style by using associative array
|
* Set style by using associative array
|
||||||
*
|
*
|
||||||
* @param array $styles
|
* @param array $values
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setStyleByArray($styles = array())
|
public function setStyleByArray($values = array())
|
||||||
{
|
{
|
||||||
foreach ($styles as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
$this->setStyleValue($key, $value);
|
$this->setStyleValue($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ class Table extends AbstractElement
|
||||||
if ($rowCount > 0) {
|
if ($rowCount > 0) {
|
||||||
$content .= '<table>' . PHP_EOL;
|
$content .= '<table>' . PHP_EOL;
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
// $height = $row->getHeight();
|
/** @var $row \PhpOffice\PhpWord\Element\Row Type hint */
|
||||||
$rowStyle = $row->getStyle();
|
$rowStyle = $row->getStyle();
|
||||||
$tblHeader = $rowStyle->getTblHeader();
|
// $height = $row->getHeight();
|
||||||
|
$tblHeader = $rowStyle->isTblHeader();
|
||||||
$content .= '<tr>' . PHP_EOL;
|
$content .= '<tr>' . PHP_EOL;
|
||||||
foreach ($row->getCells() as $cell) {
|
foreach ($row->getCells() as $cell) {
|
||||||
$writer = new Container($this->parentWriter, $cell);
|
$writer = new Container($this->parentWriter, $cell);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class ODText extends AbstractWriter implements WriterInterface
|
||||||
foreach (array_keys($this->parts) as $partName) {
|
foreach (array_keys($this->parts) as $partName) {
|
||||||
$partClass = get_class($this) . '\\Part\\' . $partName;
|
$partClass = get_class($this) . '\\Part\\' . $partName;
|
||||||
if (class_exists($partClass)) {
|
if (class_exists($partClass)) {
|
||||||
|
/** @var $partObject \PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart Type hint */
|
||||||
$partObject = new $partClass();
|
$partObject = new $partClass();
|
||||||
$partObject->setParentWriter($this);
|
$partObject->setParentWriter($this);
|
||||||
$this->writerParts[strtolower($partName)] = $partObject;
|
$this->writerParts[strtolower($partName)] = $partObject;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class Table extends AbstractElement
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$xmlWriter->startElement('table:table-row');
|
$xmlWriter->startElement('table:table-row');
|
||||||
|
/** @var $row \PhpOffice\PhpWord\Element\Row Type hint */
|
||||||
foreach ($row->getCells() as $cell) {
|
foreach ($row->getCells() as $cell) {
|
||||||
$xmlWriter->startElement('table:table-cell');
|
$xmlWriter->startElement('table:table-cell');
|
||||||
$xmlWriter->writeAttribute('office:value-type', 'string');
|
$xmlWriter->writeAttribute('office:value-type', 'string');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2014 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title element writer
|
||||||
|
*
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
class Title extends AbstractElement
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write element
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
$element = $this->getElement();
|
||||||
|
if (!$element instanceof \PhpOffice\PhpWord\Element\Title) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xmlWriter->startElement('text:p');
|
||||||
|
$xmlWriter->writeRaw($element->getText());
|
||||||
|
$xmlWriter->endElement(); // text:p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,12 +19,13 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Element\Table;
|
use PhpOffice\PhpWord\Element\Table;
|
||||||
use PhpOffice\PhpWord\Element\Text;
|
use PhpOffice\PhpWord\Element\Text;
|
||||||
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
use PhpOffice\PhpWord\Style;
|
|
||||||
use PhpOffice\PhpWord\Writer\ODText\Element\Container;
|
use PhpOffice\PhpWord\Writer\ODText\Element\Container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,8 +40,10 @@ class Content extends AbstractPart
|
||||||
*/
|
*/
|
||||||
public function write()
|
public function write()
|
||||||
{
|
{
|
||||||
$phpWord = $this->getParentWriter()->getPhpWord();
|
|
||||||
$xmlWriter = $this->getXmlWriter();
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
$phpWord = $this->getParentWriter()->getPhpWord();
|
||||||
|
|
||||||
|
$this->getAutoStyles($phpWord);
|
||||||
|
|
||||||
$xmlWriter->startDocument('1.0', 'UTF-8');
|
$xmlWriter->startDocument('1.0', 'UTF-8');
|
||||||
$xmlWriter->startElement('office:document-content');
|
$xmlWriter->startElement('office:document-content');
|
||||||
|
|
@ -51,14 +54,20 @@ class Content extends AbstractPart
|
||||||
$xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
|
$xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
|
||||||
$xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
|
$xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
|
||||||
|
|
||||||
$this->getAutomaticStyles($phpWord);
|
|
||||||
$this->writeFontFaces($xmlWriter); // office:font-face-decls
|
$this->writeFontFaces($xmlWriter); // office:font-face-decls
|
||||||
$this->writeAutomaticStyles($xmlWriter, $phpWord); // office:automatic-styles
|
|
||||||
|
|
||||||
|
// Automatic styles
|
||||||
|
$xmlWriter->startElement('office:automatic-styles');
|
||||||
|
$this->writeTextAutoStyles($xmlWriter);
|
||||||
|
$this->writeImageAutoStyles($xmlWriter);
|
||||||
|
$this->writeTableAutoStyles($xmlWriter, $phpWord);
|
||||||
|
$xmlWriter->endElement(); // office:automatic-styles
|
||||||
|
|
||||||
|
// Body
|
||||||
$xmlWriter->startElement('office:body');
|
$xmlWriter->startElement('office:body');
|
||||||
$xmlWriter->startElement('office:text');
|
$xmlWriter->startElement('office:text');
|
||||||
|
|
||||||
// text:sequence-decls
|
// Sequence declarations
|
||||||
$sequences = array('Illustration', 'Table', 'Text', 'Drawing');
|
$sequences = array('Illustration', 'Table', 'Text', 'Drawing');
|
||||||
$xmlWriter->startElement('text:sequence-decls');
|
$xmlWriter->startElement('text:sequence-decls');
|
||||||
foreach ($sequences as $sequence) {
|
foreach ($sequences as $sequence) {
|
||||||
|
|
@ -69,18 +78,18 @@ class Content extends AbstractPart
|
||||||
}
|
}
|
||||||
$xmlWriter->endElement(); // text:sequence-decl
|
$xmlWriter->endElement(); // text:sequence-decl
|
||||||
|
|
||||||
|
// Sections
|
||||||
$sections = $phpWord->getSections();
|
$sections = $phpWord->getSections();
|
||||||
$sectionCount = count($sections);
|
|
||||||
if ($sectionCount > 0) {
|
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
// $xmlWriter->startElement('text:section');
|
// $xmlWriter->startElement('text:section');
|
||||||
$containerWriter = new Container($xmlWriter, $section);
|
$containerWriter = new Container($xmlWriter, $section);
|
||||||
$containerWriter->write();
|
$containerWriter->write();
|
||||||
// $xmlWriter->endElement(); // text:section
|
// $xmlWriter->endElement(); // text:section
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$xmlWriter->endElement(); // office:text
|
$xmlWriter->endElement(); // office:text
|
||||||
$xmlWriter->endElement(); // office:body
|
$xmlWriter->endElement(); // office:body
|
||||||
|
|
||||||
$xmlWriter->endElement(); // office:document-content
|
$xmlWriter->endElement(); // office:document-content
|
||||||
|
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
|
|
@ -89,22 +98,16 @@ class Content extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Write automatic styles
|
* Write automatic styles
|
||||||
*/
|
*/
|
||||||
private function writeAutomaticStyles(XMLWriter $xmlWriter, PhpWord $phpWord)
|
private function writeTextAutoStyles(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('office:automatic-styles');
|
|
||||||
|
|
||||||
// Font and paragraph
|
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
$paragraphStyleCount = 0;
|
$paragraphStyleCount = 0;
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $style) {
|
||||||
if (preg_match('#^T[0-9]+$#', $styleName) != 0
|
if ($style->isAuto() === true) {
|
||||||
|| preg_match('#^P[0-9]+$#', $styleName) != 0
|
|
||||||
) {
|
|
||||||
$styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style));
|
$styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style));
|
||||||
if (class_exists($styleClass)) {
|
if (class_exists($styleClass)) {
|
||||||
$styleWriter = new $styleClass($xmlWriter, $style);
|
$styleWriter = new $styleClass($xmlWriter, $style);
|
||||||
$styleWriter->setIsAuto(true);
|
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
}
|
}
|
||||||
if ($style instanceof Paragraph) {
|
if ($style instanceof Paragraph) {
|
||||||
|
|
@ -115,13 +118,18 @@ class Content extends AbstractPart
|
||||||
if ($paragraphStyleCount == 0) {
|
if ($paragraphStyleCount == 0) {
|
||||||
$style = new Paragraph();
|
$style = new Paragraph();
|
||||||
$style->setStyleName('P1');
|
$style->setStyleName('P1');
|
||||||
|
$style->setAuto();
|
||||||
$styleWriter = new \PhpOffice\PhpWord\Writer\ODText\Style\Paragraph($xmlWriter, $style);
|
$styleWriter = new \PhpOffice\PhpWord\Writer\ODText\Style\Paragraph($xmlWriter, $style);
|
||||||
$styleWriter->setIsAuto(true);
|
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Images
|
/**
|
||||||
|
* Write image automatic styles
|
||||||
|
*/
|
||||||
|
private function writeImageAutoStyles(XMLWriter $xmlWriter)
|
||||||
|
{
|
||||||
$images = Media::getElements('section');
|
$images = Media::getElements('section');
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
if ($image['type'] == 'image') {
|
if ($image['type'] == 'image') {
|
||||||
|
|
@ -132,18 +140,19 @@ class Content extends AbstractPart
|
||||||
$xmlWriter->startElement('style:graphic-properties');
|
$xmlWriter->startElement('style:graphic-properties');
|
||||||
$xmlWriter->writeAttribute('style:vertical-pos', 'top');
|
$xmlWriter->writeAttribute('style:vertical-pos', 'top');
|
||||||
$xmlWriter->writeAttribute('style:vertical-rel', 'baseline');
|
$xmlWriter->writeAttribute('style:vertical-rel', 'baseline');
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement(); // style:graphic-properties
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement(); // style:style
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tables
|
/**
|
||||||
|
* Write table automatic styles
|
||||||
|
*/
|
||||||
|
private function writeTableAutoStyles(XMLWriter $xmlWriter, PhpWord $phpWord)
|
||||||
|
{
|
||||||
$sections = $phpWord->getSections();
|
$sections = $phpWord->getSections();
|
||||||
$sectionCount = count($sections);
|
|
||||||
if ($sectionCount > 0) {
|
|
||||||
$sectionId = 0;
|
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$sectionId++;
|
|
||||||
$elements = $section->getElements();
|
$elements = $section->getElements();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($elements instanceof Table) {
|
if ($elements instanceof Table) {
|
||||||
|
|
@ -161,46 +170,64 @@ class Content extends AbstractPart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->endElement(); // office:automatic-styles
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set automatic styles
|
* Get automatic styles
|
||||||
*/
|
*/
|
||||||
private function getAutomaticStyles(PhpWord $phpWord)
|
private function getAutoStyles(PhpWord $phpWord)
|
||||||
{
|
{
|
||||||
$sections = $phpWord->getSections();
|
$sections = $phpWord->getSections();
|
||||||
$sectionCount = count($sections);
|
|
||||||
if ($sectionCount > 0) {
|
|
||||||
$paragraphStyleCount = 0;
|
$paragraphStyleCount = 0;
|
||||||
$fontStyleCount = 0;
|
$fontStyleCount = 0;
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$elements = $section->getElements();
|
$this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all styles of each elements in container recursively
|
||||||
|
*
|
||||||
|
* @param \PhpOffice\PhpWord\Element\AbstractContainer $container
|
||||||
|
* @param int $paragraphStyleCount
|
||||||
|
* @param int $fontStyleCount
|
||||||
|
*/
|
||||||
|
private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyleCount)
|
||||||
|
{
|
||||||
|
$elements = $container->getElements();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof TextRun) {
|
||||||
|
$this->getContainerStyle($element, $paragraphStyleCount, $fontStyleCount);
|
||||||
|
} elseif ($element instanceof Text) {
|
||||||
|
$this->getElementStyle($element, $paragraphStyleCount, $fontStyleCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get style of individual element
|
||||||
|
*
|
||||||
|
* @param \PhpOffice\PhpWord\Element\Text $element
|
||||||
|
* @param int $paragraphStyleCount
|
||||||
|
* @param int $fontStyleCount
|
||||||
|
*/
|
||||||
|
private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount)
|
||||||
|
{
|
||||||
$fontStyle = $element->getFontStyle();
|
$fontStyle = $element->getFontStyle();
|
||||||
$paragraphStyle = $element->getParagraphStyle();
|
$paragraphStyle = $element->getParagraphStyle();
|
||||||
|
$phpWord = $this->getParentWriter()->getPhpWord();
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
if ($fontStyle instanceof Font) {
|
if ($fontStyle instanceof Font) {
|
||||||
$fontStyleCount++;
|
$fontStyleCount++;
|
||||||
$arrStyle = array(
|
$style = $phpWord->addFontStyle("T{$fontStyleCount}", $fontStyle);
|
||||||
'color' => $fontStyle->getColor(),
|
$style->setAuto();
|
||||||
'name' => $fontStyle->getName()
|
$element->setFontStyle("T{$fontStyleCount}");
|
||||||
);
|
|
||||||
$phpWord->addFontStyle('T' . $fontStyleCount, $arrStyle);
|
|
||||||
$element->setFontStyle('T' . $fontStyleCount);
|
|
||||||
|
|
||||||
// Paragraph
|
// Paragraph
|
||||||
} elseif ($paragraphStyle instanceof Paragraph) {
|
} elseif ($paragraphStyle instanceof Paragraph) {
|
||||||
$paragraphStyleCount++;
|
$paragraphStyleCount++;
|
||||||
|
$style = $phpWord->addParagraphStyle("P{$paragraphStyleCount}", array());
|
||||||
$phpWord->addParagraphStyle('P' . $paragraphStyleCount, array());
|
$style->setAuto();
|
||||||
$element->setParagraphStyle('P' . $paragraphStyleCount);
|
$element->setParagraphStyle("P{$paragraphStyleCount}");
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Settings;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Style;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ODText styloes part writer: styles.xml
|
* ODText styloes part writer: styles.xml
|
||||||
|
|
@ -36,128 +35,39 @@ class Styles extends AbstractPart
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$xmlWriter->startDocument('1.0', 'UTF-8');
|
$xmlWriter->startDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
// Styles:Styles
|
|
||||||
$xmlWriter->startElement('office:document-styles');
|
$xmlWriter->startElement('office:document-styles');
|
||||||
$this->writeCommonRootAttributes($xmlWriter);
|
$this->writeCommonRootAttributes($xmlWriter);
|
||||||
|
|
||||||
// office:font-face-decls
|
// Font declarations
|
||||||
$this->writeFontFaces($xmlWriter);
|
$this->writeFontFaces($xmlWriter);
|
||||||
|
|
||||||
// office:styles
|
// Office styles
|
||||||
$xmlWriter->startElement('office:styles');
|
$xmlWriter->startElement('office:styles');
|
||||||
|
$this->writePart($xmlWriter, 'Default');
|
||||||
// style:default-style
|
$this->writePart($xmlWriter, 'Named');
|
||||||
$xmlWriter->startElement('style:default-style');
|
|
||||||
$xmlWriter->writeAttribute('style:family', 'paragraph');
|
|
||||||
|
|
||||||
// style:paragraph-properties
|
|
||||||
$xmlWriter->startElement('style:paragraph-properties');
|
|
||||||
$xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
|
|
||||||
$xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
|
|
||||||
$xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging');
|
|
||||||
$xmlWriter->writeAttribute('style:line-break', 'strict');
|
|
||||||
$xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
|
|
||||||
$xmlWriter->writeAttribute('style:writing-mode', 'page');
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
// style:text-properties
|
// Automatic styles
|
||||||
$xmlWriter->startElement('style:text-properties');
|
$xmlWriter->startElement('office:automatic-styles');
|
||||||
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
|
$this->writePart($xmlWriter, 'PageLayout');
|
||||||
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
|
$this->writePart($xmlWriter, 'Master');
|
||||||
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
|
|
||||||
$xmlWriter->writeAttribute('fo:language', 'fr');
|
|
||||||
$xmlWriter->writeAttribute('fo:country', 'FR');
|
|
||||||
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
|
|
||||||
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
|
|
||||||
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
|
|
||||||
$xmlWriter->writeAttribute('style:language-asian', 'zh');
|
|
||||||
$xmlWriter->writeAttribute('style:country-asian', 'CN');
|
|
||||||
$xmlWriter->writeAttribute('style:font-name-complex', Settings::getDefaultFontName() . '2');
|
|
||||||
$xmlWriter->writeAttribute('style:font-size-complex', Settings::getDefaultFontSize() . 'pt');
|
|
||||||
$xmlWriter->writeAttribute('style:language-complex', 'hi');
|
|
||||||
$xmlWriter->writeAttribute('style:country-complex', 'IN');
|
|
||||||
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
|
|
||||||
$xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
|
||||||
$xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement(); // office:document-styles
|
||||||
|
|
||||||
// Write Style Definitions
|
return $xmlWriter->getData();
|
||||||
$styles = Style::getStyles();
|
}
|
||||||
if (count($styles) > 0) {
|
|
||||||
foreach ($styles as $styleName => $style) {
|
/**
|
||||||
if (preg_match('#^T[0-9]+$#', $styleName) == 0
|
* Write style part
|
||||||
&& preg_match('#^P[0-9]+$#', $styleName) == 0
|
*
|
||||||
) {
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
$styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style));
|
* @param string $subStyle
|
||||||
if (class_exists($styleClass)) {
|
*/
|
||||||
$styleWriter = new $styleClass($xmlWriter, $style);
|
private function writePart(XMLWriter $xmlWriter, $subStyle)
|
||||||
|
{
|
||||||
|
$writerClass = "PhpOffice\\PhpWord\\Writer\\ODText\\Style\\{$subStyle}Style";
|
||||||
|
$styleWriter = new $writerClass($xmlWriter);
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
// office:automatic-styles
|
|
||||||
$xmlWriter->startElement('office:automatic-styles');
|
|
||||||
// style:page-layout
|
|
||||||
$xmlWriter->startElement('style:page-layout');
|
|
||||||
$xmlWriter->writeAttribute('style:name', 'Mpm1');
|
|
||||||
// style:page-layout-properties
|
|
||||||
$xmlWriter->startElement('style:page-layout-properties');
|
|
||||||
$xmlWriter->writeAttribute('fo:page-width', "21.001cm");
|
|
||||||
$xmlWriter->writeAttribute('fo:page-height', '29.7cm');
|
|
||||||
$xmlWriter->writeAttribute('style:num-format', '1');
|
|
||||||
$xmlWriter->writeAttribute('style:print-orientation', 'portrait');
|
|
||||||
$xmlWriter->writeAttribute('fo:margin-top', '2.501cm');
|
|
||||||
$xmlWriter->writeAttribute('fo:margin-bottom', '2cm');
|
|
||||||
$xmlWriter->writeAttribute('fo:margin-left', '2.501cm');
|
|
||||||
$xmlWriter->writeAttribute('fo:margin-right', '2.501cm');
|
|
||||||
$xmlWriter->writeAttribute('style:writing-mode', 'lr-tb');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-lines', '25199');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-mode', 'none');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-print', 'false');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-display', 'false');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm');
|
|
||||||
$xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true');
|
|
||||||
$xmlWriter->writeAttribute('style:footnote-max-height', '0cm');
|
|
||||||
//style:footnote-sep
|
|
||||||
$xmlWriter->startElement('style:footnote-sep');
|
|
||||||
$xmlWriter->writeAttribute('style:width', '0.018cm');
|
|
||||||
$xmlWriter->writeAttribute('style:line-style', 'solid');
|
|
||||||
$xmlWriter->writeAttribute('style:adjustment', 'left');
|
|
||||||
$xmlWriter->writeAttribute('style:rel-width', '25%');
|
|
||||||
$xmlWriter->writeAttribute('style:color', '#000000');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
// style:header-style
|
|
||||||
$xmlWriter->startElement('style:header-style');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
// style:footer-style
|
|
||||||
$xmlWriter->startElement('style:footer-style');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
// office:master-styles
|
|
||||||
$xmlWriter->startElement('office:master-styles');
|
|
||||||
// style:master-page
|
|
||||||
$xmlWriter->startElement('style:master-page');
|
|
||||||
$xmlWriter->writeAttribute('style:name', 'Standard');
|
|
||||||
$xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
// Return
|
|
||||||
return $xmlWriter->getData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2014 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default-style writer; cannot use `default` only because it's a reserved word
|
||||||
|
*
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
class DefaultStyle extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:default-style');
|
||||||
|
$xmlWriter->writeAttribute('style:family', 'paragraph');
|
||||||
|
|
||||||
|
// Paragraph
|
||||||
|
$xmlWriter->startElement('style:paragraph-properties');
|
||||||
|
$xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
|
||||||
|
$xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
|
||||||
|
$xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging');
|
||||||
|
$xmlWriter->writeAttribute('style:line-break', 'strict');
|
||||||
|
$xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
|
||||||
|
$xmlWriter->writeAttribute('style:writing-mode', 'page');
|
||||||
|
$xmlWriter->endElement(); // style:paragraph-properties
|
||||||
|
|
||||||
|
// Font
|
||||||
|
$xmlWriter->startElement('style:text-properties');
|
||||||
|
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
|
||||||
|
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
|
||||||
|
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
|
||||||
|
$xmlWriter->writeAttribute('fo:language', 'fr');
|
||||||
|
$xmlWriter->writeAttribute('fo:country', 'FR');
|
||||||
|
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
|
||||||
|
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
|
||||||
|
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
|
||||||
|
$xmlWriter->writeAttribute('style:language-asian', 'zh');
|
||||||
|
$xmlWriter->writeAttribute('style:country-asian', 'CN');
|
||||||
|
$xmlWriter->writeAttribute('style:font-name-complex', Settings::getDefaultFontName() . '2');
|
||||||
|
$xmlWriter->writeAttribute('style:font-size-complex', Settings::getDefaultFontSize() . 'pt');
|
||||||
|
$xmlWriter->writeAttribute('style:language-complex', 'hi');
|
||||||
|
$xmlWriter->writeAttribute('style:country-complex', 'IN');
|
||||||
|
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
|
||||||
|
$xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
||||||
|
$xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
||||||
|
$xmlWriter->endElement(); // style:text-properties
|
||||||
|
|
||||||
|
$xmlWriter->endElement(); // style:default-style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,11 +24,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
*/
|
*/
|
||||||
class Font extends AbstractStyle
|
class Font extends AbstractStyle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Is automatic style
|
|
||||||
*/
|
|
||||||
private $isAuto = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write style
|
* Write style
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,17 +62,28 @@ class Font extends AbstractStyle
|
||||||
$xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-asian', 'italic');
|
$xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-asian', 'italic');
|
||||||
$xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-complex', 'italic');
|
$xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-complex', 'italic');
|
||||||
|
|
||||||
|
// Underline
|
||||||
|
// @todo Various mode of underline
|
||||||
|
$underline = $style->getUnderline();
|
||||||
|
$xmlWriter->writeAttributeIf($underline != 'none', 'style:text-underline-style', 'solid');
|
||||||
|
|
||||||
|
// Strikethrough, double strikethrough
|
||||||
|
$xmlWriter->writeAttributeIf($style->isStrikethrough(), 'style:text-line-through-type', 'single');
|
||||||
|
$xmlWriter->writeAttributeIf($style->isDoubleStrikethrough(), 'style:text-line-through-type', 'double');
|
||||||
|
|
||||||
|
// Small caps, all caps
|
||||||
|
$xmlWriter->writeAttributeIf($style->isSmallCaps(), 'fo:font-variant', 'small-caps');
|
||||||
|
$xmlWriter->writeAttributeIf($style->isAllCaps(), 'fo:text-transform', 'uppercase');
|
||||||
|
|
||||||
|
// Superscript/subscript
|
||||||
|
$xmlWriter->writeAttributeIf($style->isSuperScript(), 'style:text-position', 'super');
|
||||||
|
$xmlWriter->writeAttributeIf($style->isSubScript(), 'style:text-position', 'sub');
|
||||||
|
|
||||||
|
// @todo Foreground-Color
|
||||||
|
|
||||||
|
// @todo Background color
|
||||||
|
|
||||||
$xmlWriter->endElement(); // style:text-properties
|
$xmlWriter->endElement(); // style:text-properties
|
||||||
$xmlWriter->endElement(); // style:style
|
$xmlWriter->endElement(); // style:style
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set is automatic style
|
|
||||||
*
|
|
||||||
* @param bool $value
|
|
||||||
*/
|
|
||||||
public function setIsAuto($value)
|
|
||||||
{
|
|
||||||
$this->isAuto = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2014 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Master style writer
|
||||||
|
*
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
class MasterStyle extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
|
$xmlWriter->startElement('office:master-styles');
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:master-page');
|
||||||
|
$xmlWriter->writeAttribute('style:name', 'Standard');
|
||||||
|
$xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1');
|
||||||
|
$xmlWriter->endElement(); // style:master-page
|
||||||
|
|
||||||
|
$xmlWriter->endElement(); // office:master-styles
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2014 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named style writer
|
||||||
|
*
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
class NamedStyle extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
|
$styles = Style::getStyles();
|
||||||
|
if (count($styles) > 0) {
|
||||||
|
foreach ($styles as $style) {
|
||||||
|
if ($style->isAuto() === false) {
|
||||||
|
$styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style));
|
||||||
|
if (class_exists($styleClass)) {
|
||||||
|
/** @var $styleWriter \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle Type hint */
|
||||||
|
$styleWriter = new $styleClass($xmlWriter, $style);
|
||||||
|
$styleWriter->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
|
* word processing documents.
|
||||||
|
*
|
||||||
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please read the LICENSE
|
||||||
|
* file that was distributed with this source code. For the full list of
|
||||||
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
|
*
|
||||||
|
* @link https://github.com/PHPOffice/PHPWord
|
||||||
|
* @copyright 2010-2014 PHPWord contributors
|
||||||
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page layout style writer
|
||||||
|
*
|
||||||
|
* @since 0.11.0
|
||||||
|
*/
|
||||||
|
class PageLayoutStyle extends AbstractStyle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Write style
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:page-layout');
|
||||||
|
$xmlWriter->writeAttribute('style:name', 'Mpm1');
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:page-layout-properties');
|
||||||
|
$xmlWriter->writeAttribute('fo:page-width', "21.001cm");
|
||||||
|
$xmlWriter->writeAttribute('fo:page-height', '29.7cm');
|
||||||
|
$xmlWriter->writeAttribute('style:num-format', '1');
|
||||||
|
$xmlWriter->writeAttribute('style:print-orientation', 'portrait');
|
||||||
|
$xmlWriter->writeAttribute('fo:margin-top', '2.501cm');
|
||||||
|
$xmlWriter->writeAttribute('fo:margin-bottom', '2cm');
|
||||||
|
$xmlWriter->writeAttribute('fo:margin-left', '2.501cm');
|
||||||
|
$xmlWriter->writeAttribute('fo:margin-right', '2.501cm');
|
||||||
|
$xmlWriter->writeAttribute('style:writing-mode', 'lr-tb');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-lines', '25199');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-mode', 'none');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-print', 'false');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-display', 'false');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm');
|
||||||
|
$xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true');
|
||||||
|
$xmlWriter->writeAttribute('style:footnote-max-height', '0cm');
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:footnote-sep');
|
||||||
|
$xmlWriter->writeAttribute('style:width', '0.018cm');
|
||||||
|
$xmlWriter->writeAttribute('style:line-style', 'solid');
|
||||||
|
$xmlWriter->writeAttribute('style:adjustment', 'left');
|
||||||
|
$xmlWriter->writeAttribute('style:rel-width', '25%');
|
||||||
|
$xmlWriter->writeAttribute('style:color', '#000000');
|
||||||
|
$xmlWriter->endElement(); //style:footnote-sep
|
||||||
|
|
||||||
|
$xmlWriter->endElement(); // style:page-layout-properties
|
||||||
|
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:header-style');
|
||||||
|
$xmlWriter->endElement(); // style:header-style
|
||||||
|
|
||||||
|
$xmlWriter->startElement('style:footer-style');
|
||||||
|
$xmlWriter->endElement(); // style:footer-style
|
||||||
|
|
||||||
|
$xmlWriter->endElement(); // style:page-layout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,11 +24,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
||||||
*/
|
*/
|
||||||
class Paragraph extends AbstractStyle
|
class Paragraph extends AbstractStyle
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Is automatic style
|
|
||||||
*/
|
|
||||||
private $isAuto = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write style
|
* Write style
|
||||||
*/
|
*/
|
||||||
|
|
@ -46,13 +41,13 @@ class Paragraph extends AbstractStyle
|
||||||
$xmlWriter->startElement('style:style');
|
$xmlWriter->startElement('style:style');
|
||||||
$xmlWriter->writeAttribute('style:name', $style->getStyleName());
|
$xmlWriter->writeAttribute('style:name', $style->getStyleName());
|
||||||
$xmlWriter->writeAttribute('style:family', 'paragraph');
|
$xmlWriter->writeAttribute('style:family', 'paragraph');
|
||||||
if ($this->isAuto) {
|
if ($style->isAuto()) {
|
||||||
$xmlWriter->writeAttribute('style:parent-style-name', 'Standard');
|
$xmlWriter->writeAttribute('style:parent-style-name', 'Standard');
|
||||||
$xmlWriter->writeAttribute('style:master-page-name', 'Standard');
|
$xmlWriter->writeAttribute('style:master-page-name', 'Standard');
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->startElement('style:paragraph-properties');
|
$xmlWriter->startElement('style:paragraph-properties');
|
||||||
if ($this->isAuto) {
|
if ($style->isAuto()) {
|
||||||
$xmlWriter->writeAttribute('style:page-number', 'auto');
|
$xmlWriter->writeAttribute('style:page-number', 'auto');
|
||||||
} else {
|
} else {
|
||||||
$xmlWriter->writeAttribute('fo:margin-top', $marginTop . 'cm');
|
$xmlWriter->writeAttribute('fo:margin-top', $marginTop . 'cm');
|
||||||
|
|
@ -63,14 +58,4 @@ class Paragraph extends AbstractStyle
|
||||||
|
|
||||||
$xmlWriter->endElement(); //style:style
|
$xmlWriter->endElement(); //style:style
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set is automatic style
|
|
||||||
*
|
|
||||||
* @param bool $value
|
|
||||||
*/
|
|
||||||
public function setIsAuto($value)
|
|
||||||
{
|
|
||||||
$this->isAuto = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||||
use PhpOffice\PhpWord\Writer\WriterInterface;
|
use PhpOffice\PhpWord\Writer\AbstractWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Word2007 writer part abstract class
|
* Word2007 writer part abstract class
|
||||||
|
|
@ -29,16 +29,16 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Parent writer
|
* Parent writer
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Writer\WriterInterface
|
* @var \PhpOffice\PhpWord\Writer\AbstractWriter
|
||||||
*/
|
*/
|
||||||
protected $parentWriter;
|
protected $parentWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parent writer
|
* Set parent writer
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Writer\WriterInterface $writer
|
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
||||||
*/
|
*/
|
||||||
public function setParentWriter(WriterInterface $writer = null)
|
public function setParentWriter(AbstractWriter $writer = null)
|
||||||
{
|
{
|
||||||
$this->parentWriter = $writer;
|
$this->parentWriter = $writer;
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ abstract class AbstractPart
|
||||||
/**
|
/**
|
||||||
* Get parent writer
|
* Get parent writer
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface
|
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
|
||||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||||
*/
|
*/
|
||||||
public function getParentWriter()
|
public function getParentWriter()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class ElementTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testUnmatchedElements()
|
public function testUnmatchedElements()
|
||||||
{
|
{
|
||||||
$elements = array('Image', 'Link', 'Table', 'Text');
|
$elements = array('Image', 'Link', 'Table', 'Text', 'Title');
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $element;
|
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $element;
|
||||||
$xmlWriter = new XMLWriter();
|
$xmlWriter = new XMLWriter();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue