Merge branch '#160-element-container' into xml-reader

This commit is contained in:
Ivan Lanin 2014-04-08 01:15:14 +07:00
commit dadfc2903c
57 changed files with 285 additions and 311 deletions

View File

@ -39,8 +39,8 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
- `createHeader` replaced by `addHeader` - `createHeader` replaced by `addHeader`
- `createFooter` replaced by `addFooter` - `createFooter` replaced by `addFooter`
- `createSection` replaced by `addSection` - `createSection` replaced by `addSection`
- `Element\Footnote::getReferenceId` replaced by `Container\Container::getRelationId` - `Element\Footnote::getReferenceId` replaced by `Element\AbstractElement::getRelationId`
- `Element\Footnote::setReferenceId` replaced by `Container\Container::setRelationId` - `Element\Footnote::setReferenceId` replaced by `Element\AbstractElement::setRelationId`
- `Footnote::addFootnoteLinkElement` replaced by `Media::addElement` - `Footnote::addFootnoteLinkElement` replaced by `Media::addElement`
- `Footnote::getFootnoteLinkElements` replaced by `Media::getElements` - `Footnote::getFootnoteLinkElements` replaced by `Media::getElements`
- All current methods on `Media` - All current methods on `Media`
@ -48,14 +48,14 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
### Miscellaneous ### Miscellaneous
- Documentation: Simplify page level docblock - @ivanlanin GH-179 - Documentation: Simplify page level docblock - @ivanlanin GH-179
- Writer: Refactor writer classes and make a new Writer abstract class - @ivanlanin GH-160 - Writer: Refactor writer classes and make a new AbstractWriter abstract class - @ivanlanin GH-160
- Reader: Rename AbstractReader > Reader - @ivanlanin - General: Refactor folders: Element and Exception - @ivanlanin GH-187
- General: Refactor folders: Element, Container, and Exception - @ivanlanin GH-187
- General: Remove legacy HashTable and ZipStreamWrapper and all related properties/methods - @ivanlanin GH-187 - General: Remove legacy HashTable and ZipStreamWrapper and all related properties/methods - @ivanlanin GH-187
- Container: Create new Container abstract class - @ivanlanin GH-187 - Element: Create new AbstractElement abstract class - @ivanlanin GH-187
- Element: Create new Element abstract class - @ivanlanin GH-187
- Media: Refactor media class to use one method for all docPart (section, header, footer, footnote) - @ivanlanin GH-187 - Media: Refactor media class to use one method for all docPart (section, header, footer, footnote) - @ivanlanin GH-187
- General: Remove underscore prefix from all private properties name - General: Remove underscore prefix from all private properties name - @ivanlanin GH-187
- General: Move Section Settings to Style\Section - @ivanlanin GH-187
- General: Give `Abstract` prefix and `Interface` suffix for all abstract classes and interfaces as per [PHP-FIG recommendation](https://github.com/php-fig/fig-standards/blob/master/bylaws/002-psr-naming-conventions.md) - @ivanlanin GH-187
## 0.9.1 - 27 Mar 2014 ## 0.9.1 - 27 Mar 2014

View File

@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Container; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\InvalidImageException;
use PhpOffice\PhpWord\Exception\InvalidObjectException; use PhpOffice\PhpWord\Exception\InvalidObjectException;
@ -35,7 +35,7 @@ use PhpOffice\PhpWord\Element\CheckBox;
* *
* @since 0.9.2 * @since 0.9.2
*/ */
abstract class Container extends Element abstract class AbstractElement
{ {
/** /**
* Container type section|header|footer|cell|textrun|footnote * Container type section|header|footer|cell|textrun|footnote
@ -51,6 +51,28 @@ abstract class Container extends Element
*/ */
protected $sectionId; protected $sectionId;
/**
* Document part type: section|header|footer
*
* Used by textrun and cell container to determine where the element is
* located because it will affect the availability of other element,
* e.g. footnote will not be available when $docPart is header or footer.
*
* @var string
*/
private $docPart = 'section';
/**
* Document part Id
*
* For header and footer, this will be = ($sectionId - 1) * 3 + $index
* because the max number of header/footer in every page is 3, i.e.
* AUTO, FIRST, and EVEN (AUTO = ODD)
*
* @var integer
*/
private $docPartId = 1;
/** /**
* Elements collection * Elements collection
* *
@ -340,6 +362,38 @@ abstract class Container extends Element
return $this->sectionId; return $this->sectionId;
} }
/**
* Set doc part
*
* @param string $docPart
* @param integer $docPartId
*/
public function setDocPart($docPart, $docPartId = 1)
{
$this->docPart = $docPart;
$this->docPartId = $docPartId;
}
/**
* Get doc part
*
* @return string
*/
public function getDocPart()
{
return $this->docPart;
}
/**
* Get doc part Id
*
* @return integer
*/
public function getDocPartId()
{
return $this->docPartId;
}
/** /**
* Get all elements * Get all elements
* *
@ -372,6 +426,106 @@ abstract class Container extends Element
$this->relationId = $rId; $this->relationId = $rId;
} }
/**
* Check if element is located in section doc part (as opposed to header/footer)
*
* @return boolean
*/
public function isInSection()
{
return ($this->docPart == 'section');
}
/**
* Set style value
*
* @param mixed $styleObject Style object
* @param mixed $styleValue Style value
* @param boolean $returnObject Always return object
*/
protected function setStyle($styleObject, $styleValue = null, $returnObject = false)
{
if (!is_null($styleValue) && is_array($styleValue)) {
foreach ($styleValue as $key => $value) {
if (substr($key, 0, 1) == '_') {
$key = substr($key, 1);
}
$styleObject->setStyleValue($key, $value);
}
$style = $styleObject;
} else {
$style = $returnObject ? $styleObject : $styleValue;
}
return $style;
}
/**
* Check if a method is allowed for the current container
*
* @param string $method
* @return boolean
*/
private function checkValidity($method)
{
// Valid containers for each element
$allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote');
$validContainers = array(
'text' => $allContainers,
'link' => $allContainers,
'textbreak' => $allContainers,
'image' => $allContainers,
'object' => $allContainers,
'textrun' => array('section', 'header', 'footer', 'cell'),
'listitem' => array('section', 'header', 'footer', 'cell'),
'checkbox' => array('section', 'header', 'footer', 'cell'),
'table' => array('section', 'header', 'footer'),
'footnote' => array('section', 'textrun', 'cell'),
'preservetext' => array('header', 'footer', 'cell'),
'relationid' => array('header', 'footer', 'footnote'),
'title' => array('section'),
);
// Special condition, e.g. preservetext can only exists in cell when
// the cell is located in header or footer
$validContainerInContainers = array(
'preservetext' => array(array('cell'), array('header', 'footer')),
'footnote' => array(array('cell', 'textrun'), array('section')),
);
// Check if a method is valid for current container
if (array_key_exists($method, $validContainers)) {
if (!in_array($this->container, $validContainers[$method])) {
throw new \BadMethodCallException();
}
}
// Check if a method is valid for current container, located in other container
if (array_key_exists($method, $validContainerInContainers)) {
$rules = $validContainerInContainers[$method];
$containers = $rules[0];
$allowedDocParts = $rules[1];
foreach ($containers as $container) {
if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) {
throw new \BadMethodCallException();
}
}
}
return true;
}
/**
* Return element location in document: section, headerx, or footerx
*/
private function checkElementDocPart()
{
$isCellTextrun = in_array($this->container, array('cell', 'textrun'));
$docPart = $isCellTextrun ? $this->getDocPart() : $this->container;
$docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId;
$inHeaderFooter = ($docPart == 'header' || $docPart == 'footer');
return $inHeaderFooter ? $docPart . $docPartId : $docPart;
}
/** /**
* Add memory image element * Add memory image element
* *
@ -408,71 +562,4 @@ abstract class Container extends Element
{ {
return $this->addFootnote($paragraphStyle); return $this->addFootnote($paragraphStyle);
} }
/**
* Check if a method is allowed for the current container
*
* @param string $method
* @return boolean
*/
private function checkValidity($method)
{
// Empty array means the element can be accepted by all containers
$validContainers = array(
'text' => array(),
'link' => array(),
'textbreak' => array(),
'image' => array(),
'object' => array(),
'textrun' => array('section', 'header', 'footer', 'cell'),
'listitem' => array('section', 'header', 'footer', 'cell'),
'checkbox' => array('section', 'header', 'footer', 'cell'),
'table' => array('section', 'header', 'footer'),
'footnote' => array('section', 'textrun', 'cell'),
'preservetext' => array('header', 'footer', 'cell'),
'relationid' => array('header', 'footer', 'footnote'),
'title' => array('section'),
);
// Special condition, e.g. preservetext can only exists in cell when
// the cell is located in header or footer
$validContainerInContainers = array(
'preservetext' => array(array('cell'), array('header', 'footer')),
'footnote' => array(array('cell', 'textrun'), array('section')),
);
// Check if a method is valid for current container
if (array_key_exists($method, $validContainers)) {
if (!empty($validContainers[$method])) {
if (!in_array($this->container, $validContainers[$method])) {
throw new \BadMethodCallException();
}
}
}
// Check if a method is valid for current container, located in other container
if (array_key_exists($method, $validContainerInContainers)) {
$rules = $validContainerInContainers[$method];
$containers = $rules[0];
$allowedDocParts = $rules[1];
foreach ($containers as $container) {
if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) {
throw new \BadMethodCallException();
}
}
}
return true;
}
/**
* Return element location in document: section, headerx, or footerx
*/
private function checkElementDocPart()
{
$isCellTextrun = in_array($this->container, array('cell', 'textrun'));
$docPart = $isCellTextrun ? $this->getDocPart() : $this->container;
$docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId;
$inHeaderFooter = ($docPart == 'header' || $docPart == 'footer');
return $inHeaderFooter ? $docPart . $docPartId : $docPart;
}
} }

