Part II.
This commit is contained in:
Roman Syroeshko 2014-03-18 15:04:14 +04:00
parent 510f9cdf79
commit b32c198824
21 changed files with 602 additions and 635 deletions

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* PHPWord_Style_Cell
*/
class PHPWord_Style_Cell
{
class Cell
{
const TEXT_DIR_BTLR = 'btLr'; const TEXT_DIR_BTLR = 'btLr';
const TEXT_DIR_TBRL = 'tbRl'; const TEXT_DIR_TBRL = 'tbRl';

View File

@ -1,5 +1,4 @@
<?php <?php
/** /**
* PHPWord * PHPWord
* *
@ -25,12 +24,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException; use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/** class Font
* Class PHPWord_Style_Font
*/
class PHPWord_Style_Font
{ {
const UNDERLINE_NONE = 'none'; const UNDERLINE_NONE = 'none';
const UNDERLINE_DASH = 'dash'; const UNDERLINE_DASH = 'dash';
@ -76,7 +75,7 @@ class PHPWord_Style_Font
/** /**
* Paragraph Style * Paragraph Style
* *
* @var PHPWord_Style_Paragraph * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_paragraphStyle; private $_paragraphStyle;
@ -127,7 +126,7 @@ class PHPWord_Style_Font
* *
* @var string * @var string
*/ */
private $_underline = PHPWord_Style_Font::UNDERLINE_NONE; private $_underline = self::UNDERLINE_NONE;
/** /**
* Strikethrough * Strikethrough
@ -174,10 +173,10 @@ class PHPWord_Style_Font
{ {
$this->_type = $type; $this->_type = $type;
if ($paragraphStyle instanceof PHPWord_Style_Paragraph) { if ($paragraphStyle instanceof Paragraph) {
$this->_paragraphStyle = $paragraphStyle; $this->_paragraphStyle = $paragraphStyle;
} elseif (is_array($paragraphStyle)) { } elseif (is_array($paragraphStyle)) {
$this->_paragraphStyle = new PHPWord_Style_Paragraph; $this->_paragraphStyle = new Paragraph;
$this->_paragraphStyle->setArrayStyle($paragraphStyle); $this->_paragraphStyle->setArrayStyle($paragraphStyle);
} else { } else {
$this->_paragraphStyle = $paragraphStyle; $this->_paragraphStyle = $paragraphStyle;
@ -230,8 +229,8 @@ class PHPWord_Style_Font
/** /**
* Set font name * Set font name
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
{ {
@ -256,8 +255,8 @@ class PHPWord_Style_Font
/** /**
* Set font size * Set font size
* *
* @param int|float $pValue * @param int|float $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
{ {
@ -281,8 +280,8 @@ class PHPWord_Style_Font
/** /**
* Set bold * Set bold
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setBold($pValue = false) public function setBold($pValue = false)
{ {
@ -306,8 +305,8 @@ class PHPWord_Style_Font
/** /**
* Set italics * Set italics
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setItalic($pValue = false) public function setItalic($pValue = false)
{ {
@ -331,8 +330,8 @@ class PHPWord_Style_Font
/** /**
* Set superscript * Set superscript
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setSuperScript($pValue = false) public function setSuperScript($pValue = false)
{ {
@ -357,8 +356,8 @@ class PHPWord_Style_Font
/** /**
* Set subscript * Set subscript
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setSubScript($pValue = false) public function setSubScript($pValue = false)
{ {
@ -383,13 +382,13 @@ class PHPWord_Style_Font
/** /**
* Set underline * Set underline
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) public function setUnderline($pValue = self::UNDERLINE_NONE)
{ {
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPWord_Style_Font::UNDERLINE_NONE; $pValue = self::UNDERLINE_NONE;
} }
$this->_underline = $pValue; $this->_underline = $pValue;
return $this; return $this;
@ -408,8 +407,8 @@ class PHPWord_Style_Font
/** /**
* Set strikethrough * Set strikethrough
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setStrikethrough($pValue = false) public function setStrikethrough($pValue = false)
{ {
@ -433,8 +432,8 @@ class PHPWord_Style_Font
/** /**
* Set font color * Set font color
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
{ {
@ -458,8 +457,8 @@ class PHPWord_Style_Font
/** /**
* Set foreground/highlight color * Set foreground/highlight color
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setFgColor($pValue = null) public function setFgColor($pValue = null)
{ {
@ -480,7 +479,7 @@ class PHPWord_Style_Font
/** /**
* Get paragraph style * Get paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
@ -530,8 +529,8 @@ class PHPWord_Style_Font
/** /**
* Set Font Content Type * Set Font Content Type
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE) public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE)
{ {

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* Class PHPWord_Style_Image
*/ class Image
class PHPWord_Style_Image
{ {
const WRAPPING_STYLE_INLINE = 'inline'; const WRAPPING_STYLE_INLINE = 'inline';
const WRAPPING_STYLE_SQUARE = 'square'; const WRAPPING_STYLE_SQUARE = 'square';

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* Class PHPWord_Style_ListItem
*/
class PHPWord_Style_ListItem
{
class ListItem
{
const TYPE_NUMBER = 7; const TYPE_NUMBER = 7;
const TYPE_NUMBER_NESTED = 8; const TYPE_NUMBER_NESTED = 8;
const TYPE_ALPHANUM = 9; const TYPE_ALPHANUM = 9;
@ -48,7 +46,7 @@ class PHPWord_Style_ListItem
*/ */
public function __construct() public function __construct()
{ {
$this->_listType = PHPWord_Style_ListItem::TYPE_BULLET_FILLED; $this->_listType = self::TYPE_BULLET_FILLED;
} }
/** /**
@ -67,7 +65,7 @@ class PHPWord_Style_ListItem
* *
* @param int $pValue * @param int $pValue
*/ */
public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) public function setListType($pValue = self::TYPE_BULLET_FILLED)
{ {
$this->_listType = $pValue; $this->_listType = $pValue;
} }

View File

@ -25,12 +25,11 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException; use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/** class Paragraph
* PHPWord_Style_Paragraph
*/
class PHPWord_Style_Paragraph
{ {
const LINE_HEIGHT = 240; const LINE_HEIGHT = 240;
@ -187,7 +186,7 @@ class PHPWord_Style_Paragraph
* Set Paragraph Alignment * Set Paragraph Alignment
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setAlign($pValue = null) public function setAlign($pValue = null)
{ {
@ -213,7 +212,7 @@ class PHPWord_Style_Paragraph
* Set Space before Paragraph * Set Space before Paragraph
* *
* @param int $pValue * @param int $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setSpaceBefore($pValue = null) public function setSpaceBefore($pValue = null)
{ {
@ -235,7 +234,7 @@ class PHPWord_Style_Paragraph
* Set Space after Paragraph * Set Space after Paragraph
* *
* @param int $pValue * @param int $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setSpaceAfter($pValue = null) public function setSpaceAfter($pValue = null)
{ {
@ -257,7 +256,7 @@ class PHPWord_Style_Paragraph
* Set Spacing between breaks * Set Spacing between breaks
* *
* @param int $pValue * @param int $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setSpacing($pValue = null) public function setSpacing($pValue = null)
{ {
@ -279,7 +278,7 @@ class PHPWord_Style_Paragraph
* Set indentation * Set indentation
* *
* @param int $pValue * @param int $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setIndent($pValue = null) public function setIndent($pValue = null)
{ {
@ -301,7 +300,7 @@ class PHPWord_Style_Paragraph
* Set hanging * Set hanging
* *
* @param int $pValue * @param int $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setHanging($pValue = null) public function setHanging($pValue = null)
{ {
@ -312,7 +311,7 @@ class PHPWord_Style_Paragraph
/** /**
* Get tabs * Get tabs
* *
* @return PHPWord_Style_Tabs * @return PhpOffice\PhpWord\Style\Tabs
*/ */
public function getTabs() public function getTabs()
{ {
@ -323,12 +322,12 @@ class PHPWord_Style_Paragraph
* Set tabs * Set tabs
* *
* @param array $pValue * @param array $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setTabs($pValue = null) public function setTabs($pValue = null)
{ {
if (is_array($pValue)) { if (is_array($pValue)) {
$this->_tabs = new PHPWord_Style_Tabs($pValue); $this->_tabs = new Tabs($pValue);
} }
return $this; return $this;
} }
@ -347,7 +346,7 @@ class PHPWord_Style_Paragraph
* Set parent style ID * Set parent style ID
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setBasedOn($pValue = 'Normal') public function setBasedOn($pValue = 'Normal')
{ {
@ -369,7 +368,7 @@ class PHPWord_Style_Paragraph
* Set style for next paragraph * Set style for next paragraph
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setNext($pValue = null) public function setNext($pValue = null)
{ {
@ -391,7 +390,7 @@ class PHPWord_Style_Paragraph
* Set keep paragraph with next paragraph setting * Set keep paragraph with next paragraph setting
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setWidowControl($pValue = true) public function setWidowControl($pValue = true)
{ {
@ -416,7 +415,7 @@ class PHPWord_Style_Paragraph
* Set keep paragraph with next paragraph setting * Set keep paragraph with next paragraph setting
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setKeepNext($pValue = false) public function setKeepNext($pValue = false)
{ {
@ -441,7 +440,7 @@ class PHPWord_Style_Paragraph
* Set keep all lines on one page setting * Set keep all lines on one page setting
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setKeepLines($pValue = false) public function setKeepLines($pValue = false)
{ {
@ -466,7 +465,7 @@ class PHPWord_Style_Paragraph
* Set start paragraph on next page setting * Set start paragraph on next page setting
* *
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setPageBreakBefore($pValue = false) public function setPageBreakBefore($pValue = false)
{ {

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* PHPWord_Style_Row
*/
class PHPWord_Style_Row
{
class Row
{
/** /**
* Repeat table row on every new page * Repeat table row on every new page
* *

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* Class PHPWord_Style_TOC
*/
class PHPWord_Style_TOC
{
class TOC
{
const TABLEADER_DOT = 'dot'; const TABLEADER_DOT = 'dot';
const TABLEADER_UNDERSCORE = 'underscore'; const TABLEADER_UNDERSCORE = 'underscore';
const TABLEADER_LINE = 'hyphen'; const TABLEADER_LINE = 'hyphen';
@ -64,7 +62,7 @@ class PHPWord_Style_TOC
public function __construct() public function __construct()
{ {
$this->_tabPos = 9062; $this->_tabPos = 9062;
$this->_tabLeader = PHPWord_Style_TOC::TABLEADER_DOT; $this->_tabLeader = self::TABLEADER_DOT;
$this->_indent = 200; $this->_indent = 200;
} }
@ -103,7 +101,7 @@ class PHPWord_Style_TOC
* *
* @param string $pValue * @param string $pValue
*/ */
public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT) public function setTabLeader($pValue = self::TABLEADER_DOT)
{ {
$this->_tabLeader = $pValue; $this->_tabLeader = $pValue;
} }

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* PHPWord_Style_Tabs
*/
class PHPWord_Style_Tab
{
use PhpOffice\PhpWord\Shared\XMLWriter;
class Tab
{
/** /**
* Tab Stop Type * Tab Stop Type
* *
@ -84,7 +84,7 @@ class PHPWord_Style_Tab
); );
/** /**
* Create a new instance of PHPWord_Style_Tab. Both $val and $leader * Create a new instance of Tab. Both $val and $leader
* must conform to the values put forth in the schema. If they do not * must conform to the values put forth in the schema. If they do not
* they will be changed to default values. * they will be changed to default values.
* *
@ -105,20 +105,20 @@ class PHPWord_Style_Tab
} }
/** /**
* Creates the XML DOM for the instance of PHPWord_Style_Tab. * Creates the XML DOM for the instance of Tab.
* *
* @param PHPWord_Shared_XMLWriter $objWriter * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
*/ */
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null) public function toXml(XMLWriter &$xmlWriter = null)
{ {
if (isset($objWriter)) { if (isset($xmlWriter)) {
$objWriter->startElement("w:tab"); $xmlWriter->startElement("w:tab");
$objWriter->writeAttribute("w:val", $this->_val); $xmlWriter->writeAttribute("w:val", $this->_val);
if (!is_null($this->_leader)) { if (!is_null($this->_leader)) {
$objWriter->writeAttribute("w:leader", $this->_leader); $xmlWriter->writeAttribute("w:leader", $this->_leader);
} }
$objWriter->writeAttribute("w:pos", $this->_position); $xmlWriter->writeAttribute("w:pos", $this->_position);
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* Class PHPWord_Style_Table
*/
class PHPWord_Style_Table
{
class Table
{
private $_cellMarginTop; private $_cellMarginTop;
private $_cellMarginLeft; private $_cellMarginLeft;
private $_cellMarginRight; private $_cellMarginRight;

View File

@ -25,145 +25,104 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* Class PHPWord_Style_TableFull
*/
class PHPWord_Style_TableFull
{
class TableFull
{
/** /**
* Style for first row * Style for first row
* *
* @var PHPWord_Style_Table * @var PhpOffice\PhpWord\Style\TableFull
*/ */
private $_firstRow = null; private $_firstRow = null;
/** /**
* Cell Margin Top
*
* @var int * @var int
*/ */
private $_cellMarginTop = null; private $_cellMarginTop = null;
/** /**
* Cell Margin Left
*
* @var int * @var int
*/ */
private $_cellMarginLeft = null; private $_cellMarginLeft = null;
/** /**
* Cell Margin Right
*
* @var int * @var int
*/ */
private $_cellMarginRight = null; private $_cellMarginRight = null;
/** /**
* Cell Margin Bottom
*
* @var int * @var int
*/ */
private $_cellMarginBottom = null; private $_cellMarginBottom = null;
/** /**
* Background-Color
*
* @var string * @var string
*/ */
private $_bgColor; private $_bgColor;
/** /**
* Border Top Size
*
* @var int * @var int
*/ */
private $_borderTopSize; private $_borderTopSize;
/** /**
* Border Top Color
*
* @var string * @var string
*/ */
private $_borderTopColor; private $_borderTopColor;
/** /**
* Border Left Size
*
* @var int * @var int
*/ */
private $_borderLeftSize; private $_borderLeftSize;
/** /**
* Border Left Color
*
* @var string * @var string
*/ */
private $_borderLeftColor; private $_borderLeftColor;
/** /**
* Border Right Size
*
* @var int * @var int
*/ */
private $_borderRightSize; private $_borderRightSize;
/** /**
* Border Right Color
*
* @var string * @var string
*/ */
private $_borderRightColor; private $_borderRightColor;
/** /**
* Border Bottom Size
*
* @var int * @var int
*/ */
private $_borderBottomSize; private $_borderBottomSize;
/** /**
* Border Bottom Color
*
* @var string * @var string
*/ */
private $_borderBottomColor; private $_borderBottomColor;
/** /**
* Border InsideH Size
*
* @var int * @var int
*/ */
private $_borderInsideHSize; private $_borderInsideHSize;
/** /**
* Border InsideH Color
*
* @var string * @var string
*/ */
private $_borderInsideHColor; private $_borderInsideHColor;
/** /**
* Border InsideV Size
*
* @var int * @var int
*/ */
private $_borderInsideVSize; private $_borderInsideVSize;
/** /**
* Border InsideV Color
*
* @var string * @var string
*/ */
private $_borderInsideVColor; private $_borderInsideVColor;
public function __construct($styleTable = null, $styleFirstRow = null)
/**
* Create a new TableFull Font
*/
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null)
{ {
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
$this->_firstRow = clone $this; $this->_firstRow = clone $this;
@ -196,8 +155,6 @@ class PHPWord_Style_TableFull
} }
/** /**
* Set style value
*
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
@ -217,7 +174,7 @@ class PHPWord_Style_TableFull
/** /**
* Get First Row Style * Get First Row Style
* *
* @return PHPWord_Style_TableFull * @return PhpOffice\PhpWord\Style\TableFull
*/ */
public function getFirstRow() public function getFirstRow()
{ {
@ -227,7 +184,7 @@ class PHPWord_Style_TableFull
/** /**
* Get Last Row Style * Get Last Row Style
* *
* @return PHPWord_Style_TableFull * @return PhpOffice\PhpWord\Style\TableFull
*/ */
public function getLastRow() public function getLastRow()
{ {
@ -483,4 +440,4 @@ class PHPWord_Style_TableFull
{ {
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
} }
} }

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Style;
* PHPWord_Style_Tabs
*/
class PHPWord_Style_Tabs
{
use PhpOffice\PhpWord\Shared\XMLWriter;
class Tabs
{
/** /**
* Tabs * Tabs
* *
@ -48,17 +48,16 @@ class PHPWord_Style_Tabs
} }
/** /**
* * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
* @param PHPWord_Shared_XMLWriter $objWriter
*/ */
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null) public function toXml(XMLWriter &$xmlWriter = null)
{ {
if (isset($objWriter)) { if (isset($xmlWriter)) {
$objWriter->startElement("w:tabs"); $xmlWriter->startElement("w:tabs");
foreach ($this->_tabs as &$tab) { foreach ($this->_tabs as &$tab) {
$tab->toXml($objWriter); $tab->toXml($xmlWriter);
} }
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
} }

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord;
* Class PHPWord_TOC
*/
class PHPWord_TOC
{
use PhpOffice\PhpWord\Style\Font;
class TOC
{
/** /**
* Title Elements * Title Elements
* *
@ -75,7 +75,7 @@ class PHPWord_TOC
*/ */
public function __construct($styleFont = null, $styleTOC = null) public function __construct($styleFont = null, $styleTOC = null)
{ {
self::$_styleTOC = new PHPWord_Style_TOC(); self::$_styleTOC = new PhpOffice\PhpWord\Style\TOC();
if (!is_null($styleTOC) && is_array($styleTOC)) { if (!is_null($styleTOC) && is_array($styleTOC)) {
foreach ($styleTOC as $key => $value) { foreach ($styleTOC as $key => $value) {
@ -88,7 +88,7 @@ class PHPWord_TOC
if (!is_null($styleFont)) { if (!is_null($styleFont)) {
if (is_array($styleFont)) { if (is_array($styleFont)) {
self::$_styleFont = new PHPWord_Style_Font(); self::$_styleFont = new Font();
foreach ($styleFont as $key => $value) { foreach ($styleFont as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -136,7 +136,7 @@ class PHPWord_TOC
/** /**
* Get TOC Style * Get TOC Style
* *
* @return PHPWord_Style_TOC * @return PhpOffice\PhpWord\Style\TOC
*/ */
public static function getStyleTOC() public static function getStyleTOC()
{ {
@ -146,7 +146,7 @@ class PHPWord_TOC
/** /**
* Get Font Style * Get Font Style
* *
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public static function getStyleFont() public static function getStyleFont()
{ {

View File

@ -25,14 +25,13 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\String;
/** class Template
* PHPWord_DocumentProperties
*/
class PHPWord_Template
{ {
/** /**
* ZipArchive * ZipArchive
* *
@ -132,7 +131,7 @@ class PHPWord_Template
} }
if (!is_array($replace)) { if (!is_array($replace)) {
if (!PHPWord_Shared_String::IsUTF8($replace)) { if (!String::IsUTF8($replace)) {
$replace = utf8_encode($replace); $replace = utf8_encode($replace);
} }
$replace = htmlspecialchars($replace); $replace = htmlspecialchars($replace);

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer;
* Interface PHPWord_Writer_IWriter
*/ interface IWriter
interface PHPWord_Writer_IWriter
{ {
/** /**
* Save PHPWord to file * Save PHPWord to file
@ -37,4 +36,4 @@ interface PHPWord_Writer_IWriter
* @throws Exception * @throws Exception
*/ */
public function save($pFilename = null); public function save($pFilename = null);
} }

View File

@ -25,10 +25,16 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer;
* Class PHPWord_Writer_ODText
*/ use PhpOffice\PhpWord\HashTable;
class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter use PhpOffice\PhpWord\Writer\ODText\Content;
use PhpOffice\PhpWord\Writer\ODText\Manifest;
use PhpOffice\PhpWord\Writer\ODText\Meta;
use PhpOffice\PhpWord\Writer\ODText\Mimetype;
use PhpOffice\PhpWord\Writer\ODText\Styles;
class ODText implements IWriter
{ {
/** /**
* Private PHPWord * Private PHPWord
@ -40,14 +46,14 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
/** /**
* Private writer parts * Private writer parts
* *
* @var PHPWord_Writer_ODText_WriterPart[] * @var PhpOffice\PhpWord\Writer\ODText\WriterPart[]
*/ */
private $_writerParts; private $_writerParts;
/** /**
* Private unique PHPWord_Worksheet_BaseDrawing HashTable * Private unique PHPWord_Worksheet_BaseDrawing HashTable
* *
* @var PHPWord_HashTable * @var PhpOffice\PhpWord\HashTable
*/ */
private $_drawingHashTable; private $_drawingHashTable;
@ -66,9 +72,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
private $_diskCachingDirectory; private $_diskCachingDirectory;
/** /**
* Create a new PHPWord_Writer_ODText * @param PHPWord $pPHPWord
*
* @param PHPWord $pPHPWord
*/ */
public function __construct(PHPWord $pPHPWord = null) public function __construct(PHPWord $pPHPWord = null)
{ {
@ -79,11 +83,11 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
$this->_diskCachingDirectory = './'; $this->_diskCachingDirectory = './';
// Initialise writer parts // Initialise writer parts
$this->_writerParts['content'] = new PHPWord_Writer_ODText_Content(); $this->_writerParts['content'] = new Content();
$this->_writerParts['manifest'] = new PHPWord_Writer_ODText_Manifest(); $this->_writerParts['manifest'] = new Manifest();
$this->_writerParts['meta'] = new PHPWord_Writer_ODText_Meta(); $this->_writerParts['meta'] = new Meta();
$this->_writerParts['mimetype'] = new PHPWord_Writer_ODText_Mimetype(); $this->_writerParts['mimetype'] = new Mimetype();
$this->_writerParts['styles'] = new PHPWord_Writer_ODText_Styles(); $this->_writerParts['styles'] = new Styles();
// Assign parent IWriter // Assign parent IWriter
@ -92,7 +96,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
} }
// Set HashTable variables // Set HashTable variables
$this->_drawingHashTable = new PHPWord_HashTable(); $this->_drawingHashTable = new HashTable();
} }
/** /**
@ -212,9 +216,9 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
/** /**
* Get PHPWord object * Get PHPWord object
* *
* @param PHPWord $pPHPWord PHPWord object * @param PHPWord $pPHPWord PHPWord object
* @throws Exception * @throws Exception
* @return PHPWord_Writer_ODText * @return PhpOffice\PhpWord\Writer\ODText
*/ */
public function setPHPWord(PHPWord $pPHPWord = null) public function setPHPWord(PHPWord $pPHPWord = null)
{ {
@ -225,7 +229,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
/** /**
* Get PHPWord_Worksheet_BaseDrawing HashTable * Get PHPWord_Worksheet_BaseDrawing HashTable
* *
* @return PHPWord_HashTable * @return PhpOffice\PhpWord\HashTable
*/ */
public function getDrawingHashTable() public function getDrawingHashTable()
{ {
@ -235,8 +239,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
/** /**
* Get writer part * Get writer part
* *
* @param string $pPartName Writer part name * @param string $pPartName Writer part name
* @return PHPWord_Writer_ODText_WriterPart * @return PhpOffice\PhpWord\Writer\ODText\WriterPart
*/ */
public function getWriterPart($pPartName = '') public function getWriterPart($pPartName = '')
{ {
@ -260,10 +264,10 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
/** /**
* Set use disk caching where possible? * Set use disk caching where possible?
* *
* @param boolean $pValue * @param boolean $pValue
* @param string $pDirectory Disk caching directory * @param string $pDirectory Disk caching directory
* @throws Exception Exception when directory does not exist * @throws Exception Exception when directory does not exist
* @return PHPWord_Writer_ODText * @return PhpOffice\PhpWord\Writer\ODText
*/ */
public function setUseDiskCaching($pValue = false, $pDirectory = null) public function setUseDiskCaching($pValue = false, $pDirectory = null)
{ {

View File

@ -25,68 +25,85 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_Manifest
*/ use PhpOffice\PhpWord\Section;
class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart use PhpOffice\PhpWord\Section\Image;
use PhpOffice\PhpWord\Section\Link;
use PhpOffice\PhpWord\Section\ListItem;
use PhpOffice\PhpWord\Section\MemoryImage;
use PhpOffice\PhpWord\Section\Object;
use PhpOffice\PhpWord\Section\PageBreak;
use PhpOffice\PhpWord\Section\Table;
use PhpOffice\PhpWord\Section\Text;
use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Section\Title;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC;
class Content extends WriterPart
{ {
/** /**
* Write content file to XML format * Write content file to XML format
* *
* @param PHPWord $pPHPWord * @param PHPWord $phpWord
* @return string XML Output * @return string XML Output
* @throws Exception * @throws Exception
*/ */
public function writeContent(PHPWord $pPHPWord = null) public function writeContent(PHPWord $phpWord = null)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else { } else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
} }
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startDocument('1.0', 'UTF-8');
// office:document-content // office:document-content
$objWriter->startElement('office:document-content'); $xmlWriter->startElement('office:document-content');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
$objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); $xmlWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
$objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); $xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
$objWriter->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');
$objWriter->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');
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
$objWriter->writeAttribute('office:version', '1.2'); $xmlWriter->writeAttribute('office:version', '1.2');
// We firstly search all fonts used // We firstly search all fonts used
$_sections = $pPHPWord->getSections(); $_sections = $phpWord->getSections();
$countSections = count($_sections); $countSections = count($_sections);
if ($countSections > 0) { if ($countSections > 0) {
$pSection = 0; $pSection = 0;
@ -98,23 +115,23 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
$_elements = $section->getElements(); $_elements = $section->getElements();
foreach ($_elements as $element) { foreach ($_elements as $element) {
if ($element instanceof PHPWord_Section_Text) { if ($element instanceof Text) {
$fStyle = $element->getFontStyle(); $fStyle = $element->getFontStyle();
$pStyle = $element->getParagraphStyle(); $pStyle = $element->getParagraphStyle();
if ($fStyle instanceof PHPWord_Style_Font) { if ($fStyle instanceof Font) {
$numFStyles++; $numFStyles++;
$arrStyle = array( $arrStyle = array(
'color' => $fStyle->getColor(), 'color' => $fStyle->getColor(),
'name' => $fStyle->getName() 'name' => $fStyle->getName()
); );
$pPHPWord->addFontStyle('T' . $numFStyles, $arrStyle); $phpWord->addFontStyle('T' . $numFStyles, $arrStyle);
$element->setFontStyle('T' . $numFStyles); $element->setFontStyle('T' . $numFStyles);
} elseif ($pStyle instanceof PHPWord_Style_Paragraph) { } elseif ($pStyle instanceof Paragraph) {
$numPStyles++; $numPStyles++;
$pPHPWord->addParagraphStyle('P' . $numPStyles, array()); $phpWord->addParagraphStyle('P' . $numPStyles, array());
$element->setParagraphStyle('P' . $numPStyles); $element->setParagraphStyle('P' . $numPStyles);
} }
} }
@ -123,120 +140,120 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
} }
// office:font-face-decls // office:font-face-decls
$objWriter->startElement('office:font-face-decls'); $xmlWriter->startElement('office:font-face-decls');
$arrFonts = array(); $arrFonts = array();
$styles = PHPWord_Style::getStyles(); $styles = Style::getStyles();
$numFonts = 0; $numFonts = 0;
if (count($styles) > 0) { if (count($styles) > 0) {
foreach ($styles as $styleName => $style) { foreach ($styles as $styleName => $style) {
// PHPWord_Style_Font // PhpOffice\PhpWord\Style\Font
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
$numFonts++; $numFonts++;
$name = $style->getName(); $name = $style->getName();
if (!in_array($name, $arrFonts)) { if (!in_array($name, $arrFonts)) {
$arrFonts[] = $name; $arrFonts[] = $name;
// style:font-face // style:font-face
$objWriter->startElement('style:font-face'); $xmlWriter->startElement('style:font-face');
$objWriter->writeAttribute('style:name', $name); $xmlWriter->writeAttribute('style:name', $name);
$objWriter->writeAttribute('svg:font-family', $name); $xmlWriter->writeAttribute('svg:font-family', $name);
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
} }
if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
$objWriter->startElement('style:font-face'); $xmlWriter->startElement('style:font-face');
$objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
$objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->startElement('office:automatic-styles'); $xmlWriter->startElement('office:automatic-styles');
$styles = PHPWord_Style::getStyles(); $styles = Style::getStyles();
$numPStyles = 0; $numPStyles = 0;
if (count($styles) > 0) { if (count($styles) > 0) {
foreach ($styles as $styleName => $style) { foreach ($styles as $styleName => $style) {
if (preg_match('#^T[0-9]+$#', $styleName) != 0 if (preg_match('#^T[0-9]+$#', $styleName) != 0
|| preg_match('#^P[0-9]+$#', $styleName) != 0 || preg_match('#^P[0-9]+$#', $styleName) != 0
) { ) {
// PHPWord_Style_Font // PhpOffice\PhpWord\Style\Font
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
$objWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$objWriter->writeAttribute('style:name', $styleName); $xmlWriter->writeAttribute('style:name', $styleName);
$objWriter->writeAttribute('style:family', 'text'); $xmlWriter->writeAttribute('style:family', 'text');
// style:text-properties // style:text-properties
$objWriter->startElement('style:text-properties'); $xmlWriter->startElement('style:text-properties');
$objWriter->writeAttribute('fo:color', '#' . $style->getColor()); $xmlWriter->writeAttribute('fo:color', '#' . $style->getColor());
$objWriter->writeAttribute('style:font-name', $style->getName()); $xmlWriter->writeAttribute('style:font-name', $style->getName());
$objWriter->writeAttribute('style:font-name-complex', $style->getName()); $xmlWriter->writeAttribute('style:font-name-complex', $style->getName());
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
} }
if ($style instanceof PHPWord_Style_Paragraph) { if ($style instanceof Paragraph) {
$numPStyles++; $numPStyles++;
// style:style // style:style
$objWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$objWriter->writeAttribute('style:name', $styleName); $xmlWriter->writeAttribute('style:name', $styleName);
$objWriter->writeAttribute('style:family', 'paragraph'); $xmlWriter->writeAttribute('style:family', 'paragraph');
$objWriter->writeAttribute('style:parent-style-name', 'Standard'); $xmlWriter->writeAttribute('style:parent-style-name', 'Standard');
$objWriter->writeAttribute('style:master-page-name', 'Standard'); $xmlWriter->writeAttribute('style:master-page-name', 'Standard');
// style:paragraph-properties // style:paragraph-properties
$objWriter->startElement('style:paragraph-properties'); $xmlWriter->startElement('style:paragraph-properties');
$objWriter->writeAttribute('style:page-number', 'auto'); $xmlWriter->writeAttribute('style:page-number', 'auto');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
} }
if ($numPStyles == 0) { if ($numPStyles == 0) {
// style:style // style:style
$objWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$objWriter->writeAttribute('style:name', 'P1'); $xmlWriter->writeAttribute('style:name', 'P1');
$objWriter->writeAttribute('style:family', 'paragraph'); $xmlWriter->writeAttribute('style:family', 'paragraph');
$objWriter->writeAttribute('style:parent-style-name', 'Standard'); $xmlWriter->writeAttribute('style:parent-style-name', 'Standard');
$objWriter->writeAttribute('style:master-page-name', 'Standard'); $xmlWriter->writeAttribute('style:master-page-name', 'Standard');
// style:paragraph-properties // style:paragraph-properties
$objWriter->startElement('style:paragraph-properties'); $xmlWriter->startElement('style:paragraph-properties');
$objWriter->writeAttribute('style:page-number', 'auto'); $xmlWriter->writeAttribute('style:page-number', 'auto');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
$objWriter->endElement(); $xmlWriter->endElement();
// office:body // office:body
$objWriter->startElement('office:body'); $xmlWriter->startElement('office:body');
// office:text // office:text
$objWriter->startElement('office:text'); $xmlWriter->startElement('office:text');
// text:sequence-decls // text:sequence-decls
$objWriter->startElement('text:sequence-decls'); $xmlWriter->startElement('text:sequence-decls');
// text:sequence-decl // text:sequence-decl
$objWriter->startElement('text:sequence-decl'); $xmlWriter->startElement('text:sequence-decl');
$objWriter->writeAttribute('text:display-outline-level', 0); $xmlWriter->writeAttribute('text:display-outline-level', 0);
$objWriter->writeAttribute('text:name', 'Illustration'); $xmlWriter->writeAttribute('text:name', 'Illustration');
$objWriter->endElement(); $xmlWriter->endElement();
// text:sequence-decl // text:sequence-decl
$objWriter->startElement('text:sequence-decl'); $xmlWriter->startElement('text:sequence-decl');
$objWriter->writeAttribute('text:display-outline-level', 0); $xmlWriter->writeAttribute('text:display-outline-level', 0);
$objWriter->writeAttribute('text:name', 'Table'); $xmlWriter->writeAttribute('text:name', 'Table');
$objWriter->endElement(); $xmlWriter->endElement();
// text:sequence-decl // text:sequence-decl
$objWriter->startElement('text:sequence-decl'); $xmlWriter->startElement('text:sequence-decl');
$objWriter->writeAttribute('text:display-outline-level', 0); $xmlWriter->writeAttribute('text:display-outline-level', 0);
$objWriter->writeAttribute('text:name', 'Text'); $xmlWriter->writeAttribute('text:name', 'Text');
$objWriter->endElement(); $xmlWriter->endElement();
// text:sequence-decl // text:sequence-decl
$objWriter->startElement('text:sequence-decl'); $xmlWriter->startElement('text:sequence-decl');
$objWriter->writeAttribute('text:display-outline-level', 0); $xmlWriter->writeAttribute('text:display-outline-level', 0);
$objWriter->writeAttribute('text:name', 'Drawing'); $xmlWriter->writeAttribute('text:name', 'Drawing');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
$_sections = $pPHPWord->getSections(); $_sections = $phpWord->getSections();
$countSections = count($_sections); $countSections = count($_sections);
$pSection = 0; $pSection = 0;
@ -247,66 +264,63 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
$_elements = $section->getElements(); $_elements = $section->getElements();
foreach ($_elements as $element) { foreach ($_elements as $element) {
if ($element instanceof PHPWord_Section_Text) { if ($element instanceof Text) {
$this->_writeText($objWriter, $element); $this->_writeText($xmlWriter, $element);
} elseif ($element instanceof PHPWord_Section_TextRun) { } elseif ($element instanceof TextRun) {
$this->_writeTextRun($objWriter, $element); $this->_writeTextRun($xmlWriter, $element);
} elseif ($element instanceof PHPWord_Section_TextBreak) { } elseif ($element instanceof TextBreak) {
$this->_writeTextBreak($objWriter); $this->_writeTextBreak($xmlWriter);
} elseif ($element instanceof PHPWord_Section_Link) { } elseif ($element instanceof Link) {
$this->writeUnsupportedElement($objWriter, 'Link'); $this->writeUnsupportedElement($xmlWriter, 'Link');
} elseif ($element instanceof PHPWord_Section_Title) { } elseif ($element instanceof Title) {
$this->writeUnsupportedElement($objWriter, 'Title'); $this->writeUnsupportedElement($xmlWriter, 'Title');
} elseif ($element instanceof PHPWord_Section_PageBreak) { } elseif ($element instanceof PageBreak) {
$this->writeUnsupportedElement($objWriter, 'Page Break'); $this->writeUnsupportedElement($xmlWriter, 'Page Break');
} elseif ($element instanceof PHPWord_Section_Table) { } elseif ($element instanceof Table) {
$this->writeUnsupportedElement($objWriter, 'Table'); $this->writeUnsupportedElement($xmlWriter, 'Table');
} elseif ($element instanceof PHPWord_Section_ListItem) { } elseif ($element instanceof ListItem) {
$this->writeUnsupportedElement($objWriter, 'List Item'); $this->writeUnsupportedElement($xmlWriter, 'List Item');
} elseif ($element instanceof PHPWord_Section_Image || } elseif ($element instanceof Image ||
$element instanceof PHPWord_Section_MemoryImage) { $element instanceof MemoryImage) {
$this->writeUnsupportedElement($objWriter, 'Image'); $this->writeUnsupportedElement($xmlWriter, 'Image');
} elseif ($element instanceof PHPWord_Section_Object) { } elseif ($element instanceof Object) {
$this->writeUnsupportedElement($objWriter, 'Object'); $this->writeUnsupportedElement($xmlWriter, 'Object');
} elseif ($element instanceof PHPWord_TOC) { } elseif ($element instanceof TOC) {
$this->writeUnsupportedElement($objWriter, 'TOC'); $this->writeUnsupportedElement($xmlWriter, 'TOC');
} else { } else {
$this->writeUnsupportedElement($objWriter, 'Element'); $this->writeUnsupportedElement($xmlWriter, 'Element');
} }
} }
if ($pSection == $countSections) { if ($pSection == $countSections) {
$this->_writeEndSection($objWriter, $section); $this->_writeEndSection($xmlWriter, $section);
} else { } else {
$this->_writeSection($objWriter, $section); $this->_writeSection($xmlWriter, $section);
} }
} }
} }
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// Return // Return
return $objWriter->getData(); return $xmlWriter->getData();
} }
/** /**
* Write text * Write text
* *
* @param PHPWord_Shared_XMLWriter $objWriter * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PHPWord_Section_Text $text * @param PhpOffice\PhpWord\Section\Text $text
* @param bool $withoutP * @param bool $withoutP
*/ */
protected function _writeText( protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false)
PHPWord_Shared_XMLWriter $objWriter = null, {
PHPWord_Section_Text $text,
$withoutP = false
) {
$styleFont = $text->getFontStyle(); $styleFont = $text->getFontStyle();
$styleParagraph = $text->getParagraphStyle(); $styleParagraph = $text->getParagraphStyle();
// @todo Commented for TextRun. Should really checkout this value // @todo Commented for TextRun. Should really checkout this value
// $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false; // $SfIsObject = ($styleFont instanceof Font) ? true : false;
$SfIsObject = false; $SfIsObject = false;
if ($SfIsObject) { if ($SfIsObject) {
@ -314,29 +328,29 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
die('PHPWord : $SfIsObject wouldn\'t be an object'); die('PHPWord : $SfIsObject wouldn\'t be an object');
} else { } else {
if (!$withoutP) { if (!$withoutP) {
$objWriter->startElement('text:p'); // text:p $xmlWriter->startElement('text:p'); // text:p
} }
if (empty($styleFont)) { if (empty($styleFont)) {
if (empty($styleParagraph)) { if (empty($styleParagraph)) {
$objWriter->writeAttribute('text:style-name', 'P1'); $xmlWriter->writeAttribute('text:style-name', 'P1');
} else { } else {
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
} }
$objWriter->writeRaw($text->getText()); $xmlWriter->writeRaw($text->getText());
} else { } else {
if (empty($styleParagraph)) { if (empty($styleParagraph)) {
$objWriter->writeAttribute('text:style-name', 'Standard'); $xmlWriter->writeAttribute('text:style-name', 'Standard');
} else { } else {
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
} }
// text:span // text:span
$objWriter->startElement('text:span'); $xmlWriter->startElement('text:span');
$objWriter->writeAttribute('text:style-name', $styleFont); $xmlWriter->writeAttribute('text:style-name', $styleFont);
$objWriter->writeRaw($text->getText()); $xmlWriter->writeRaw($text->getText());
$objWriter->endElement(); $xmlWriter->endElement();
} }
if (!$withoutP) { if (!$withoutP) {
$objWriter->endElement(); // text:p $xmlWriter->endElement(); // text:p
} }
} }
} }
@ -344,40 +358,40 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
/** /**
* Write TextRun section * Write TextRun section
* *
* @param PHPWord_Shared_XMLWriter $objWriter * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PHPWord_Section_TextRun $textrun * @param PhpOffice\PhpWord\Section\TextRun $textrun
* @todo Enable all other section types * @todo Enable all other section types
*/ */
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun)
{ {
$elements = $textrun->getElements(); $elements = $textrun->getElements();
$objWriter->startElement('text:p'); $xmlWriter->startElement('text:p');
if (count($elements) > 0) { if (count($elements) > 0) {
foreach ($elements as $element) { foreach ($elements as $element) {
if ($element instanceof PHPWord_Section_Text) { if ($element instanceof Text) {
$this->_writeText($objWriter, $element, true); $this->_writeText($xmlWriter, $element, true);
} }
} }
} }
$objWriter->endElement(); $xmlWriter->endElement();
} }
/** /**
* Write TextBreak * Write TextBreak
*/ */
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) protected function _writeTextBreak(XMLWriter $xmlWriter = null)
{ {
$objWriter->startElement('text:p'); $xmlWriter->startElement('text:p');
$objWriter->writeAttribute('text:style-name', 'Standard'); $xmlWriter->writeAttribute('text:style-name', 'Standard');
$objWriter->endElement(); $xmlWriter->endElement();
} }
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null)
{ {
} }
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null) private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null)
{ {
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
@ -385,13 +399,13 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
/** /**
* Write unsupported element * Write unsupported element
* *
* @param PHPWord_Shared_XMLWriter $objWriter * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $element * @param string $element
*/ */
private function writeUnsupportedElement($objWriter, $element) private function writeUnsupportedElement($xmlWriter, $element)
{ {
$objWriter->startElement('text:p'); $xmlWriter->startElement('text:p');
$objWriter->writeRaw("{$element}"); $xmlWriter->writeRaw($element);
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }

View File

@ -25,10 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_Manifest
*/ use PhpOffice\PhpWord\Shared\File;
class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart use PhpOffice\PhpWord\Shared\XMLWriter;
class Manifest extends WriterPart
{ {
/** /**
* Write Manifest file to XML format * Write Manifest file to XML format
@ -40,42 +42,42 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
public function writeManifest(PHPWord $pPHPWord = null) public function writeManifest(PHPWord $pPHPWord = null)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else { } else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
} }
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startDocument('1.0', 'UTF-8');
// manifest:manifest // manifest:manifest
$objWriter->startElement('manifest:manifest'); $xmlWriter->startElement('manifest:manifest');
$objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
$objWriter->writeAttribute('manifest:version', '1.2'); $xmlWriter->writeAttribute('manifest:version', '1.2');
// manifest:file-entry // manifest:file-entry
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text');
$objWriter->writeAttribute('manifest:version', '1.2'); $xmlWriter->writeAttribute('manifest:version', '1.2');
$objWriter->writeAttribute('manifest:full-path', '/'); $xmlWriter->writeAttribute('manifest:full-path', '/');
$objWriter->endElement(); $xmlWriter->endElement();
// manifest:file-entry // manifest:file-entry
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', 'text/xml'); $xmlWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->writeAttribute('manifest:full-path', 'content.xml'); $xmlWriter->writeAttribute('manifest:full-path', 'content.xml');
$objWriter->endElement(); $xmlWriter->endElement();
// manifest:file-entry // manifest:file-entry
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', 'text/xml'); $xmlWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->writeAttribute('manifest:full-path', 'meta.xml'); $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml');
$objWriter->endElement(); $xmlWriter->endElement();
// manifest:file-entry // manifest:file-entry
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', 'text/xml'); $xmlWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->writeAttribute('manifest:full-path', 'styles.xml'); $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml');
$objWriter->endElement(); $xmlWriter->endElement();
// Not used yet. Legacy from PHPExcel // Not used yet. Legacy from PHPExcel
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@ -84,10 +86,10 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
$mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', $mimeType); $xmlWriter->writeAttribute('manifest:media-type', $mimeType);
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
$objWriter->endElement(); $xmlWriter->endElement();
} elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
$extension = explode('/', $extension); $extension = explode('/', $extension);
@ -95,18 +97,18 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
$objWriter->startElement('manifest:file-entry'); $xmlWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', $mimeType); $xmlWriter->writeAttribute('manifest:media-type', $mimeType);
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
$objWriter->endElement(); $xmlWriter->endElement();
// Return // Return
return $objWriter->getData(); return $xmlWriter->getData();
} }
@ -119,7 +121,7 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
*/ */
private function _getImageMimeType($pFile = '') private function _getImageMimeType($pFile = '')
{ {
if (PHPWord_Shared_File::file_exists($pFile)) { if (File::file_exists($pFile)) {
$image = getimagesize($pFile); $image = getimagesize($pFile);
return image_type_to_mime_type($image[2]); return image_type_to_mime_type($image[2]);
} else { } else {

View File

@ -25,10 +25,11 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_Meta
*/ use PhpOffice\PhpWord\Shared\XMLWriter;
class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
class Meta extends WriterPart
{ {
/** /**
* Write Meta file to XML format * Write Meta file to XML format
@ -40,55 +41,55 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
public function writeMeta(PHPWord $pPHPWord = null) public function writeMeta(PHPWord $pPHPWord = null)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else { } else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
} }
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startDocument('1.0', 'UTF-8');
// office:document-meta // office:document-meta
$objWriter->startElement('office:document-meta'); $xmlWriter->startElement('office:document-meta');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('office:version', '1.2'); $xmlWriter->writeAttribute('office:version', '1.2');
// office:meta // office:meta
$objWriter->startElement('office:meta'); $xmlWriter->startElement('office:meta');
// dc:creator // dc:creator
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy()); $xmlWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
// dc:date // dc:date
$objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified())); $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified()));
// dc:description // dc:description
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); $xmlWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
// dc:subject // dc:subject
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); $xmlWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
// dc:title // dc:title
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); $xmlWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
// meta:creation-date // meta:creation-date
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated())); $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated()));
// meta:initial-creator // meta:initial-creator
$objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator()); $xmlWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
// meta:keyword // meta:keyword
$objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords()); $xmlWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
// @todo : Where these properties are written ? // @todo : Where these properties are written ?
// $pPHPWord->getProperties()->getCategory() // $pPHPWord->getProperties()->getCategory()
// $pPHPWord->getProperties()->getCompany() // $pPHPWord->getProperties()->getCompany()
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// Return // Return
return $objWriter->getData(); return $xmlWriter->getData();
} }
} }

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_Mimetype
*/ class Mimetype extends WriterPart
class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart
{ {
/** /**
* Write Mimetype to Text format * Write Mimetype to Text format

View File

@ -25,10 +25,15 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_Styles
*/ use PhpOffice\PhpWord\Shared\XMLWriter;
class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull;
class Styles extends WriterPart
{ {
/** /**
* Write Styles file to XML format * Write Styles file to XML format
@ -40,228 +45,228 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
public function writeStyles(PHPWord $pPHPWord = null) public function writeStyles(PHPWord $pPHPWord = null)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else { } else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY); $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
} }
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startDocument('1.0', 'UTF-8');
// Styles:Styles // Styles:Styles
$objWriter->startElement('office:document-styles'); $xmlWriter->startElement('office:document-styles');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
$objWriter->writeAttribute('office:version', '1.2'); $xmlWriter->writeAttribute('office:version', '1.2');
// office:font-face-decls // office:font-face-decls
$objWriter->startElement('office:font-face-decls'); $xmlWriter->startElement('office:font-face-decls');
$arrFonts = array(); $arrFonts = array();
$styles = PHPWord_Style::getStyles(); $styles = Style::getStyles();
$numFonts = 0; $numFonts = 0;
if (count($styles) > 0) { if (count($styles) > 0) {
foreach ($styles as $styleName => $style) { foreach ($styles as $styleName => $style) {
// PHPWord_Style_Font // PhpOffice\PhpWord\Style\Font
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
$numFonts++; $numFonts++;
$name = $style->getName(); $name = $style->getName();
if (!in_array($name, $arrFonts)) { if (!in_array($name, $arrFonts)) {
$arrFonts[] = $name; $arrFonts[] = $name;
// style:font-face // style:font-face
$objWriter->startElement('style:font-face'); $xmlWriter->startElement('style:font-face');
$objWriter->writeAttribute('style:name', $name); $xmlWriter->writeAttribute('style:name', $name);
$objWriter->writeAttribute('svg:font-family', $name); $xmlWriter->writeAttribute('svg:font-family', $name);
$objWriter->endElement(); $xmlWriter->endElement();
} }
} }
} }
} }
if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
$objWriter->startElement('style:font-face'); $xmlWriter->startElement('style:font-face');
$objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
$objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
$objWriter->endElement(); $xmlWriter->endElement();
} }
$objWriter->endElement(); $xmlWriter->endElement();
// office:styles // office:styles
$objWriter->startElement('office:styles'); $xmlWriter->startElement('office:styles');
// style:default-style // style:default-style
$objWriter->startElement('style:default-style'); $xmlWriter->startElement('style:default-style');
$objWriter->writeAttribute('style:family', 'paragraph'); $xmlWriter->writeAttribute('style:family', 'paragraph');
// style:paragraph-properties // style:paragraph-properties
$objWriter->startElement('style:paragraph-properties'); $xmlWriter->startElement('style:paragraph-properties');
$objWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); $xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
$objWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); $xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
$objWriter->writeAttribute('style:punctuation-wrap', 'hanging'); $xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging');
$objWriter->writeAttribute('style:line-break', 'strict'); $xmlWriter->writeAttribute('style:line-break', 'strict');
$objWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); $xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
$objWriter->writeAttribute('style:writing-mode', 'page'); $xmlWriter->writeAttribute('style:writing-mode', 'page');
$objWriter->endElement(); $xmlWriter->endElement();
// style:text-properties // style:text-properties
$objWriter->startElement('style:text-properties'); $xmlWriter->startElement('style:text-properties');
$objWriter->writeAttribute('style:use-window-font-color', 'true'); $xmlWriter->writeAttribute('style:use-window-font-color', 'true');
$objWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME); $xmlWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME);
$objWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt');
$objWriter->writeAttribute('fo:language', 'fr'); $xmlWriter->writeAttribute('fo:language', 'fr');
$objWriter->writeAttribute('fo:country', 'FR'); $xmlWriter->writeAttribute('fo:country', 'FR');
$objWriter->writeAttribute('style:letter-kerning', 'true'); $xmlWriter->writeAttribute('style:letter-kerning', 'true');
$objWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2'); $xmlWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2');
$objWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt');
$objWriter->writeAttribute('style:language-asian', 'zh'); $xmlWriter->writeAttribute('style:language-asian', 'zh');
$objWriter->writeAttribute('style:country-asian', 'CN'); $xmlWriter->writeAttribute('style:country-asian', 'CN');
$objWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2'); $xmlWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2');
$objWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt'); $xmlWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt');
$objWriter->writeAttribute('style:language-complex', 'hi'); $xmlWriter->writeAttribute('style:language-complex', 'hi');
$objWriter->writeAttribute('style:country-complex', 'IN'); $xmlWriter->writeAttribute('style:country-complex', 'IN');
$objWriter->writeAttribute('fo:hyphenate', 'false'); $xmlWriter->writeAttribute('fo:hyphenate', 'false');
$objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); $xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
$objWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); $xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// Write Style Definitions // Write Style Definitions
$styles = PHPWord_Style::getStyles(); $styles = Style::getStyles();
if (count($styles) > 0) { if (count($styles) > 0) {
foreach ($styles as $styleName => $style) { foreach ($styles as $styleName => $style) {
if (preg_match('#^T[0-9]+$#', $styleName) == 0 if (preg_match('#^T[0-9]+$#', $styleName) == 0
&& preg_match('#^P[0-9]+$#', $styleName) == 0 && preg_match('#^P[0-9]+$#', $styleName) == 0
) { ) {
// PHPWord_Style_Font // PhpOffice\PhpWord\Style\Font
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
// style:style // style:style
$objWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$objWriter->writeAttribute('style:name', $styleName); $xmlWriter->writeAttribute('style:name', $styleName);
$objWriter->writeAttribute('style:family', 'text'); $xmlWriter->writeAttribute('style:family', 'text');
// style:text-properties // style:text-properties
$objWriter->startElement('style:text-properties'); $xmlWriter->startElement('style:text-properties');
$objWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); $xmlWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt');
$objWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); $xmlWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt');
$objWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); $xmlWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt');
if ($style->getItalic()) { if ($style->getItalic()) {
$objWriter->writeAttribute('fo:font-style', 'italic'); $xmlWriter->writeAttribute('fo:font-style', 'italic');
$objWriter->writeAttribute('style:font-style-asian', 'italic'); $xmlWriter->writeAttribute('style:font-style-asian', 'italic');
$objWriter->writeAttribute('style:font-style-complex', 'italic'); $xmlWriter->writeAttribute('style:font-style-complex', 'italic');
} }
if ($style->getBold()) { if ($style->getBold()) {
$objWriter->writeAttribute('fo:font-weight', 'bold'); $xmlWriter->writeAttribute('fo:font-weight', 'bold');
$objWriter->writeAttribute('style:font-weight-asian', 'bold'); $xmlWriter->writeAttribute('style:font-weight-asian', 'bold');
} }
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
} elseif ($style instanceof PHPWord_Style_Paragraph) { } elseif ($style instanceof Paragraph) {
// PHPWord_Style_Paragraph // PhpOffice\PhpWord\Style\Paragraph
// style:style // style:style
$objWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$objWriter->writeAttribute('style:name', $styleName); $xmlWriter->writeAttribute('style:name', $styleName);
$objWriter->writeAttribute('style:family', 'paragraph'); $xmlWriter->writeAttribute('style:family', 'paragraph');
//style:paragraph-properties //style:paragraph-properties
$objWriter->startElement('style:paragraph-properties'); $xmlWriter->startElement('style:paragraph-properties');
$objWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); $xmlWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm');
$objWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); $xmlWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm');
$objWriter->writeAttribute('fo:text-align', $style->getAlign()); $xmlWriter->writeAttribute('fo:text-align', $style->getAlign());
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
} elseif ($style instanceof PHPWord_Style_TableFull) { } elseif ($style instanceof TableFull) {
// PHPWord_Style_TableFull // PhpOffice\PhpWord\Style\TableFull
} }
} }
} }
} }
$objWriter->endElement(); $xmlWriter->endElement();
// office:automatic-styles // office:automatic-styles
$objWriter->startElement('office:automatic-styles'); $xmlWriter->startElement('office:automatic-styles');
// style:page-layout // style:page-layout
$objWriter->startElement('style:page-layout'); $xmlWriter->startElement('style:page-layout');
$objWriter->writeAttribute('style:name', 'Mpm1'); $xmlWriter->writeAttribute('style:name', 'Mpm1');
// style:page-layout-properties // style:page-layout-properties
$objWriter->startElement('style:page-layout-properties'); $xmlWriter->startElement('style:page-layout-properties');
$objWriter->writeAttribute('fo:page-width', "21.001cm"); $xmlWriter->writeAttribute('fo:page-width', "21.001cm");
$objWriter->writeAttribute('fo:page-height', '29.7cm'); $xmlWriter->writeAttribute('fo:page-height', '29.7cm');
$objWriter->writeAttribute('style:num-format', '1'); $xmlWriter->writeAttribute('style:num-format', '1');
$objWriter->writeAttribute('style:print-orientation', 'portrait'); $xmlWriter->writeAttribute('style:print-orientation', 'portrait');
$objWriter->writeAttribute('fo:margin-top', '2.501cm'); $xmlWriter->writeAttribute('fo:margin-top', '2.501cm');
$objWriter->writeAttribute('fo:margin-bottom', '2cm'); $xmlWriter->writeAttribute('fo:margin-bottom', '2cm');
$objWriter->writeAttribute('fo:margin-left', '2.501cm'); $xmlWriter->writeAttribute('fo:margin-left', '2.501cm');
$objWriter->writeAttribute('fo:margin-right', '2.501cm'); $xmlWriter->writeAttribute('fo:margin-right', '2.501cm');
$objWriter->writeAttribute('style:writing-mode', 'lr-tb'); $xmlWriter->writeAttribute('style:writing-mode', 'lr-tb');
$objWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); $xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0');
$objWriter->writeAttribute('style:layout-grid-lines', '25199'); $xmlWriter->writeAttribute('style:layout-grid-lines', '25199');
$objWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); $xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm');
$objWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); $xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm');
$objWriter->writeAttribute('style:layout-grid-mode', 'none'); $xmlWriter->writeAttribute('style:layout-grid-mode', 'none');
$objWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); $xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false');
$objWriter->writeAttribute('style:layout-grid-print', 'false'); $xmlWriter->writeAttribute('style:layout-grid-print', 'false');
$objWriter->writeAttribute('style:layout-grid-display', 'false'); $xmlWriter->writeAttribute('style:layout-grid-display', 'false');
$objWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); $xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm');
$objWriter->writeAttribute('style:layout-grid-snap-to', 'true'); $xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true');
$objWriter->writeAttribute('style:footnote-max-height', '0cm'); $xmlWriter->writeAttribute('style:footnote-max-height', '0cm');
//style:footnote-sep //style:footnote-sep
$objWriter->startElement('style:footnote-sep'); $xmlWriter->startElement('style:footnote-sep');
$objWriter->writeAttribute('style:width', '0.018cm'); $xmlWriter->writeAttribute('style:width', '0.018cm');
$objWriter->writeAttribute('style:line-style', 'solid'); $xmlWriter->writeAttribute('style:line-style', 'solid');
$objWriter->writeAttribute('style:adjustment', 'left'); $xmlWriter->writeAttribute('style:adjustment', 'left');
$objWriter->writeAttribute('style:rel-width', '25%'); $xmlWriter->writeAttribute('style:rel-width', '25%');
$objWriter->writeAttribute('style:color', '#000000'); $xmlWriter->writeAttribute('style:color', '#000000');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// style:header-style // style:header-style
$objWriter->startElement('style:header-style'); $xmlWriter->startElement('style:header-style');
$objWriter->endElement(); $xmlWriter->endElement();
// style:footer-style // style:footer-style
$objWriter->startElement('style:footer-style'); $xmlWriter->startElement('style:footer-style');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// office:master-styles // office:master-styles
$objWriter->startElement('office:master-styles'); $xmlWriter->startElement('office:master-styles');
// style:master-page // style:master-page
$objWriter->startElement('style:master-page'); $xmlWriter->startElement('style:master-page');
$objWriter->writeAttribute('style:name', 'Standard'); $xmlWriter->writeAttribute('style:name', 'Standard');
$objWriter->writeAttribute('style:page-layout-name', 'Mpm1'); $xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1');
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
$objWriter->endElement(); $xmlWriter->endElement();
// Return // Return
return $objWriter->getData(); return $xmlWriter->getData();
} }
} }

View File

@ -25,25 +25,26 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Writer\ODText;
* Class PHPWord_Writer_ODText_WriterPart
*/ use PhpOffice\PhpWord\Writer\IWriter;
abstract class PHPWord_Writer_ODText_WriterPart
abstract class WriterPart
{ {
/** /**
* Parent IWriter object * Parent IWriter object
* *
* @var PHPWord_Writer_IWriter * @var PhpOffice\PhpWord\Writer\IWriter
*/ */
private $_parentWriter; private $_parentWriter;
/** /**
* Set parent IWriter object * Set parent IWriter object
* *
* @param PHPWord_Writer_IWriter $pWriter * @param PhpOffice\PhpWord\Writer\IWriter $pWriter
* @throws Exception * @throws Exception
*/ */
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) public function setParentWriter(IWriter $pWriter = null)
{ {
$this->_parentWriter = $pWriter; $this->_parentWriter = $pWriter;
} }
@ -51,7 +52,7 @@ abstract class PHPWord_Writer_ODText_WriterPart
/** /**
* Get parent IWriter object * Get parent IWriter object
* *
* @return PHPWord_Writer_IWriter * @return PhpOffice\PhpWord\Writer\IWriter
* @throws Exception * @throws Exception
*/ */
public function getParentWriter() public function getParentWriter()
@ -59,7 +60,7 @@ abstract class PHPWord_Writer_ODText_WriterPart
if (!is_null($this->_parentWriter)) { if (!is_null($this->_parentWriter)) {
return $this->_parentWriter; return $this->_parentWriter;
} else { } else {
throw new Exception("No parent PHPWord_Writer_IWriter assigned."); throw new Exception("No parent IWriter assigned.");
} }
} }
} }