diff --git a/CHANGELOG.md b/CHANGELOG.md index 962479bd..53d10a2c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ This release marked heavy refactorings on internal code structure with the creat - Test: Add some samples and tests for image wrapping style - @brunocasado GH-59 - Refactor: Remove Style\Tabs - Refactor: Apply composite pattern for writers +- Refactor: Split `AbstractContainer` from `AbstractElement` ## 0.9.1 - 27 Mar 2014 diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php new file mode 100644 index 00000000..72b642bb --- /dev/null +++ b/src/PhpWord/Element/AbstractContainer.php @@ -0,0 +1,456 @@ +setElementIndex($this->countElements() + 1); + $element->setElementId(); + $this->elements[] = $element; + } + + /** + * Get all elements + * + * @return array + */ + public function getElements() + { + return $this->elements; + } + + /** + * Count elements + * + * @return integer + */ + public function countElements() + { + return count($this->elements); + } + + /** + * Add text element + * + * @param string $text + * @param mixed $fontStyle + * @param mixed $paragraphStyle + * @return Text + */ + public function addText($text, $fontStyle = null, $paragraphStyle = null) + { + $this->checkValidity('text'); + + // Reset paragraph style for footnote and textrun. They have their own + if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { + $paragraphStyle = null; + } + + $text = String::toUTF8($text); + $textObject = new Text($text, $fontStyle, $paragraphStyle); + $textObject->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($textObject); + + return $textObject; + } + + /** + * Add textrun element + * + * @param mixed $paragraphStyle + * @return TextRun + */ + public function addTextRun($paragraphStyle = null) + { + $this->checkValidity('textrun'); + + $textRun = new TextRun($paragraphStyle); + $textRun->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($textRun); + + return $textRun; + } + + /** + * Add link element + * + * @param string $linkSrc + * @param string $linkName + * @param mixed $fontStyle + * @param mixed $paragraphStyle + * @return Link + */ + public function addLink($linkSrc, $linkName = null, $fontStyle = null, $paragraphStyle = null) + { + $this->checkValidity('link'); + $elementDocPart = $this->checkElementDocPart(); + + $link = new Link(String::toUTF8($linkSrc), String::toUTF8($linkName), $fontStyle, $paragraphStyle); + $link->setDocPart($this->getDocPart(), $this->getDocPartId()); + $rId = Media::addElement($elementDocPart, 'link', $linkSrc); + $link->setRelationId($rId); + $this->addElement($link); + + return $link; + } + + /** + * Add a Title Element + * + * @param string $text + * @param int $depth + * @return Title + * @todo Enable title element in other containers + */ + public function addTitle($text, $depth = 1) + { + $this->checkValidity('title'); + + $styles = Style::getStyles(); + if (array_key_exists('Heading_' . $depth, $styles)) { + $style = 'Heading' . $depth; + } else { + $style = null; + } + $text = String::toUTF8($text); + $title = new Title($text, $depth, $style); + $title->setDocPart($this->getDocPart(), $this->getDocPartId()); + $data = Titles::addTitle($text, $depth); + $anchor = $data[0]; + $bookmarkId = $data[1]; + $title->setAnchor($anchor); + $title->setBookmarkId($bookmarkId); + $this->addElement($title); + + return $title; + } + + /** + * Add preserve text element + * + * @param string $text + * @param mixed $fontStyle + * @param mixed $paragraphStyle + * @return PreserveText + */ + public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) + { + $this->checkValidity('preservetext'); + + $preserveText = new PreserveText(String::toUTF8($text), $fontStyle, $paragraphStyle); + $preserveText->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($preserveText); + + return $preserveText; + } + + /** + * Add text break element + * + * @param int $count + * @param mixed $fontStyle + * @param mixed $paragraphStyle + */ + public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) + { + $this->checkValidity('textbreak'); + + for ($i = 1; $i <= $count; $i++) { + $textBreak = new TextBreak($fontStyle, $paragraphStyle); + $textBreak->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($textBreak); + } + } + + /** + * Add listitem element + * + * @param string $text + * @param int $depth + * @param mixed $fontStyle + * @param mixed $styleList + * @param mixed $paragraphStyle + * @return ListItem + */ + public function addListItem($text, $depth = 0, $fontStyle = null, $styleList = null, $paragraphStyle = null) + { + $this->checkValidity('listitem'); + + $listItem = new ListItem(String::toUTF8($text), $depth, $fontStyle, $styleList, $paragraphStyle); + $listItem->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($listItem); + + return $listItem; + } + + /** + * Add table element + * + * @param mixed $style + * @return Table + */ + public function addTable($style = null) + { + $this->checkValidity('table'); + + $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($table); + + return $table; + } + + /** + * Add image element + * + * @param string $src + * @param mixed $style Image style + * @param boolean $isWatermark + * @return Image + */ + public function addImage($src, $style = null, $isWatermark = false) + { + $this->checkValidity('image'); + $elementDocPart = $this->checkElementDocPart(); + + $image = new Image($src, $style, $isWatermark); + $image->setDocPart($this->getDocPart(), $this->getDocPartId()); + $rId = Media::addElement($elementDocPart, 'image', $src, $image); + $image->setRelationId($rId); + $this->addElement($image); + + return $image; + } + + /** + * Add OLE-object element + * + * All exceptions should be handled by \PhpOffice\PhpWord\Element\Object + * + * @param string $src + * @param mixed $style + * @return Object + * @throws \PhpOffice\PhpWord\Exception\Exception + * @todo Enable OLE object element in header and footer + */ + public function addObject($src, $style = null) + { + $this->checkValidity('object'); + $elementDocPart = $this->checkElementDocPart(); + + $object = new Object($src, $style); + $object->setDocPart($this->getDocPart(), $this->getDocPartId()); + if (!is_null($object->getSource())) { + $inf = pathinfo($src); + $ext = $inf['extension']; + if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { + $ext = substr($ext, 0, -1); + } + $icon = realpath(__DIR__ . "/../_staticDocParts/_{$ext}.png"); + $rId = Media::addElement($elementDocPart, 'object', $src); + $object->setRelationId($rId); + $rIdimg = Media::addElement($elementDocPart, 'image', $icon, new Image($icon)); + $object->setImageRelationId($rIdimg); + $this->addElement($object); + + return $object; + } else { + throw new InvalidObjectException(); + } + } + + /** + * Add footnote element + * + * @param mixed $paragraphStyle + * @return Footnote + */ + public function addFootnote($paragraphStyle = null) + { + $this->checkValidity('footnote'); + + $footnote = new Footnote($paragraphStyle); + $rId = Footnotes::addElement($footnote); + + $footnote->setDocPart('footnote', $this->getDocPartId()); + $footnote->setRelationId($rId); + $this->addElement($footnote); + + return $footnote; + } + + /** + * Add endnote element + * + * @param mixed $paragraphStyle + * @return Endnote + */ + public function addEndnote($paragraphStyle = null) + { + $this->checkValidity('endnote'); + + $endnote = new Endnote($paragraphStyle); + $rId = Endnotes::addElement($endnote); + + $endnote->setDocPart('endnote', $this->getDocPartId()); + $endnote->setRelationId($rId); + $this->addElement($endnote); + + return $endnote; + } + + /** + * Add a CheckBox Element + * + * @param string $name + * @param string $text + * @param mixed $fontStyle + * @param mixed $paragraphStyle + * @return CheckBox + */ + public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null) + { + $this->checkValidity('checkbox'); + + $checkBox = new CheckBox(String::toUTF8($name), String::toUTF8($text), $fontStyle, $paragraphStyle); + $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($checkBox); + + return $checkBox; + } + + /** + * 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', 'endnote'); + $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'), + 'endnote' => array('section', 'textrun', 'cell'), + 'preservetext' => array('header', 'footer', 'cell'), + 'title' => array('section'), + ); + // Special condition, e.g. preservetext can only exists in cell when + // the cell is located in header or footer + $validSubcontainers = array( + 'preservetext' => array(array('cell'), array('header', 'footer')), + 'footnote' => array(array('cell', 'textrun'), array('section')), + 'endnote' => 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, $validSubcontainers)) { + $rules = $validSubcontainers[$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 + * + * @param string $src + * @param mixed $style + * @deprecated 0.9.0 + * @codeCoverageIgnore + */ + public function addMemoryImage($src, $style = null) + { + return $this->addImage($src, $style); + } + + /** + * Create textrun element + * + * @param mixed $paragraphStyle + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function createTextRun($paragraphStyle = null) + { + return $this->addTextRun($paragraphStyle); + } + + /** + * Create footnote element + * + * @param mixed $paragraphStyle + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function createFootnote($paragraphStyle = null) + { + return $this->addFootnote($paragraphStyle); + } +} diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 66683980..6e993748 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -9,13 +9,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Endnotes; -use PhpOffice\PhpWord\Footnotes; -use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\TOC as Titles; -use PhpOffice\PhpWord\Exception\InvalidObjectException; -use PhpOffice\PhpWord\Shared\String; /** * Element abstract class @@ -60,13 +54,6 @@ abstract class AbstractElement */ protected $docPartId = 1; - /** - * Elements collection - * - * @var array - */ - protected $elements = array(); - /** * Index of element in the elements collection (start with 1) * @@ -88,295 +75,6 @@ abstract class AbstractElement */ protected $relationId; - /** - * Add text element - * - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return Text - */ - public function addText($text, $fontStyle = null, $paragraphStyle = null) - { - $this->checkValidity('text'); - - // Reset paragraph style for footnote and textrun. They have their own - if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { - $paragraphStyle = null; - } - - $text = String::toUTF8($text); - $textObject = new Text($text, $fontStyle, $paragraphStyle); - $textObject->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textObject); - - return $textObject; - } - - /** - * Add textrun element - * - * @param mixed $paragraphStyle - * @return TextRun - */ - public function addTextRun($paragraphStyle = null) - { - $this->checkValidity('textrun'); - - $textRun = new TextRun($paragraphStyle); - $textRun->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textRun); - - return $textRun; - } - - /** - * Add link element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return Link - */ - public function addLink($linkSrc, $linkName = null, $fontStyle = null, $paragraphStyle = null) - { - $this->checkValidity('link'); - $elementDocPart = $this->checkElementDocPart(); - - $link = new Link(String::toUTF8($linkSrc), String::toUTF8($linkName), $fontStyle, $paragraphStyle); - $link->setDocPart($this->getDocPart(), $this->getDocPartId()); - $rId = Media::addElement($elementDocPart, 'link', $linkSrc); - $link->setRelationId($rId); - $this->addElement($link); - - return $link; - } - - /** - * Add a Title Element - * - * @param string $text - * @param int $depth - * @return Title - * @todo Enable title element in other containers - */ - public function addTitle($text, $depth = 1) - { - $this->checkValidity('title'); - - $styles = Style::getStyles(); - if (array_key_exists('Heading_' . $depth, $styles)) { - $style = 'Heading' . $depth; - } else { - $style = null; - } - $text = String::toUTF8($text); - $title = new Title($text, $depth, $style); - $title->setDocPart($this->getDocPart(), $this->getDocPartId()); - $data = Titles::addTitle($text, $depth); - $anchor = $data[0]; - $bookmarkId = $data[1]; - $title->setAnchor($anchor); - $title->setBookmarkId($bookmarkId); - $this->addElement($title); - - return $title; - } - - /** - * Add preserve text element - * - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return PreserveText - */ - public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) - { - $this->checkValidity('preservetext'); - - $preserveText = new PreserveText(String::toUTF8($text), $fontStyle, $paragraphStyle); - $preserveText->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($preserveText); - - return $preserveText; - } - - /** - * Add text break element - * - * @param int $count - * @param mixed $fontStyle - * @param mixed $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - $this->checkValidity('textbreak'); - - for ($i = 1; $i <= $count; $i++) { - $textBreak = new TextBreak($fontStyle, $paragraphStyle); - $textBreak->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textBreak); - } - } - - /** - * Add listitem element - * - * @param string $text - * @param int $depth - * @param mixed $fontStyle - * @param mixed $styleList - * @param mixed $paragraphStyle - * @return ListItem - */ - public function addListItem($text, $depth = 0, $fontStyle = null, $styleList = null, $paragraphStyle = null) - { - $this->checkValidity('listitem'); - - $listItem = new ListItem(String::toUTF8($text), $depth, $fontStyle, $styleList, $paragraphStyle); - $listItem->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($listItem); - - return $listItem; - } - - /** - * Add table element - * - * @param mixed $style - * @return Table - */ - public function addTable($style = null) - { - $this->checkValidity('table'); - - $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($table); - - return $table; - } - - /** - * Add image element - * - * @param string $src - * @param mixed $style Image style - * @param boolean $isWatermark - * @return Image - */ - public function addImage($src, $style = null, $isWatermark = false) - { - $this->checkValidity('image'); - $elementDocPart = $this->checkElementDocPart(); - - $image = new Image($src, $style, $isWatermark); - $image->setDocPart($this->getDocPart(), $this->getDocPartId()); - $rId = Media::addElement($elementDocPart, 'image', $src, $image); - $image->setRelationId($rId); - $this->addElement($image); - - return $image; - } - - /** - * Add OLE-object element - * - * All exceptions should be handled by \PhpOffice\PhpWord\Element\Object - * - * @param string $src - * @param mixed $style - * @return Object - * @throws \PhpOffice\PhpWord\Exception\Exception - * @todo Enable OLE object element in header and footer - */ - public function addObject($src, $style = null) - { - $this->checkValidity('object'); - $elementDocPart = $this->checkElementDocPart(); - - $object = new Object($src, $style); - $object->setDocPart($this->getDocPart(), $this->getDocPartId()); - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - $icon = realpath(__DIR__ . "/../_staticDocParts/_{$ext}.png"); - $rId = Media::addElement($elementDocPart, 'object', $src); - $object->setRelationId($rId); - $rIdimg = Media::addElement($elementDocPart, 'image', $icon, new Image($icon)); - $object->setImageRelationId($rIdimg); - $this->addElement($object); - - return $object; - } else { - throw new InvalidObjectException(); - } - } - - /** - * Add footnote element - * - * @param mixed $paragraphStyle - * @return Footnote - */ - public function addFootnote($paragraphStyle = null) - { - $this->checkValidity('footnote'); - - $footnote = new Footnote($paragraphStyle); - $rId = Footnotes::addElement($footnote); - - $footnote->setDocPart('footnote', $this->getDocPartId()); - $footnote->setRelationId($rId); - $this->addElement($footnote); - - return $footnote; - } - - /** - * Add endnote element - * - * @param mixed $paragraphStyle - * @return Endnote - */ - public function addEndnote($paragraphStyle = null) - { - $this->checkValidity('endnote'); - - $endnote = new Endnote($paragraphStyle); - $rId = Endnotes::addElement($endnote); - - $endnote->setDocPart('endnote', $this->getDocPartId()); - $endnote->setRelationId($rId); - $this->addElement($endnote); - - return $endnote; - } - - /** - * Add a CheckBox Element - * - * @param string $name - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return CheckBox - */ - public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null) - { - $this->checkValidity('checkbox'); - - $checkBox = new CheckBox(String::toUTF8($name), String::toUTF8($text), $fontStyle, $paragraphStyle); - $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($checkBox); - - return $checkBox; - } - /** * Get section number * @@ -419,36 +117,6 @@ abstract class AbstractElement return $this->docPartId; } - /** - * Set element index and unique id, and add element into elements collection - */ - protected function addElement(AbstractElement $element) - { - $element->setElementIndex($this->countElements() + 1); - $element->setElementId(); - $this->elements[] = $element; - } - - /** - * Get all elements - * - * @return array - */ - public function getElements() - { - return $this->elements; - } - - /** - * Count elements - * - * @return integer - */ - public function countElements() - { - return count($this->elements); - } - /** * Get element index * @@ -494,7 +162,6 @@ abstract class AbstractElement */ public function getRelationId() { - $this->checkValidity('relationid'); return $this->relationId; } @@ -505,7 +172,6 @@ abstract class AbstractElement */ public function setRelationId($rId) { - $this->checkValidity('relationid'); $this->relationId = $rId; } @@ -539,108 +205,4 @@ abstract class AbstractElement 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', 'endnote'); - $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'), - 'endnote' => array('section', 'textrun', 'cell'), - 'preservetext' => array('header', 'footer', 'cell'), - 'title' => array('section'), - ); - // Special condition, e.g. preservetext can only exists in cell when - // the cell is located in header or footer - $validSubcontainers = array( - 'preservetext' => array(array('cell'), array('header', 'footer')), - 'footnote' => array(array('cell', 'textrun'), array('section')), - 'endnote' => 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, $validSubcontainers)) { - $rules = $validSubcontainers[$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 - * - * @param string $src - * @param mixed $style - * @deprecated 0.9.0 - * @codeCoverageIgnore - */ - public function addMemoryImage($src, $style = null) - { - return $this->addImage($src, $style); - } - - /** - * Create textrun element - * - * @param mixed $paragraphStyle - * @deprecated 0.10.0 - * @codeCoverageIgnore - */ - public function createTextRun($paragraphStyle = null) - { - return $this->addTextRun($paragraphStyle); - } - - /** - * Create footnote element - * - * @param mixed $paragraphStyle - * @deprecated 0.10.0 - * @codeCoverageIgnore - */ - public function createFootnote($paragraphStyle = null) - { - return $this->addFootnote($paragraphStyle); - } } diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index fe76ef3d..e3d3dd06 100755 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Cell as CellStyle; /** * Table cell element */ -class Cell extends AbstractElement +class Cell extends AbstractContainer { /** * Cell width diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 8db9c6eb..50ec8236 100755 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Element; /** * Footer element */ -class Footer extends AbstractElement +class Footer extends AbstractContainer { const AUTO = 'default'; // default and odd pages const FIRST = 'first'; diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index de303330..bb8d6170 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Footnote element */ -class Footnote extends AbstractElement +class Footnote extends AbstractContainer { /** * Paragraph style diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index e4211d29..2c963d84 100755 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Element\Image; /** * Header element */ -class Header extends AbstractElement +class Header extends AbstractContainer { /** * Header types constants diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index d78904eb..59d8eb2e 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -17,7 +17,7 @@ use PhpOffice\PhpWord\Element\TOC; /** * Section */ -class Section extends AbstractElement +class Section extends AbstractContainer { /** * Section settings diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index a79c9583..a8428d1e 100755 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Textrun/paragraph element */ -class TextRun extends AbstractElement +class TextRun extends AbstractContainer { /** * Paragraph style diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 2acbc8d7..7972eb37 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -9,8 +9,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; -use PhpOffice\PhpWord\Style\Cell; -use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 967947fb..c2f53102 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -9,10 +9,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; -use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Style\Paragraph; - /** * Text element writer * diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 01a30baa..016510e1 100755 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -81,8 +81,6 @@ class RTF extends AbstractWriter implements WriterInterface /** * Get color table - * - * @param mixed $value */ public function getColorTable() { @@ -91,8 +89,6 @@ class RTF extends AbstractWriter implements WriterInterface /** * Get font table - * - * @param mixed $value */ public function getFontTable() { @@ -101,8 +97,6 @@ class RTF extends AbstractWriter implements WriterInterface /** * Get last paragraph style - * - * @param mixed $value */ public function getLastParagraphStyle() { diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 8041b680..1ef4b6de 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -12,7 +12,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Style\Paragraph; /** * Text element RTF writer diff --git a/src/PhpWord/Writer/Word2007/Base.php b/src/PhpWord/Writer/Word2007/Base.php index bc9e332a..bae18410 100644 --- a/src/PhpWord/Writer/Word2007/Base.php +++ b/src/PhpWord/Writer/Word2007/Base.php @@ -14,8 +14,6 @@ use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Element\TextBreak; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Writer\Word2007\Element\Element as ElementWriter; /**