View File

@ -9,13 +9,12 @@
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Container\Container;
use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Cell as CellStyle;
/** /**
* Table cell element * Table cell element
*/ */
class Cell extends Container class Cell extends AbstractElement
{ {
/** /**
* Cell width * Cell width

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Check box element * Check box element
*/ */
class CheckBox extends Element class CheckBox extends AbstractElement
{ {
/** /**
* Name content * Name content

View File

@ -1,106 +0,0 @@
<?php
/**
* PHPWord
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/
namespace PhpOffice\PhpWord\Element;
/**
* Abstract element class
*
* @since 0.9.2
*/
abstract class Element
{
/**
* Document part type: section|header|footer
*
* Used by textrun and cell container to determine where the element is
* located because it will affect the availability of other element,
* e.g. footnote will not be available when $docPart is header or footer.
*
* @var string
*/
private $docPart = 'section';
/**
* Document part Id
*
* For header and footer, this will be = ($sectionId - 1) * 3 + $index
* because the max number of header/footer in every page is 3, i.e.
* AUTO, FIRST, and EVEN (AUTO = ODD)
*
* @var integer
*/
private $docPartId = 1;
/**
* Set style value
*
* @param mixed $styleObject Style object
* @param mixed $styleValue Style value
* @param boolean $returnObject Always return object
*/
protected function setStyle($styleObject, $styleValue = null, $returnObject = false)
{
if (!is_null($styleValue) && is_array($styleValue)) {
foreach ($styleValue as $key => $value) {
if (substr($key, 0, 1) == '_') {
$key = substr($key, 1);
}
$styleObject->setStyleValue($key, $value);
}
$style = $styleObject;
} else {
$style = $returnObject ? $styleObject : $styleValue;
}
return $style;
}
/**
* Set doc part
*
* @param string $docPart
* @param integer $docPartId
*/
public function setDocPart($docPart, $docPartId = 1)
{
$this->docPart = $docPart;
$this->docPartId = $docPartId;
}
/**
* Get doc part
*
* @return string
*/
public function getDocPart()
{
return $this->docPart;
}
/**
* Get doc part Id
*
* @return integer
*/
public function getDocPartId()
{
return $this->docPartId;
}
/**
* Check if element is located in section doc part (as opposed to header/footer)
*
* @return boolean
*/
public function isInSection()
{
return ($this->docPart == 'section');
}
}

View File

@ -7,12 +7,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Container; namespace PhpOffice\PhpWord\Element;
/** /**
* Footer element * Footer element
*/ */
class Footer extends Container class Footer extends AbstractElement
{ {
const AUTO = 'default'; // default and odd pages const AUTO = 'default'; // default and odd pages
const FIRST = 'first'; const FIRST = 'first';

View File

@ -9,13 +9,12 @@
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Container\Container;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Footnote element * Footnote element
*/ */
class Footnote extends Container class Footnote extends AbstractElement
{ {
/** /**
* Paragraph style * Paragraph style

View File

@ -7,14 +7,14 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Container; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Image;
/** /**
* Header element * Header element
*/ */
class Header extends Container class Header extends AbstractElement
{ {
/** /**
* Header types constants * Header types constants

View File

@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle;
/** /**
* Image element * Image element
*/ */
class Image extends Element class Image extends AbstractElement
{ {
/** /**
* Image source * Image source
@ -138,9 +138,6 @@ class Image extends Element
$this->source = $source; $this->source = $source;
$this->isWatermark = $isWatermark; $this->isWatermark = $isWatermark;
$this->style = $this->setStyle(new ImageStyle(), $style, true); $this->style = $this->setStyle(new ImageStyle(), $style, true);
if (isset($style['wrappingStyle'])) {
$this->style->setWrappingStyle($style['wrappingStyle']);
}
if ($this->style->getWidth() == null && $this->style->getHeight() == null) { if ($this->style->getWidth() == null && $this->style->getHeight() == null) {
$this->style->setWidth($imgData[0]); $this->style->setWidth($imgData[0]);
$this->style->setHeight($imgData[1]); $this->style->setHeight($imgData[1]);

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Link element * Link element
*/ */
class Link extends Element class Link extends AbstractElement
{ {
/** /**
* Link source * Link source

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
/** /**
* List item element * List item element
*/ */
class ListItem extends Element class ListItem extends AbstractElement
{ {
/** /**
* ListItem Style * ListItem Style

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle;
/** /**
* Object element * Object element
*/ */
class Object extends Element class Object extends AbstractElement
{ {
/** /**
* Ole-Object Src * Ole-Object Src

View File

@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Element;
/** /**
* Page break element * Page break element
*/ */
class PageBreak extends Element class PageBreak extends AbstractElement
{ {
/** /**
* Create new page break * Create new page break

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Preserve text/field element * Preserve text/field element
*/ */
class PreserveText extends Element class PreserveText extends AbstractElement
{ {
/** /**
* Text content * Text content

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Row as RowStyle;
/** /**
* Table row element * Table row element
*/ */
class Row extends Element class Row extends AbstractElement
{ {
/** /**
* Row height * Row height

View File

@ -7,24 +7,24 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Container; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\TOC; use PhpOffice\PhpWord\TOC;
use PhpOffice\PhpWord\Container\Footer; use PhpOffice\PhpWord\Element\Footer;
use PhpOffice\PhpWord\Container\Header; use PhpOffice\PhpWord\Element\Header;
use PhpOffice\PhpWord\Container\Settings;
use PhpOffice\PhpWord\Element\PageBreak; use PhpOffice\PhpWord\Element\PageBreak;
use PhpOffice\PhpWord\Style\Section as SectionSettings;
/** /**
* Section * Section
*/ */
class Section extends Container class Section extends AbstractElement
{ {
/** /**
* Section settings * Section settings
* *
* @var Settings * @var SectionSettings
*/ */
private $settings; private $settings;
@ -53,7 +53,7 @@ class Section extends Container
$this->container = 'section'; $this->container = 'section';
$this->sectionId = $sectionCount; $this->sectionId = $sectionCount;
$this->setDocPart($this->container, $this->sectionId); $this->setDocPart($this->container, $this->sectionId);
$this->settings = new Settings(); $this->settings = new SectionSettings();
$this->setSettings($settings); $this->setSettings($settings);
} }
@ -80,7 +80,7 @@ class Section extends Container
/** /**
* Get Section Settings * Get Section Settings
* *
* @return Settings * @return SectionSettings
*/ */
public function getSettings() public function getSettings()
{ {
@ -184,7 +184,7 @@ class Section extends Container
private function addHeaderFooter($type = Header::AUTO, $header = true) private function addHeaderFooter($type = Header::AUTO, $header = true)
{ {
$collectionArray = $header ? 'headers' : 'footers'; $collectionArray = $header ? 'headers' : 'footers';
$containerClass = 'PhpOffice\\PhpWord\\Container\\'; $containerClass = 'PhpOffice\\PhpWord\\Element\\';
$containerClass .= ($header ? 'Header' : 'Footer'); $containerClass .= ($header ? 'Header' : 'Footer');
$collection = &$this->$collectionArray; $collection = &$this->$collectionArray;

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Table as TableStyle;
/** /**
* Table element * Table element
*/ */
class Table extends Element class Table extends AbstractElement
{ {
/** /**
* Table style * Table style

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Text element * Text element
*/ */
class Text extends Element class Text extends AbstractElement
{ {
/** /**
* Text content * Text content

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Text break element * Text break element
*/ */
class TextBreak extends Element class TextBreak extends AbstractElement
{ {
/** /**
* Paragraph style * Paragraph style

View File

@ -9,13 +9,12 @@
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Container\Container;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/** /**
* Textrun/paragraph element * Textrun/paragraph element
*/ */
class TextRun extends Container class TextRun extends AbstractElement
{ {
/** /**
* Paragraph style * Paragraph style

View File

@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Element;
/** /**
* Title element * Title element
*/ */
class Title extends Element class Title extends AbstractElement
{ {
/** /**
* Title Text content * Title Text content

View File

@ -21,12 +21,12 @@ abstract class IOFactory
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $name * @param string $name
* @return \PhpOffice\PhpWord\Writer\IWriter * @return \PhpOffice\PhpWord\Writer\WriterInterface
* @throws Exception * @throws Exception
*/ */
public static function createWriter(PhpWord $phpWord, $name = 'Word2007') public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
{ {
if ($name !== 'IWriter' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') { if ($name !== 'WriterInterface' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') {
throw new Exception("\"{$name}\" is not a valid writer."); throw new Exception("\"{$name}\" is not a valid writer.");
} }
@ -38,12 +38,12 @@ abstract class IOFactory
* Create new reader * Create new reader
* *
* @param string $name * @param string $name
* @return \PhpOffice\PhpWord\Reader\IReader * @return \PhpOffice\PhpWord\Reader\ReaderInterface
* @throws Exception * @throws Exception
*/ */
public static function createReader($name = 'Word2007') public static function createReader($name = 'Word2007')
{ {
if ($name !== 'IReader' && $name !== 'Word2007') { if ($name !== 'ReaderInterface' && $name !== 'Word2007') {
throw new Exception("\"{$name}\" is not a valid reader."); throw new Exception("\"{$name}\" is not a valid reader.");
} }

View File

@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Template; use PhpOffice\PhpWord\Template;
@ -217,7 +217,7 @@ class PhpWord
/** /**
* Get all sections * Get all sections
* *
* @return \PhpOffice\PhpWord\Container\Section[] * @return \PhpOffice\PhpWord\Element\Section[]
*/ */
public function getSections() public function getSections()
{ {

View File

@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Exception\Exception;
* *
* @codeCoverageIgnore Abstract class * @codeCoverageIgnore Abstract class
*/ */
abstract class Reader implements IReader abstract class AbstractReader implements ReaderInterface
{ {
/** /**
* Read data only? * Read data only?
@ -47,7 +47,7 @@ abstract class Reader implements IReader
* Set read data only * Set read data only
* *
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Reader\IReader * @return \PhpOffice\PhpWord\Reader\ReaderInterface
*/ */
public function setReadDataOnly($pValue = true) public function setReadDataOnly($pValue = true)
{ {
@ -77,7 +77,7 @@ abstract class Reader implements IReader
} }
/** /**
* Can the current IReader read the file? * Can the current ReaderInterface read the file?
* *
* @param string $pFilename * @param string $pFilename
* @return bool * @return bool

View File

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

View File

@ -14,12 +14,12 @@ use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Shared\XMLReader; use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
/** /**
* Reader for Word2007 * Reader for Word2007
*/ */
class Word2007 extends Reader implements IReader class Word2007 extends AbstractReader implements ReaderInterface
{ {
/** /**
* PhpWord object * PhpWord object
@ -43,7 +43,7 @@ class Word2007 extends Reader implements IReader
private $activePart = 'document'; private $activePart = 'document';
/** /**
* Can the current IReader read the file? * Can the current ReaderInterface read the file?
* *
* @param string $fileName * @param string $fileName
* @return bool * @return bool

View File

@ -7,12 +7,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Container; namespace PhpOffice\PhpWord\Style;
/** /**
* Section settings * Section settings
*/ */
class Settings class Section
{ {
/** /**
* Default Page Size Width * Default Page Size Width

View File

@ -17,7 +17,7 @@ use PhpOffice\PhpWord\PhpWord;
* *
* @since 0.9.2 * @since 0.9.2
*/ */
abstract class Writer implements IWriter abstract class AbstractWriter implements WriterInterface
{ {
/** /**
* PHPWord object * PHPWord object

View File

@ -21,7 +21,7 @@ use PhpOffice\PhpWord\Writer\ODText\Styles;
/** /**
* ODText writer * ODText writer
*/ */
class ODText extends Writer implements IWriter class ODText extends AbstractWriter implements WriterInterface
{ {
/** /**
* Create new ODText writer * Create new ODText writer

View File

@ -12,6 +12,6 @@ namespace PhpOffice\PhpWord\Writer\ODText;
/** /**
* ODText writer part abstract * ODText writer part abstract
*/ */
abstract class WriterPart extends \PhpOffice\PhpWord\Writer\Word2007\WriterPart abstract class AbstractWriterPart extends \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
{ {
} }

View File

@ -29,7 +29,7 @@ use PhpOffice\PhpWord\TOC;
/** /**
* ODText content part writer * ODText content part writer
*/ */
class Content extends WriterPart class Content extends AbstractWriterPart
{ {
/** /**
* Write content file to XML format * Write content file to XML format

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\PhpWord;
/** /**
* ODText manifest part writer * ODText manifest part writer
*/ */
class Manifest extends WriterPart class Manifest extends AbstractWriterPart
{ {
/** /**
* Write Manifest file to XML format * Write Manifest file to XML format

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord;
/** /**
* ODText meta part writer * ODText meta part writer
*/ */
class Meta extends WriterPart class Meta extends AbstractWriterPart
{ {
/** /**
* Write Meta file to XML format * Write Meta file to XML format

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord;
/** /**
* ODText mimetype part writer * ODText mimetype part writer
*/ */
class Mimetype extends WriterPart class Mimetype extends AbstractWriterPart
{ {
/** /**
* Write Mimetype to Text format * Write Mimetype to Text format

View File

@ -18,7 +18,7 @@ use PhpOffice\PhpWord\Style\Table;
/** /**
* ODText styloes part writer * ODText styloes part writer
*/ */
class Styles extends WriterPart class Styles extends AbstractWriterPart
{ {
/** /**
* Write Styles file to XML format * Write Styles file to XML format

View File

@ -29,7 +29,7 @@ use PhpOffice\PhpWord\TOC;
/** /**
* RTF writer * RTF writer
*/ */
class RTF extends Writer implements IWriter class RTF extends AbstractWriter implements WriterInterface
{ {
/** /**
* Color register * Color register

View File

@ -26,7 +26,7 @@ use PhpOffice\PhpWord\Writer\Word2007\Styles;
/** /**
* Word2007 writer * Word2007 writer
*/ */
class Word2007 extends Writer implements IWriter class Word2007 extends AbstractWriter implements WriterInterface
{ {
/** /**
* Content types values * Content types values
@ -229,7 +229,7 @@ class Word2007 extends Writer implements IWriter
/** /**
* Add header/footer content * Add header/footer content
* *
* @param \PhpOffice\PhpWord\Container\Section $section * @param \PhpOffice\PhpWord\Element\Section $section
* @param mixed $objZip * @param mixed $objZip
* @param string $elmType * @param string $elmType
* @param integer $rID * @param integer $rID

View File

@ -10,27 +10,27 @@
namespace PhpOffice\PhpWord\Writer\Word2007; namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Writer\IWriter; use PhpOffice\PhpWord\Writer\WriterInterface;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Word2007 writer part abstract class * Word2007 writer part abstract class
*/ */
abstract class WriterPart abstract class AbstractWriterPart
{ {
/** /**
* Parent writer * Parent writer
* *
* @var IWriter * @var WriterInterface
*/ */
protected $parentWriter; protected $parentWriter;
/** /**
* Set parent writer * Set parent writer
* *
* @param IWriter $pWriter * @param WriterInterface $pWriter
*/ */
public function setParentWriter(IWriter $pWriter = null) public function setParentWriter(WriterInterface $pWriter = null)
{ {
$this->parentWriter = $pWriter; $this->parentWriter = $pWriter;
} }
@ -38,7 +38,7 @@ abstract class WriterPart
/** /**
* Get parent writer * Get parent writer
* *
* @return IWriter * @return WriterInterface
* @throws Exception * @throws Exception
*/ */
public function getParentWriter() public function getParentWriter()
@ -46,7 +46,7 @@ abstract class WriterPart
if (!is_null($this->parentWriter)) { if (!is_null($this->parentWriter)) {
return $this->parentWriter; return $this->parentWriter;
} else { } else {
throw new Exception("No parent IWriter assigned."); throw new Exception("No parent WriterInterface assigned.");
} }
} }

View File

@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Container\Container; use PhpOffice\PhpWord\Element\AbstractElement;
use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\Text;
use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\Link; use PhpOffice\PhpWord\Element\Link;
@ -37,7 +37,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle;
* *
* Write common parts of document.xml, headerx.xml, and footerx.xml * Write common parts of document.xml, headerx.xml, and footerx.xml
*/ */
class Base extends WriterPart class Base extends AbstractWriterPart
{ {
/** /**
* Write text element * Write text element
@ -1121,9 +1121,9 @@ class Base extends WriterPart
* Write container elements * Write container elements
* *
* @param XMLWriter $xmlWriter * @param XMLWriter $xmlWriter
* @param Container $container * @param AbstractElement $container
*/ */
protected function writeContainerElements(XMLWriter $xmlWriter, Container $container) protected function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $container)
{ {
// Check allowed elements // Check allowed elements
$elmCommon = array('Text', 'Link', 'TextBreak', 'Image', 'Object'); $elmCommon = array('Text', 'Link', 'TextBreak', 'Image', 'Object');

View File

@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Word2007 contenttypes part writer * Word2007 contenttypes part writer
*/ */
class ContentTypes extends WriterPart class ContentTypes extends AbstractWriterPart
{ {
/** /**
* Write [Content_Types].xml * Write [Content_Types].xml

View File

@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord;
/** /**
* Word2007 contenttypes part writer * Word2007 contenttypes part writer
*/ */
class DocProps extends WriterPart class DocProps extends AbstractWriterPart
{ {
/** /**
* Write docProps/app.xml * Write docProps/app.xml

View File

@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\TOC; use PhpOffice\PhpWord\TOC;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Element\PageBreak; use PhpOffice\PhpWord\Element\PageBreak;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;

View File

@ -9,7 +9,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007; namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Container\Footer as FooterElement; use PhpOffice\PhpWord\Element\Footer as FooterElement;
/** /**
* Word2007 footer part writer * Word2007 footer part writer

View File

@ -9,7 +9,7 @@
namespace PhpOffice\PhpWord\Writer\Word2007; namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Container\Header as HeaderElement; use PhpOffice\PhpWord\Element\Header as HeaderElement;
/** /**
* Word2007 header part writer * Word2007 header part writer

View File

@ -17,7 +17,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
* *
* @since 0.9.2 * @since 0.9.2
*/ */
class Rels extends WriterPart class Rels extends AbstractWriterPart
{ {
/** /**
* Base relationship URL * Base relationship URL

View File

@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Writer;
/** /**
* Writer interface * Writer interface
*/ */
interface IWriter interface WriterInterface
{ {
/** /**
* Save PhpWord to file * Save PhpWord to file

View File

@ -7,12 +7,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Tests\Container; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Container\Footer; use PhpOffice\PhpWord\Element\Footer;
/** /**
* Test class for PhpOffice\PhpWord\Container\Footer * Test class for PhpOffice\PhpWord\Element\Footer
* *
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -26,7 +26,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
$oFooter = new Footer($iVal); $oFooter = new Footer($iVal);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Footer', $oFooter); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footer', $oFooter);
$this->assertEquals($oFooter->getSectionId(), $iVal); $this->assertEquals($oFooter->getSectionId(), $iVal);
} }

View File

@ -7,12 +7,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Tests\Container; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Container\Header; use PhpOffice\PhpWord\Element\Header;
/** /**
* Test class for PhpOffice\PhpWord\Container\Header * Test class for PhpOffice\PhpWord\Element\Header
* *
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -26,7 +26,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
$oHeader = new Header($iVal); $oHeader = new Header($iVal);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Header', $oHeader); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Header', $oHeader);
$this->assertEquals($oHeader->getSectionId(), $iVal); $this->assertEquals($oHeader->getSectionId(), $iVal);
$this->assertEquals($oHeader->getType(), Header::AUTO); $this->assertEquals($oHeader->getType(), Header::AUTO);
} }

View File

@ -24,7 +24,6 @@ class PageBreakTest extends \PHPUnit_Framework_TestCase
*/ */
public function testConstruct() public function testConstruct()
{ {
// Section Settings
$oPageBreak = new PageBreak(); $oPageBreak = new PageBreak();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\PageBreak', $oPageBreak); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\PageBreak', $oPageBreak);

View File

@ -7,15 +7,15 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Tests\Container; namespace PhpOffice\PhpWord\Tests\Element;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Container\Header; use PhpOffice\PhpWord\Element\Header;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
/** /**
* Test class for PhpOffice\PhpWord\Container\Section * Test class for PhpOffice\PhpWord\Element\Section
* *
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
@ -139,7 +139,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
foreach ($elements as $element) { foreach ($elements as $element) {
$method = "create{$element}"; $method = "create{$element}";
$this->assertInstanceOf("PhpOffice\\PhpWord\\Container\\{$element}", $object->$method()); $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method());
} }
$this->assertFalse($object->hasDifferentFirstPage()); $this->assertFalse($object->hasDifferentFirstPage());
} }

View File

@ -10,7 +10,7 @@
namespace PhpOffice\PhpWord\Tests; namespace PhpOffice\PhpWord\Tests;
use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Image;
/** /**

View File

@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Tests;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Container\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
/** /**

View File

@ -7,14 +7,14 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/ */
namespace PhpOffice\PhpWord\Tests\Container; namespace PhpOffice\PhpWord\Tests\Style;
use PhpOffice\PhpWord\Container\Settings; use PhpOffice\PhpWord\Style\Section;
/** /**
* Test class for PhpOffice\PhpWord\Container\Settings * Test class for PhpOffice\PhpWord\Style\Section
* *
* @coversDefaultClass \PhpOffice\PhpWord\Container\Settings * @coversDefaultClass \PhpOffice\PhpWord\Element\Section
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class SettingsTest extends \PHPUnit_Framework_TestCase class SettingsTest extends \PHPUnit_Framework_TestCase
@ -25,7 +25,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testSettingValue() public function testSettingValue()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$oSettings->setSettingValue('_orientation', 'landscape'); $oSettings->setSettingValue('_orientation', 'landscape');
$this->assertEquals('landscape', $oSettings->getOrientation()); $this->assertEquals('landscape', $oSettings->getOrientation());
@ -63,7 +63,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testMargin() public function testMargin()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
$oSettings->setMarginTop($iVal); $oSettings->setMarginTop($iVal);
@ -88,7 +88,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testOrientationLandscape() public function testOrientationLandscape()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$oSettings->setLandscape(); $oSettings->setLandscape();
$this->assertEquals('landscape', $oSettings->getOrientation()); $this->assertEquals('landscape', $oSettings->getOrientation());
@ -102,7 +102,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testOrientationPortrait() public function testOrientationPortrait()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$oSettings->setPortrait(); $oSettings->setPortrait();
$this->assertNull($oSettings->getOrientation()); $this->assertNull($oSettings->getOrientation());
@ -116,7 +116,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testBorderSize() public function testBorderSize()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
$oSettings->setBorderSize($iVal); $oSettings->setBorderSize($iVal);
@ -149,7 +149,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testBorderColor() public function testBorderColor()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$oSettings->setBorderColor('FF00AA'); $oSettings->setBorderColor('FF00AA');
$this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor()); $this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor());
@ -177,7 +177,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testNumberingStart() public function testNumberingStart()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$this->assertNull($oSettings->getPageNumberingStart()); $this->assertNull($oSettings->getPageNumberingStart());
@ -194,7 +194,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
*/ */
public function testHeader() public function testHeader()
{ {
$oSettings = new Settings(); $oSettings = new Section();
$this->assertEquals(720, $oSettings->getHeaderHeight()); $this->assertEquals(720, $oSettings->getHeaderHeight());
@ -212,7 +212,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testFooter() public function testFooter()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$this->assertEquals(720, $oSettings->getFooterHeight()); $this->assertEquals(720, $oSettings->getFooterHeight());
@ -230,7 +230,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testColumnsNum() public function testColumnsNum()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
// Default // Default
$this->assertEquals(1, $oSettings->getColsNum()); $this->assertEquals(1, $oSettings->getColsNum());
@ -249,16 +249,16 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testColumnsSpace() public function testColumnsSpace()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
// Default // Default
$this->assertEquals(720, $oSettings->getColsSpace()); $this->assertEquals(720, $oSettings->getColsSpace());
$iVal = rand(1, 1000); $iVal = rand(1, 1000);
$this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Settings', $oSettings->setColsSpace($iVal)); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Section', $oSettings->setColsSpace($iVal));
$this->assertEquals($iVal, $oSettings->getColsSpace()); $this->assertEquals($iVal, $oSettings->getColsSpace());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Settings', $oSettings->setColsSpace()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Section', $oSettings->setColsSpace());
$this->assertEquals(720, $oSettings->getColsSpace()); $this->assertEquals(720, $oSettings->getColsSpace());
} }
@ -268,7 +268,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testBreakType() public function testBreakType()
{ {
// Section Settings // Section Settings
$oSettings = new Settings(); $oSettings = new Section();
$this->assertNull($oSettings->getBreakType()); $this->assertNull($oSettings->getBreakType());

View File

@ -12,12 +12,12 @@ use PhpOffice\PhpWord\Writer\ODText;
use PhpWord\Tests\TestHelperDOCX; use PhpWord\Tests\TestHelperDOCX;
/** /**
* Test class for PhpOffice\PhpWord\Writer\ODText\WriterPart * Test class for PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
* *
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\WriterPart * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class WriterPartTest extends \PHPUnit_Framework_TestCase class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* covers ::setParentWriter * covers ::setParentWriter
@ -26,7 +26,7 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase
public function testSetGetParentWriter() public function testSetGetParentWriter()
{ {
$object = $this->getMockForAbstractClass( $object = $this->getMockForAbstractClass(
'PhpOffice\\PhpWord\\Writer\\ODText\\WriterPart' 'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
); );
$object->setParentWriter(new ODText()); $object->setParentWriter(new ODText());
$this->assertEquals( $this->assertEquals(
@ -38,12 +38,12 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase
/** /**
* covers ::getParentWriter * covers ::getParentWriter
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage No parent IWriter assigned. * @expectedExceptionMessage No parent WriterInterface assigned.
*/ */
public function testSetGetParentWriterNull() public function testSetGetParentWriterNull()
{ {
$object = $this->getMockForAbstractClass( $object = $this->getMockForAbstractClass(
'PhpOffice\\PhpWord\\Writer\\ODText\\WriterPart' 'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
); );
$object->getParentWriter(); $object->getParentWriter();
} }

View File

@ -8,17 +8,17 @@
*/ */
namespace PhpOffice\PhpWord\Tests\Writer\Word2007; namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
use PhpOffice\PhpWord\Writer\Word2007\WriterPart; use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart;
use PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Writer\Word2007;
use PhpWord\Tests\TestHelperDOCX; use PhpWord\Tests\TestHelperDOCX;
/** /**
* Test class for PhpOffice\PhpWord\Writer\Word2007\WriterPart * Test class for PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
* *
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\WriterPart * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
*/ */
class WriterPartTest extends \PHPUnit_Framework_TestCase class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* covers ::setParentWriter * covers ::setParentWriter
@ -27,7 +27,7 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase
public function testSetGetParentWriter() public function testSetGetParentWriter()
{ {
$object = $this->getMockForAbstractClass( $object = $this->getMockForAbstractClass(
'PhpOffice\\PhpWord\\Writer\\Word2007\\WriterPart' 'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
); );
$object->setParentWriter(new Word2007()); $object->setParentWriter(new Word2007());
$this->assertEquals( $this->assertEquals(
@ -39,12 +39,12 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase
/** /**
* covers ::getParentWriter * covers ::getParentWriter
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessage No parent IWriter assigned. * @expectedExceptionMessage No parent WriterInterface assigned.
*/ */
public function testSetGetParentWriterNull() public function testSetGetParentWriterNull()
{ {
$object = $this->getMockForAbstractClass( $object = $this->getMockForAbstractClass(
'PhpOffice\\PhpWord\\Writer\\Word2007\\WriterPart' 'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
); );
$object->getParentWriter(); $object->getParentWriter();
} }

View File

@ -28,7 +28,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
public function testWriteFooter() public function testWriteFooter()
{ {
$imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
$container = new \PhpOffice\PhpWord\Container\Footer(1); $container = new \PhpOffice\PhpWord\Element\Footer(1);
$container->addText(''); $container->addText('');
$container->addPreserveText(''); $container->addPreserveText('');
$container->addTextBreak(); $container->addTextBreak();

View File

@ -26,7 +26,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
{ {
$imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
$container = new \PhpOffice\PhpWord\Container\Header(1); $container = new \PhpOffice\PhpWord\Element\Header(1);
$container->addText('Test'); $container->addText('Test');
$container->addPreserveText(''); $container->addPreserveText('');
$container->addTextBreak(); $container->addTextBreak();