Part I.
This commit is contained in:
Roman Syroeshko 2014-03-17 20:25:30 +04:00
parent f4d7fa427d
commit 510f9cdf79
38 changed files with 485 additions and 497 deletions

View File

@ -25,6 +25,13 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice;
use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Template;
/** PHPWORD_BASE_PATH */ /** PHPWORD_BASE_PATH */
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (!defined('PHPWORD_BASE_PATH')) { if (!defined('PHPWORD_BASE_PATH')) {
@ -36,12 +43,8 @@ if (!defined('PHPWORD_BASE_PATH')) {
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/** class PhpWord
* PHPWord
*/
class PHPWord
{ {
/** /**
* Default font name (Arial) * Default font name (Arial)
*/ */
@ -67,7 +70,7 @@ class PHPWord
/** /**
* Document properties * Document properties
* *
* @var PHPWord_DocumentProperties * @var PhpOffice\PhpWord\DocumentProperties
*/ */
private $_properties; private $_properties;
@ -98,14 +101,14 @@ class PHPWord
*/ */
public function __construct() public function __construct()
{ {
$this->_properties = new PHPWord_DocumentProperties(); $this->_properties = new DocumentProperties();
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME; $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE; $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
} }
/** /**
* Get properties * Get properties
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function getProperties() public function getProperties()
{ {
@ -115,10 +118,10 @@ class PHPWord
/** /**
* Set properties * Set properties
* *
* @param PHPWord_DocumentProperties $value * @param PhpOffice\PhpWord\DocumentProperties $value
* @return PHPWord * @return PhpOffice\PHPWord
*/ */
public function setProperties(PHPWord_DocumentProperties $value) public function setProperties(DocumentProperties $value)
{ {
$this->_properties = $value; $this->_properties = $value;
return $this; return $this;
@ -127,14 +130,14 @@ class PHPWord
/** /**
* Create a new Section * Create a new Section
* *
* @param PHPWord_Section_Settings $settings * @param PhpOffice\PhpWord\Section\Settings $settings
* @return PHPWord_Section * @return PhpOffice\PhpWord\Section
*/ */
public function createSection($settings = null) public function createSection($settings = null)
{ {
$sectionCount = $this->_countSections() + 1; $sectionCount = $this->_countSections() + 1;
$section = new PHPWord_Section($sectionCount, $settings); $section = new Section($sectionCount, $settings);
$this->_sectionCollection[] = $section; $this->_sectionCollection[] = $section;
return $section; return $section;
} }
@ -182,7 +185,7 @@ class PHPWord
*/ */
public function setDefaultParagraphStyle($styles) public function setDefaultParagraphStyle($styles)
{ {
PHPWord_Style::setDefaultParagraphStyle($styles); Style::setDefaultParagraphStyle($styles);
} }
/** /**
@ -193,7 +196,7 @@ class PHPWord
*/ */
public function addParagraphStyle($styleName, $styles) public function addParagraphStyle($styleName, $styles)
{ {
PHPWord_Style::addParagraphStyle($styleName, $styles); Style::addParagraphStyle($styleName, $styles);
} }
/** /**
@ -204,7 +207,7 @@ class PHPWord
*/ */
public function addFontStyle($styleName, $styleFont, $styleParagraph = null) public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
{ {
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph); Style::addFontStyle($styleName, $styleFont, $styleParagraph);
} }
/** /**
@ -215,7 +218,7 @@ class PHPWord
*/ */
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{ {
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow); Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
} }
/** /**
@ -226,7 +229,7 @@ class PHPWord
*/ */
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
{ {
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
} }
/** /**
@ -237,12 +240,12 @@ class PHPWord
*/ */
public function addLinkStyle($styleName, $styles) public function addLinkStyle($styleName, $styles)
{ {
PHPWord_Style::addLinkStyle($styleName, $styles); Style::addLinkStyle($styleName, $styles);
} }
/** /**
* Get sections * Get sections
* @return PHPWord_Section[] * @return PhpOffice\PhpWord\Section[]
*/ */
public function getSections() public function getSections()
{ {
@ -253,14 +256,13 @@ class PHPWord
* Load a Template File * Load a Template File
* *
* @param string $strFilename * @param string $strFilename
* @return PHPWord_Template * @return PhpOffice\PhpWord\Template
* @throws Exception * @throws Exception
*/ */
public function loadTemplate($strFilename) public function loadTemplate($strFilename)
{ {
if (file_exists($strFilename)) { if (file_exists($strFilename)) {
$template = new PHPWord_Template($strFilename); return new Template($strFilename);
return $template;
} }
throw new Exception("Template file {$strFilename} not found."); throw new Exception("Template file {$strFilename} not found.");
} }

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord;
* Class PHPWord_DocumentProperties
*/ class DocumentProperties
class PHPWord_DocumentProperties
{ {
/** Constants */ /** Constants */
const PROPERTY_TYPE_BOOLEAN = 'b'; const PROPERTY_TYPE_BOOLEAN = 'b';
@ -123,7 +122,7 @@ class PHPWord_DocumentProperties
private $_customProperties = array(); private $_customProperties = array();
/** /**
* Create new PHPWord_DocumentProperties * Create new DocumentProperties
*/ */
public function __construct() public function __construct()
{ {
@ -154,7 +153,7 @@ class PHPWord_DocumentProperties
* Set Creator * Set Creator
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setCreator($pValue = '') public function setCreator($pValue = '')
{ {
@ -176,7 +175,7 @@ class PHPWord_DocumentProperties
* Set Last Modified By * Set Last Modified By
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setLastModifiedBy($pValue = '') public function setLastModifiedBy($pValue = '')
{ {
@ -198,7 +197,7 @@ class PHPWord_DocumentProperties
* Set Created * Set Created
* *
* @param datetime $pValue * @param datetime $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setCreated($pValue = null) public function setCreated($pValue = null)
{ {
@ -223,7 +222,7 @@ class PHPWord_DocumentProperties
* Set Modified * Set Modified
* *
* @param datetime $pValue * @param datetime $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setModified($pValue = null) public function setModified($pValue = null)
{ {
@ -248,7 +247,7 @@ class PHPWord_DocumentProperties
* Set Title * Set Title
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setTitle($pValue = '') public function setTitle($pValue = '')
{ {
@ -270,7 +269,7 @@ class PHPWord_DocumentProperties
* Set Description * Set Description
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setDescription($pValue = '') public function setDescription($pValue = '')
{ {
@ -292,7 +291,7 @@ class PHPWord_DocumentProperties
* Set Subject * Set Subject
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setSubject($pValue = '') public function setSubject($pValue = '')
{ {
@ -314,7 +313,7 @@ class PHPWord_DocumentProperties
* Set Keywords * Set Keywords
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setKeywords($pValue = '') public function setKeywords($pValue = '')
{ {
@ -336,7 +335,7 @@ class PHPWord_DocumentProperties
* Set Category * Set Category
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setCategory($pValue = '') public function setCategory($pValue = '')
{ {
@ -358,7 +357,7 @@ class PHPWord_DocumentProperties
* Set Company * Set Company
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setCompany($pValue = '') public function setCompany($pValue = '')
{ {
@ -380,7 +379,7 @@ class PHPWord_DocumentProperties
* Set Manager * Set Manager
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setManager($pValue = '') public function setManager($pValue = '')
{ {
@ -448,7 +447,7 @@ class PHPWord_DocumentProperties
* 's': String * 's': String
* 'd': Date/Time * 'd': Date/Time
* 'b': Boolean * 'b': Boolean
* @return PHPExcel_DocumentProperties * @return PhpOffice\PhpWord\DocumentProperties
*/ */
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
{ {

View File

@ -1,9 +1,6 @@
<?php <?php
namespace PhpOffice\PhpWord\Exceptions; namespace PhpOffice\PhpWord\Exceptions;
/**
* Class Exception
*/
class Exception extends \Exception class Exception extends \Exception
{ {
} }

View File

@ -10,4 +10,4 @@ namespace PhpOffice\PhpWord\Exceptions;
*/ */
class InvalidImageException extends Exception class InvalidImageException extends Exception
{ {
} }

View File

@ -10,4 +10,4 @@ namespace PhpOffice\PhpWord\Exceptions;
*/ */
class UnsupportedImageTypeException extends Exception class UnsupportedImageTypeException extends Exception
{ {
} }

View File

@ -25,13 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord;
/** class Footnote
* PHPWord_Footnote
*/
class PHPWord_Footnote
{ {
/** /**
* Footnote Elements * Footnote Elements
* *
@ -54,7 +51,7 @@ class PHPWord_Footnote
* *
* @return mixed * @return mixed
*/ */
public static function addFootnoteElement(PHPWord_Section_Footnote $footnote) public static function addFootnoteElement(PhpOffice\PhpWord\Section\Footnote $footnote)
{ {
$refID = self::countFootnoteElements() + 2; $refID = self::countFootnoteElements() + 2;

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord;
/** /**
* PHPWord_HashTable * @codeCoverageIgnore Legacy from PHPExcel
*
* @codeCoverageIgnore Legacy from PHPExcel
*/ */
class PHPWord_HashTable class HashTable
{ {
/** /**
* HashTable elements * HashTable elements
@ -47,15 +47,12 @@ class PHPWord_HashTable
public $_keyMap = array(); public $_keyMap = array();
/** /**
* Create a new PHPWord_HashTable * @param PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from
* * @throws Exception
* @param PHPWord_IComparable[] $pSource Optional source array to create HashTable from
* @throws Exception
*/ */
public function __construct($pSource = null) public function __construct($pSource = null)
{ {
if (!is_null($pSource)) { if (!is_null($pSource)) {
// Create HashTable
$this->addFromSource($pSource); $this->addFromSource($pSource);
} }
} }
@ -63,8 +60,8 @@ class PHPWord_HashTable
/** /**
* Add HashTable items from source * Add HashTable items from source
* *
* @param PHPWord_IComparable[] $pSource Source array to create HashTable from * @param PhpOffice\PhpWord\IComparable[] $pSource Source array to create HashTable from
* @throws Exception * @throws Exception
*/ */
public function addFromSource($pSource = null) public function addFromSource($pSource = null)
{ {
@ -83,10 +80,10 @@ class PHPWord_HashTable
/** /**
* Add HashTable item * Add HashTable item
* *
* @param PHPWord_IComparable $pSource Item to add * @param PhpOffice\PhpWord\IComparable $pSource Item to add
* @throws Exception * @throws Exception
*/ */
public function add(PHPWord_IComparable $pSource = null) public function add(IComparable $pSource = null)
{ {
// Determine hashcode // Determine hashcode
$hashCode = null; $hashCode = null;
@ -113,10 +110,10 @@ class PHPWord_HashTable
/** /**
* Remove HashTable item * Remove HashTable item
* *
* @param PHPWord_IComparable $pSource Item to remove * @param PhpOffice\PhpWord\IComparable $pSource Item to remove
* @throws Exception * @throws Exception
*/ */
public function remove(PHPWord_IComparable $pSource = null) public function remove(IComparable $pSource = null)
{ {
if (isset($this->_items[$pSource->getHashCode()])) { if (isset($this->_items[$pSource->getHashCode()])) {
unset($this->_items[$pSource->getHashCode()]); unset($this->_items[$pSource->getHashCode()]);
@ -146,8 +143,6 @@ class PHPWord_HashTable
} }
/** /**
* Count
*
* @return int * @return int
*/ */
public function count() public function count()
@ -156,10 +151,8 @@ class PHPWord_HashTable
} }
/** /**
* Get index for hash code * @param string $pHashCode
* * @return int Index
* @param string $pHashCode
* @return int Index
*/ */
public function getIndexForHashCode($pHashCode = '') public function getIndexForHashCode($pHashCode = '')
{ {
@ -167,11 +160,8 @@ class PHPWord_HashTable
} }
/** /**
* Get by index * @param int $pIndex
* * @return PhpOffice\PhpWord\IComparable
* @param int $pIndex
* @return PHPWord_IComparable
*
*/ */
public function getByIndex($pIndex = 0) public function getByIndex($pIndex = 0)
{ {
@ -183,10 +173,8 @@ class PHPWord_HashTable
} }
/** /**
* Get by hashcode * @param string $pHashCode
* * @return PhpOffice\PhpWord\IComparable
* @param string $pHashCode
* @return PHPWord_IComparable
* *
*/ */
public function getByHashCode($pHashCode = '') public function getByHashCode($pHashCode = '')
@ -199,9 +187,7 @@ class PHPWord_HashTable
} }
/** /**
* HashTable to array * @return PhpOffice\PhpWord\IComparable[]
*
* @return PHPWord_IComparable[]
*/ */
public function toArray() public function toArray()
{ {
@ -220,4 +206,4 @@ class PHPWord_HashTable
} }
} }
} }
} }

View File

@ -25,10 +25,11 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord;
* Class PHPWord_Media
*/ use PhpOffice\PhpWord\Section\MemoryImage;
class PHPWord_Media
class Media
{ {
/** /**
* Section Media Elements * Section Media Elements
@ -67,10 +68,10 @@ class PHPWord_Media
* *
* @param string $src * @param string $src
* @param string $type * @param string $type
* @param PHPWord_Section_MemoryImage|null $memoryImage * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage
* @return mixed * @return mixed
*/ */
public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null)
{ {
$mediaId = md5($src); $mediaId = md5($src);
$key = ($type === 'image') ? 'images' : 'embeddings'; $key = ($type === 'image') ? 'images' : 'embeddings';
@ -205,10 +206,10 @@ class PHPWord_Media
* *
* @param int $headerCount * @param int $headerCount
* @param string $src * @param string $src
* @param PHPWord_Section_MemoryImage|null $memoryImage * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage
* @return int * @return int
*/ */
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null)
{ {
$mediaId = md5($src); $mediaId = md5($src);
$key = 'header' . $headerCount; $key = 'header' . $headerCount;
@ -277,10 +278,10 @@ class PHPWord_Media
* *
* @param int $footerCount * @param int $footerCount
* @param string $src * @param string $src
* @param PHPWord_Section_MemoryImage|null $memoryImage * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage
* @return int * @return int
*/ */
public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null)
{ {
$mediaId = md5($src); $mediaId = md5($src);
$key = 'footer' . $footerCount; $key = 'footer' . $footerCount;

View File

@ -25,13 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Reader;
* PHPWord_Reader_IReader
*/ interface IReader
interface PHPWord_Reader_IReader
{ {
/** /**
* Can the current PHPWord_Reader_IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return boolean * @return boolean

View File

@ -25,21 +25,22 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\File;
/** PHPWord root directory */ /** PHPWord root directory */
if (!defined('PHPWORD_BASE_PATH')) { if (!defined('PHPWORD_BASE_PATH')) {
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/../../'); define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/../../');
require(PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php'); require(PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php');
} }
use PhpOffice\PhpWord\Exceptions\Exception; class Word2007 extends AbstractReader implements IReader
/**
* PHPWord_Reader_Word2007
*/
class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
{ {
/** /**
* Can the current PHPWord_Reader_IReader read the file? * Can the current IReader read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return bool * @return bool
@ -90,7 +91,7 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
if (strpos($fileName, '//') !== false) { if (strpos($fileName, '//') !== false) {
$fileName = substr($fileName, strpos($fileName, '//') + 1); $fileName = substr($fileName, strpos($fileName, '//') + 1);
} }
$fileName = PHPWord_Shared_File::realpath($fileName); $fileName = File::realpath($fileName);
// Apache POI fixes // Apache POI fixes
$contents = $archive->getFromName($fileName); $contents = $archive->getFromName($fileName);
@ -172,8 +173,8 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
$cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); $cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
$attributeType = $cellDataOfficeChildren->getName(); $attributeType = $cellDataOfficeChildren->getName();
$attributeValue = (string)$cellDataOfficeChildren->{$attributeType}; $attributeValue = (string)$cellDataOfficeChildren->{$attributeType};
$attributeValue = PHPWord_DocumentProperties::convertProperty($attributeValue, $attributeType); $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType);
$attributeType = PHPWord_DocumentProperties::convertPropertyType($attributeType); $attributeType = DocumentProperties::convertPropertyType($attributeType);
$docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
} }
} }

View File

@ -25,12 +25,26 @@
* @version 0.8.0 * @version 0.8.0
*/ */
use PhpOffice\PhpWord\Exceptions\Exception; namespace PhpOffice\PhpWord;
/** use PhpOffice\PhpWord\Exceptions\Exception;
* Class PHPWord_Section use PhpOffice\PhpWord\Section\Footer;
*/ use PhpOffice\PhpWord\Section\Footnote;
class PHPWord_Section 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\Settings;
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\String;
class Section
{ {
/** /**
* Section count * Section count
@ -42,7 +56,7 @@ class PHPWord_Section
/** /**
* Section settings * Section settings
* *
* @var PHPWord_Section_Settings * @var PhpOffice\PhpWord\Section\Settings
*/ */
private $_settings; private $_settings;
@ -63,7 +77,7 @@ class PHPWord_Section
/** /**
* Section Footer * Section Footer
* *
* @var PHPWord_Section_Footer * @var PhpOffice\PhpWord\Section\Footer
*/ */
private $_footer = null; private $_footer = null;
@ -77,7 +91,7 @@ class PHPWord_Section
public function __construct($sectionCount, $settings = null) public function __construct($sectionCount, $settings = null)
{ {
$this->_sectionCount = $sectionCount; $this->_sectionCount = $sectionCount;
$this->_settings = new PHPWord_Section_Settings(); $this->_settings = new Settings();
$this->setSettings($settings); $this->setSettings($settings);
} }
@ -101,7 +115,7 @@ class PHPWord_Section
/** /**
* Get Section Settings * Get Section Settings
* *
* @return PHPWord_Section_Settings * @return PhpOffice\PhpWord\Section\Settings
*/ */
public function getSettings() public function getSettings()
{ {
@ -114,14 +128,14 @@ class PHPWord_Section
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text, $styleFont = null, $styleParagraph = null) public function addText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); $text = new Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -133,21 +147,21 @@ class PHPWord_Section
* @param string $linkName * @param string $linkName
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Link * @return PhpOffice\PhpWord\Section\Link
*/ */
public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { if (!String::IsUTF8($linkSrc)) {
$linkSrc = utf8_encode($linkSrc); $linkSrc = utf8_encode($linkSrc);
} }
if (!is_null($linkName)) { if (!is_null($linkName)) {
if (!PHPWord_Shared_String::IsUTF8($linkName)) { if (!String::IsUTF8($linkName)) {
$linkName = utf8_encode($linkName); $linkName = utf8_encode($linkName);
} }
} }
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph); $link = new Link($linkSrc, $linkName, $styleFont, $styleParagraph);
$rID = PHPWord_Media::addSectionLinkElement($linkSrc); $rID = Media::addSectionLinkElement($linkSrc);
$link->setRelationId($rID); $link->setRelationId($rID);
$this->_elementCollection[] = $link; $this->_elementCollection[] = $link;
@ -157,14 +171,14 @@ class PHPWord_Section
/** /**
* Add a TextBreak Element * Add a TextBreak Element
* *
* @param int $count * @param int $count
* @param null|string|array|PHPWord_Style_Font $fontStyle * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
{ {
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle);
} }
} }
@ -173,18 +187,18 @@ class PHPWord_Section
*/ */
public function addPageBreak() public function addPageBreak()
{ {
$this->_elementCollection[] = new PHPWord_Section_PageBreak(); $this->_elementCollection[] = new PageBreak();
} }
/** /**
* Add a Table Element * Add a Table Element
* *
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Table * @return PhpOffice\PhpWord\Section\Table
*/ */
public function addTable($style = null) public function addTable($style = null)
{ {
$table = new PHPWord_Section_Table('section', $this->_sectionCount, $style); $table = new Table('section', $this->_sectionCount, $style);
$this->_elementCollection[] = $table; $this->_elementCollection[] = $table;
return $table; return $table;
} }
@ -197,14 +211,14 @@ class PHPWord_Section
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleList * @param mixed $styleList
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_ListItem * @return PhpOffice\PhpWord\Section\ListItem
*/ */
public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); $listItem = new ListItem($text, $depth, $styleFont, $styleList, $styleParagraph);
$this->_elementCollection[] = $listItem; $this->_elementCollection[] = $listItem;
return $listItem; return $listItem;
} }
@ -214,12 +228,12 @@ class PHPWord_Section
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Object * @return PhpOffice\PhpWord\Section\Object
* @throws Exception * @throws Exception
*/ */
public function addObject($src, $style = null) public function addObject($src, $style = null)
{ {
$object = new PHPWord_Section_Object($src, $style); $object = new Object($src, $style);
if (!is_null($object->getSource())) { if (!is_null($object->getSource())) {
$inf = pathinfo($src); $inf = pathinfo($src);
@ -235,8 +249,8 @@ class PHPWord_Section
$iconSrc .= '_' . $ext . '.png'; $iconSrc .= '_' . $ext . '.png';
} }
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); $rIDimg = Media::addSectionMediaElement($iconSrc, 'image');
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject'); $data = Media::addSectionMediaElement($src, 'oleObject');
$rID = $data[0]; $rID = $data[0];
$objectId = $data[1]; $objectId = $data[1];
@ -255,15 +269,15 @@ class PHPWord_Section
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Image * @return PhpOffice\PhpWord\Section\Image
* @throws Exception * @throws Exception
*/ */
public function addImage($src, $style = null) public function addImage($src, $style = null)
{ {
$image = new PHPWord_Section_Image($src, $style); $image = new Image($src, $style);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
$rID = PHPWord_Media::addSectionMediaElement($src, 'image'); $rID = Media::addSectionMediaElement($src, 'image');
$image->setRelationId($rID); $image->setRelationId($rID);
$this->_elementCollection[] = $image; $this->_elementCollection[] = $image;
@ -277,14 +291,14 @@ class PHPWord_Section
* *
* @param string $link * @param string $link
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_MemoryImage * @return PhpOffice\PhpWord\Section\MemoryImage
* @throws Exception * @throws Exception
*/ */
public function addMemoryImage($link, $style = null) public function addMemoryImage($link, $style = null)
{ {
$memoryImage = new PHPWord_Section_MemoryImage($link, $style); $memoryImage = new MemoryImage($link, $style);
if (!is_null($memoryImage->getSource())) { if (!is_null($memoryImage->getSource())) {
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); $rID = Media::addSectionMediaElement($link, 'image', $memoryImage);
$memoryImage->setRelationId($rID); $memoryImage->setRelationId($rID);
$this->_elementCollection[] = $memoryImage; $this->_elementCollection[] = $memoryImage;
@ -298,11 +312,11 @@ class PHPWord_Section
* *
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleTOC * @param mixed $styleTOC
* @return PHPWord_TOC * @return PhpOffice\PhpWord\TOC
*/ */
public function addTOC($styleFont = null, $styleTOC = null) public function addTOC($styleFont = null, $styleTOC = null)
{ {
$toc = new PHPWord_TOC($styleFont, $styleTOC); $toc = new TOC($styleFont, $styleTOC);
$this->_elementCollection[] = $toc; $this->_elementCollection[] = $toc;
return $toc; return $toc;
} }
@ -312,23 +326,23 @@ class PHPWord_Section
* *
* @param string $text * @param string $text
* @param int $depth * @param int $depth
* @return PHPWord_Section_Title * @return PhpOffice\PhpWord\Section\Title
*/ */
public function addTitle($text, $depth = 1) public function addTitle($text, $depth = 1)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$styles = PHPWord_Style::getStyles(); $styles = Style::getStyles();
if (array_key_exists('Heading_' . $depth, $styles)) { if (array_key_exists('Heading_' . $depth, $styles)) {
$style = 'Heading' . $depth; $style = 'Heading' . $depth;
} else { } else {
$style = null; $style = null;
} }
$title = new PHPWord_Section_Title($text, $depth, $style); $title = new Title($text, $depth, $style);
$data = PHPWord_TOC::addTitle($text, $depth); $data = TOC::addTitle($text, $depth);
$anchor = $data[0]; $anchor = $data[0];
$bookmarkId = $data[1]; $bookmarkId = $data[1];
@ -343,11 +357,11 @@ class PHPWord_Section
* Create a new TextRun * Create a new TextRun
* *
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_TextRun * @return PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)
{ {
$textRun = new PHPWord_Section_TextRun($styleParagraph); $textRun = new TextRun($styleParagraph);
$this->_elementCollection[] = $textRun; $this->_elementCollection[] = $textRun;
return $textRun; return $textRun;
} }
@ -365,11 +379,11 @@ class PHPWord_Section
/** /**
* Create a new Header * Create a new Header
* *
* @return PHPWord_Section_Header * @return PhpOffice\PhpWord\Section\Header
*/ */
public function createHeader() public function createHeader()
{ {
$header = new PHPWord_Section_Header($this->_sectionCount); $header = new Header($this->_sectionCount);
$this->_headers[] = $header; $this->_headers[] = $header;
return $header; return $header;
} }
@ -387,16 +401,15 @@ class PHPWord_Section
/** /**
* Is there a header for this section that is for the first page only? * Is there a header for this section that is for the first page only?
* *
* If any of the PHPWord_Section_Header instances have a type of * If any of the Header instances have a type of Header::FIRST then this method returns true.
* PHPWord_Section_Header::FIRST then this method returns true. False * False otherwise.
* otherwise.
* *
* @return Boolean * @return Boolean
*/ */
public function hasDifferentFirstPage() public function hasDifferentFirstPage()
{ {
$value = array_filter($this->_headers, function (PHPWord_Section_Header &$header) { $value = array_filter($this->_headers, function (Header &$header) {
return $header->getType() == PHPWord_Section_Header::FIRST; return $header->getType() == Header::FIRST;
}); });
return count($value) > 0; return count($value) > 0;
} }
@ -404,11 +417,11 @@ class PHPWord_Section
/** /**
* Create a new Footer * Create a new Footer
* *
* @return PHPWord_Section_Footer * @return PhpOffice\PhpWord\Section\Footer
*/ */
public function createFooter() public function createFooter()
{ {
$footer = new PHPWord_Section_Footer($this->_sectionCount); $footer = new Footer($this->_sectionCount);
$this->_footer = $footer; $this->_footer = $footer;
return $footer; return $footer;
} }
@ -416,7 +429,7 @@ class PHPWord_Section
/** /**
* Get Footer * Get Footer
* *
* @return PHPWord_Section_Footer * @return PhpOffice\PhpWord\Section\Footer
*/ */
public function getFooter() public function getFooter()
{ {
@ -427,12 +440,12 @@ class PHPWord_Section
* Create a new Footnote Element * Create a new Footnote Element
* *
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Footnote * @return PhpOffice\PhpWord\Section\Footnote
*/ */
public function createFootnote($styleParagraph = null) public function createFootnote($styleParagraph = null)
{ {
$footnote = new PHPWord_Section_Footnote($styleParagraph); $footnote = new Footnote($styleParagraph);
$refID = PHPWord_Footnote::addFootnoteElement($footnote); $refID = Footnote::addFootnoteElement($footnote);
$footnote->setReferenceId($refID); $footnote->setReferenceId($refID);
$this->_elementCollection[] = $footnote; $this->_elementCollection[] = $footnote;
return $footnote; return $footnote;

View File

@ -25,12 +25,14 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* PHPWord_Section_Footer
*/
class PHPWord_Section_Footer
{
use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String;
class Footer
{
/** /**
* Footer Count * Footer Count
* *
@ -66,14 +68,14 @@ class PHPWord_Section_Footer
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text, $styleFont = null, $styleParagraph = null) public function addText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); $text = new Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -81,25 +83,25 @@ class PHPWord_Section_Footer
/** /**
* Add TextBreak * Add TextBreak
* *
* @param int $count * @param int $count
* @param null|string|array|PHPWord_Style_Font $fontStyle * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
{ {
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle);
} }
} }
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @return PHPWord_Section_TextRun * @return PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)
{ {
$textRun = new PHPWord_Section_TextRun($styleParagraph); $textRun = new TextRun($styleParagraph);
$this->_elementCollection[] = $textRun; $this->_elementCollection[] = $textRun;
return $textRun; return $textRun;
} }
@ -108,11 +110,11 @@ class PHPWord_Section_Footer
* Add a Table Element * Add a Table Element
* *
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Table * @return PhpOffice\PhpWord\Section\Table
*/ */
public function addTable($style = null) public function addTable($style = null)
{ {
$table = new PHPWord_Section_Table('footer', $this->_footerCount, $style); $table = new Table('footer', $this->_footerCount, $style);
$this->_elementCollection[] = $table; $this->_elementCollection[] = $table;
return $table; return $table;
} }
@ -122,14 +124,14 @@ class PHPWord_Section_Footer
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Image * @return Image
*/ */
public function addImage($src, $style = null) public function addImage($src, $style = null)
{ {
$image = new PHPWord_Section_Image($src, $style); $image = new Image($src, $style);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src); $rID = Media::addFooterMediaElement($this->_footerCount, $src);
$image->setRelationId($rID); $image->setRelationId($rID);
$this->_elementCollection[] = $image; $this->_elementCollection[] = $image;
@ -144,13 +146,13 @@ class PHPWord_Section_Footer
* *
* @param string $link * @param string $link
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_MemoryImage * @return PhpOffice\PhpWord\Section\MemoryImage
*/ */
public function addMemoryImage($link, $style = null) public function addMemoryImage($link, $style = null)
{ {
$memoryImage = new PHPWord_Section_MemoryImage($link, $style); $memoryImage = new MemoryImage($link, $style);
if (!is_null($memoryImage->getSource())) { if (!is_null($memoryImage->getSource())) {
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); $rID = Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage);
$memoryImage->setRelationId($rID); $memoryImage->setRelationId($rID);
$this->_elementCollection[] = $memoryImage; $this->_elementCollection[] = $memoryImage;
@ -166,14 +168,14 @@ class PHPWord_Section_Footer
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Footer_PreserveText * @return PhpOffice\PhpWord\Section\Footer\PreserveText
*/ */
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); $ptext = new PreserveText($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $ptext; $this->_elementCollection[] = $ptext;
return $ptext; return $ptext;
} }

View File

@ -25,12 +25,13 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section\Footer;
* Class PHPWord_Section_Footer_PreserveText
*/
class PHPWord_Section_Footer_PreserveText
{
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
class PreserveText
{
/** /**
* Text content * Text content
* *
@ -41,14 +42,14 @@ class PHPWord_Section_Footer_PreserveText
/** /**
* Text style * Text style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Font
*/ */
private $_styleFont; private $_styleFont;
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_styleParagraph; private $_styleParagraph;
@ -63,7 +64,7 @@ class PHPWord_Section_Footer_PreserveText
{ {
// Set font style // Set font style
if (is_array($styleFont)) { if (is_array($styleFont)) {
$this->_styleFont = new PHPWord_Style_Font('text'); $this->_styleFont = new Font('text');
foreach ($styleFont as $key => $value) { foreach ($styleFont as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -77,7 +78,7 @@ class PHPWord_Section_Footer_PreserveText
// Set paragraph style // Set paragraph style
if (is_array($styleParagraph)) { if (is_array($styleParagraph)) {
$this->_styleParagraph = new PHPWord_Style_Paragraph(); $this->_styleParagraph = new Paragraph();
foreach ($styleParagraph as $key => $value) { foreach ($styleParagraph as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -100,7 +101,7 @@ class PHPWord_Section_Footer_PreserveText
/** /**
* Get Text style * Get Text style
* *
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -110,7 +111,7 @@ class PHPWord_Section_Footer_PreserveText
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {

View File

@ -25,16 +25,16 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* PHPWord_Section_Footnote
*/
class PHPWord_Section_Footnote
{
use PhpOffice\PhpWord\Style\Paragraph;
class Footnote
{
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_styleParagraph; private $_styleParagraph;
@ -61,7 +61,7 @@ class PHPWord_Section_Footnote
// Set paragraph style // Set paragraph style
if (is_array($styleParagraph)) { if (is_array($styleParagraph)) {
$this->_styleParagraph = new PHPWord_Style_Paragraph(); $this->_styleParagraph = new Paragraph();
foreach ($styleParagraph as $key => $value) { foreach ($styleParagraph as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -80,12 +80,12 @@ class PHPWord_Section_Footnote
* *
* @var string $text * @var string $text
* @var mixed $styleFont * @var mixed $styleFont
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text = null, $styleFont = null) public function addText($text = null, $styleFont = null)
{ {
$givenText = $text; $givenText = $text;
$text = new PHPWord_Section_Text($givenText, $styleFont); $text = new Text($givenText, $styleFont);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -96,13 +96,13 @@ class PHPWord_Section_Footnote
* @param string $linkSrc * @param string $linkSrc
* @param string $linkName * @param string $linkName
* @param mixed $styleFont * @param mixed $styleFont
* @return PHPWord_Section_Link * @return PhpOffice\PhpWord\Section\Link
*/ */
public function addLink($linkSrc, $linkName = null, $styleFont = null) public function addLink($linkSrc, $linkName = null, $styleFont = null)
{ {
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); $link = new Link($linkSrc, $linkName, $styleFont);
$rID = PHPWord_Footnote::addFootnoteLinkElement($linkSrc); $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc);
$link->setRelationId($rID); $link->setRelationId($rID);
$this->_elementCollection[] = $link; $this->_elementCollection[] = $link;
@ -122,7 +122,7 @@ class PHPWord_Section_Footnote
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {

View File

@ -25,12 +25,14 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* PHPWord_Section_Header
*/
class PHPWord_Section_Header
{
use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String;
class Header
{
/** /**
* Header Count * Header Count
* *
@ -51,7 +53,7 @@ class PHPWord_Section_Header
* @var string * @var string
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type * @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
*/ */
private $_type = PHPWord_Section_Header::AUTO; private $_type = self::AUTO;
/** /**
* Even Numbered Pages Only * Even Numbered Pages Only
@ -95,14 +97,14 @@ class PHPWord_Section_Header
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text, $styleFont = null, $styleParagraph = null) public function addText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); $text = new Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -110,25 +112,25 @@ class PHPWord_Section_Header
/** /**
* Add TextBreak * Add TextBreak
* *
* @param int $count * @param int $count
* @param null|string|array|PHPWord_Style_Font $fontStyle * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
{ {
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle);
} }
} }
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @return PHPWord_Section_TextRun * @return PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)
{ {
$textRun = new PHPWord_Section_TextRun($styleParagraph); $textRun = new TextRun($styleParagraph);
$this->_elementCollection[] = $textRun; $this->_elementCollection[] = $textRun;
return $textRun; return $textRun;
} }
@ -137,11 +139,11 @@ class PHPWord_Section_Header
* Add a Table Element * Add a Table Element
* *
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Table * @return PhpOffice\PhpWord\Section\Table
*/ */
public function addTable($style = null) public function addTable($style = null)
{ {
$table = new PHPWord_Section_Table('header', $this->_headerCount, $style); $table = new Table('header', $this->_headerCount, $style);
$this->_elementCollection[] = $table; $this->_elementCollection[] = $table;
return $table; return $table;
} }
@ -151,14 +153,14 @@ class PHPWord_Section_Header
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Image * @return PhpOffice\PhpWord\Section\Image
*/ */
public function addImage($src, $style = null) public function addImage($src, $style = null)
{ {
$image = new PHPWord_Section_Image($src, $style); $image = new Image($src, $style);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); $rID = Media::addHeaderMediaElement($this->_headerCount, $src);
$image->setRelationId($rID); $image->setRelationId($rID);
$this->_elementCollection[] = $image; $this->_elementCollection[] = $image;
@ -173,13 +175,13 @@ class PHPWord_Section_Header
* *
* @param string $link * @param string $link
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_MemoryImage * @return PhpOffice\PhpWord\Section\MemoryImage
*/ */
public function addMemoryImage($link, $style = null) public function addMemoryImage($link, $style = null)
{ {
$memoryImage = new PHPWord_Section_MemoryImage($link, $style); $memoryImage = new MemoryImage($link, $style);
if (!is_null($memoryImage->getSource())) { if (!is_null($memoryImage->getSource())) {
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); $rID = Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage);
$memoryImage->setRelationId($rID); $memoryImage->setRelationId($rID);
$this->_elementCollection[] = $memoryImage; $this->_elementCollection[] = $memoryImage;
@ -195,14 +197,14 @@ class PHPWord_Section_Header
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Footer_PreserveText * @return PhpOffice\PhpWord\Section\Footer\PreserveText
*/ */
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); $ptext = new PreserveText($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $ptext; $this->_elementCollection[] = $ptext;
return $ptext; return $ptext;
} }
@ -212,14 +214,14 @@ class PHPWord_Section_Header
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Image * @return PhpOffice\PhpWord\Section\Image
*/ */
public function addWatermark($src, $style = null) public function addWatermark($src, $style = null)
{ {
$image = new PHPWord_Section_Image($src, $style, true); $image = new Image($src, $style, true);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src); $rID = Media::addHeaderMediaElement($this->_headerCount, $src);
$image->setRelationId($rID); $image->setRelationId($rID);
$this->_elementCollection[] = $image; $this->_elementCollection[] = $image;
@ -276,7 +278,7 @@ class PHPWord_Section_Header
*/ */
public function resetType() public function resetType()
{ {
return $this->_type = PHPWord_Section_Header::AUTO; return $this->_type = self::AUTO;
} }
/** /**
@ -284,7 +286,7 @@ class PHPWord_Section_Header
*/ */
public function firstPage() public function firstPage()
{ {
return $this->_type = PHPWord_Section_Header::FIRST; return $this->_type = self::FIRST;
} }
/** /**
@ -292,6 +294,6 @@ class PHPWord_Section_Header
*/ */
public function evenPage() public function evenPage()
{ {
return $this->_type = PHPWord_Section_Header::EVEN; return $this->_type = self::EVEN;
} }
} }

View File

@ -25,13 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Exceptions\InvalidImageException;
use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
/** class Image
* Class PHPWord_Section_Image
*/
class PHPWord_Section_Image
{ {
/** /**
* Image Src * Image Src
@ -43,7 +42,7 @@ class PHPWord_Section_Image
/** /**
* Image Style * Image Style
* *
* @var PHPWord_Style_Image * @var PhpOffice\PhpWord\Style\Image
*/ */
private $_style; private $_style;
@ -84,7 +83,7 @@ class PHPWord_Section_Image
$this->_src = $src; $this->_src = $src;
$this->_isWatermark = $isWatermark; $this->_isWatermark = $isWatermark;
$this->_style = new PHPWord_Style_Image(); $this->_style = new PhpOffice\PhpWord\Style\Image();
if (!is_null($style) && is_array($style)) { if (!is_null($style) && is_array($style)) {
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
@ -109,7 +108,7 @@ class PHPWord_Section_Image
/** /**
* Get Image style * Get Image style
* *
* @return PHPWord_Style_Image * @return PhpOffice\PhpWord\Style\Image
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,12 +25,13 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Link
*/
class PHPWord_Section_Link
{
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
class Link
{
/** /**
* Link source * Link source
* *
@ -55,14 +56,14 @@ class PHPWord_Section_Link
/** /**
* Link style * Link style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Font
*/ */
private $_styleFont; private $_styleFont;
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_styleParagraph; private $_styleParagraph;
@ -82,7 +83,7 @@ class PHPWord_Section_Link
// Set font style // Set font style
if (is_array($styleFont)) { if (is_array($styleFont)) {
$this->_styleFont = new PHPWord_Style_Font('text'); $this->_styleFont = new Font('text');
foreach ($styleFont as $key => $value) { foreach ($styleFont as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -96,7 +97,7 @@ class PHPWord_Section_Link
// Set paragraph style // Set paragraph style
if (is_array($styleParagraph)) { if (is_array($styleParagraph)) {
$this->_styleParagraph = new PHPWord_Style_Paragraph(); $this->_styleParagraph = new Paragraph();
foreach ($styleParagraph as $key => $value) { foreach ($styleParagraph as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -154,7 +155,7 @@ class PHPWord_Section_Link
/** /**
* Get Text style * Get Text style
* *
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -164,7 +165,7 @@ class PHPWord_Section_Link
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {

View File

@ -25,23 +25,21 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_ListItem
*/
class PHPWord_Section_ListItem
{
class ListItem
{
/** /**
* ListItem Style * ListItem Style
* *
* @var PHPWord_Style_ListItem * @var PhpOffice\PhpWord\Style\ListItem
*/ */
private $_style; private $_style;
/** /**
* Textrun * Textrun
* *
* @var PHPWord_Section_Text * @var PhpOffice\PhpWord\Section\Text
*/ */
private $_textObject; private $_textObject;
@ -63,8 +61,8 @@ class PHPWord_Section_ListItem
*/ */
public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null)
{ {
$this->_style = new PHPWord_Style_ListItem(); $this->_style = new PhpOffice\PhpWord\Style\ListItem();
$this->_textObject = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); $this->_textObject = new Text($text, $styleFont, $styleParagraph);
$this->_depth = $depth; $this->_depth = $depth;
if (!is_null($styleList) && is_array($styleList)) { if (!is_null($styleList) && is_array($styleList)) {

View File

@ -25,10 +25,11 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_MemoryImage
*/ use PhpOffice\PhpWord\Style\Image;
class PHPWord_Section_MemoryImage
class MemoryImage
{ {
/** /**
* Image Src * Image Src
@ -40,7 +41,7 @@ class PHPWord_Section_MemoryImage
/** /**
* Image Style * Image Style
* *
* @var PHPWord_Style_Image * @var PhpOffice\PhpWord\Style\Image
*/ */
private $_style; private $_style;
@ -95,7 +96,7 @@ class PHPWord_Section_MemoryImage
if (in_array($this->_imageType, $_supportedImageTypes)) { if (in_array($this->_imageType, $_supportedImageTypes)) {
$this->_src = $src; $this->_src = $src;
$this->_style = new PHPWord_Style_Image(); $this->_style = new Image();
if (!is_null($style) && is_array($style)) { if (!is_null($style) && is_array($style)) {
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
@ -143,7 +144,7 @@ class PHPWord_Section_MemoryImage
/** /**
* Get Image style * Get Image style
* *
* @return PHPWord_Style_Image * @return PhpOffice\PhpWord\Style\Image
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Object
*/
class PHPWord_Section_Object
{
use PhpOffice\PhpWord\Style\Image;
class Object
{
/** /**
* Ole-Object Src * Ole-Object Src
* *
@ -41,7 +41,7 @@ class PHPWord_Section_Object
/** /**
* Image Style * Image Style
* *
* @var PHPWord_Style_Image * @var PhpOffice\PhpWord\Style\Image
*/ */
private $_style; private $_style;
@ -80,7 +80,7 @@ class PHPWord_Section_Object
if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
$this->_src = $src; $this->_src = $src;
$this->_style = new PHPWord_Style_Image(); $this->_style = new Image();
if (!is_null($style) && is_array($style)) { if (!is_null($style) && is_array($style)) {
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
@ -100,7 +100,7 @@ class PHPWord_Section_Object
/** /**
* Get Image style * Get Image style
* *
* @return PHPWord_Style_Image * @return PhpOffice\PhpWord\Style\Image
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,16 +25,14 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_PageBreak
*/
class PHPWord_Section_PageBreak
{
class PageBreak
{
/** /**
* Create a new PageBreak Element * Create a new PageBreak Element
*/ */
public function __construct() public function __construct()
{ {
} }
} }

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Settings
*/
class PHPWord_Section_Settings
{
class Settings
{
/** /**
* Default Page Size Width * Default Page Size Width
* *

View File

@ -25,16 +25,16 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Table
*/
class PHPWord_Section_Table
{
use PhpOffice\PhpWord\Section\Table\Row;
class Table
{
/** /**
* Table style * Table style
* *
* @var PHPWord_Style_Table * @var PhpOffice\PhpWord\Style\Table
*/ */
private $_style; private $_style;
@ -81,7 +81,7 @@ class PHPWord_Section_Table
if (!is_null($style)) { if (!is_null($style)) {
if (is_array($style)) { if (is_array($style)) {
$this->_style = new PHPWord_Style_Table(); $this->_style = new PhpOffice\PhpWord\Style\Table();
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -102,7 +102,7 @@ class PHPWord_Section_Table
*/ */
public function addRow($height = null, $style = null) public function addRow($height = null, $style = null)
{ {
$row = new PHPWord_Section_Table_Row($this->_insideOf, $this->_pCount, $height, $style); $row = new Row($this->_insideOf, $this->_pCount, $height, $style);
$this->_rows[] = $row; $this->_rows[] = $row;
return $row; return $row;
} }
@ -112,7 +112,7 @@ class PHPWord_Section_Table
* *
* @param int $width * @param int $width
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Table_Cell * @return PhpOffice\PhpWord\Section\Table\Cell
*/ */
public function addCell($width = null, $style = null) public function addCell($width = null, $style = null)
{ {
@ -134,7 +134,7 @@ class PHPWord_Section_Table
/** /**
* Get table style * Get table style
* *
* @return PHPWord_Style_Table * @return PhpOffice\PhpWord\Style\Table
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,12 +25,22 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section\Table;
* PHPWord_Section_Table_Cell
*/
class PHPWord_Section_Table_Cell
{
use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText;
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\Text;
use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\String;
class Cell
{
/** /**
* Cell Width * Cell Width
* *
@ -41,7 +51,7 @@ class PHPWord_Section_Table_Cell
/** /**
* Cell Style * Cell Style
* *
* @var PHPWord_Style_Cell * @var PhpOffice\PhpWord\Style\Cell
*/ */
private $_style; private $_style;
@ -80,7 +90,7 @@ class PHPWord_Section_Table_Cell
$this->_insideOf = $insideOf; $this->_insideOf = $insideOf;
$this->_pCount = $pCount; $this->_pCount = $pCount;
$this->_width = $width; $this->_width = $width;
$this->_style = new PHPWord_Style_Cell; $this->_style = new PhpOffice\PhpWord\Style\Cell();
if (!is_null($style)) { if (!is_null($style)) {
if (is_array($style)) { if (is_array($style)) {
@ -101,14 +111,14 @@ class PHPWord_Section_Table_Cell
* *
* @param string $text * @param string $text
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text, $styleFont = null, $styleParagraph = null) public function addText($text, $styleFont = null, $styleParagraph = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph); $text = new Text($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -119,22 +129,22 @@ class PHPWord_Section_Table_Cell
* @param string $linkSrc * @param string $linkSrc
* @param string $linkName * @param string $linkName
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Link * @return PhpOffice\PhpWord\Section\Link
*/ */
public function addLink($linkSrc, $linkName = null, $style = null) public function addLink($linkSrc, $linkName = null, $style = null)
{ {
if ($this->_insideOf == 'section') { if ($this->_insideOf == 'section') {
if (!PHPWord_Shared_String::IsUTF8($linkSrc)) { if (!String::IsUTF8($linkSrc)) {
$linkSrc = utf8_encode($linkSrc); $linkSrc = utf8_encode($linkSrc);
} }
if (!is_null($linkName)) { if (!is_null($linkName)) {
if (!PHPWord_Shared_String::IsUTF8($linkName)) { if (!String::IsUTF8($linkName)) {
$linkName = utf8_encode($linkName); $linkName = utf8_encode($linkName);
} }
} }
$link = new PHPWord_Section_Link($linkSrc, $linkName, $style); $link = new Link($linkSrc, $linkName, $style);
$rID = PHPWord_Media::addSectionLinkElement($linkSrc); $rID = Media::addSectionLinkElement($linkSrc);
$link->setRelationId($rID); $link->setRelationId($rID);
$this->_elementCollection[] = $link; $this->_elementCollection[] = $link;
@ -148,14 +158,14 @@ class PHPWord_Section_Table_Cell
/** /**
* Add TextBreak * Add TextBreak
* *
* @param int $count * @param int $count
* @param null|string|array|PHPWord_Style_Font $fontStyle * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
{ {
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle);
} }
} }
@ -166,14 +176,14 @@ class PHPWord_Section_Table_Cell
* @param int $depth * @param int $depth
* @param mixed $styleText * @param mixed $styleText
* @param mixed $styleList * @param mixed $styleList
* @return PHPWord_Section_ListItem * @return PhpOffice\PhpWord\Section\ListItem
*/ */
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) public function addListItem($text, $depth = 0, $styleText = null, $styleList = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList); $listItem = new ListItem($text, $depth, $styleText, $styleList);
$this->_elementCollection[] = $listItem; $this->_elementCollection[] = $listItem;
return $listItem; return $listItem;
} }
@ -183,19 +193,19 @@ class PHPWord_Section_Table_Cell
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Image * @return PhpOffice\PhpWord\Section\Image
*/ */
public function addImage($src, $style = null) public function addImage($src, $style = null)
{ {
$image = new PHPWord_Section_Image($src, $style); $image = new Image($src, $style);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
if ($this->_insideOf == 'section') { if ($this->_insideOf == 'section') {
$rID = PHPWord_Media::addSectionMediaElement($src, 'image'); $rID = Media::addSectionMediaElement($src, 'image');
} elseif ($this->_insideOf == 'header') { } elseif ($this->_insideOf == 'header') {
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src); $rID = Media::addHeaderMediaElement($this->_pCount, $src);
} elseif ($this->_insideOf == 'footer') { } elseif ($this->_insideOf == 'footer') {
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src); $rID = Media::addFooterMediaElement($this->_pCount, $src);
} }
$image->setRelationId($rID); $image->setRelationId($rID);
@ -211,18 +221,18 @@ class PHPWord_Section_Table_Cell
* *
* @param string $link * @param string $link
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_MemoryImage * @return PhpOffice\PhpWord\Section\MemoryImage
*/ */
public function addMemoryImage($link, $style = null) public function addMemoryImage($link, $style = null)
{ {
$memoryImage = new PHPWord_Section_MemoryImage($link, $style); $memoryImage = new MemoryImage($link, $style);
if (!is_null($memoryImage->getSource())) { if (!is_null($memoryImage->getSource())) {
if ($this->_insideOf == 'section') { if ($this->_insideOf == 'section') {
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage); $rID = Media::addSectionMediaElement($link, 'image', $memoryImage);
} elseif ($this->_insideOf == 'header') { } elseif ($this->_insideOf == 'header') {
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); $rID = Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
} elseif ($this->_insideOf == 'footer') { } elseif ($this->_insideOf == 'footer') {
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); $rID = Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
} }
$memoryImage->setRelationId($rID); $memoryImage->setRelationId($rID);
@ -238,11 +248,11 @@ class PHPWord_Section_Table_Cell
* *
* @param string $src * @param string $src
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Object * @return PhpOffice\PhpWord\Section\Object
*/ */
public function addObject($src, $style = null) public function addObject($src, $style = null)
{ {
$object = new PHPWord_Section_Object($src, $style); $object = new Object($src, $style);
if (!is_null($object->getSource())) { if (!is_null($object->getSource())) {
$inf = pathinfo($src); $inf = pathinfo($src);
@ -258,8 +268,8 @@ class PHPWord_Section_Table_Cell
$iconSrc .= '_' . $ext . '.png'; $iconSrc .= '_' . $ext . '.png';
} }
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image'); $rIDimg = Media::addSectionMediaElement($iconSrc, 'image');
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject'); $data = Media::addSectionMediaElement($src, 'oleObject');
$rID = $data[0]; $rID = $data[0];
$objectId = $data[1]; $objectId = $data[1];
@ -280,15 +290,15 @@ class PHPWord_Section_Table_Cell
* @param string $text * @param string $text
* @param mixed $styleFont * @param mixed $styleFont
* @param mixed $styleParagraph * @param mixed $styleParagraph
* @return PHPWord_Section_Footer_PreserveText * @return PhpOffice\PhpWord\Section\Footer\PreserveText
*/ */
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
{ {
if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph); $ptext = new PreserveText($text, $styleFont, $styleParagraph);
$this->_elementCollection[] = $ptext; $this->_elementCollection[] = $ptext;
return $ptext; return $ptext;
} else { } else {
@ -299,11 +309,11 @@ class PHPWord_Section_Table_Cell
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @return PHPWord_Section_TextRun * @return PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)
{ {
$textRun = new PHPWord_Section_TextRun($styleParagraph); $textRun = new TextRun($styleParagraph);
$this->_elementCollection[] = $textRun; $this->_elementCollection[] = $textRun;
return $textRun; return $textRun;
} }
@ -321,7 +331,7 @@ class PHPWord_Section_Table_Cell
/** /**
* Get Cell Style * Get Cell Style
* *
* @return PHPWord_Style_Cell * @return PhpOffice\PhpWord\Style\Cell
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section\Table;
* PHPWord_Section_Table_Row
*/
class PHPWord_Section_Table_Row
{
class Row
{
/** /**
* Row height * Row height
* *
@ -41,7 +39,7 @@ class PHPWord_Section_Table_Row
/** /**
* Row style * Row style
* *
* @var PHPWord_Style_Row * @var PhpOffice\PhpWord\Style\Row
*/ */
private $_style; private $_style;
@ -80,7 +78,7 @@ class PHPWord_Section_Table_Row
$this->_insideOf = $insideOf; $this->_insideOf = $insideOf;
$this->_pCount = $pCount; $this->_pCount = $pCount;
$this->_height = $height; $this->_height = $height;
$this->_style = new PHPWord_Style_Row(); $this->_style = new PhpOffice\PhpWord\Style\Row();
if (!is_null($style)) { if (!is_null($style)) {
if (is_array($style)) { if (is_array($style)) {
@ -100,11 +98,11 @@ class PHPWord_Section_Table_Row
* *
* @param int $width * @param int $width
* @param mixed $style * @param mixed $style
* @return PHPWord_Section_Table_Cell * @return PhpOffice\PhpWord\Section\Table\Cell
*/ */
public function addCell($width = null, $style = null) public function addCell($width = null, $style = null)
{ {
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); $cell = new Cell($this->_insideOf, $this->_pCount, $width, $style);
$this->_cells[] = $cell; $this->_cells[] = $cell;
return $cell; return $cell;
} }
@ -122,7 +120,7 @@ class PHPWord_Section_Table_Row
/** /**
* Get row style * Get row style
* *
* @return PHPWord_Style_Row * @return PhpOffice\PhpWord\Style\Row
*/ */
public function getStyle() public function getStyle()
{ {

View File

@ -25,10 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Text
*/ use PhpOffice\PhpWord\Style\Font;
class PHPWord_Section_Text use PhpOffice\PhpWord\Style\Paragraph;
class Text
{ {
/** /**
* Text content * Text content
@ -40,14 +42,14 @@ class PHPWord_Section_Text
/** /**
* Text style * Text style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Font
*/ */
private $fontStyle; private $fontStyle;
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Paragraph * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $paragraphStyle; private $paragraphStyle;
@ -55,8 +57,8 @@ class PHPWord_Section_Text
* Create a new Text Element * Create a new Text Element
* *
* @param string $text * @param string $text
* @param null|array|\PHPWord_Style_Font $fontStyle * @param null|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|array|\PHPWord_Style_Paragraph $paragraphStyle * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null) public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
{ {
@ -68,20 +70,20 @@ class PHPWord_Section_Text
/** /**
* Set Text style * Set Text style
* *
* @param null|array|\PHPWord_Style_Font $style * @param null|array|PhpOffice\PhpWord\Style\Font $style
* @param null|array|\PHPWord_Style_Paragraph $paragraphStyle * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setFontStyle($style = null, $paragraphStyle = null) public function setFontStyle($style = null, $paragraphStyle = null)
{ {
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
$this->fontStyle = $style; $this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle); $this->setParagraphStyle($paragraphStyle);
} elseif (is_array($style)) { } elseif (is_array($style)) {
$this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); $this->fontStyle = new Font('text', $paragraphStyle);
$this->fontStyle->setArrayStyle($style); $this->fontStyle->setArrayStyle($style);
} elseif (null === $style) { } elseif (null === $style) {
$this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); $this->fontStyle = new Font('text', $paragraphStyle);
} else { } else {
$this->fontStyle = $style; $this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle); $this->setParagraphStyle($paragraphStyle);
@ -92,7 +94,7 @@ class PHPWord_Section_Text
/** /**
* Get Text style * Get Text style
* *
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -102,18 +104,18 @@ class PHPWord_Section_Text
/** /**
* Set Paragraph style * Set Paragraph style
* *
* @param null|array|\PHPWord_Style_Paragraph $style * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style
* @return null|\PHPWord_Style_Paragraph * @return null|PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setParagraphStyle($style = null) public function setParagraphStyle($style = null)
{ {
if (is_array($style)) { if (is_array($style)) {
$this->paragraphStyle = new PHPWord_Style_Paragraph; $this->paragraphStyle = new Paragraph;
$this->paragraphStyle->setArrayStyle($style); $this->paragraphStyle->setArrayStyle($style);
} elseif ($style instanceof PHPWord_Style_Paragraph) { } elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} elseif (null === $style) { } elseif (null === $style) {
$this->paragraphStyle = new PHPWord_Style_Paragraph; $this->paragraphStyle = new Paragraph;
} else { } else {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} }
@ -123,7 +125,7 @@ class PHPWord_Section_Text
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {

View File

@ -25,22 +25,24 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_TextBreak
*/ use PhpOffice\PhpWord\Style\Font;
class PHPWord_Section_TextBreak use PhpOffice\PhpWord\Style\Paragraph;
class TextBreak
{ {
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Pagaraph * @var PhpOffice\PhpWord\Style\Pagaraph
*/ */
private $paragraphStyle = null; private $paragraphStyle = null;
/** /**
* Text style * Text style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Font
*/ */
private $fontStyle = null; private $fontStyle = null;
@ -60,17 +62,17 @@ class PHPWord_Section_TextBreak
/** /**
* Set Text style * Set Text style
* *
* @param null|array|\PHPWord_Style_Font $style * @param null|array|PhpOffice\PhpWord\Style\Font $style
* @param null|array|\PHPWord_Style_Paragraph $paragraphStyle * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function setFontStyle($style = null, $paragraphStyle = null) public function setFontStyle($style = null, $paragraphStyle = null)
{ {
if ($style instanceof PHPWord_Style_Font) { if ($style instanceof Font) {
$this->fontStyle = $style; $this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle); $this->setParagraphStyle($paragraphStyle);
} elseif (is_array($style)) { } elseif (is_array($style)) {
$this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); $this->fontStyle = new Font('text', $paragraphStyle);
$this->fontStyle->setArrayStyle($style); $this->fontStyle->setArrayStyle($style);
} else { } else {
$this->fontStyle = $style; $this->fontStyle = $style;
@ -82,7 +84,7 @@ class PHPWord_Section_TextBreak
/** /**
* Get Text style * Get Text style
* *
* @return PHPWord_Style_Font * @return PhpOffice\PhpWord\Style\Font
*/ */
public function getFontStyle() public function getFontStyle()
{ {
@ -92,15 +94,15 @@ class PHPWord_Section_TextBreak
/** /**
* Set Paragraph style * Set Paragraph style
* *
* @param null|array|\PHPWord_Style_Paragraph $style * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style
* @return null|\PHPWord_Style_Paragraph * @return null|PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setParagraphStyle($style = null) public function setParagraphStyle($style = null)
{ {
if (is_array($style)) { if (is_array($style)) {
$this->paragraphStyle = new PHPWord_Style_Paragraph; $this->paragraphStyle = new Paragraph;
$this->paragraphStyle->setArrayStyle($style); $this->paragraphStyle->setArrayStyle($style);
} elseif ($style instanceof PHPWord_Style_Paragraph) { } elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} else { } else {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
@ -111,10 +113,10 @@ class PHPWord_Section_TextBreak
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
return $this->paragraphStyle; return $this->paragraphStyle;
} }
} }

View File

@ -25,16 +25,18 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* PHPWord_Section_TextRun
*/
class PHPWord_Section_TextRun
{
use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\Style\Paragraph;
class TextRun
{
/** /**
* Paragraph style * Paragraph style
* *
* @var PHPWord_Style_Font * @var PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_styleParagraph; private $_styleParagraph;
@ -55,7 +57,7 @@ class PHPWord_Section_TextRun
// Set paragraph style // Set paragraph style
if (is_array($styleParagraph)) { if (is_array($styleParagraph)) {
$this->_styleParagraph = new PHPWord_Style_Paragraph(); $this->_styleParagraph = new Paragraph();
foreach ($styleParagraph as $key => $value) { foreach ($styleParagraph as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
@ -74,14 +76,14 @@ class PHPWord_Section_TextRun
* *
* @var string $text * @var string $text
* @var mixed $styleFont * @var mixed $styleFont
* @return PHPWord_Section_Text * @return PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text = null, $styleFont = null) public function addText($text = null, $styleFont = null)
{ {
if (!PHPWord_Shared_String::IsUTF8($text)) { if (!String::IsUTF8($text)) {
$text = utf8_encode($text); $text = utf8_encode($text);
} }
$text = new PHPWord_Section_Text($text, $styleFont); $text = new Text($text, $styleFont);
$this->_elementCollection[] = $text; $this->_elementCollection[] = $text;
return $text; return $text;
} }
@ -92,7 +94,7 @@ class PHPWord_Section_TextRun
* @param string $linkSrc * @param string $linkSrc
* @param string $linkName * @param string $linkName
* @param mixed $styleFont * @param mixed $styleFont
* @return PHPWord_Section_Link * @return PhpOffice\PhpWord\Section\Link
*/ */
public function addLink($linkSrc, $linkName = null, $styleFont = null) public function addLink($linkSrc, $linkName = null, $styleFont = null)
{ {
@ -101,8 +103,8 @@ class PHPWord_Section_TextRun
$linkName = utf8_encode($linkName); $linkName = utf8_encode($linkName);
} }
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont); $link = new Link($linkSrc, $linkName, $styleFont);
$rID = PHPWord_Media::addSectionLinkElement($linkSrc); $rID = Media::addSectionLinkElement($linkSrc);
$link->setRelationId($rID); $link->setRelationId($rID);
$this->_elementCollection[] = $link; $this->_elementCollection[] = $link;
@ -114,14 +116,14 @@ class PHPWord_Section_TextRun
* *
* @param string $imageSrc * @param string $imageSrc
* @param mixed $styleFont * @param mixed $styleFont
* @return PHPWord_Section_Image * @return PhpOffice\PhpWord\Section\Image
*/ */
public function addImage($imageSrc, $style = null) public function addImage($imageSrc, $style = null)
{ {
$image = new PHPWord_Section_Image($imageSrc, $style); $image = new Image($imageSrc, $style);
if (!is_null($image->getSource())) { if (!is_null($image->getSource())) {
$rID = PHPWord_Media::addSectionMediaElement($imageSrc, 'image'); $rID = Media::addSectionMediaElement($imageSrc, 'image');
$image->setRelationId($rID); $image->setRelationId($rID);
$this->_elementCollection[] = $image; $this->_elementCollection[] = $image;
@ -134,14 +136,14 @@ class PHPWord_Section_TextRun
/** /**
* Add TextBreak * Add TextBreak
* *
* @param int $count * @param int $count
* @param null|string|array|PHPWord_Style_Font $fontStyle * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
*/ */
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
{ {
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->_elementCollection[] = new PHPWord_Section_TextBreak($fontStyle, $paragraphStyle); $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle);
} }
} }
@ -149,12 +151,12 @@ class PHPWord_Section_TextRun
* Create a new Footnote Element * Create a new Footnote Element
* *
* @param string $text * @param string $text
* @return PHPWord_Section_Footnote * @return PhpOffice\PhpWord\Section\Footnote
*/ */
public function createFootnote($styleParagraph = null) public function createFootnote($styleParagraph = null)
{ {
$footnote = new PHPWord_Section_Footnote($styleParagraph); $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph);
$refID = PHPWord_Footnote::addFootnoteElement($footnote); $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote);
$footnote->setReferenceId($refID); $footnote->setReferenceId($refID);
$this->_elementCollection[] = $footnote; $this->_elementCollection[] = $footnote;
return $footnote; return $footnote;
@ -173,10 +175,10 @@ class PHPWord_Section_TextRun
/** /**
* Get Paragraph style * Get Paragraph style
* *
* @return PHPWord_Style_Paragraph * @return PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
{ {
return $this->_styleParagraph; return $this->_styleParagraph;
} }
} }

View File

@ -25,12 +25,10 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Section;
* Class PHPWord_Section_Title
*/
class PHPWord_Section_Title
{
class Title
{
/** /**
* Title Text content * Title Text content
* *

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord;
* PHPWord_Settings
*/ class Settings
class PHPWord_Settings
{ {
/** /**
* Compatibility option for XMLWriter * Compatibility option for XMLWriter

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Shared;
* Class PHPWord_Shared_Drawing
*/ class Drawing
class PHPWord_Shared_Drawing
{ {
/** /**
* Convert pixels to EMU * Convert pixels to EMU

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Shared;
* Class PHPWord_Shared_File
*/ class File
class PHPWord_Shared_File
{ {
/** /**
* Verify if a file exists * Verify if a file exists

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Shared;
* Class PHPWord_Shared_Font
*/ class Font
class PHPWord_Shared_Font
{ {
/** /**
* Calculate an (approximate) pixel size, based on a font points size * Calculate an (approximate) pixel size, based on a font points size

View File

@ -25,10 +25,9 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord\Shared;
* Class PHPWord_Shared_String
*/ class String
class PHPWord_Shared_String
{ {
/** /**
* Control characters array * Control characters array

View File

@ -25,18 +25,20 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Shared;
use PhpOffice\PhpWord\Settings;
if (!defined('DATE_W3C')) { if (!defined('DATE_W3C')) {
define('DATE_W3C', 'Y-m-d\TH:i:sP'); define('DATE_W3C', 'Y-m-d\TH:i:sP');
} }
/** /**
* Class PHPWord_Shared_XMLWriter
*
* @method bool startElement(string $name) * @method bool startElement(string $name)
* @method bool writeAttribute(string $name, string $value) * @method bool writeAttribute(string $name, string $value)
* @method bool endElement() * @method bool endElement()
*/ */
class PHPWord_Shared_XMLWriter class XMLWriter
{ {
/** Temporary storage method */ /** Temporary storage method */
const STORAGE_MEMORY = 1; const STORAGE_MEMORY = 1;
@ -57,7 +59,7 @@ class PHPWord_Shared_XMLWriter
private $_tempFileName = ''; private $_tempFileName = '';
/** /**
* Create a new PHPWord_Shared_XMLWriter instance * Create a new XMLWriter instance
* *
* @param int $pTemporaryStorage Temporary storage location * @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder * @param string $pTemporaryStorageFolder Temporary storage folder
@ -82,7 +84,7 @@ class PHPWord_Shared_XMLWriter
} }
// Set xml Compatibility // Set xml Compatibility
$compatibility = PHPWord_Settings::getCompatibility(); $compatibility = Settings::getCompatibility();
if ($compatibility) { if ($compatibility) {
$this->_xmlWriter->setIndent(false); $this->_xmlWriter->setIndent(false);
$this->_xmlWriter->setIndentString(''); $this->_xmlWriter->setIndentString('');

View File

@ -25,12 +25,12 @@
* @version 0.8.0 * @version 0.8.0
*/ */
namespace PhpOffice\PhpWord\Shared;
/** /**
* Class PHPWord_Shared_ZipStreamWrapper
*
* @codeCoverageIgnore Legacy from PHPExcel * @codeCoverageIgnore Legacy from PHPExcel
*/ */
class PHPWord_Shared_ZipStreamWrapper class ZipStreamWrapper
{ {
/** /**
* Internal ZipAcrhive * Internal ZipAcrhive
@ -180,4 +180,4 @@ class PHPWord_Shared_ZipStreamWrapper
return false; return false;
} }
} }
} }

View File

@ -25,30 +25,27 @@
* @version 0.8.0 * @version 0.8.0
*/ */
/** namespace PhpOffice\PhpWord;
* Class PHPWord_Style
*/
class PHPWord_Style
{
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull;
class Style
{
/** /**
* Style Elements
*
* @var array * @var array
*/ */
private static $_styleElements = array(); private static $_styleElements = array();
/** /**
* Add a paragraph style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styles
*/ */
public static function addParagraphStyle($styleName, $styles) public static function addParagraphStyle($styleName, $styles)
{ {
if (!array_key_exists($styleName, self::$_styleElements)) { if (!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Paragraph(); $style = new Paragraph();
foreach ($styles as $key => $value) { foreach ($styles as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
$key = '_' . $key; $key = '_' . $key;
@ -61,8 +58,6 @@ class PHPWord_Style
} }
/** /**
* Add a font style
*
* @param string $styleName * @param string $styleName
* @param array $styleFont * @param array $styleFont
* @param array $styleParagraph * @param array $styleParagraph
@ -70,7 +65,7 @@ class PHPWord_Style
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) public static function addFontStyle($styleName, $styleFont, $styleParagraph = null)
{ {
if (!array_key_exists($styleName, self::$_styleElements)) { if (!array_key_exists($styleName, self::$_styleElements)) {
$font = new PHPWord_Style_Font('text', $styleParagraph); $font = new Font('text', $styleParagraph);
foreach ($styleFont as $key => $value) { foreach ($styleFont as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
$key = '_' . $key; $key = '_' . $key;
@ -82,15 +77,13 @@ class PHPWord_Style
} }
/** /**
* Add a link style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styles
*/ */
public static function addLinkStyle($styleName, $styles) public static function addLinkStyle($styleName, $styles)
{ {
if (!array_key_exists($styleName, self::$_styleElements)) { if (!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_Font('link'); $style = new Font('link');
foreach ($styles as $key => $value) { foreach ($styles as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
$key = '_' . $key; $key = '_' . $key;
@ -103,23 +96,19 @@ class PHPWord_Style
} }
/** /**
* Add a table style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styles
*/ */
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null)
{ {
if (!array_key_exists($styleName, self::$_styleElements)) { if (!array_key_exists($styleName, self::$_styleElements)) {
$style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow); $style = new TableFull($styleTable, $styleFirstRow, $styleLastRow);
self::$_styleElements[$styleName] = $style; self::$_styleElements[$styleName] = $style;
} }
} }
/** /**
* Add a title style
*
* @param string $styleName * @param string $styleName
* @param array $styleFont * @param array $styleFont
* @param array $styleParagraph * @param array $styleParagraph
@ -128,7 +117,7 @@ class PHPWord_Style
{ {
$styleName = 'Heading_' . $titleCount; $styleName = 'Heading_' . $titleCount;
if (!array_key_exists($styleName, self::$_styleElements)) { if (!array_key_exists($styleName, self::$_styleElements)) {
$font = new PHPWord_Style_Font('title', $styleParagraph); $font = new Font('title', $styleParagraph);
foreach ($styleFont as $key => $value) { foreach ($styleFont as $key => $value) {
if (substr($key, 0, 1) != '_') { if (substr($key, 0, 1) != '_') {
$key = '_' . $key; $key = '_' . $key;
@ -141,9 +130,7 @@ class PHPWord_Style
} }
/** /**
* Set default paragraph style * @param array $styles Paragraph style definition
*
* @param array $styles Paragraph style definition
*/ */
public static function setDefaultParagraphStyle($styles) public static function setDefaultParagraphStyle($styles)
{ {
@ -153,7 +140,7 @@ class PHPWord_Style
/** /**
* Get all styles * Get all styles
* *
* @return PHPWord_Style_Font[] * @return PhpOffice\PhpWord\Style\Font[]
*/ */
public static function getStyles() public static function getStyles()
{ {
@ -161,10 +148,7 @@ class PHPWord_Style
} }
/** /**
* Get style
*
* @param string * @param string
* @return PHPWord_Style
*/ */
public static function getStyle($styleName) public static function getStyle($styleName)
{ {
@ -174,4 +158,4 @@ class PHPWord_Style
return null; return null;
} }
} }
} }