From 9c11067720f905486550c7aed4cc6530cb1d4980 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sat, 3 May 2014 10:08:39 +0200 Subject: [PATCH 001/167] Added Image relative and absolute positioning --- src/PhpWord/Style/Image.php | 240 +++++++++++++++++- src/PhpWord/Writer/Word2007/Element/Image.php | 31 ++- 2 files changed, 263 insertions(+), 8 deletions(-) diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index f21e667408..7aabdeb2ff 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -19,7 +19,32 @@ class Image extends AbstractStyle const WRAPPING_STYLE_TIGHT = 'tight'; const WRAPPING_STYLE_BEHIND = 'behind'; const WRAPPING_STYLE_INFRONT = 'infront'; - + const POSITION_HORIZONTAL_LEFT = 'left'; + const POSITION_HORIZONTAL_CENTER = 'centered'; + const POSITION_HORIZONTAL_RIGHT = 'right'; + const POSITION_VERTICAL_TOP = 'top'; + const POSITION_VERTICAL_CENTER = 'center'; + const POSITION_VERTICAL_BOTTOM = 'bottom'; + const POSITION_VERTICAL_INSIDE = 'inside'; + const POSITION_VERTICAL_OUTSIDE = 'outside'; + const POSITION_HORIZONTAL_RELATIVE_MARGIN = 'margin'; + const POSITION_HORIZONTAL_RELATIVE_PAGE = 'page'; + const POSITION_HORIZONTAL_RELATIVE_COLUMN = 'column'; + const POSITION_HORIZONTAL_RELATIVE_CHAR = 'char'; + const POSITION_HORIZONTAL_RELATIVE_LMARGIN = 'left-margin-area'; + const POSITION_HORIZONTAL_RELATIVE_RMARGIN = 'right-margin-area'; + const POSITION_HORIZONTAL_RELATIVE_IMARGIN = 'inner-margin-area'; + const POSITION_HORIZONTAL_RELATIVE_OMARGIN = 'outer-margin-area'; + const POSITION_VERTICAL_RELATIVE_MARGIN = 'margin'; + const POSITION_VERTICAL_RELATIVE_PAGE = 'page'; + const POSITION_VERTICAL_RELATIVE_LINE = 'line'; + const POSITION_VERTICAL_RELATIVE_TMARGIN = 'top-margin-area'; + const POSITION_VERTICAL_RELATIVE_BMARGIN = 'bottom-margin-area'; + const POSITION_VERTICAL_RELATIVE_IMARGIN = 'inner-margin-area'; + const POSITION_VERTICAL_RELATIVE_OMARGIN = 'outer-margin-area'; + const POSITION_RELATIVE = 'relative'; + const POSITION_ABSOLUTE = 'absolute'; + /** * Image width * @@ -62,6 +87,42 @@ class Image extends AbstractStyle */ private $wrappingStyle; + /** + * Horizontal alignment + * + * @var string + */ + private $posHorizontal; + + /** + * Horizontal Relation + * + * @var string + */ + private $posHorizontalRel; + + /** + * Vertical alignment + * + * @var string + */ + private $posVertical; + + /** + * Vertical Relation + * + * @var string + */ + private $posVerticalRel; + + /** + * Positioning type (Relative or Absolute) + * + * @var string + */ + private $positioning; + + /** * Create new image style */ @@ -73,6 +134,11 @@ public function __construct() $this->marginTop = null; $this->marginLeft = null; $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); + $this->setPositioning(self::POSITION_RELATIVE); + $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); + $this->setPosHorizontalRel(self::POSITION_HORIZONTAL_RELATIVE_CHAR); + $this->setPosVertical(self::POSITION_VERTICAL_TOP); + $this->setPosVerticalRel(self::POSITION_VERTICAL_RELATIVE_LINE); } /** @@ -205,4 +271,176 @@ public function getWrappingStyle() { return $this->wrappingStyle; } + + /** + * Set positioning type + * + * @param string $positioning + * @throws \InvalidArgumentException + * @return $this + */ + + public function setPositioning($positioning) + { + switch ($positioning) { + case self::POSITION_RELATIVE: + case self::POSITION_ABSOLUTE: + $this->positioning = $positioning; + break; + default: + throw new InvalidArgumentException('Positioning does not exists'); + break; + } + return $this; + } + + /** + * Get positioning type + * + * @return string + */ + public function getPositioning() + { + return $this->positioning; + } + + /** + * Set horizontal alignment + * + * @param string $alignment + * @throws \InvalidArgumentException + * @return $this + */ + public function setPosHorizontal($alignment) + { + switch ($alignment) { + case self::POSITION_HORIZONTAL_LEFT: + case self::POSITION_HORIZONTAL_CENTER: + case self::POSITION_HORIZONTAL_RIGHT: + $this->posHorizontal = $alignment; + break; + default: + throw new InvalidArgumentException('Horizontal alignment does not exists'); + break; + } + return $this; + } + + /** + * Get horizontal alignment + * + * @return string + */ + public function getPosHorizontal() + { + return $this->posHorizontal; + } + + /** + * Set vertical alignment + * + * @param string $alignment + * @throws \InvalidArgumentException + * @return $this + */ + + public function setPosVertical($alignment) + { + switch ($alignment) { + case self::POSITION_VERTICAL_TOP: + case self::POSITION_VERTICAL_CENTER: + case self::POSITION_VERTICAL_BOTTOM: + case self::POSITION_VERTICAL_INSIDE: + case self::POSITION_VERTICAL_OUTSIDE: + $this->posVertical = $alignment; + break; + default: + throw new InvalidArgumentException('Vertical alignment does not exists'); + break; + } + return $this; + } + + /** + * Get vertical alignment + * + * @return string + */ + public function getPosVertical() + { + return $this->posVertical; + } + + /** + * Set horizontal relation + * + * @param string $relto + * @throws \InvalidArgumentException + * @return $this + */ + public function setPosHorizontalRel($relto) + { + switch ($relto) { + case self::POSITION_HORIZONTAL_RELATIVE_MARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_PAGE: + case self::POSITION_HORIZONTAL_RELATIVE_COLUMN: + case self::POSITION_HORIZONTAL_RELATIVE_CHAR: + case self::POSITION_HORIZONTAL_RELATIVE_LMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_RMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_IMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_OMARGIN: + $this->posHorizontalRel = $relto; + break; + default: + throw new InvalidArgumentException('Horizontal relation does not exists'); + break; + } + return $this; + } + + /** + * Get horizontal relation + * + * @return string + */ + public function getPosHorizontalRel() + { + return $this->posHorizontalRel; + } + + /** + * Set vertical relation + * + * @param string $relto + * @throws \InvalidArgumentException + * @return $this + */ + public function setPosVerticalRel($relto) + { + switch ($relto) { + case self::POSITION_VERTICAL_RELATIVE_MARGIN: + case self::POSITION_VERTICAL_RELATIVE_PAGE: + case self::POSITION_VERTICAL_RELATIVE_LINE: + case self::POSITION_VERTICAL_RELATIVE_TMARGIN: + case self::POSITION_VERTICAL_RELATIVE_BMARGIN: + case self::POSITION_VERTICAL_RELATIVE_IMARGIN: + case self::POSITION_VERTICAL_RELATIVE_OMARGIN: + $this->posVerticalRel = $relto; + break; + default: + throw new InvalidArgumentException('Vertical relation does not exists'); + break; + } + return $this; + } + + /** + * Get vertical relation + * + * @return string + */ + public function getPosVerticalRel() + { + return $this->posVerticalRel; + } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index e944b7af53..80b71121da 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -44,6 +44,7 @@ private function writeImage() $marginTop = $style->getMarginTop(); $marginLeft = $style->getMarginLeft(); $wrappingStyle = $style->getWrappingStyle(); + $positioning = $style->getPositioning(); $w10wrapType = null; $imgStyle = ''; if (null !== $width) { @@ -53,28 +54,44 @@ private function writeImage() $imgStyle .= 'height:' . $height . 'px;'; } if (null !== $marginTop) { - $imgStyle .= 'margin-top:' . $marginTop . 'in;'; + $imgStyle .= 'margin-top:' . $marginTop . 'px;'; } if (null !== $marginLeft) { - $imgStyle .= 'margin-left:' . $marginLeft . 'in;'; + $imgStyle .= 'margin-left:' . $marginLeft . 'px;'; } + $imgStyle.='position:absolute;mso-width-percent:0;mso-height-percent:0;mso-width-relative:margin;mso-height-relative:margin;'; + switch ($positioning) { + case ImageStyle::POSITION_RELATIVE: + $imgStyle.='mso-position-horizontal:'.$style->getPosHorizontal().';'; + $imgStyle.='mso-position-horizontal-relative:'.$style->getPosHorizontalRel().';'; + $imgStyle.='mso-position-vertical:'.$style->getPosVertical().';'; + $imgStyle.='mso-position-vertical-relative:'.$style->getPosVerticalRel().';'; + $imgStyle.='margin-left:0;margin-top:0;'; + break; + + case ImageStyle::POSITION_ABSOLUTE: + $imgStyle.='mso-position-horizontal-relative:page;'; + $imgStyle.='mso-position-vertical-relative:page;'; + break; + } + switch ($wrappingStyle) { case ImageStyle::WRAPPING_STYLE_BEHIND: - $imgStyle .= 'position:absolute;z-index:-251658752;'; + $imgStyle .= 'z-index:-251658752;'; break; case ImageStyle::WRAPPING_STYLE_INFRONT: - $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; break; case ImageStyle::WRAPPING_STYLE_SQUARE: - $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; $w10wrapType = 'square'; break; case ImageStyle::WRAPPING_STYLE_TIGHT: - $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; + $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; $w10wrapType = 'tight'; break; } - + if (!$this->withoutP) { $this->xmlWriter->startElement('w:p'); if (!is_null($align)) { From 725162bc6b433f4eaa2beb0a28fe9ef791150a20 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 00:57:44 +0700 Subject: [PATCH 002/167] Deprecate static classes Footnotes, Endnotes, and TOC (#206); Reactivate `phpcpd` and `phpmd` on Travis --- .travis.yml | 18 +- CHANGELOG.md | 5 +- samples/resources/Sample_11_ReadWord2007.docx | Bin 69796 -> 69796 bytes src/PhpWord/Collection/AbstractCollection.php | 87 ++++++++ src/PhpWord/Collection/Endnotes.php | 19 ++ src/PhpWord/Collection/Footnotes.php | 19 ++ src/PhpWord/Collection/Titles.php | 19 ++ src/PhpWord/Element/AbstractContainer.php | 192 +++++++----------- src/PhpWord/Element/AbstractElement.php | 26 +++ src/PhpWord/Element/CheckBox.php | 4 +- src/PhpWord/Element/Footer.php | 70 ++++++- src/PhpWord/Element/Header.php | 84 +------- src/PhpWord/Element/Link.php | 5 +- src/PhpWord/Element/ListItem.php | 3 +- src/PhpWord/Element/PreserveText.php | 4 +- src/PhpWord/Element/Row.php | 1 + src/PhpWord/Element/Section.php | 48 ++++- src/PhpWord/Element/TOC.php | 14 +- src/PhpWord/Element/Table.php | 1 + src/PhpWord/Element/Text.php | 3 +- src/PhpWord/Element/Title.php | 63 +++--- src/PhpWord/Endnotes.php | 95 --------- src/PhpWord/Footnotes.php | 23 +-- src/PhpWord/PhpWord.php | 129 ++++++++++-- src/PhpWord/Reader/Word2007/DocProps.php | 63 ------ src/PhpWord/Reader/Word2007/DocPropsApp.php | 9 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 35 +++- src/PhpWord/Reader/Word2007/Notes.php | 9 +- src/PhpWord/Style/TOC.php | 49 ++--- src/PhpWord/Style/Tab.php | 54 ++++- src/PhpWord/TOC.php | 6 + src/PhpWord/Writer/HTML.php | 6 +- src/PhpWord/Writer/HTML/Element/Endnote.php | 8 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 23 ++- src/PhpWord/Writer/HTML/Element/Note.php | 34 ---- src/PhpWord/Writer/Word2007.php | 28 ++- .../Writer/Word2007/Element/Endnote.php | 12 +- .../Writer/Word2007/Element/Footnote.php | 27 ++- src/PhpWord/Writer/Word2007/Element/Note.php | 48 ----- src/PhpWord/Writer/Word2007/Element/TOC.php | 61 +++--- src/PhpWord/Writer/Word2007/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 2 +- tests/PhpWord/Tests/Element/SectionTest.php | 5 +- tests/PhpWord/Tests/Element/TOCTest.php | 16 +- tests/PhpWord/Tests/Element/TextRunTest.php | 2 + tests/PhpWord/Tests/Element/TitleTest.php | 22 -- tests/PhpWord/Tests/EndnotesTest.php | 39 ---- tests/PhpWord/Tests/FootnotesTest.php | 39 ---- tests/PhpWord/Tests/PhpWordTest.php | 3 +- tests/PhpWord/Tests/Style/TOCTest.php | 8 +- tests/PhpWord/Tests/TOCTest.php | 53 ----- 51 files changed, 781 insertions(+), 814 deletions(-) create mode 100644 src/PhpWord/Collection/AbstractCollection.php create mode 100644 src/PhpWord/Collection/Endnotes.php create mode 100644 src/PhpWord/Collection/Footnotes.php create mode 100644 src/PhpWord/Collection/Titles.php delete mode 100644 src/PhpWord/Endnotes.php delete mode 100644 src/PhpWord/Reader/Word2007/DocProps.php delete mode 100644 src/PhpWord/Writer/HTML/Element/Note.php delete mode 100644 src/PhpWord/Writer/Word2007/Element/Note.php delete mode 100644 tests/PhpWord/Tests/EndnotesTest.php delete mode 100644 tests/PhpWord/Tests/FootnotesTest.php delete mode 100644 tests/PhpWord/Tests/TOCTest.php diff --git a/.travis.yml b/.travis.yml index ad3df6137d..cf69291fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,14 +25,14 @@ before_script: - pyrus install pear/PHP_CodeSniffer - phpenv rehash ## PHP Copy/Paste Detector - #- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar + - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar ## PHP Mess Detector - #- pear config-set preferred_state beta - #- printf "\n" | pecl install imagick - #- pear channel-discover pear.phpmd.org - #- pear channel-discover pear.pdepend.org - #- pear install --alldeps phpmd/PHP_PMD - #- phpenv rehash + - pear config-set preferred_state beta + - printf "\n" | pecl install imagick + - pear channel-discover pear.phpmd.org + - pear channel-discover pear.pdepend.org + - pear install --alldeps phpmd/PHP_PMD + - phpenv rehash ## PHPLOC #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar @@ -41,9 +41,9 @@ script: - phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip - phpcs --standard=PSR2 -n tests/ ## PHP Copy/Paste Detector - #- php phpcpd.phar --verbose src/ + - php phpcpd.phar --verbose src/ ## PHP Mess Detector - #- phpmd src/ text unusedcode,naming,design + - phpmd src/ text phpmd.xml --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/CHANGELOG.md b/CHANGELOG.md index e23edf9132..ccdac7eef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ This release marked heavy refactorings on internal code structure with the creat - Link: Ability to add link in header/footer - @ivanlanin GH-187 - Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187 - Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19 -- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187 +- General: Add `Style::resetStyles()` - @ivanlanin GH-187 - DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin - Endnote: Ability to add endnotes - @ivanlanin - ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198 @@ -66,6 +66,7 @@ This release marked heavy refactorings on internal code structure with the creat - `Element\Link::getLinkSrc` replaced by `Element\Link::getTarget` - `Element\Link::getLinkName` replaced by `Element\Link::getText` - `Style\Cell::getDefaultBorderColor` +- Static classes `Footnotes`, `Endnotes`, and `TOC` ### Miscellaneous @@ -87,6 +88,8 @@ This release marked heavy refactorings on internal code structure with the creat - Refactor: Apply composite pattern for writers - @ivanlanin - Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin - Refactor: Apply composite pattern for Word2007 reader - @ivanlanin +- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 +- QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin ## 0.9.1 - 27 Mar 2014 diff --git a/samples/resources/Sample_11_ReadWord2007.docx b/samples/resources/Sample_11_ReadWord2007.docx index 2143c628c5132f5948c339538bef2c2fabdab545..aefe9f485ea617defd77ba8129edd70dd2fbb789 100644 GIT binary patch delta 646 zcmV;10(t$Up#-F%1c0;wB?lyU#3eR90ssKE1pojL0QUf7Z(~q$Z*X%jVQ_FRcx`MT zqVoWi&H?j(v{YSh(=Zf$N8&$3d0(Awqm0V+ggT)j4OWqCd-j~0*21wZ+pAW7J=bxY zrO+XUM4s+fuCLGWx%Bd>RoModmqyR>@ubD=G1C}-*Ybd_TM^SVQoxlFk1gmxPK#nf z;3T`A6O1I2&ez;=5fDQ5;q;u6flohLtEAuo!DU~haK@V^WH%iQ zS^S@Wl3@u&Xi5-|PKGTjC>gr+T56o+JtfJ&$sAufZr7gS$ODg-f-9Kg{aM462TGm; zbOAhayW|q*rJFF_fC$EAUj9IKk?aTVA)+?RH{40C1ELqplGEAB`rue4gTmgJOMYh# z%Z9c*j~HSt8h?UjSF}gu|GIsJFZ6$Zjb18QL)L-wn(<#iC*CPBgs>fQmyWn; zkoj;(yU#3eR90ssKEmuV0IJIujB8~^|S delta 622 zcmV-!0+Icsp#-F%1c0;wB?lbkzG9y(0ssK71pojL00;qOZ(~q$Z*X%jVQ_G>Q2Go3 zf3#FxZ`&XgeV?@dVEMhlNwchr2-TEo%A{_M7Poz-_&PzufPhBLe*G>c@tiK3lu6_1 zesMV5%Yk0MG%DMI^U~;9J{%Nz23nX(>h&zYFF##e<(Us$S6mqlvwR0Wzh-aW(4{jL zT#(>1gwTGLZ$hwBLcG{O!~Fo$8Z)(Ve+>`lx-~I%Ed|^d@!Wt8WKZaf=BdYwmCf-9Kg{aMYG2TFbg=mL10?UKvL zZyTmt5W%?2%O5yh9QG6U5W61y6sW6|T)O~Sv*;jNgMOPSwD+>G8sjLgo z1$N!3cmVFzYp4!2zbE1!@sR#sHhecIaJ8SpA%@cKK1TKvw{!{t>;(zszG9y(0ssK7 ImuV0II|A=0@c;k- diff --git a/src/PhpWord/Collection/AbstractCollection.php b/src/PhpWord/Collection/AbstractCollection.php new file mode 100644 index 0000000000..7b5d4579bc --- /dev/null +++ b/src/PhpWord/Collection/AbstractCollection.php @@ -0,0 +1,87 @@ +items; + } + + /** + * Get item by index + * + * @param int $index + * @return mixed + */ + public function getItem($index) + { + if (array_key_exists($index, $this->items)) { + return $this->items[$index]; + } else { + return null; + } + } + + /** + * Set item + * + * @param int $index + * @param mixed $item + */ + public function setItem($index, $item) + { + if (array_key_exists($index, $this->items)) { + $this->items[$index] = $item; + } + } + + /** + * Add new item + * + * @param mixed $item + * @return int + */ + public function addItem($item) + { + $index = $this->countItems() + 1; + $this->items[$index] = $item; + + return $index; + } + + /** + * Get item count + * + * @return int + */ + public function countItems() + { + return count($this->items); + } +} diff --git a/src/PhpWord/Collection/Endnotes.php b/src/PhpWord/Collection/Endnotes.php new file mode 100644 index 0000000000..36c547a320 --- /dev/null +++ b/src/PhpWord/Collection/Endnotes.php @@ -0,0 +1,19 @@ +setElementIndex($this->countElements() + 1); $element->setElementId(); + $element->setPhpWord($this->phpWord); $this->elements[] = $element; } @@ -67,18 +74,17 @@ public function countElements() * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return Text + * @return \PhpOffice\PhpWord\Element\Text */ public function addText($text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('text'); + $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); @@ -90,11 +96,11 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null) * Add textrun element * * @param mixed $paragraphStyle - * @return TextRun + * @return \PhpOffice\PhpWord\Element\TextRun */ public function addTextRun($paragraphStyle = null) { - $this->checkValidity('textrun'); + $this->checkValidity('Textrun'); $textRun = new TextRun($paragraphStyle); $textRun->setDocPart($this->getDocPart(), $this->getDocPartId()); @@ -106,70 +112,39 @@ public function addTextRun($paragraphStyle = null) /** * Add link element * - * @param string $linkSrc - * @param string $linkName + * @param string $target + * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return Link + * @return \PhpOffice\PhpWord\Element\Link */ - public function addLink($linkSrc, $linkName = null, $fontStyle = null, $paragraphStyle = null) + public function addLink($target, $text = null, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('link'); + $this->checkValidity('Link'); $elementDocPart = $this->checkElementDocPart(); - $link = new Link(String::toUTF8($linkSrc), String::toUTF8($linkName), $fontStyle, $paragraphStyle); + $link = new Link($target, $text, $fontStyle, $paragraphStyle); $link->setDocPart($this->getDocPart(), $this->getDocPartId()); - $rId = Media::addElement($elementDocPart, 'link', $linkSrc); + $rId = Media::addElement($elementDocPart, 'link', $target); $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 + * @return \PhpOffice\PhpWord\Element\PreserveText */ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('preservetext'); + $this->checkValidity('PreserveText'); - $preserveText = new PreserveText(String::toUTF8($text), $fontStyle, $paragraphStyle); + $preserveText = new PreserveText($text, $fontStyle, $paragraphStyle); $preserveText->setDocPart($this->getDocPart(), $this->getDocPartId()); $this->addElement($preserveText); @@ -185,7 +160,7 @@ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('textbreak'); + $this->checkValidity('TextBreak'); for ($i = 1; $i <= $count; $i++) { $textBreak = new TextBreak($fontStyle, $paragraphStyle); @@ -200,48 +175,32 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu * @param string $text * @param int $depth * @param mixed $fontStyle - * @param mixed $styleList + * @param mixed $listStyle * @param mixed $paragraphStyle - * @return ListItem + * @return \PhpOffice\PhpWord\Element\ListItem */ - public function addListItem($text, $depth = 0, $fontStyle = null, $styleList = null, $paragraphStyle = null) + public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->checkValidity('listitem'); + $this->checkValidity('ListItem'); - $listItem = new ListItem(String::toUTF8($text), $depth, $fontStyle, $styleList, $paragraphStyle); + $listItem = new ListItem($text, $depth, $fontStyle, $listStyle, $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 + * @return \PhpOffice\PhpWord\Element\Image */ public function addImage($src, $style = null, $isWatermark = false) { - $this->checkValidity('image'); + $this->checkValidity('Image'); $elementDocPart = $this->checkElementDocPart(); $image = new Image($src, $style, $isWatermark); @@ -260,13 +219,12 @@ public function addImage($src, $style = null, $isWatermark = false) * * @param string $src * @param mixed $style - * @return Object + * @return \PhpOffice\PhpWord\Element\Object * @throws \PhpOffice\PhpWord\Exception\Exception - * @todo Enable OLE object element in header and footer */ public function addObject($src, $style = null) { - $this->checkValidity('object'); + $this->checkValidity('Object'); $elementDocPart = $this->checkElementDocPart(); $object = new Object($src, $style); @@ -294,40 +252,36 @@ public function addObject($src, $style = null) * Add footnote element * * @param mixed $paragraphStyle - * @return Footnote + * @param string $elementName + * @return \PhpOffice\PhpWord\Element\Footnote */ - public function addFootnote($paragraphStyle = null) + public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { - $this->checkValidity('footnote'); - - $footnote = new Footnote($paragraphStyle); - $rId = Footnotes::addElement($footnote); - - $footnote->setDocPart('footnote', $this->getDocPartId()); - $footnote->setRelationId($rId); - $this->addElement($footnote); - - return $footnote; + $this->checkValidity($elementName); + $docPart = strtolower($elementName); + $addMethod = "add{$elementName}"; + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; + + $note = new $elementClass($paragraphStyle); + // if ($this->phpWord instanceof PhpWord) { + $rId = $this->phpWord->$addMethod($note); + // } + $note->setDocPart($docPart, $this->getDocPartId()); + $note->setRelationId($rId); + $this->addElement($note); + + return $note; } /** * Add endnote element * * @param mixed $paragraphStyle - * @return Endnote + * @return \PhpOffice\PhpWord\Element\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; + return $this->addFootnote($paragraphStyle, 'Endnote'); } /** @@ -337,13 +291,13 @@ public function addEndnote($paragraphStyle = null) * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return CheckBox + * @return \PhpOffice\PhpWord\Element\CheckBox */ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('checkbox'); + $this->checkValidity('CheckBox'); - $checkBox = new CheckBox(String::toUTF8($name), String::toUTF8($text), $fontStyle, $paragraphStyle); + $checkBox = new CheckBox($name, $text, $fontStyle, $paragraphStyle); $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId()); $this->addElement($checkBox); @@ -361,26 +315,24 @@ 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'), + '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'), + 'Footnote' => array('section', 'textrun', 'cell'), + 'Endnote' => array('section', 'textrun', 'cell'), + 'PreserveText' => array('header', 'footer', 'cell'), ); // 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')), + '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 diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 6e993748ea..fdad7daf2b 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; /** @@ -18,6 +19,11 @@ */ abstract class AbstractElement { + /** + * PhpWord object + */ + protected $phpWord; + /** * Container type section|header|footer|cell|textrun|footnote|endnote * @@ -75,6 +81,26 @@ abstract class AbstractElement */ protected $relationId; + /** + * Get PhpWord + * + * @return \PhpOffice\PhpWord\PhpWord + */ + public function getPhpWord() + { + return $this->phpWord; + } + + /** + * Set PhpWord + * + * @param \PhpOffice\PhpWord\PhpWord + */ + public function setPhpWord(PhpWord &$phpWord = null) + { + $this->phpWord = $phpWord; + } + /** * Get section number * diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index f273c128d4..6353e2d4c0 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -9,6 +9,8 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Shared\String; + /** * Check box element */ @@ -44,7 +46,7 @@ public function __construct($name = null, $text = null, $fontStyle = null, $para */ public function setName($name) { - $this->name = $name; + $this->name = String::toUTF8($name); return $this; } diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 50ec823606..9090720da3 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -9,21 +9,36 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Element\Table; + /** * Footer element */ class Footer extends AbstractContainer { + /** + * Header/footer types constants + * + * @var string + * @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type + */ const AUTO = 'default'; // default and odd pages const FIRST = 'first'; const EVEN = 'even'; + /** + * Container type + * + * @var string + */ + protected $container = 'footer'; + /** * Header type * * @var string */ - private $type = self::AUTO; + protected $type = self::AUTO; /** * Create new instance @@ -32,12 +47,11 @@ class Footer extends AbstractContainer * @param int $footerId * @param string $type */ - public function __construct($sectionId, $footerId = 1, $type = self::AUTO) + public function __construct($sectionId, $containerId = 1, $type = self::AUTO) { - $this->container = 'footer'; $this->sectionId = $sectionId; $this->setType($type); - $this->setDocPart($this->container, ($sectionId - 1) * 3 + $footerId); + $this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId); } /** @@ -48,6 +62,9 @@ public function __construct($sectionId, $footerId = 1, $type = self::AUTO) */ public function setType($value = self::AUTO) { + if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) { + $value = self::AUTO; + } $this->type = $value; } @@ -61,4 +78,49 @@ public function getType() { return $this->type; } + + /** + * Reset type to default + * + * @return string + */ + public function resetType() + { + return $this->type = self::AUTO; + } + + /** + * First page only header + * + * @return string + */ + public function firstPage() + { + return $this->type = self::FIRST; + } + + /** + * Even numbered pages only + * + * @return string + */ + public function evenPage() + { + return $this->type = self::EVEN; + } + + /** + * Add table element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Table + * @todo Merge with the same function on Section + */ + public function addTable($style = null) + { + $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($table); + + return $table; + } } diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index 2c963d84ea..774e63f996 100644 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -14,39 +14,15 @@ /** * Header element */ -class Header extends AbstractContainer +class Header extends Footer { - /** - * Header types constants - * - * @var string - * @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type - */ - const AUTO = 'default'; // default and odd pages - const FIRST = 'first'; - const EVEN = 'even'; /** - * Header type + * Container type * * @var string */ - private $type = self::AUTO; - - /** - * Create new instance - * - * @param int $sectionId - * @param int $headerId - * @param string $type - */ - public function __construct($sectionId, $headerId = 1, $type = self::AUTO) - { - $this->container = 'header'; - $this->sectionId = $sectionId; - $this->setType($type); - $this->setDocPart($this->container, ($sectionId - 1) * 3 + $headerId); - } + protected $container = 'header'; /** * Add a Watermark Element @@ -59,58 +35,4 @@ public function addWatermark($src, $style = null) { return $this->addImage($src, $style, true); } - - /** - * Set header type - * - * @param string $value - * @since 0.10.0 - */ - public function setType($value = self::AUTO) - { - if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) { - $value = self::AUTO; - } - $this->type = $value; - } - - /** - * Get header type - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Reset type to default - * - * @return string - */ - public function resetType() - { - return $this->type = self::AUTO; - } - - /** - * First page only header - * - * @return string - */ - public function firstPage() - { - return $this->type = self::FIRST; - } - - /** - * Even numbered pages only - * - * @return string - */ - public function evenPage() - { - return $this->type = self::EVEN; - } } diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 31b06c68aa..e4ead5d5a1 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -56,8 +57,8 @@ class Link extends AbstractElement */ public function __construct($target, $text = null, $fontStyle = null, $paragraphStyle = null) { - $this->target = $target; - $this->text = is_null($text) ? $target : $text; + $this->target = String::toUTF8($target); + $this->text = is_null($text) ? $this->target : String::toUTF8($text); $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 660615375e..e52d025223 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; /** @@ -49,7 +50,7 @@ class ListItem extends AbstractElement */ public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->textObject = new Text($text, $fontStyle, $paragraphStyle); + $this->textObject = new Text(String::toUTF8($text), $fontStyle, $paragraphStyle); $this->depth = $depth; // Version >= 0.10.0 will pass numbering style name. Older version will use old method diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index ac7d1f52e4..bf280d6688 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -52,7 +53,8 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); - $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $this->text = String::toUTF8($text); + $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->text = $matches; } diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index dc4b8a4430..ed8e1141eb 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -63,6 +63,7 @@ public function __construct($docPart, $docPartId, $height = null, $style = null) public function addCell($width = null, $style = null) { $cell = new Cell($this->getDocPart(), $this->getDocPartId(), $width, $style); + $cell->setPhpWord($this->phpWord); $this->cells[] = $cell; return $cell; } diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 64e226ab58..dd1c0afb2c 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -9,10 +9,12 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Style\Section as SectionSettings; use PhpOffice\PhpWord\Element\PageBreak; +use PhpOffice\PhpWord\Element\Table; use PhpOffice\PhpWord\Element\TOC; +use PhpOffice\PhpWord\Element\Title; +use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\Style\Section as SectionSettings; /** * Section @@ -82,12 +84,47 @@ public function getSettings() return $this->settings; } + /** + * Add a Title Element + * + * @param string $text + * @param int $depth + * @return \PhpOffice\PhpWord\Element\Title + */ + public function addTitle($text, $depth = 1) + { + $title = new Title($text, $depth); + $title->setDocPart($this->getDocPart(), $this->getDocPartId()); + if ($this->phpWord instanceof PhpWord) { + $bookmarkId = $this->phpWord->addTitle($title); + $title->setBookmarkId($bookmarkId); + } + $this->addElement($title); + + return $title; + } + /** * Add a PageBreak Element */ public function addPageBreak() { - $this->elements[] = new PageBreak(); + $this->addElement(new PageBreak()); + } + + /** + * Add table element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Table + * @todo Merge with the same function on Footer + */ + public function addTable($style = null) + { + $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($table); + + return $table; } /** @@ -102,7 +139,8 @@ public function addPageBreak() public function addTOC($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9) { $toc = new TOC($fontStyle, $tocStyle, $minDepth, $maxDepth); - $this->elements[] = $toc; + $this->addElement($toc); + return $toc; } @@ -187,6 +225,8 @@ private function addHeaderFooter($type = Header::AUTO, $header = true) if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { $index = count($collection); $container = new $containerClass($this->sectionId, ++$index, $type); + $container->setPhpWord($this->phpWord); + $collection[$index] = $container; return $container; } else { diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index ac48a49d40..b8eee6e50b 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -9,7 +9,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\TOC as Titles; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\TOC as TOCStyle; @@ -87,16 +87,20 @@ public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, */ public function getTitles() { - $titles = Titles::getTitles(); + if (!$this->phpWord instanceof PhpWord) { + return array(); + } + + $titles = $this->phpWord->getTitles()->getItems(); foreach ($titles as $i => $title) { - if ($this->minDepth > $title['depth']) { + $depth = $title->getDepth(); + if ($this->minDepth > $depth) { unset($titles[$i]); } - if (($this->maxDepth != 0) && ($this->maxDepth < $title['depth'])) { + if (($this->maxDepth != 0) && ($this->maxDepth < $depth)) { unset($titles[$i]); } } - $titles = array_merge(array(), $titles); return $titles; } diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 1fa729e172..89bef829c9 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -60,6 +60,7 @@ public function __construct($docPart, $docPartId, $style = null) public function addRow($height = null, $style = null) { $row = new Row($this->getDocPart(), $this->getDocPartId(), $height, $style); + $row->setPhpWord($this->phpWord); $this->rows[] = $row; return $row; } diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index 96e0e164e9..481f532b53 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -127,7 +128,7 @@ public function getParagraphStyle() */ public function setText($text) { - $this->text = $text; + $this->text = String::toUTF8($text); return $this; } diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 93b48d626c..f6d3bba9b5 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -9,6 +9,9 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Shared\String; + /** * Title element */ @@ -40,10 +43,10 @@ class Title extends AbstractElement * * @var int */ - private $bookmarkId; + private $bookmarkId = 1; /** - * Title style + * Name of the heading style, e.g. 'Heading1' * * @var string */ @@ -55,40 +58,20 @@ class Title extends AbstractElement * * @param string $text * @param int $depth - * @param string $style Name of the heading style, e.g. 'Heading1' + * @param string $style */ - public function __construct($text, $depth = 1, $style = null) + public function __construct($text, $depth = 1) { - if (!is_null($style)) { - $this->style = $style; - } - $this->text = $text; + $this->text = String::toUTF8($text); $this->depth = $depth; + if (array_key_exists('Heading_' . $this->depth, Style::getStyles())) { + $this->style = 'Heading' . $this->depth; + } return $this; } - /** - * Set Anchor - * - * @param int $anchor - */ - public function setAnchor($anchor) - { - $this->anchor = $anchor; - } - - /** - * Get Anchor - * - * @return int - */ - public function getAnchor() - { - return $this->anchor; - } - /** * Set Bookmark ID * @@ -138,4 +121,28 @@ public function getStyle() { return $this->style; } + + /** + * Set Anchor + * + * @param int $anchor + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function setAnchor($anchor) + { + $this->anchor = $anchor; + } + + /** + * Get Anchor + * + * @return int + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getAnchor() + { + return '_Toc' . (252634154 + $this->bookmarkId); + } } diff --git a/src/PhpWord/Endnotes.php b/src/PhpWord/Endnotes.php deleted file mode 100644 index 6587dfe946..0000000000 --- a/src/PhpWord/Endnotes.php +++ /dev/null @@ -1,95 +0,0 @@ -documentProperties = new DocumentProperties(); + $this->titles = new Titles(); + $this->footnotes = new Footnotes(); + $this->endnotes = new Endnotes(); $this->defaultFontName = self::DEFAULT_FONT_NAME; $this->defaultFontSize = self::DEFAULT_FONT_SIZE; } @@ -92,6 +119,16 @@ public function setDocumentProperties(DocumentProperties $documentProperties) return $this; } + /** + * Get all sections + * + * @return \PhpOffice\PhpWord\Element\Section[] + */ + public function getSections() + { + return $this->sections; + } + /** * Create new section * @@ -101,11 +138,75 @@ public function setDocumentProperties(DocumentProperties $documentProperties) public function addSection($settings = null) { $section = new Section(count($this->sections) + 1, $settings); + $section->setPhpWord($this); $this->sections[] = $section; return $section; } + /** + * Get titles + * + * @return \PhpOffice\PhpWord\Collection\Titles + */ + public function getTitles() + { + return $this->titles; + } + + /** + * Add new title + * + * @param \PhpOffice\PhpWord\Element\Title $title + * @return int + */ + public function addTitle($title) + { + return $this->titles->addItem($title); + } + + /** + * Get footnotes + * + * @return \PhpOffice\PhpWord\Collection\Footnotes + */ + public function getFootnotes() + { + return $this->footnotes; + } + + /** + * Add new footnote + * + * @param \PhpOffice\PhpWord\Element\Footnote $footnote + * @return int + */ + public function addFootnote($footnote) + { + return $this->footnotes->addItem($footnote); + } + + /** + * Get endnotes + * + * @return \PhpOffice\PhpWord\Collection\Endnotes + */ + public function getEndnotes() + { + return $this->endnotes; + } + + /** + * Add new endnote + * + * @param \PhpOffice\PhpWord\Element\Endnote $endnote + * @return int + */ + public function addEndnote($endnote) + { + return $this->endnotes->addItem($endnote); + } + /** * Get default font name * @@ -225,16 +326,6 @@ public function addNumberingStyle($styleName, $styles) Style::addNumberingStyle($styleName, $styles); } - /** - * Get all sections - * - * @return \PhpOffice\PhpWord\Element\Section[] - */ - public function getSections() - { - return $this->sections; - } - /** * Load template by filename * diff --git a/src/PhpWord/Reader/Word2007/DocProps.php b/src/PhpWord/Reader/Word2007/DocProps.php deleted file mode 100644 index 2c76417aad..0000000000 --- a/src/PhpWord/Reader/Word2007/DocProps.php +++ /dev/null @@ -1,63 +0,0 @@ -getDomFromZip($this->docFile, $this->xmlFile); - - $docProps = $phpWord->getDocumentProperties(); - - $nodes = $xmlReader->getElements('*'); - if ($nodes->length > 0) { - foreach ($nodes as $node) { - if (!array_key_exists($node->nodeName, $this->mapping)) { - continue; - } - $method = $this->mapping[$node->nodeName]; - $value = $node->nodeValue == '' ? null : $node->nodeValue; - if (array_key_exists($node->nodeName, $this->callbacks)) { - $value = $this->callbacks[$node->nodeName]($value); - } - if (method_exists($docProps, $method)) { - $docProps->$method($value); - } - } - } - } -} diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php index 7797528aec..40d08667e6 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsApp.php +++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php @@ -12,7 +12,7 @@ /** * Extended properties reader */ -class DocPropsApp extends DocProps +class DocPropsApp extends DocPropsCore { /** * Property mapping @@ -20,4 +20,11 @@ class DocPropsApp extends DocProps * @var array */ protected $mapping = array('Company' => 'setCompany', 'Manager' => 'setManager'); + + /** + * Callback functions + * + * @var array + */ + protected $callbacks = array(); } diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index fd943875ed..a6a8902bda 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -9,10 +9,13 @@ namespace PhpOffice\PhpWord\Reader\Word2007; +use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Shared\XMLReader; + /** * Core properties reader */ -class DocPropsCore extends DocProps +class DocPropsCore extends AbstractPart { /** * Property mapping @@ -37,4 +40,34 @@ class DocPropsCore extends DocProps * @var array */ protected $callbacks = array('dcterms:created' => 'strtotime', 'dcterms:modified' => 'strtotime'); + + /** + * Read core/extended document properties + * + * @param \PhpOffice\PhpWord\PhpWord $phpWord + */ + public function read(PhpWord &$phpWord) + { + $xmlReader = new XMLReader(); + $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); + + $docProps = $phpWord->getDocumentProperties(); + + $nodes = $xmlReader->getElements('*'); + if ($nodes->length > 0) { + foreach ($nodes as $node) { + if (!array_key_exists($node->nodeName, $this->mapping)) { + continue; + } + $method = $this->mapping[$node->nodeName]; + $value = $node->nodeValue == '' ? null : $node->nodeValue; + if (array_key_exists($node->nodeName, $this->callbacks)) { + $value = $this->callbacks[$node->nodeName]($value); + } + if (method_exists($docProps, $method)) { + $docProps->$method($value); + } + } + } + } } diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php index bdb0b9e8b5..f92388dcf9 100644 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ b/src/PhpWord/Reader/Word2007/Notes.php @@ -32,8 +32,8 @@ class Notes extends AbstractPart public function read(PhpWord &$phpWord) { $this->type = ($this->type == 'endnotes') ? 'endnotes' : 'footnotes'; - $collectionClass = 'PhpOffice\\PhpWord\\' . ucfirst($this->type); - $collection = $collectionClass::getElements(); + $getMethod = 'get' . $this->type; + $collection = $phpWord->$getMethod()->getItems(); $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); @@ -49,9 +49,10 @@ public function read(PhpWord &$phpWord) $element = $collection[$id]; $pNodes = $xmlReader->getElements('w:p/*', $node); foreach ($pNodes as $pNode) { - $this->readRun($xmlReader, $pNode, $element, $type); + $this->readRun($xmlReader, $pNode, $element, $this->type); } - $collectionClass::setElement($id, $element); + $addMethod = 'add' . ($this->type == 'endnotes' ? 'endnote' : 'footnote'); + $phpWord->$addMethod($element); } } } diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index e8a781b00f..5333a0b6b1 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -12,26 +12,12 @@ /** * TOC style */ -class TOC extends AbstractStyle +class TOC extends Tab { - const TABLEADER_DOT = 'dot'; - const TABLEADER_UNDERSCORE = 'underscore'; - const TABLEADER_LINE = 'hyphen'; - const TABLEADER_NONE = ''; - - /** - * Tab Leader - * - * @var string - */ - private $tabLeader; - - /** - * Tab Position - * - * @var int - */ - private $tabPos; + const TABLEADER_DOT = self::TAB_LEADER_DOT; + const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE; + const TABLEADER_LINE = self::TAB_LEADER_HYPHEN; + const TABLEADER_NONE = self::TAB_LEADER_NONE; /** * Indent @@ -46,8 +32,7 @@ class TOC extends AbstractStyle */ public function __construct() { - $this->tabPos = 9062; - $this->tabLeader = self::TABLEADER_DOT; + parent::__construct(self::TAB_STOP_RIGHT, 9062, self::TABLEADER_DOT); $this->indent = 200; } @@ -58,17 +43,17 @@ public function __construct() */ public function getTabPos() { - return $this->tabPos; + return $this->getPosition(); } /** * Set Tab Position * - * @param int $pValue + * @param int $value */ - public function setTabPos($pValue) + public function setTabPos($value) { - $this->tabPos = $pValue; + $this->position = $value; } /** @@ -78,17 +63,17 @@ public function setTabPos($pValue) */ public function getTabLeader() { - return $this->tabLeader; + return $this->getLeader(); } /** * Set Tab Leader * - * @param string $pValue + * @param string $value */ - public function setTabLeader($pValue = self::TABLEADER_DOT) + public function setTabLeader($value = self::TABLEADER_DOT) { - $this->tabLeader = $pValue; + $this->leader = $value; } /** @@ -104,10 +89,10 @@ public function getIndent() /** * Set Indent * - * @param string $pValue + * @param string $value */ - public function setIndent($pValue) + public function setIndent($value) { - $this->indent = $pValue; + $this->indent = $value; } } diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index dfcb3b95de..62785cfb67 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -44,7 +44,7 @@ class Tab extends AbstractStyle * * @var string */ - private $val = self::TAB_STOP_CLEAR; + private $type = self::TAB_STOP_CLEAR; /** * Tab leader character @@ -54,22 +54,22 @@ class Tab extends AbstractStyle private $leader = self::TAB_LEADER_NONE; /** - * Tab stop position + * Tab stop position (twip) * - * @var int + * @var int|float */ private $position = 0; /** - * Create a new instance of Tab. Both $val and $leader + * Create a new instance of Tab. Both $type and $leader * must conform to the values put forth in the schema. If they do not * they will be changed to default values. * - * @param string $val Defaults to 'clear' if value is not possible. + * @param string $type Defaults to 'clear' if value is not possible. * @param int $position Must be numeric; otherwise defaults to 0. * @param string $leader Defaults to null if value is not possible. */ - public function __construct($val = null, $position = 0, $leader = null) + public function __construct($type = null, $position = 0, $leader = null) { $stopTypes = array( self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT,self::TAB_STOP_CENTER, @@ -80,7 +80,7 @@ public function __construct($val = null, $position = 0, $leader = null) self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT ); - $this->val = $this->setEnumVal($val, $stopTypes, $this->val); + $this->type = $this->setEnumVal($type, $stopTypes, $this->type); $this->position = $this->setNumericVal($position, $this->position); $this->leader = $this->setEnumVal($leader, $leaderTypes, $this->leader); } @@ -90,9 +90,21 @@ public function __construct($val = null, $position = 0, $leader = null) * * @return string */ - public function getStopType() + public function getType() { - return $this->val; + return $this->type; + } + + /** + * Set stop type + * + * @param string $value + */ + public function setType($value) + { + $enum = array(self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER, + self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM); + $this->type = $this->setEnumVal($value, $enum, $this->type); } /** @@ -105,13 +117,35 @@ public function getLeader() return $this->leader; } + /** + * Set leader + * + * @param string $value + */ + public function setLeader($value) + { + $enum = array(self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN, + self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT); + $this->leader = $this->setEnumVal($value, $enum, $this->leader); + } + /** * Get position * - * @return integer + * @return int|float */ public function getPosition() { return $this->position; } + + /** + * Set position + * + * @param int|float $value + */ + public function setPosition($value) + { + $this->position = $this->setNumericVal($value, $this->position); + } } diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php index ea75c10de5..577fe4ab0d 100644 --- a/src/PhpWord/TOC.php +++ b/src/PhpWord/TOC.php @@ -11,6 +11,12 @@ /** * Table of contents + * + * This static class has been deprecated and replaced by Collection\Titles. + * File maintained for backward compatibility and will be removed on 1.0. + * + * @deprecated 0.10.0 + * @codeCoverageIgnore */ class TOC { diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index d4b8adb392..a11a92ff74 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -167,14 +167,16 @@ private function writeHTMLBody() */ private function writeNotes() { + $phpWord = $this->getPhpWord(); $html = ''; + if (!empty($this->notes)) { $html .= "
"; foreach ($this->notes as $noteId => $noteMark) { $noteAnchor = "note-{$noteId}"; list($noteType, $noteTypeId) = explode('-', $noteMark); - $collectionObject = 'PhpOffice\\PhpWord\\' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); - $collection = $collectionObject::getElements(); + $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); + $collection = $phpWord->$method()->getItems(); if (array_key_exists($noteTypeId, $collection)) { $element = $collection[$noteTypeId]; $elmWriter = new TextRunWriter($this, $element, true); diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php index 66efcf4da9..f9c62f416c 100644 --- a/src/PhpWord/Writer/HTML/Element/Endnote.php +++ b/src/PhpWord/Writer/HTML/Element/Endnote.php @@ -14,6 +14,12 @@ * * @since 0.10.0 */ -class Endnote extends Note +class Endnote extends Footnote { + /** + * Note type + * + * @var string + */ + protected $noteType = 'endnote'; } diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index 5fdc55a221..ab723d6950 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -14,6 +14,27 @@ * * @since 0.10.0 */ -class Footnote extends Note +class Footnote extends Element { + /** + * Note type footnote|endnote + * + * @var string + */ + protected $noteType = 'footnote'; + + /** + * Write footnote/endnote marks + * + * @return string + */ + public function write() + { + $noteId = count($this->parentWriter->getNotes()) + 1; + $noteMark = $this->noteType . '-' . $this->element->getRelationId(); + $this->parentWriter->addNote($noteId, $noteMark); + $html = "{$noteId}"; + + return $html; + } } diff --git a/src/PhpWord/Writer/HTML/Element/Note.php b/src/PhpWord/Writer/HTML/Element/Note.php deleted file mode 100644 index cac84cbeb9..0000000000 --- a/src/PhpWord/Writer/HTML/Element/Note.php +++ /dev/null @@ -1,34 +0,0 @@ -parentWriter->getNotes()) + 1; - $prefix = ($this->element instanceof \PhpOffice\PhpWord\Element\Endnote) ? 'endnote' : 'footnote'; - $noteMark = $prefix . '-' . $this->element->getRelationId(); - $this->parentWriter->addNote($noteId, $noteMark); - $html = "{$noteId}"; - - return $html; - } -} diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index b87f1d2441..59fa2194e4 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -179,29 +179,27 @@ private function addHeaderFooterContent(Section &$section, $objZip, $elmType, &$ * * @param mixed $objZip * @param integer $rId - * @param string $notesType + * @param string $noteType */ - private function addNotes($objZip, &$rId, $notesType = 'footnote') + private function addNotes($objZip, &$rId, $noteType = 'footnote') { - $notesType = ($notesType == 'endnote') ? 'endnote' : 'footnote'; - $notesTypes = "{$notesType}s"; - $collection = 'PhpOffice\\PhpWord\\' . ucfirst($notesTypes); - $xmlFile = "{$notesTypes}.xml"; - $relsFile = "word/_rels/{$xmlFile}.rels"; - $xmlPath = "word/{$xmlFile}"; + $noteType = ($noteType == 'endnote') ? 'endnote' : 'footnote'; + $noteTypePlural = "{$noteType}s"; + $method = 'get' . $noteTypePlural; + $collection = $this->phpWord->$method(); // Add footnotes media files, relations, and contents - if ($collection::countElements() > 0) { - $media = Media::getElements($notesType); + if ($collection->countItems() > 0) { + $media = Media::getElements($noteType); $this->addFilesToPackage($objZip, $media); $this->registerContentTypes($media); if (!empty($media)) { - $objZip->addFromString($relsFile, $this->getWriterPart('rels')->writeMediaRels($media)); + $objZip->addFromString("word/_rels/{$noteTypePlural}.xml.rels", $this->getWriterPart('rels')->writeMediaRels($media)); } - $elements = $collection::getElements(); - $objZip->addFromString($xmlPath, $this->getWriterPart($notesTypes)->write($elements)); - $this->cTypes['override']["/{$xmlPath}"] = $notesTypes; - $this->docRels[] = array('target' => $xmlFile, 'type' => $notesTypes, 'rID' => ++$rId); + $elements = $collection->getItems(); + $objZip->addFromString("word/{$noteTypePlural}.xml", $this->getWriterPart($noteTypePlural)->write($elements)); + $this->cTypes['override']["/word/{$noteTypePlural}.xml"] = $noteTypePlural; + $this->docRels[] = array('target' => "{$noteTypePlural}.xml", 'type' => $noteTypePlural, 'rID' => ++$rId); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Endnote.php b/src/PhpWord/Writer/Word2007/Element/Endnote.php index fbdf7a7590..e1865e644b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Endnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Endnote.php @@ -14,14 +14,12 @@ * * @since 0.10.0 */ -class Endnote extends Note +class Endnote extends Footnote { /** - * Write element + * Reference type + * + * @var string */ - public function write() - { - $this->referenceType = 'endnoteReference'; - parent::write(); - } + protected $referenceType = 'endnoteReference'; } diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 20360ebc10..d962d8bc7c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -14,14 +14,35 @@ * * @since 0.10.0 */ -class Footnote extends Note +class Footnote extends Element { + /** + * Reference type footnoteReference|endnoteReference + * + * @var string + */ + protected $referenceType = 'footnoteReference'; + /** * Write element */ public function write() { - $this->referenceType = 'footnoteReference'; - parent::write(); + if (!$this->withoutP) { + $this->xmlWriter->startElement('w:p'); + } + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:rPr'); + $this->xmlWriter->startElement('w:rStyle'); + $this->xmlWriter->writeAttribute('w:val', ucfirst($this->referenceType)); + $this->xmlWriter->endElement(); // w:rStyle + $this->xmlWriter->endElement(); // w:rPr + $this->xmlWriter->startElement("w:{$this->referenceType}"); + $this->xmlWriter->writeAttribute('w:id', $this->element->getRelationId()); + $this->xmlWriter->endElement(); // w:$referenceType + $this->xmlWriter->endElement(); // w:r + if (!$this->withoutP) { + $this->xmlWriter->endElement(); // w:p + } } } diff --git a/src/PhpWord/Writer/Word2007/Element/Note.php b/src/PhpWord/Writer/Word2007/Element/Note.php deleted file mode 100644 index 1ba73de82c..0000000000 --- a/src/PhpWord/Writer/Word2007/Element/Note.php +++ /dev/null @@ -1,48 +0,0 @@ -withoutP) { - $this->xmlWriter->startElement('w:p'); - } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:rPr'); - $this->xmlWriter->startElement('w:rStyle'); - $this->xmlWriter->writeAttribute('w:val', ucfirst($this->referenceType)); - $this->xmlWriter->endElement(); // w:rStyle - $this->xmlWriter->endElement(); // w:rPr - $this->xmlWriter->startElement("w:{$this->referenceType}"); - $this->xmlWriter->writeAttribute('w:id', $this->element->getRelationId()); - $this->xmlWriter->endElement(); // w:$referenceType - $this->xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p - } - } -} diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 5be287a39b..37888b7f3e 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -12,6 +12,7 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; +use PhpOffice\PhpWord\Writer\Word2007\Style\Tab as TabStyleWriter; /** * TOC element writer @@ -26,59 +27,53 @@ class TOC extends Element public function write() { $titles = $this->element->getTitles(); - $fontStyle = $this->element->getStyleFont(); - $tocStyle = $this->element->getStyleTOC(); - $fIndent = $tocStyle->getIndent(); - $tabLeader = $tocStyle->getTabLeader(); - $tabPos = $tocStyle->getTabPos(); - - $maxDepth = $this->element->getMaxDepth(); - $minDepth = $this->element->getMinDepth(); - + $fontStyle = $this->element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; - for ($i = 0; $i < count($titles); $i++) { - $title = $titles[$i]; - $indent = ($title['depth'] - 1) * $fIndent; + $tocFieldWritten = false; + foreach ($titles as $title) { + $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); + $anchor = '_Toc' . ($title->getBookmarkId() + 252634154); $this->xmlWriter->startElement('w:p'); + // Style $this->xmlWriter->startElement('w:pPr'); + // Paragraph if ($isObject && !is_null($fontStyle->getParagraphStyle())) { $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $fontStyle->getParagraphStyle()); $styleWriter->write(); } - if ($indent > 0) { - $this->xmlWriter->startElement('w:ind'); - $this->xmlWriter->writeAttribute('w:left', $indent); - $this->xmlWriter->endElement(); - } - + // Font if (!empty($fontStyle) && !$isObject) { - $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:pStyle'); + $this->xmlWriter->startElement('w:rPr'); + $this->xmlWriter->startElement('w:rStyle'); $this->xmlWriter->writeAttribute('w:val', $fontStyle); $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); // w:rPr } + // Tab $this->xmlWriter->startElement('w:tabs'); - $this->xmlWriter->startElement('w:tab'); - $this->xmlWriter->writeAttribute('w:val', 'right'); - if (!empty($tabLeader)) { - $this->xmlWriter->writeAttribute('w:leader', $tabLeader); - } - $this->xmlWriter->writeAttribute('w:pos', $tabPos); - $this->xmlWriter->endElement(); + $styleWriter = new TabStyleWriter($this->xmlWriter, $tocStyle); + $styleWriter->write(); $this->xmlWriter->endElement(); + // Indent + if ($indent > 0) { + $this->xmlWriter->startElement('w:ind'); + $this->xmlWriter->writeAttribute('w:left', $indent); + $this->xmlWriter->endElement(); + } + $this->xmlWriter->endElement(); // w:pPr + if ($tocFieldWritten !== true) { + $tocFieldWritten = true; - if ($i == 0) { $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:fldChar'); $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); @@ -88,7 +83,7 @@ public function write() $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:instrText'); $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw('TOC \o "' . $minDepth . '-' . $maxDepth . '" \h \z \u'); + $this->xmlWriter->writeRaw('TOC \o "' . $this->element->getMinDepth() . '-' . $this->element->getMaxDepth() . '" \h \z \u'); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); @@ -100,7 +95,7 @@ public function write() } $this->xmlWriter->startElement('w:hyperlink'); - $this->xmlWriter->writeAttribute('w:anchor', $title['anchor']); + $this->xmlWriter->writeAttribute('w:anchor', $anchor); $this->xmlWriter->writeAttribute('w:history', '1'); $this->xmlWriter->startElement('w:r'); @@ -111,7 +106,7 @@ public function write() } $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeRaw($title['text']); + $this->xmlWriter->writeRaw($title->getText()); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); @@ -128,7 +123,7 @@ public function write() $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:instrText'); $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); + $this->xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 5570921f52..9b9f931d46 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -23,8 +23,8 @@ class Title extends Element */ public function write() { - $anchor = $this->element->getAnchor(); $bookmarkId = $this->element->getBookmarkId(); + $anchor = '_Toc' . ($bookmarkId + 252634154); $style = $this->element->getStyle(); $text = htmlspecialchars($this->element->getText()); $text = String::controlCharacterPHP2OOXML($text); diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index 403c6173da..21a5d130c0 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -26,7 +26,7 @@ public function write() } $this->xmlWriter->startElement("w:tab"); - $this->xmlWriter->writeAttribute("w:val", $this->style->getStopType()); + $this->xmlWriter->writeAttribute("w:val", $this->style->getType()); $this->xmlWriter->writeAttribute("w:leader", $this->style->getLeader()); $this->xmlWriter->writeAttribute('w:pos', $this->convertTwip($this->style->getPosition())); $this->xmlWriter->endElement(); diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index 415e43ad20..5377a6c2cc 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -9,10 +9,11 @@ namespace PhpOffice\PhpWord\Tests\Element; +use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Header; -use PhpOffice\PhpWord\Style; /** * Test class for PhpOffice\PhpWord\Element\Section @@ -78,6 +79,7 @@ public function testAddElements() $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; $section = new Section(0); + $section->setPhpWord(new PhpWord()); $section->addText(utf8_decode('ä')); $section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä')); $section->addTextBreak(); @@ -122,6 +124,7 @@ public function testAddTitleWithStyle() { Style::addTitleStyle(1, array('size' => 14)); $section = new Section(0); + $section->setPhpWord(new PhpWord()); $section->addTitle('Test', 1); $elementCollection = $section->getElements(); diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index 207f69691a..49d4ca0677 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -9,6 +9,8 @@ namespace PhpOffice\PhpWord\Tests\Element; +use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Element\Title; use PhpOffice\PhpWord\Element\TOC; /** @@ -24,11 +26,11 @@ class TOCTest extends \PHPUnit_Framework_TestCase public function testConstructWithStyleArray() { $expected = array( - 'tabPos' => 9062, - 'tabLeader' => \PhpOffice\PhpWord\Style\TOC::TABLEADER_DOT, + 'position' => 9062, + 'leader' => \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_DOT, 'indent' => 200, ); - $object = new TOC(array('_size' => 11), array('_tabPos' => $expected['tabPos'])); + $object = new TOC(array('size' => 11), array('position' => $expected['position'])); $tocStyle = $object->getStyleTOC(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TOC', $tocStyle); @@ -56,17 +58,19 @@ public function testConstructWithStyleName() */ public function testSetGetMinMaxDepth() { - $toc = new TOC(); $titles = array( 'Heading 1' => 1, 'Heading 2' => 2, 'Heading 3' => 3, 'Heading 4' => 4, ); + + $phpWord = new PhpWord(); foreach ($titles as $text => $depth) { - \PhpOffice\PhpWord\TOC::addTitle($text, $depth); + $phpWord->addTitle(new Title($text, $depth)); } - + $toc = new TOC(); + $toc->setPhpWord($phpWord); $this->assertEquals(1, $toc->getMinDepth()); $this->assertEquals(9, $toc->getMaxDepth()); diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 0916e40b8f..16b71698b6 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Tests\Element; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\TextRun; /** @@ -138,6 +139,7 @@ public function testAddImage() public function testCreateFootnote() { $oTextRun = new TextRun(); + $oTextRun->setPhpWord(new PhpWord()); $element = $oTextRun->addFootnote(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $element); diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 6c472b0d9e..ee111634cc 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -40,28 +40,6 @@ public function testStyleNull() $this->assertEquals($oTitle->getStyle(), null); } - /** - * Get style not null - */ - public function testStyleNotNull() - { - $oTitle = new Title('text', 1, 'style'); - - $this->assertEquals($oTitle->getStyle(), 'style'); - } - - /** - * Get anchor - */ - public function testAnchor() - { - $oTitle = new Title('text'); - - $iVal = rand(1, 1000); - $oTitle->setAnchor($iVal); - $this->assertEquals($oTitle->getAnchor(), $iVal); - } - /** * Get bookmark Id */ diff --git a/tests/PhpWord/Tests/EndnotesTest.php b/tests/PhpWord/Tests/EndnotesTest.php deleted file mode 100644 index a72e85f94d..0000000000 --- a/tests/PhpWord/Tests/EndnotesTest.php +++ /dev/null @@ -1,39 +0,0 @@ -assertEquals(1, $rId); - $this->assertEquals(1, count(Endnotes::getElements())); - $this->assertEquals($endnote2, Endnotes::getElement(1)); - $this->assertNull(Endnotes::getElement(2)); - - Endnotes::resetElements(); - $this->assertEquals(0, Endnotes::countElements()); - } -} diff --git a/tests/PhpWord/Tests/FootnotesTest.php b/tests/PhpWord/Tests/FootnotesTest.php deleted file mode 100644 index 869c69a736..0000000000 --- a/tests/PhpWord/Tests/FootnotesTest.php +++ /dev/null @@ -1,39 +0,0 @@ -assertEquals(1, $rId); - $this->assertEquals(1, count(Footnotes::getElements())); - $this->assertEquals($footnote2, Footnotes::getElement(1)); - $this->assertNull(Footnotes::getElement(2)); - - Footnotes::resetElements(); - $this->assertEquals(0, Footnotes::countElements()); - } -} diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 8de6f80883..d7c5a7f67d 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -51,9 +51,8 @@ public function testSetGetDocumentProperties() public function testCreateGetSections() { $phpWord = new PhpWord(); - $this->assertEquals(new Section(1), $phpWord->addSection()); $phpWord->addSection(); - $this->assertEquals(2, count($phpWord->getSections())); + $this->assertEquals(1, count($phpWord->getSections())); } /** diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index 2c10de8def..dab87d6747 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -27,8 +27,8 @@ public function testProperties() $object = new TOC(); $properties = array( - 'tabPos' => 9062, - 'tabLeader' => TOC::TABLEADER_DOT, + 'position' => 9062, + 'leader' => \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_DOT, 'indent' => 200, ); foreach ($properties as $key => $value) { @@ -37,10 +37,6 @@ public function testProperties() $get = "get{$key}"; $object->$set($value); $this->assertEquals($value, $object->$get()); - - // setStyleValue - $object->setStyleValue("{$key}", null); - $this->assertEquals(null, $object->$get()); } } } diff --git a/tests/PhpWord/Tests/TOCTest.php b/tests/PhpWord/Tests/TOCTest.php deleted file mode 100644 index d0b73352ad..0000000000 --- a/tests/PhpWord/Tests/TOCTest.php +++ /dev/null @@ -1,53 +0,0 @@ - 1, - 'Heading 2' => 2, - 'Heading 3' => 3, - ); - $toc = new TOC(); - - foreach ($titles as $text => $depth) { - $response = $toc->addTitle($text, $depth); - } - $this->assertEquals($anchor, $response[0]); - $this->assertEquals($bookmark, $response[1]); - - $i = 0; - $savedTitles = $toc->getTitles(); - foreach ($titles as $text => $depth) { - $this->assertEquals($text, $savedTitles[$i]['text']); - $this->assertEquals($depth, $savedTitles[$i]['depth']); - $i++; - } - - TOC::resetTitles(); - $this->assertEquals(0, count($toc->getTitles())); - } -} From f6f52afa68c06eb24fcd8162b5a24405852137b5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 14:15:44 +0700 Subject: [PATCH 003/167] Fix Travis build error --- src/PhpWord/Element/Section.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index dd1c0afb2c..ef92bbd0d5 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -9,6 +9,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\PageBreak; use PhpOffice\PhpWord\Element\Table; use PhpOffice\PhpWord\Element\TOC; From 2187954b565acf4ae661c0715892136897125618 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 10:16:28 +0200 Subject: [PATCH 004/167] Fixed bug in header, wherein all images were assigned to the first header in a section. This resulted in a corrupt DOCX --- src/PhpWord/Element/AbstractContainer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 8af70d421d..b90f6d728a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -249,7 +249,6 @@ public function addImage($src, $style = null, $isWatermark = false) $rId = Media::addElement($elementDocPart, 'image', $src, $image); $image->setRelationId($rId); $this->addElement($image); - return $image; } @@ -413,7 +412,7 @@ private function checkElementDocPart() $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - + $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; return $inHeaderFooter ? $docPart . $docPartId : $docPart; } From 15dcb384c64167fb33a6ac5f2989fc7bf513d134 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 10:34:40 +0200 Subject: [PATCH 005/167] Messed up something. Resetting --- src/PhpWord/Element/AbstractContainer.php | 1 - src/PhpWord/Style/Image.php | 281 ++++++++++-------- src/PhpWord/Writer/Word2007/Element/Image.php | 30 +- 3 files changed, 169 insertions(+), 143 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index b90f6d728a..ea3450a5fa 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -412,7 +412,6 @@ private function checkElementDocPart() $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; return $inHeaderFooter ? $docPart . $docPartId : $docPart; } diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 7aabdeb2ff..a035be6ea3 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -1,4 +1,5 @@ width = null; - $this->height = null; - $this->align = null; - $this->marginTop = null; - $this->marginLeft = null; - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - $this->setPositioning(self::POSITION_RELATIVE); - $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); - $this->setPosHorizontalRel(self::POSITION_HORIZONTAL_RELATIVE_CHAR); - $this->setPosVertical(self::POSITION_VERTICAL_TOP); - $this->setPosVerticalRel(self::POSITION_VERTICAL_RELATIVE_LINE); + $this->width = null; + $this->height = null; + $this->align = null; + $this->marginTop = null; + $this->marginLeft = null; + $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); + $this->setPositioning(self::POSITION_RELATIVE); + $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); + $this->setPosHorizontalRel(self::POSITION_HORIZONTAL_RELATIVE_CHAR); + $this->setPosVertical(self::POSITION_VERTICAL_TOP); + $this->setPosVerticalRel(self::POSITION_VERTICAL_RELATIVE_LINE); } /** @@ -146,17 +175,17 @@ public function __construct() */ public function getWidth() { - return $this->width; + return $this->width; } /** * Set width * - * @param int $pValue + * @param int $pValue */ public function setWidth($pValue = null) { - $this->width = $pValue; + $this->width = $pValue; } /** @@ -164,17 +193,17 @@ public function setWidth($pValue = null) */ public function getHeight() { - return $this->height; + return $this->height; } /** * Set height * - * @param int $pValue + * @param int $pValue */ public function setHeight($pValue = null) { - $this->height = $pValue; + $this->height = $pValue; } /** @@ -182,17 +211,17 @@ public function setHeight($pValue = null) */ public function getAlign() { - return $this->align; + return $this->align; } /** * Set alignment * - * @param string $pValue + * @param string $pValue */ public function setAlign($pValue = null) { - $this->align = $pValue; + $this->align = $pValue; } /** @@ -202,19 +231,19 @@ public function setAlign($pValue = null) */ public function getMarginTop() { - return $this->marginTop; + return $this->marginTop; } /** * Set Margin Top * - * @param int $pValue + * @param int $pValue * @return $this */ public function setMarginTop($pValue = null) { - $this->marginTop = $pValue; - return $this; + $this->marginTop = $pValue; + return $this; } /** @@ -224,25 +253,25 @@ public function setMarginTop($pValue = null) */ public function getMarginLeft() { - return $this->marginLeft; + return $this->marginLeft; } /** * Set Margin Left * - * @param int $pValue + * @param int $pValue * @return $this */ public function setMarginLeft($pValue = null) { - $this->marginLeft = $pValue; - return $this; + $this->marginLeft = $pValue; + return $this; } /** * Set wrapping style * - * @param string $wrappingStyle + * @param string $wrappingStyle * @throws \InvalidArgumentException * @return $this */ @@ -269,178 +298,176 @@ public function setWrappingStyle($wrappingStyle) */ public function getWrappingStyle() { - return $this->wrappingStyle; + return $this->wrappingStyle; } /** * Set positioning type * - * @param string $positioning + * @param string $positioning * @throws \InvalidArgumentException * @return $this */ - public function setPositioning($positioning) { - switch ($positioning) { - case self::POSITION_RELATIVE: - case self::POSITION_ABSOLUTE: - $this->positioning = $positioning; - break; - default: - throw new InvalidArgumentException('Positioning does not exists'); - break; - } - return $this; + switch ($positioning) { + case self::POSITION_RELATIVE: + case self::POSITION_ABSOLUTE: + $this->positioning = $positioning; + break; + default: + throw new InvalidArgumentException('Positioning does not exists'); + break; + } + return $this; } - + /** * Get positioning type - * + * * @return string */ public function getPositioning() { - return $this->positioning; + return $this->positioning; } /** * Set horizontal alignment * - * @param string $alignment + * @param string $alignment * @throws \InvalidArgumentException * @return $this */ public function setPosHorizontal($alignment) { - switch ($alignment) { - case self::POSITION_HORIZONTAL_LEFT: - case self::POSITION_HORIZONTAL_CENTER: - case self::POSITION_HORIZONTAL_RIGHT: - $this->posHorizontal = $alignment; - break; - default: - throw new InvalidArgumentException('Horizontal alignment does not exists'); - break; - } - return $this; + switch ($alignment) { + case self::POSITION_HORIZONTAL_LEFT: + case self::POSITION_HORIZONTAL_CENTER: + case self::POSITION_HORIZONTAL_RIGHT: + $this->posHorizontal = $alignment; + break; + default: + throw new InvalidArgumentException('Horizontal alignment does not exists'); + break; + } + return $this; } - + /** * Get horizontal alignment - * + * * @return string */ public function getPosHorizontal() { - return $this->posHorizontal; + return $this->posHorizontal; } /** * Set vertical alignment * - * @param string $alignment + * @param string $alignment * @throws \InvalidArgumentException * @return $this */ - public function setPosVertical($alignment) { - switch ($alignment) { - case self::POSITION_VERTICAL_TOP: - case self::POSITION_VERTICAL_CENTER: - case self::POSITION_VERTICAL_BOTTOM: - case self::POSITION_VERTICAL_INSIDE: - case self::POSITION_VERTICAL_OUTSIDE: - $this->posVertical = $alignment; - break; - default: - throw new InvalidArgumentException('Vertical alignment does not exists'); - break; - } - return $this; + switch ($alignment) { + case self::POSITION_VERTICAL_TOP: + case self::POSITION_VERTICAL_CENTER: + case self::POSITION_VERTICAL_BOTTOM: + case self::POSITION_VERTICAL_INSIDE: + case self::POSITION_VERTICAL_OUTSIDE: + $this->posVertical = $alignment; + break; + default: + throw new InvalidArgumentException('Vertical alignment does not exists'); + break; + } + return $this; } - + /** * Get vertical alignment - * + * * @return string */ public function getPosVertical() { - return $this->posVertical; + return $this->posVertical; } - + /** * Set horizontal relation * - * @param string $relto + * @param string $relto * @throws \InvalidArgumentException * @return $this */ public function setPosHorizontalRel($relto) { - switch ($relto) { - case self::POSITION_HORIZONTAL_RELATIVE_MARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_PAGE: - case self::POSITION_HORIZONTAL_RELATIVE_COLUMN: - case self::POSITION_HORIZONTAL_RELATIVE_CHAR: - case self::POSITION_HORIZONTAL_RELATIVE_LMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_RMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_IMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_OMARGIN: - $this->posHorizontalRel = $relto; - break; - default: - throw new InvalidArgumentException('Horizontal relation does not exists'); - break; - } - return $this; + switch ($relto) { + case self::POSITION_HORIZONTAL_RELATIVE_MARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_PAGE: + case self::POSITION_HORIZONTAL_RELATIVE_COLUMN: + case self::POSITION_HORIZONTAL_RELATIVE_CHAR: + case self::POSITION_HORIZONTAL_RELATIVE_LMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_RMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_IMARGIN: + case self::POSITION_HORIZONTAL_RELATIVE_OMARGIN: + $this->posHorizontalRel = $relto; + break; + default: + throw new InvalidArgumentException('Horizontal relation does not exists'); + break; + } + return $this; } - + /** * Get horizontal relation - * + * * @return string */ public function getPosHorizontalRel() { - return $this->posHorizontalRel; + return $this->posHorizontalRel; } - + /** * Set vertical relation * - * @param string $relto + * @param string $relto * @throws \InvalidArgumentException * @return $this */ public function setPosVerticalRel($relto) { - switch ($relto) { - case self::POSITION_VERTICAL_RELATIVE_MARGIN: - case self::POSITION_VERTICAL_RELATIVE_PAGE: - case self::POSITION_VERTICAL_RELATIVE_LINE: - case self::POSITION_VERTICAL_RELATIVE_TMARGIN: - case self::POSITION_VERTICAL_RELATIVE_BMARGIN: - case self::POSITION_VERTICAL_RELATIVE_IMARGIN: - case self::POSITION_VERTICAL_RELATIVE_OMARGIN: - $this->posVerticalRel = $relto; - break; - default: - throw new InvalidArgumentException('Vertical relation does not exists'); - break; - } - return $this; + switch ($relto) { + case self::POSITION_VERTICAL_RELATIVE_MARGIN: + case self::POSITION_VERTICAL_RELATIVE_PAGE: + case self::POSITION_VERTICAL_RELATIVE_LINE: + case self::POSITION_VERTICAL_RELATIVE_TMARGIN: + case self::POSITION_VERTICAL_RELATIVE_BMARGIN: + case self::POSITION_VERTICAL_RELATIVE_IMARGIN: + case self::POSITION_VERTICAL_RELATIVE_OMARGIN: + $this->posVerticalRel = $relto; + break; + default: + throw new InvalidArgumentException('Vertical relation does not exists'); + break; + } + return $this; } - + /** * Get vertical relation - * + * * @return string */ public function getPosVerticalRel() { - return $this->posVerticalRel; + return $this->posVerticalRel; } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 80b71121da..eb73536d16 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -59,21 +59,21 @@ private function writeImage() if (null !== $marginLeft) { $imgStyle .= 'margin-left:' . $marginLeft . 'px;'; } - $imgStyle.='position:absolute;mso-width-percent:0;mso-height-percent:0;mso-width-relative:margin;mso-height-relative:margin;'; - switch ($positioning) { - case ImageStyle::POSITION_RELATIVE: - $imgStyle.='mso-position-horizontal:'.$style->getPosHorizontal().';'; - $imgStyle.='mso-position-horizontal-relative:'.$style->getPosHorizontalRel().';'; - $imgStyle.='mso-position-vertical:'.$style->getPosVertical().';'; - $imgStyle.='mso-position-vertical-relative:'.$style->getPosVerticalRel().';'; - $imgStyle.='margin-left:0;margin-top:0;'; - break; - - case ImageStyle::POSITION_ABSOLUTE: - $imgStyle.='mso-position-horizontal-relative:page;'; - $imgStyle.='mso-position-vertical-relative:page;'; - break; - } + $imgStyle.='position:absolute;mso-width-percent:0;mso-height-percent:0;'; + $imgStyle.='mso-width-relative:margin;mso-height-relative:margin;'; + switch ($positioning) { + case ImageStyle::POSITION_RELATIVE: + $imgStyle.='mso-position-horizontal:'.$style->getPosHorizontal().';'; + $imgStyle.='mso-position-horizontal-relative:'.$style->getPosHorizontalRel().';'; + $imgStyle.='mso-position-vertical:'.$style->getPosVertical().';'; + $imgStyle.='mso-position-vertical-relative:'.$style->getPosVerticalRel().';'; + $imgStyle.='margin-left:0;margin-top:0;'; + break; + case ImageStyle::POSITION_ABSOLUTE: + $imgStyle.='mso-position-horizontal-relative:page;'; + $imgStyle.='mso-position-vertical-relative:page;'; + break; + } switch ($wrappingStyle) { case ImageStyle::WRAPPING_STYLE_BEHIND: From 1a544cb2fa3c20015892fc19f5f5bce9448f5324 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 10:36:13 +0200 Subject: [PATCH 006/167] Fixed bug in header / footer, in which media elements were all assigned to the first header element. This resulted in a corrupted DOCX, when a media element was assigned to a second header in the same section. --- src/PhpWord/Element/AbstractContainer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index ea3450a5fa..b90f6d728a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -412,6 +412,7 @@ private function checkElementDocPart() $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); + $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; return $inHeaderFooter ? $docPart . $docPartId : $docPart; } From c21e28f9744cf25be7d643cdaf3fb28470d917a5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 15:13:31 +0700 Subject: [PATCH 007/167] More refactoring for PHPMD compliance --- .travis.yml | 7 +- CHANGELOG.md | 1 + phpmd.xml | 14 -- src/PhpWord/Element/AbstractContainer.php | 142 ++++++++-------- src/PhpWord/Element/AbstractElement.php | 4 +- src/PhpWord/Element/Footer.php | 2 +- src/PhpWord/Element/Image.php | 54 +++++-- src/PhpWord/Element/Object.php | 47 ++++-- src/PhpWord/Element/Title.php | 17 +- src/PhpWord/Footnotes.php | 151 ------------------ src/PhpWord/Media.php | 2 +- src/PhpWord/Reader/AbstractReader.php | 13 +- src/PhpWord/Settings.php | 39 +++-- src/PhpWord/Shared/Drawing.php | 80 +++++----- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Style/Font.php | 71 +++++++- src/PhpWord/Style/Paragraph.php | 84 +++++++--- src/PhpWord/Style/Row.php | 61 +++++-- src/PhpWord/Style/TOC.php | 4 +- src/PhpWord/Style/Table.php | 16 +- src/PhpWord/TOC.php | 84 ---------- src/PhpWord/Writer/AbstractWriter.php | 19 ++- src/PhpWord/Writer/HTML/Style/Font.php | 10 +- src/PhpWord/Writer/ODText/Element/Text.php | 8 +- src/PhpWord/Writer/ODText/Style/Font.php | 4 +- src/PhpWord/Writer/RTF/Element/Text.php | 8 +- src/PhpWord/Writer/Word2007/Element/Image.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 11 +- .../Writer/Word2007/Part/AbstractPart.php | 2 +- .../Writer/Word2007/Part/ContentTypes.php | 24 +-- src/PhpWord/Writer/Word2007/Style/Font.php | 16 +- .../Writer/Word2007/Style/Paragraph.php | 13 +- tests/PhpWord/Tests/Element/ImageTest.php | 4 +- tests/PhpWord/Tests/SettingsTest.php | 4 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- 37 files changed, 485 insertions(+), 541 deletions(-) delete mode 100644 phpmd.xml delete mode 100644 src/PhpWord/Footnotes.php delete mode 100644 src/PhpWord/TOC.php diff --git a/.travis.yml b/.travis.yml index cf69291fc2..10cb442fac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,12 +38,11 @@ before_script: script: ## PHP_CodeSniffer - - phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip - - phpcs --standard=PSR2 -n tests/ + - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP Copy/Paste Detector - - php phpcpd.phar --verbose src/ + - phpcpd src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/ text phpmd.xml --exclude pclzip.lib.php + - phpmd src/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/CHANGELOG.md b/CHANGELOG.md index ccdac7eef3..b3b70dcee6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ This release marked heavy refactorings on internal code structure with the creat - Refactor: Apply composite pattern for Word2007 reader - @ivanlanin - Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 - QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin +- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin ## 0.9.1 - 27 Mar 2014 diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index c1ebb770d3..0000000000 --- a/phpmd.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 0968c4ffe6..6c277dad65 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -9,17 +9,15 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Element\CheckBox; use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Link; use PhpOffice\PhpWord\Element\ListItem; use PhpOffice\PhpWord\Element\Object; -use PhpOffice\PhpWord\Element\PreserveText; -use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextBreak; use PhpOffice\PhpWord\Element\TextRun; -use PhpOffice\PhpWord\Exception\InvalidObjectException; /** * Container abstract class @@ -69,27 +67,29 @@ public function countElements() } /** - * Add text element + * Add text/preservetext element * * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Text + * @param string $elementName Text|PreserveText + * @return \PhpOffice\PhpWord\Element\Text|\PhpOffice\PhpWord\Element\PreserveText */ - public function addText($text, $fontStyle = null, $paragraphStyle = null) + public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') { - $this->checkValidity('Text'); + $this->checkValidity($elementName); + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { $paragraphStyle = null; } - $textObject = new Text($text, $fontStyle, $paragraphStyle); - $textObject->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textObject); + $element = new $elementClass($text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $textObject; + return $element; } /** @@ -102,11 +102,11 @@ public function addTextRun($paragraphStyle = null) { $this->checkValidity('Textrun'); - $textRun = new TextRun($paragraphStyle); - $textRun->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textRun); + $element = new TextRun($paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $textRun; + return $element; } /** @@ -123,13 +123,15 @@ public function addLink($target, $text = null, $fontStyle = null, $paragraphStyl $this->checkValidity('Link'); $elementDocPart = $this->checkElementDocPart(); - $link = new Link($target, $text, $fontStyle, $paragraphStyle); - $link->setDocPart($this->getDocPart(), $this->getDocPartId()); + $element = new Link($target, $text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $rId = Media::addElement($elementDocPart, 'link', $target); - $link->setRelationId($rId); - $this->addElement($link); + $element->setRelationId($rId); - return $link; + $this->addElement($element); + + return $element; } /** @@ -142,13 +144,7 @@ public function addLink($target, $text = null, $fontStyle = null, $paragraphStyl */ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('PreserveText'); - - $preserveText = new PreserveText($text, $fontStyle, $paragraphStyle); - $preserveText->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($preserveText); - - return $preserveText; + return $this->addText($text, $fontStyle, $paragraphStyle, 'PreserveText'); } /** @@ -163,9 +159,9 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu $this->checkValidity('TextBreak'); for ($i = 1; $i <= $count; $i++) { - $textBreak = new TextBreak($fontStyle, $paragraphStyle); - $textBreak->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textBreak); + $element = new TextBreak($fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); } } @@ -183,33 +179,35 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n { $this->checkValidity('ListItem'); - $listItem = new ListItem($text, $depth, $fontStyle, $listStyle, $paragraphStyle); - $listItem->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($listItem); + $element = new ListItem($text, $depth, $fontStyle, $listStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $listItem; + return $element; } /** * Add image element * - * @param string $src + * @param string $source * @param mixed $style Image style * @param boolean $isWatermark * @return \PhpOffice\PhpWord\Element\Image */ - public function addImage($src, $style = null, $isWatermark = false) + public function addImage($source, $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); + $element = new Image($source, $style, $isWatermark); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + + $rId = Media::addElement($elementDocPart, 'image', $source, $element); + $element->setRelationId($rId); + + $this->addElement($element); - return $image; + return $element; } /** @@ -217,35 +215,27 @@ public function addImage($src, $style = null, $isWatermark = false) * * All exceptions should be handled by \PhpOffice\PhpWord\Element\Object * - * @param string $src + * @param string $source * @param mixed $style * @return \PhpOffice\PhpWord\Element\Object * @throws \PhpOffice\PhpWord\Exception\Exception */ - public function addObject($src, $style = null) + public function addObject($source, $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__ . "/../resources/{$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(); - } + $element = new Object($source, $style); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + + $rId = Media::addElement($elementDocPart, 'object', $source); + $element->setRelationId($rId); + $rIdIcon = Media::addElement($elementDocPart, 'image', $element->getIcon(), new Image($element->getIcon())); + $element->setImageRelationId($rIdIcon); + + $this->addElement($element); + + return $element; } /** @@ -258,19 +248,19 @@ public function addObject($src, $style = null) public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { $this->checkValidity($elementName); + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; $docPart = strtolower($elementName); $addMethod = "add{$elementName}"; - $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; - $note = new $elementClass($paragraphStyle); - // if ($this->phpWord instanceof PhpWord) { - $rId = $this->phpWord->$addMethod($note); - // } - $note->setDocPart($docPart, $this->getDocPartId()); - $note->setRelationId($rId); - $this->addElement($note); + $element = new $elementClass($paragraphStyle); + if ($this->phpWord instanceof PhpWord) { + $rId = $this->phpWord->$addMethod($element); + } + $element->setDocPart($docPart, $this->getDocPartId()); + $element->setRelationId($rId); + $this->addElement($element); - return $note; + return $element; } /** @@ -297,11 +287,11 @@ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = n { $this->checkValidity('CheckBox'); - $checkBox = new CheckBox($name, $text, $fontStyle, $paragraphStyle); - $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($checkBox); + $element = new CheckBox($name, $text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $checkBox; + return $element; } /** diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index fdad7daf2b..ce83a2cb23 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -92,13 +92,13 @@ public function getPhpWord() } /** - * Set PhpWord + * Set PhpWord as reference * * @param \PhpOffice\PhpWord\PhpWord */ public function setPhpWord(PhpWord &$phpWord = null) { - $this->phpWord = $phpWord; + $this->phpWord = &$phpWord; } /** diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 9090720da3..349b59aace 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -44,7 +44,7 @@ class Footer extends AbstractContainer * Create new instance * * @param int $sectionId - * @param int $footerId + * @param int $containerId * @param string $type */ public function __construct($sectionId, $containerId = 1, $type = self::AUTO) diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 53becbbfc3..ec120cae88 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -52,7 +52,7 @@ class Image extends AbstractElement * * @var boolean */ - private $isWatermark; + private $watermark; /** * Image type @@ -87,7 +87,7 @@ class Image extends AbstractElement * * @var boolean */ - private $isMemImage; + private $memoryImage; /** * Image target file name @@ -108,14 +108,14 @@ class Image extends AbstractElement * * @param string $source * @param mixed $style - * @param boolean $isWatermark + * @param boolean $watermark * @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException */ - public function __construct($source, $style = null, $isWatermark = false) + public function __construct($source, $style = null, $watermark = false) { $this->source = $source; - $this->setIsWatermark($isWatermark); + $this->setIsWatermark($watermark); $this->style = $this->setStyle(new ImageStyle(), $style, true); $this->checkImage($source); @@ -166,19 +166,19 @@ public function getMediaId() * * @return boolean */ - public function getIsWatermark() + public function isWatermark() { - return $this->isWatermark; + return $this->watermark; } /** * Set is watermark * - * @param boolean $pValue + * @param boolean $value */ - public function setIsWatermark($pValue) + public function setIsWatermark($value) { - $this->isWatermark = $pValue; + $this->watermark = $value; } /** @@ -226,9 +226,9 @@ public function getImageExtension() * * @return boolean */ - public function getIsMemImage() + public function isMemImage() { - return $this->isMemImage; + return $this->memoryImage; } /** @@ -314,14 +314,14 @@ private function checkImage($source) private function setSourceType($source) { if (stripos(strrev($source), strrev('.php')) === 0) { - $this->isMemImage = true; + $this->memoryImage = true; $this->sourceType = self::SOURCE_GD; } elseif (strpos($source, 'zip://') !== false) { - $this->isMemImage = false; + $this->memoryImage = false; $this->sourceType = self::SOURCE_ARCHIVE; } else { - $this->isMemImage = (filter_var($source, FILTER_VALIDATE_URL) !== false); - $this->sourceType = $this->isMemImage ? self::SOURCE_GD : self::SOURCE_LOCAL; + $this->memoryImage = (filter_var($source, FILTER_VALIDATE_URL) !== false); + $this->sourceType = $this->memoryImage ? self::SOURCE_GD : self::SOURCE_LOCAL; } } @@ -409,4 +409,26 @@ private function setProportionalSize($actualWidth, $actualHeight) } } } + + /** + * Get is watermark + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getIsWatermark() + { + return $this->isWatermark(); + } + + /** + * Get is memory image + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getIsMemImage() + { + return $this->isMemImage(); + } } diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 7407688a81..c2d204cc8c 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -10,6 +10,7 @@ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Style\Image as ImageStyle; +use PhpOffice\PhpWord\Exception\InvalidObjectException; /** * Object element @@ -30,6 +31,13 @@ class Object extends AbstractElement */ private $style; + /** + * Icon + * + * @var string + */ + private $icon; + /** * Image Relation ID * @@ -40,25 +48,42 @@ class Object extends AbstractElement /** * Create a new Ole-Object Element * - * @param string $src + * @param string $source * @param mixed $style */ - public function __construct($src, $style = null) + public function __construct($source, $style = null) { $supportedTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx'); - $inf = pathinfo($src); + $pathInfo = pathinfo($source); - if (file_exists($src) && in_array($inf['extension'], $supportedTypes)) { - $this->source = $src; + if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) { + $ext = $pathInfo['extension']; + if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { + $ext = substr($ext, 0, -1); + } + + $this->source = $source; $this->style = $this->setStyle(new ImageStyle(), $style, true); + $this->icon = realpath(__DIR__ . "/../resources/{$ext}.png"); + return $this; } else { - return false; + throw new InvalidObjectException(); } } /** - * Get Image style + * Get object source + * + * @return string + */ + public function getSource() + { + return $this->source; + } + + /** + * Get object style * * @return \PhpOffice\PhpWord\Style\Image */ @@ -68,17 +93,17 @@ public function getStyle() } /** - * Get Source + * Get object icon * * @return string */ - public function getSource() + public function getIcon() { - return $this->source; + return $this->icon; } /** - * Get Image Relation ID + * Get image relation ID * * @return int */ diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index f6d3bba9b5..d07df480d3 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -29,14 +29,7 @@ class Title extends AbstractElement * * @var int */ - private $depth; - - /** - * Title anchor - * - * @var int - */ - private $anchor; + private $depth = 1; /** * Title Bookmark ID @@ -52,13 +45,19 @@ class Title extends AbstractElement */ private $style; + /** + * Title anchor + * + * @var int + * @deprecated 0.10.0 + */ + private $anchor; /** * Create a new Title Element * * @param string $text * @param int $depth - * @param string $style */ public function __construct($text, $depth = 1) { diff --git a/src/PhpWord/Footnotes.php b/src/PhpWord/Footnotes.php deleted file mode 100644 index 7ab2a587c7..0000000000 --- a/src/PhpWord/Footnotes.php +++ /dev/null @@ -1,151 +0,0 @@ -getIsMemImage(); + $isMemImage = $image->isMemImage(); $extension = $image->getImageExtension(); $mediaData['imageExtension'] = $extension; $mediaData['imageType'] = $image->getImageType(); diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 424ff2cd9b..2eb53fe25e 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -37,7 +37,7 @@ abstract class AbstractReader implements ReaderInterface * * @return bool */ - public function getReadDataOnly() + public function isReadDataOnly() { // return $this->readDataOnly; return true; @@ -96,4 +96,15 @@ public function canRead($pFilename) return true; } + + /** + * Read data only? + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getReadDataOnly() + { + return $this->isReadDataOnly(); + } } diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index bd18df4857..af9044d32d 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -91,6 +91,16 @@ class Settings */ private static $measurementUnit = self::UNIT_TWIP; + /** + * Return the compatibility option used by the XMLWriter + * + * @return bool Compatibility + */ + public static function hasCompatibility() + { + return self::$xmlWriterCompatibility; + } + /** * Set the compatibility option used by the XMLWriter * @@ -110,13 +120,13 @@ public static function setCompatibility($compatibility) } /** - * Return the compatibility option used by the XMLWriter + * Get zip handler class * - * @return bool Compatibility + * @return string */ - public static function getCompatibility() + public static function getZipClass() { - return self::$xmlWriterCompatibility; + return self::$zipClass; } /** @@ -136,16 +146,6 @@ public static function setZipClass($zipClass) return false; } - /** - * Get zip handler class - * - * @return string - */ - public static function getZipClass() - { - return self::$zipClass; - } - /** * Set details of the external library for rendering PDF files * @@ -237,4 +237,15 @@ public static function setMeasurementUnit($value) return true; } + + /** + * Return the compatibility option used by the XMLWriter + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public static function getCompatibility() + { + return self::hasCompatibility(); + } } diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 58a6ee1a9c..3d754469a9 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -17,24 +17,24 @@ class Drawing /** * Convert pixels to EMU * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in EMU */ - public static function pixelsToEMU($pValue = 0) + public static function pixelsToEMU($value = 0) { - return round($pValue * 9525); + return round($value * 9525); } /** * Convert EMU to pixels * - * @param integer $pValue Value in EMU + * @param integer $value Value in EMU * @return integer Value in pixels */ - public static function EMUToPixels($pValue = 0) + public static function emuToPixels($value = 0) { - if ($pValue != 0) { - return round($pValue / 9525); + if ($value != 0) { + return round($value / 9525); } else { return 0; } @@ -43,24 +43,24 @@ public static function EMUToPixels($pValue = 0) /** * Convert pixels to points * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in points */ - public static function pixelsToPoints($pValue = 0) + public static function pixelsToPoints($value = 0) { - return $pValue * 0.67777777; + return $value * 0.67777777; } /** * Convert points width to pixels * - * @param integer $pValue Value in points + * @param integer $value Value in points * @return integer Value in pixels */ - public static function pointsToPixels($pValue = 0) + public static function pointsToPixels($value = 0) { - if ($pValue != 0) { - return $pValue * 1.333333333; + if ($value != 0) { + return $value * 1.333333333; } else { return 0; } @@ -69,24 +69,24 @@ public static function pointsToPixels($pValue = 0) /** * Convert degrees to angle * - * @param integer $pValue Degrees + * @param integer $value Degrees * @return integer Angle */ - public static function degreesToAngle($pValue = 0) + public static function degreesToAngle($value = 0) { - return (integer)round($pValue * 60000); + return (integer)round($value * 60000); } /** * Convert angle to degrees * - * @param integer $pValue Angle + * @param integer $value Angle * @return integer Degrees */ - public static function angleToDegrees($pValue = 0) + public static function angleToDegrees($value = 0) { - if ($pValue != 0) { - return round($pValue / 60000); + if ($value != 0) { + return round($value / 60000); } else { return 0; } @@ -95,24 +95,24 @@ public static function angleToDegrees($pValue = 0) /** * Convert pixels to centimeters * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in centimeters */ - public static function pixelsToCentimeters($pValue = 0) + public static function pixelsToCentimeters($value = 0) { - return $pValue * 0.028; + return $value * 0.028; } /** * Convert centimeters width to pixels * - * @param integer $pValue Value in centimeters + * @param integer $value Value in centimeters * @return integer Value in pixels */ - public static function centimetersToPixels($pValue = 0) + public static function centimetersToPixels($value = 0) { - if ($pValue != 0) { - return $pValue / 0.028; + if ($value != 0) { + return $value / 0.028; } else { return 0; } @@ -121,27 +121,27 @@ public static function centimetersToPixels($pValue = 0) /** * Convert HTML hexadecimal to RGB * - * @param string $pValue HTML Color in hexadecimal + * @param string $value HTML Color in hexadecimal * @return array Value in RGB */ - public static function htmlToRGB($pValue) + public static function htmlToRGB($value) { - if ($pValue[0] == '#') { - $pValue = substr($pValue, 1); + if ($value[0] == '#') { + $value = substr($value, 1); } - if (strlen($pValue) == 6) { - list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]); - } elseif (strlen($pValue) == 3) { - list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]); + if (strlen($value) == 6) { + list($red, $green, $blue) = array($value[0] . $value[1], $value[2] . $value[3], $value[4] . $value[5]); + } elseif (strlen($value) == 3) { + list($red, $green, $blue) = array($value[0] . $value[0], $value[1] . $value[1], $value[2] . $value[2]); } else { return false; } - $color_R = hexdec($color_R); - $color_G = hexdec($color_G); - $color_B = hexdec($color_B); + $red = hexdec($red); + $green = hexdec($green); + $blue = hexdec($blue); - return array($color_R, $color_G, $color_B); + return array($red, $green, $blue); } } diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 53f5e893d4..876053a7fe 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -73,7 +73,7 @@ public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = } // Set xml Compatibility - $compatibility = Settings::getCompatibility(); + $compatibility = Settings::hasCompatibility(); if ($compatibility) { $this->xmlWriter->setIndent(false); $this->xmlWriter->setIndentString(''); diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 86467d026a..ce6882cbef 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -288,7 +288,7 @@ public function setSize($value = PhpWord::DEFAULT_FONT_SIZE) * * @return bool */ - public function getBold() + public function isBold() { return $this->bold; } @@ -311,7 +311,7 @@ public function setBold($value = false) * * @return bool */ - public function getItalic() + public function isItalic() { return $this->italic; } @@ -334,7 +334,7 @@ public function setItalic($value = false) * * @return bool */ - public function getSuperScript() + public function isSuperScript() { return $this->superScript; } @@ -360,7 +360,7 @@ public function setSuperScript($value = false) * * @return bool */ - public function getSubScript() + public function isSubScript() { return $this->subScript; } @@ -409,7 +409,7 @@ public function setUnderline($value = self::UNDERLINE_NONE) * * @return bool */ - public function getStrikethrough() + public function isStrikethrough() { return $this->strikethrough; } @@ -435,7 +435,7 @@ public function setStrikethrough($value = false) * * @return bool */ - public function getDoubleStrikethrough() + public function isDoubleStrikethrough() { return $this->doubleStrikethrough; } @@ -605,7 +605,7 @@ public function setHint($value = PhpWord::DEFAULT_FONT_CONTENT_TYPE) * * @return bool */ - public function getSmallCaps() + public function isSmallCaps() { return $this->smallCaps; } @@ -631,7 +631,7 @@ public function setSmallCaps($value = false) * * @return bool */ - public function getAllCaps() + public function isAllCaps() { return $this->allCaps; } @@ -681,4 +681,59 @@ public function setShading($value = null) return $this; } + + /** + * Get bold + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getBold() + { + return $this->isBold(); + } + + /** + * Get italic + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getItalic() + { + return $this->isItalic(); + } + + /** + * Get superscript + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getSuperScript() + { + return $this->isSuperScript(); + } + + /** + * Get subscript + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getSubScript() + { + return $this->isSubScript(); + } + + /** + * Get strikethrough + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getStrikethrough() + { + return $this->isStrikethrough(); + } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index b6f482bf5e..0a1be26b01 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -340,7 +340,7 @@ public function setTabs($value = null) /** * Get parent style ID * - * @return string + * @return string */ public function getBasedOn() { @@ -350,8 +350,8 @@ public function getBasedOn() /** * Set parent style ID * - * @param string $value - * @return self + * @param string $value + * @return self */ public function setBasedOn($value = 'Normal') { @@ -372,8 +372,8 @@ public function getNext() /** * Set style for next paragraph * - * @param string $value - * @return self + * @param string $value + * @return self */ public function setNext($value = null) { @@ -384,9 +384,9 @@ public function setNext($value = null) /** * Get allow first/last line to display on a separate page setting * - * @return bool + * @return bool */ - public function getWidowControl() + public function hasWidowControl() { return $this->widowControl; } @@ -394,8 +394,8 @@ public function getWidowControl() /** * Set keep paragraph with next paragraph setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setWidowControl($value = true) { @@ -409,9 +409,9 @@ public function setWidowControl($value = true) /** * Get keep paragraph with next paragraph setting * - * @return bool + * @return bool */ - public function getKeepNext() + public function isKeepNext() { return $this->keepNext; } @@ -419,8 +419,8 @@ public function getKeepNext() /** * Set keep paragraph with next paragraph setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setKeepNext($value = false) { @@ -434,9 +434,9 @@ public function setKeepNext($value = false) /** * Get keep all lines on one page setting * - * @return bool + * @return bool */ - public function getKeepLines() + public function isKeepLines() { return $this->keepLines; } @@ -444,8 +444,8 @@ public function getKeepLines() /** * Set keep all lines on one page setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setKeepLines($value = false) { @@ -461,7 +461,7 @@ public function setKeepLines($value = false) * * @return bool */ - public function getPageBreakBefore() + public function hasPageBreakBefore() { return $this->pageBreakBefore; } @@ -469,8 +469,8 @@ public function getPageBreakBefore() /** * Set start paragraph on next page setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setPageBreakBefore($value = false) { @@ -542,4 +542,48 @@ public function setSpace($value = null) return $this; } + + /** + * Get allow first/last line to display on a separate page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getWidowControl() + { + return $this->hasWidowControl(); + } + + /** + * Get keep paragraph with next paragraph setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getKeepNext() + { + return $this->isKeepNext(); + } + + /** + * Get keep all lines on one page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getKeepLines() + { + return $this->isKeepLines(); + } + + /** + * Get start paragraph on next page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getPageBreakBefore() + { + return $this->hasPageBreakBefore(); + } } diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index e2a07b85fc..727ad22148 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -45,9 +45,19 @@ public function __construct() } /** - * Set tblHeader + * Is tblHeader * - * @param boolean $value + * @return bool + */ + public function isTblHeader() + { + return $this->tblHeader; + } + + /** + * Is tblHeader + * + * @param bool $value * @return self */ public function setTblHeader($value = false) @@ -56,19 +66,19 @@ public function setTblHeader($value = false) } /** - * Get tblHeader + * Is cantSplit * - * @return boolean + * @return bool */ - public function getTblHeader() + public function isCantSplit() { - return $this->tblHeader; + return $this->cantSplit; } /** - * Set cantSplit + * Is cantSplit * - * @param boolean $value + * @param bool $value * @return self */ public function setCantSplit($value = false) @@ -77,13 +87,13 @@ public function setCantSplit($value = false) } /** - * Get cantSplit + * Is exactHeight * - * @return boolean + * @return bool */ - public function getCantSplit() + public function isExactHeight() { - return $this->cantSplit; + return $this->exactHeight; } /** @@ -98,13 +108,36 @@ public function setExactHeight($value = false) return $this; } + /** + * Get tblHeader + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getTblHeader() + { + return $this->isTblHeader(); + } + + /** + * Get cantSplit + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getCantSplit() + { + return $this->isCantSplit(); + } + /** * Get exactHeight * - * @return boolean + * @deprecated 0.10.0 + * @codeCoverageIgnore */ public function getExactHeight() { - return $this->exactHeight; + return $this->isExactHeight(); } } diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 5333a0b6b1..255da5b64a 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -53,7 +53,7 @@ public function getTabPos() */ public function setTabPos($value) { - $this->position = $value; + $this->setPosition($value); } /** @@ -73,7 +73,7 @@ public function getTabLeader() */ public function setTabLeader($value = self::TABLEADER_DOT) { - $this->leader = $value; + $this->setLeader($value); } /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c4ec8b6831..9995a2f248 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -224,7 +224,7 @@ public function getBorderColor() /** * Set border size inside horizontal * - * @param $value + * @param int $value */ public function setBorderInsideHSize($value = null) { @@ -234,7 +234,7 @@ public function setBorderInsideHSize($value = null) /** * Get border size inside horizontal * - * @return + * @return int */ public function getBorderInsideHSize() { @@ -244,7 +244,7 @@ public function getBorderInsideHSize() /** * Set border size inside vertical * - * @param $value + * @param int $value */ public function setBorderInsideVSize($value = null) { @@ -254,7 +254,7 @@ public function setBorderInsideVSize($value = null) /** * Get border size inside vertical * - * @return + * @return int */ public function getBorderInsideVSize() { @@ -264,7 +264,7 @@ public function getBorderInsideVSize() /** * Set border color inside horizontal * - * @param $value + * @param string $value */ public function setBorderInsideHColor($value = null) { @@ -274,7 +274,7 @@ public function setBorderInsideHColor($value = null) /** * Get border color inside horizontal * - * @return + * @return string */ public function getBorderInsideHColor() { @@ -284,7 +284,7 @@ public function getBorderInsideHColor() /** * Set border color inside vertical * - * @param $value + * @param string $value */ public function setBorderInsideVColor($value = null) { @@ -294,7 +294,7 @@ public function setBorderInsideVColor($value = null) /** * Get border color inside vertical * - * @return + * @return string */ public function getBorderInsideVColor() { diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php deleted file mode 100644 index 577fe4ab0d..0000000000 --- a/src/PhpWord/TOC.php +++ /dev/null @@ -1,84 +0,0 @@ -useDiskCaching; } @@ -131,7 +131,7 @@ public function getUseDiskCaching() /** * Set use disk caching status * - * @param boolean $pValue + * @param bool $pValue * @param string $pDirectory * @return self */ @@ -356,4 +356,15 @@ private function deleteDir($dir) rmdir($dir); } + + /** + * Get use disk caching status + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getUseDiskCaching() + { + return $this->isUseDiskCaching(); + } } diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 73ae14c134..3d217f3349 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -41,22 +41,22 @@ public function write() $css['color'] = '#' . $this->style->getColor(); } $css['background'] = $this->style->getFgColor(); - if ($this->style->getBold()) { + if ($this->style->isBold()) { $css['font-weight'] = 'bold'; } - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $css['font-style'] = 'italic'; } - if ($this->style->getSuperScript()) { + if ($this->style->isSuperScript()) { $css['vertical-align'] = 'super'; - } elseif ($this->style->getSubScript()) { + } elseif ($this->style->isSubScript()) { $css['vertical-align'] = 'sub'; } $css['text-decoration'] = ''; if ($this->style->getUnderline() != FontStyle::UNDERLINE_NONE) { $css['text-decoration'] .= 'underline '; } - if ($this->style->getStrikethrough()) { + if ($this->style->isStrikethrough()) { $css['text-decoration'] .= 'line-through '; } diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 63ce7b6853..b9f8de4deb 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -25,12 +25,12 @@ public function write() $paragraphStyle = $this->element->getParagraphStyle(); // @todo Commented for TextRun. Should really checkout this value - // $SfIsObject = ($fontStyle instanceof Font) ? true : false; - $SfIsObject = false; + // $fStyleIsObject = ($fontStyle instanceof Font) ? true : false; + $fStyleIsObject = false; - if ($SfIsObject) { + if ($fStyleIsObject) { // Don't never be the case, because I browse all sections for cleaning all styles not declared - throw new Exception('PhpWord : $SfIsObject wouldn\'t be an object'); + throw new Exception('PhpWord : $fStyleIsObject wouldn\'t be an object'); } else { if (!$this->withoutP) { $this->xmlWriter->startElement('text:p'); // text:p diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 822e8a9051..bf174ee6ab 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -48,12 +48,12 @@ public function write() if ($this->style->getColor()) { $this->xmlWriter->writeAttribute('fo:color', '#' . $this->style->getColor()); } - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $this->xmlWriter->writeAttribute('fo:font-style', 'italic'); $this->xmlWriter->writeAttribute('style:font-style-asian', 'italic'); $this->xmlWriter->writeAttribute('style:font-style-complex', 'italic'); } - if ($this->style->getBold()) { + if ($this->style->isBold()) { $this->xmlWriter->writeAttribute('fo:font-weight', 'bold'); $this->xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 2ee110e006..bbd36f65db 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -73,10 +73,10 @@ public function write() } else { $rtfText .= '\f0'; } - if ($fontStyle->getBold()) { + if ($fontStyle->isBold()) { $rtfText .= '\b'; } - if ($fontStyle->getItalic()) { + if ($fontStyle->isItalic()) { $rtfText .= '\i'; } if ($fontStyle->getSize()) { @@ -92,10 +92,10 @@ public function write() $rtfText .= '\cf0'; $rtfText .= '\f0'; - if ($fontStyle->getBold()) { + if ($fontStyle->isBold()) { $rtfText .= '\b0'; } - if ($fontStyle->getItalic()) { + if ($fontStyle->isItalic()) { $rtfText .= '\i0'; } if ($fontStyle->getSize()) { diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index e944b7af53..8da8a13b36 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -23,7 +23,7 @@ class Image extends Element */ public function write() { - if ($this->element->getIsWatermark()) { + if ($this->element->isWatermark()) { $this->writeWatermark(); } else { $this->writeImage(); diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index c538561abd..f838796084 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -84,25 +84,22 @@ public function write() $row = $rows[$i]; $height = $row->getHeight(); $rowStyle = $row->getStyle(); - $tblHeader = $rowStyle->getTblHeader(); - $cantSplit = $rowStyle->getCantSplit(); - $exactHeight = $rowStyle->getExactHeight(); $this->xmlWriter->startElement('w:tr'); - if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { + if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { $this->xmlWriter->startElement('w:trPr'); if (!is_null($height)) { $this->xmlWriter->startElement('w:trHeight'); $this->xmlWriter->writeAttribute('w:val', $height); - $this->xmlWriter->writeAttribute('w:hRule', ($exactHeight ? 'exact' : 'atLeast')); + $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); $this->xmlWriter->endElement(); } - if ($tblHeader) { + if ($rowStyle->isTblHeader()) { $this->xmlWriter->startElement('w:tblHeader'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($cantSplit) { + if ($rowStyle->isCantSplit()) { $this->xmlWriter->startElement('w:cantSplit'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index afa84caf8f..914c04074f 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -63,7 +63,7 @@ protected function getXmlWriter() { $useDiskCaching = false; if (!is_null($this->parentWriter)) { - if ($this->parentWriter->getUseDiskCaching()) { + if ($this->parentWriter->isUseDiskCaching()) { $useDiskCaching = true; } } diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 00e05c7619..e89b8d7985 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -24,24 +24,24 @@ class ContentTypes extends AbstractPart */ public function writeContentTypes($contentTypes) { - $OpenXMLPrefix = 'application/vnd.openxmlformats-'; - $WordMLPrefix = $OpenXMLPrefix . 'officedocument.wordprocessingml.'; + $openXMLPrefix = 'application/vnd.openxmlformats-'; + $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; $overrides = array( - '/docProps/core.xml' => $OpenXMLPrefix . 'package.core-properties+xml', - '/docProps/app.xml' => $OpenXMLPrefix . 'officedocument.extended-properties+xml', - '/word/document.xml' => $WordMLPrefix . 'document.main+xml', - '/word/styles.xml' => $WordMLPrefix . 'styles+xml', - '/word/numbering.xml' => $WordMLPrefix . 'numbering+xml', - '/word/settings.xml' => $WordMLPrefix . 'settings+xml', - '/word/theme/theme1.xml' => $OpenXMLPrefix . 'officedocument.theme+xml', - '/word/webSettings.xml' => $WordMLPrefix . 'webSettings+xml', - '/word/fontTable.xml' => $WordMLPrefix . 'fontTable+xml', + '/docProps/core.xml' => $openXMLPrefix . 'package.core-properties+xml', + '/docProps/app.xml' => $openXMLPrefix . 'officedocument.extended-properties+xml', + '/word/document.xml' => $wordMLPrefix . 'document.main+xml', + '/word/styles.xml' => $wordMLPrefix . 'styles+xml', + '/word/numbering.xml' => $wordMLPrefix . 'numbering+xml', + '/word/settings.xml' => $wordMLPrefix . 'settings+xml', + '/word/theme/theme1.xml' => $openXMLPrefix . 'officedocument.theme+xml', + '/word/webSettings.xml' => $wordMLPrefix . 'webSettings+xml', + '/word/fontTable.xml' => $wordMLPrefix . 'fontTable+xml', ); $defaults = $contentTypes['default']; if (!empty($contentTypes['override'])) { foreach ($contentTypes['override'] as $key => $val) { - $overrides[$key] = $WordMLPrefix . $val . '+xml'; + $overrides[$key] = $wordMLPrefix . $val . '+xml'; } } diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 6ffc6a8707..b6a46b5b03 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -89,12 +89,12 @@ private function writeStyle() } // Bold - if ($this->style->getBold()) { + if ($this->style->isBold()) { $this->xmlWriter->writeElement('w:b', null); } // Italic - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $this->xmlWriter->writeElement('w:i', null); $this->xmlWriter->writeElement('w:iCs', null); } @@ -107,12 +107,12 @@ private function writeStyle() } // Strikethrough - if ($this->style->getStrikethrough()) { + if ($this->style->isStrikethrough()) { $this->xmlWriter->writeElement('w:strike', null); } // Double strikethrough - if ($this->style->getDoubleStrikethrough()) { + if ($this->style->isDoubleStrikethrough()) { $this->xmlWriter->writeElement('w:dstrike', null); } @@ -130,19 +130,19 @@ private function writeStyle() } // Superscript/subscript - if ($this->style->getSuperScript() || $this->style->getSubScript()) { + if ($this->style->isSuperScript() || $this->style->isSubScript()) { $this->xmlWriter->startElement('w:vertAlign'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getSuperScript() ? 'superscript' : 'subscript'); + $this->xmlWriter->writeAttribute('w:val', $this->style->isSuperScript() ? 'superscript' : 'subscript'); $this->xmlWriter->endElement(); } // Small caps - if ($this->style->getSmallCaps()) { + if ($this->style->isSmallCaps()) { $this->xmlWriter->writeElement('w:smallCaps', null); } // All caps - if ($this->style->getAllCaps()) { + if ($this->style->isAllCaps()) { $this->xmlWriter->writeElement('w:caps', null); } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index b92e171423..d2978ff8b9 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -64,11 +64,6 @@ private function writeStyle() return; } - $widowControl = $this->style->getWidowControl(); - $keepNext = $this->style->getKeepNext(); - $keepLines = $this->style->getKeepLines(); - $pageBreakBefore = $this->style->getPageBreakBefore(); - if (!$this->withoutPPR) { $this->xmlWriter->startElement('w:pPr'); } @@ -93,22 +88,22 @@ private function writeStyle() } // Pagination - if (!$widowControl) { + if (!$this->style->hasWidowControl()) { $this->xmlWriter->startElement('w:widowControl'); $this->xmlWriter->writeAttribute('w:val', '0'); $this->xmlWriter->endElement(); } - if ($keepNext) { + if ($this->style->isKeepNext()) { $this->xmlWriter->startElement('w:keepNext'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($keepLines) { + if ($this->style->isKeepLines()) { $this->xmlWriter->startElement('w:keepLines'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($pageBreakBefore) { + if ($this->style->hasPageBreakBefore()) { $this->xmlWriter->startElement('w:pageBreakBefore'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index eb4823980a..4d927b42dd 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -29,7 +29,7 @@ public function testConstruct() $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Image', $oImage); $this->assertEquals($oImage->getSource(), $src); $this->assertEquals($oImage->getMediaId(), md5($src)); - $this->assertEquals($oImage->getIsWatermark(), false); + $this->assertEquals($oImage->isWatermark(), false); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } @@ -72,7 +72,7 @@ public function testImages() $this->assertEquals($image->getImageExtension(), $extension); $this->assertEquals($image->getImageCreateFunction(), $createFunction); $this->assertEquals($image->getImageFunction(), $imageFunction); - $this->assertFalse($image->getIsMemImage()); + $this->assertFalse($image->isMemImage()); } } diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 64a0999498..ced861cb32 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -23,9 +23,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase */ public function testSetGetCompatibility() { - $this->assertTrue(Settings::getCompatibility()); + $this->assertTrue(Settings::hasCompatibility()); $this->assertTrue(Settings::setCompatibility(false)); - $this->assertFalse(Settings::getCompatibility()); + $this->assertFalse(Settings::hasCompatibility()); $this->assertFalse(Settings::setCompatibility('Non boolean')); } diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 713cebcde9..519e01879f 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -32,7 +32,7 @@ public function testUnitConversions() $result = Drawing::pixelsToEMU($value); $this->assertEquals(round($value * 9525), $result); - $result = Drawing::EMUToPixels($value); + $result = Drawing::emuToPixels($value); $this->assertEquals(round($value / 9525), $result); $result = Drawing::pixelsToPoints($value); diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index b02c3f9f19..915a564946 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -129,7 +129,7 @@ public function testSetGetUseDiskCaching() { $object = new ODText(); $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertTrue($object->isUseDiskCaching()); $this->assertEquals(PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory()); } diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 74f3b1fda0..52f9392725 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -177,7 +177,7 @@ public function testSetGetUseDiskCaching() $writer = new Word2007($phpWord); $writer->save('php://output'); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertTrue($object->isUseDiskCaching()); } /** From a62a58afc3b6d0230ddab40679f09107d4c2d106 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 12:21:19 +0200 Subject: [PATCH 008/167] #154 : PHPDocumentor on GH-Pages --- .travis_shell_after_success.sh | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .travis_shell_after_success.sh diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh new file mode 100644 index 0000000000..de2f366a3b --- /dev/null +++ b/.travis_shell_after_success.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +echo "--DEBUG--" +echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG" +echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION" +echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST" + +if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.5" ]; then + + echo -e "Publishing PHPDoc...\n" + + cp -R build/docs $HOME/docs-latest + + cd $HOME + git config --global user.email "travis@travis-ci.org" + git config --global user.name "travis-ci" + git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/Progi1984/YATSPHP gh-pages > /dev/null + + cd gh-pages + echo "--DEBUG : Suppression" + git rm -rf ./docs/$TRAVIS_BRANCH + + echo "--DEBUG : Dossier" + mkdir docs + cd docs + mkdir $TRAVIS_BRANCH + + echo "--DEBUG : Copie" + cp -Rf $HOME/docs-latest/* ./$TRAVIS_BRANCH/ + + echo "--DEBUG : Git" + git add -f . + git commit -m "PHPDocumentor (Travis Build : $TRAVIS_BUILD_NUMBER - Branch : $TRAVIS_BRANCH)" + git push -fq origin gh-pages > /dev/null + + echo -e "Published PHPDoc to gh-pages.\n" + +fi From a5287ac705cb8b4e2b67a846fbad2be3ae4808e3 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 12:22:55 +0200 Subject: [PATCH 009/167] #154 : PHPDocumentor on GH-Pages --- .travis.yml | 14 +++++++++++++- composer.json | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad3df6137d..d6d5ddd12f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,13 +14,17 @@ matrix: - php: 5.6 - php: hhvm +env: + global: + - secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4=" + before_script: ## Composer # - curl -s http://getcomposer.org/installer | php # - php composer.phar install --prefer-source - composer self-update - composer require dompdf/dompdf:0.6.* - - composer install --prefer-source + - composer install --prefer-source --dev ## PHP_CodeSniffer - pyrus install pear/PHP_CodeSniffer - phpenv rehash @@ -35,6 +39,8 @@ before_script: #- phpenv rehash ## PHPLOC #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar + ## PHPDocumentor + - mkdir -p build/docs script: ## PHP_CodeSniffer @@ -48,3 +54,9 @@ script: #- php phploc.phar src/ ## PHPUnit - phpunit -c ./ --coverage-text + ## PHPDocumentor + - vendor/bin/phpdoc.php -d ./src -t ./build/docs + +after_script: + ## PHPDocumentor + - bash .travis_shell_after_success.sh diff --git a/composer.json b/composer.json index fafa9a28c0..a8c83abd07 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "ext-zip": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*", + "phpdocumentor/phpdocumentor":"2.*" }, "suggest": { "ext-gd2": "Required to add images", From de2b7d897cd5c99abfc5ef65a47fe8e5d2709304 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 12:34:35 +0200 Subject: [PATCH 010/167] #154 : PHPDocumentor on GH-Pages --- .travis_shell_after_success.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh index de2f366a3b..567b1acb33 100644 --- a/.travis_shell_after_success.sh +++ b/.travis_shell_after_success.sh @@ -14,7 +14,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == cd $HOME git config --global user.email "travis@travis-ci.org" git config --global user.name "travis-ci" - git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/Progi1984/YATSPHP gh-pages > /dev/null + git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/PHPOffice/PHPWord gh-pages > /dev/null cd gh-pages echo "--DEBUG : Suppression" From 35d06cc2ce5269ea01f2c57a453c54db17a42e01 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 17:55:54 +0700 Subject: [PATCH 011/167] Change PHPWord license to LGPL 3 as per #211 --- CHANGELOG.md | 22 +- LICENSE.md | 1069 +++++++++++------ composer.json | 2 +- src/PhpWord/Autoloader.php | 2 +- src/PhpWord/DocumentProperties.php | 2 +- src/PhpWord/Element/AbstractContainer.php | 2 +- src/PhpWord/Element/AbstractElement.php | 2 +- src/PhpWord/Element/Cell.php | 2 +- src/PhpWord/Element/CheckBox.php | 2 +- src/PhpWord/Element/Endnote.php | 2 +- src/PhpWord/Element/Footer.php | 2 +- src/PhpWord/Element/Footnote.php | 2 +- src/PhpWord/Element/Header.php | 2 +- src/PhpWord/Element/Image.php | 2 +- src/PhpWord/Element/Link.php | 2 +- src/PhpWord/Element/ListItem.php | 2 +- src/PhpWord/Element/Object.php | 2 +- src/PhpWord/Element/PageBreak.php | 2 +- src/PhpWord/Element/PreserveText.php | 2 +- src/PhpWord/Element/Row.php | 2 +- src/PhpWord/Element/Section.php | 2 +- src/PhpWord/Element/TOC.php | 2 +- src/PhpWord/Element/Table.php | 2 +- src/PhpWord/Element/Text.php | 2 +- src/PhpWord/Element/TextBreak.php | 2 +- src/PhpWord/Element/TextRun.php | 2 +- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/Endnotes.php | 2 +- src/PhpWord/Exception/Exception.php | 2 +- .../Exception/InvalidImageException.php | 2 +- .../Exception/InvalidObjectException.php | 2 +- .../Exception/InvalidStyleException.php | 2 +- .../UnsupportedImageTypeException.php | 2 +- src/PhpWord/Footnotes.php | 2 +- src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Media.php | 2 +- src/PhpWord/PhpWord.php | 2 +- src/PhpWord/Reader/AbstractReader.php | 2 +- src/PhpWord/Reader/ODText.php | 2 +- src/PhpWord/Reader/ODText/AbstractPart.php | 2 +- src/PhpWord/Reader/ODText/Content.php | 2 +- src/PhpWord/Reader/ReaderInterface.php | 2 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 2 +- src/PhpWord/Reader/Word2007/DocProps.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsApp.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +- .../Reader/Word2007/DocPropsCustom.php | 2 +- src/PhpWord/Reader/Word2007/Document.php | 2 +- src/PhpWord/Reader/Word2007/Endnotes.php | 2 +- src/PhpWord/Reader/Word2007/Footnotes.php | 2 +- src/PhpWord/Reader/Word2007/Notes.php | 2 +- src/PhpWord/Reader/Word2007/Numbering.php | 2 +- src/PhpWord/Reader/Word2007/Styles.php | 2 +- src/PhpWord/Settings.php | 2 +- src/PhpWord/Shared/Drawing.php | 2 +- src/PhpWord/Shared/Font.php | 2 +- src/PhpWord/Shared/String.php | 2 +- src/PhpWord/Shared/XMLReader.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Shared/ZipArchive.php | 2 +- src/PhpWord/Style.php | 2 +- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Border.php | 2 +- src/PhpWord/Style/Cell.php | 2 +- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Style/Image.php | 2 +- src/PhpWord/Style/Indentation.php | 2 +- src/PhpWord/Style/LineNumbering.php | 2 +- src/PhpWord/Style/ListItem.php | 2 +- src/PhpWord/Style/Numbering.php | 2 +- src/PhpWord/Style/NumberingLevel.php | 2 +- src/PhpWord/Style/Paragraph.php | 2 +- src/PhpWord/Style/Row.php | 2 +- src/PhpWord/Style/Section.php | 2 +- src/PhpWord/Style/Shading.php | 2 +- src/PhpWord/Style/Spacing.php | 2 +- src/PhpWord/Style/TOC.php | 2 +- src/PhpWord/Style/Tab.php | 2 +- src/PhpWord/Style/Table.php | 2 +- src/PhpWord/TOC.php | 2 +- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 2 +- src/PhpWord/Writer/HTML.php | 2 +- src/PhpWord/Writer/HTML/Element/Element.php | 2 +- src/PhpWord/Writer/HTML/Element/Endnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Image.php | 2 +- src/PhpWord/Writer/HTML/Element/Link.php | 2 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 2 +- src/PhpWord/Writer/HTML/Element/Note.php | 2 +- src/PhpWord/Writer/HTML/Element/PageBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/Table.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 2 +- src/PhpWord/Writer/HTML/Element/TextBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/TextRun.php | 2 +- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- .../Writer/HTML/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/HTML/Style/Generic.php | 2 +- src/PhpWord/Writer/HTML/Style/Image.php | 2 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 2 +- src/PhpWord/Writer/ODText.php | 2 +- src/PhpWord/Writer/ODText/Element/Element.php | 2 +- src/PhpWord/Writer/ODText/Element/Image.php | 2 +- src/PhpWord/Writer/ODText/Element/Link.php | 2 +- src/PhpWord/Writer/ODText/Element/Table.php | 2 +- src/PhpWord/Writer/ODText/Element/Text.php | 2 +- .../Writer/ODText/Element/TextBreak.php | 2 +- src/PhpWord/Writer/ODText/Element/TextRun.php | 2 +- .../Writer/ODText/Part/AbstractPart.php | 2 +- src/PhpWord/Writer/ODText/Part/Content.php | 2 +- src/PhpWord/Writer/ODText/Part/Manifest.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 2 +- src/PhpWord/Writer/ODText/Part/Mimetype.php | 2 +- src/PhpWord/Writer/ODText/Part/Styles.php | 2 +- .../Writer/ODText/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/ODText/Style/Font.php | 2 +- src/PhpWord/Writer/ODText/Style/Paragraph.php | 2 +- src/PhpWord/Writer/PDF.php | 2 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 2 +- src/PhpWord/Writer/PDF/DomPDF.php | 2 +- src/PhpWord/Writer/RTF.php | 2 +- src/PhpWord/Writer/RTF/Element/Element.php | 2 +- src/PhpWord/Writer/RTF/Element/Text.php | 2 +- src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 2 +- src/PhpWord/Writer/RTF/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007.php | 2 +- .../Writer/Word2007/Element/CheckBox.php | 2 +- .../Writer/Word2007/Element/Element.php | 2 +- .../Writer/Word2007/Element/Endnote.php | 2 +- .../Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Image.php | 2 +- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- .../Writer/Word2007/Element/ListItem.php | 2 +- src/PhpWord/Writer/Word2007/Element/Note.php | 2 +- .../Writer/Word2007/Element/Object.php | 2 +- .../Writer/Word2007/Element/PageBreak.php | 2 +- .../Writer/Word2007/Element/PreserveText.php | 2 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 2 +- src/PhpWord/Writer/Word2007/Element/Text.php | 2 +- .../Writer/Word2007/Element/TextBreak.php | 2 +- .../Writer/Word2007/Element/TextRun.php | 2 +- src/PhpWord/Writer/Word2007/Element/Title.php | 2 +- .../Writer/Word2007/Part/AbstractPart.php | 2 +- .../Writer/Word2007/Part/ContentTypes.php | 2 +- src/PhpWord/Writer/Word2007/Part/DocProps.php | 2 +- src/PhpWord/Writer/Word2007/Part/Document.php | 2 +- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 2 +- .../Writer/Word2007/Part/FontTable.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 2 +- .../Writer/Word2007/Part/Footnotes.php | 2 +- src/PhpWord/Writer/Word2007/Part/Header.php | 2 +- .../Writer/Word2007/Part/Numbering.php | 2 +- src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 2 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 2 +- src/PhpWord/Writer/Word2007/Part/Theme.php | 2 +- .../Writer/Word2007/Part/WebSettings.php | 2 +- .../Writer/Word2007/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 2 +- src/PhpWord/Writer/Word2007/Style/Font.php | 2 +- .../Writer/Word2007/Style/Indentation.php | 2 +- .../Writer/Word2007/Style/LineNumbering.php | 2 +- .../Writer/Word2007/Style/MarginBorder.php | 2 +- .../Writer/Word2007/Style/Paragraph.php | 2 +- src/PhpWord/Writer/Word2007/Style/Section.php | 2 +- src/PhpWord/Writer/Word2007/Style/Shading.php | 2 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 2 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 2 +- src/PhpWord/Writer/WriterInterface.php | 2 +- tests/PhpWord/Tests/AutoloaderTest.php | 2 +- .../PhpWord/Tests/DocumentPropertiesTest.php | 2 +- .../Tests/Element/AbstractElementTest.php | 2 +- tests/PhpWord/Tests/Element/CellTest.php | 2 +- tests/PhpWord/Tests/Element/CheckBoxTest.php | 2 +- tests/PhpWord/Tests/Element/FooterTest.php | 2 +- tests/PhpWord/Tests/Element/FootnoteTest.php | 2 +- tests/PhpWord/Tests/Element/HeaderTest.php | 2 +- tests/PhpWord/Tests/Element/ImageTest.php | 2 +- tests/PhpWord/Tests/Element/LinkTest.php | 2 +- tests/PhpWord/Tests/Element/ListItemTest.php | 2 +- tests/PhpWord/Tests/Element/ObjectTest.php | 2 +- tests/PhpWord/Tests/Element/PageBreakTest.php | 2 +- .../Tests/Element/PreserveTextTest.php | 2 +- tests/PhpWord/Tests/Element/RowTest.php | 2 +- tests/PhpWord/Tests/Element/SectionTest.php | 2 +- tests/PhpWord/Tests/Element/TOCTest.php | 2 +- tests/PhpWord/Tests/Element/TableTest.php | 2 +- tests/PhpWord/Tests/Element/TextBreakTest.php | 2 +- tests/PhpWord/Tests/Element/TextRunTest.php | 2 +- tests/PhpWord/Tests/Element/TextTest.php | 2 +- tests/PhpWord/Tests/Element/TitleTest.php | 2 +- tests/PhpWord/Tests/EndnotesTest.php | 2 +- .../PhpWord/Tests/Exception/ExceptionTest.php | 2 +- .../Exception/InvalidImageExceptionTest.php | 2 +- .../Exception/InvalidStyleExceptionTest.php | 2 +- .../UnsupportedImageTypeExceptionTest.php | 2 +- tests/PhpWord/Tests/FootnotesTest.php | 2 +- tests/PhpWord/Tests/IOFactoryTest.php | 2 +- tests/PhpWord/Tests/MediaTest.php | 2 +- tests/PhpWord/Tests/PhpWordTest.php | 2 +- tests/PhpWord/Tests/Reader/ODTextTest.php | 2 +- tests/PhpWord/Tests/Reader/Word2007Test.php | 2 +- tests/PhpWord/Tests/SettingsTest.php | 2 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- tests/PhpWord/Tests/Shared/FontTest.php | 2 +- tests/PhpWord/Tests/Shared/StringTest.php | 2 +- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 2 +- tests/PhpWord/Tests/Shared/ZipArchiveTest.php | 2 +- .../PhpWord/Tests/Style/AbstractStyleTest.php | 2 +- tests/PhpWord/Tests/Style/CellTest.php | 2 +- tests/PhpWord/Tests/Style/FontTest.php | 2 +- tests/PhpWord/Tests/Style/ImageTest.php | 2 +- tests/PhpWord/Tests/Style/ListItemTest.php | 2 +- .../Tests/Style/NumberingLevelTest.php | 2 +- tests/PhpWord/Tests/Style/ParagraphTest.php | 2 +- tests/PhpWord/Tests/Style/RowTest.php | 2 +- tests/PhpWord/Tests/Style/SectionTest.php | 2 +- tests/PhpWord/Tests/Style/TOCTest.php | 2 +- tests/PhpWord/Tests/Style/TableTest.php | 2 +- tests/PhpWord/Tests/Style/TabsTest.php | 2 +- tests/PhpWord/Tests/StyleTest.php | 2 +- tests/PhpWord/Tests/TOCTest.php | 2 +- tests/PhpWord/Tests/TemplateTest.php | 2 +- tests/PhpWord/Tests/Writer/HTMLTest.php | 2 +- .../Writer/ODText/Part/AbstractPartTest.php | 2 +- .../Tests/Writer/ODText/Part/ContentTest.php | 2 +- .../Tests/Writer/ODText/Part/MetaTest.php | 2 +- .../Tests/Writer/ODText/Part/StylesTest.php | 2 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 2 +- tests/PhpWord/Tests/Writer/PDFTest.php | 2 +- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- .../Writer/Word2007/Part/AbstractPartTest.php | 2 +- .../Writer/Word2007/Part/DocPropsTest.php | 2 +- .../Writer/Word2007/Part/DocumentTest.php | 2 +- .../Tests/Writer/Word2007/Part/FooterTest.php | 2 +- .../Writer/Word2007/Part/FootnotesTest.php | 2 +- .../Tests/Writer/Word2007/Part/HeaderTest.php | 2 +- .../Writer/Word2007/Part/NumberingTest.php | 2 +- .../Tests/Writer/Word2007/Part/StylesTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- .../Tests/_includes/TestHelperDOCX.php | 2 +- tests/PhpWord/Tests/_includes/XmlDocument.php | 2 +- tests/bootstrap.php | 2 +- 249 files changed, 997 insertions(+), 588 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e23edf9132..57c1b7000c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,27 @@ This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub. -## 0.10.0 - Not yet released +## 0.11.0 - Not yet released + +PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release. + +### Features + +- + +### Bugfixes + +- + +### Deprecated + +- + +### Miscellaneous + +- License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211 + +## 0.10.0 - 4 May 2014 This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled. Basic ODText reader is introduced. diff --git a/LICENSE.md b/LICENSE.md index 57b74d4c74..a4343e8e41 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,345 +1,734 @@ -GNU LESSER GENERAL PUBLIC LICENSE - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the +# PHPWord License + +PHPWord, a pure PHP library for reading and writing word processing documents + +Copyright (c) 2014 PHPWord + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . + +## GNU LESSER GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with +## GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - -NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - -END OF TERMS AND CONDITIONS \ No newline at end of file +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. diff --git a/composer.json b/composer.json index fafa9a28c0..aeb38b7daf 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "homepage": "http://phpoffice.github.io", "type": "library", - "license": "LGPL-2.1+", + "license": "LGPL", "authors": [ { "name": "Mark Baker" diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index 5bb331abb0..ddbbf36b3e 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 137162e777..7978b22d95 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 8af70d421d..9972749974 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 6e993748ea..8bc0cbbd96 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index e3d3dd0688..de1de0ff61 100644 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index f273c128d4..9344ad0b2f 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php index 07d219690e..49c52d0317 100644 --- a/src/PhpWord/Element/Endnote.php +++ b/src/PhpWord/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 50ec823606..1df69c29f0 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index bb8d617000..ba6442f086 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index 2c963d84ea..f642f13b43 100644 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 53becbbfc3..19f4e5c4b3 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 31b06c68aa..9358fac610 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 660615375e..72452b1d57 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 7407688a81..d1c8fe351e 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php index d2f85f2083..64cf2f678c 100644 --- a/src/PhpWord/Element/PageBreak.php +++ b/src/PhpWord/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index ac7d1f52e4..68c15cc265 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index dc4b8a4430..21481a540e 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 64e226ab58..e456f68f4d 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index ac48a49d40..31a81db1ef 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 1fa729e172..041f3c3e2e 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index 96e0e164e9..f0ade0e174 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index b80ff6812b..3af7d2c9f3 100644 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index a8428d1e0a..9b1b891921 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 93b48d626c..89774d2927 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Endnotes.php b/src/PhpWord/Endnotes.php index 6587dfe946..7fda82b3d7 100644 --- a/src/PhpWord/Endnotes.php +++ b/src/PhpWord/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Exception/Exception.php b/src/PhpWord/Exception/Exception.php index 470698a825..36346f7555 100644 --- a/src/PhpWord/Exception/Exception.php +++ b/src/PhpWord/Exception/Exception.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidImageException.php b/src/PhpWord/Exception/InvalidImageException.php index c8d2143cfb..3a236dec92 100644 --- a/src/PhpWord/Exception/InvalidImageException.php +++ b/src/PhpWord/Exception/InvalidImageException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidObjectException.php b/src/PhpWord/Exception/InvalidObjectException.php index b27de805d3..f66d0e86f9 100644 --- a/src/PhpWord/Exception/InvalidObjectException.php +++ b/src/PhpWord/Exception/InvalidObjectException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidStyleException.php b/src/PhpWord/Exception/InvalidStyleException.php index 37290e63fb..630bd3a7cf 100644 --- a/src/PhpWord/Exception/InvalidStyleException.php +++ b/src/PhpWord/Exception/InvalidStyleException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/UnsupportedImageTypeException.php b/src/PhpWord/Exception/UnsupportedImageTypeException.php index 2b1a25ce1a..d4bd82c4f4 100644 --- a/src/PhpWord/Exception/UnsupportedImageTypeException.php +++ b/src/PhpWord/Exception/UnsupportedImageTypeException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Footnotes.php b/src/PhpWord/Footnotes.php index a0a5c42ff9..d25699bc08 100644 --- a/src/PhpWord/Footnotes.php +++ b/src/PhpWord/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index f28ef08890..daa1eca3dc 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 7d129b866b..bad8dd64e6 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index d4b1335676..fc87f7efd9 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 424ff2cd9b..a9627a0a9c 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index db4708b47b..247c3d33a3 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 15c6719080..84f5b3bf11 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\ODText; diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index c0bb49c68c..6cefac715f 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\ODText; diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php index 2829d4abb3..2baee55fdd 100644 --- a/src/PhpWord/Reader/ReaderInterface.php +++ b/src/PhpWord/Reader/ReaderInterface.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 759166d1e1..d466d41998 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 57ad4815dc..8c83c13e5e 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocProps.php b/src/PhpWord/Reader/Word2007/DocProps.php index 2c76417aad..443e5d6470 100644 --- a/src/PhpWord/Reader/Word2007/DocProps.php +++ b/src/PhpWord/Reader/Word2007/DocProps.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php index 7797528aec..5d0ebbca00 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsApp.php +++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index fd943875ed..60a1ee7014 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 6c67dc7a64..9f33ddb50c 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 21b28f4521..562094cdec 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php index 235dab4b55..48b098a5ba 100644 --- a/src/PhpWord/Reader/Word2007/Endnotes.php +++ b/src/PhpWord/Reader/Word2007/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index 01a837eb13..4d9aca50ae 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php index bdb0b9e8b5..3981abb11c 100644 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ b/src/PhpWord/Reader/Word2007/Notes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index 5cd3f7ae06..946d260c6c 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index afc4f9c07b..24165938c7 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index bd18df4857..d8df5d21cd 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 58a6ee1a9c..42a334f04b 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php index f5317abbf4..2317676ce8 100644 --- a/src/PhpWord/Shared/Font.php +++ b/src/PhpWord/Shared/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 95f75f13d7..7fa59b3f21 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index b7f5549e69..c7baf02753 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 53f5e893d4..e51dd636df 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 2da7573cbe..0bc5ae1405 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 85743a224c..2ff500c4a6 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index c498575af5..e4dd3082ba 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index 1323086349..2ba912bb2d 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index d7597e0e5b..9a60946ab8 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 86467d026a..964df35632 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index f21e667408..1e21934e06 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php index bda2c9ad2f..e2783ea6e9 100644 --- a/src/PhpWord/Style/Indentation.php +++ b/src/PhpWord/Style/Indentation.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php index 384d5d42b3..3caf0b6974 100644 --- a/src/PhpWord/Style/LineNumbering.php +++ b/src/PhpWord/Style/LineNumbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index a4f4933d52..9c951656c3 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php index 8c2e4a69d8..67cc48217d 100644 --- a/src/PhpWord/Style/Numbering.php +++ b/src/PhpWord/Style/Numbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index dff7de22d7..f292c9356f 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index b6f482bf5e..3a0defeed6 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index e2a07b85fc..b9804e2844 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index e109526fb3..84e9397c17 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php index fee66a080f..5081589589 100644 --- a/src/PhpWord/Style/Shading.php +++ b/src/PhpWord/Style/Shading.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index db173061a2..07bcde48ab 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index e8a781b00f..14c46aadf8 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index dfcb3b95de..011e24770d 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c4ec8b6831..f1bebe20e0 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php index ea75c10de5..f760f278e2 100644 --- a/src/PhpWord/TOC.php +++ b/src/PhpWord/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index a8a221d766..53c7efa43a 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 0d713bc532..c4e2cc5dcd 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index d4b8adb392..1f1fefa835 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index 434760f935..79ace1e861 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php index 66efcf4da9..95e93f6bec 100644 --- a/src/PhpWord/Writer/HTML/Element/Endnote.php +++ b/src/PhpWord/Writer/HTML/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index 5fdc55a221..f93072eb10 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 660e6204f4..442ee4e5c8 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 1680edfc86..36053f9499 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index f8aa607304..baf2e26128 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Note.php b/src/PhpWord/Writer/HTML/Element/Note.php index cac84cbeb9..d195a11d6d 100644 --- a/src/PhpWord/Writer/HTML/Element/Note.php +++ b/src/PhpWord/Writer/HTML/Element/Note.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index b05e43cab0..fa52d8ab14 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index c0b3989cc8..d635fc3322 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 56839c3495..e434c485d4 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php index ed8f9f71f7..26689cf77c 100644 --- a/src/PhpWord/Writer/HTML/Element/TextBreak.php +++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index 712c1b3376..17ec57f2b9 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 1395afeded..947539bf49 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index eeb0a7676a..c332ba5ad9 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 73ae14c134..9a9d05c4c4 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php index 841f20d8c1..c8fcbc4991 100644 --- a/src/PhpWord/Writer/HTML/Style/Generic.php +++ b/src/PhpWord/Writer/HTML/Style/Generic.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index fb59b60d80..9e7fa9d5c7 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index dd025ee235..60e864a844 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index 0eb6c5452e..77cd166bbd 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/ODText/Element/Element.php b/src/PhpWord/Writer/ODText/Element/Element.php index 67ee9c2023..60163150c3 100644 --- a/src/PhpWord/Writer/ODText/Element/Element.php +++ b/src/PhpWord/Writer/ODText/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index d096a03b4f..a115bb1691 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 08235519a9..2553e51efc 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 7972eb3792..9199f83246 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 63ce7b6853..17286a337f 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/TextBreak.php b/src/PhpWord/Writer/ODText/Element/TextBreak.php index ce342399ed..96a355bd49 100644 --- a/src/PhpWord/Writer/ODText/Element/TextBreak.php +++ b/src/PhpWord/Writer/ODText/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php index f97d9c8c7b..4ac659c1c4 100644 --- a/src/PhpWord/Writer/ODText/Element/TextRun.php +++ b/src/PhpWord/Writer/ODText/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index 4aa5d79f9f..64ab52ee73 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index fbeb6982bd..408a69bd24 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php index 4462e7ef62..0ecba936d3 100644 --- a/src/PhpWord/Writer/ODText/Part/Manifest.php +++ b/src/PhpWord/Writer/ODText/Part/Manifest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index 355e288ba7..b4999f95c8 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php index 3c3af1a502..75c2bb1fab 100644 --- a/src/PhpWord/Writer/ODText/Part/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index f53e1bf835..1f1a525f1c 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php index 30416b5dcd..3436490ca2 100644 --- a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Style; diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 822e8a9051..ec0334453a 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Style; diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index 7bd490c3eb..9b5da1fbf4 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\ODText\Style; diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index 7421e3e43d..574a6ce006 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index 860a29dc08..0a11b78819 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\PDF; diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index d4c7b5f834..02547925bf 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\PDF; diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index dca6bc1f0b..893ba72da5 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index 9bb3b5d993..0beaa0ba23 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 2ee110e006..aecbc889d1 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index 91ae706db4..ca177f9382 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 86c30f4b45..228833a828 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 61a400329b..440c034b85 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index b87f1d2441..3f4626e026 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 12b28cf928..a4a4332943 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/Element.php index 9c91beb781..a2b1968d62 100644 --- a/src/PhpWord/Writer/Word2007/Element/Element.php +++ b/src/PhpWord/Writer/Word2007/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Endnote.php b/src/PhpWord/Writer/Word2007/Element/Endnote.php index fbdf7a7590..e72fa9369c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Endnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 20360ebc10..a82d1d47ce 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index e944b7af53..1e958df28c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index e9cdad9105..7d7c4a0d79 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index d020fe6f96..5c4b64a584 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Note.php b/src/PhpWord/Writer/Word2007/Element/Note.php index 1ba73de82c..0fe1349e71 100644 --- a/src/PhpWord/Writer/Word2007/Element/Note.php +++ b/src/PhpWord/Writer/Word2007/Element/Note.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index 1a2dfa4a7d..8ed84dae76 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index a6cdd27f55..602bc23051 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index 72ff7f1bfa..e6eab9709a 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 5be287a39b..af173c3776 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index c538561abd..7a6d3bf2be 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 99ad4953aa..96e58ef826 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 008e1e12a1..9ccaf79c9d 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index f23ef693e4..cbe1c33f6a 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 5570921f52..d6adc20cfe 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index afa84caf8f..4a0c442e20 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 00e05c7619..273a965a34 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/DocProps.php b/src/PhpWord/Writer/Word2007/Part/DocProps.php index ade15c0afd..df00e74373 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocProps.php +++ b/src/PhpWord/Writer/Word2007/Part/DocProps.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 535784b82d..3022f7e72e 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php index 9cecf4028d..866378abe1 100644 --- a/src/PhpWord/Writer/Word2007/Part/Endnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php index 9493dc0731..b5c8d44b4e 100644 --- a/src/PhpWord/Writer/Word2007/Part/FontTable.php +++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index f31ece860c..d09baf7e76 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 2356849e07..ced2ba39be 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php index d2af19da29..39057609be 100644 --- a/src/PhpWord/Writer/Word2007/Part/Header.php +++ b/src/PhpWord/Writer/Word2007/Part/Header.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index ea1b699bf6..88684b713f 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 8771b0f6ab..9b9af81a23 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index 81a5967929..e0d561c632 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 579ae8e5c8..4358f9f5d4 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Theme.php b/src/PhpWord/Writer/Word2007/Part/Theme.php index 2e0b4c9911..8ae230643b 100644 --- a/src/PhpWord/Writer/Word2007/Part/Theme.php +++ b/src/PhpWord/Writer/Word2007/Part/Theme.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php index b1b5cc15cb..17bfcc8ece 100644 --- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php +++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 9b2d7ffd1b..b1a7ce380a 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index d33eed564c..6b5fe6b575 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 6ffc6a8707..def9cac47a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index c31cdebf36..8049933fc1 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index 6167e329fa..8ab987c518 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index ef6992dbc1..7f286492a3 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index b92e171423..eeb0f0d647 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index e00a32261d..9d735da158 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index 3d83193568..998162b611 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index 94f02a3c93..f73c37c759 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index 403c6173da..bbaeddaf4c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 00bda8a422..28afb17acd 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/WriterInterface.php b/src/PhpWord/Writer/WriterInterface.php index 2c225b2c6f..50335c3acd 100644 --- a/src/PhpWord/Writer/WriterInterface.php +++ b/src/PhpWord/Writer/WriterInterface.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Writer; diff --git a/tests/PhpWord/Tests/AutoloaderTest.php b/tests/PhpWord/Tests/AutoloaderTest.php index 2a021aebed..0bf71ce27d 100644 --- a/tests/PhpWord/Tests/AutoloaderTest.php +++ b/tests/PhpWord/Tests/AutoloaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/DocumentPropertiesTest.php b/tests/PhpWord/Tests/DocumentPropertiesTest.php index 207eb195d6..78d26da5ba 100644 --- a/tests/PhpWord/Tests/DocumentPropertiesTest.php +++ b/tests/PhpWord/Tests/DocumentPropertiesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Element/AbstractElementTest.php b/tests/PhpWord/Tests/Element/AbstractElementTest.php index 8dbfb5b315..0df09abb0f 100644 --- a/tests/PhpWord/Tests/Element/AbstractElementTest.php +++ b/tests/PhpWord/Tests/Element/AbstractElementTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index 3a2c33429c..c2ce43d6d6 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/CheckBoxTest.php b/tests/PhpWord/Tests/Element/CheckBoxTest.php index e461161843..66580195c4 100644 --- a/tests/PhpWord/Tests/Element/CheckBoxTest.php +++ b/tests/PhpWord/Tests/Element/CheckBoxTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/FooterTest.php b/tests/PhpWord/Tests/Element/FooterTest.php index d4201149db..02e42942e9 100644 --- a/tests/PhpWord/Tests/Element/FooterTest.php +++ b/tests/PhpWord/Tests/Element/FooterTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/FootnoteTest.php b/tests/PhpWord/Tests/Element/FootnoteTest.php index c2571afe03..3197bbee8d 100644 --- a/tests/PhpWord/Tests/Element/FootnoteTest.php +++ b/tests/PhpWord/Tests/Element/FootnoteTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/HeaderTest.php b/tests/PhpWord/Tests/Element/HeaderTest.php index 849dd220bc..6297ba6501 100644 --- a/tests/PhpWord/Tests/Element/HeaderTest.php +++ b/tests/PhpWord/Tests/Element/HeaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index eb4823980a..5dfbc2dee5 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/LinkTest.php b/tests/PhpWord/Tests/Element/LinkTest.php index 3840ede886..c0e038ff1b 100644 --- a/tests/PhpWord/Tests/Element/LinkTest.php +++ b/tests/PhpWord/Tests/Element/LinkTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ListItemTest.php b/tests/PhpWord/Tests/Element/ListItemTest.php index 6526f57158..4b88cdf170 100644 --- a/tests/PhpWord/Tests/Element/ListItemTest.php +++ b/tests/PhpWord/Tests/Element/ListItemTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ObjectTest.php b/tests/PhpWord/Tests/Element/ObjectTest.php index 0f5f191a2a..69b11e478d 100644 --- a/tests/PhpWord/Tests/Element/ObjectTest.php +++ b/tests/PhpWord/Tests/Element/ObjectTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/PageBreakTest.php b/tests/PhpWord/Tests/Element/PageBreakTest.php index 0c6379f5d3..a2e690cded 100644 --- a/tests/PhpWord/Tests/Element/PageBreakTest.php +++ b/tests/PhpWord/Tests/Element/PageBreakTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/PreserveTextTest.php b/tests/PhpWord/Tests/Element/PreserveTextTest.php index 16d4361d36..29195e848d 100644 --- a/tests/PhpWord/Tests/Element/PreserveTextTest.php +++ b/tests/PhpWord/Tests/Element/PreserveTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/RowTest.php b/tests/PhpWord/Tests/Element/RowTest.php index e232afa8ea..c8eb7fcefd 100644 --- a/tests/PhpWord/Tests/Element/RowTest.php +++ b/tests/PhpWord/Tests/Element/RowTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index 415e43ad20..f3fb336017 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index 207f69691a..a976720c72 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TableTest.php b/tests/PhpWord/Tests/Element/TableTest.php index 3fc51f98e7..34f25c0e7c 100644 --- a/tests/PhpWord/Tests/Element/TableTest.php +++ b/tests/PhpWord/Tests/Element/TableTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextBreakTest.php b/tests/PhpWord/Tests/Element/TextBreakTest.php index c228215ff3..0c658f9404 100644 --- a/tests/PhpWord/Tests/Element/TextBreakTest.php +++ b/tests/PhpWord/Tests/Element/TextBreakTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 0916e40b8f..9101519fc6 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextTest.php b/tests/PhpWord/Tests/Element/TextTest.php index 953dfc8fbe..746b4f5abf 100644 --- a/tests/PhpWord/Tests/Element/TextTest.php +++ b/tests/PhpWord/Tests/Element/TextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 6c472b0d9e..948d051e68 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/EndnotesTest.php b/tests/PhpWord/Tests/EndnotesTest.php index a72e85f94d..691cc5cd74 100644 --- a/tests/PhpWord/Tests/EndnotesTest.php +++ b/tests/PhpWord/Tests/EndnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Exception/ExceptionTest.php b/tests/PhpWord/Tests/Exception/ExceptionTest.php index 04eb03e0d6..b0f6c152d6 100644 --- a/tests/PhpWord/Tests/Exception/ExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/ExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php index c0dfeddab5..edc4eb2cea 100644 --- a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php index 1cc29a723c..721a48912b 100644 --- a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php index a73db59917..dc642fb4e4 100644 --- a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/FootnotesTest.php b/tests/PhpWord/Tests/FootnotesTest.php index 869c69a736..cbab6ecc3a 100644 --- a/tests/PhpWord/Tests/FootnotesTest.php +++ b/tests/PhpWord/Tests/FootnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/IOFactoryTest.php b/tests/PhpWord/Tests/IOFactoryTest.php index 405eabe0d6..6bd21c57ed 100644 --- a/tests/PhpWord/Tests/IOFactoryTest.php +++ b/tests/PhpWord/Tests/IOFactoryTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 0b98bfd29c..50806116be 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 8de6f80883..e2eef452ef 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Reader/ODTextTest.php b/tests/PhpWord/Tests/Reader/ODTextTest.php index 6136b0c483..6462148334 100644 --- a/tests/PhpWord/Tests/Reader/ODTextTest.php +++ b/tests/PhpWord/Tests/Reader/ODTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Reader; diff --git a/tests/PhpWord/Tests/Reader/Word2007Test.php b/tests/PhpWord/Tests/Reader/Word2007Test.php index 3a572f4dce..d69e6a45f9 100644 --- a/tests/PhpWord/Tests/Reader/Word2007Test.php +++ b/tests/PhpWord/Tests/Reader/Word2007Test.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Reader; diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 64a0999498..a312bae5ff 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 713cebcde9..cd85adf39f 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/FontTest.php b/tests/PhpWord/Tests/Shared/FontTest.php index f36f10741c..8183051b03 100644 --- a/tests/PhpWord/Tests/Shared/FontTest.php +++ b/tests/PhpWord/Tests/Shared/FontTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/StringTest.php b/tests/PhpWord/Tests/Shared/StringTest.php index 02b4898a39..6b00313193 100644 --- a/tests/PhpWord/Tests/Shared/StringTest.php +++ b/tests/PhpWord/Tests/Shared/StringTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/XMLReaderTest.php b/tests/PhpWord/Tests/Shared/XMLReaderTest.php index 759bf58020..5cc96523c0 100644 --- a/tests/PhpWord/Tests/Shared/XMLReaderTest.php +++ b/tests/PhpWord/Tests/Shared/XMLReaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php index 2e45fcf87d..d6a76995f4 100644 --- a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php +++ b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Style/AbstractStyleTest.php b/tests/PhpWord/Tests/Style/AbstractStyleTest.php index ae11c27cf9..ea72528d80 100644 --- a/tests/PhpWord/Tests/Style/AbstractStyleTest.php +++ b/tests/PhpWord/Tests/Style/AbstractStyleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index 5e3d959d1c..3838a36eea 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 9185d64649..552c197fe7 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ImageTest.php b/tests/PhpWord/Tests/Style/ImageTest.php index fd74d73cd7..868d6c94bb 100644 --- a/tests/PhpWord/Tests/Style/ImageTest.php +++ b/tests/PhpWord/Tests/Style/ImageTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ListItemTest.php b/tests/PhpWord/Tests/Style/ListItemTest.php index 6eef720c57..577aacdcc2 100644 --- a/tests/PhpWord/Tests/Style/ListItemTest.php +++ b/tests/PhpWord/Tests/Style/ListItemTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/NumberingLevelTest.php b/tests/PhpWord/Tests/Style/NumberingLevelTest.php index f3e28a0e56..5ffdf83e0f 100644 --- a/tests/PhpWord/Tests/Style/NumberingLevelTest.php +++ b/tests/PhpWord/Tests/Style/NumberingLevelTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 690e34e138..c9d0794ff3 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/RowTest.php b/tests/PhpWord/Tests/Style/RowTest.php index ad193f80dc..a8355a90f6 100644 --- a/tests/PhpWord/Tests/Style/RowTest.php +++ b/tests/PhpWord/Tests/Style/RowTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index a268c7fceb..90ea811bc4 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index 2c10de8def..49bd5e680f 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index e5c3ab6625..77733271a4 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TabsTest.php b/tests/PhpWord/Tests/Style/TabsTest.php index 26ee41d0fe..08fabab324 100644 --- a/tests/PhpWord/Tests/Style/TabsTest.php +++ b/tests/PhpWord/Tests/Style/TabsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index 4ace72b6f0..05d655ac5a 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/TOCTest.php b/tests/PhpWord/Tests/TOCTest.php index d0b73352ad..4dd6a79a58 100644 --- a/tests/PhpWord/Tests/TOCTest.php +++ b/tests/PhpWord/Tests/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/TemplateTest.php b/tests/PhpWord/Tests/TemplateTest.php index f99ce2946e..220c91b947 100644 --- a/tests/PhpWord/Tests/TemplateTest.php +++ b/tests/PhpWord/Tests/TemplateTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 265c4f6bd0..06cd44bfc1 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php index bde6b4136a..f4c5cdb149 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index ebbfe470b6..242eea8e03 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php index fde045793f..71b28abf67 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php index 556bc80473..18b162dd58 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Part\ODText; diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index b02c3f9f19..4e26d6c63b 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php index 3282eecbdf..d8d941e754 100644 --- a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\PDF; diff --git a/tests/PhpWord/Tests/Writer/PDFTest.php b/tests/PhpWord/Tests/Writer/PDFTest.php index fba930549c..797765795a 100644 --- a/tests/PhpWord/Tests/Writer/PDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index 9cc7ed717a..9d07300887 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php index 81786b145a..18c908864a 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php index e6db4bf53a..5d765c1b43 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 0cc4895d1a..9597e772e8 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php index 513d4d2c20..9cb9eeb242 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php index 3f9aaae7e9..9a80c7801c 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php index c3ca6b6bb6..704f34968a 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php index 8d76f016d0..7e4a59258d 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php index 42c32bbca2..440165e2b7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 74f3b1fda0..924e3e3149 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index bea0d03740..84438e234d 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/_includes/XmlDocument.php b/tests/PhpWord/Tests/_includes/XmlDocument.php index a08227ba58..5e649385b5 100644 --- a/tests/PhpWord/Tests/_includes/XmlDocument.php +++ b/tests/PhpWord/Tests/_includes/XmlDocument.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index eb23221ede..e3dc8efc76 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ date_default_timezone_set('UTC'); From cbf0c07a747f91c4e27015a444cd66f182086216 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 13:24:53 +0200 Subject: [PATCH 012/167] #154 : PHPDocumentor on GH-Pages --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d6d5ddd12f..673ce067f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,9 @@ env: - secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4=" before_script: + ## Packages + - sudo apt-get -qq update > /dev/null + - sudo apt-get -qq install graphviz > /dev/null ## Composer # - curl -s http://getcomposer.org/installer | php # - php composer.phar install --prefer-source From 9aec52168fed390c2fe47af75f0c16faa37c612e Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 13:46:31 +0200 Subject: [PATCH 013/167] #154 : PHPDocumentor on GH-Pages --- .travis.yml | 3 ++- .travis_shell_after_success.sh | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 673ce067f8..713cc268df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ before_script: #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar ## PHPDocumentor - mkdir -p build/docs + - mkdir -p build/coverage script: ## PHP_CodeSniffer @@ -56,7 +57,7 @@ script: ## PHPLOC #- php phploc.phar src/ ## PHPUnit - - phpunit -c ./ --coverage-text + - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - vendor/bin/phpdoc.php -d ./src -t ./build/docs diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh index 567b1acb33..fe6c2d3129 100644 --- a/.travis_shell_after_success.sh +++ b/.travis_shell_after_success.sh @@ -10,6 +10,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == echo -e "Publishing PHPDoc...\n" cp -R build/docs $HOME/docs-latest + cp -R build/coverage $HOME/coverage-latest cd $HOME git config --global user.email "travis@travis-ci.org" @@ -21,12 +22,18 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == git rm -rf ./docs/$TRAVIS_BRANCH echo "--DEBUG : Dossier" + mkdir coverage + cd coverage + mkdir $TRAVIS_BRANCH + cd .. mkdir docs cd docs mkdir $TRAVIS_BRANCH + cd .. echo "--DEBUG : Copie" - cp -Rf $HOME/docs-latest/* ./$TRAVIS_BRANCH/ + cp -Rf $HOME/docs-latest/* ./docs/$TRAVIS_BRANCH/ + cp -Rf $HOME/coverage-latest/* ./coverage/$TRAVIS_BRANCH/ echo "--DEBUG : Git" git add -f . From 06462fbac5eb0adc3d71995f323af41423615963 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sun, 4 May 2014 16:00:37 +0200 Subject: [PATCH 014/167] #154 : PHPDocumentor on GH-Pages --- .travis_shell_after_success.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh index fe6c2d3129..308388d7f5 100644 --- a/.travis_shell_after_success.sh +++ b/.travis_shell_after_success.sh @@ -22,14 +22,8 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == git rm -rf ./docs/$TRAVIS_BRANCH echo "--DEBUG : Dossier" - mkdir coverage - cd coverage - mkdir $TRAVIS_BRANCH - cd .. - mkdir docs - cd docs - mkdir $TRAVIS_BRANCH - cd .. + mkdir -p docs/$TRAVIS_BRANCH + mkdir -p coverage/$TRAVIS_BRANCH echo "--DEBUG : Copie" cp -Rf $HOME/docs-latest/* ./docs/$TRAVIS_BRANCH/ From 42c712e334a25f0893f74a9f5562c288d12132ff Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 21:16:12 +0700 Subject: [PATCH 015/167] Refactor new image styles and create `Word2007/Style/Image` class --- CHANGELOG.md | 9 +- samples/Sample_13_Images.php | 2 +- src/PhpWord/Style/Image.php | 349 ++++++++---------- src/PhpWord/Writer/Word2007/Element/Image.php | 87 +---- src/PhpWord/Writer/Word2007/Style/Image.php | 140 +++++++ 5 files changed, 316 insertions(+), 271 deletions(-) create mode 100644 src/PhpWord/Writer/Word2007/Style/Image.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c1b7000c..ff717ebb0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,19 +8,16 @@ PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release. ### Features -- +- Image: Ability to define relative and absolute positioning - @basjan GH-217 ### Bugfixes -- - -### Deprecated - -- +- ... ### Miscellaneous - License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211 +- Word2007 Writer: New `Style\Image` class - @ivanlanin ## 0.10.0 - 4 May 2014 diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 65e38bf5d0..784230650d 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -26,7 +26,7 @@ foreach ($wrappingStyles as $wrappingStyle) { $section->addTextBreak(5); $section->addText('Wrapping style ' . $wrappingStyle); - $section->addImage('resources/_earth.jpg', array('marginTop' => -1, 'marginLeft' => 1, + $section->addImage('resources/_earth.jpg', array('positioning' => 'relative', 'marginTop' => -1, 'marginLeft' => 1, 'width' => 80, 'height' => 80, 'wrappingStyle' => $wrappingStyle)); $section->addText($text); } diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index cece4407cf..b258fa08a0 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -14,66 +14,61 @@ */ class Image extends AbstractStyle { - + /** + * Wrapping styles + * + * @const string + */ const WRAPPING_STYLE_INLINE = 'inline'; - const WRAPPING_STYLE_SQUARE = 'square'; - const WRAPPING_STYLE_TIGHT = 'tight'; - const WRAPPING_STYLE_BEHIND = 'behind'; - const WRAPPING_STYLE_INFRONT = 'infront'; + /** + * Horizontal alignment + * + * @const string + */ const POSITION_HORIZONTAL_LEFT = 'left'; - const POSITION_HORIZONTAL_CENTER = 'centered'; - const POSITION_HORIZONTAL_RIGHT = 'right'; + /** + * Vertical alignment + * + * @const string + */ const POSITION_VERTICAL_TOP = 'top'; - const POSITION_VERTICAL_CENTER = 'center'; - const POSITION_VERTICAL_BOTTOM = 'bottom'; - const POSITION_VERTICAL_INSIDE = 'inside'; - const POSITION_VERTICAL_OUTSIDE = 'outside'; - const POSITION_HORIZONTAL_RELATIVE_MARGIN = 'margin'; - - const POSITION_HORIZONTAL_RELATIVE_PAGE = 'page'; - - const POSITION_HORIZONTAL_RELATIVE_COLUMN = 'column'; - - const POSITION_HORIZONTAL_RELATIVE_CHAR = 'char'; - - const POSITION_HORIZONTAL_RELATIVE_LMARGIN = 'left-margin-area'; - - const POSITION_HORIZONTAL_RELATIVE_RMARGIN = 'right-margin-area'; - - const POSITION_HORIZONTAL_RELATIVE_IMARGIN = 'inner-margin-area'; - - const POSITION_HORIZONTAL_RELATIVE_OMARGIN = 'outer-margin-area'; - - const POSITION_VERTICAL_RELATIVE_MARGIN = 'margin'; - - const POSITION_VERTICAL_RELATIVE_PAGE = 'page'; - - const POSITION_VERTICAL_RELATIVE_LINE = 'line'; - - const POSITION_VERTICAL_RELATIVE_TMARGIN = 'top-margin-area'; - - const POSITION_VERTICAL_RELATIVE_BMARGIN = 'bottom-margin-area'; - - const POSITION_VERTICAL_RELATIVE_IMARGIN = 'inner-margin-area'; - - const POSITION_VERTICAL_RELATIVE_OMARGIN = 'outer-margin-area'; - - const POSITION_RELATIVE = 'relative'; - + /** + * Position relative to + * + * @const string + */ + const POSITION_RELATIVE_TO_MARGIN = 'margin'; + const POSITION_RELATIVE_TO_PAGE = 'page'; + const POSITION_RELATIVE_TO_COLUMN = 'column'; // horizontal only + const POSITION_RELATIVE_TO_CHAR = 'char'; // horizontal only + const POSITION_RELATIVE_TO_LINE = 'line'; // vertical only + const POSITION_RELATIVE_TO_LMARGIN = 'left-margin-area'; // horizontal only + const POSITION_RELATIVE_TO_RMARGIN = 'right-margin-area'; // horizontal only + const POSITION_RELATIVE_TO_TMARGIN = 'top-margin-area'; // vertical only + const POSITION_RELATIVE_TO_BMARGIN = 'bottom-margin-area'; // vertical only + const POSITION_RELATIVE_TO_IMARGIN = 'inner-margin-area'; + const POSITION_RELATIVE_TO_OMARGIN = 'outer-margin-area'; + + /** + * Position type, relative/absolute + * + * @const string + */ const POSITION_ABSOLUTE = 'absolute'; + const POSITION_RELATIVE = 'relative'; /** * Image width @@ -117,6 +112,13 @@ class Image extends AbstractStyle */ private $wrappingStyle; + /** + * Positioning type (relative or absolute) + * + * @var string + */ + private $positioning; + /** * Horizontal alignment * @@ -145,29 +147,16 @@ class Image extends AbstractStyle */ private $posVerticalRel; - /** - * Positioning type (Relative or Absolute) - * - * @var string - */ - private $positioning; - /** * Create new image style */ public function __construct() { - $this->width = null; - $this->height = null; - $this->align = null; - $this->marginTop = null; - $this->marginLeft = null; - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - $this->setPositioning(self::POSITION_RELATIVE); - $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); - $this->setPosHorizontalRel(self::POSITION_HORIZONTAL_RELATIVE_CHAR); - $this->setPosVertical(self::POSITION_VERTICAL_TOP); - $this->setPosVerticalRel(self::POSITION_VERTICAL_RELATIVE_LINE); + $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); + $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); + $this->setPosHorizontalRel(self::POSITION_RELATIVE_TO_CHAR); + $this->setPosVertical(self::POSITION_VERTICAL_TOP); + $this->setPosVerticalRel(self::POSITION_RELATIVE_TO_LINE); } /** @@ -175,17 +164,17 @@ public function __construct() */ public function getWidth() { - return $this->width; + return $this->width; } /** * Set width * - * @param int $pValue + * @param int $value */ - public function setWidth($pValue = null) + public function setWidth($value = null) { - $this->width = $pValue; + $this->width = $value; } /** @@ -193,17 +182,17 @@ public function setWidth($pValue = null) */ public function getHeight() { - return $this->height; + return $this->height; } /** * Set height * - * @param int $pValue + * @param int $value */ - public function setHeight($pValue = null) + public function setHeight($value = null) { - $this->height = $pValue; + $this->height = $value; } /** @@ -211,17 +200,17 @@ public function setHeight($pValue = null) */ public function getAlign() { - return $this->align; + return $this->align; } /** * Set alignment * - * @param string $pValue + * @param string $value */ - public function setAlign($pValue = null) + public function setAlign($value = null) { - $this->align = $pValue; + $this->align = $value; } /** @@ -231,19 +220,19 @@ public function setAlign($pValue = null) */ public function getMarginTop() { - return $this->marginTop; + return $this->marginTop; } /** * Set Margin Top * - * @param int $pValue - * @return $this + * @param int $value + * @return self */ - public function setMarginTop($pValue = null) + public function setMarginTop($value = null) { - $this->marginTop = $pValue; - return $this; + $this->marginTop = $value; + return $this; } /** @@ -253,221 +242,207 @@ public function setMarginTop($pValue = null) */ public function getMarginLeft() { - return $this->marginLeft; + return $this->marginLeft; } /** * Set Margin Left * - * @param int $pValue - * @return $this + * @param int $value + * @return self + */ + public function setMarginLeft($value = null) + { + $this->marginLeft = $value; + return $this; + } + + /** + * Get wrapping style + * + * @return string */ - public function setMarginLeft($pValue = null) + public function getWrappingStyle() { - $this->marginLeft = $pValue; - return $this; + return $this->wrappingStyle; } /** * Set wrapping style * - * @param string $wrappingStyle + * @param string $wrappingStyle * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setWrappingStyle($wrappingStyle) { - switch ($wrappingStyle) { - case self::WRAPPING_STYLE_BEHIND: - case self::WRAPPING_STYLE_INFRONT: - case self::WRAPPING_STYLE_INLINE: - case self::WRAPPING_STYLE_SQUARE: - case self::WRAPPING_STYLE_TIGHT: - $this->wrappingStyle = $wrappingStyle; - break; - default: - throw new \InvalidArgumentException('Wrapping style does not exists'); + $enum = array(self::WRAPPING_STYLE_INLINE, self::WRAPPING_STYLE_INFRONT, self::WRAPPING_STYLE_BEHIND, + self::WRAPPING_STYLE_SQUARE, self::WRAPPING_STYLE_TIGHT); + + if (in_array($wrappingStyle, $enum)) { + $this->wrappingStyle = $wrappingStyle; + } else { + throw new \InvalidArgumentException('Invalid wrapping style.'); } + return $this; } /** - * Get wrapping style + * Get positioning type * * @return string */ - public function getWrappingStyle() + public function getPositioning() { - return $this->wrappingStyle; + return $this->positioning; } /** * Set positioning type * - * @param string $positioning + * @param string $positioning * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setPositioning($positioning) { - switch ($positioning) { - case self::POSITION_RELATIVE: - case self::POSITION_ABSOLUTE: - $this->positioning = $positioning; - break; - default: - throw new InvalidArgumentException('Positioning does not exists'); - break; + $enum = array(self::POSITION_RELATIVE, self::POSITION_ABSOLUTE); + + if (in_array($positioning, $enum)) { + $this->positioning = $positioning; + } else { + throw new \InvalidArgumentException('Invalid positioning.'); } + return $this; } /** - * Get positioning type + * Get horizontal alignment * * @return string */ - public function getPositioning() + public function getPosHorizontal() { - return $this->positioning; + return $this->posHorizontal; } /** * Set horizontal alignment * - * @param string $alignment + * @param string $alignment * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setPosHorizontal($alignment) { - switch ($alignment) { - case self::POSITION_HORIZONTAL_LEFT: - case self::POSITION_HORIZONTAL_CENTER: - case self::POSITION_HORIZONTAL_RIGHT: - $this->posHorizontal = $alignment; - break; - default: - throw new InvalidArgumentException('Horizontal alignment does not exists'); - break; + $enum = array(self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, + self::POSITION_HORIZONTAL_RIGHT); + + if (in_array($alignment, $enum)) { + $this->posHorizontal = $alignment; + } else { + throw new \InvalidArgumentException('Invalid horizontal alignment.'); } + return $this; } /** - * Get horizontal alignment + * Get vertical alignment * * @return string */ - public function getPosHorizontal() + public function getPosVertical() { - return $this->posHorizontal; + return $this->posVertical; } /** * Set vertical alignment * - * @param string $alignment + * @param string $alignment * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setPosVertical($alignment) { - switch ($alignment) { - case self::POSITION_VERTICAL_TOP: - case self::POSITION_VERTICAL_CENTER: - case self::POSITION_VERTICAL_BOTTOM: - case self::POSITION_VERTICAL_INSIDE: - case self::POSITION_VERTICAL_OUTSIDE: - $this->posVertical = $alignment; - break; - default: - throw new InvalidArgumentException('Vertical alignment does not exists'); - break; + $enum = array(self::POSITION_VERTICAL_TOP, self::POSITION_VERTICAL_CENTER, + self::POSITION_VERTICAL_BOTTOM, self::POSITION_VERTICAL_INSIDE, self::POSITION_VERTICAL_OUTSIDE); + + if (in_array($alignment, $enum)) { + $this->posVertical = $alignment; + } else { + throw new \InvalidArgumentException('Invalid vertical alignment.'); } + return $this; } /** - * Get vertical alignment + * Get horizontal relation * * @return string */ - public function getPosVertical() + public function getPosHorizontalRel() { - return $this->posVertical; + return $this->posHorizontalRel; } /** * Set horizontal relation * - * @param string $relto + * @param string $relto * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setPosHorizontalRel($relto) { - switch ($relto) { - case self::POSITION_HORIZONTAL_RELATIVE_MARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_PAGE: - case self::POSITION_HORIZONTAL_RELATIVE_COLUMN: - case self::POSITION_HORIZONTAL_RELATIVE_CHAR: - case self::POSITION_HORIZONTAL_RELATIVE_LMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_RMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_IMARGIN: - case self::POSITION_HORIZONTAL_RELATIVE_OMARGIN: - $this->posHorizontalRel = $relto; - break; - default: - throw new InvalidArgumentException('Horizontal relation does not exists'); - break; + $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + self::POSITION_RELATIVE_TO_COLUMN, self::POSITION_RELATIVE_TO_CHAR, + self::POSITION_RELATIVE_TO_LMARGIN, self::POSITION_RELATIVE_TO_RMARGIN, + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); + + if (in_array($relto, $enum)) { + $this->posHorizontalRel = $relto; + } else { + throw new \InvalidArgumentException('Invalid relative horizontal alignment.'); } + return $this; } /** - * Get horizontal relation + * Get vertical relation * * @return string */ - public function getPosHorizontalRel() + public function getPosVerticalRel() { - return $this->posHorizontalRel; + return $this->posVerticalRel; } /** * Set vertical relation * - * @param string $relto + * @param string $relto * @throws \InvalidArgumentException - * @return $this + * @return self */ public function setPosVerticalRel($relto) { - switch ($relto) { - case self::POSITION_VERTICAL_RELATIVE_MARGIN: - case self::POSITION_VERTICAL_RELATIVE_PAGE: - case self::POSITION_VERTICAL_RELATIVE_LINE: - case self::POSITION_VERTICAL_RELATIVE_TMARGIN: - case self::POSITION_VERTICAL_RELATIVE_BMARGIN: - case self::POSITION_VERTICAL_RELATIVE_IMARGIN: - case self::POSITION_VERTICAL_RELATIVE_OMARGIN: - $this->posVerticalRel = $relto; - break; - default: - throw new InvalidArgumentException('Vertical relation does not exists'); - break; + $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + self::POSITION_RELATIVE_TO_LINE, + self::POSITION_RELATIVE_TO_TMARGIN, self::POSITION_RELATIVE_TO_BMARGIN, + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); + + if (in_array($relto, $enum)) { + $this->posVerticalRel = $relto; + } else { + throw new \InvalidArgumentException('Invalid relative vertical alignment.'); } - return $this; - } - /** - * Get vertical relation - * - * @return string - */ - public function getPosVerticalRel() - { - return $this->posVerticalRel; + return $this; } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 60baaadf0a..b7d24cb5f3 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -10,6 +10,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Style\Image as ImageStyle; +use PhpOffice\PhpWord\Writer\Word2007\Style\Image as ImageStyleWriter; /** * Image element writer @@ -36,86 +37,30 @@ public function write() private function writeImage() { $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); - $style = $this->element->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - $marginTop = $style->getMarginTop(); - $marginLeft = $style->getMarginLeft(); - $wrappingStyle = $style->getWrappingStyle(); - $positioning = $style->getPositioning(); - $w10wrapType = null; - $imgStyle = ''; - if (null !== $width) { - $imgStyle .= 'width:' . $width . 'px;'; - } - if (null !== $height) { - $imgStyle .= 'height:' . $height . 'px;'; - } - if (null !== $marginTop) { - $imgStyle .= 'margin-top:' . $marginTop . 'px;'; - } - if (null !== $marginLeft) { - $imgStyle .= 'margin-left:' . $marginLeft . 'px;'; - } - $imgStyle.='position:absolute;mso-width-percent:0;mso-height-percent:0;'; - $imgStyle.='mso-width-relative:margin;mso-height-relative:margin;'; - switch ($positioning) { - case ImageStyle::POSITION_RELATIVE: - $imgStyle.='mso-position-horizontal:'.$style->getPosHorizontal().';'; - $imgStyle.='mso-position-horizontal-relative:'.$style->getPosHorizontalRel().';'; - $imgStyle.='mso-position-vertical:'.$style->getPosVertical().';'; - $imgStyle.='mso-position-vertical-relative:'.$style->getPosVerticalRel().';'; - $imgStyle.='margin-left:0;margin-top:0;'; - break; - case ImageStyle::POSITION_ABSOLUTE: - $imgStyle.='mso-position-horizontal-relative:page;'; - $imgStyle.='mso-position-vertical-relative:page;'; - break; - } + $styleWriter = new ImageStyleWriter($this->xmlWriter, $style); - switch ($wrappingStyle) { - case ImageStyle::WRAPPING_STYLE_BEHIND: - $imgStyle .= 'z-index:-251658752;'; - break; - case ImageStyle::WRAPPING_STYLE_INFRONT: - $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - break; - case ImageStyle::WRAPPING_STYLE_SQUARE: - $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - $w10wrapType = 'square'; - break; - case ImageStyle::WRAPPING_STYLE_TIGHT: - $imgStyle .= 'z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - $w10wrapType = 'tight'; - break; - } - if (!$this->withoutP) { $this->xmlWriter->startElement('w:p'); - if (!is_null($align)) { + if (!is_null($style->getAlign())) { $this->xmlWriter->startElement('w:pPr'); $this->xmlWriter->startElement('w:jc'); - $this->xmlWriter->writeAttribute('w:val', $align); + $this->xmlWriter->writeAttribute('w:val', $style->getAlign()); $this->xmlWriter->endElement(); // w:jc $this->xmlWriter->endElement(); // w:pPr } } + $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:pict'); $this->xmlWriter->startElement('v:shape'); $this->xmlWriter->writeAttribute('type', '#_x0000_t75'); - $this->xmlWriter->writeAttribute('style', $imgStyle); + $styleWriter->write(); $this->xmlWriter->startElement('v:imagedata'); $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId); $this->xmlWriter->writeAttribute('o:title', ''); $this->xmlWriter->endElement(); // v:imagedata - if (!is_null($w10wrapType)) { - $this->xmlWriter->startElement('w10:wrap'); - $this->xmlWriter->writeAttribute('type', $w10wrapType); - $this->xmlWriter->endElement(); // w10:wrap - } + $styleWriter->writeW10Wrap(); $this->xmlWriter->endElement(); // v:shape $this->xmlWriter->endElement(); // w:pict $this->xmlWriter->endElement(); // w:r @@ -130,28 +75,16 @@ private function writeImage() private function writeWatermark() { $rId = $this->element->getRelationId(); - $style = $this->element->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $marginLeft = $style->getMarginLeft(); - $marginTop = $style->getMarginTop(); - $strStyle = 'position:absolute;'; - $strStyle .= ' width:' . $width . 'px;'; - $strStyle .= ' height:' . $height . 'px;'; - if (!is_null($marginTop)) { - $strStyle .= ' margin-top:' . $marginTop . 'px;'; - } - if (!is_null($marginLeft)) { - $strStyle .= ' margin-left:' . $marginLeft . 'px;'; - } + $style->setPositioning('absolute'); + $styleWriter = new ImageStyleWriter($this->xmlWriter, $style); $this->xmlWriter->startElement('w:p'); $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:pict'); $this->xmlWriter->startElement('v:shape'); $this->xmlWriter->writeAttribute('type', '#_x0000_t75'); - $this->xmlWriter->writeAttribute('style', $strStyle); + $styleWriter->write(); $this->xmlWriter->startElement('v:imagedata'); $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId); $this->xmlWriter->writeAttribute('o:title', ''); diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php new file mode 100644 index 0000000000..e93e58cdb2 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -0,0 +1,140 @@ +style instanceof \PhpOffice\PhpWord\Style\Image)) { + return; + } + + $wrapping = $this->style->getWrappingStyle(); + $positioning = $this->style->getPositioning(); + + // Default style array + $styleArray = array( + 'mso-width-percent' => '0', + 'mso-height-percent' => '0', + 'mso-width-relative' => 'margin', + 'mso-height-relative' => 'margin', + ); + $styleArray = array_merge($styleArray, $this->getElementStyle()); + + // Absolute/relative positioning + $styleArray['position'] = $positioning; + if ($positioning == ImageStyle::POSITION_ABSOLUTE) { + $styleArray['mso-position-horizontal-relative'] = 'page'; + $styleArray['mso-position-vertical-relative'] = 'page'; + } elseif ($positioning == ImageStyle::POSITION_RELATIVE) { + $styleArray['mso-position-horizontal'] = $this->style->getPosHorizontal(); + $styleArray['mso-position-vertical'] = $this->style->getPosVertical(); + $styleArray['mso-position-horizontal-relative'] = $this->style->getPosHorizontalRel(); + $styleArray['mso-position-vertical-relative'] = $this->style->getPosVerticalRel(); + $styleArray['margin-left'] = 0; + $styleArray['margin-top'] = 0; + } + + // Wrapping style + if ($wrapping == ImageStyle::WRAPPING_STYLE_INLINE) { + // Nothing to do when inline + } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_BEHIND) { + $styleArray['z-index'] = -251658752; + } else { + $styleArray['z-index'] = 251659264; + $styleArray['mso-position-horizontal'] = 'absolute'; + $styleArray['mso-position-vertical'] = 'absolute'; + } + + // w10 wrapping + if ($wrapping == ImageStyle::WRAPPING_STYLE_SQUARE) { + $this->w10wrap = 'square'; + } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_TIGHT) { + $this->w10wrap = 'tight'; + } + + $imageStyle = $this->assembleStyle($styleArray); + + $this->xmlWriter->writeAttribute('style', $imageStyle); + } + + /** + * Write w10 wrapping + * + * @return array + */ + public function writeW10Wrap() + { + if (!is_null($this->w10wrap)) { + $this->xmlWriter->startElement('w10:wrap'); + $this->xmlWriter->writeAttribute('type', $this->w10wrap); + $this->xmlWriter->endElement(); // w10:wrap + } + } + + /** + * Get element style + * + * @return array + */ + private function getElementStyle() + { + $styles = array(); + $styleValues = array( + 'width' => $this->style->getWidth(), + 'height' => $this->style->getHeight(), + 'margin-top' => $this->style->getMarginTop(), + 'margin-left' => $this->style->getMarginLeft() + ); + foreach ($styleValues as $key => $value) { + if (!is_null($value) && $value != '') { + $styles[$key] = $value . 'px'; + } + } + + return $styles; + } + + /** + * Assemble style array into style string + * + * @param array $styles + * @return string + */ + private function assembleStyle($styles = array()) + { + $style = ''; + foreach ($styles as $key => $value) { + if (!is_null($value) && $value != '') { + $style .= "{$key}:{$value}; "; + } + } + + return trim($style); + } +} From 250562ddd6b86a7aa38c2103de2ba1236cf38f0f Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 17:59:58 +0200 Subject: [PATCH 016/167] Added firstPage function and evenPage function to bring Footer Element in conformity with Header Element --- src/PhpWord/Element/Footer.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 1df69c29f0..2c42a08722 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -61,4 +61,24 @@ public function getType() { return $this->type; } + + /** + * First page only footer + * + * @return string + */ + public function firstPage() + { + return $this->type = self::FIRST; + } + + /** + * Even numbered pages only + * + * @return string + */ + public function evenPage() + { + return $this->type = self::EVEN; + } } From d1022a9e3c945a78e4a4599a243a583fa4687c11 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 22:53:56 +0700 Subject: [PATCH 017/167] QA: PHPMD fixes for `tests`; Some adjustment for Travis build --- .travis.yml | 4 ++-- .travis_shell_after_success.sh | 2 +- CHANGELOG.md | 2 +- phpunit.xml.dist | 3 +++ tests/PhpWord/Tests/Element/CellTest.php | 4 ++-- tests/PhpWord/Tests/Element/ImageTest.php | 2 ++ tests/PhpWord/Tests/Element/ObjectTest.php | 7 +++---- tests/PhpWord/Tests/Element/SectionTest.php | 10 +++++----- tests/PhpWord/Tests/Element/TOCTest.php | 2 +- tests/PhpWord/Tests/Element/TextRunTest.php | 2 +- tests/PhpWord/Tests/Shared/FontTest.php | 2 -- tests/PhpWord/Tests/Style/CellTest.php | 1 - tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 1 - tests/PhpWord/Tests/Writer/PDFTest.php | 1 + .../Tests/Writer/Word2007/Part/DocumentTest.php | 9 ++++----- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e22b85541..a8b60e2d30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,13 +52,13 @@ script: ## PHP Copy/Paste Detector - phpcpd src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php + - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs + - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/ after_script: ## PHPDocumentor diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh index 308388d7f5..35c7a338b9 100644 --- a/.travis_shell_after_success.sh +++ b/.travis_shell_after_success.sh @@ -31,7 +31,7 @@ if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == echo "--DEBUG : Git" git add -f . - git commit -m "PHPDocumentor (Travis Build : $TRAVIS_BUILD_NUMBER - Branch : $TRAVIS_BRANCH)" + git commit -m "PHPDocumentor (Travis Build: $TRAVIS_BUILD_NUMBER - Branch: $TRAVIS_BRANCH)" git push -fq origin gh-pages > /dev/null echo -e "Published PHPDoc to gh-pages.\n" diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c5ea1bfb..64804690ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -PHPWord license is changed from LGPL 2.1 to LGPL 3 in this release. +This release changed PHPWord license from LGPL 2.1 to LGPL 3. ### Features diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f77b9ce362..ce823a545b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -21,4 +21,7 @@ + + + \ No newline at end of file diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index c2ce43d6d6..9466f521bb 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -219,7 +219,7 @@ public function testAddObjectException() { $src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $oCell = new Cell('section', 1); - $element = $oCell->addObject($src); + $oCell->addObject($src); } /** @@ -255,7 +255,7 @@ public function testAddPreserveTextNotUTF8() public function testAddPreserveTextException() { $oCell = new Cell('section', 1); - $element = $oCell->addPreserveText('text'); + $oCell->addPreserveText('text'); } /** diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index f5c3570190..ca5234eab5 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -107,6 +107,7 @@ public function testInvalidImageLocal() public function testInvalidImagePhp() { $object = new Image('test.php'); + $object->getSource(); } /** @@ -117,6 +118,7 @@ public function testInvalidImagePhp() public function testUnsupportedImage() { $object = new Image('http://samples.libav.org/image-samples/RACECAR.BMP'); + $object->getSource(); } /** diff --git a/tests/PhpWord/Tests/Element/ObjectTest.php b/tests/PhpWord/Tests/Element/ObjectTest.php index 69b11e478d..33b63ec936 100644 --- a/tests/PhpWord/Tests/Element/ObjectTest.php +++ b/tests/PhpWord/Tests/Element/ObjectTest.php @@ -34,15 +34,14 @@ public function testConstructWithSupportedFiles() /** * Create new instance with non-supported files + * + * @expectedException \PhpOffice\PhpWord\Exception\InvalidObjectException */ public function testConstructWithNotSupportedFiles() { $src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $oObject = new Object($src); - - $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject); - $this->assertEquals($oObject->getSource(), null); - $this->assertEquals($oObject->getStyle(), null); + $oObject->getSource(); } /** diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index 04cda2675d..068aaa978f 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -76,7 +76,7 @@ public function testAddElements() { $objectSource = __DIR__ . "/../_files/documents/reader.docx"; $imageSource = __DIR__ . "/../_files/images/PhpWord.png"; - $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; + // $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; $section = new Section(0); $section->setPhpWord(new PhpWord()); @@ -98,10 +98,10 @@ public function testAddElements() $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak', 'Table', 'ListItem', 'Object', 'Image', 'Title', 'TextRun', 'Footnote', 'CheckBox', 'TOC'); - $i = 0; + $elmCount = 0; foreach ($elementTypes as $elementType) { - $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$i]); - $i++; + $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$elementType}", $elementCollection[$elmCount]); + $elmCount++; } } @@ -166,6 +166,6 @@ public function testHasDifferentFirstPage() public function testAddHeaderException() { $object = new Section(1); - $header = $object->addHeader('ODD'); + $object->addHeader('ODD'); } } diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index c38f3b4172..7787503733 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -48,7 +48,7 @@ public function testConstructWithStyleArray() public function testConstructWithStyleName() { $object = new TOC('Font Style'); - $tocStyle = $object->getStyleTOC(); + // $tocStyle = $object->getStyleTOC(); $this->assertEquals('Font Style', $object->getStyleFont()); } diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 6b9011c238..49b9c3bb6e 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -114,7 +114,7 @@ public function testAddLinkWithName() public function testAddTextBreak() { $oTextRun = new TextRun(); - $element = $oTextRun->addTextBreak(2); + $oTextRun->addTextBreak(2); $this->assertCount(2, $oTextRun->getElements()); } diff --git a/tests/PhpWord/Tests/Shared/FontTest.php b/tests/PhpWord/Tests/Shared/FontTest.php index 8183051b03..a6c10362de 100644 --- a/tests/PhpWord/Tests/Shared/FontTest.php +++ b/tests/PhpWord/Tests/Shared/FontTest.php @@ -25,8 +25,6 @@ class FontTest extends \PHPUnit_Framework_TestCase */ public function testConversions() { - $phpWord = new PhpWord(); - $original = 1; $result = Font::fontSizeToPixels($original); diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index 3838a36eea..78b5d60dcc 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -56,7 +56,6 @@ public function testBorderColor() { $object = new Cell(); - $default = '000000'; $value = 'FF0000'; $object->setStyleValue('borderColor', $value); diff --git a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php index d8d941e754..3dd21d7f58 100644 --- a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php @@ -48,7 +48,6 @@ public function testConstruct() public function testSetGetAbstractRendererProperties() { define('DOMPDF_ENABLE_AUTOLOAD', false); - $file = __DIR__ . "/../../_files/temp.pdf"; $rendererName = Settings::PDF_RENDERER_DOMPDF; $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf'); diff --git a/tests/PhpWord/Tests/Writer/PDFTest.php b/tests/PhpWord/Tests/Writer/PDFTest.php index 797765795a..0359ba1885 100644 --- a/tests/PhpWord/Tests/Writer/PDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDFTest.php @@ -47,5 +47,6 @@ public function testConstruct() public function testConstructException() { $writer = new PDF(new PhpWord()); + $writer->save(); } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 9597e772e8..8c7ae1c7a7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -361,11 +361,11 @@ public function testWriteParagraphStyle() $doc = TestHelperDOCX::getDocument($phpWord); // Test the attributes - $i = 0; + $attributeCount = 0; foreach ($attributes as $key => $value) { - $i++; + $attributeCount++; $nodeName = ($key == 'align') ? 'jc' : $key; - $path = "/w:document/w:body/w:p[{$i}]/w:pPr/w:{$nodeName}"; + $path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}"; if ($key != 'align') { $value = $value ? 1 : 0; } @@ -416,7 +416,6 @@ public function testWriteFontStyle() public function testWriteTableStyle() { $phpWord = new PhpWord(); - $tWidth = 120; $rHeight = 120; $cWidth = 120; $imageSrc = __DIR__ . "/../../../_files/images/earth.jpg"; @@ -511,7 +510,7 @@ public function testWriteGutterAndLineNumbering() $lineNumberingPath = '/w:document/w:body/w:sectPr/w:lnNumType'; $phpWord = new PhpWord(); - $section = $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array())); + $phpWord->addSection(array('gutter' => 240, 'lineNumbering' => array())); $doc = TestHelperDOCX::getDocument($phpWord); $this->assertEquals(240, $doc->getElement($pageMarginPath)->getAttribute('w:gutter')); diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 3dbdd0496b..4be12d40e7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -171,7 +171,7 @@ public function testGetWriterPartNull() public function testSetGetUseDiskCaching() { $phpWord = new PhpWord(); - $section = $phpWord->addSection(); + $phpWord->addSection(); $object = new Word2007($phpWord); $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); $writer = new Word2007($phpWord); From dd01ed1aaaefd63a95109aecbbe18d37568da679 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 23:36:28 +0700 Subject: [PATCH 018/167] Fix .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8b60e2d30..65b9de9aa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ script: ## PHP_CodeSniffer - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP Copy/Paste Detector - - phpcpd src/ tests/ --verbose + - php phpcpd.phar src/ tests/ --verbose ## PHP Mess Detector - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC @@ -58,7 +58,7 @@ script: ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/ + - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/* after_script: ## PHPDocumentor From 6c3d1e721d8a41a1482cb1a0c86ad02a3aaac7e1 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 4 May 2014 21:03:28 +0400 Subject: [PATCH 019/167] License version has been added. --- docs/intro.rst | 2 +- docs/src/documentation.md | 2 +- src/PhpWord/Autoloader.php | 2 +- src/PhpWord/DocumentProperties.php | 2 +- src/PhpWord/Element/AbstractContainer.php | 6 +++--- src/PhpWord/Element/AbstractElement.php | 2 +- src/PhpWord/Element/Cell.php | 2 +- src/PhpWord/Element/CheckBox.php | 2 +- src/PhpWord/Element/Endnote.php | 2 +- src/PhpWord/Element/Footer.php | 2 +- src/PhpWord/Element/Footnote.php | 2 +- src/PhpWord/Element/Header.php | 4 +--- src/PhpWord/Element/Image.php | 4 ++-- src/PhpWord/Element/Link.php | 2 +- src/PhpWord/Element/ListItem.php | 2 +- src/PhpWord/Element/Object.php | 2 +- src/PhpWord/Element/PageBreak.php | 2 +- src/PhpWord/Element/PreserveText.php | 2 +- src/PhpWord/Element/Row.php | 2 +- src/PhpWord/Element/Section.php | 4 +--- src/PhpWord/Element/TOC.php | 4 ++-- src/PhpWord/Element/Table.php | 2 +- src/PhpWord/Element/Text.php | 2 +- src/PhpWord/Element/TextBreak.php | 2 +- src/PhpWord/Element/TextRun.php | 2 +- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/Endnotes.php | 2 +- src/PhpWord/Exception/Exception.php | 2 +- src/PhpWord/Exception/InvalidImageException.php | 2 +- src/PhpWord/Exception/InvalidObjectException.php | 2 +- src/PhpWord/Exception/InvalidStyleException.php | 2 +- .../Exception/UnsupportedImageTypeException.php | 2 +- src/PhpWord/Footnotes.php | 2 +- src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Media.php | 2 +- src/PhpWord/PhpWord.php | 6 ++---- src/PhpWord/Reader/AbstractReader.php | 2 +- src/PhpWord/Reader/ODText.php | 2 +- src/PhpWord/Reader/ODText/AbstractPart.php | 2 +- src/PhpWord/Reader/ODText/Content.php | 2 +- src/PhpWord/Reader/ReaderInterface.php | 2 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 2 +- src/PhpWord/Reader/Word2007/DocProps.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsApp.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCustom.php | 2 +- src/PhpWord/Reader/Word2007/Document.php | 2 +- src/PhpWord/Reader/Word2007/Endnotes.php | 2 +- src/PhpWord/Reader/Word2007/Footnotes.php | 2 +- src/PhpWord/Reader/Word2007/Notes.php | 2 +- src/PhpWord/Reader/Word2007/Numbering.php | 2 +- src/PhpWord/Reader/Word2007/Styles.php | 2 +- src/PhpWord/Settings.php | 2 +- src/PhpWord/Shared/Drawing.php | 2 +- src/PhpWord/Shared/Font.php | 2 +- src/PhpWord/Shared/String.php | 2 +- src/PhpWord/Shared/XMLReader.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Shared/ZipArchive.php | 2 +- src/PhpWord/Style.php | 4 ++-- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Border.php | 2 +- src/PhpWord/Style/Cell.php | 4 +--- src/PhpWord/Style/Font.php | 5 ++--- src/PhpWord/Style/Image.php | 2 +- src/PhpWord/Style/Indentation.php | 2 +- src/PhpWord/Style/LineNumbering.php | 2 +- src/PhpWord/Style/ListItem.php | 2 +- src/PhpWord/Style/Numbering.php | 4 +--- src/PhpWord/Style/NumberingLevel.php | 2 +- src/PhpWord/Style/Paragraph.php | 4 +--- src/PhpWord/Style/Row.php | 2 +- src/PhpWord/Style/Section.php | 4 +--- src/PhpWord/Style/Shading.php | 2 +- src/PhpWord/Style/Spacing.php | 2 +- src/PhpWord/Style/TOC.php | 2 +- src/PhpWord/Style/Tab.php | 2 +- src/PhpWord/Style/Table.php | 4 +--- src/PhpWord/TOC.php | 2 +- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 2 +- src/PhpWord/Writer/HTML.php | 8 ++++---- src/PhpWord/Writer/HTML/Element/Element.php | 2 +- src/PhpWord/Writer/HTML/Element/Endnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Image.php | 2 +- src/PhpWord/Writer/HTML/Element/Link.php | 2 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 2 +- src/PhpWord/Writer/HTML/Element/Note.php | 2 +- src/PhpWord/Writer/HTML/Element/PageBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/Table.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 2 +- src/PhpWord/Writer/HTML/Element/TextBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/TextRun.php | 2 +- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- src/PhpWord/Writer/HTML/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/HTML/Style/Generic.php | 2 +- src/PhpWord/Writer/HTML/Style/Image.php | 2 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 2 +- src/PhpWord/Writer/ODText.php | 4 ++-- src/PhpWord/Writer/ODText/Element/Element.php | 2 +- src/PhpWord/Writer/ODText/Element/Image.php | 2 +- src/PhpWord/Writer/ODText/Element/Link.php | 2 +- src/PhpWord/Writer/ODText/Element/Table.php | 2 +- src/PhpWord/Writer/ODText/Element/Text.php | 2 +- src/PhpWord/Writer/ODText/Element/TextBreak.php | 2 +- src/PhpWord/Writer/ODText/Element/TextRun.php | 2 +- src/PhpWord/Writer/ODText/Part/AbstractPart.php | 6 +++--- src/PhpWord/Writer/ODText/Part/Content.php | 10 +++++----- src/PhpWord/Writer/ODText/Part/Manifest.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 2 +- src/PhpWord/Writer/ODText/Part/Mimetype.php | 2 +- src/PhpWord/Writer/ODText/Part/Styles.php | 4 ++-- src/PhpWord/Writer/ODText/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/ODText/Style/Font.php | 4 +--- src/PhpWord/Writer/ODText/Style/Paragraph.php | 4 +--- src/PhpWord/Writer/PDF.php | 2 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 2 +- src/PhpWord/Writer/PDF/DomPDF.php | 4 ++-- src/PhpWord/Writer/RTF.php | 6 +++--- src/PhpWord/Writer/RTF/Element/Element.php | 2 +- src/PhpWord/Writer/RTF/Element/Text.php | 4 ++-- src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 2 +- src/PhpWord/Writer/RTF/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007.php | 6 +++--- src/PhpWord/Writer/Word2007/Element/CheckBox.php | 2 +- src/PhpWord/Writer/Word2007/Element/Element.php | 2 +- src/PhpWord/Writer/Word2007/Element/Endnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Image.php | 3 +-- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- src/PhpWord/Writer/Word2007/Element/ListItem.php | 2 +- src/PhpWord/Writer/Word2007/Element/Note.php | 2 +- src/PhpWord/Writer/Word2007/Element/Object.php | 2 +- src/PhpWord/Writer/Word2007/Element/PageBreak.php | 2 +- src/PhpWord/Writer/Word2007/Element/PreserveText.php | 2 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 4 ++-- src/PhpWord/Writer/Word2007/Element/Text.php | 2 +- src/PhpWord/Writer/Word2007/Element/TextBreak.php | 2 +- src/PhpWord/Writer/Word2007/Element/TextRun.php | 2 +- src/PhpWord/Writer/Word2007/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 3 +-- src/PhpWord/Writer/Word2007/Part/ContentTypes.php | 2 +- src/PhpWord/Writer/Word2007/Part/DocProps.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Document.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 2 +- src/PhpWord/Writer/Word2007/Part/FontTable.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footnotes.php | 2 +- src/PhpWord/Writer/Word2007/Part/Header.php | 2 +- src/PhpWord/Writer/Word2007/Part/Numbering.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 4 +--- src/PhpWord/Writer/Word2007/Part/Styles.php | 6 +++--- src/PhpWord/Writer/Word2007/Part/Theme.php | 2 +- src/PhpWord/Writer/Word2007/Part/WebSettings.php | 2 +- src/PhpWord/Writer/Word2007/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 3 +-- src/PhpWord/Writer/Word2007/Style/Font.php | 2 +- src/PhpWord/Writer/Word2007/Style/Image.php | 2 +- src/PhpWord/Writer/Word2007/Style/Indentation.php | 2 +- src/PhpWord/Writer/Word2007/Style/LineNumbering.php | 2 +- src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 2 +- src/PhpWord/Writer/Word2007/Style/Paragraph.php | 6 +----- src/PhpWord/Writer/Word2007/Style/Section.php | 4 +--- src/PhpWord/Writer/Word2007/Style/Shading.php | 2 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 2 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 4 +--- src/PhpWord/Writer/WriterInterface.php | 2 +- tests/PhpWord/Tests/AutoloaderTest.php | 2 +- tests/PhpWord/Tests/DocumentPropertiesTest.php | 2 +- tests/PhpWord/Tests/Element/AbstractElementTest.php | 2 +- tests/PhpWord/Tests/Element/CellTest.php | 2 +- tests/PhpWord/Tests/Element/CheckBoxTest.php | 2 +- tests/PhpWord/Tests/Element/FooterTest.php | 2 +- tests/PhpWord/Tests/Element/FootnoteTest.php | 2 +- tests/PhpWord/Tests/Element/HeaderTest.php | 2 +- tests/PhpWord/Tests/Element/ImageTest.php | 2 +- tests/PhpWord/Tests/Element/LinkTest.php | 2 +- tests/PhpWord/Tests/Element/ListItemTest.php | 2 +- tests/PhpWord/Tests/Element/ObjectTest.php | 2 +- tests/PhpWord/Tests/Element/PageBreakTest.php | 2 +- tests/PhpWord/Tests/Element/PreserveTextTest.php | 2 +- tests/PhpWord/Tests/Element/RowTest.php | 2 +- tests/PhpWord/Tests/Element/SectionTest.php | 6 +++--- tests/PhpWord/Tests/Element/TOCTest.php | 2 +- tests/PhpWord/Tests/Element/TableTest.php | 2 +- tests/PhpWord/Tests/Element/TextBreakTest.php | 2 +- tests/PhpWord/Tests/Element/TextRunTest.php | 2 +- tests/PhpWord/Tests/Element/TextTest.php | 2 +- tests/PhpWord/Tests/Element/TitleTest.php | 2 +- tests/PhpWord/Tests/EndnotesTest.php | 2 +- tests/PhpWord/Tests/Exception/ExceptionTest.php | 2 +- .../Tests/Exception/InvalidImageExceptionTest.php | 2 +- .../Tests/Exception/InvalidStyleExceptionTest.php | 2 +- .../Exception/UnsupportedImageTypeExceptionTest.php | 2 +- tests/PhpWord/Tests/FootnotesTest.php | 2 +- tests/PhpWord/Tests/IOFactoryTest.php | 4 ++-- tests/PhpWord/Tests/MediaTest.php | 5 ++--- tests/PhpWord/Tests/PhpWordTest.php | 4 ++-- tests/PhpWord/Tests/Reader/ODTextTest.php | 2 +- tests/PhpWord/Tests/Reader/Word2007Test.php | 4 ++-- tests/PhpWord/Tests/SettingsTest.php | 2 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- tests/PhpWord/Tests/Shared/FontTest.php | 2 +- tests/PhpWord/Tests/Shared/StringTest.php | 2 +- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 2 +- tests/PhpWord/Tests/Shared/ZipArchiveTest.php | 2 +- tests/PhpWord/Tests/Style/AbstractStyleTest.php | 2 +- tests/PhpWord/Tests/Style/CellTest.php | 2 +- tests/PhpWord/Tests/Style/FontTest.php | 2 +- tests/PhpWord/Tests/Style/ImageTest.php | 2 +- tests/PhpWord/Tests/Style/ListItemTest.php | 2 +- tests/PhpWord/Tests/Style/NumberingLevelTest.php | 2 +- tests/PhpWord/Tests/Style/ParagraphTest.php | 2 +- tests/PhpWord/Tests/Style/RowTest.php | 2 +- tests/PhpWord/Tests/Style/SectionTest.php | 2 +- tests/PhpWord/Tests/Style/TOCTest.php | 2 +- tests/PhpWord/Tests/Style/TableTest.php | 2 +- tests/PhpWord/Tests/Style/TabsTest.php | 2 +- tests/PhpWord/Tests/StyleTest.php | 2 +- tests/PhpWord/Tests/TOCTest.php | 2 +- tests/PhpWord/Tests/TemplateTest.php | 3 +-- tests/PhpWord/Tests/Writer/HTMLTest.php | 2 +- .../Tests/Writer/ODText/Part/AbstractPartTest.php | 2 +- tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php | 4 ++-- tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php | 2 +- tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php | 2 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 2 +- tests/PhpWord/Tests/Writer/PDFTest.php | 2 +- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- .../Tests/Writer/Word2007/Part/AbstractPartTest.php | 2 +- .../Tests/Writer/Word2007/Part/DocPropsTest.php | 2 +- .../Tests/Writer/Word2007/Part/DocumentTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/FooterTest.php | 5 ++--- .../Tests/Writer/Word2007/Part/FootnotesTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php | 5 ++--- .../Tests/Writer/Word2007/Part/NumberingTest.php | 5 +---- .../PhpWord/Tests/Writer/Word2007/Part/StylesTest.php | 4 ++-- tests/PhpWord/Tests/Writer/Word2007Test.php | 4 ++-- tests/PhpWord/Tests/_includes/TestHelperDOCX.php | 4 ++-- tests/PhpWord/Tests/_includes/XmlDocument.php | 2 +- tests/bootstrap.php | 2 +- 249 files changed, 291 insertions(+), 332 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index 3e74519e3c..3c2a47bde5 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -16,7 +16,7 @@ No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major `word processing softwares `__. -PHPWord is an open source project licensed under LGPL. PHPWord is `unit +PHPWord is an open source project licensed under LGPL version 3. PHPWord is `unit tested `__ to make sure that the released versions are stable. diff --git a/docs/src/documentation.md b/docs/src/documentation.md index bcf38a048d..4ae1f50ec6 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -49,7 +49,7 @@ PHPWord is a library written in pure PHP that provides a set of classes to write No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major [word processing softwares](http://en.wikipedia.org/wiki/List_of_word_processors). -PHPWord is an open source project licensed under LGPL. PHPWord is [unit tested](https://travis-ci.org/PHPOffice/PHPWord) to make sure that the released versions are stable. +PHPWord is an open source project licensed under LGPL version 3. PHPWord is [unit tested](https://travis-ci.org/PHPOffice/PHPWord) to make sure that the released versions are stable. **Want to contribute?** [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us. diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index ddbbf36b3e..0688ffda57 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 7978b22d95..eb928dc17d 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 013ee4eeaf..1273a8497e 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -4,18 +4,18 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Endnotes; +use PhpOffice\PhpWord\Exception\InvalidObjectException; use PhpOffice\PhpWord\Footnotes; use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\TOC as Titles; -use PhpOffice\PhpWord\Exception\InvalidObjectException; -use PhpOffice\PhpWord\Shared\String; /** * Container abstract class diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 8bc0cbbd96..14d1bcc04f 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index de1de0ff61..2a6eab44df 100644 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index 9344ad0b2f..d078f52c82 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php index 49c52d0317..db6b1d54e0 100644 --- a/src/PhpWord/Element/Endnote.php +++ b/src/PhpWord/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 1df69c29f0..3f64a9b23e 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index ba6442f086..79117d0adb 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index f642f13b43..609b109213 100644 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Element\Image; - /** * Header element */ diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 19f4e5c4b3..9904710ce2 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\UnsupportedImageTypeException; +use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Style\Image as ImageStyle; /** diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 9358fac610..21d6d7a60c 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 72452b1d57..d63ebc096b 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index d1c8fe351e..ffe33dbf27 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php index 64cf2f678c..6cf78e99e3 100644 --- a/src/PhpWord/Element/PageBreak.php +++ b/src/PhpWord/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 68c15cc265..214f191af4 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index 21481a540e..45e351a9f6 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index e456f68f4d..11ecef4b60 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -4,15 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Style\Section as SectionSettings; -use PhpOffice\PhpWord\Element\PageBreak; -use PhpOffice\PhpWord\Element\TOC; /** * Section diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index 31a81db1ef..5efaa5f08f 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\TOC as Titles; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\TOC as TOCStyle; +use PhpOffice\PhpWord\TOC as Titles; /** * Table of contents diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 041f3c3e2e..99fe6b2969 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index f0ade0e174..ba908b6fd2 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index 3af7d2c9f3..d8157c02d4 100644 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index 9b1b891921..3eff554bdd 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 89774d2927..7c60961efc 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; diff --git a/src/PhpWord/Endnotes.php b/src/PhpWord/Endnotes.php index 7fda82b3d7..be00646f56 100644 --- a/src/PhpWord/Endnotes.php +++ b/src/PhpWord/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Exception/Exception.php b/src/PhpWord/Exception/Exception.php index 36346f7555..1c27d55e08 100644 --- a/src/PhpWord/Exception/Exception.php +++ b/src/PhpWord/Exception/Exception.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidImageException.php b/src/PhpWord/Exception/InvalidImageException.php index 3a236dec92..6cf4de0da5 100644 --- a/src/PhpWord/Exception/InvalidImageException.php +++ b/src/PhpWord/Exception/InvalidImageException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidObjectException.php b/src/PhpWord/Exception/InvalidObjectException.php index f66d0e86f9..44884989fd 100644 --- a/src/PhpWord/Exception/InvalidObjectException.php +++ b/src/PhpWord/Exception/InvalidObjectException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/InvalidStyleException.php b/src/PhpWord/Exception/InvalidStyleException.php index 630bd3a7cf..e05a296805 100644 --- a/src/PhpWord/Exception/InvalidStyleException.php +++ b/src/PhpWord/Exception/InvalidStyleException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Exception/UnsupportedImageTypeException.php b/src/PhpWord/Exception/UnsupportedImageTypeException.php index d4bd82c4f4..a038ba4e6b 100644 --- a/src/PhpWord/Exception/UnsupportedImageTypeException.php +++ b/src/PhpWord/Exception/UnsupportedImageTypeException.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Exception; diff --git a/src/PhpWord/Footnotes.php b/src/PhpWord/Footnotes.php index d25699bc08..24fd8d6a96 100644 --- a/src/PhpWord/Footnotes.php +++ b/src/PhpWord/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index daa1eca3dc..6845b2cefb 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index bad8dd64e6..f06027d983 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index fc87f7efd9..f997dec236 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -4,16 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; -use PhpOffice\PhpWord\DocumentProperties; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Element\Section; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Template; /** * PHPWord main class diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index a9627a0a9c..e9e52c63a0 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index 247c3d33a3..7bb6485021 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 84f5b3bf11..32799c72fc 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\ODText; diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index 6cefac715f..c5fe7b2253 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\ODText; diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php index 2baee55fdd..7b291e4e48 100644 --- a/src/PhpWord/Reader/ReaderInterface.php +++ b/src/PhpWord/Reader/ReaderInterface.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index d466d41998..914177a315 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader; diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 8c83c13e5e..32377b54e4 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocProps.php b/src/PhpWord/Reader/Word2007/DocProps.php index 443e5d6470..abd481db3c 100644 --- a/src/PhpWord/Reader/Word2007/DocProps.php +++ b/src/PhpWord/Reader/Word2007/DocProps.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php index 5d0ebbca00..233225a687 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsApp.php +++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index 60a1ee7014..67324cb31d 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 9f33ddb50c..8b107beb47 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 562094cdec..40257d97e8 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php index 48b098a5ba..9c4c10402f 100644 --- a/src/PhpWord/Reader/Word2007/Endnotes.php +++ b/src/PhpWord/Reader/Word2007/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index 4d9aca50ae..ba27853b81 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php index 3981abb11c..89e15cfb5e 100644 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ b/src/PhpWord/Reader/Word2007/Notes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index 946d260c6c..a45614924a 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index 24165938c7..aeb8806d39 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Reader\Word2007; diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index d8df5d21cd..717b055cfc 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 42a334f04b..b0ff8d6c73 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php index 2317676ce8..3831dff356 100644 --- a/src/PhpWord/Shared/Font.php +++ b/src/PhpWord/Shared/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 7fa59b3f21..e4dacf6dc8 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index c7baf02753..6f491c8d00 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index e51dd636df..8f4162e1ec 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 0bc5ae1405..3747436215 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Shared; diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 2ff500c4a6..93197418f2 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -4,15 +4,15 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Numbering; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Table; -use PhpOffice\PhpWord\Style\Numbering; /** * Style collection diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index e4dd3082ba..ea0c85fdf2 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index 2ba912bb2d..33d4fe0fdf 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 9a60946ab8..74e1e51941 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\Shading; - /** * Table cell style */ diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 964df35632..7ae31ad770 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -4,14 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Exception\InvalidStyleException; -use PhpOffice\PhpWord\Style\Shading; +use PhpOffice\PhpWord\PhpWord; /** * Font style diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index b258fa08a0..4dbfa5f4d0 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -5,7 +5,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php index e2783ea6e9..f564df0baa 100644 --- a/src/PhpWord/Style/Indentation.php +++ b/src/PhpWord/Style/Indentation.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php index 3caf0b6974..f230634db1 100644 --- a/src/PhpWord/Style/LineNumbering.php +++ b/src/PhpWord/Style/LineNumbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 9c951656c3..4cdb0623a4 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php index 67cc48217d..88503964d6 100644 --- a/src/PhpWord/Style/Numbering.php +++ b/src/PhpWord/Style/Numbering.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\NumberingLevel; - /** * Numbering style * diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index f292c9356f..d6fc364906 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 3a0defeed6..22371e3716 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -4,15 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Exception\InvalidStyleException; use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Style\Indentation; -use PhpOffice\PhpWord\Style\Spacing; /** * Paragraph style diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index b9804e2844..06284eb728 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index 84e9397c17..4bff700701 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\LineNumbering; - /** * Section settings */ diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php index 5081589589..a83d17fedf 100644 --- a/src/PhpWord/Style/Shading.php +++ b/src/PhpWord/Style/Shading.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index 07bcde48ab..609ef5a058 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 14c46aadf8..2741bbf208 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index 011e24770d..8ba2e85a81 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index f1bebe20e0..6dcee1ae19 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\Shading; - /** * Table style */ diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php index f760f278e2..064a836de0 100644 --- a/src/PhpWord/TOC.php +++ b/src/PhpWord/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 53c7efa43a..bdc000c47f 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index c4e2cc5dcd..d613a85ff1 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 1f1fefa835..8ce1264cc5 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -4,21 +4,21 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\HTML\Element\Element as ElementWriter; use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter; -use PhpOffice\PhpWord\Writer\HTML\Style\Generic as GenericStyleWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter; +use PhpOffice\PhpWord\Writer\HTML\Style\Generic as GenericStyleWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter; /** diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index 79ace1e861..a24364e3ef 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php index 95e93f6bec..7b13ecdb3d 100644 --- a/src/PhpWord/Writer/HTML/Element/Endnote.php +++ b/src/PhpWord/Writer/HTML/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index f93072eb10..3283895d1e 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 442ee4e5c8..ca5847ee06 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 36053f9499..9df76a1a7e 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index baf2e26128..54b014dbab 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Note.php b/src/PhpWord/Writer/HTML/Element/Note.php index d195a11d6d..4610495c0c 100644 --- a/src/PhpWord/Writer/HTML/Element/Note.php +++ b/src/PhpWord/Writer/HTML/Element/Note.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index fa52d8ab14..c0f5c564aa 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index d635fc3322..3938a160b5 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index e434c485d4..242645eedd 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php index 26689cf77c..5dee7a0ee2 100644 --- a/src/PhpWord/Writer/HTML/Element/TextBreak.php +++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index 17ec57f2b9..22cf657fd6 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 947539bf49..fa3ff09924 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Element; diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index c332ba5ad9..0b978f7a6c 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 9a9d05c4c4..309d47181a 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php index c8fcbc4991..e840dfb3a6 100644 --- a/src/PhpWord/Writer/HTML/Style/Generic.php +++ b/src/PhpWord/Writer/HTML/Style/Generic.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index 9e7fa9d5c7..dcd7e8c201 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index 60e864a844..a095a30831 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\HTML\Style; diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index 77cd166bbd..7b7b9c1a43 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Exception\Exception; /** * ODText writer diff --git a/src/PhpWord/Writer/ODText/Element/Element.php b/src/PhpWord/Writer/ODText/Element/Element.php index 60163150c3..81ee1a6475 100644 --- a/src/PhpWord/Writer/ODText/Element/Element.php +++ b/src/PhpWord/Writer/ODText/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index a115bb1691..03fe5a4ed1 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 2553e51efc..21431109d5 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 9199f83246..5839a07c9f 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 17286a337f..b5e55752c7 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/TextBreak.php b/src/PhpWord/Writer/ODText/Element/TextBreak.php index 96a355bd49..8670866af4 100644 --- a/src/PhpWord/Writer/ODText/Element/TextBreak.php +++ b/src/PhpWord/Writer/ODText/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php index 4ac659c1c4..9854c61eed 100644 --- a/src/PhpWord/Writer/ODText/Element/TextRun.php +++ b/src/PhpWord/Writer/ODText/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Element; diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index 64ab52ee73..448597666f 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -4,15 +4,15 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style; /** * ODText writer part abstract diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 408a69bd24..49f3c40299 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -4,20 +4,20 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Media; -use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\Table; +use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; /** diff --git a/src/PhpWord/Writer/ODText/Part/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php index 0ecba936d3..ebfd2b5920 100644 --- a/src/PhpWord/Writer/ODText/Part/Manifest.php +++ b/src/PhpWord/Writer/ODText/Part/Manifest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index b4999f95c8..032d03e8bd 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php index 75c2bb1fab..a8ededbb2e 100644 --- a/src/PhpWord/Writer/ODText/Part/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index 1f1a525f1c..bfc8f7c521 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Part; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Exception\Exception; /** * ODText styloes part writer diff --git a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php index 3436490ca2..4f28de4a0d 100644 --- a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Style; diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index ec0334453a..aebf3872d7 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Style; -use PhpOffice\PhpWord\PhpWord; - /** * Font style writer * diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index 9b5da1fbf4..3aaac86526 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\ODText\Style; -use PhpOffice\PhpWord\PhpWord; - /** * Font style writer * diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index 574a6ce006..e668bc770d 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index 0a11b78819..3500acceb4 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\PDF; diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index 02547925bf..2239b4167e 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PhpWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\PDF; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Settings; -use PhpOffice\PhpWord\Exception\Exception; /** * DomPDF writer diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 893ba72da5..8bef6629d5 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -4,16 +4,16 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\Drawing; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Writer\RTF\Element\Element as ElementWriter; diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index 0beaa0ba23..d50f1c8fc3 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index aecbc889d1..8a718909b4 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style; /** * Text element RTF writer diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index ca177f9382..7a813ad1fe 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 228833a828..970d049afe 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 440c034b85..54767637e6 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 3f4626e026..105093a7a8 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -4,15 +4,15 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\Media; +use PhpOffice\PhpWord\PhpWord; /** * Word2007 writer diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index a4a4332943..edc0e0ebc8 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/Element.php index a2b1968d62..8ebbf79c23 100644 --- a/src/PhpWord/Writer/Word2007/Element/Element.php +++ b/src/PhpWord/Writer/Word2007/Element/Element.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Endnote.php b/src/PhpWord/Writer/Word2007/Element/Endnote.php index e72fa9369c..d270186698 100644 --- a/src/PhpWord/Writer/Word2007/Element/Endnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Endnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index a82d1d47ce..b53bd55381 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index b7d24cb5f3..1f5f6e8516 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -4,12 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Style\Image as ImageStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Image as ImageStyleWriter; /** diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 7d7c4a0d79..7ec937f881 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index 5c4b64a584..14544fd74a 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Note.php b/src/PhpWord/Writer/Word2007/Element/Note.php index 0fe1349e71..5e0b36e92f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Note.php +++ b/src/PhpWord/Writer/Word2007/Element/Note.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index 8ed84dae76..c8e4d68638 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index 602bc23051..912f59dbfe 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index e6eab9709a..4a2f1268fc 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index af173c3776..d56a8d1dd0 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 7a6d3bf2be..954dd6a980 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -4,15 +4,15 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Style\Cell; use PhpOffice\PhpWord\Style\Table as TableStyle; -use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; +use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; /** * Table element writer diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 96e58ef826..716c625d90 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 9ccaf79c9d..67219f94eb 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index cbe1c33f6a..6ed058aa95 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index d6adc20cfe..5d3ab37151 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Element; diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index 4a0c442e20..eec380c90c 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -4,12 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Element\TextBreak; use PhpOffice\PhpWord\Exception\Exception; diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 273a965a34..08c39ce7f0 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/DocProps.php b/src/PhpWord/Writer/Word2007/Part/DocProps.php index df00e74373..c489f74a79 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocProps.php +++ b/src/PhpWord/Writer/Word2007/Part/DocProps.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\PhpWord; /** * Word2007 document properties part writer diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 3022f7e72e..a12623b044 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php index 866378abe1..86782b31b0 100644 --- a/src/PhpWord/Writer/Word2007/Part/Endnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php index b5c8d44b4e..deb3c09fbf 100644 --- a/src/PhpWord/Writer/Word2007/Part/FontTable.php +++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index d09baf7e76..e30a2ea975 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index ced2ba39be..05bf17d190 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php index 39057609be..1ff30e74c3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Header.php +++ b/src/PhpWord/Writer/Word2007/Part/Header.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 88684b713f..723a043f90 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\NumberingLevel; +use PhpOffice\PhpWord\Style; /** * Word2007 numbering part writer diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 9b9af81a23..bccb945438 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index e0d561c632..994a1747d9 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; - /** * Word2007 settings part writer */ diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 4358f9f5d4..adabd89ab5 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -4,18 +4,18 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Table; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Theme.php b/src/PhpWord/Writer/Word2007/Part/Theme.php index 8ae230643b..081c3b6853 100644 --- a/src/PhpWord/Writer/Word2007/Part/Theme.php +++ b/src/PhpWord/Writer/Word2007/Part/Theme.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php index 17bfcc8ece..7c22e9f00c 100644 --- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php +++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index b1a7ce380a..ab0e4d3358 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index 6b5fe6b575..544ae40db1 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -4,13 +4,12 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; use PhpOffice\PhpWord\Style\Cell as CellStyle; -use PhpOffice\PhpWord\Writer\Word2007\Style\Shading; /** * Cell style writer diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index def9cac47a..f508ccbdbb 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index e93e58cdb2..2983c50543 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index 8049933fc1..6fb5689775 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index 8ab987c518..84b3933ea9 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 7f286492a3..92c10fd1ed 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index eeb0f0d647..432a45ff78 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -4,15 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Writer\Word2007\Style\Tab; -use PhpOffice\PhpWord\Writer\Word2007\Style\Indentation; -use PhpOffice\PhpWord\Writer\Word2007\Style\Spacing; - /** * Paragraph style writer * diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index 9d735da158..66dde75130 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -4,14 +4,12 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; use PhpOffice\PhpWord\Style\Section as SectionStyle; -use PhpOffice\PhpWord\Writer\Word2007\Style\LineNumbering; -use PhpOffice\PhpWord\Writer\Word2007\Style\MarginBorder; /** * Section style writer diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index 998162b611..adbb19d4b2 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index f73c37c759..c6e1343629 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index bbaeddaf4c..60e2db0ee8 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 28afb17acd..e57e4cd61c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -4,13 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Writer\Word2007\Style\Shading; - /** * Table style writer * diff --git a/src/PhpWord/Writer/WriterInterface.php b/src/PhpWord/Writer/WriterInterface.php index 50335c3acd..3bc0c38da8 100644 --- a/src/PhpWord/Writer/WriterInterface.php +++ b/src/PhpWord/Writer/WriterInterface.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer; diff --git a/tests/PhpWord/Tests/AutoloaderTest.php b/tests/PhpWord/Tests/AutoloaderTest.php index 0bf71ce27d..75b273ecd0 100644 --- a/tests/PhpWord/Tests/AutoloaderTest.php +++ b/tests/PhpWord/Tests/AutoloaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/DocumentPropertiesTest.php b/tests/PhpWord/Tests/DocumentPropertiesTest.php index 78d26da5ba..20545c1ec3 100644 --- a/tests/PhpWord/Tests/DocumentPropertiesTest.php +++ b/tests/PhpWord/Tests/DocumentPropertiesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Element/AbstractElementTest.php b/tests/PhpWord/Tests/Element/AbstractElementTest.php index 0df09abb0f..9308fe20d9 100644 --- a/tests/PhpWord/Tests/Element/AbstractElementTest.php +++ b/tests/PhpWord/Tests/Element/AbstractElementTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index c2ce43d6d6..2d7cfd56a9 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/CheckBoxTest.php b/tests/PhpWord/Tests/Element/CheckBoxTest.php index 66580195c4..8c09e478f8 100644 --- a/tests/PhpWord/Tests/Element/CheckBoxTest.php +++ b/tests/PhpWord/Tests/Element/CheckBoxTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/FooterTest.php b/tests/PhpWord/Tests/Element/FooterTest.php index 02e42942e9..9eea65b29a 100644 --- a/tests/PhpWord/Tests/Element/FooterTest.php +++ b/tests/PhpWord/Tests/Element/FooterTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/FootnoteTest.php b/tests/PhpWord/Tests/Element/FootnoteTest.php index 3197bbee8d..40128ce475 100644 --- a/tests/PhpWord/Tests/Element/FootnoteTest.php +++ b/tests/PhpWord/Tests/Element/FootnoteTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/HeaderTest.php b/tests/PhpWord/Tests/Element/HeaderTest.php index 6297ba6501..5bc9c5d5c9 100644 --- a/tests/PhpWord/Tests/Element/HeaderTest.php +++ b/tests/PhpWord/Tests/Element/HeaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index 5dfbc2dee5..ab4d7a5931 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/LinkTest.php b/tests/PhpWord/Tests/Element/LinkTest.php index c0e038ff1b..9e54593d66 100644 --- a/tests/PhpWord/Tests/Element/LinkTest.php +++ b/tests/PhpWord/Tests/Element/LinkTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ListItemTest.php b/tests/PhpWord/Tests/Element/ListItemTest.php index 4b88cdf170..a3ab3d2d8f 100644 --- a/tests/PhpWord/Tests/Element/ListItemTest.php +++ b/tests/PhpWord/Tests/Element/ListItemTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/ObjectTest.php b/tests/PhpWord/Tests/Element/ObjectTest.php index 69b11e478d..45fa627180 100644 --- a/tests/PhpWord/Tests/Element/ObjectTest.php +++ b/tests/PhpWord/Tests/Element/ObjectTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/PageBreakTest.php b/tests/PhpWord/Tests/Element/PageBreakTest.php index a2e690cded..0165029607 100644 --- a/tests/PhpWord/Tests/Element/PageBreakTest.php +++ b/tests/PhpWord/Tests/Element/PageBreakTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/PreserveTextTest.php b/tests/PhpWord/Tests/Element/PreserveTextTest.php index 29195e848d..be7a78cda0 100644 --- a/tests/PhpWord/Tests/Element/PreserveTextTest.php +++ b/tests/PhpWord/Tests/Element/PreserveTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/RowTest.php b/tests/PhpWord/Tests/Element/RowTest.php index c8eb7fcefd..6af674acfd 100644 --- a/tests/PhpWord/Tests/Element/RowTest.php +++ b/tests/PhpWord/Tests/Element/RowTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index f3fb336017..9624299c25 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; -use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Header; +use PhpOffice\PhpWord\Element\Section; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Style; /** diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index a976720c72..f3d4238163 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TableTest.php b/tests/PhpWord/Tests/Element/TableTest.php index 34f25c0e7c..b8325aca5f 100644 --- a/tests/PhpWord/Tests/Element/TableTest.php +++ b/tests/PhpWord/Tests/Element/TableTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextBreakTest.php b/tests/PhpWord/Tests/Element/TextBreakTest.php index 0c658f9404..1ef33c6b7a 100644 --- a/tests/PhpWord/Tests/Element/TextBreakTest.php +++ b/tests/PhpWord/Tests/Element/TextBreakTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 9101519fc6..7dfe4e636a 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TextTest.php b/tests/PhpWord/Tests/Element/TextTest.php index 746b4f5abf..212f531fa5 100644 --- a/tests/PhpWord/Tests/Element/TextTest.php +++ b/tests/PhpWord/Tests/Element/TextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 948d051e68..d4635f6f57 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; diff --git a/tests/PhpWord/Tests/EndnotesTest.php b/tests/PhpWord/Tests/EndnotesTest.php index 691cc5cd74..7217a1acc3 100644 --- a/tests/PhpWord/Tests/EndnotesTest.php +++ b/tests/PhpWord/Tests/EndnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Exception/ExceptionTest.php b/tests/PhpWord/Tests/Exception/ExceptionTest.php index b0f6c152d6..51338cd7d3 100644 --- a/tests/PhpWord/Tests/Exception/ExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/ExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php index edc4eb2cea..e6fe05d2d8 100644 --- a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php index 721a48912b..c20cde2c7b 100644 --- a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php index dc642fb4e4..5b1cc16857 100644 --- a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Exception; diff --git a/tests/PhpWord/Tests/FootnotesTest.php b/tests/PhpWord/Tests/FootnotesTest.php index cbab6ecc3a..5371273d39 100644 --- a/tests/PhpWord/Tests/FootnotesTest.php +++ b/tests/PhpWord/Tests/FootnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/IOFactoryTest.php b/tests/PhpWord/Tests/IOFactoryTest.php index 6bd21c57ed..8dc0c4518d 100644 --- a/tests/PhpWord/Tests/IOFactoryTest.php +++ b/tests/PhpWord/Tests/IOFactoryTest.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\IOFactory; +use PhpOffice\PhpWord\PhpWord; /** * Test class for PhpOffice\PhpWord\IOFactory diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 50806116be..013bf769cc 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -4,14 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\Media; -use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Image; +use PhpOffice\PhpWord\Media; /** * Test class for PhpOffice\PhpWord\Media diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index e2eef452ef..eddb6b23de 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -4,14 +4,14 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\Element\Section; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; /** diff --git a/tests/PhpWord/Tests/Reader/ODTextTest.php b/tests/PhpWord/Tests/Reader/ODTextTest.php index 6462148334..82f05cecb4 100644 --- a/tests/PhpWord/Tests/Reader/ODTextTest.php +++ b/tests/PhpWord/Tests/Reader/ODTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Reader; diff --git a/tests/PhpWord/Tests/Reader/Word2007Test.php b/tests/PhpWord/Tests/Reader/Word2007Test.php index d69e6a45f9..14ae625371 100644 --- a/tests/PhpWord/Tests/Reader/Word2007Test.php +++ b/tests/PhpWord/Tests/Reader/Word2007Test.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Reader; -use PhpOffice\PhpWord\Reader\Word2007; use PhpOffice\PhpWord\IOFactory; +use PhpOffice\PhpWord\Reader\Word2007; /** * Test class for PhpOffice\PhpWord\Reader\Word2007 diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index a312bae5ff..94fe74494c 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index cd85adf39f..2ae0217057 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/FontTest.php b/tests/PhpWord/Tests/Shared/FontTest.php index 8183051b03..c68aac12bc 100644 --- a/tests/PhpWord/Tests/Shared/FontTest.php +++ b/tests/PhpWord/Tests/Shared/FontTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/StringTest.php b/tests/PhpWord/Tests/Shared/StringTest.php index 6b00313193..362f3950c5 100644 --- a/tests/PhpWord/Tests/Shared/StringTest.php +++ b/tests/PhpWord/Tests/Shared/StringTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/XMLReaderTest.php b/tests/PhpWord/Tests/Shared/XMLReaderTest.php index 5cc96523c0..acbc78c283 100644 --- a/tests/PhpWord/Tests/Shared/XMLReaderTest.php +++ b/tests/PhpWord/Tests/Shared/XMLReaderTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php index d6a76995f4..d6fe9142aa 100644 --- a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php +++ b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; diff --git a/tests/PhpWord/Tests/Style/AbstractStyleTest.php b/tests/PhpWord/Tests/Style/AbstractStyleTest.php index ea72528d80..27bceaba71 100644 --- a/tests/PhpWord/Tests/Style/AbstractStyleTest.php +++ b/tests/PhpWord/Tests/Style/AbstractStyleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index 3838a36eea..7f12ce1c40 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 552c197fe7..ba7c99b2cb 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ImageTest.php b/tests/PhpWord/Tests/Style/ImageTest.php index 868d6c94bb..db2aeb5597 100644 --- a/tests/PhpWord/Tests/Style/ImageTest.php +++ b/tests/PhpWord/Tests/Style/ImageTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ListItemTest.php b/tests/PhpWord/Tests/Style/ListItemTest.php index 577aacdcc2..c6224d756f 100644 --- a/tests/PhpWord/Tests/Style/ListItemTest.php +++ b/tests/PhpWord/Tests/Style/ListItemTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/NumberingLevelTest.php b/tests/PhpWord/Tests/Style/NumberingLevelTest.php index 5ffdf83e0f..f41527002c 100644 --- a/tests/PhpWord/Tests/Style/NumberingLevelTest.php +++ b/tests/PhpWord/Tests/Style/NumberingLevelTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index c9d0794ff3..b51bd8ec16 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/RowTest.php b/tests/PhpWord/Tests/Style/RowTest.php index a8355a90f6..f7c4c593be 100644 --- a/tests/PhpWord/Tests/Style/RowTest.php +++ b/tests/PhpWord/Tests/Style/RowTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 90ea811bc4..f404fd53f9 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index 49bd5e680f..43537dbb10 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index 77733271a4..76fd686441 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/Style/TabsTest.php b/tests/PhpWord/Tests/Style/TabsTest.php index 08fabab324..1b588168f6 100644 --- a/tests/PhpWord/Tests/Style/TabsTest.php +++ b/tests/PhpWord/Tests/Style/TabsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Style; diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index 05d655ac5a..0738e72119 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/TOCTest.php b/tests/PhpWord/Tests/TOCTest.php index 4dd6a79a58..1db3e6f008 100644 --- a/tests/PhpWord/Tests/TOCTest.php +++ b/tests/PhpWord/Tests/TOCTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/PhpWord/Tests/TemplateTest.php b/tests/PhpWord/Tests/TemplateTest.php index 220c91b947..580f4f3d8e 100644 --- a/tests/PhpWord/Tests/TemplateTest.php +++ b/tests/PhpWord/Tests/TemplateTest.php @@ -4,12 +4,11 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Template; /** diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 06cd44bfc1..48ed689165 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php index f4c5cdb149..a2f5be98b0 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index 242eea8e03..cff6bfa22b 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Writer\ODText\Part\Content; use PhpOffice\PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Writer\ODText\Part\Content; /** * Test class for PhpOffice\PhpWord\Writer\ODText\Part\Content diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php index 71b28abf67..3e83396da3 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php index 18b162dd58..578671a180 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Part\ODText; diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index 4e26d6c63b..dc545fdc78 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php index d8d941e754..f597d463c5 100644 --- a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\PDF; diff --git a/tests/PhpWord/Tests/Writer/PDFTest.php b/tests/PhpWord/Tests/Writer/PDFTest.php index 797765795a..3e583d0f96 100644 --- a/tests/PhpWord/Tests/Writer/PDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index 9d07300887..f22dc0a6c8 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php index 18c908864a..6a8dc157a0 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php index 5d765c1b43..a483c2751a 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 9597e772e8..dd4665e244 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php index 9cb9eeb242..ac9f42c321 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php @@ -4,13 +4,12 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; -use PhpOffice\PhpWord\Writer\Word2007\Part\Footer; use PhpOffice\PhpWord\Writer\Word2007; -use PhpOffice\PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Writer\Word2007\Part\Footer; /** * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Footer diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php index 9a80c7801c..bf3e892af0 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php index 704f34968a..ebd4fe2b27 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php @@ -4,13 +4,12 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; -use PhpOffice\PhpWord\Writer\Word2007\Part\Header; use PhpOffice\PhpWord\Writer\Word2007; -use PhpOffice\PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Writer\Word2007\Part\Header; /** * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Header diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php index 7e4a59258d..4a43f106bb 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php @@ -4,15 +4,12 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; -use PhpOffice\PhpWord\Style\NumberingLevel; use PhpOffice\PhpWord\Tests\TestHelperDOCX; -use PhpOffice\PhpWord\Writer\Word2007\Part\Numbering; /** * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Numbering diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php index 440165e2b7..69f8993318 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Writer\Word2007\Part\Styles; use PhpOffice\PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Writer\Word2007\Part\Styles; /** * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Styles diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 924e3e3149..a297b16252 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Writer\Word2007; /** * Test class for PhpOffice\PhpWord\Writer\Word2007 diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index 84438e234d..cc91756dab 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -4,13 +4,13 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\IOFactory; +use PhpOffice\PhpWord\PhpWord; /** * Test helper class diff --git a/tests/PhpWord/Tests/_includes/XmlDocument.php b/tests/PhpWord/Tests/_includes/XmlDocument.php index 5e649385b5..cbea126468 100644 --- a/tests/PhpWord/Tests/_includes/XmlDocument.php +++ b/tests/PhpWord/Tests/_includes/XmlDocument.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e3dc8efc76..5f624df34a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ * * @link https://github.com/PHPOffice/PHPWord * @copyright 2014 PHPWord - * @license http://www.gnu.org/licenses/lgpl.txt LGPL + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ date_default_timezone_set('UTC'); From aba15481c8d6e11c00e4715b233b9c9f2cc0e6d0 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 22:34:37 +0200 Subject: [PATCH 020/167] Corrected typo to 'const POSITION_HORIZONTAL_CENTER = 'center';' and added examples to Sample_13 --- samples/Sample_13_Images.php | 31 +++++++++++++++++++++++++++++++ src/PhpWord/Style/Image.php | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 784230650d..dd5209bf6d 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -31,6 +31,37 @@ $section->addText($text); } +//Absolute positioning +$section->addTextBreak(3); +$section->addText('Absolute positioning: see top right corner of page'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1.55) + ) +); + +//Relative positioning +$section->addTextBreak(3); +$section->addText('Relative positioning: Horizontal position center relative to column,'); +$section->addText('Vertical position top relative to line'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE, + 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, + 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN, + 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE + ) +); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 4dbfa5f4d0..9274b0c9a4 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -31,7 +31,7 @@ class Image extends AbstractStyle * @const string */ const POSITION_HORIZONTAL_LEFT = 'left'; - const POSITION_HORIZONTAL_CENTER = 'centered'; + const POSITION_HORIZONTAL_CENTER = 'center'; const POSITION_HORIZONTAL_RIGHT = 'right'; /** From 11b39411037bd28b6cab79dc5f7711076076c901 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 4 May 2014 22:48:17 +0200 Subject: [PATCH 021/167] Fixed a bug, that when a second header was added to a section, all images added to the second header were assigned to the first header, resulting in at least a corrupted DOCX. --- src/PhpWord/Element/AbstractContainer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 2970f02fdf..a533d8d6f0 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -355,7 +355,7 @@ private function checkElementDocPart() $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - + $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; return $inHeaderFooter ? $docPart . $docPartId : $docPart; } From 6dd51c54ea21055f058f84e5a02b8ea4975ec144 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 5 May 2014 09:08:15 +0700 Subject: [PATCH 022/167] Update changelog and add sample for bug fix #222 --- CHANGELOG.md | 2 +- samples/Sample_12_HeaderFooter.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 794c47ee4e..5e8f09d5bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. ### Bugfixes -- ... +- Header: All images added to the second header were assigned to the first header - @basjan GH-222 ### Deprecated diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 8e05328697..0fd56edc0a 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -25,6 +25,7 @@ // Add header for all other pages $subsequent = $section->addHeader(); $subsequent->addText("Subsequent pages in Section 1 will Have this!"); +$subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80)); // Add footer $footer = $section->addFooter(); From 61b5f6800c04d479845b62628d63f76b54aeb3ca Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 5 May 2014 10:14:33 +0400 Subject: [PATCH 023/167] [CHANGED] References to ISO/IEC 29500 spec were documented. --- docs/references.rst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/references.rst b/docs/references.rst index 4f19a8173a..d327ab6019 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -3,18 +3,28 @@ References ========== +ISO/IEC 29500, Third edition, 2012-09-01 +--------------------- + +- `Part 1: Fundamentals and Markup Language Reference + `__ +- `Part 2: Open Packaging Conventions + `__ +- `Part 3: Markup Compatibility and Extensibility + `__ +- `Part 4: Transitional Migration Features + `__ + Formal specifications --------------------- -- `Office Open XML (OOXML) (ECMA-376) - Schema `__ - `Oasis OpenDocument Standard Version - 1.2 `__ + 1.2 `__ - `Rich Text Format (RTF) Specification, version - 1.9.1 `__ + 1.9.1 `__ Other resources --------------- - `DocumentFormat.OpenXml.Wordprocessing Namespace on - MSDN `__ + MSDN `__ From 4194dd46c0f9d41231af79a2dc435301818d05e0 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 5 May 2014 10:18:08 +0400 Subject: [PATCH 024/167] [CHANGED] References to ISO/IEC 29500 spec were documented. --- docs/references.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/references.rst b/docs/references.rst index d327ab6019..20aa1ed061 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -7,24 +7,24 @@ ISO/IEC 29500, Third edition, 2012-09-01 --------------------- - `Part 1: Fundamentals and Markup Language Reference - `__ + `__ - `Part 2: Open Packaging Conventions - `__ + `__ - `Part 3: Markup Compatibility and Extensibility - `__ + `__ - `Part 4: Transitional Migration Features - `__ + `__ Formal specifications --------------------- - `Oasis OpenDocument Standard Version - 1.2 `__ + 1.2 `__ - `Rich Text Format (RTF) Specification, version - 1.9.1 `__ + 1.9.1 `__ Other resources --------------- - `DocumentFormat.OpenXml.Wordprocessing Namespace on - MSDN `__ + MSDN `__ From 8c9890fe0dd44ae71e87b2eec24605bd2957247e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 5 May 2014 10:37:34 +0400 Subject: [PATCH 025/167] [FIXED] License in "composer.json". --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20aca17b52..8396f07375 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "homepage": "http://phpoffice.github.io", "type": "library", - "license": "LGPL", + "license": "LGPL-3.0", "authors": [ { "name": "Mark Baker" From 105e53b1cd538a62f25286b75b055d695f5788ab Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 5 May 2014 09:49:15 +0200 Subject: [PATCH 026/167] #154 : Ignore PCLZip in PHPDocumentor --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65b9de9aa7..5db4c37369 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ script: ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/* + - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" after_script: ## PHPDocumentor From ec0de298d928711a82dda6cbd55d6f6676be692d Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 5 May 2014 10:35:21 +0200 Subject: [PATCH 027/167] #154 : Change template for PHPDocumentor --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5db4c37369..41e3bebb25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ script: ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" + - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" --template="responsive-twig" after_script: ## PHPDocumentor From 89f94b793dc47e0317bbee65860ea647b10983be Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 5 May 2014 12:38:31 +0400 Subject: [PATCH 028/167] [CHANGED] https://github.com/PHPOffice/PHPWord/pull/179 - copyright info has been changed. --- src/PhpWord/Autoloader.php | 2 +- src/PhpWord/Collection/AbstractCollection.php | 2 +- src/PhpWord/Collection/Endnotes.php | 2 +- src/PhpWord/Collection/Footnotes.php | 2 +- src/PhpWord/Collection/Titles.php | 2 +- src/PhpWord/DocumentProperties.php | 2 +- src/PhpWord/Element/AbstractContainer.php | 9 +-------- src/PhpWord/Element/AbstractElement.php | 2 +- src/PhpWord/Element/Cell.php | 2 +- src/PhpWord/Element/CheckBox.php | 2 +- src/PhpWord/Element/Endnote.php | 2 +- src/PhpWord/Element/Footer.php | 4 +--- src/PhpWord/Element/Footnote.php | 2 +- src/PhpWord/Element/Header.php | 2 +- src/PhpWord/Element/Image.php | 2 +- src/PhpWord/Element/Link.php | 2 +- src/PhpWord/Element/ListItem.php | 2 +- src/PhpWord/Element/Object.php | 4 ++-- src/PhpWord/Element/PageBreak.php | 2 +- src/PhpWord/Element/PreserveText.php | 2 +- src/PhpWord/Element/Row.php | 2 +- src/PhpWord/Element/Section.php | 6 +----- src/PhpWord/Element/TOC.php | 2 +- src/PhpWord/Element/Table.php | 2 +- src/PhpWord/Element/Text.php | 2 +- src/PhpWord/Element/TextBreak.php | 2 +- src/PhpWord/Element/TextRun.php | 2 +- src/PhpWord/Element/Title.php | 4 ++-- src/PhpWord/Exception/Exception.php | 2 +- src/PhpWord/Exception/InvalidImageException.php | 2 +- src/PhpWord/Exception/InvalidObjectException.php | 2 +- src/PhpWord/Exception/InvalidStyleException.php | 2 +- src/PhpWord/Exception/UnsupportedImageTypeException.php | 2 +- src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Media.php | 2 +- src/PhpWord/PhpWord.php | 4 +--- src/PhpWord/Reader/AbstractReader.php | 2 +- src/PhpWord/Reader/ODText.php | 2 +- src/PhpWord/Reader/ODText/AbstractPart.php | 2 +- src/PhpWord/Reader/ODText/Content.php | 2 +- src/PhpWord/Reader/ReaderInterface.php | 2 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsApp.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCustom.php | 2 +- src/PhpWord/Reader/Word2007/Document.php | 2 +- src/PhpWord/Reader/Word2007/Endnotes.php | 2 +- src/PhpWord/Reader/Word2007/Footnotes.php | 2 +- src/PhpWord/Reader/Word2007/Notes.php | 2 +- src/PhpWord/Reader/Word2007/Numbering.php | 2 +- src/PhpWord/Reader/Word2007/Styles.php | 2 +- src/PhpWord/Settings.php | 2 +- src/PhpWord/Shared/Drawing.php | 2 +- src/PhpWord/Shared/Font.php | 2 +- src/PhpWord/Shared/String.php | 2 +- src/PhpWord/Shared/XMLReader.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Shared/ZipArchive.php | 2 +- src/PhpWord/Style.php | 2 +- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Border.php | 2 +- src/PhpWord/Style/Cell.php | 2 +- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Style/Image.php | 2 +- src/PhpWord/Style/Indentation.php | 2 +- src/PhpWord/Style/LineNumbering.php | 2 +- src/PhpWord/Style/ListItem.php | 2 +- src/PhpWord/Style/Numbering.php | 2 +- src/PhpWord/Style/NumberingLevel.php | 2 +- src/PhpWord/Style/Paragraph.php | 2 +- src/PhpWord/Style/Row.php | 2 +- src/PhpWord/Style/Section.php | 2 +- src/PhpWord/Style/Shading.php | 2 +- src/PhpWord/Style/Spacing.php | 2 +- src/PhpWord/Style/TOC.php | 2 +- src/PhpWord/Style/Tab.php | 2 +- src/PhpWord/Style/Table.php | 2 +- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 2 +- src/PhpWord/Writer/HTML.php | 4 ++-- src/PhpWord/Writer/HTML/Element/Element.php | 2 +- src/PhpWord/Writer/HTML/Element/Endnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 2 +- src/PhpWord/Writer/HTML/Element/Image.php | 2 +- src/PhpWord/Writer/HTML/Element/Link.php | 2 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 2 +- src/PhpWord/Writer/HTML/Element/PageBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/Table.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 2 +- src/PhpWord/Writer/HTML/Element/TextBreak.php | 2 +- src/PhpWord/Writer/HTML/Element/TextRun.php | 2 +- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- src/PhpWord/Writer/HTML/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/HTML/Style/Generic.php | 2 +- src/PhpWord/Writer/HTML/Style/Image.php | 2 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 2 +- src/PhpWord/Writer/ODText.php | 2 +- src/PhpWord/Writer/ODText/Element/Element.php | 2 +- src/PhpWord/Writer/ODText/Element/Image.php | 2 +- src/PhpWord/Writer/ODText/Element/Link.php | 2 +- src/PhpWord/Writer/ODText/Element/Table.php | 2 +- src/PhpWord/Writer/ODText/Element/Text.php | 2 +- src/PhpWord/Writer/ODText/Element/TextBreak.php | 2 +- src/PhpWord/Writer/ODText/Element/TextRun.php | 2 +- src/PhpWord/Writer/ODText/Part/AbstractPart.php | 4 ++-- src/PhpWord/Writer/ODText/Part/Content.php | 4 ++-- src/PhpWord/Writer/ODText/Part/Manifest.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 2 +- src/PhpWord/Writer/ODText/Part/Mimetype.php | 2 +- src/PhpWord/Writer/ODText/Part/Styles.php | 2 +- src/PhpWord/Writer/ODText/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/ODText/Style/Font.php | 2 +- src/PhpWord/Writer/ODText/Style/Paragraph.php | 2 +- src/PhpWord/Writer/PDF.php | 2 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 2 +- src/PhpWord/Writer/PDF/DomPDF.php | 2 +- src/PhpWord/Writer/RTF.php | 2 +- src/PhpWord/Writer/RTF/Element/Element.php | 2 +- src/PhpWord/Writer/RTF/Element/Text.php | 4 ++-- src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 2 +- src/PhpWord/Writer/RTF/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007.php | 2 +- src/PhpWord/Writer/Word2007/Element/CheckBox.php | 2 +- src/PhpWord/Writer/Word2007/Element/Element.php | 2 +- src/PhpWord/Writer/Word2007/Element/Endnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Image.php | 2 +- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- src/PhpWord/Writer/Word2007/Element/ListItem.php | 2 +- src/PhpWord/Writer/Word2007/Element/Object.php | 2 +- src/PhpWord/Writer/Word2007/Element/PageBreak.php | 2 +- src/PhpWord/Writer/Word2007/Element/PreserveText.php | 2 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 2 +- src/PhpWord/Writer/Word2007/Element/Text.php | 2 +- src/PhpWord/Writer/Word2007/Element/TextBreak.php | 2 +- src/PhpWord/Writer/Word2007/Element/TextRun.php | 2 +- src/PhpWord/Writer/Word2007/Element/Title.php | 2 +- src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 2 +- src/PhpWord/Writer/Word2007/Part/ContentTypes.php | 2 +- src/PhpWord/Writer/Word2007/Part/DocProps.php | 2 +- src/PhpWord/Writer/Word2007/Part/Document.php | 2 +- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 2 +- src/PhpWord/Writer/Word2007/Part/FontTable.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footnotes.php | 2 +- src/PhpWord/Writer/Word2007/Part/Header.php | 2 +- src/PhpWord/Writer/Word2007/Part/Numbering.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 2 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Theme.php | 2 +- src/PhpWord/Writer/Word2007/Part/WebSettings.php | 2 +- src/PhpWord/Writer/Word2007/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 2 +- src/PhpWord/Writer/Word2007/Style/Font.php | 2 +- src/PhpWord/Writer/Word2007/Style/Image.php | 2 +- src/PhpWord/Writer/Word2007/Style/Indentation.php | 2 +- src/PhpWord/Writer/Word2007/Style/LineNumbering.php | 2 +- src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 2 +- src/PhpWord/Writer/Word2007/Style/Paragraph.php | 2 +- src/PhpWord/Writer/Word2007/Style/Section.php | 2 +- src/PhpWord/Writer/Word2007/Style/Shading.php | 2 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 2 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 2 +- src/PhpWord/Writer/WriterInterface.php | 2 +- tests/PhpWord/Tests/AutoloaderTest.php | 2 +- tests/PhpWord/Tests/DocumentPropertiesTest.php | 2 +- tests/PhpWord/Tests/Element/AbstractElementTest.php | 2 +- tests/PhpWord/Tests/Element/CellTest.php | 2 +- tests/PhpWord/Tests/Element/CheckBoxTest.php | 2 +- tests/PhpWord/Tests/Element/FooterTest.php | 2 +- tests/PhpWord/Tests/Element/FootnoteTest.php | 2 +- tests/PhpWord/Tests/Element/HeaderTest.php | 2 +- tests/PhpWord/Tests/Element/ImageTest.php | 2 +- tests/PhpWord/Tests/Element/LinkTest.php | 2 +- tests/PhpWord/Tests/Element/ListItemTest.php | 2 +- tests/PhpWord/Tests/Element/ObjectTest.php | 2 +- tests/PhpWord/Tests/Element/PageBreakTest.php | 2 +- tests/PhpWord/Tests/Element/PreserveTextTest.php | 2 +- tests/PhpWord/Tests/Element/RowTest.php | 2 +- tests/PhpWord/Tests/Element/SectionTest.php | 2 +- tests/PhpWord/Tests/Element/TOCTest.php | 4 ++-- tests/PhpWord/Tests/Element/TableTest.php | 2 +- tests/PhpWord/Tests/Element/TextBreakTest.php | 2 +- tests/PhpWord/Tests/Element/TextRunTest.php | 4 ++-- tests/PhpWord/Tests/Element/TextTest.php | 2 +- tests/PhpWord/Tests/Element/TitleTest.php | 2 +- tests/PhpWord/Tests/Exception/ExceptionTest.php | 2 +- .../Tests/Exception/InvalidImageExceptionTest.php | 2 +- .../Tests/Exception/InvalidStyleExceptionTest.php | 2 +- .../Exception/UnsupportedImageTypeExceptionTest.php | 2 +- tests/PhpWord/Tests/IOFactoryTest.php | 2 +- tests/PhpWord/Tests/MediaTest.php | 2 +- tests/PhpWord/Tests/PhpWordTest.php | 3 +-- tests/PhpWord/Tests/Reader/ODTextTest.php | 2 +- tests/PhpWord/Tests/Reader/Word2007Test.php | 2 +- tests/PhpWord/Tests/SettingsTest.php | 2 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- tests/PhpWord/Tests/Shared/FontTest.php | 3 +-- tests/PhpWord/Tests/Shared/StringTest.php | 2 +- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 2 +- tests/PhpWord/Tests/Shared/ZipArchiveTest.php | 2 +- tests/PhpWord/Tests/Style/AbstractStyleTest.php | 2 +- tests/PhpWord/Tests/Style/CellTest.php | 2 +- tests/PhpWord/Tests/Style/FontTest.php | 2 +- tests/PhpWord/Tests/Style/ImageTest.php | 2 +- tests/PhpWord/Tests/Style/ListItemTest.php | 2 +- tests/PhpWord/Tests/Style/NumberingLevelTest.php | 2 +- tests/PhpWord/Tests/Style/ParagraphTest.php | 2 +- tests/PhpWord/Tests/Style/RowTest.php | 2 +- tests/PhpWord/Tests/Style/SectionTest.php | 2 +- tests/PhpWord/Tests/Style/TOCTest.php | 2 +- tests/PhpWord/Tests/Style/TableTest.php | 2 +- tests/PhpWord/Tests/Style/TabsTest.php | 2 +- tests/PhpWord/Tests/StyleTest.php | 2 +- tests/PhpWord/Tests/TemplateTest.php | 2 +- tests/PhpWord/Tests/Writer/HTMLTest.php | 2 +- .../Tests/Writer/ODText/Part/AbstractPartTest.php | 2 +- tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php | 2 +- tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php | 2 +- tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php | 2 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 2 +- tests/PhpWord/Tests/Writer/PDFTest.php | 2 +- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- .../Tests/Writer/Word2007/Part/AbstractPartTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php | 2 +- .../PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- tests/PhpWord/Tests/_includes/TestHelperDOCX.php | 2 +- tests/PhpWord/Tests/_includes/XmlDocument.php | 2 +- tests/bootstrap.php | 2 +- 242 files changed, 252 insertions(+), 269 deletions(-) diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index 0688ffda57..5363732fdb 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Collection/AbstractCollection.php b/src/PhpWord/Collection/AbstractCollection.php index 7b5d4579bc..e2042a6e58 100644 --- a/src/PhpWord/Collection/AbstractCollection.php +++ b/src/PhpWord/Collection/AbstractCollection.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ diff --git a/src/PhpWord/Collection/Endnotes.php b/src/PhpWord/Collection/Endnotes.php index 36c547a320..34e9a50a91 100644 --- a/src/PhpWord/Collection/Endnotes.php +++ b/src/PhpWord/Collection/Endnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ diff --git a/src/PhpWord/Collection/Footnotes.php b/src/PhpWord/Collection/Footnotes.php index 488955aa70..1f2f9aba77 100644 --- a/src/PhpWord/Collection/Footnotes.php +++ b/src/PhpWord/Collection/Footnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ diff --git a/src/PhpWord/Collection/Titles.php b/src/PhpWord/Collection/Titles.php index 01256d23fd..18b681ffba 100644 --- a/src/PhpWord/Collection/Titles.php +++ b/src/PhpWord/Collection/Titles.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index eb928dc17d..6620c9df42 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index a533d8d6f0..36ec81f2d7 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -3,19 +3,12 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Element\CheckBox; -use PhpOffice\PhpWord\Element\Image; -use PhpOffice\PhpWord\Element\Link; -use PhpOffice\PhpWord\Element\ListItem; -use PhpOffice\PhpWord\Element\Object; -use PhpOffice\PhpWord\Element\TextBreak; -use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\PhpWord; diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 9c0a48c49a..8b8fd908ba 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index 2a6eab44df..21ed42b524 100644 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index e47a8342c5..75f4a7d307 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php index db6b1d54e0..32f14bb8ff 100644 --- a/src/PhpWord/Element/Endnote.php +++ b/src/PhpWord/Element/Endnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 77f36f6bfb..3ad9401221 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -3,14 +3,12 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Element\Table; - /** * Footer element */ diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index 79117d0adb..9454acf810 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index db0d2d6b64..d11c986be9 100644 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 0d90479ff0..7b750944c2 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 4b09fab7fe..a371b2b98d 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 74af97b5af..c5e455565f 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 3b249cb727..04726c5faa 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -3,14 +3,14 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Style\Image as ImageStyle; use PhpOffice\PhpWord\Exception\InvalidObjectException; +use PhpOffice\PhpWord\Style\Image as ImageStyle; /** * Object element diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php index 6cf78e99e3..4e2b0caf45 100644 --- a/src/PhpWord/Element/PageBreak.php +++ b/src/PhpWord/Element/PageBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 90bddb6fe0..dd7b275a8c 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index 85ffb6acf0..4a85676390 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index af253f034b..11c57cec50 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -3,16 +3,12 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Element\PageBreak; -use PhpOffice\PhpWord\Element\TOC; -use PhpOffice\PhpWord\Element\Table; -use PhpOffice\PhpWord\Element\Title; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Section as SectionSettings; diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index 3c8e6386e8..8d68615935 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL */ diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index faa2c0f0b6..03c9d01f2f 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index b79a82e34d..70a7d182c9 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index d8157c02d4..6053d92e34 100644 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index 3eff554bdd..13145168b1 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index c80cc86be2..59ffdd63a0 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -3,14 +3,14 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Style; /** * Title element diff --git a/src/PhpWord/Exception/Exception.php b/src/PhpWord/Exception/Exception.php index 1c27d55e08..adc48e271b 100644 --- a/src/PhpWord/Exception/Exception.php +++ b/src/PhpWord/Exception/Exception.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Exception/InvalidImageException.php b/src/PhpWord/Exception/InvalidImageException.php index 6cf4de0da5..649ef44ea9 100644 --- a/src/PhpWord/Exception/InvalidImageException.php +++ b/src/PhpWord/Exception/InvalidImageException.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Exception/InvalidObjectException.php b/src/PhpWord/Exception/InvalidObjectException.php index 44884989fd..a538281612 100644 --- a/src/PhpWord/Exception/InvalidObjectException.php +++ b/src/PhpWord/Exception/InvalidObjectException.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Exception/InvalidStyleException.php b/src/PhpWord/Exception/InvalidStyleException.php index e05a296805..501d301710 100644 --- a/src/PhpWord/Exception/InvalidStyleException.php +++ b/src/PhpWord/Exception/InvalidStyleException.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Exception/UnsupportedImageTypeException.php b/src/PhpWord/Exception/UnsupportedImageTypeException.php index a038ba4e6b..a5f8e38b75 100644 --- a/src/PhpWord/Exception/UnsupportedImageTypeException.php +++ b/src/PhpWord/Exception/UnsupportedImageTypeException.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 6845b2cefb..4ff23c5292 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 1ddef41902..b1a4d942fe 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index cac3ada376..633fb3cf09 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ @@ -12,11 +12,9 @@ use PhpOffice\PhpWord\Collection\Endnotes; use PhpOffice\PhpWord\Collection\Footnotes; use PhpOffice\PhpWord\Collection\Titles; -use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Template; /** * PHPWord main class diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 3cd1e1e4f3..b70590e9f7 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index 7bb6485021..fd930d00fe 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 32799c72fc..d142011ab3 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index c5fe7b2253..f05adb6836 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php index 7b291e4e48..d8f520e50b 100644 --- a/src/PhpWord/Reader/ReaderInterface.php +++ b/src/PhpWord/Reader/ReaderInterface.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 914177a315..f11ae4270c 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 32377b54e4..9670033fde 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php index f3af8a7f00..351d4c8abc 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsApp.php +++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index 18b142e29f..ca60586473 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 8b107beb47..e602bdd220 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 40257d97e8..354ace8680 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php index 9c4c10402f..489ffbc0b6 100644 --- a/src/PhpWord/Reader/Word2007/Endnotes.php +++ b/src/PhpWord/Reader/Word2007/Endnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index ba27853b81..f98f7df551 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php index a213b7f154..b0b4732040 100644 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ b/src/PhpWord/Reader/Word2007/Notes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index a45614924a..afd1c1aeb1 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index aeb8806d39..bceaa7acd2 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 5d357d19f0..02aedd10f7 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index cac0b8f44c..bf988bcb6d 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php index 3831dff356..ff371c9211 100644 --- a/src/PhpWord/Shared/Font.php +++ b/src/PhpWord/Shared/Font.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index e4dacf6dc8..ed0730444b 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 6f491c8d00..555068f346 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 2a763ed3c6..52a012ef37 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 3747436215..d6fcc113af 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 93197418f2..d5fff49946 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index ea0c85fdf2..e6b32f6ef7 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index 33d4fe0fdf..4d51b84f66 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 74e1e51941..a5d930b5ba 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index dde54413e2..20dbb7bae5 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 9274b0c9a4..579853b798 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -4,7 +4,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php index f564df0baa..bf6e557384 100644 --- a/src/PhpWord/Style/Indentation.php +++ b/src/PhpWord/Style/Indentation.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php index f230634db1..d40d96c969 100644 --- a/src/PhpWord/Style/LineNumbering.php +++ b/src/PhpWord/Style/LineNumbering.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 4cdb0623a4..a5e70f0e35 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php index 88503964d6..7de49e454c 100644 --- a/src/PhpWord/Style/Numbering.php +++ b/src/PhpWord/Style/Numbering.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index d6fc364906..67f51391e4 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 874ff1df15..dab0e27a0c 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index bd0d35d9f3..5c03a934ca 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index 4bff700701..18f7321881 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php index a83d17fedf..d62a9a89b6 100644 --- a/src/PhpWord/Style/Shading.php +++ b/src/PhpWord/Style/Shading.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index 609ef5a058..3a4fc9594e 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 0c16ccc633..8bd2f758b8 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index 6e44eeade9..126034c135 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 8306f78bf3..54dd185a56 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index bdc000c47f..eb1357e660 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index f5315697e9..5de7189983 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index b8d9e87bd1..5d97f872a9 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ @@ -12,9 +12,9 @@ use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\HTML\Element\Element as ElementWriter; use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter; diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index a24364e3ef..03e1273ee4 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php index 60f078e312..3b54c3782b 100644 --- a/src/PhpWord/Writer/HTML/Element/Endnote.php +++ b/src/PhpWord/Writer/HTML/Element/Endnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index 713878cac2..098c40d39f 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index ca5847ee06..81c6f49489 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 9df76a1a7e..f53b01a207 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 54b014dbab..5923debf09 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index c0f5c564aa..310d2e018e 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index 3938a160b5..6ef094c458 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 242645eedd..1343d11631 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php index 5dee7a0ee2..c178b32380 100644 --- a/src/PhpWord/Writer/HTML/Element/TextBreak.php +++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index 22cf657fd6..8c500faffe 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index fa3ff09924..5e89e4cdf6 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index 0b978f7a6c..60d19f3418 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index c858694e36..b16053f68f 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php index e840dfb3a6..2045ce519f 100644 --- a/src/PhpWord/Writer/HTML/Style/Generic.php +++ b/src/PhpWord/Writer/HTML/Style/Generic.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index dcd7e8c201..2ce18c0dc3 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index a095a30831..54c5b648cc 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index 7b7b9c1a43..b7744bfe4a 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/Element.php b/src/PhpWord/Writer/ODText/Element/Element.php index 81ee1a6475..e6f88f5b24 100644 --- a/src/PhpWord/Writer/ODText/Element/Element.php +++ b/src/PhpWord/Writer/ODText/Element/Element.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index 03fe5a4ed1..feebcddadf 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 21431109d5..073d8b471c 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 5839a07c9f..47f4b3b4b4 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index bedc212ff9..60a1d8421b 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/TextBreak.php b/src/PhpWord/Writer/ODText/Element/TextBreak.php index 8670866af4..c68a6edcd4 100644 --- a/src/PhpWord/Writer/ODText/Element/TextBreak.php +++ b/src/PhpWord/Writer/ODText/Element/TextBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php index 9854c61eed..231f34a128 100644 --- a/src/PhpWord/Writer/ODText/Element/TextRun.php +++ b/src/PhpWord/Writer/ODText/Element/TextRun.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index 448597666f..a822856c64 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ @@ -11,8 +11,8 @@ use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; /** * ODText writer part abstract diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 49f3c40299..c7d54bbbd9 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ @@ -15,9 +15,9 @@ use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; /** diff --git a/src/PhpWord/Writer/ODText/Part/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php index ebfd2b5920..aedb1af60a 100644 --- a/src/PhpWord/Writer/ODText/Part/Manifest.php +++ b/src/PhpWord/Writer/ODText/Part/Manifest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index 032d03e8bd..d09555f250 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Part/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php index a8ededbb2e..983f247549 100644 --- a/src/PhpWord/Writer/ODText/Part/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index bfc8f7c521..7a1d804be3 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php index 4f28de4a0d..9d441cb636 100644 --- a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 7e72dcb668..17ad52e7a4 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index 3aaac86526..41a62d63d3 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index e668bc770d..a77f05e28a 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PhpWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index 3500acceb4..fdeb214833 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PhpWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index 2239b4167e..ed0b9eb662 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PhpWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 8bef6629d5..41fcb83c79 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index d50f1c8fc3..aa62ff47bf 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index d4e29eec3c..f45ad7025d 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -3,15 +3,15 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; /** * Text element RTF writer diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index 7a813ad1fe..fa1d8bf6e8 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 970d049afe..6184f47607 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 54767637e6..8ff24d534e 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index be91dd8544..aaa3b93fe1 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index edc0e0ebc8..d7a9a7cbe3 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/Element.php index 8ebbf79c23..2ec9adfd05 100644 --- a/src/PhpWord/Writer/Word2007/Element/Element.php +++ b/src/PhpWord/Writer/Word2007/Element/Element.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Endnote.php b/src/PhpWord/Writer/Word2007/Element/Endnote.php index bd5bf80222..6957090045 100644 --- a/src/PhpWord/Writer/Word2007/Element/Endnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Endnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 5f149b124b..fffab3d902 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index dcee63a58f..22f9dc34e4 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 7ec937f881..da86b85fa6 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index 14544fd74a..10d6a46598 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index c8e4d68638..64dcc0bd59 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index 912f59dbfe..5687ca9c3d 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index 4a2f1268fc..797266b0f8 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index ff23fa00e7..cb4161b735 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 3c659e34a2..e44cf51e37 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 716c625d90..49768a2ab5 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 67219f94eb..071283e6ac 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index 6ed058aa95..f8e7bb8669 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 025b95d3c0..b45e1581db 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index 29c004c62e..9bcbe8fef7 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 24df901146..c7499df7b8 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/DocProps.php b/src/PhpWord/Writer/Word2007/Part/DocProps.php index c489f74a79..8178263ac5 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocProps.php +++ b/src/PhpWord/Writer/Word2007/Part/DocProps.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index a12623b044..ad925f257e 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php index 86782b31b0..1dafe3cea8 100644 --- a/src/PhpWord/Writer/Word2007/Part/Endnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php index deb3c09fbf..1b02bbb4ab 100644 --- a/src/PhpWord/Writer/Word2007/Part/FontTable.php +++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index e30a2ea975..1d4eecffa7 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 05bf17d190..ec463656d0 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php index 1ff30e74c3..44936c0171 100644 --- a/src/PhpWord/Writer/Word2007/Part/Header.php +++ b/src/PhpWord/Writer/Word2007/Part/Header.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 723a043f90..bc7a74fb64 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -3,15 +3,15 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Writer\Word2007\Part; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\NumberingLevel; -use PhpOffice\PhpWord\Style; /** * Word2007 numbering part writer diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index bccb945438..249fccb4ec 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index 994a1747d9..037a17a577 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index adabd89ab5..13a0ea2bea 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ @@ -12,10 +12,10 @@ use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Table; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Theme.php b/src/PhpWord/Writer/Word2007/Part/Theme.php index 081c3b6853..2322b26b29 100644 --- a/src/PhpWord/Writer/Word2007/Part/Theme.php +++ b/src/PhpWord/Writer/Word2007/Part/Theme.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php index 7c22e9f00c..397ef8bf57 100644 --- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php +++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index ab0e4d3358..2812742001 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index 544ae40db1..e52de275bc 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index c62510d0bd..a9e72a35f2 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index 2983c50543..4291a6204d 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index 6fb5689775..8badd69438 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index 84b3933ea9..b7ddc314e3 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 92c10fd1ed..629c37a1ce 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 993ec6a0d7..6363944cf6 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index 66dde75130..ea898bb32a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index adbb19d4b2..def81000ca 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index c6e1343629..ad9e780fdd 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index 2536025369..e8a4a4f314 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index e57e4cd61c..2478bf2ce4 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/src/PhpWord/Writer/WriterInterface.php b/src/PhpWord/Writer/WriterInterface.php index 3bc0c38da8..7de96d33b6 100644 --- a/src/PhpWord/Writer/WriterInterface.php +++ b/src/PhpWord/Writer/WriterInterface.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/AutoloaderTest.php b/tests/PhpWord/Tests/AutoloaderTest.php index 75b273ecd0..253443ae09 100644 --- a/tests/PhpWord/Tests/AutoloaderTest.php +++ b/tests/PhpWord/Tests/AutoloaderTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/DocumentPropertiesTest.php b/tests/PhpWord/Tests/DocumentPropertiesTest.php index 20545c1ec3..1711b185a7 100644 --- a/tests/PhpWord/Tests/DocumentPropertiesTest.php +++ b/tests/PhpWord/Tests/DocumentPropertiesTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/AbstractElementTest.php b/tests/PhpWord/Tests/Element/AbstractElementTest.php index 9308fe20d9..17e6c22465 100644 --- a/tests/PhpWord/Tests/Element/AbstractElementTest.php +++ b/tests/PhpWord/Tests/Element/AbstractElementTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index a1ef6e3682..d258ae88e6 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/CheckBoxTest.php b/tests/PhpWord/Tests/Element/CheckBoxTest.php index 8c09e478f8..ede3e70752 100644 --- a/tests/PhpWord/Tests/Element/CheckBoxTest.php +++ b/tests/PhpWord/Tests/Element/CheckBoxTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/FooterTest.php b/tests/PhpWord/Tests/Element/FooterTest.php index 9eea65b29a..0acc0cc667 100644 --- a/tests/PhpWord/Tests/Element/FooterTest.php +++ b/tests/PhpWord/Tests/Element/FooterTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/FootnoteTest.php b/tests/PhpWord/Tests/Element/FootnoteTest.php index 40128ce475..27ee8f1591 100644 --- a/tests/PhpWord/Tests/Element/FootnoteTest.php +++ b/tests/PhpWord/Tests/Element/FootnoteTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/HeaderTest.php b/tests/PhpWord/Tests/Element/HeaderTest.php index 5bc9c5d5c9..50f351a484 100644 --- a/tests/PhpWord/Tests/Element/HeaderTest.php +++ b/tests/PhpWord/Tests/Element/HeaderTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index 28b3946e85..858ac765d7 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/LinkTest.php b/tests/PhpWord/Tests/Element/LinkTest.php index 9e54593d66..264e55308f 100644 --- a/tests/PhpWord/Tests/Element/LinkTest.php +++ b/tests/PhpWord/Tests/Element/LinkTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/ListItemTest.php b/tests/PhpWord/Tests/Element/ListItemTest.php index a3ab3d2d8f..9dd38e2f54 100644 --- a/tests/PhpWord/Tests/Element/ListItemTest.php +++ b/tests/PhpWord/Tests/Element/ListItemTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/ObjectTest.php b/tests/PhpWord/Tests/Element/ObjectTest.php index 8d92f4afb1..725588b810 100644 --- a/tests/PhpWord/Tests/Element/ObjectTest.php +++ b/tests/PhpWord/Tests/Element/ObjectTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/PageBreakTest.php b/tests/PhpWord/Tests/Element/PageBreakTest.php index 0165029607..cf9de8ab2e 100644 --- a/tests/PhpWord/Tests/Element/PageBreakTest.php +++ b/tests/PhpWord/Tests/Element/PageBreakTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/PreserveTextTest.php b/tests/PhpWord/Tests/Element/PreserveTextTest.php index be7a78cda0..b64ac0dc1a 100644 --- a/tests/PhpWord/Tests/Element/PreserveTextTest.php +++ b/tests/PhpWord/Tests/Element/PreserveTextTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/RowTest.php b/tests/PhpWord/Tests/Element/RowTest.php index 6af674acfd..d098d847fc 100644 --- a/tests/PhpWord/Tests/Element/RowTest.php +++ b/tests/PhpWord/Tests/Element/RowTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index 49e6a9fe7f..b606b4539d 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index 854670cb27..14841b7b21 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -3,15 +3,15 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\Title; use PhpOffice\PhpWord\Element\TOC; +use PhpOffice\PhpWord\PhpWord; /** * Test class for PhpOffice\PhpWord\Element\TOC diff --git a/tests/PhpWord/Tests/Element/TableTest.php b/tests/PhpWord/Tests/Element/TableTest.php index b8325aca5f..3ea668f0bc 100644 --- a/tests/PhpWord/Tests/Element/TableTest.php +++ b/tests/PhpWord/Tests/Element/TableTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/TextBreakTest.php b/tests/PhpWord/Tests/Element/TextBreakTest.php index 1ef33c6b7a..55d9874ea4 100644 --- a/tests/PhpWord/Tests/Element/TextBreakTest.php +++ b/tests/PhpWord/Tests/Element/TextBreakTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 9ce44543fd..83a331cfe7 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -3,14 +3,14 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Element; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Element\TextRun; +use PhpOffice\PhpWord\PhpWord; /** * Test class for PhpOffice\PhpWord\Element\TextRun diff --git a/tests/PhpWord/Tests/Element/TextTest.php b/tests/PhpWord/Tests/Element/TextTest.php index 212f531fa5..06c1c12c80 100644 --- a/tests/PhpWord/Tests/Element/TextTest.php +++ b/tests/PhpWord/Tests/Element/TextTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 5236398064..760db2794b 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Exception/ExceptionTest.php b/tests/PhpWord/Tests/Exception/ExceptionTest.php index 51338cd7d3..1eae339b03 100644 --- a/tests/PhpWord/Tests/Exception/ExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/ExceptionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php index e6fe05d2d8..b5b4cdf1bc 100644 --- a/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidImageExceptionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php index c20cde2c7b..45e1b3f9ed 100644 --- a/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/InvalidStyleExceptionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php index 5b1cc16857..badda87d08 100644 --- a/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php +++ b/tests/PhpWord/Tests/Exception/UnsupportedImageTypeExceptionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/IOFactoryTest.php b/tests/PhpWord/Tests/IOFactoryTest.php index 8dc0c4518d..32881a6515 100644 --- a/tests/PhpWord/Tests/IOFactoryTest.php +++ b/tests/PhpWord/Tests/IOFactoryTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 013bf769cc..a3fa62e432 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index ae82b1fee4..6f85fc3248 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -3,14 +3,13 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests; use PhpOffice\PhpWord\DocumentProperties; -use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; diff --git a/tests/PhpWord/Tests/Reader/ODTextTest.php b/tests/PhpWord/Tests/Reader/ODTextTest.php index 82f05cecb4..6b59208c63 100644 --- a/tests/PhpWord/Tests/Reader/ODTextTest.php +++ b/tests/PhpWord/Tests/Reader/ODTextTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Reader/Word2007Test.php b/tests/PhpWord/Tests/Reader/Word2007Test.php index 14ae625371..76190c6b81 100644 --- a/tests/PhpWord/Tests/Reader/Word2007Test.php +++ b/tests/PhpWord/Tests/Reader/Word2007Test.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 2bb16fce01..56522efff0 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 2d95810f25..898c5ef893 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Shared/FontTest.php b/tests/PhpWord/Tests/Shared/FontTest.php index f41de0bfd9..b605434c36 100644 --- a/tests/PhpWord/Tests/Shared/FontTest.php +++ b/tests/PhpWord/Tests/Shared/FontTest.php @@ -3,13 +3,12 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Shared; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\Font; /** diff --git a/tests/PhpWord/Tests/Shared/StringTest.php b/tests/PhpWord/Tests/Shared/StringTest.php index 362f3950c5..722c1cbdf1 100644 --- a/tests/PhpWord/Tests/Shared/StringTest.php +++ b/tests/PhpWord/Tests/Shared/StringTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Shared/XMLReaderTest.php b/tests/PhpWord/Tests/Shared/XMLReaderTest.php index acbc78c283..3fc9b636b8 100644 --- a/tests/PhpWord/Tests/Shared/XMLReaderTest.php +++ b/tests/PhpWord/Tests/Shared/XMLReaderTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php index d6fe9142aa..29c3d072ec 100644 --- a/tests/PhpWord/Tests/Shared/ZipArchiveTest.php +++ b/tests/PhpWord/Tests/Shared/ZipArchiveTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/AbstractStyleTest.php b/tests/PhpWord/Tests/Style/AbstractStyleTest.php index 27bceaba71..592f3fc558 100644 --- a/tests/PhpWord/Tests/Style/AbstractStyleTest.php +++ b/tests/PhpWord/Tests/Style/AbstractStyleTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index a3a7e03084..b103c83106 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index ba7c99b2cb..f10751ccf7 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/ImageTest.php b/tests/PhpWord/Tests/Style/ImageTest.php index db2aeb5597..44f2e7904e 100644 --- a/tests/PhpWord/Tests/Style/ImageTest.php +++ b/tests/PhpWord/Tests/Style/ImageTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/ListItemTest.php b/tests/PhpWord/Tests/Style/ListItemTest.php index c6224d756f..1e769fc621 100644 --- a/tests/PhpWord/Tests/Style/ListItemTest.php +++ b/tests/PhpWord/Tests/Style/ListItemTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/NumberingLevelTest.php b/tests/PhpWord/Tests/Style/NumberingLevelTest.php index f41527002c..442770f706 100644 --- a/tests/PhpWord/Tests/Style/NumberingLevelTest.php +++ b/tests/PhpWord/Tests/Style/NumberingLevelTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index b51bd8ec16..d16e297e67 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/RowTest.php b/tests/PhpWord/Tests/Style/RowTest.php index f7c4c593be..d2e2781b54 100644 --- a/tests/PhpWord/Tests/Style/RowTest.php +++ b/tests/PhpWord/Tests/Style/RowTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index f404fd53f9..24c834a831 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index fd2a809e0d..ce1c118bcc 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index 76fd686441..14dc59b618 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Style/TabsTest.php b/tests/PhpWord/Tests/Style/TabsTest.php index 1b588168f6..58e7b729e7 100644 --- a/tests/PhpWord/Tests/Style/TabsTest.php +++ b/tests/PhpWord/Tests/Style/TabsTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index 0738e72119..0f2262049f 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/TemplateTest.php b/tests/PhpWord/Tests/TemplateTest.php index 580f4f3d8e..a56b1cb028 100644 --- a/tests/PhpWord/Tests/TemplateTest.php +++ b/tests/PhpWord/Tests/TemplateTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 48ed689165..0c0481c63a 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php index a2f5be98b0..829caf71fa 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index cff6bfa22b..c4e4ad7083 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php index 3e83396da3..8fe66c8b55 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part; diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php index 578671a180..98e4f2b2e4 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Part\ODText; diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index 2e68374c9e..4437a68029 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php index ff01edb34e..4c14fc842b 100644 --- a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\PDF; diff --git a/tests/PhpWord/Tests/Writer/PDFTest.php b/tests/PhpWord/Tests/Writer/PDFTest.php index b164392f3f..6c6cf1b584 100644 --- a/tests/PhpWord/Tests/Writer/PDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDFTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index f22dc0a6c8..b89391572b 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php index 6a8dc157a0..25c48c2736 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php index a483c2751a..cedc95e413 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 8286473bd5..0890324e0b 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php index ac9f42c321..6b9d286dcf 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php index bf3e892af0..70cd4ad37f 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php index ebd4fe2b27..601e75ffa6 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php index 4a43f106bb..da884d8796 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php index 69f8993318..3ef39ca706 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 1d4687f1af..ee05fc574b 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ namespace PhpOffice\PhpWord\Tests\Writer; diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index cc91756dab..f726c76866 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/PhpWord/Tests/_includes/XmlDocument.php b/tests/PhpWord/Tests/_includes/XmlDocument.php index cbea126468..36f34db631 100644 --- a/tests/PhpWord/Tests/_includes/XmlDocument.php +++ b/tests/PhpWord/Tests/_includes/XmlDocument.php @@ -3,7 +3,7 @@ * PHPWord * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5f624df34a..8aad78c380 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,7 +3,7 @@ * PHPWord test bootstrap * * @link https://github.com/PHPOffice/PHPWord - * @copyright 2014 PHPWord + * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ From 2add5541ce982b69ceae92a1dbc2d67072342b96 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 5 May 2014 13:06:53 +0400 Subject: [PATCH 029/167] [CHANGED] https://github.com/PHPOffice/PHPWord/pull/179 - copyright notice has been added. --- src/PhpWord/Autoloader.php | 10 +++++++++- src/PhpWord/Collection/AbstractCollection.php | 10 +++++++++- src/PhpWord/Collection/Endnotes.php | 10 +++++++++- src/PhpWord/Collection/Footnotes.php | 10 +++++++++- src/PhpWord/Collection/Titles.php | 10 +++++++++- src/PhpWord/DocumentProperties.php | 10 +++++++++- src/PhpWord/Element/AbstractContainer.php | 10 +++++++++- src/PhpWord/Element/AbstractElement.php | 20 +++++++++++++++++-- src/PhpWord/Element/Cell.php | 10 +++++++++- src/PhpWord/Element/CheckBox.php | 10 +++++++++- src/PhpWord/Element/Endnote.php | 10 +++++++++- src/PhpWord/Element/Footer.php | 10 +++++++++- src/PhpWord/Element/Footnote.php | 10 +++++++++- src/PhpWord/Element/Header.php | 10 +++++++++- src/PhpWord/Element/Image.php | 10 +++++++++- src/PhpWord/Element/Link.php | 10 +++++++++- src/PhpWord/Element/ListItem.php | 10 +++++++++- src/PhpWord/Element/Object.php | 10 +++++++++- src/PhpWord/Element/PageBreak.php | 10 +++++++++- src/PhpWord/Element/PreserveText.php | 10 +++++++++- src/PhpWord/Element/Row.php | 10 +++++++++- src/PhpWord/Element/Section.php | 10 +++++++++- src/PhpWord/Element/TOC.php | 10 +++++++++- src/PhpWord/Element/Table.php | 10 +++++++++- src/PhpWord/Element/Text.php | 10 +++++++++- src/PhpWord/Element/TextBreak.php | 10 +++++++++- src/PhpWord/Element/TextRun.php | 10 +++++++++- src/PhpWord/Element/Title.php | 10 +++++++++- src/PhpWord/Exception/Exception.php | 10 +++++++++- .../Exception/InvalidImageException.php | 10 +++++++++- .../Exception/InvalidObjectException.php | 10 +++++++++- .../Exception/InvalidStyleException.php | 10 +++++++++- .../UnsupportedImageTypeException.php | 10 +++++++++- src/PhpWord/IOFactory.php | 10 +++++++++- src/PhpWord/Media.php | 10 +++++++++- src/PhpWord/PhpWord.php | 10 +++++++++- src/PhpWord/Reader/AbstractReader.php | 10 +++++++++- src/PhpWord/Reader/ODText.php | 10 +++++++++- src/PhpWord/Reader/ODText/AbstractPart.php | 10 +++++++++- src/PhpWord/Reader/ODText/Content.php | 10 +++++++++- src/PhpWord/Reader/ReaderInterface.php | 10 +++++++++- src/PhpWord/Reader/Word2007.php | 10 +++++++++- src/PhpWord/Reader/Word2007/AbstractPart.php | 10 +++++++++- src/PhpWord/Reader/Word2007/DocPropsApp.php | 10 +++++++++- src/PhpWord/Reader/Word2007/DocPropsCore.php | 10 +++++++++- .../Reader/Word2007/DocPropsCustom.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Document.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Endnotes.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Footnotes.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Notes.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Numbering.php | 10 +++++++++- src/PhpWord/Reader/Word2007/Styles.php | 10 +++++++++- src/PhpWord/Settings.php | 10 +++++++++- src/PhpWord/Shared/Drawing.php | 10 +++++++++- src/PhpWord/Shared/Font.php | 10 +++++++++- src/PhpWord/Shared/String.php | 10 +++++++++- src/PhpWord/Shared/XMLReader.php | 10 +++++++++- src/PhpWord/Shared/XMLWriter.php | 10 +++++++++- src/PhpWord/Shared/ZipArchive.php | 10 +++++++++- src/PhpWord/Style.php | 10 +++++++++- src/PhpWord/Style/AbstractStyle.php | 10 +++++++++- src/PhpWord/Style/Border.php | 10 +++++++++- src/PhpWord/Style/Cell.php | 10 +++++++++- src/PhpWord/Style/Font.php | 10 +++++++++- src/PhpWord/Style/Image.php | 11 ++++++++-- src/PhpWord/Style/Indentation.php | 10 +++++++++- src/PhpWord/Style/LineNumbering.php | 10 +++++++++- src/PhpWord/Style/ListItem.php | 10 +++++++++- src/PhpWord/Style/Numbering.php | 10 +++++++++- src/PhpWord/Style/NumberingLevel.php | 10 +++++++++- src/PhpWord/Style/Paragraph.php | 10 +++++++++- src/PhpWord/Style/Row.php | 10 +++++++++- src/PhpWord/Style/Section.php | 10 +++++++++- src/PhpWord/Style/Shading.php | 10 +++++++++- src/PhpWord/Style/Spacing.php | 10 +++++++++- src/PhpWord/Style/TOC.php | 10 +++++++++- src/PhpWord/Style/Tab.php | 10 +++++++++- src/PhpWord/Style/Table.php | 10 +++++++++- src/PhpWord/Template.php | 10 +++++++++- src/PhpWord/Writer/AbstractWriter.php | 10 +++++++++- src/PhpWord/Writer/HTML.php | 12 +++++++++-- src/PhpWord/Writer/HTML/Element/Element.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Endnote.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Footnote.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Image.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Link.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/ListItem.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/PageBreak.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Table.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Text.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/TextBreak.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/TextRun.php | 10 +++++++++- src/PhpWord/Writer/HTML/Element/Title.php | 10 +++++++++- .../Writer/HTML/Style/AbstractStyle.php | 10 +++++++++- src/PhpWord/Writer/HTML/Style/Font.php | 10 +++++++++- src/PhpWord/Writer/HTML/Style/Generic.php | 10 +++++++++- src/PhpWord/Writer/HTML/Style/Image.php | 10 +++++++++- src/PhpWord/Writer/HTML/Style/Paragraph.php | 10 +++++++++- src/PhpWord/Writer/ODText.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/Element.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/Image.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/Link.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/Table.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/Text.php | 10 +++++++++- .../Writer/ODText/Element/TextBreak.php | 10 +++++++++- src/PhpWord/Writer/ODText/Element/TextRun.php | 10 +++++++++- .../Writer/ODText/Part/AbstractPart.php | 12 +++++++++-- src/PhpWord/Writer/ODText/Part/Content.php | 12 +++++++++-- src/PhpWord/Writer/ODText/Part/Manifest.php | 10 +++++++++- src/PhpWord/Writer/ODText/Part/Meta.php | 10 +++++++++- src/PhpWord/Writer/ODText/Part/Mimetype.php | 10 +++++++++- src/PhpWord/Writer/ODText/Part/Styles.php | 10 +++++++++- .../Writer/ODText/Style/AbstractStyle.php | 10 +++++++++- src/PhpWord/Writer/ODText/Style/Font.php | 10 +++++++++- src/PhpWord/Writer/ODText/Style/Paragraph.php | 10 +++++++++- src/PhpWord/Writer/PDF.php | 10 +++++++++- src/PhpWord/Writer/PDF/AbstractRenderer.php | 10 +++++++++- src/PhpWord/Writer/PDF/DomPDF.php | 10 +++++++++- src/PhpWord/Writer/RTF.php | 10 +++++++++- src/PhpWord/Writer/RTF/Element/Element.php | 10 +++++++++- src/PhpWord/Writer/RTF/Element/Text.php | 12 +++++++++-- src/PhpWord/Writer/RTF/Element/TextBreak.php | 10 +++++++++- src/PhpWord/Writer/RTF/Element/TextRun.php | 10 +++++++++- src/PhpWord/Writer/RTF/Element/Title.php | 10 +++++++++- src/PhpWord/Writer/Word2007.php | 10 +++++++++- .../Writer/Word2007/Element/CheckBox.php | 10 +++++++++- .../Writer/Word2007/Element/Element.php | 10 +++++++++- .../Writer/Word2007/Element/Endnote.php | 10 +++++++++- .../Writer/Word2007/Element/Footnote.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/Image.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/Link.php | 10 +++++++++- .../Writer/Word2007/Element/ListItem.php | 10 +++++++++- .../Writer/Word2007/Element/Object.php | 10 +++++++++- .../Writer/Word2007/Element/PageBreak.php | 10 +++++++++- .../Writer/Word2007/Element/PreserveText.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/TOC.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/Table.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/Text.php | 10 +++++++++- .../Writer/Word2007/Element/TextBreak.php | 10 +++++++++- .../Writer/Word2007/Element/TextRun.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Element/Title.php | 10 +++++++++- .../Writer/Word2007/Part/AbstractPart.php | 10 +++++++++- .../Writer/Word2007/Part/ContentTypes.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/DocProps.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Document.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 10 +++++++++- .../Writer/Word2007/Part/FontTable.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Footer.php | 10 +++++++++- .../Writer/Word2007/Part/Footnotes.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Header.php | 10 +++++++++- .../Writer/Word2007/Part/Numbering.php | 12 +++++++++-- src/PhpWord/Writer/Word2007/Part/Rels.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Settings.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Part/Styles.php | 12 +++++++++-- src/PhpWord/Writer/Word2007/Part/Theme.php | 10 +++++++++- .../Writer/Word2007/Part/WebSettings.php | 10 +++++++++- .../Writer/Word2007/Style/AbstractStyle.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Cell.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Font.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Image.php | 10 +++++++++- .../Writer/Word2007/Style/Indentation.php | 10 +++++++++- .../Writer/Word2007/Style/LineNumbering.php | 10 +++++++++- .../Writer/Word2007/Style/MarginBorder.php | 10 +++++++++- .../Writer/Word2007/Style/Paragraph.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Section.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Shading.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Spacing.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Tab.php | 10 +++++++++- src/PhpWord/Writer/Word2007/Style/Table.php | 10 +++++++++- src/PhpWord/Writer/WriterInterface.php | 10 +++++++++- tests/PhpWord/Tests/AutoloaderTest.php | 10 +++++++++- .../PhpWord/Tests/DocumentPropertiesTest.php | 10 +++++++++- .../Tests/Element/AbstractElementTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/CellTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/CheckBoxTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/FooterTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/FootnoteTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/HeaderTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/ImageTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/LinkTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/ListItemTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/ObjectTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/PageBreakTest.php | 10 +++++++++- .../Tests/Element/PreserveTextTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/RowTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/SectionTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TOCTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TableTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TextBreakTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TextRunTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TextTest.php | 10 +++++++++- tests/PhpWord/Tests/Element/TitleTest.php | 10 +++++++++- .../PhpWord/Tests/Exception/ExceptionTest.php | 10 +++++++++- .../Exception/InvalidImageExceptionTest.php | 10 +++++++++- .../Exception/InvalidStyleExceptionTest.php | 10 +++++++++- .../UnsupportedImageTypeExceptionTest.php | 10 +++++++++- tests/PhpWord/Tests/IOFactoryTest.php | 10 +++++++++- tests/PhpWord/Tests/MediaTest.php | 10 +++++++++- tests/PhpWord/Tests/PhpWordTest.php | 10 +++++++++- tests/PhpWord/Tests/Reader/ODTextTest.php | 10 +++++++++- tests/PhpWord/Tests/Reader/Word2007Test.php | 10 +++++++++- tests/PhpWord/Tests/SettingsTest.php | 10 +++++++++- tests/PhpWord/Tests/Shared/DrawingTest.php | 10 +++++++++- tests/PhpWord/Tests/Shared/FontTest.php | 10 +++++++++- tests/PhpWord/Tests/Shared/StringTest.php | 10 +++++++++- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 10 +++++++++- tests/PhpWord/Tests/Shared/ZipArchiveTest.php | 10 +++++++++- .../PhpWord/Tests/Style/AbstractStyleTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/CellTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/FontTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/ImageTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/ListItemTest.php | 10 +++++++++- .../Tests/Style/NumberingLevelTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/ParagraphTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/RowTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/SectionTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/TOCTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/TableTest.php | 10 +++++++++- tests/PhpWord/Tests/Style/TabsTest.php | 10 +++++++++- tests/PhpWord/Tests/StyleTest.php | 10 +++++++++- tests/PhpWord/Tests/TemplateTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/HTMLTest.php | 10 +++++++++- .../Writer/ODText/Part/AbstractPartTest.php | 10 +++++++++- .../Tests/Writer/ODText/Part/ContentTest.php | 10 +++++++++- .../Tests/Writer/ODText/Part/MetaTest.php | 10 +++++++++- .../Tests/Writer/ODText/Part/StylesTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/ODTextTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/PDFTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/RTFTest.php | 10 +++++++++- .../Writer/Word2007/Part/AbstractPartTest.php | 10 +++++++++- .../Writer/Word2007/Part/DocPropsTest.php | 10 +++++++++- .../Writer/Word2007/Part/DocumentTest.php | 10 +++++++++- .../Tests/Writer/Word2007/Part/FooterTest.php | 10 +++++++++- .../Writer/Word2007/Part/FootnotesTest.php | 10 +++++++++- .../Tests/Writer/Word2007/Part/HeaderTest.php | 10 +++++++++- .../Writer/Word2007/Part/NumberingTest.php | 10 +++++++++- .../Tests/Writer/Word2007/Part/StylesTest.php | 10 +++++++++- tests/PhpWord/Tests/Writer/Word2007Test.php | 10 +++++++++- .../Tests/_includes/TestHelperDOCX.php | 10 +++++++++- tests/PhpWord/Tests/_includes/XmlDocument.php | 10 +++++++++- tests/bootstrap.php | 10 +++++++++- 242 files changed, 2193 insertions(+), 250 deletions(-) diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index 5363732fdb..6acfff21e5 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -1,6 +1,14 @@ Date: Mon, 5 May 2014 18:57:54 +0700 Subject: [PATCH 030/167] QA: Additional unit testing and template scrutinizer config file --- .scrutinizer.yml | 13 ++++ src/PhpWord/Style/Shading.php | 23 ++++++- src/PhpWord/Style/TOC.php | 10 ++- src/PhpWord/Style/Table.php | 2 + .../Tests/Collection/CollectionTest.php | 40 ++++++++++++ tests/PhpWord/Tests/Element/TOCTest.php | 11 ++++ tests/PhpWord/Tests/Style/IndentationTest.php | 53 ++++++++++++++++ .../PhpWord/Tests/Style/LineNumberingTest.php | 53 ++++++++++++++++ tests/PhpWord/Tests/Style/NumberingTest.php | 61 +++++++++++++++++++ tests/PhpWord/Tests/Style/ShadingTest.php | 52 ++++++++++++++++ tests/PhpWord/Tests/Style/SpacingTest.php | 53 ++++++++++++++++ tests/PhpWord/Tests/Style/TOCTest.php | 28 +++++---- tests/PhpWord/Tests/Style/TabTest.php | 52 ++++++++++++++++ tests/PhpWord/Tests/Style/TableTest.php | 3 + tests/PhpWord/Tests/Style/TabsTest.php | 55 ----------------- 15 files changed, 435 insertions(+), 74 deletions(-) create mode 100644 .scrutinizer.yml create mode 100644 tests/PhpWord/Tests/Collection/CollectionTest.php create mode 100644 tests/PhpWord/Tests/Style/IndentationTest.php create mode 100644 tests/PhpWord/Tests/Style/LineNumberingTest.php create mode 100644 tests/PhpWord/Tests/Style/NumberingTest.php create mode 100644 tests/PhpWord/Tests/Style/ShadingTest.php create mode 100644 tests/PhpWord/Tests/Style/SpacingTest.php create mode 100644 tests/PhpWord/Tests/Style/TabTest.php delete mode 100644 tests/PhpWord/Tests/Style/TabsTest.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000000..dd558b8e98 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,13 @@ +filter: + excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ] + +before_commands: + - "composer install --prefer-source --dev" + +tools: + php_code_coverage: + enabled: true + test_command: phpunit -c phpunit.xml.dist + php_sim: true + php_pdepend: true + php_analyzer: true diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php index 677e55d589..3e970e6e0b 100644 --- a/src/PhpWord/Style/Shading.php +++ b/src/PhpWord/Style/Shading.php @@ -25,20 +25,34 @@ */ class Shading extends AbstractStyle { + /** + * Pattern constants (partly) + * + * @const string + * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html + */ + const PATTERN_CLEAR = 'clear'; // No pattern + const PATTERN_SOLID = 'solid'; // 100% fill pattern + const PATTERN_HSTRIPE = 'horzStripe'; // Horizontal stripe pattern + const PATTERN_VSTRIPE = 'vertStripe'; // Vertical stripe pattern + const PATTERN_DSTRIPE = 'diagStripe'; // Diagonal stripe pattern + const PATTERN_HCROSS = 'horzCross'; // Horizontal cross pattern + const PATTERN_DCROSS = 'diagCross'; // Diagonal cross pattern + /** * Shading pattern * * @var string * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html */ - private $pattern = 'clear'; + private $pattern = self::PATTERN_CLEAR; /** * Shading pattern color * * @var string */ - private $color = 'auto'; + private $color; /** * Shading background color @@ -75,7 +89,10 @@ public function getPattern() */ public function setPattern($value = null) { - $this->pattern = $value; + $enum = array(self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE, + self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS); + + $this->pattern = $this->setEnumVal($value, $enum, $this->pattern); return $this; } diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 75a20f6aa7..13a7029449 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -22,6 +22,12 @@ */ class TOC extends Tab { + /** + * Tab leader types for backward compatibility + * + * @const string + * @deprecated 0.11.0 + */ const TABLEADER_DOT = self::TAB_LEADER_DOT; const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE; const TABLEADER_LINE = self::TAB_LEADER_HYPHEN; @@ -32,8 +38,7 @@ class TOC extends Tab * * @var int */ - private $indent; - + private $indent = 200; /** * Create a new TOC Style @@ -41,7 +46,6 @@ class TOC extends Tab public function __construct() { parent::__construct(self::TAB_STOP_RIGHT, 9062, self::TABLEADER_DOT); - $this->indent = 200; } /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 5ffd557a42..7aa108bfed 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -143,6 +143,8 @@ public function getBgColor() { if (!is_null($this->shading)) { return $this->shading->getFill(); + } else { + return null; } } diff --git a/tests/PhpWord/Tests/Collection/CollectionTest.php b/tests/PhpWord/Tests/Collection/CollectionTest.php new file mode 100644 index 0000000000..e3d08da276 --- /dev/null +++ b/tests/PhpWord/Tests/Collection/CollectionTest.php @@ -0,0 +1,40 @@ +addItem(new Footnote()); // addItem #1 + + $this->assertEquals(2, $object->addItem(new Footnote())); // addItem #2. Should returns new item index + $this->assertEquals(2, $object->countItems()); // There are two items now + $this->assertEquals(2, count($object->getItems())); // getItems returns array + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $object->getItem(1)); // getItem returns object + $this->assertNull($object->getItem(3)); // getItem returns null when invalid index is referenced + + $object->setItem(2, null); // Set item #2 to null + + $this->assertNull($object->getItem(2)); // Check if it's null + } +} diff --git a/tests/PhpWord/Tests/Element/TOCTest.php b/tests/PhpWord/Tests/Element/TOCTest.php index eaa61c2f7c..d0ebf343fe 100644 --- a/tests/PhpWord/Tests/Element/TOCTest.php +++ b/tests/PhpWord/Tests/Element/TOCTest.php @@ -61,6 +61,17 @@ public function testConstructWithStyleName() $this->assertEquals('Font Style', $object->getStyleFont()); } + /** + * Test when no PHPWord object is assigned: + */ + public function testNoPhpWord() + { + $object = new TOC(); + + $this->assertEmpty($object->getTitles()); + $this->assertNull($object->getPhpWord()); + } + /** * Set/get minDepth and maxDepth */ diff --git a/tests/PhpWord/Tests/Style/IndentationTest.php b/tests/PhpWord/Tests/Style/IndentationTest.php new file mode 100644 index 0000000000..d0e88f2cb2 --- /dev/null +++ b/tests/PhpWord/Tests/Style/IndentationTest.php @@ -0,0 +1,53 @@ + array(0, 10), + 'right' => array(0, 10), + 'firstLine' => array(null, 20), + 'hanging' => array(null, 20), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/LineNumberingTest.php b/tests/PhpWord/Tests/Style/LineNumberingTest.php new file mode 100644 index 0000000000..bc4dc603f3 --- /dev/null +++ b/tests/PhpWord/Tests/Style/LineNumberingTest.php @@ -0,0 +1,53 @@ + array(1, 2), + 'increment' => array(1, 10), + 'distance' => array(null, 10), + 'restart' => array(null, 'continuous'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/NumberingTest.php b/tests/PhpWord/Tests/Style/NumberingTest.php new file mode 100644 index 0000000000..e15753576b --- /dev/null +++ b/tests/PhpWord/Tests/Style/NumberingTest.php @@ -0,0 +1,61 @@ +object = new Numbering(); + $this->properties = array( + 'numId' => array(null, 1), + 'type' => array(null, 'singleLevel'), + ); + foreach ($this->properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $this->object->$get()); // Default value + + $this->object->$set($expected); + + $this->assertEquals($expected, $this->object->$get()); // New value + } + } + + /** + * Test get level + */ + public function testGetLevels() + { + $this->object = new Numbering(); + + $this->assertEmpty($this->object->getLevels()); + } +} diff --git a/tests/PhpWord/Tests/Style/ShadingTest.php b/tests/PhpWord/Tests/Style/ShadingTest.php new file mode 100644 index 0000000000..5a965e1d10 --- /dev/null +++ b/tests/PhpWord/Tests/Style/ShadingTest.php @@ -0,0 +1,52 @@ + array('clear', 'solid'), + 'color' => array(null, 'FF0000'), + 'fill' => array(null, 'FF0000'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/SpacingTest.php b/tests/PhpWord/Tests/Style/SpacingTest.php new file mode 100644 index 0000000000..a4022b74bd --- /dev/null +++ b/tests/PhpWord/Tests/Style/SpacingTest.php @@ -0,0 +1,53 @@ + array(null, 10), + 'after' => array(null, 10), + 'line' => array(null, 10), + 'rule' => array('auto', 'exact'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index b70ed1bbec..e6e32e6b9d 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -23,28 +23,30 @@ * Test class for PhpOffice\PhpWord\Style\TOC * * @coversDefaultClass \PhpOffice\PhpWord\Style\TOC - * @runTestsInSeparateProcesses */ class TOCTest extends \PHPUnit_Framework_TestCase { /** - * Test properties with normal value + * Test get/set */ - public function testProperties() + public function testGetSet() { $object = new TOC(); - $properties = array( - 'position' => 9062, - 'leader' => \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_DOT, - 'indent' => 200, + 'tabLeader' => array(TOC::TAB_LEADER_DOT, TOC::TAB_LEADER_UNDERSCORE), + 'tabPos' => array(9062, 10), + 'indent' => array(200, 10), ); - foreach ($properties as $key => $value) { - // set/get - $set = "set{$key}"; - $get = "get{$key}"; - $object->$set($value); - $this->assertEquals($value, $object->$get()); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value } } } diff --git a/tests/PhpWord/Tests/Style/TabTest.php b/tests/PhpWord/Tests/Style/TabTest.php new file mode 100644 index 0000000000..784b4e4709 --- /dev/null +++ b/tests/PhpWord/Tests/Style/TabTest.php @@ -0,0 +1,52 @@ + array(Tab::TAB_STOP_CLEAR, Tab::TAB_STOP_RIGHT), + 'leader' => array(Tab::TAB_LEADER_NONE, Tab::TAB_LEADER_DOT), + 'position' => array(0, 10), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index 6ae2f35ccc..a7b46c1f48 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -38,6 +38,9 @@ public function testConstruct() $styleTable = array('bgColor' => 'FF0000'); $styleFirstRow = array('borderBottomSize' => 3); + $object = new Table(); + $this->assertNull($object->getBgColor()); + $object = new Table($styleTable, $styleFirstRow); $this->assertEquals('FF0000', $object->getBgColor()); diff --git a/tests/PhpWord/Tests/Style/TabsTest.php b/tests/PhpWord/Tests/Style/TabsTest.php deleted file mode 100644 index 94f6c90016..0000000000 --- a/tests/PhpWord/Tests/Style/TabsTest.php +++ /dev/null @@ -1,55 +0,0 @@ -addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); - $doc = TestHelperDOCX::getDocument($phpWord); - $file = 'word/styles.xml'; - $path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]'; - $element = $doc->getElement($path, $file); - $this->assertEquals('left', $element->getAttribute('w:val')); - $this->assertEquals(1440, $element->getAttribute('w:pos')); - $this->assertEquals('dot', $element->getAttribute('w:leader')); - } -} From 061ba4bfb2133a5cd79d599a3e3bb0bc4ad36685 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 5 May 2014 19:26:21 +0700 Subject: [PATCH 031/167] Including `composer.lock` to enable Scrutinizer test https://scrutinizer-ci.com/docs/tools/php/php-analyzer/guides/composer_dependencies --- .gitignore | 1 - .scrutinizer.yml | 1 + composer.lock | 3107 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 3108 insertions(+), 1 deletion(-) create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index eb0f06791d..016060632c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ .Trashes Thumbs.db Desktop.ini -composer.lock composer.phar phpunit.xml /.buildpath diff --git a/.scrutinizer.yml b/.scrutinizer.yml index dd558b8e98..0b0464f7b0 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -2,6 +2,7 @@ filter: excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ] before_commands: + - "composer self-update" - "composer install --prefer-source --dev" tools: diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000000..6d63264a83 --- /dev/null +++ b/composer.lock @@ -0,0 +1,3107 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "6daefa91649add98af3850b0a3f13415", + "packages": [ + + ], + "packages-dev": [ + { + "name": "cilex/cilex", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/Cilex/Cilex.git", + "reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Cilex/Cilex/zipball/7acd965a609a56d0345e8b6071c261fbdb926cb5", + "reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5", + "shasum": "" + }, + "require": { + "cilex/console-service-provider": "1.*", + "php": ">=5.3.3", + "pimple/pimple": "~1.0", + "symfony/finder": "~2.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "symfony/validator": "~2.1" + }, + "suggest": { + "monolog/monolog": ">=1.0.0", + "symfony/validator": ">=1.0.0", + "symfony/yaml": ">=1.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Cilex": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "description": "The PHP micro-framework for Command line tools based on the Symfony2 Components", + "homepage": "http://cilex.github.com", + "keywords": [ + "cli", + "microframework" + ], + "time": "2014-03-29 14:03:13" + }, + { + "name": "cilex/console-service-provider", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Cilex/console-service-provider.git", + "reference": "25ee3d1875243d38e1a3448ff94bdf944f70d24e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Cilex/console-service-provider/zipball/25ee3d1875243d38e1a3448ff94bdf944f70d24e", + "reference": "25ee3d1875243d38e1a3448ff94bdf944f70d24e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "pimple/pimple": "1.*@dev", + "symfony/console": "~2.1" + }, + "require-dev": { + "cilex/cilex": "1.*@dev", + "silex/silex": "1.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Cilex\\Provider\\Console": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Beau Simensen", + "email": "beau@dflydev.com", + "homepage": "http://beausimensen.com" + }, + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "description": "Console Service Provider", + "keywords": [ + "cilex", + "console", + "pimple", + "service-provider", + "silex" + ], + "time": "2012-12-19 10:50:58" + }, + { + "name": "doctrine/annotations", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/40db0c96985aab2822edbc4848b3bd2429e02670", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan H. Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2013-06-16 21:33:03" + }, + { + "name": "doctrine/lexer", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2013-01-12 18:59:04" + }, + { + "name": "dompdf/dompdf", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "cf7d8a0a27270418850cc7d7ea532159e5eeb3eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/cf7d8a0a27270418850cc7d7ea532159e5eeb3eb", + "reference": "cf7d8a0a27270418850cc7d7ea532159e5eeb3eb", + "shasum": "" + }, + "require": { + "phenx/php-font-lib": "0.2.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "include/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Fabien Ménager", + "email": "fabien.menager@gmail.com" + }, + { + "name": "Brian Sweeney", + "email": "eclecticgeek@gmail.com" + } + ], + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "time": "2014-03-11 01:59:52" + }, + { + "name": "erusev/parsedown", + "version": "0.9.4", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown.git", + "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/d29ff18299210b52a75a631a70963e7c8b35b04f", + "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "time": "2014-02-06 12:16:14" + }, + { + "name": "jms/metadata", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/metadata.git", + "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/88ffa28bc987e4c26229fc84a2e541b6ed4e1459", + "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "doctrine/cache": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Metadata\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Class/method/property metadata management in PHP", + "keywords": [ + "annotations", + "metadata", + "xml", + "yaml" + ], + "time": "2013-11-05 23:02:36" + }, + { + "name": "jms/parser-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/parser-lib.git", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "shasum": "" + }, + "require": { + "phpoption/phpoption": ">=0.9,<2.0-dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "description": "A library for easily creating recursive-descent parsers.", + "time": "2012-11-18 18:08:43" + }, + { + "name": "jms/serializer", + "version": "0.16.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/serializer.git", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/c8a171357ca92b6706e395c757f334902d430ea9", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "jms/metadata": "~1.1", + "jms/parser-lib": "1.*", + "php": ">=5.3.2", + "phpcollection/phpcollection": "~0.1" + }, + "require-dev": { + "doctrine/orm": "~2.1", + "doctrine/phpcr-odm": "~1.0.1", + "jackalope/jackalope-doctrine-dbal": "1.0.*", + "propel/propel1": "~1.7", + "symfony/filesystem": "2.*", + "symfony/form": "~2.1", + "symfony/translation": "~2.0", + "symfony/validator": "~2.0", + "symfony/yaml": "2.*", + "twig/twig": ">=1.8,<2.0-dev" + }, + "suggest": { + "symfony/yaml": "Required if you'd like to serialize data to YAML format." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.15-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\Serializer": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.", + "homepage": "http://jmsyst.com/libs/serializer", + "keywords": [ + "deserialization", + "jaxb", + "json", + "serialization", + "xml" + ], + "time": "2014-03-18 08:39:00" + }, + { + "name": "knplabs/knp-menu", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/KnpMenu.git", + "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/KnpMenu/zipball/f8e867268f63f561c1adadd6cbb5d8524f921873", + "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "pimple/pimple": "*", + "silex/silex": "1.0.*", + "twig/twig": ">=1.2,<2.0-dev" + }, + "suggest": { + "pimple/pimple": "for the built-in implementations of the menu provider and renderer provider", + "silex/silex": "for the integration with your silex application", + "twig/twig": "for the TwigRenderer and the integration with your templates" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Knp\\Menu\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christophe Coevoet", + "email": "stof@notk.org" + }, + { + "name": "KnpLabs", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/KnpLabs/KnpMenu/contributors" + } + ], + "description": "An object oriented menu library", + "homepage": "http://knplabs.com", + "keywords": [ + "menu", + "tree" + ], + "time": "2012-06-10 16:20:40" + }, + { + "name": "monolog/monolog", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "65026b610f8c19e61d7242f600530677b0466aac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/65026b610f8c19e61d7242f600530677b0466aac", + "reference": "65026b610f8c19e61d7242f600530677b0466aac", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "require-dev": { + "aws/aws-sdk-php": "~2.4, >2.4.8", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "phpunit/phpunit": "~3.7.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be", + "role": "Developer" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2014-04-24 13:29:03" + }, + { + "name": "nikic/php-parser", + "version": "v0.9.4", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "autoload": { + "psr-0": { + "PHPParser": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2013-08-25 17:11:40" + }, + { + "name": "phenx/php-font-lib", + "version": "0.2.2", + "source": { + "type": "git", + "url": "https://github.com/PhenX/php-font-lib.git", + "reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82", + "reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "classes/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Fabien Ménager", + "email": "fabien.menager@gmail.com" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/PhenX/php-font-lib", + "time": "2014-02-01 15:22:28" + }, + { + "name": "phpcollection/phpcollection", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-collection.git", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/b8bf55a0a929ca43b01232b36719f176f86c7e83", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83", + "shasum": "" + }, + "require": { + "phpoption/phpoption": "1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpCollection": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "General-Purpose Collection Library for PHP", + "keywords": [ + "collection", + "list", + "map", + "sequence", + "set" + ], + "time": "2014-03-11 13:46:42" + }, + { + "name": "phpdocumentor/fileset", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/Fileset.git", + "reference": "bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/Fileset/zipball/bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0", + "reference": "bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/finder": "~2.1" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Fileset component for collecting a set of files given directories and file paths", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "files", + "fileset", + "phpdoc" + ], + "time": "2013-08-06 21:07:42" + }, + { + "name": "phpdocumentor/graphviz", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/GraphViz.git", + "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/GraphViz/zipball/13595130b9bc185109f40f1b70f0b231f490f5fc", + "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-02-26 17:45:01" + }, + { + "name": "phpdocumentor/phpdocumentor", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/phpDocumentor2.git", + "reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/d7503ada7386aa6b2956224d50a8d0226a22a99f", + "reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f", + "shasum": "" + }, + "require": { + "cilex/cilex": "~1.0", + "dompdf/dompdf": "~0.6", + "erusev/parsedown": "~0.7", + "jms/serializer": "~0.12", + "knplabs/knp-menu": "~1.1", + "monolog/monolog": "~1.6", + "php": ">=5.3.3", + "phpdocumentor/fileset": "~1.0", + "phpdocumentor/graphviz": "~1.0", + "phpdocumentor/reflection": "~1.0", + "phpdocumentor/reflection-docblock": "~2.0", + "phpdocumentor/template-abstract": "~1.2", + "phpdocumentor/template-checkstyle": "~1.2", + "phpdocumentor/template-clean": "~1.0", + "phpdocumentor/template-new-black": "~1.3", + "phpdocumentor/template-old-ocean": "~1.3", + "phpdocumentor/template-responsive": "~1.3", + "phpdocumentor/template-responsive-twig": "~1.2", + "phpdocumentor/template-xml": "~1.0", + "phpdocumentor/template-zend": "~1.3", + "symfony/config": "~2.3", + "symfony/console": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/process": "~2.0", + "symfony/stopwatch": "~2.3", + "symfony/validator": "~2.2", + "twig/twig": "~1.3", + "zendframework/zend-cache": "2.1.*", + "zendframework/zend-config": "2.1.*", + "zendframework/zend-filter": "2.1.*", + "zendframework/zend-i18n": "2.1.*", + "zendframework/zend-serializer": "2.1.*", + "zendframework/zend-servicemanager": "2.1.*", + "zendframework/zend-stdlib": "2.1.*", + "zetacomponents/document": ">=1.3.1" + }, + "require-dev": { + "behat/behat": "~2.4", + "mikey179/vfsstream": "~1.2", + "mockery/mockery": ">=0.8.0", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "~1.4", + "symfony/expression-language": "~2.4" + }, + "suggest": { + "ext-twig": "Enabling the twig extension improves the generation of twig based templates.", + "ext-xslcache": "Enabling the XSLCache extension improves the generation of xml based templates." + }, + "bin": [ + "bin/phpdoc.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Documentation Generator for PHP", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "api", + "application", + "dga", + "documentation", + "phpdoc" + ], + "time": "2014-04-01 18:14:51" + }, + { + "name": "phpdocumentor/reflection", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/Reflection.git", + "reference": "df82db631acd60739c8796b3c6d5e4da970808f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/df82db631acd60739c8796b3c6d5e4da970808f3", + "reference": "df82db631acd60739c8796b3c6d5e4da970808f3", + "shasum": "" + }, + "require": { + "nikic/php-parser": "0.9.4", + "php": ">=5.3.3", + "phpdocumentor/reflection-docblock": "2.*", + "psr/log": "~1.0" + }, + "require-dev": { + "behat/behat": "~2.4", + "mockery/mockery": ">=0.7.0", + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/", + "tests/mocks/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Reflection library to do Static Analysis for PHP Projects", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2014-03-28 11:20:22" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "0bca477a34baea39add016af90046f002a175619" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0bca477a34baea39add016af90046f002a175619", + "reference": "0bca477a34baea39add016af90046f002a175619", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "suggest": { + "dflydev/markdown": "1.0.*", + "erusev/parsedown": "~0.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-03-28 09:21:30" + }, + { + "name": "phpdocumentor/template-abstract", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.abstract.git", + "reference": "43fa2db351d7a150803397721e778f9dd8a20b47" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.abstract/zipball/43fa2db351d7a150803397721e778f9dd8a20b47", + "reference": "43fa2db351d7a150803397721e778f9dd8a20b47", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Simple bright template for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:11:13" + }, + { + "name": "phpdocumentor/template-checkstyle", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.checkstyle.git", + "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.checkstyle/zipball/22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", + "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Checkstyle XML output template for phpDocumentor2", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-01 19:43:19" + }, + { + "name": "phpdocumentor/template-clean", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.clean.git", + "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.clean/zipball/78f2048c5ecd62f0b79dbac093687d78a66d1806", + "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A clean, responsive modern template for phpDocumentor for Twig aimed at usability", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "responsive", + "template" + ], + "time": "2014-03-29 08:22:15" + }, + { + "name": "phpdocumentor/template-new-black", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.new_black.git", + "reference": "be38beba2b2674be292f32f88efe8a60c658a139" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.new_black/zipball/be38beba2b2674be292f32f88efe8a60c658a139", + "reference": "be38beba2b2674be292f32f88efe8a60c658a139", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/template-abstract": "1.*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Web 2.0 template with dark sidebar for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:16:30" + }, + { + "name": "phpdocumentor/template-old-ocean", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.old_ocean.git", + "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.old_ocean/zipball/3a0e2bcced4045a694d53b4607aad04e99d78489", + "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Blue template with high contrast for the foreground", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:21:07" + }, + { + "name": "phpdocumentor/template-responsive", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.responsive.git", + "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive/zipball/26f895a2ed3148e1686ae4d802f65a3ef04c04e1", + "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Responsive modern template for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2014-03-29 08:55:54" + }, + { + "name": "phpdocumentor/template-responsive-twig", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.responsive-twig.git", + "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive-twig/zipball/cd6d82be6a4626d865fd01d40aad170cea08db0a", + "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Responsive modern template for phpDocumentor for Twig", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2014-03-30 21:02:00" + }, + { + "name": "phpdocumentor/template-xml", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/mvriel/template.xml.git", + "reference": "a372713be8ee99b16497e2580592e474ff51190c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mvriel/template.xml/zipball/a372713be8ee99b16497e2580592e474ff51190c", + "reference": "a372713be8ee99b16497e2580592e474ff51190c", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Generates an XML representation of the project's structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-01 20:23:32" + }, + { + "name": "phpdocumentor/template-zend", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.zend.git", + "reference": "75913288bfd73d3bf4c1b1179c3963f3431e7a9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.zend/zipball/75913288bfd73d3bf4c1b1179c3963f3431e7a9d", + "reference": "75913288bfd73d3bf4c1b1179c3963f3431e7a9d", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/template-abstract": "1.*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Official Zend Framework Template for phpDocumentor2", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "ZendFramework", + "documentation", + "phpdoc", + "template", + "zend", + "zf" + ], + "time": "2013-12-05 08:51:57" + }, + { + "name": "phpdocumentor/unified-asset-installer", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/UnifiedAssetInstaller.git", + "reference": "241fb036268cd9da7d76da3db66e3eda66259c52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/UnifiedAssetInstaller/zipball/241fb036268cd9da7d76da3db66e3eda66259c52", + "reference": "241fb036268cd9da7d76da3db66e3eda66259c52", + "shasum": "" + }, + "require": { + "composer-plugin-api": "1.0.0" + }, + "require-dev": { + "composer/composer": "~1.0@dev", + "phpunit/phpunit": "~3.7" + }, + "type": "composer-installer", + "extra": { + "class": "\\phpDocumentor\\Composer\\UnifiedAssetInstaller" + }, + "autoload": { + "psr-0": { + "phpDocumentor\\Composer": [ + "src/", + "test/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Asset installer for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "assets", + "installer", + "plugins", + "templates" + ], + "time": "2013-09-09 06:13:02" + }, + { + "name": "phpoption/phpoption", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpOption\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "time": "2014-01-09 22:37:17" + }, + { + "name": "phpunit/php-code-coverage", + "version": "1.2.17", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": ">=1.3.0@stable", + "phpunit/php-text-template": ">=1.2.0@stable", + "phpunit/php-token-stream": ">=1.1.3@stable" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-03-28 10:53:45" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-03-03 05:10:30" + }, + { + "name": "phpunit/phpunit", + "version": "3.7.37", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~1.2", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.1", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~1.2", + "symfony/yaml": "~2.0" + }, + "require-dev": { + "pear-pear.php.net/pear": "1.9.4" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "composer/bin/phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-04-30 12:24:19" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-text-template": ">=1.1.1@stable" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2013-01-13 10:24:48" + }, + { + "name": "pimple/pimple", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Pimple.git", + "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d", + "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2013-11-22 08:30:29" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "symfony/config", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "2effc67af6f21a0d267210b72d0b0b691d113528" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/2effc67af6f21a0d267210b72d0b0b691d113528", + "reference": "2effc67af6f21a0d267210b72d0b0b691d113528", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com", + "time": "2014-04-22 08:11:06" + }, + { + "name": "symfony/console", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "2e452005b1e1d003d23702d227e23614679eb5ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/2e452005b1e1d003d23702d227e23614679eb5ca", + "reference": "2e452005b1e1d003d23702d227e23614679eb5ca", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.4.4", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "e539602e5455aa086c0e81e604745af7789e4d8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e539602e5455aa086c0e81e604745af7789e4d8a", + "reference": "e539602e5455aa086c0e81e604745af7789e4d8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~2.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2014-04-16 10:34:31" + }, + { + "name": "symfony/filesystem", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a3af8294bcce4a7c1b2892363b0c9d8109affad4", + "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2014-04-16 10:34:31" + }, + { + "name": "symfony/finder", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/25e1e7d5e7376f8a92ae3b1d714d956edf33a730", + "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/process", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", + "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/property-access", + "version": "v2.4.4", + "target-dir": "Symfony/Component/PropertyAccess", + "source": { + "type": "git", + "url": "https://github.com/symfony/PropertyAccess.git", + "reference": "0456222bc00c40c1365065b603f7c397fb9a7134" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/0456222bc00c40c1365065b603f7c397fb9a7134", + "reference": "0456222bc00c40c1365065b603f7c397fb9a7134", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\PropertyAccess\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony PropertyAccess Component", + "homepage": "http://symfony.com", + "keywords": [ + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" + ], + "time": "2014-04-18 20:37:09" + }, + { + "name": "symfony/stopwatch", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Stopwatch", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/343bcc0360f2c22f371884b8f6a9fee8d1aa431a", + "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:37:09" + }, + { + "name": "symfony/translation", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Translation", + "source": { + "type": "git", + "url": "https://github.com/symfony/Translation.git", + "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Translation/zipball/d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", + "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.0", + "symfony/yaml": "~2.2" + }, + "suggest": { + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 21:02:05" + }, + { + "name": "symfony/validator", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Validator", + "source": { + "type": "git", + "url": "https://github.com/symfony/Validator.git", + "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Validator/zipball/5bbcdcc520bc7fb3826abb44020880f14c9c03a7", + "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/property-access": "~2.2", + "symfony/translation": "~2.0" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.0", + "symfony/config": "~2.2", + "symfony/http-foundation": "~2.1", + "symfony/intl": "~2.3", + "symfony/yaml": "~2.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Validator\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Validator Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/yaml", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/65539ecde838f9c0d18b006b2101e3deb4b5c9ff", + "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:37:09" + }, + { + "name": "twig/twig", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Twig.git", + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher2", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2014-02-13 10:19:29" + }, + { + "name": "zendframework/zend-cache", + "version": "2.1.6", + "target-dir": "Zend/Cache", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendCache.git", + "reference": "560355160f06cdc3ef549a7eef843af3bead7e39" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendCache/zipball/560355160f06cdc3ef549a7eef843af3bead7e39", + "reference": "560355160f06cdc3ef549a7eef843af3bead7e39", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "zendframework/zend-serializer": "self.version" + }, + "suggest": { + "ext-apc": "APC >= 3.1.6 to use the APC storage adapter", + "ext-dba": "DBA, to use the DBA storage adapter", + "ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter", + "ext-wincache": "WinCache, to use the WinCache storage adapter", + "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-session": "Zend\\Session component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a generic way to cache any data", + "keywords": [ + "cache", + "zf2" + ], + "time": "2014-03-03 23:00:17" + }, + { + "name": "zendframework/zend-config", + "version": "2.1.6", + "target-dir": "Zend/Config", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendConfig.git", + "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendConfig/zipball/a31c3980cf7ec88418a931e9cf4ba21079f47a08", + "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-json": "Zend\\Json to use the Json reader or writer classes", + "zendframework/zend-servicemanager": "Zend\\ServiceManager for use with the Config Factory to retrieve reader and writer instances" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a nested object property based user interface for accessing this configuration data within application code", + "keywords": [ + "config", + "zf2" + ], + "time": "2014-01-02 18:00:10" + }, + { + "name": "zendframework/zend-eventmanager", + "version": "2.1.6", + "target-dir": "Zend/EventManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendEventManager.git", + "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/89368704bb37303fba64c3ddd6bce0506aa7187c", + "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\EventManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "eventmanager", + "zf2" + ], + "time": "2014-01-04 13:00:14" + }, + { + "name": "zendframework/zend-filter", + "version": "2.1.6", + "target-dir": "Zend/Filter", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendFilter.git", + "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/8ceece474b29d079e86976dbd3efffe6064b3d72", + "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "zendframework/zend-crypt": "self.version" + }, + "suggest": { + "zendframework/zend-crypt": "Zend\\Crypt component", + "zendframework/zend-i18n": "Zend\\I18n component", + "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter", + "zendframework/zend-validator": "Zend\\Validator component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Filter\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a set of commonly needed data filters", + "keywords": [ + "filter", + "zf2" + ], + "time": "2014-03-03 21:00:06" + }, + { + "name": "zendframework/zend-i18n", + "version": "2.1.6", + "target-dir": "Zend/I18n", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendI18n.git", + "reference": "10f56e0869761d62699782e4dd04eb77262cc353" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendI18n/zipball/10f56e0869761d62699782e4dd04eb77262cc353", + "reference": "10f56e0869761d62699782e4dd04eb77262cc353", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "ext-intl": "Required for most features of Zend\\I18n; included in default builds of PHP", + "zendframework/zend-eventmanager": "You should install this package to use the events in the translator", + "zendframework/zend-filter": "You should install this package to use the provided filters", + "zendframework/zend-resources": "Translation resources", + "zendframework/zend-validator": "You should install this package to use the provided validators", + "zendframework/zend-view": "You should install this package to use the provided view helpers" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\I18n\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "i18n", + "zf2" + ], + "time": "2014-01-04 13:00:19" + }, + { + "name": "zendframework/zend-json", + "version": "2.1.6", + "target-dir": "Zend/Json", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendJson.git", + "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendJson/zipball/dd8a8239a7c08c7449a6ea219da3e2369bd90d92", + "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-server": "Zend\\Server component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Json\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", + "keywords": [ + "json", + "zf2" + ], + "time": "2014-03-06 18:00:05" + }, + { + "name": "zendframework/zend-math", + "version": "2.1.6", + "target-dir": "Zend/Math", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendMath.git", + "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendMath/zipball/b982ee2edafd4075b22372596ab2e2fdd0f6424e", + "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-bcmath": "If using the bcmath functionality", + "ext-gmp": "If using the gmp functionality", + "ircmaxell/random-lib": "Fallback random byte generator for Zend\\Math\\Rand if OpenSSL/Mcrypt extensions are unavailable", + "zendframework/zend-servicemanager": ">= current version, if using the BigInteger::factory functionality" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Math\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "math", + "zf2" + ], + "time": "2014-03-05 18:00:06" + }, + { + "name": "zendframework/zend-serializer", + "version": "2.1.6", + "target-dir": "Zend/Serializer", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendSerializer.git", + "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendSerializer/zipball/d76b931d3ffa842a496c9fa319bbe285b5ddfade", + "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-json": "self.version", + "zendframework/zend-math": "self.version", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-servicemanager": "To support plugin manager support" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Serializer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover", + "keywords": [ + "serializer", + "zf2" + ], + "time": "2014-01-02 18:00:26" + }, + { + "name": "zendframework/zend-servicemanager", + "version": "2.1.6", + "target-dir": "Zend/ServiceManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendServiceManager.git", + "reference": "de182a20dfdcf978c49570514103c7477ef16e4f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/de182a20dfdcf978c49570514103c7477ef16e4f", + "reference": "de182a20dfdcf978c49570514103c7477ef16e4f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "zendframework/zend-di": "Zend\\Di component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\ServiceManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "servicemanager", + "zf2" + ], + "time": "2014-03-03 21:00:04" + }, + { + "name": "zendframework/zend-stdlib", + "version": "2.1.6", + "target-dir": "Zend/Stdlib", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendStdlib.git", + "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/e646729f2274f4552b6a92e38d8e458efe08ebc5", + "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Stdlib\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2014-01-04 13:00:28" + }, + { + "name": "zetacomponents/base", + "version": "1.8", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Base.git", + "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zetacomponents/Base/zipball/52ca69c1de55f3fa4f595779e5bc831da7ee176c", + "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "apache2" + ], + "authors": [ + { + "name": "Sergey Alexeev" + }, + { + "name": "Sebastian Bergmann" + }, + { + "name": "Jan Borsodi" + }, + { + "name": "Raymond Bosman" + }, + { + "name": "Frederik Holljen" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Vadym Savchuk" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + } + ], + "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.", + "homepage": "https://github.com/zetacomponents", + "time": "2009-12-21 12:14:16" + }, + { + "name": "zetacomponents/document", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Document.git", + "reference": "688abfde573cf3fe0730f82538fbd7aa9fc95bc8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zetacomponents/Document/zipball/688abfde573cf3fe0730f82538fbd7aa9fc95bc8", + "reference": "688abfde573cf3fe0730f82538fbd7aa9fc95bc8", + "shasum": "" + }, + "require": { + "zetacomponents/base": "*" + }, + "require-dev": { + "zetacomponents/unit-test": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Sebastian Bergmann" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + } + ], + "description": "The Document components provides a general conversion framework for different semantic document markup languages like XHTML, Docbook, RST and similar.", + "homepage": "https://github.com/zetacomponents", + "time": "2013-12-19 11:40:00" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.3.3", + "ext-xml": "*", + "ext-zip": "*" + }, + "platform-dev": [ + + ] +} From febb9d072ab5d48a9d66f6c2206a399fdbb1cf01 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 5 May 2014 20:21:56 +0700 Subject: [PATCH 032/167] Update changelog for #154 and #186 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e8f09d5bc..19e6d9f914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 - QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin - Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin +- Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 +- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 ## 0.10.0 - 4 May 2014 From b2a0e08db99043e560c50ac278484d05f1b4390b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 5 May 2014 22:31:29 +0700 Subject: [PATCH 033/167] #154: Update documentation to include API docs and code coverage report --- README.md | 71 ++++++++++++++++++++++----------------- docs/intro.rst | 37 +++++++++++++------- docs/src/documentation.md | 30 +++++++++++------ 3 files changed, 85 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 5a8db0ef1b..21e18a7e00 100644 --- a/README.md +++ b/README.md @@ -7,40 +7,44 @@ [![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) -PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF). +PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF. + +PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/LICENSE.md). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/). + +## Features With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your PHP 5.3+ scripts. Below are some of the things that you can do with PHPWord library: -* Set document properties, e.g. title, subject, and creator. -* Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering -* Create header and footer for each sections -* Set default font type, font size, and paragraph style -* Use UTF-8 and East Asia fonts/characters -* Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text -* Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements -* Insert titles (headers) and table of contents -* Insert text breaks and page breaks -* Insert and format images, either local, remote, or as page watermarks -* Insert binary OLE Objects such as Excel or Visio -* Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan) -* Insert list items as bulleted, numbered, or multilevel -* Insert hyperlinks -* Insert footnotes and endnotes -* Create document from templates -* Use XSL 1.0 style sheets to transform main document part of OOXML template -* ... and many more features on progress - -__Want to contribute?__ [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us. +- Set document properties, e.g. title, subject, and creator. +- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering +- Create header and footer for each sections +- Set default font type, font size, and paragraph style +- Use UTF-8 and East Asia fonts/characters +- Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text +- Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements +- Insert titles (headers) and table of contents +- Insert text breaks and page breaks +- Insert and format images, either local, remote, or as page watermarks +- Insert binary OLE Objects such as Excel or Visio +- Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan) +- Insert list items as bulleted, numbered, or multilevel +- Insert hyperlinks +- Insert footnotes and endnotes +- Create document from templates +- Use XSL 1.0 style sheets to transform main document part of OOXML template +- ... and many more features on progress ## Requirements -* PHP 5.3+ -* PHP [Zip](http://php.net/manual/en/book.zip.php) extension -* PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension -### Optional PHP extensions -* PHP [GD](http://php.net/manual/en/book.image.php) extension -* PHP [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) extension -* PHP [XSL](http://php.net/manual/en/book.xsl.php) extension +PHPWord requires the following: + +- PHP 5.3+ +- [Zip extension](http://php.net/manual/en/book.zip.php) +- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php) +- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images) +- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write DOCX and ODT) +- [XSL extension](http://php.net/manual/en/book.xsl.php) (optional, used to apply XSL style sheet to template ) +- [dompdf](https://github.com/dompdf/dompdf) (optional, used to write PDF) ## Installation @@ -63,7 +67,7 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); ``` -## Basic usage +## Usages The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/). @@ -107,6 +111,11 @@ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); $objWriter->save('helloWorld.rtf'); ``` -## Documentation +## Contributing + +We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: -__Want to know more?__ Read the full documentation of PHPWord on [Read The Docs](http://phpword.readthedocs.org/). +- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md) +- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch +- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub +- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter diff --git a/docs/intro.rst b/docs/intro.rst index 3c2a47bde5..25a5020521 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -12,18 +12,14 @@ Applications `__ (OpenDocument or ODF), and `Rich Text Format `__ (RTF). -No Windows operating system is needed for usage because the resulting -DOCX, ODT, or RTF files can be opened by all major `word processing -softwares `__. - -PHPWord is an open source project licensed under LGPL version 3. PHPWord is `unit -tested `__ to make sure that -the released versions are stable. - -**Want to contribute?** `Fork -us `__ or -`submit `__ your bug -reports or feature requests to us. +PHPWord is an open source project licensed under the terms of `LGPL +version 3 `__. +PHPWord is aimed to be a high quality software product by incorporating +`continuous integration `__ and +`unit testing `__. +You can learn more about PHPWord by reading this Developers' +Documentation and the `API +Documentation `__. Features -------- @@ -180,3 +176,20 @@ Readers +---------------------------+----------------------+--------+-------+-------+ | | Protection | | | | +---------------------------+----------------------+--------+-------+-------+ + +Contributing +------------ + +We welcome everyone to contribute to PHPWord. Below are some of the +things that you can do to contribute: + +- Read `our contributing + guide `__ +- `Fork us `__ and `request + a pull `__ to the + `develop `__ + branch +- Submit `bug reports or feature + requests `__ to GitHub +- Follow `@PHPWord `__ and + `@PHPOffice `__ on Twitter diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 4ae1f50ec6..a140c5bae0 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -47,11 +47,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF). -No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major [word processing softwares](http://en.wikipedia.org/wiki/List_of_word_processors). - -PHPWord is an open source project licensed under LGPL version 3. PHPWord is [unit tested](https://travis-ci.org/PHPOffice/PHPWord) to make sure that the released versions are stable. - -**Want to contribute?** [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us. +PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/LICENSE.md). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading this Developers' Documentation and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/). ## Features @@ -142,6 +138,15 @@ Below are the supported features for each file formats. | **Bonus** | Encryption | | | | | | Protection | | | | +## Contributing + +We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: + +- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md) +- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch +- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub +- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter + # Installing/configuring ## Requirements @@ -938,13 +943,18 @@ PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex can run w # References +## ISO/IEC 29500, Third edition, 2012-09-01 + +- [Part 1: Fundamentals and Markup Language Reference](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip) +- [Part 2: Open Packaging Conventions](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061796_ISO_IEC_29500-2_2012.zip) +- [Part 3: Markup Compatibility and Extensibility](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061797_ISO_IEC_29500-3_2012.zip) +- [Part 4: Transitional Migration Features](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061798_ISO_IEC_29500-4_2012.zip) + ## Formal specifications -- [Office Open XML (OOXML) (ECMA-376) Schema](http://www.schemacentral.com/sc/ooxml/ss.html) -- [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html) -- [Rich Text Format (RTF) Specification, version 1.9.1](http://www.microsoft.com/en-us/download/details.aspx?id=10725) +- [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html) +- [Rich Text Format (RTF) Specification, version 1.9.1](http://www.microsoft.com/en-us/download/details.aspx?id=10725) ## Other resources -- [DocumentFormat.OpenXml.Wordprocessing Namespace on MSDN](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing%28v=office.14%29.aspx) - +- [DocumentFormat.OpenXml.Wordprocessing Namespace on MSDN](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing%28v=office.14%29.aspx) From 704cc2fe040286007722193303756e85a5befb49 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 5 May 2014 23:30:15 +0700 Subject: [PATCH 034/167] Refactoring: Extends Endnotes from Footnotes & Heder from Footer --- src/PhpWord/Reader/Word2007/Endnotes.php | 13 +++- src/PhpWord/Reader/Word2007/Footnotes.php | 49 ++++++++++++++- src/PhpWord/Reader/Word2007/Notes.php | 68 --------------------- src/PhpWord/Writer/Word2007/Part/Footer.php | 21 ++++--- src/PhpWord/Writer/Word2007/Part/Header.php | 35 ++++------- 5 files changed, 82 insertions(+), 104 deletions(-) delete mode 100644 src/PhpWord/Reader/Word2007/Notes.php diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php index 7c81a3dffd..02bf9e9e66 100644 --- a/src/PhpWord/Reader/Word2007/Endnotes.php +++ b/src/PhpWord/Reader/Word2007/Endnotes.php @@ -20,12 +20,19 @@ /** * Endnotes reader */ -class Endnotes extends Notes +class Endnotes extends Footnotes { /** - * Note type = endnotes + * Collection name * * @var string */ - protected $type = 'endnotes'; + protected $collection = 'endnotes'; + + /** + * Element name + * + * @var string + */ + protected $element = 'endnote'; } diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index d0c8b98cc5..7aadf6c031 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -17,15 +17,58 @@ namespace PhpOffice\PhpWord\Reader\Word2007; +use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Shared\XMLReader; + /** * Footnotes reader */ -class Footnotes extends Notes +class Footnotes extends AbstractPart { /** - * Note type = footnotes + * Collection name footnotes|endnotes + * + * @var string + */ + protected $collection = 'footnotes'; + + /** + * Element name footnote|endnote * * @var string */ - protected $type = 'footnotes'; + protected $element = 'footnote'; + + /** + * Read (footnotes|endnotes).xml + * + * @param \PhpOffice\PhpWord\PhpWord $phpWord + */ + public function read(PhpWord &$phpWord) + { + $getMethod = "get{$this->collection}"; + $collection = $phpWord->$getMethod()->getItems(); + + $xmlReader = new XMLReader(); + $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); + $nodes = $xmlReader->getElements('*'); + if ($nodes->length > 0) { + foreach ($nodes as $node) { + $id = $xmlReader->getAttribute('w:id', $node); + $type = $xmlReader->getAttribute('w:type', $node); + + // Avoid w:type "separator" and "continuationSeparator" + // Only look for or without w:type attribute + if (is_null($type) && array_key_exists($id, $collection)) { + $element = $collection[$id]; + $pNodes = $xmlReader->getElements('w:p/*', $node); + foreach ($pNodes as $pNode) { + $this->readRun($xmlReader, $pNode, $element, $this->collection); + } + $addMethod = "add{$this->element}"; + $phpWord->$addMethod($element); + } + } + } + } } diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php deleted file mode 100644 index e3a7bba602..0000000000 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ /dev/null @@ -1,68 +0,0 @@ -type = ($this->type == 'endnotes') ? 'endnotes' : 'footnotes'; - $getMethod = 'get' . $this->type; - $collection = $phpWord->$getMethod()->getItems(); - - $xmlReader = new XMLReader(); - $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); - $nodes = $xmlReader->getElements('*'); - if ($nodes->length > 0) { - foreach ($nodes as $node) { - $id = $xmlReader->getAttribute('w:id', $node); - $type = $xmlReader->getAttribute('w:type', $node); - - // Avoid w:type "separator" and "continuationSeparator" - // Only look for or without w:type attribute - if (is_null($type) && array_key_exists($id, $collection)) { - $element = $collection[$id]; - $pNodes = $xmlReader->getElements('w:p/*', $node); - foreach ($pNodes as $pNode) { - $this->readRun($xmlReader, $pNode, $element, $this->type); - } - $addMethod = 'add' . ($this->type == 'endnotes' ? 'endnote' : 'footnote'); - $phpWord->$addMethod($element); - } - } - } - } -} diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index eed495b022..dded826610 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Element\Footer as FooterElement; +use PhpOffice\PhpWord\Element\AbstractContainer as Container; /** * Word2007 footer part writer @@ -25,16 +25,23 @@ class Footer extends AbstractPart { /** - * Write word/footnotes.xml + * Root element name * - * @param \PhpOffice\PhpWord\Element\Footer $footer + * @var string */ - public function writeFooter(FooterElement $footer) + protected $rootElement = 'w:ftr'; + + /** + * Write word/footerx.xml + * + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + */ + public function writeFooter(Container $element) { $xmlWriter = $this->getXmlWriter(); $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('w:ftr'); + $xmlWriter->startElement($this->rootElement); $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); @@ -45,9 +52,9 @@ public function writeFooter(FooterElement $footer) $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - $this->writeContainerElements($xmlWriter, $footer); + $this->writeContainerElements($xmlWriter, $element); - $xmlWriter->endElement(); // w:ftr + $xmlWriter->endElement(); // $this->rootElement return $xmlWriter->getData(); } diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php index 319b030e16..2b515c4737 100644 --- a/src/PhpWord/Writer/Word2007/Part/Header.php +++ b/src/PhpWord/Writer/Word2007/Part/Header.php @@ -17,38 +17,27 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Element\Header as HeaderElement; +use PhpOffice\PhpWord\Element\AbstractContainer as Container; /** * Word2007 header part writer */ -class Header extends AbstractPart +class Header extends Footer { + /** + * Root element name + * + * @var string + */ + protected $rootElement = 'w:hdr'; + /** * Write word/headerx.xml * - * @param \PhpOffice\PhpWord\Element\Header $header + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element */ - public function writeHeader(HeaderElement $header) + public function writeHeader(Container $element) { - $xmlWriter = $this->getXmlWriter(); - - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('w:hdr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $this->writeContainerElements($xmlWriter, $header); - - $xmlWriter->endElement(); // w:hdr - - return $xmlWriter->getData(); + return $this->writeFooter($element); } } From 4039304ba00fc2796aba5ccad348499b0109e3d5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 01:45:13 +0700 Subject: [PATCH 035/167] Word2007 Writer: Refactor writer parts using composite pattern --- CHANGELOG.md | 3 + src/PhpWord/Writer/Word2007.php | 74 ++++++++++++------- .../Writer/Word2007/Part/ContentTypes.php | 19 ++++- .../Writer/Word2007/Part/DocPropsApp.php | 54 ++++++++++++++ .../Part/{DocProps.php => DocPropsCore.php} | 38 ++-------- src/PhpWord/Writer/Word2007/Part/Document.php | 19 ++++- .../Writer/Word2007/Part/Numbering.php | 68 ++++++++--------- src/PhpWord/Writer/Word2007/Part/Rels.php | 39 +--------- .../Writer/Word2007/Part/RelsDocument.php | 47 ++++++++++++ src/PhpWord/Writer/Word2007/Part/RelsMain.php | 44 +++++++++++ src/PhpWord/Writer/Word2007/Part/Settings.php | 13 +++- src/PhpWord/Writer/Word2007/Part/Styles.php | 20 ++++- .../Writer/Word2007/Part/WebSettings.php | 13 +++- 13 files changed, 308 insertions(+), 143 deletions(-) create mode 100644 src/PhpWord/Writer/Word2007/Part/DocPropsApp.php rename src/PhpWord/Writer/Word2007/Part/{DocProps.php => DocPropsCore.php} (70%) create mode 100644 src/PhpWord/Writer/Word2007/Part/RelsDocument.php create mode 100644 src/PhpWord/Writer/Word2007/Part/RelsMain.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e6d9f914..22b36a78b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. ### Deprecated - Static classes `Footnotes`, `Endnotes`, and `TOC` +- `Writer\Word2007\Part`: `Numbering::writeNumbering()`, `Settings::writeSettings()`, `WebSettings::writeWebSettings()`, `ContentTypes::writeContentTypes()`, `Styles::writeStyles()`, `Document::writeDocument()` all changed into `write()` +- `Writer\Word2007\Part\DocProps`: Split into `Writer\Word2007\Part\DocPropsCore` and `Writer\Word2007\Part\DocPropsApp` ### Miscellaneous @@ -28,6 +30,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin - Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 - QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 +- Word2007 Writer: Refactor writer parts using composite pattern - @ivanlanin ## 0.10.0 - 4 May 2014 diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 9e4143694a..8b91d03652 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -32,14 +32,14 @@ class Word2007 extends AbstractWriter implements WriterInterface * * @var array */ - private $cTypes = array('default' => array(), 'override' => array()); + private $contentTypes = array('default' => array(), 'override' => array()); /** * Document relationship * * @var array */ - private $docRels = array(); + private $relationships = array(); /** * Create new Word2007 writer @@ -52,7 +52,7 @@ public function __construct(PhpWord $phpWord = null) $this->setPhpWord($phpWord); // Create parts - $parts = array('ContentTypes', 'Rels', 'DocProps', 'Document', 'Styles', + $parts = array('ContentTypes', 'RelsMain', 'RelsDocument', 'DocPropsApp', 'DocPropsCore', 'Document', 'Styles', 'Numbering', 'Settings', 'WebSettings', 'Header', 'Footer', 'Footnotes', 'Endnotes', 'FontTable', 'Theme'); foreach ($parts as $part) { @@ -81,7 +81,7 @@ public function save($filename = null) $objZip = $this->getZipArchive($filename); // Content types - $this->cTypes['default'] = array( + $this->contentTypes['default'] = array( 'rels' => 'application/vnd.openxmlformats-package.relationships+xml', 'xml' => 'application/xml', ); @@ -92,7 +92,7 @@ public function save($filename = null) $this->addFilesToPackage($objZip, $sectionMedia); $this->registerContentTypes($sectionMedia); foreach ($sectionMedia as $element) { - $this->docRels[] = $element; + $this->relationships[] = $element; } } @@ -112,16 +112,16 @@ public function save($filename = null) $this->addNotes($objZip, $rId, 'endnote'); // Write parts - $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->cTypes)); - $objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeMainRels()); - $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->phpWord)); - $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->phpWord)); - $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('rels')->writeDocRels($this->docRels)); - $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->phpWord)); - $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->phpWord)); - $objZip->addFromString('word/numbering.xml', $this->getWriterPart('numbering')->writeNumbering()); - $objZip->addFromString('word/settings.xml', $this->getWriterPart('settings')->writeSettings()); - $objZip->addFromString('word/webSettings.xml', $this->getWriterPart('websettings')->writeWebSettings()); + $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->write()); + $objZip->addFromString('_rels/.rels', $this->getWriterPart('relsmain')->write()); + $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docpropsapp')->write()); + $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docpropscore')->write()); + $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('relsdocument')->write()); + $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->write()); + $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->write()); + $objZip->addFromString('word/numbering.xml', $this->getWriterPart('numbering')->write()); + $objZip->addFromString('word/settings.xml', $this->getWriterPart('settings')->write()); + $objZip->addFromString('word/webSettings.xml', $this->getWriterPart('websettings')->write()); $objZip->addFromString('word/fontTable.xml', $this->getWriterPart('fonttable')->write()); $objZip->addFromString('word/theme/theme1.xml', $this->getWriterPart('theme')->write()); @@ -136,6 +136,26 @@ public function save($filename = null) } } + /** + * Get content types + * + * @return array + */ + public function getContentTypes() + { + return $this->contentTypes; + } + + /** + * Get content types + * + * @return array + */ + public function getRelationships() + { + return $this->relationships; + } + /** * Add header/footer media files * @@ -177,8 +197,8 @@ private function addHeaderFooterContent(Section &$section, $objZip, $elmType, &$ $elmObject->setRelationId(++$rId); $elmFile = "{$elmType}{$elmCount}.xml"; $objZip->addFromString("word/$elmFile", $this->getWriterPart($elmType)->$writeFunction($elmObject)); - $this->cTypes['override']["/word/$elmFile"] = $elmType; - $this->docRels[] = array('target' => $elmFile, 'type' => $elmType, 'rID' => $rId); + $this->contentTypes['override']["/word/$elmFile"] = $elmType; + $this->relationships[] = array('target' => $elmFile, 'type' => $elmType, 'rID' => $rId); } } @@ -192,8 +212,8 @@ private function addHeaderFooterContent(Section &$section, $objZip, $elmType, &$ private function addNotes($objZip, &$rId, $noteType = 'footnote') { $noteType = ($noteType == 'endnote') ? 'endnote' : 'footnote'; - $noteTypePlural = "{$noteType}s"; - $method = 'get' . $noteTypePlural; + $partName = "{$noteType}s"; + $method = 'get' . $partName; $collection = $this->phpWord->$method(); // Add footnotes media files, relations, and contents @@ -202,12 +222,12 @@ private function addNotes($objZip, &$rId, $noteType = 'footnote') $this->addFilesToPackage($objZip, $media); $this->registerContentTypes($media); if (!empty($media)) { - $objZip->addFromString("word/_rels/{$noteTypePlural}.xml.rels", $this->getWriterPart('rels')->writeMediaRels($media)); + $objZip->addFromString("word/_rels/{$partName}.xml.rels", $this->getWriterPart('rels')->writeMediaRels($media)); } $elements = $collection->getItems(); - $objZip->addFromString("word/{$noteTypePlural}.xml", $this->getWriterPart($noteTypePlural)->write($elements)); - $this->cTypes['override']["/word/{$noteTypePlural}.xml"] = $noteTypePlural; - $this->docRels[] = array('target' => "{$noteTypePlural}.xml", 'type' => $noteTypePlural, 'rID' => ++$rId); + $objZip->addFromString("word/{$partName}.xml", $this->getWriterPart($partName)->write($elements)); + $this->contentTypes['override']["/word/{$partName}.xml"] = $partName; + $this->relationships[] = array('target' => "{$partName}.xml", 'type' => $partName, 'rID' => ++$rId); } } @@ -222,12 +242,12 @@ private function registerContentTypes($media) $mediumType = $medium['type']; if ($mediumType == 'image') { $extension = $medium['imageExtension']; - if (!array_key_exists($extension, $this->cTypes['default'])) { - $this->cTypes['default'][$extension] = $medium['imageType']; + if (!array_key_exists($extension, $this->contentTypes['default'])) { + $this->contentTypes['default'][$extension] = $medium['imageType']; } } elseif ($mediumType == 'object') { - if (!array_key_exists('bin', $this->cTypes['default'])) { - $this->cTypes['default']['bin'] = 'application/vnd.openxmlformats-officedocument.oleObject'; + if (!array_key_exists('bin', $this->contentTypes['default'])) { + $this->contentTypes['default']['bin'] = 'application/vnd.openxmlformats-officedocument.oleObject'; } } } diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 73677d858d..3af420cc56 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -27,11 +27,11 @@ class ContentTypes extends AbstractPart { /** * Write [Content_Types].xml - * - * @param array $contentTypes */ - public function writeContentTypes($contentTypes) + public function write() { + $contentTypes = $this->parentWriter->getContentTypes(); + $openXMLPrefix = 'application/vnd.openxmlformats-'; $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; $overrides = array( @@ -90,4 +90,17 @@ private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault) } } } + + /** + * Write [Content_Types].xml + * + * @param array $contentTypes + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeContentTypes($contentTypes) + { + $contentTypes = null; // dummy assignment + return $this->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php new file mode 100644 index 0000000000..06a4e7802a --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php @@ -0,0 +1,54 @@ +parentWriter->getPhpWord(); + if (is_null($phpWord)) { + throw new Exception('No PhpWord assigned.'); + } + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startElement('Properties'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); + $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + + $xmlWriter->writeElement('Application', 'PHPWord'); + $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); + $xmlWriter->writeElement('Manager', $phpWord->getDocumentProperties()->getManager()); + + $xmlWriter->endElement(); // Properties + + return $xmlWriter->getData(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Part/DocProps.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php similarity index 70% rename from src/PhpWord/Writer/Word2007/Part/DocProps.php rename to src/PhpWord/Writer/Word2007/Part/DocPropsCore.php index 7dd51472ee..95fb213ee2 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocProps.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php @@ -21,44 +21,20 @@ use PhpOffice\PhpWord\PhpWord; /** - * Word2007 document properties part writer + * Word2007 core document properties part writer + * + * @since 0.11.0 */ -class DocProps extends AbstractPart +class DocPropsCore extends AbstractPart { - /** - * Write docProps/app.xml - */ - public function writeDocPropsApp(PhpWord $phpWord = null) - { - if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); - } - $xmlWriter = $this->getXmlWriter(); - - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('Properties'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); - $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - - $xmlWriter->writeElement('Application', 'PHPWord'); - $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); - $xmlWriter->writeElement('Manager', $phpWord->getDocumentProperties()->getManager()); - - $xmlWriter->endElement(); // Properties - - return $xmlWriter->getData(); - } - - /** * Write docProps/core.xml - * - * @param \PhpOffice\PhpWord\PhpWord $phpWord */ - public function writeDocPropsCore(PhpWord $phpWord = null) + public function write() { + $phpWord = $this->parentWriter->getPhpWord(); if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); + throw new Exception('No PhpWord assigned.'); } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 3371dc922e..47f7e02db3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -31,14 +31,14 @@ class Document extends AbstractPart /** * Write word/document.xml * - * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return string * @throws \PhpOffice\PhpWord\Exception\Exception */ - public function writeDocument(PhpWord $phpWord = null) + public function write() { + $phpWord = $this->parentWriter->getPhpWord(); if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); + throw new Exception('No PhpWord assigned.'); } $xmlWriter = $this->getXmlWriter(); $sections = $phpWord->getSections(); @@ -133,4 +133,17 @@ private function writeSectionSettings(XMLWriter $xmlWriter, Section $section) $xmlWriter->endElement(); // w:sectPr } + + /** + * Write word/document.xml + * + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeDocument(PhpWord $phpWord = null) + { + $this->parentWriter->setPhpWord($phpWord); + return $this->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 18c8f8f4d0..1ff57e2b90 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -29,7 +29,7 @@ class Numbering extends AbstractPart /** * Write word/numbering.xml */ - public function writeNumbering() + public function write() { $styles = Style::getStyles(); @@ -66,12 +66,6 @@ public function writeNumbering() if (is_array($levels)) { foreach ($levels as $levelNum => $levelObject) { if ($levelObject instanceof NumberingLevel) { - $start = $levelObject->getStart(); - $format = $levelObject->getFormat(); - $restart = $levelObject->getRestart(); - $suffix = $levelObject->getSuffix(); - $text = $levelObject->getText(); - $align = $levelObject->getAlign(); $tabPos = $levelObject->getTabPos(); $left = $levelObject->getLeft(); $hanging = $levelObject->getHanging(); @@ -81,36 +75,25 @@ public function writeNumbering() $xmlWriter->startElement('w:lvl'); $xmlWriter->writeAttribute('w:ilvl', $levelNum); - if (!is_null($start)) { - $xmlWriter->startElement('w:start'); - $xmlWriter->writeAttribute('w:val', $start); - $xmlWriter->endElement(); // w:start - } - if (!is_null($format)) { - $xmlWriter->startElement('w:numFmt'); - $xmlWriter->writeAttribute('w:val', $format); - $xmlWriter->endElement(); // w:numFmt - } - if (!is_null($restart)) { - $xmlWriter->startElement('w:lvlRestart'); - $xmlWriter->writeAttribute('w:val', $restart); - $xmlWriter->endElement(); // w:lvlRestart - } - if (!is_null($suffix)) { - $xmlWriter->startElement('w:suff'); - $xmlWriter->writeAttribute('w:val', $suffix); - $xmlWriter->endElement(); // w:suff - } - if (!is_null($text)) { - $xmlWriter->startElement('w:lvlText'); - $xmlWriter->writeAttribute('w:val', $text); - $xmlWriter->endElement(); // w:start - } - if (!is_null($align)) { - $xmlWriter->startElement('w:lvlJc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); // w:lvlJc + // Numbering level properties + $properties = array( + 'start' => 'start', + 'format' => 'numFmt', + 'restart' => 'lvlRestart', + 'suffix' => 'suff', + 'text' => 'lvlText', + 'align' => 'lvlJc' + ); + foreach ($properties as $property => $nodeName) { + $getMethod = "get{$property}"; + if (!is_null($levelObject->$getMethod())) { + $xmlWriter->startElement("w:{$nodeName}"); + $xmlWriter->writeAttribute('w:val', $levelObject->$getMethod()); + $xmlWriter->endElement(); // w:start + } } + + // Paragraph styles if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { $xmlWriter->startElement('w:pPr'); if (!is_null($tabPos)) { @@ -133,6 +116,8 @@ public function writeNumbering() } $xmlWriter->endElement(); // w:pPr } + + // Font styles if (!is_null($font) || !is_null($hint)) { $xmlWriter->startElement('w:rPr'); $xmlWriter->startElement('w:rFonts'); @@ -182,4 +167,15 @@ private function getRandomHexNumber($length = 8) { return strtoupper(substr(md5(rand()), 0, $length)); } + + /** + * Write numbering + * + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeNumbering() + { + return $this->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 07b49753b3..4266450585 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -32,43 +32,6 @@ class Rels extends AbstractPart */ const RELS_BASE = 'http://schemas.openxmlformats.org/'; - /** - * Write _rels/.rels - */ - public function writeMainRels() - { - $xmlRels = array( - 'docProps/core.xml' => 'package/2006/relationships/metadata/core-properties', - 'docProps/app.xml' => 'officeDocument/2006/relationships/extended-properties', - 'word/document.xml' => 'officeDocument/2006/relationships/officeDocument', - ); - $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, $xmlRels); - - return $xmlWriter->getData(); - } - - /** - * Write word/_rels/document.xml.rels - * - * @param array $mediaRels - */ - public function writeDocRels($mediaRels) - { - $xmlRels = array( - 'styles.xml' => 'officeDocument/2006/relationships/styles', - 'numbering.xml' => 'officeDocument/2006/relationships/numbering', - 'settings.xml' => 'officeDocument/2006/relationships/settings', - 'theme/theme1.xml' => 'officeDocument/2006/relationships/theme', - 'webSettings.xml' => 'officeDocument/2006/relationships/webSettings', - 'fontTable.xml' => 'officeDocument/2006/relationships/fontTable', - ); - $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, $xmlRels, $mediaRels); - - return $xmlWriter->getData(); - } - /** * Write word/_rels/(header|footer|footnotes)*.xml.rels * @@ -90,7 +53,7 @@ public function writeMediaRels($mediaRels) * @param null|array $mediaRels * @param integer $relId */ - private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1) + protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1) { $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('Relationships'); diff --git a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php new file mode 100644 index 0000000000..1588440669 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php @@ -0,0 +1,47 @@ + 'officeDocument/2006/relationships/styles', + 'numbering.xml' => 'officeDocument/2006/relationships/numbering', + 'settings.xml' => 'officeDocument/2006/relationships/settings', + 'theme/theme1.xml' => 'officeDocument/2006/relationships/theme', + 'webSettings.xml' => 'officeDocument/2006/relationships/webSettings', + 'fontTable.xml' => 'officeDocument/2006/relationships/fontTable', + ); + $xmlWriter = $this->getXmlWriter(); + $this->writeRels($xmlWriter, $xmlRels, $this->parentWriter->getRelationships()); + + return $xmlWriter->getData(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Part/RelsMain.php b/src/PhpWord/Writer/Word2007/Part/RelsMain.php new file mode 100644 index 0000000000..ec29981e1d --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Part/RelsMain.php @@ -0,0 +1,44 @@ + 'package/2006/relationships/metadata/core-properties', + 'docProps/app.xml' => 'officeDocument/2006/relationships/extended-properties', + 'word/document.xml' => 'officeDocument/2006/relationships/officeDocument', + ); + $xmlWriter = $this->getXmlWriter(); + $this->writeRels($xmlWriter, $xmlRels); + + return $xmlWriter->getData(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index 2b20a18a71..cafc03daca 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -25,7 +25,7 @@ class Settings extends AbstractPart /** * Write word/settings.xml */ - public function writeSettings() + public function write() { $settings = array( 'w:zoom' => array('@attributes' => array('w:percent' => '100')), @@ -136,4 +136,15 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) $xmlWriter->endElement(); } } + + /** + * Write word/settings.xml + * + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeSettings() + { + return $this->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 1c7b213415..4edd99aacd 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -38,12 +38,13 @@ class Styles extends AbstractPart /** * Write word/styles.xml * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return string */ - public function writeStyles(PhpWord $phpWord = null) + public function write() { + $phpWord = $this->parentWriter->getPhpWord(); if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); + throw new Exception('No PhpWord assigned.'); } $xmlWriter = $this->getXmlWriter(); @@ -219,4 +220,17 @@ private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $sty $xmlWriter->endElement(); // w:style } } + + /** + * Write word/styles.xml + * + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeStyles(PhpWord $phpWord = null) + { + $this->parentWriter->setPhpWord($phpWord); + return $this->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php index a82099b628..2dcf2e769c 100644 --- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php +++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php @@ -25,7 +25,7 @@ class WebSettings extends Settings /** * Write word/webSettings.xml */ - public function writeWebSettings() + public function write() { $settings = array( 'w:optimizeForBrowser' => '', @@ -46,4 +46,15 @@ public function writeWebSettings() return $xmlWriter->getData(); } + + /** + * Write word/webSettings.xml + * + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeWebSettings() + { + return $this->write(); + } } From 15c38960f7154f2e3572df1ba8075a00a96d014d Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Mon, 5 May 2014 23:38:31 +0200 Subject: [PATCH 036/167] Improved Test Unit for Image Style in line with additions of #217 --- tests/PhpWord/Tests/Style/ImageTest.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/PhpWord/Tests/Style/ImageTest.php b/tests/PhpWord/Tests/Style/ImageTest.php index db2aeb5597..1a679da3a2 100644 --- a/tests/PhpWord/Tests/Style/ImageTest.php +++ b/tests/PhpWord/Tests/Style/ImageTest.php @@ -1,9 +1,17 @@ 200, 'align' => 'left', 'marginTop' => 240, - 'marginLeft' => 240 + 'marginLeft' => 240, + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, + 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, + 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, + 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN, + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_IMARGIN ); foreach ($properties as $key => $value) { $get = "get{$key}"; From 13c178d140c9440aa561fe6620c4dde9b754b01b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 08:50:55 +0700 Subject: [PATCH 037/167] Refactor: Composite Word2007 & ODText writer parts --- src/PhpWord/Settings.php | 3 +- src/PhpWord/Template.php | 28 +++++-- src/PhpWord/Writer/AbstractWriter.php | 34 ++++---- src/PhpWord/Writer/HTML.php | 3 +- src/PhpWord/Writer/HTML/Element/Element.php | 3 +- src/PhpWord/Writer/ODText.php | 27 +++--- src/PhpWord/Writer/ODText/Element/Element.php | 3 +- src/PhpWord/Writer/ODText/Element/Table.php | 3 +- src/PhpWord/Writer/ODText/Part/Content.php | 13 ++- src/PhpWord/Writer/ODText/Part/Manifest.php | 39 ++++----- src/PhpWord/Writer/ODText/Part/Meta.php | 48 ++++------- src/PhpWord/Writer/ODText/Part/Mimetype.php | 8 +- src/PhpWord/Writer/ODText/Part/Styles.php | 14 +--- src/PhpWord/Writer/RTF.php | 5 +- src/PhpWord/Writer/Word2007.php | 83 +++++++++++-------- .../Writer/Word2007/Element/Element.php | 3 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 4 +- .../Writer/Word2007/Part/ContentTypes.php | 21 ++--- .../Writer/Word2007/Part/DocPropsApp.php | 14 ++-- .../Writer/Word2007/Part/DocPropsCore.php | 14 ++-- src/PhpWord/Writer/Word2007/Part/Document.php | 27 ++---- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 2 +- .../Writer/Word2007/Part/FontTable.php | 2 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 35 ++++++-- .../Writer/Word2007/Part/Footnotes.php | 33 ++++++-- src/PhpWord/Writer/Word2007/Part/Header.php | 14 +--- .../Writer/Word2007/Part/Numbering.php | 23 ++--- src/PhpWord/Writer/Word2007/Part/Rels.php | 19 +++-- .../Writer/Word2007/Part/RelsDocument.php | 10 +-- .../Part/{RelsMain.php => RelsPart.php} | 37 ++++++--- src/PhpWord/Writer/Word2007/Part/Settings.php | 17 +--- src/PhpWord/Writer/Word2007/Part/Styles.php | 24 +----- src/PhpWord/Writer/Word2007/Part/Theme.php | 6 +- .../Writer/Word2007/Part/WebSettings.php | 17 +--- src/PhpWord/Writer/Word2007/Style/Section.php | 25 ++++-- tests/PhpWord/Tests/Style/SectionTest.php | 3 +- tests/PhpWord/Tests/Writer/HTMLTest.php | 3 +- .../Tests/Writer/ODText/Part/ContentTest.php | 12 --- .../Tests/Writer/ODText/Part/MetaTest.php | 40 --------- .../Tests/Writer/ODText/Part/StylesTest.php | 40 --------- tests/PhpWord/Tests/Writer/RTFTest.php | 3 +- .../Writer/Word2007/Part/DocPropsTest.php | 52 ------------ .../Writer/Word2007/Part/DocumentTest.php | 16 +--- .../Tests/Writer/Word2007/Part/FooterTest.php | 8 +- .../Tests/Writer/Word2007/Part/HeaderTest.php | 6 +- .../Tests/Writer/Word2007/Part/StylesTest.php | 12 --- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- 47 files changed, 350 insertions(+), 508 deletions(-) rename src/PhpWord/Writer/Word2007/Part/{RelsMain.php => RelsPart.php} (63%) delete mode 100644 tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php delete mode 100644 tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php delete mode 100644 tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 9fc1156846..b8dfe8cd87 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -237,7 +237,8 @@ public static function getMeasurementUnit() */ public static function setMeasurementUnit($value) { - $units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH, self::UNIT_POINT, self::UNIT_PICA); + $units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH, + self::UNIT_POINT, self::UNIT_PICA); if (!in_array($value, $units)) { return false; } diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 97bd601ed6..1c2a5cdbb7 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -205,7 +205,8 @@ public function cloneRow($search, $numberOfClones) // If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row. $tmpXmlRow = $this->getSlice($extraRowStart, $extraRowEnd); - if (!preg_match('##', $tmpXmlRow) && !preg_match('##', $tmpXmlRow)) { + if (!preg_match('##', $tmpXmlRow) && + !preg_match('##', $tmpXmlRow)) { break; } // This row was a spanned row, update $rowEnd and search for the next row. @@ -234,7 +235,12 @@ public function cloneRow($search, $numberOfClones) public function cloneBlock($blockname, $clones = 1, $replace = true) { $xmlBlock = null; - preg_match('/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', $this->documentXML, $matches); + $pattern = + preg_match( + '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + $this->documentXML, + $matches + ); if (isset($matches[3])) { $xmlBlock = $matches[3]; @@ -244,7 +250,11 @@ public function cloneBlock($blockname, $clones = 1, $replace = true) } if ($replace) { - $this->documentXML = str_replace($matches[2] . $matches[3] . $matches[4], implode('', $cloned), $this->documentXML); + $this->documentXML = str_replace( + $matches[2] . $matches[3] . $matches[4], + implode('', $cloned), + $this->documentXML + ); } } @@ -259,10 +269,18 @@ public function cloneBlock($blockname, $clones = 1, $replace = true) */ public function replaceBlock($blockname, $replacement) { - preg_match('/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', $this->documentXML, $matches); + preg_match( + '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + $this->documentXML, + $matches + ); if (isset($matches[3])) { - $this->documentXML = str_replace($matches[2] . $matches[3] . $matches[4], $replacement, $this->documentXML); + $this->documentXML = str_replace( + $matches[2] . $matches[3] . $matches[4], + $replacement, + $this->documentXML + ); } } diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 2ae65f39af..f1a3002688 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -35,6 +35,13 @@ abstract class AbstractWriter implements WriterInterface */ protected $phpWord = null; + /** + * Part name and file name pairs + * + * @var array + */ + protected $parts = array(); + /** * Individual writers * @@ -114,13 +121,13 @@ public function setPhpWord(PhpWord $phpWord = null) /** * Get writer part * - * @param string $pPartName Writer part name + * @param string $partName Writer part name * @return mixed */ - public function getWriterPart($pPartName = '') + public function getWriterPart($partName = '') { - if ($pPartName != '' && isset($this->writerParts[strtolower($pPartName)])) { - return $this->writerParts[strtolower($pPartName)]; + if ($partName != '' && isset($this->writerParts[strtolower($partName)])) { + return $this->writerParts[strtolower($partName)]; } else { return null; } @@ -139,19 +146,19 @@ public function isUseDiskCaching() /** * Set use disk caching status * - * @param bool $pValue - * @param string $pDirectory + * @param bool $value + * @param string $directory * @return self */ - public function setUseDiskCaching($pValue = false, $pDirectory = null) + public function setUseDiskCaching($value = false, $directory = null) { - $this->useDiskCaching = $pValue; + $this->useDiskCaching = $value; - if (!is_null($pDirectory)) { - if (is_dir($pDirectory)) { - $this->diskCachingDirectory = $pDirectory; + if (!is_null($directory)) { + if (is_dir($directory)) { + $this->diskCachingDirectory = $directory; } else { - throw new Exception("Directory does not exist: $pDirectory"); + throw new Exception("Directory does not exist: $directory"); } } @@ -227,7 +234,7 @@ protected function cleanupTempFile() { if ($this->originalFilename != $this->tempFilename) { if (copy($this->tempFilename, $this->originalFilename) === false) { - throw new Exception("Could not copy temporary zip file {$this->tempFilename} to {$this->originalFilename}."); + throw new Exception("Could not copy temporary zip file."); } @unlink($this->tempFilename); } @@ -258,7 +265,6 @@ protected function getZipArchive($filename) $objZip = new $zipClass(); // Retrieve OVERWRITE and CREATE constants from the instantiated zip class - // This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP $reflection = new \ReflectionObject($objZip); $zipOverWrite = $reflection->getConstant('OVERWRITE'); $zipCreate = $reflection->getConstant('CREATE'); diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index d08f704fcc..d8ecd31f36 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -188,7 +188,8 @@ private function writeNotes() if (array_key_exists($noteTypeId, $collection)) { $element = $collection[$noteTypeId]; $elmWriter = new TextRunWriter($this, $element, true); - $content = "{$noteId}" . $elmWriter->write(); + $content = "{$noteId}"; + $content .= $elmWriter->write(); $html .= "

{$content}

" . PHP_EOL; } } diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index 82326c1710..bd8d38b6f3 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -23,7 +23,8 @@ /** * Generic element HTML writer * - * Section: Text, TextRun, Link, Title, PreserveText, TextBreak, PageBreak, Table, ListItem, Image, Object, Endnote, Footnote + * Section: Text, TextRun, Link, Title, PreserveText, TextBreak, PageBreak, Table, ListItem, Image, + * Object, Endnote, Footnote * Cell: Text, TextRun, Link, PreserveText, TextBreak, ListItem, Image, Object, Endnote, Footnote * TextRun: Text, Link, TextBreak, Image, Endnote, Footnote * diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index afd4a81b6d..fa290206df 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -39,14 +39,19 @@ public function __construct(PhpWord $phpWord = null) $this->setPhpWord($phpWord); // Create parts - $parts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles'); - foreach ($parts as $part) { - $partName = strtolower($part); - $partClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\' . $part; + $this->parts = array( + 'Mimetype' => 'mimetype', + 'Content' => 'content.xml', + 'Meta' => 'meta.xml', + 'Styles' => 'styles.xml', + 'Manifest' => 'META-INF/manifest.xml', + ); + foreach (array_keys($this->parts) as $partName) { + $partClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\' . $partName; if (class_exists($partClass)) { $partObject = new $partClass(); $partObject->setParentWriter($this); - $this->writerParts[$partName] = $partObject; + $this->writerParts[strtolower($partName)] = $partObject; } } @@ -72,12 +77,12 @@ public function save($filename = null) $this->addFilesToPackage($objZip, $sectionMedia); } - // Add parts - $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype()); - $objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->phpWord)); - $objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->phpWord)); - $objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->phpWord)); - $objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest()); + // Write parts + foreach ($this->parts as $partName => $fileName) { + if ($fileName != '') { + $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); + } + } // Close file if ($objZip->close() === false) { diff --git a/src/PhpWord/Writer/ODText/Element/Element.php b/src/PhpWord/Writer/ODText/Element/Element.php index c9df774a18..e5038d21d6 100644 --- a/src/PhpWord/Writer/ODText/Element/Element.php +++ b/src/PhpWord/Writer/ODText/Element/Element.php @@ -59,9 +59,10 @@ class Element /** * Create new instance * + * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param bool $withoutP */ - public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false) + public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, $element, $withoutP = false) { $this->xmlWriter = $xmlWriter; $this->parentWriter = $parentWriter; diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 7dd09ce808..fcd1461a6d 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -56,7 +56,8 @@ public function write() $elementWriter->write(); } } else { - $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, new TextBreakElement()); + $element = new TextBreakElement(); + $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, $element); $elementWriter->write(); } $this->xmlWriter->endElement(); // table:table-cell diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index a777ad5dd7..231e3b0d6d 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -29,21 +29,18 @@ use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; /** - * ODText content part writer + * ODText content part writer: content.xml */ class Content extends AbstractPart { /** - * Write content file to XML format + * Write part * - * @param \PhpOffice\PhpWord\PhpWord $phpWord - * @return string XML Output + * @return string */ - public function writeContent(PhpWord $phpWord = null) + public function write() { - if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); - } + $phpWord = $this->getParentWriter()->getPhpWord(); $xmlWriter = $this->getXmlWriter(); $xmlWriter->startDocument('1.0', 'UTF-8'); diff --git a/src/PhpWord/Writer/ODText/Part/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php index 2b18d2a4da..7c695e9bd4 100644 --- a/src/PhpWord/Writer/ODText/Part/Manifest.php +++ b/src/PhpWord/Writer/ODText/Part/Manifest.php @@ -20,49 +20,38 @@ use PhpOffice\PhpWord\Media; /** - * ODText manifest part writer + * ODText manifest part writer: META-INF/manifest.xml */ class Manifest extends AbstractPart { /** - * Write Manifest file to XML format + * Write part * - * @return string XML Output + * @return string */ - public function writeManifest() + public function write() { - // Create XML writer + $parts = array('content.xml', 'meta.xml', 'styles.xml'); $xmlWriter = $this->getXmlWriter(); - // XML header $xmlWriter->startDocument('1.0', 'UTF-8'); - - // manifest:manifest $xmlWriter->startElement('manifest:manifest'); $xmlWriter->writeAttribute('manifest:version', '1.2'); $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); - // manifest:file-entry $xmlWriter->startElement('manifest:file-entry'); $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); - $xmlWriter->writeAttribute('manifest:version', '1.2'); $xmlWriter->writeAttribute('manifest:full-path', '/'); + $xmlWriter->writeAttribute('manifest:version', '1.2'); $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'content.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml'); - $xmlWriter->endElement(); + + // Parts + foreach ($parts as $part) { + $xmlWriter->startElement('manifest:file-entry'); + $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); + $xmlWriter->writeAttribute('manifest:full-path', $part); + $xmlWriter->endElement(); + } // Media files $media = Media::getElements('section'); diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index df07426da8..ec1ee4c1e1 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -21,29 +21,22 @@ use PhpOffice\PhpWord\PhpWord; /** - * ODText meta part writer + * ODText meta part writer: meta.xml */ class Meta extends AbstractPart { /** - * Write Meta file to XML format + * Write part * - * @param \PhpOffice\PhpWord\PhpWord $phpWord - * @return string XML Output + * @return string */ - public function writeMeta(PhpWord $phpWord = null) + public function write() { - if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); - } - - // Create XML writer + $phpWord = $this->getParentWriter()->getPhpWord(); + $docProps = $phpWord->getDocumentProperties(); $xmlWriter = $this->getXmlWriter(); - // XML header $xmlWriter->startDocument('1.0', 'UTF-8'); - - // office:document-meta $xmlWriter->startElement('office:document-meta'); $xmlWriter->writeAttribute('office:version', '1.2'); $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); @@ -55,27 +48,18 @@ public function writeMeta(PhpWord $phpWord = null) // office:meta $xmlWriter->startElement('office:meta'); - - // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy()); - // dc:date - $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified())); - // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - // meta:creation-date - $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated())); - // meta:initial-creator - $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator()); - // meta:keyword - $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords()); + $xmlWriter->writeElement('dc:creator', $docProps->getLastModifiedBy()); + $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $docProps->getModified())); + $xmlWriter->writeElement('dc:description', $docProps->getDescription()); + $xmlWriter->writeElement('dc:subject', $docProps->getSubject()); + $xmlWriter->writeElement('dc:title', $docProps->getTitle()); + $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $docProps->getCreated())); + $xmlWriter->writeElement('meta:initial-creator', $docProps->getCreator()); + $xmlWriter->writeElement('meta:keyword', $docProps->getKeywords()); // @todo : Where these properties are written ? - // $phpWord->getDocumentProperties()->getCategory() - // $phpWord->getDocumentProperties()->getCompany() + // $docProps->getCategory() + // $docProps->getCompany() $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/ODText/Part/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php index ebb09f58c2..1da4edb0b5 100644 --- a/src/PhpWord/Writer/ODText/Part/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php @@ -18,16 +18,16 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; /** - * ODText mimetype part writer + * ODText mimetype part writer: mimetype */ class Mimetype extends AbstractPart { /** - * Write Mimetype to Text format + * Write part * - * @return string Text Output + * @return string */ - public function writeMimetype() + public function write() { return 'application/vnd.oasis.opendocument.text'; } diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index 7dde4031ef..270ef15de5 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -22,23 +22,17 @@ use PhpOffice\PhpWord\Style; /** - * ODText styloes part writer + * ODText styloes part writer: styles.xml */ class Styles extends AbstractPart { /** - * Write Styles file to XML format + * Write part * - * @param \PhpOffice\PhpWord\PhpWord $phpWord - * @return string XML Output + * @return string */ - public function writeStyles(PhpWord $phpWord = null) + public function write() { - if (is_null($phpWord)) { - throw new Exception("No PhpWord assigned."); - } - - // Create XML writer $xmlWriter = $this->getXmlWriter(); // XML header diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 2c2b012f7a..4a63fdcc84 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -260,6 +260,7 @@ private function populateFontTable() private function populateColorTable() { $phpWord = $this->phpWord; + $defaultFontColor = PhpWord::DEFAULT_FONT_COLOR; $arrColors = array(); // PhpWord object : $this->phpWord @@ -272,10 +273,10 @@ private function populateColorTable() if ($style instanceof Font) { $color = $style->getColor(); $fgcolor = $style->getFgColor(); - if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) { + if (!in_array($color, $arrColors) && $color != $defaultFontColor && !empty($color)) { $arrColors[] = $color; } - if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { + if (!in_array($fgcolor, $arrColors) && $fgcolor != $defaultFontColor && !empty($fgcolor)) { $arrColors[] = $fgcolor; } } diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 8b91d03652..07eef989d6 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -52,16 +52,31 @@ public function __construct(PhpWord $phpWord = null) $this->setPhpWord($phpWord); // Create parts - $parts = array('ContentTypes', 'RelsMain', 'RelsDocument', 'DocPropsApp', 'DocPropsCore', 'Document', 'Styles', - 'Numbering', 'Settings', 'WebSettings', 'Header', 'Footer', 'Footnotes', - 'Endnotes', 'FontTable', 'Theme'); - foreach ($parts as $part) { - $partName = strtolower($part); - $partClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\' . $part; + $this->parts = array( + 'ContentTypes' => '[Content_Types].xml', + 'Rels' => '_rels/.rels', + 'DocPropsApp' => 'docProps/app.xml', + 'DocPropsCore' => 'docProps/core.xml', + 'RelsDocument' => 'word/_rels/document.xml.rels', + 'Document' => 'word/document.xml', + 'Styles' => 'word/styles.xml', + 'Numbering' => 'word/numbering.xml', + 'Settings' => 'word/settings.xml', + 'WebSettings' => 'word/webSettings.xml', + 'FontTable' => 'word/fontTable.xml', + 'Theme' => 'word/theme/theme1.xml', + 'RelsPart' => '', + 'Header' => '', + 'Footer' => '', + 'Footnotes' => '', + 'Endnotes' => '', + ); + foreach (array_keys($this->parts) as $partName) { + $partClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\' . $partName; if (class_exists($partClass)) { $partObject = new $partClass(); $partObject->setParentWriter($this); - $this->writerParts[$partName] = $partObject; + $this->writerParts[strtolower($partName)] = $partObject; } } @@ -112,18 +127,11 @@ public function save($filename = null) $this->addNotes($objZip, $rId, 'endnote'); // Write parts - $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->write()); - $objZip->addFromString('_rels/.rels', $this->getWriterPart('relsmain')->write()); - $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docpropsapp')->write()); - $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docpropscore')->write()); - $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('relsdocument')->write()); - $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->write()); - $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->write()); - $objZip->addFromString('word/numbering.xml', $this->getWriterPart('numbering')->write()); - $objZip->addFromString('word/settings.xml', $this->getWriterPart('settings')->write()); - $objZip->addFromString('word/webSettings.xml', $this->getWriterPart('websettings')->write()); - $objZip->addFromString('word/fontTable.xml', $this->getWriterPart('fonttable')->write()); - $objZip->addFromString('word/theme/theme1.xml', $this->getWriterPart('theme')->write()); + foreach ($this->parts as $partName => $fileName) { + if ($fileName != '') { + $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); + } + } // Close file if ($objZip->close() === false) { @@ -157,7 +165,7 @@ public function getRelationships() } /** - * Add header/footer media files + * Add header/footer media files, e.g. footer1.xml.rels * * @param mixed $objZip * @param string $docPart @@ -172,8 +180,9 @@ private function addHeaderFooterMedia($objZip, $docPart) $this->addFilesToPackage($objZip, $media); $this->registerContentTypes($media); } - $relsFile = "word/_rels/{$file}.xml.rels"; - $objZip->addFromString($relsFile, $this->getWriterPart('rels')->writeMediaRels($media)); + + $writerPart = $this->getWriterPart('relspart')->setMedia($media); + $objZip->addFromString("word/_rels/{$file}.xml.rels", $writerPart->write()); } } } @@ -183,22 +192,23 @@ private function addHeaderFooterMedia($objZip, $docPart) * Add header/footer content * * @param mixed $objZip - * @param string $elmType + * @param string $elmType header|footer * @param integer $rId */ private function addHeaderFooterContent(Section &$section, $objZip, $elmType, &$rId) { $getFunction = $elmType == 'header' ? 'getHeaders' : 'getFooters'; - $writeFunction = $elmType == 'header' ? 'writeHeader' : 'writeFooter'; $elmCount = ($section->getSectionId() - 1) * 3; - $elmObjects = $section->$getFunction(); - foreach ($elmObjects as &$elmObject) { + $elements = $section->$getFunction(); + foreach ($elements as &$element) { $elmCount++; - $elmObject->setRelationId(++$rId); - $elmFile = "{$elmType}{$elmCount}.xml"; - $objZip->addFromString("word/$elmFile", $this->getWriterPart($elmType)->$writeFunction($elmObject)); + $element->setRelationId(++$rId); + $elmFile = "{$elmType}{$elmCount}.xml"; // e.g. footer1.xml $this->contentTypes['override']["/word/$elmFile"] = $elmType; $this->relationships[] = array('target' => $elmFile, 'type' => $elmType, 'rID' => $rId); + + $writerPart = $this->getWriterPart($elmType)->setElement($element); + $objZip->addFromString("word/$elmFile", $writerPart->write()); } } @@ -221,13 +231,18 @@ private function addNotes($objZip, &$rId, $noteType = 'footnote') $media = Media::getElements($noteType); $this->addFilesToPackage($objZip, $media); $this->registerContentTypes($media); - if (!empty($media)) { - $objZip->addFromString("word/_rels/{$partName}.xml.rels", $this->getWriterPart('rels')->writeMediaRels($media)); - } - $elements = $collection->getItems(); - $objZip->addFromString("word/{$partName}.xml", $this->getWriterPart($partName)->write($elements)); $this->contentTypes['override']["/word/{$partName}.xml"] = $partName; $this->relationships[] = array('target' => "{$partName}.xml", 'type' => $partName, 'rID' => ++$rId); + + // Write relationships file, e.g. word/_rels/footnotes.xml + if (!empty($media)) { + $writerPart = $this->getWriterPart('relspart')->setMedia($media); + $objZip->addFromString("word/_rels/{$partName}.xml.rels", $writerPart->write()); + } + + // Write content file, e.g. word/footnotes.xml + $writerPart = $this->getWriterPart($partName)->setElements($collection->getItems()); + $objZip->addFromString("word/{$partName}.xml", $writerPart->write()); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/Element.php index acccd81dd1..89d92ac542 100644 --- a/src/PhpWord/Writer/Word2007/Element/Element.php +++ b/src/PhpWord/Writer/Word2007/Element/Element.php @@ -59,9 +59,10 @@ class Element /** * Create new instance * + * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param bool $withoutP */ - public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false) + public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, $element, $withoutP = false) { $this->xmlWriter = $xmlWriter; $this->parentWriter = $parentWriter; diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index fc91ee9080..5c2496cb88 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -81,6 +81,8 @@ public function write() if ($tocFieldWritten !== true) { $tocFieldWritten = true; + $minDepth = $this->element->getMinDepth(); + $maxDepth = $this->element->getMaxDepth(); $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:fldChar'); @@ -91,7 +93,7 @@ public function write() $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:instrText'); $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw('TOC \o "' . $this->element->getMinDepth() . '-' . $this->element->getMaxDepth() . '" \h \z \u'); + $this->xmlWriter->writeRaw("TOC \o {$minDepth}-{$maxDepth} \h \z \u"); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 3af420cc56..3af62a44c5 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -21,16 +21,18 @@ use PhpOffice\PhpWord\Shared\XMLWriter; /** - * Word2007 contenttypes part writer + * Word2007 contenttypes part writer: [Content_Types].xml */ class ContentTypes extends AbstractPart { /** - * Write [Content_Types].xml + * Write part + * + * @return string */ public function write() { - $contentTypes = $this->parentWriter->getContentTypes(); + $contentTypes = $this->getParentWriter()->getContentTypes(); $openXMLPrefix = 'application/vnd.openxmlformats-'; $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; @@ -90,17 +92,4 @@ private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault) } } } - - /** - * Write [Content_Types].xml - * - * @param array $contentTypes - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeContentTypes($contentTypes) - { - $contentTypes = null; // dummy assignment - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php index 06a4e7802a..99b2c56723 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php @@ -21,26 +21,26 @@ use PhpOffice\PhpWord\PhpWord; /** - * Word2007 extended document properties part writer + * Word2007 extended document properties part writer: docProps/app.xml * * @since 0.11.0 */ class DocPropsApp extends AbstractPart { /** - * Write docProps/app.xml + * Write part + * + * @return string */ public function write() { - $phpWord = $this->parentWriter->getPhpWord(); - if (is_null($phpWord)) { - throw new Exception('No PhpWord assigned.'); - } + $phpWord = $this->getParentWriter()->getPhpWord(); $xmlWriter = $this->getXmlWriter(); + $schema = 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('Properties'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); + $xmlWriter->writeAttribute('xmlns', $schema); $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $xmlWriter->writeElement('Application', 'PHPWord'); diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php index 95fb213ee2..2e9a329fa6 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php @@ -21,26 +21,26 @@ use PhpOffice\PhpWord\PhpWord; /** - * Word2007 core document properties part writer + * Word2007 core document properties part writer: docProps/core.xml * * @since 0.11.0 */ class DocPropsCore extends AbstractPart { /** - * Write docProps/core.xml + * Write part + * + * @return string */ public function write() { - $phpWord = $this->parentWriter->getPhpWord(); - if (is_null($phpWord)) { - throw new Exception('No PhpWord assigned.'); - } + $phpWord = $this->getParentWriter()->getPhpWord(); $xmlWriter = $this->getXmlWriter(); + $schema = 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('cp:coreProperties'); - $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + $xmlWriter->writeAttribute('xmlns:cp', $schema); $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 47f7e02db3..a25588f825 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -24,26 +24,24 @@ use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; /** - * Word2007 document part writer + * Word2007 document part writer: word/document.xml */ class Document extends AbstractPart { /** - * Write word/document.xml + * Write part * * @return string - * @throws \PhpOffice\PhpWord\Exception\Exception */ public function write() { - $phpWord = $this->parentWriter->getPhpWord(); - if (is_null($phpWord)) { - throw new Exception('No PhpWord assigned.'); - } + $phpWord = $this->getParentWriter()->getPhpWord(); $xmlWriter = $this->getXmlWriter(); + $sections = $phpWord->getSections(); $sectionCount = count($sections); $currentSection = 0; + $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('w:document'); @@ -52,7 +50,7 @@ public function write() $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema); $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); @@ -133,17 +131,4 @@ private function writeSectionSettings(XMLWriter $xmlWriter, Section $section) $xmlWriter->endElement(); // w:sectPr } - - /** - * Write word/document.xml - * - * @param \PhpOffice\PhpWord\PhpWord $phpWord - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeDocument(PhpWord $phpWord = null) - { - $this->parentWriter->setPhpWord($phpWord); - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php index ad97be417b..f07bac5f70 100644 --- a/src/PhpWord/Writer/Word2007/Part/Endnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; /** - * Word2007 endnotes part writer + * Word2007 endnotes part writer: word/endnotes.xml */ class Endnotes extends Footnotes { diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php index 52eeb00f84..e894cd23ed 100644 --- a/src/PhpWord/Writer/Word2007/Part/FontTable.php +++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; /** - * Word2007 font table writer + * Word2007 font table writer: word/fontTable.xml * * @since 0.10.0 */ diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index dded826610..12a7b1aadf 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -17,10 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Element\AbstractContainer as Container; - /** - * Word2007 footer part writer + * Word2007 footer part writer: word/footerx.xml */ class Footer extends AbstractPart { @@ -32,13 +30,21 @@ class Footer extends AbstractPart protected $rootElement = 'w:ftr'; /** - * Write word/footerx.xml + * Footer/header element to be written + * + * @var \PhpOffice\PhpWord\Element\Footer + */ + protected $element; + + /** + * Write part * - * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @return string */ - public function writeFooter(Container $element) + public function write() { $xmlWriter = $this->getXmlWriter(); + $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement($this->rootElement); @@ -47,15 +53,28 @@ public function writeFooter(Container $element) $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema); $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - $this->writeContainerElements($xmlWriter, $element); + $this->writeContainerElements($xmlWriter, $this->element); $xmlWriter->endElement(); // $this->rootElement return $xmlWriter->getData(); } + + /** + * Set element + * + * @param \PhpOffice\PhpWord\Element\Footer|\PhpOffice\PhpWord\Element\Header $element + * @return self + */ + public function setElement($element) + { + $this->element = $element; + + return $this; + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 42ea99058d..7e09446db2 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -22,7 +22,7 @@ use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; /** - * Word2007 footnotes part writer + * Word2007 footnotes part writer: word/(footnotes|endnotes).xml */ class Footnotes extends AbstractPart { @@ -55,13 +55,21 @@ class Footnotes extends AbstractPart protected $refStyle = 'FootnoteReference'; /** - * Write word/(footnotes|endnotes).xml + * Footnotes/endnotes collection to be written * - * @param array $elements + * @var \PhpOffice\PhpWord\Collection\Footnotes|\PhpOffice\PhpWord\Collection\Endnotes */ - public function write($elements) + protected $elements; + + /** + * Write part + * + * @return string + */ + public function write() { $xmlWriter = $this->getXmlWriter(); + $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement($this->rootNode); @@ -70,7 +78,7 @@ public function write($elements) $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema); $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); @@ -98,7 +106,7 @@ public function write($elements) $xmlWriter->endElement(); // $this->elementNode // Content - foreach ($elements as $element) { + foreach ($this->elements as $element) { if ($element instanceof Footnote) { $this->writeNote($xmlWriter, $element); } @@ -109,6 +117,19 @@ public function write($elements) return $xmlWriter->getData(); } + /** + * Set element + * + * @param \PhpOffice\PhpWord\Collection\Footnotes|\PhpOffice\PhpWord\Collection\Endnotes $elements + * @return self + */ + public function setElements($elements) + { + $this->elements = $elements; + + return $this; + } + /** * Write note item * diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php index 2b515c4737..638111d7f3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Header.php +++ b/src/PhpWord/Writer/Word2007/Part/Header.php @@ -17,10 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Element\AbstractContainer as Container; - /** - * Word2007 header part writer + * Word2007 header part writer: word/headerx.xml */ class Header extends Footer { @@ -30,14 +28,4 @@ class Header extends Footer * @var string */ protected $rootElement = 'w:hdr'; - - /** - * Write word/headerx.xml - * - * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - */ - public function writeHeader(Container $element) - { - return $this->writeFooter($element); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 1ff57e2b90..6f042b4a57 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -22,18 +22,20 @@ use PhpOffice\PhpWord\Style; /** - * Word2007 numbering part writer + * Word2007 numbering part writer: word/numbering.xml */ class Numbering extends AbstractPart { /** - * Write word/numbering.xml + * Write part + * + * @return string */ public function write() { - $styles = Style::getStyles(); - $xmlWriter = $this->getXmlWriter(); + $styles = Style::getStyles(); + $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'; $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('w:numbering'); @@ -42,7 +44,7 @@ public function write() $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); + $xmlWriter->writeAttribute('xmlns:wp', $drawingSchema); $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); @@ -167,15 +169,4 @@ private function getRandomHexNumber($length = 8) { return strtoupper(substr(md5(rand()), 0, $length)); } - - /** - * Write numbering - * - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeNumbering() - { - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 4266450585..20076c4e83 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -21,7 +21,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter; /** - * Word2007 relationship writer + * Word2007 main relationship writer: _rels/.rels * * @since 0.10.0 */ @@ -33,14 +33,19 @@ class Rels extends AbstractPart const RELS_BASE = 'http://schemas.openxmlformats.org/'; /** - * Write word/_rels/(header|footer|footnotes)*.xml.rels + * Write part * - * @param array $mediaRels + * @return string */ - public function writeMediaRels($mediaRels) + public function write() { + $xmlRels = array( + 'docProps/core.xml' => 'package/2006/relationships/metadata/core-properties', + 'docProps/app.xml' => 'officeDocument/2006/relationships/extended-properties', + 'word/document.xml' => 'officeDocument/2006/relationships/officeDocument', + ); $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, null, $mediaRels); + $this->writeRels($xmlWriter, $xmlRels); return $xmlWriter->getData(); } @@ -73,10 +78,12 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = foreach ($mediaRels as $mediaRel) { $mediaType = $mediaRel['type']; $type = array_key_exists($mediaType, $mapping) ? $mapping[$mediaType] : $mediaType; + $type = "officeDocument/2006/relationships/{$type}"; $target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : ''; $target .= $mediaRel['target']; $targetMode = ($type == 'hyperlink') ? 'External' : ''; - $this->writeRel($xmlWriter, $relId++, "officeDocument/2006/relationships/{$type}", $target, $targetMode); + + $this->writeRel($xmlWriter, $relId++, $type, $target, $targetMode); } } diff --git a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php index 1588440669..e0773a4a8c 100644 --- a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php +++ b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php @@ -17,17 +17,17 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; - /** - * Word2007 document relationship writer + * Word2007 document relationship writer: word/_rels/document.xml.rels * * @since 0.11.0 */ class RelsDocument extends Rels { /** - * Write _rels/.rels + * Write part + * + * @return string */ public function write() { @@ -40,7 +40,7 @@ public function write() 'fontTable.xml' => 'officeDocument/2006/relationships/fontTable', ); $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, $xmlRels, $this->parentWriter->getRelationships()); + $this->writeRels($xmlWriter, $xmlRels, $this->getParentWriter()->getRelationships()); return $xmlWriter->getData(); } diff --git a/src/PhpWord/Writer/Word2007/Part/RelsMain.php b/src/PhpWord/Writer/Word2007/Part/RelsPart.php similarity index 63% rename from src/PhpWord/Writer/Word2007/Part/RelsMain.php rename to src/PhpWord/Writer/Word2007/Part/RelsPart.php index ec29981e1d..a3697834ae 100644 --- a/src/PhpWord/Writer/Word2007/Part/RelsMain.php +++ b/src/PhpWord/Writer/Word2007/Part/RelsPart.php @@ -17,28 +17,43 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; - /** - * Word2007 main relationship writer + * Word2007 part relationship writer: word/_rels/(header|footer|footnotes|endnotes)*.xml.rels * * @since 0.11.0 */ -class RelsMain extends Rels +class RelsPart extends Rels { /** - * Write _rels/.rels + * Media relationships + * + * @var array + */ + private $media = array(); + + /** + * Write part + * + * @return string */ public function write() { - $xmlRels = array( - 'docProps/core.xml' => 'package/2006/relationships/metadata/core-properties', - 'docProps/app.xml' => 'officeDocument/2006/relationships/extended-properties', - 'word/document.xml' => 'officeDocument/2006/relationships/officeDocument', - ); $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, $xmlRels); + $this->writeRels($xmlWriter, null, $this->media); return $xmlWriter->getData(); } + + /** + * Set media + * + * @param array $media + * @return self + */ + public function setMedia($media) + { + $this->media = $media; + + return $this; + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index cafc03daca..862e419e0a 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -18,12 +18,14 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; /** - * Word2007 settings part writer + * Word2007 settings part writer: word/settings.xml */ class Settings extends AbstractPart { /** - * Write word/settings.xml + * Write part + * + * @return string */ public function write() { @@ -136,15 +138,4 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) $xmlWriter->endElement(); } } - - /** - * Write word/settings.xml - * - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeSettings() - { - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 4edd99aacd..b6f64f6136 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -20,32 +20,29 @@ use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Table; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; /** - * Word2007 styles part writer + * Word2007 styles part writer: word/styles.xml * * @todo Do something with the numbering style introduced in 0.10.0 */ class Styles extends AbstractPart { /** - * Write word/styles.xml + * Write part * * @return string */ public function write() { - $phpWord = $this->parentWriter->getPhpWord(); - if (is_null($phpWord)) { - throw new Exception('No PhpWord assigned.'); - } + $phpWord = $this->getParentWriter()->getPhpWord(); $xmlWriter = $this->getXmlWriter(); $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); @@ -220,17 +217,4 @@ private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $sty $xmlWriter->endElement(); // w:style } } - - /** - * Write word/styles.xml - * - * @param \PhpOffice\PhpWord\PhpWord $phpWord - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeStyles(PhpWord $phpWord = null) - { - $this->parentWriter->setPhpWord($phpWord); - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Theme.php b/src/PhpWord/Writer/Word2007/Part/Theme.php index 76638e70f6..481b1d644d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Theme.php +++ b/src/PhpWord/Writer/Word2007/Part/Theme.php @@ -18,14 +18,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; /** - * Word2007 theme writer + * Word2007 theme writer: word/theme/theme1.xml * * @since 0.10.0 */ class Theme extends AbstractPart { /** - * Write theme/theme1.xml + * Write part + * + * @return string */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php index 2dcf2e769c..f800ebdeb8 100644 --- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php +++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php @@ -18,12 +18,14 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; /** - * Word2007 web settings part writer + * Word2007 web settings part writer: word/webSettings.xml */ class WebSettings extends Settings { /** - * Write word/webSettings.xml + * Write part + * + * @return string */ public function write() { @@ -46,15 +48,4 @@ public function write() return $xmlWriter->getData(); } - - /** - * Write word/webSettings.xml - * - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function writeWebSettings() - { - return $this->write(); - } } diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index 3d967e6e13..05fc1d0821 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -50,14 +50,20 @@ public function write() $this->xmlWriter->endElement(); // w:pgSz // Margins + $margins = array( + 'w:top' => array('getMarginTop', SectionStyle::DEFAULT_MARGIN), + 'w:right' => array('getMarginRight', SectionStyle::DEFAULT_MARGIN), + 'w:bottom' => array('getMarginBottom', SectionStyle::DEFAULT_MARGIN), + 'w:left' => array('getMarginLeft', SectionStyle::DEFAULT_MARGIN), + 'w:header' => array('getHeaderHeight', SectionStyle::DEFAULT_HEADER_HEIGHT), + 'w:footer' => array('getFooterHeight', SectionStyle::DEFAULT_FOOTER_HEIGHT), + 'w:gutter' => array('getGutter', SectionStyle::DEFAULT_GUTTER), + ); $this->xmlWriter->startElement('w:pgMar'); - $this->xmlWriter->writeAttribute('w:top', $this->convertTwip($this->style->getMarginTop(), SectionStyle::DEFAULT_MARGIN)); - $this->xmlWriter->writeAttribute('w:right', $this->convertTwip($this->style->getMarginRight(), SectionStyle::DEFAULT_MARGIN)); - $this->xmlWriter->writeAttribute('w:bottom', $this->convertTwip($this->style->getMarginBottom(), SectionStyle::DEFAULT_MARGIN)); - $this->xmlWriter->writeAttribute('w:left', $this->convertTwip($this->style->getMarginLeft(), SectionStyle::DEFAULT_MARGIN)); - $this->xmlWriter->writeAttribute('w:header', $this->convertTwip($this->style->getHeaderHeight(), SectionStyle::DEFAULT_HEADER_HEIGHT)); - $this->xmlWriter->writeAttribute('w:footer', $this->convertTwip($this->style->getFooterHeight(), SectionStyle::DEFAULT_FOOTER_HEIGHT)); - $this->xmlWriter->writeAttribute('w:gutter', $this->convertTwip($this->style->getGutter(), SectionStyle::DEFAULT_GUTTER)); + foreach ($margins as $attribute => $value) { + list($method, $default) = $value; + $this->xmlWriter->writeAttribute($attribute, $this->convertTwip($this->style->$method(), $default)); + } $this->xmlWriter->endElement(); // Borders @@ -91,7 +97,10 @@ public function write() // Columns $this->xmlWriter->startElement('w:cols'); $this->xmlWriter->writeAttribute('w:num', $this->style->getColsNum()); - $this->xmlWriter->writeAttribute('w:space', $this->convertTwip($this->style->getColsSpace(), SectionStyle::DEFAULT_COLUMN_SPACING)); + $this->xmlWriter->writeAttribute('w:space', $this->convertTwip( + $this->style->getColsSpace(), + SectionStyle::DEFAULT_COLUMN_SPACING + )); $this->xmlWriter->endElement(); // Line numbering diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 3ae06561b1..a6b386d925 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -63,7 +63,8 @@ public function testSettingValue() $this->assertEquals($iVal, $oSettings->getHeaderHeight()); $oSettings->setSettingValue('lineNumbering', array()); - $oSettings->setSettingValue('lineNumbering', array('start' => 1, 'increment' => 1, 'distance' => 240, 'restart' => 'newPage')); + $oSettings->setSettingValue('lineNumbering', array('start' => 1, 'increment' => 1, + 'distance' => 240, 'restart' => 'newPage')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\LineNumbering', $oSettings->getLineNumbering()); $oSettings->setSettingValue('lineNumbering', null); diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 5bfb2720bc..1c2a504960 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -64,7 +64,8 @@ public function testSave() $docProps = $phpWord->getDocumentProperties(); $docProps->setTitle('HTML Test'); - $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); + $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, + 'color' => 'FF0000', 'fgColor' => 'FF0000')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index cd2648660d..619e357345 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -36,18 +36,6 @@ public function tearDown() TestHelperDOCX::clear(); } - /** - * Test construct with no PhpWord - * - * @expectedException \PhpOffice\PhpWord\Exception\Exception - * @expectedExceptionMessage No PhpWord assigned. - */ - public function testConstructNoPhpWord() - { - $object = new Content(); - $object->writeContent(); - } - /** * Test write content */ diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php deleted file mode 100644 index 00dbf1ba63..0000000000 --- a/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php +++ /dev/null @@ -1,40 +0,0 @@ -writeMeta(); - } -} diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php deleted file mode 100644 index a0cbaf7dba..0000000000 --- a/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php +++ /dev/null @@ -1,40 +0,0 @@ -writeStyles(); - } -} diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index 2f7c040366..ad5a13e112 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -58,7 +58,8 @@ public function testSave() $file = __DIR__ . "/../_files/temp.rtf"; $phpWord = new PhpWord(); - $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); + $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, + 'color' => 'FF0000', 'fgColor' => 'FF0000')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php deleted file mode 100644 index 734cb76735..0000000000 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php +++ /dev/null @@ -1,52 +0,0 @@ -writeDocPropsApp(); - } - - /** - * Test write docProps/core.xml with no PhpWord - * - * @expectedException \PhpOffice\PhpWord\Exception\Exception - * @expectedExceptionMessage No PhpWord assigned. - */ - public function testWriteDocPropsCoreNoPhpWord() - { - $object = new DocProps(); - $object->writeDocPropsCore(); - } -} diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index d9c1f40fdc..8971133e2c 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -36,18 +36,6 @@ public function tearDown() TestHelperDOCX::clear(); } - /** - * Test write word/document.xm with no PhpWord - * - * @expectedException \PhpOffice\PhpWord\Exception\Exception - * @expectedExceptionMessage No PhpWord assigned. - */ - public function testWriteDocumentNoPhpWord() - { - $object = new Document(); - $object->writeDocument(); - } - /** * Write end section page numbering */ @@ -121,8 +109,8 @@ public function testElementStyles() $phpWord = new PhpWord(); $phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1 - $phpWord->addFontStyle('fStyle', array('size' => '20', 'doubleStrikethrough' => true, 'allCaps' => true)); // Style #2 - $phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); // Style #3 + $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true)); // Style #2 + $phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3 $fontStyle = new Font('text', array('align' => 'center')); $section = $phpWord->addSection(); $section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4 diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php index 50074c6b74..5c9d2d3081 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php @@ -29,8 +29,6 @@ class FooterTest extends \PHPUnit_Framework_TestCase { /** * Write footer - * - * @covers ::writeFooter */ public function testWriteFooter() { @@ -44,11 +42,11 @@ public function testWriteFooter() $container->addImage($imageSrc); $writer = new Word2007(); + $writer->setUseDiskCaching(true); $object = new Footer(); $object->setParentWriter($writer); - $object->writeFooter($container); - $writer->setUseDiskCaching(true); - $xml = simplexml_load_string($object->writeFooter($container)); + $object->setElement($container); + $xml = simplexml_load_string($object->write()); $this->assertInstanceOf('SimpleXMLElement', $xml); } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php index 85dab7782d..e8c31ecfb0 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php @@ -43,11 +43,11 @@ public function testWriteHeader() $container->addWatermark($imageSrc); $writer = new Word2007(); + $writer->setUseDiskCaching(true); $object = new Header(); $object->setParentWriter($writer); - $object->writeHeader($container); - $writer->setUseDiskCaching(true); - $xml = simplexml_load_string($object->writeHeader($container)); + $object->setElement($container); + $xml = simplexml_load_string($object->write()); $this->assertInstanceOf('SimpleXMLElement', $xml); } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php index c1a33f0a71..795d3e8a1d 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php @@ -36,18 +36,6 @@ public function tearDown() TestHelperDOCX::clear(); } - /** - * Test construct with no PhpWord - * - * @expectedException \PhpOffice\PhpWord\Exception\Exception - * @expectedExceptionMessage No PhpWord assigned. - */ - public function testConstructNoPhpWord() - { - $object = new Styles(); - $object->writeStyles(); - } - /** * Test write styles */ diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 46df1aaeb6..5ca5759c8e 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -45,7 +45,7 @@ public function testConstruct() $writerParts = array( 'ContentTypes' => 'ContentTypes', 'Rels' => 'Rels', - 'DocProps' => 'DocProps', + 'DocPropsApp' => 'DocPropsApp', 'Document' => 'Document', 'Styles' => 'Styles', 'Numbering' => 'Numbering', From 37152cd4594574ce72bcdb058546fad361ae7f8e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 16:53:15 +0700 Subject: [PATCH 038/167] Enable code coverage in Scrutinizer --- .scrutinizer.yml | 6 ++++-- .travis.yml | 2 ++ phpunit.xml.dist | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0b0464f7b0..37700c2c28 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -2,12 +2,14 @@ filter: excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ] before_commands: - - "composer self-update" - "composer install --prefer-source --dev" tools: - php_code_coverage: + external_code_coverage: enabled: true + timeout: 700 + php_code_coverage: + enabled: false test_command: phpunit -c phpunit.xml.dist php_sim: true php_pdepend: true diff --git a/.travis.yml b/.travis.yml index 41e3bebb25..67e9e8feb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,3 +63,5 @@ script: after_script: ## PHPDocumentor - bash .travis_shell_after_success.sh + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ce823a545b..09524450a8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,6 +22,10 @@ + + \ No newline at end of file From b3229c6a7b71991774b8af1e930bdb2bf3ec37a5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 17:13:16 +0700 Subject: [PATCH 039/167] Fix Travis test and update Scrutinizer config --- .scrutinizer.yml | 2 +- .travis.yml | 109 +++++++++--------- src/PhpWord/Template.php | 1 - src/PhpWord/Writer/ODText/Part/Content.php | 1 - src/PhpWord/Writer/ODText/Part/Meta.php | 1 - src/PhpWord/Writer/ODText/Part/Styles.php | 1 - .../Writer/Word2007/Part/DocPropsApp.php | 1 - .../Writer/Word2007/Part/DocPropsCore.php | 1 - src/PhpWord/Writer/Word2007/Part/Document.php | 1 - src/PhpWord/Writer/Word2007/Part/Styles.php | 1 - 10 files changed, 56 insertions(+), 63 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 37700c2c28..8efd68d3d6 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -7,7 +7,7 @@ before_commands: tools: external_code_coverage: enabled: true - timeout: 700 + timeout: 900 php_code_coverage: enabled: false test_command: phpunit -c phpunit.xml.dist diff --git a/.travis.yml b/.travis.yml index 67e9e8feb4..7593379cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,67 +1,68 @@ language: php php: - - 5.3.3 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm + - 5.3.3 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm matrix: - allow_failures: - - php: 5.3.3 - - php: 5.6 - - php: hhvm + allow_failures: + - php: 5.3.3 + - php: 5.6 + - php: hhvm env: - global: - - secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4=" + global: + - secure: "Sq+6bVtnPsu0mWX8DWQ+9bGAjxMcGorksUiHc4YIXEJsuDfVmVlH8tTD547IeCjDAx9MxXerZ2Z4HSjxTB70VEnJPvZMHI/EZn4Ny31YLHEthdZbV5Gd1h0TGp8VOzPKGShvGrtGBX6MvMfgpK4zuieVWbSfdKeecm8ZNLMpUd4=" before_script: - ## Packages - - sudo apt-get -qq update > /dev/null - - sudo apt-get -qq install graphviz > /dev/null - ## Composer - # - curl -s http://getcomposer.org/installer | php - # - php composer.phar install --prefer-source - - composer self-update - - composer require dompdf/dompdf:0.6.* - - composer install --prefer-source --dev - ## PHP_CodeSniffer - - pyrus install pear/PHP_CodeSniffer - - phpenv rehash - ## PHP Copy/Paste Detector - - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar - ## PHP Mess Detector - - pear config-set preferred_state beta - - printf "\n" | pecl install imagick - - pear channel-discover pear.phpmd.org - - pear channel-discover pear.pdepend.org - - pear install --alldeps phpmd/PHP_PMD - - phpenv rehash - ## PHPLOC - #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar - ## PHPDocumentor - - mkdir -p build/docs - - mkdir -p build/coverage + ## Packages + - sudo apt-get -qq update > /dev/null + - sudo apt-get -qq install graphviz > /dev/null + ## Composer + # - curl -s http://getcomposer.org/installer | php + # - php composer.phar install --prefer-source + - composer self-update + - composer require dompdf/dompdf:0.6.* + - composer install --prefer-source --dev + ## PHP_CodeSniffer + - pyrus install pear/PHP_CodeSniffer + - phpenv rehash + ## PHP Copy/Paste Detector + - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar + ## PHP Mess Detector + - pear config-set preferred_state beta + - printf "\n" | pecl install imagick + - pear channel-discover pear.phpmd.org + - pear channel-discover pear.pdepend.org + - pear install --alldeps phpmd/PHP_PMD + - phpenv rehash + ## PHPLOC + #- curl -o phploc.phar https://phar.phpunit.de/phploc.phar + ## PHPDocumentor + - mkdir -p build/docs + - mkdir -p build/coverage script: - ## PHP_CodeSniffer - - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip - ## PHP Copy/Paste Detector - - php phpcpd.phar src/ tests/ --verbose - ## PHP Mess Detector - - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php - ## PHPLOC - #- php phploc.phar src/ - ## PHPUnit - - phpunit -c ./ --coverage-text --coverage-html ./build/coverage - ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" --template="responsive-twig" + ## PHP_CodeSniffer + - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip + ## PHP Copy/Paste Detector + - php phpcpd.phar src/ tests/ --verbose + ## PHP Mess Detector + - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php + ## PHPLOC + #- php phploc.phar src/ + ## PHPUnit + - phpunit -c ./ --coverage-text --coverage-html ./build/coverage + ## PHPDocumentor + - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" --template="responsive-twig" after_script: - ## PHPDocumentor - - bash .travis_shell_after_success.sh - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml + ## PHPDocumentor + - bash .travis_shell_after_success.sh + ## Scrutinizer + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 1c2a5cdbb7..faf270f19a 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -235,7 +235,6 @@ public function cloneRow($search, $numberOfClones) public function cloneBlock($blockname, $clones = 1, $replace = true) { $xmlBlock = null; - $pattern = preg_match( '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', $this->documentXML, diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 231e3b0d6d..c607bb2b76 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -19,7 +19,6 @@ use PhpOffice\PhpWord\Element\Table; use PhpOffice\PhpWord\Element\Text; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index ec1ee4c1e1..6ed58213e7 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /** diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index 270ef15de5..cc47dbb4e1 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php index 99b2c56723..17d38a1048 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /** diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php index 2e9a329fa6..5140084624 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /** diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index a25588f825..ccbd02d024 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; use PhpOffice\PhpWord\Element\Section; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index b6f64f6136..02af5b4ed6 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; From 2432a853bfd3ffbe5c038494be14fe9ac2298b60 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 17:48:10 +0700 Subject: [PATCH 040/167] Show code quality and test code coverage badge on README --- CHANGELOG.md | 1 + README.md | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22b36a78b3..c34fbc22c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 - QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 - Word2007 Writer: Refactor writer parts using composite pattern - @ivanlanin +- Docs: Show code quality and test code coverage badge on README ## 0.10.0 - 4 May 2014 diff --git a/README.md b/README.md index 21e18a7e00..22b9c931a1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ # ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord") [![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord) -[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword) +[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?s=b5997ce59ac2816b4514f3a38de9900f6d492c1d)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) +[![Code Coverage](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/coverage.png?s=742a98745725c562955440edc8d2c39d7ff5ae25)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) [![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword) -[![Latest Unstable Version](https://poser.pugx.org/phpoffice/phpword/v/unstable.png)](https://packagist.org/packages/phpoffice/phpword) -[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) - PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF. From b7374f8936d5d81f65f8000fcc88fb94c62064af Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 6 May 2014 13:04:18 +0200 Subject: [PATCH 041/167] #186 : Add badges for license & stable version --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 22b9c931a1..eb8dd445b6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # ![PHPWord](https://rawgit.com/PHPOffice/PHPWord/develop/docs/images/phpword.svg "PHPWord") +[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpword/v/stable.png)](https://packagist.org/packages/phpoffice/phpword) [![Build Status](https://travis-ci.org/PHPOffice/PHPWord.svg?branch=master)](https://travis-ci.org/PHPOffice/PHPWord) [![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/quality-score.png?s=b5997ce59ac2816b4514f3a38de9900f6d492c1d)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) [![Code Coverage](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/badges/coverage.png?s=742a98745725c562955440edc8d2c39d7ff5ae25)](https://scrutinizer-ci.com/g/PHPOffice/PHPWord/) [![Total Downloads](https://poser.pugx.org/phpoffice/phpword/downloads.png)](https://packagist.org/packages/phpoffice/phpword) +[![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF. From 2ab5a42193d8a8d9e91145835e12276c18acf881 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 19:02:08 +0700 Subject: [PATCH 042/167] Split some functions for code quality improvement --- src/PhpWord/Writer/RTF/Element/Text.php | 103 +++++++----- src/PhpWord/Writer/Word2007/Element/Table.php | 103 +++++++----- .../Writer/Word2007/Part/Numbering.php | 149 +++++++++--------- 3 files changed, 202 insertions(+), 153 deletions(-) diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 56c922a439..83ade9d248 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style; /** @@ -64,56 +64,81 @@ public function write() $this->parentWriter->setLastParagraphStyle(); } - if ($fontStyle instanceof Font) { - if ($fontStyle->getColor() != null) { - $idxColor = array_search($fontStyle->getColor(), $this->parentWriter->getColorTable()); - if ($idxColor !== false) { - $rtfText .= '\cf' . ($idxColor + 1); - } - } else { - $rtfText .= '\cf0'; - } - if ($fontStyle->getName() != null) { - $idxFont = array_search($fontStyle->getName(), $this->parentWriter->getFontTable()); - if ($idxFont !== false) { - $rtfText .= '\f' . $idxFont; - } - } else { - $rtfText .= '\f0'; - } - if ($fontStyle->isBold()) { - $rtfText .= '\b'; - } - if ($fontStyle->isItalic()) { - $rtfText .= '\i'; - } - if ($fontStyle->getSize()) { - $rtfText .= '\fs' . ($fontStyle->getSize() * 2); - } + if ($fontStyle instanceof FontStyle) { + $rtfText .= $this->writeFontStyleBegin($fontStyle); } if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { $rtfText .= ' '; } $rtfText .= $this->element->getText(); + if ($fontStyle instanceof FontStyle) { + $rtfText .= $this->writeFontStyleEnd($fontStyle); + } + if (!$this->withoutP) { + $rtfText .= '\par' . PHP_EOL; + } - if ($fontStyle instanceof Font) { - $rtfText .= '\cf0'; - $rtfText .= '\f0'; + return $rtfText; + } - if ($fontStyle->isBold()) { - $rtfText .= '\b0'; - } - if ($fontStyle->isItalic()) { - $rtfText .= '\i0'; + /** + * Write font style beginning + * + * @return string + */ + private function writeFontStyleBegin(FontStyle $style) + { + $rtfText = ''; + if ($style->getColor() != null) { + $idxColor = array_search($style->getColor(), $this->parentWriter->getColorTable()); + if ($idxColor !== false) { + $rtfText .= '\cf' . ($idxColor + 1); } - if ($fontStyle->getSize()) { - $rtfText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + } else { + $rtfText .= '\cf0'; + } + if ($style->getName() != null) { + $idxFont = array_search($style->getName(), $this->parentWriter->getFontTable()); + if ($idxFont !== false) { + $rtfText .= '\f' . $idxFont; } + } else { + $rtfText .= '\f0'; + } + if ($style->isBold()) { + $rtfText .= '\b'; + } + if ($style->isItalic()) { + $rtfText .= '\i'; + } + if ($style->getSize()) { + $rtfText .= '\fs' . ($style->getSize() * 2); } - if (!$this->withoutP) { - $rtfText .= '\par' . PHP_EOL; + return $rtfText; + } + + /** + * Write font style ending + * + * @return string + */ + private function writeFontStyleEnd(FontStyle $style) + { + $rtfText = ''; + $rtfText .= '\cf0'; + $rtfText .= '\f0'; + + if ($style->isBold()) { + $rtfText .= '\b0'; + } + if ($style->isItalic()) { + $rtfText .= '\i0'; } + if ($style->getSize()) { + $rtfText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + } + return $rtfText; } } diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index c8c658165f..0786397977 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -17,7 +17,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Style\Cell; +use PhpOffice\PhpWord\Element\Cell as CellElement; +use PhpOffice\PhpWord\Element\Row as RowElement; +use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; @@ -89,51 +91,66 @@ public function write() // Table rows for ($i = 0; $i < $rowCount; $i++) { - $row = $rows[$i]; - $height = $row->getHeight(); - $rowStyle = $row->getStyle(); + $this->writeRow($rows[$i]); + } + $this->xmlWriter->endElement(); + } + } - $this->xmlWriter->startElement('w:tr'); - if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:trPr'); - if (!is_null($height)) { - $this->xmlWriter->startElement('w:trHeight'); - $this->xmlWriter->writeAttribute('w:val', $height); - $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); - $this->xmlWriter->endElement(); - } - if ($rowStyle->isTblHeader()) { - $this->xmlWriter->startElement('w:tblHeader'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - if ($rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:cantSplit'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - $this->xmlWriter->endElement(); - } - foreach ($row->getCells() as $cell) { - $cellStyle = $cell->getStyle(); - $width = $cell->getWidth(); - $this->xmlWriter->startElement('w:tc'); - $this->xmlWriter->startElement('w:tcPr'); - $this->xmlWriter->startElement('w:tcW'); - $this->xmlWriter->writeAttribute('w:w', $width); - $this->xmlWriter->writeAttribute('w:type', 'dxa'); - $this->xmlWriter->endElement(); // w:tcW - if ($cellStyle instanceof Cell) { - $styleWriter = new CellStyleWriter($this->xmlWriter, $cellStyle); - $styleWriter->write(); - } - $this->xmlWriter->endElement(); // w:tcPr - $this->parentWriter->writeContainerElements($this->xmlWriter, $cell); - $this->xmlWriter->endElement(); // w:tc - } - $this->xmlWriter->endElement(); // w:tr + /** + * Write row + */ + private function writeRow(RowElement $row) + { + $height = $row->getHeight(); + $rowStyle = $row->getStyle(); + + $this->xmlWriter->startElement('w:tr'); + if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { + $this->xmlWriter->startElement('w:trPr'); + if (!is_null($height)) { + $this->xmlWriter->startElement('w:trHeight'); + $this->xmlWriter->writeAttribute('w:val', $height); + $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); + $this->xmlWriter->endElement(); + } + if ($rowStyle->isTblHeader()) { + $this->xmlWriter->startElement('w:tblHeader'); + $this->xmlWriter->writeAttribute('w:val', '1'); + $this->xmlWriter->endElement(); + } + if ($rowStyle->isCantSplit()) { + $this->xmlWriter->startElement('w:cantSplit'); + $this->xmlWriter->writeAttribute('w:val', '1'); + $this->xmlWriter->endElement(); } $this->xmlWriter->endElement(); } + foreach ($row->getCells() as $cell) { + $this->writeCell($cell); + } + $this->xmlWriter->endElement(); // w:tr + } + + /** + * Write cell + */ + private function writeCell(CellElement $cell) + { + $cellStyle = $cell->getStyle(); + + $this->xmlWriter->startElement('w:tc'); + $this->xmlWriter->startElement('w:tcPr'); + $this->xmlWriter->startElement('w:tcW'); + $this->xmlWriter->writeAttribute('w:w', $cell->getWidth()); + $this->xmlWriter->writeAttribute('w:type', 'dxa'); + $this->xmlWriter->endElement(); // w:tcW + if ($cellStyle instanceof CellStyle) { + $styleWriter = new CellStyleWriter($this->xmlWriter, $cellStyle); + $styleWriter->write(); + } + $this->xmlWriter->endElement(); // w:tcPr + $this->parentWriter->writeContainerElements($this->xmlWriter, $cell); + $this->xmlWriter->endElement(); // w:tc } } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 6f042b4a57..2678ac5551 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -17,9 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\NumberingLevel; -use PhpOffice\PhpWord\Style; /** * Word2007 numbering part writer: word/numbering.xml @@ -66,76 +67,8 @@ public function write() $xmlWriter->endElement(); // w:multiLevelType if (is_array($levels)) { - foreach ($levels as $levelNum => $levelObject) { - if ($levelObject instanceof NumberingLevel) { - $tabPos = $levelObject->getTabPos(); - $left = $levelObject->getLeft(); - $hanging = $levelObject->getHanging(); - $font = $levelObject->getFont(); - $hint = $levelObject->getHint(); - - $xmlWriter->startElement('w:lvl'); - $xmlWriter->writeAttribute('w:ilvl', $levelNum); - - // Numbering level properties - $properties = array( - 'start' => 'start', - 'format' => 'numFmt', - 'restart' => 'lvlRestart', - 'suffix' => 'suff', - 'text' => 'lvlText', - 'align' => 'lvlJc' - ); - foreach ($properties as $property => $nodeName) { - $getMethod = "get{$property}"; - if (!is_null($levelObject->$getMethod())) { - $xmlWriter->startElement("w:{$nodeName}"); - $xmlWriter->writeAttribute('w:val', $levelObject->$getMethod()); - $xmlWriter->endElement(); // w:start - } - } - - // Paragraph styles - if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:pPr'); - if (!is_null($tabPos)) { - $xmlWriter->startElement('w:tabs'); - $xmlWriter->startElement('w:tab'); - $xmlWriter->writeAttribute('w:val', 'num'); - $xmlWriter->writeAttribute('w:pos', $tabPos); - $xmlWriter->endElement(); // w:tab - $xmlWriter->endElement(); // w:tabs - } - if (!is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:ind'); - if (!is_null($left)) { - $xmlWriter->writeAttribute('w:left', $left); - } - if (!is_null($hanging)) { - $xmlWriter->writeAttribute('w:hanging', $hanging); - } - $xmlWriter->endElement(); // w:ind - } - $xmlWriter->endElement(); // w:pPr - } - - // Font styles - if (!is_null($font) || !is_null($hint)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rFonts'); - if (!is_null($font)) { - $xmlWriter->writeAttribute('w:ascii', $font); - $xmlWriter->writeAttribute('w:hAnsi', $font); - $xmlWriter->writeAttribute('w:cs', $font); - } - if (!is_null($hint)) { - $xmlWriter->writeAttribute('w:hint', $hint); - } - $xmlWriter->endElement(); // w:rFonts - $xmlWriter->endElement(); // w:rPr - } - $xmlWriter->endElement(); // w:lvl - } + foreach ($levels as $level) { + $this->writeLevel($xmlWriter, $level); } } $xmlWriter->endElement(); // w:abstractNum @@ -159,6 +92,80 @@ public function write() return $xmlWriter->getData(); } + /** + * Write level + */ + private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) + { + $tabPos = $level->getTabPos(); + $left = $level->getLeft(); + $hanging = $level->getHanging(); + $font = $level->getFont(); + $hint = $level->getHint(); + + $xmlWriter->startElement('w:lvl'); + $xmlWriter->writeAttribute('w:ilvl', $level->getLevel()); + + // Numbering level properties + $properties = array( + 'start' => 'start', + 'format' => 'numFmt', + 'restart' => 'lvlRestart', + 'suffix' => 'suff', + 'text' => 'lvlText', + 'align' => 'lvlJc' + ); + foreach ($properties as $property => $nodeName) { + $getMethod = "get{$property}"; + if (!is_null($level->$getMethod())) { + $xmlWriter->startElement("w:{$nodeName}"); + $xmlWriter->writeAttribute('w:val', $level->$getMethod()); + $xmlWriter->endElement(); // w:start + } + } + + // Paragraph styles + if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { + $xmlWriter->startElement('w:pPr'); + if (!is_null($tabPos)) { + $xmlWriter->startElement('w:tabs'); + $xmlWriter->startElement('w:tab'); + $xmlWriter->writeAttribute('w:val', 'num'); + $xmlWriter->writeAttribute('w:pos', $tabPos); + $xmlWriter->endElement(); // w:tab + $xmlWriter->endElement(); // w:tabs + } + if (!is_null($left) || !is_null($hanging)) { + $xmlWriter->startElement('w:ind'); + if (!is_null($left)) { + $xmlWriter->writeAttribute('w:left', $left); + } + if (!is_null($hanging)) { + $xmlWriter->writeAttribute('w:hanging', $hanging); + } + $xmlWriter->endElement(); // w:ind + } + $xmlWriter->endElement(); // w:pPr + } + + // Font styles + if (!is_null($font) || !is_null($hint)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rFonts'); + if (!is_null($font)) { + $xmlWriter->writeAttribute('w:ascii', $font); + $xmlWriter->writeAttribute('w:hAnsi', $font); + $xmlWriter->writeAttribute('w:cs', $font); + } + if (!is_null($hint)) { + $xmlWriter->writeAttribute('w:hint', $hint); + } + $xmlWriter->endElement(); // w:rFonts + $xmlWriter->endElement(); // w:rPr + } + $xmlWriter->endElement(); // w:lvl + } + /** * Get random hexadecimal number value * From c28f28ea25cd626cd5560d475f377134b2aa70cc Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 21:22:24 +0700 Subject: [PATCH 043/167] Refactoring for code quality improvement (based on Scrutinizer) --- src/PhpWord/Element/AbstractContainer.php | 8 +- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/Style/TOC.php | 4 +- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/RTF/Element/Text.php | 103 +++++++----- src/PhpWord/Writer/Word2007/Element/Table.php | 103 +++++++----- .../Writer/Word2007/Part/Numbering.php | 149 +++++++++--------- src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +- .../Writer/Word2007/Style/AbstractStyle.php | 23 +++ src/PhpWord/Writer/Word2007/Style/Font.php | 81 +++------- src/PhpWord/Writer/Word2007/Style/Image.php | 14 +- .../Writer/Word2007/Style/Paragraph.php | 48 ++---- 12 files changed, 278 insertions(+), 261 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 7de4a42872..4ac6c22be6 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -39,8 +39,8 @@ abstract class AbstractContainer extends AbstractElement */ protected function addElement(AbstractElement $element) { - $type = get_class($element); - $type = str_replace('PhpOffice\\PhpWord\\Element\\', '', $type); + // $type = get_class($element); + // $type = str_replace('PhpOffice\\PhpWord\\Element\\', '', $type); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); $element->setPhpWord($this->phpWord); @@ -254,11 +254,11 @@ public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') $addMethod = "add{$elementName}"; $element = new $elementClass($paragraphStyle); + $element->setDocPart($docPart, $this->getDocPartId()); if ($this->phpWord instanceof PhpWord) { $rId = $this->phpWord->$addMethod($element); + $element->setRelationId($rId); } - $element->setDocPart($docPart, $this->getDocPartId()); - $element->setRelationId($rId); $this->addElement($element); return $element; diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 481f061bc5..a2dbba8b20 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -138,7 +138,7 @@ public function getStyle() */ public function setAnchor($anchor) { - $this->anchor = $anchor; + $anchor = null; } /** diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 13a7029449..6ec4318f04 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -45,7 +45,7 @@ class TOC extends Tab */ public function __construct() { - parent::__construct(self::TAB_STOP_RIGHT, 9062, self::TABLEADER_DOT); + parent::__construct(self::TAB_STOP_RIGHT, 9062, self::TAB_LEADER_DOT); } /** @@ -83,7 +83,7 @@ public function getTabLeader() * * @param string $value */ - public function setTabLeader($value = self::TABLEADER_DOT) + public function setTabLeader($value = self::TAB_LEADER_DOT) { $this->setLeader($value); } diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index faf270f19a..68550cfe1e 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -192,7 +192,7 @@ public function cloneRow($search, $numberOfClones) // Check if there's a cell spanning multiple rows. if (preg_match('##', $xmlRow)) { - $extraRowStart = $rowEnd; + // $extraRowStart = $rowEnd; $extraRowEnd = $rowEnd; while (true) { $extraRowStart = $this->findRowStart($extraRowEnd + 1); diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 56c922a439..83ade9d248 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style; /** @@ -64,56 +64,81 @@ public function write() $this->parentWriter->setLastParagraphStyle(); } - if ($fontStyle instanceof Font) { - if ($fontStyle->getColor() != null) { - $idxColor = array_search($fontStyle->getColor(), $this->parentWriter->getColorTable()); - if ($idxColor !== false) { - $rtfText .= '\cf' . ($idxColor + 1); - } - } else { - $rtfText .= '\cf0'; - } - if ($fontStyle->getName() != null) { - $idxFont = array_search($fontStyle->getName(), $this->parentWriter->getFontTable()); - if ($idxFont !== false) { - $rtfText .= '\f' . $idxFont; - } - } else { - $rtfText .= '\f0'; - } - if ($fontStyle->isBold()) { - $rtfText .= '\b'; - } - if ($fontStyle->isItalic()) { - $rtfText .= '\i'; - } - if ($fontStyle->getSize()) { - $rtfText .= '\fs' . ($fontStyle->getSize() * 2); - } + if ($fontStyle instanceof FontStyle) { + $rtfText .= $this->writeFontStyleBegin($fontStyle); } if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { $rtfText .= ' '; } $rtfText .= $this->element->getText(); + if ($fontStyle instanceof FontStyle) { + $rtfText .= $this->writeFontStyleEnd($fontStyle); + } + if (!$this->withoutP) { + $rtfText .= '\par' . PHP_EOL; + } - if ($fontStyle instanceof Font) { - $rtfText .= '\cf0'; - $rtfText .= '\f0'; + return $rtfText; + } - if ($fontStyle->isBold()) { - $rtfText .= '\b0'; - } - if ($fontStyle->isItalic()) { - $rtfText .= '\i0'; + /** + * Write font style beginning + * + * @return string + */ + private function writeFontStyleBegin(FontStyle $style) + { + $rtfText = ''; + if ($style->getColor() != null) { + $idxColor = array_search($style->getColor(), $this->parentWriter->getColorTable()); + if ($idxColor !== false) { + $rtfText .= '\cf' . ($idxColor + 1); } - if ($fontStyle->getSize()) { - $rtfText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + } else { + $rtfText .= '\cf0'; + } + if ($style->getName() != null) { + $idxFont = array_search($style->getName(), $this->parentWriter->getFontTable()); + if ($idxFont !== false) { + $rtfText .= '\f' . $idxFont; } + } else { + $rtfText .= '\f0'; + } + if ($style->isBold()) { + $rtfText .= '\b'; + } + if ($style->isItalic()) { + $rtfText .= '\i'; + } + if ($style->getSize()) { + $rtfText .= '\fs' . ($style->getSize() * 2); } - if (!$this->withoutP) { - $rtfText .= '\par' . PHP_EOL; + return $rtfText; + } + + /** + * Write font style ending + * + * @return string + */ + private function writeFontStyleEnd(FontStyle $style) + { + $rtfText = ''; + $rtfText .= '\cf0'; + $rtfText .= '\f0'; + + if ($style->isBold()) { + $rtfText .= '\b0'; + } + if ($style->isItalic()) { + $rtfText .= '\i0'; } + if ($style->getSize()) { + $rtfText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + } + return $rtfText; } } diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index c8c658165f..0786397977 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -17,7 +17,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Style\Cell; +use PhpOffice\PhpWord\Element\Cell as CellElement; +use PhpOffice\PhpWord\Element\Row as RowElement; +use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; @@ -89,51 +91,66 @@ public function write() // Table rows for ($i = 0; $i < $rowCount; $i++) { - $row = $rows[$i]; - $height = $row->getHeight(); - $rowStyle = $row->getStyle(); + $this->writeRow($rows[$i]); + } + $this->xmlWriter->endElement(); + } + } - $this->xmlWriter->startElement('w:tr'); - if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:trPr'); - if (!is_null($height)) { - $this->xmlWriter->startElement('w:trHeight'); - $this->xmlWriter->writeAttribute('w:val', $height); - $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); - $this->xmlWriter->endElement(); - } - if ($rowStyle->isTblHeader()) { - $this->xmlWriter->startElement('w:tblHeader'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - if ($rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:cantSplit'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - $this->xmlWriter->endElement(); - } - foreach ($row->getCells() as $cell) { - $cellStyle = $cell->getStyle(); - $width = $cell->getWidth(); - $this->xmlWriter->startElement('w:tc'); - $this->xmlWriter->startElement('w:tcPr'); - $this->xmlWriter->startElement('w:tcW'); - $this->xmlWriter->writeAttribute('w:w', $width); - $this->xmlWriter->writeAttribute('w:type', 'dxa'); - $this->xmlWriter->endElement(); // w:tcW - if ($cellStyle instanceof Cell) { - $styleWriter = new CellStyleWriter($this->xmlWriter, $cellStyle); - $styleWriter->write(); - } - $this->xmlWriter->endElement(); // w:tcPr - $this->parentWriter->writeContainerElements($this->xmlWriter, $cell); - $this->xmlWriter->endElement(); // w:tc - } - $this->xmlWriter->endElement(); // w:tr + /** + * Write row + */ + private function writeRow(RowElement $row) + { + $height = $row->getHeight(); + $rowStyle = $row->getStyle(); + + $this->xmlWriter->startElement('w:tr'); + if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { + $this->xmlWriter->startElement('w:trPr'); + if (!is_null($height)) { + $this->xmlWriter->startElement('w:trHeight'); + $this->xmlWriter->writeAttribute('w:val', $height); + $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); + $this->xmlWriter->endElement(); + } + if ($rowStyle->isTblHeader()) { + $this->xmlWriter->startElement('w:tblHeader'); + $this->xmlWriter->writeAttribute('w:val', '1'); + $this->xmlWriter->endElement(); + } + if ($rowStyle->isCantSplit()) { + $this->xmlWriter->startElement('w:cantSplit'); + $this->xmlWriter->writeAttribute('w:val', '1'); + $this->xmlWriter->endElement(); } $this->xmlWriter->endElement(); } + foreach ($row->getCells() as $cell) { + $this->writeCell($cell); + } + $this->xmlWriter->endElement(); // w:tr + } + + /** + * Write cell + */ + private function writeCell(CellElement $cell) + { + $cellStyle = $cell->getStyle(); + + $this->xmlWriter->startElement('w:tc'); + $this->xmlWriter->startElement('w:tcPr'); + $this->xmlWriter->startElement('w:tcW'); + $this->xmlWriter->writeAttribute('w:w', $cell->getWidth()); + $this->xmlWriter->writeAttribute('w:type', 'dxa'); + $this->xmlWriter->endElement(); // w:tcW + if ($cellStyle instanceof CellStyle) { + $styleWriter = new CellStyleWriter($this->xmlWriter, $cellStyle); + $styleWriter->write(); + } + $this->xmlWriter->endElement(); // w:tcPr + $this->parentWriter->writeContainerElements($this->xmlWriter, $cell); + $this->xmlWriter->endElement(); // w:tc } } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 6f042b4a57..2678ac5551 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -17,9 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\NumberingLevel; -use PhpOffice\PhpWord\Style; /** * Word2007 numbering part writer: word/numbering.xml @@ -66,76 +67,8 @@ public function write() $xmlWriter->endElement(); // w:multiLevelType if (is_array($levels)) { - foreach ($levels as $levelNum => $levelObject) { - if ($levelObject instanceof NumberingLevel) { - $tabPos = $levelObject->getTabPos(); - $left = $levelObject->getLeft(); - $hanging = $levelObject->getHanging(); - $font = $levelObject->getFont(); - $hint = $levelObject->getHint(); - - $xmlWriter->startElement('w:lvl'); - $xmlWriter->writeAttribute('w:ilvl', $levelNum); - - // Numbering level properties - $properties = array( - 'start' => 'start', - 'format' => 'numFmt', - 'restart' => 'lvlRestart', - 'suffix' => 'suff', - 'text' => 'lvlText', - 'align' => 'lvlJc' - ); - foreach ($properties as $property => $nodeName) { - $getMethod = "get{$property}"; - if (!is_null($levelObject->$getMethod())) { - $xmlWriter->startElement("w:{$nodeName}"); - $xmlWriter->writeAttribute('w:val', $levelObject->$getMethod()); - $xmlWriter->endElement(); // w:start - } - } - - // Paragraph styles - if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:pPr'); - if (!is_null($tabPos)) { - $xmlWriter->startElement('w:tabs'); - $xmlWriter->startElement('w:tab'); - $xmlWriter->writeAttribute('w:val', 'num'); - $xmlWriter->writeAttribute('w:pos', $tabPos); - $xmlWriter->endElement(); // w:tab - $xmlWriter->endElement(); // w:tabs - } - if (!is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:ind'); - if (!is_null($left)) { - $xmlWriter->writeAttribute('w:left', $left); - } - if (!is_null($hanging)) { - $xmlWriter->writeAttribute('w:hanging', $hanging); - } - $xmlWriter->endElement(); // w:ind - } - $xmlWriter->endElement(); // w:pPr - } - - // Font styles - if (!is_null($font) || !is_null($hint)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rFonts'); - if (!is_null($font)) { - $xmlWriter->writeAttribute('w:ascii', $font); - $xmlWriter->writeAttribute('w:hAnsi', $font); - $xmlWriter->writeAttribute('w:cs', $font); - } - if (!is_null($hint)) { - $xmlWriter->writeAttribute('w:hint', $hint); - } - $xmlWriter->endElement(); // w:rFonts - $xmlWriter->endElement(); // w:rPr - } - $xmlWriter->endElement(); // w:lvl - } + foreach ($levels as $level) { + $this->writeLevel($xmlWriter, $level); } } $xmlWriter->endElement(); // w:abstractNum @@ -159,6 +92,80 @@ public function write() return $xmlWriter->getData(); } + /** + * Write level + */ + private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) + { + $tabPos = $level->getTabPos(); + $left = $level->getLeft(); + $hanging = $level->getHanging(); + $font = $level->getFont(); + $hint = $level->getHint(); + + $xmlWriter->startElement('w:lvl'); + $xmlWriter->writeAttribute('w:ilvl', $level->getLevel()); + + // Numbering level properties + $properties = array( + 'start' => 'start', + 'format' => 'numFmt', + 'restart' => 'lvlRestart', + 'suffix' => 'suff', + 'text' => 'lvlText', + 'align' => 'lvlJc' + ); + foreach ($properties as $property => $nodeName) { + $getMethod = "get{$property}"; + if (!is_null($level->$getMethod())) { + $xmlWriter->startElement("w:{$nodeName}"); + $xmlWriter->writeAttribute('w:val', $level->$getMethod()); + $xmlWriter->endElement(); // w:start + } + } + + // Paragraph styles + if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { + $xmlWriter->startElement('w:pPr'); + if (!is_null($tabPos)) { + $xmlWriter->startElement('w:tabs'); + $xmlWriter->startElement('w:tab'); + $xmlWriter->writeAttribute('w:val', 'num'); + $xmlWriter->writeAttribute('w:pos', $tabPos); + $xmlWriter->endElement(); // w:tab + $xmlWriter->endElement(); // w:tabs + } + if (!is_null($left) || !is_null($hanging)) { + $xmlWriter->startElement('w:ind'); + if (!is_null($left)) { + $xmlWriter->writeAttribute('w:left', $left); + } + if (!is_null($hanging)) { + $xmlWriter->writeAttribute('w:hanging', $hanging); + } + $xmlWriter->endElement(); // w:ind + } + $xmlWriter->endElement(); // w:pPr + } + + // Font styles + if (!is_null($font) || !is_null($hint)) { + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rFonts'); + if (!is_null($font)) { + $xmlWriter->writeAttribute('w:ascii', $font); + $xmlWriter->writeAttribute('w:hAnsi', $font); + $xmlWriter->writeAttribute('w:cs', $font); + } + if (!is_null($hint)) { + $xmlWriter->writeAttribute('w:hint', $hint); + } + $xmlWriter->endElement(); // w:rFonts + $xmlWriter->endElement(); // w:rPr + } + $xmlWriter->endElement(); // w:lvl + } + /** * Get random hexadecimal number value * diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 20076c4e83..22480ce26c 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -78,10 +78,10 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = foreach ($mediaRels as $mediaRel) { $mediaType = $mediaRel['type']; $type = array_key_exists($mediaType, $mapping) ? $mapping[$mediaType] : $mediaType; - $type = "officeDocument/2006/relationships/{$type}"; $target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : ''; $target .= $mediaRel['target']; $targetMode = ($type == 'hyperlink') ? 'External' : ''; + $type = "officeDocument/2006/relationships/{$type}"; $this->writeRel($xmlWriter, $relId++, $type, $target, $targetMode); } diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 397adae74b..41bbed3dcc 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -73,4 +73,27 @@ protected function convertTwip($value, $default = 0) return $value * $unit; } } + + /** + * Write element when ... + * + * @param bool $condition + * @param string $element + * @param string $attribute + * @param string $value + */ + protected function writeElementIf($condition, $element, $attribute = null, $value = null) + { + if (!$condition) { + return; + } + + if (is_null($attribute)) { + $this->xmlWriter->writeElement($element, $value); + } else { + $this->xmlWriter->startElement($element); + $this->xmlWriter->writeAttribute($attribute, $value); + $this->xmlWriter->endElement(); + } + } } diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index cd235825b7..b127da313a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -62,6 +62,8 @@ private function writeStyle() $font = $this->style->getName(); $color = $this->style->getColor(); $size = $this->style->getSize(); + $underline = $this->style->getUnderline(); + $fgColor = $this->style->getFgColor(); $this->xmlWriter->startElement('w:rPr'); @@ -80,56 +82,32 @@ private function writeStyle() } // Color - if ($color != PhpWord::DEFAULT_FONT_COLOR) { - $this->xmlWriter->startElement('w:color'); - $this->xmlWriter->writeAttribute('w:val', $color); - $this->xmlWriter->endElement(); - } + $this->writeElementIf($color != PhpWord::DEFAULT_FONT_COLOR, 'w:color', 'w:val', $color); + $this->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:sz', 'w:val', $size * 2); + $this->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:szCs', 'w:val', $size * 2); - // Size - if ($size != PhpWord::DEFAULT_FONT_SIZE) { - $this->xmlWriter->startElement('w:sz'); - $this->xmlWriter->writeAttribute('w:val', $size * 2); - $this->xmlWriter->endElement(); - $this->xmlWriter->startElement('w:szCs'); - $this->xmlWriter->writeAttribute('w:val', $size * 2); - $this->xmlWriter->endElement(); - } + // Bold, italic + $this->writeElementIf($this->style->isBold(), 'w:b'); + $this->writeElementIf($this->style->isItalic(), 'w:i'); + $this->writeElementIf($this->style->isItalic(), 'w:iCs'); - // Bold - if ($this->style->isBold()) { - $this->xmlWriter->writeElement('w:b', null); - } + // Strikethrough, double strikethrough + $this->writeElementIf($this->style->isStrikethrough(), 'w:strike'); + $this->writeElementIf($this->style->isDoubleStrikethrough(), 'w:dstrike'); - // Italic - if ($this->style->isItalic()) { - $this->xmlWriter->writeElement('w:i', null); - $this->xmlWriter->writeElement('w:iCs', null); - } + // Small caps, all caps + $this->writeElementIf($this->style->isSmallCaps(), 'w:smallCaps'); + $this->writeElementIf($this->style->isAllCaps(), 'w:caps'); // Underline - if ($this->style->getUnderline() != 'none') { - $this->xmlWriter->startElement('w:u'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getUnderline()); - $this->xmlWriter->endElement(); - } - - // Strikethrough - if ($this->style->isStrikethrough()) { - $this->xmlWriter->writeElement('w:strike', null); - } - - // Double strikethrough - if ($this->style->isDoubleStrikethrough()) { - $this->xmlWriter->writeElement('w:dstrike', null); - } + $this->writeElementIf($underline != 'none', 'w:u', 'w:val', $underline); // Foreground-Color - if (!is_null($this->style->getFgColor())) { - $this->xmlWriter->startElement('w:highlight'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getFgColor()); - $this->xmlWriter->endElement(); - } + $this->writeElementIf(!is_null($fgColor), 'w:highlight', 'w:val', $fgColor); + + // Superscript/subscript + $this->writeElementIf($this->style->isSuperScript(), 'w:vertAlign', 'w:val', 'superscript'); + $this->writeElementIf($this->style->isSubScript(), 'w:vertAlign', 'w:val', 'subscript'); // Background-Color if (!is_null($this->style->getShading())) { @@ -137,23 +115,6 @@ private function writeStyle() $styleWriter->write(); } - // Superscript/subscript - if ($this->style->isSuperScript() || $this->style->isSubScript()) { - $this->xmlWriter->startElement('w:vertAlign'); - $this->xmlWriter->writeAttribute('w:val', $this->style->isSuperScript() ? 'superscript' : 'subscript'); - $this->xmlWriter->endElement(); - } - - // Small caps - if ($this->style->isSmallCaps()) { - $this->xmlWriter->writeElement('w:smallCaps', null); - } - - // All caps - if ($this->style->isAllCaps()) { - $this->xmlWriter->writeElement('w:caps', null); - } - $this->xmlWriter->endElement(); } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index a048da3fab..b5e23e9a21 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -38,7 +38,7 @@ class Image extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Image)) { + if (!$this->style instanceof \PhpOffice\PhpWord\Style\Image) { return; } @@ -52,7 +52,7 @@ public function write() 'mso-width-relative' => 'margin', 'mso-height-relative' => 'margin', ); - $styleArray = array_merge($styleArray, $this->getElementStyle()); + $styleArray = array_merge($styleArray, $this->getElementStyle($this->style)); // Absolute/relative positioning $styleArray['position'] = $positioning; @@ -110,14 +110,14 @@ public function writeW10Wrap() * * @return array */ - private function getElementStyle() + private function getElementStyle(ImageStyle $style) { $styles = array(); $styleValues = array( - 'width' => $this->style->getWidth(), - 'height' => $this->style->getHeight(), - 'margin-top' => $this->style->getMarginTop(), - 'margin-left' => $this->style->getMarginLeft() + 'width' => $style->getWidth(), + 'height' => $style->getHeight(), + 'margin-top' => $style->getMarginTop(), + 'margin-left' => $style->getMarginLeft() ); foreach ($styleValues as $key => $value) { if (!is_null($value) && $value != '') { diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 7398ad604a..af66abeda7 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -68,53 +68,37 @@ private function writeStyle() return; } + $align = $this->style->getAlign(); + $indentation = $this->style->getIndentation(); + $spacing = $this->style->getSpace(); + $tabs = $this->style->getTabs(); + if (!$this->withoutPPR) { $this->xmlWriter->startElement('w:pPr'); } // Alignment - if (!is_null($this->style->getAlign())) { - $this->xmlWriter->startElement('w:jc'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getAlign()); - $this->xmlWriter->endElement(); - } + $this->writeElementIf(!is_null($align), 'w:jc', 'w:val', $align); + + // Pagination + $this->writeElementIf(!$this->style->hasWidowControl(), 'w:widowControl', 'w:val', '0'); + $this->writeElementIf($this->style->isKeepNext(), 'w:keepNext', 'w:val', '1'); + $this->writeElementIf($this->style->isKeepLines(), 'w:keepLines', 'w:val', '1'); + $this->writeElementIf($this->style->hasPageBreakBefore(), 'w:pageBreakBefore', 'w:val', '1'); // Indentation - if (!is_null($this->style->getIndentation())) { - $styleWriter = new Indentation($this->xmlWriter, $this->style->getIndentation()); + if (!is_null($indentation)) { + $styleWriter = new Indentation($this->xmlWriter, $indentation); $styleWriter->write(); } // Spacing - if (!is_null($this->style->getSpace())) { - $styleWriter = new Spacing($this->xmlWriter, $this->style->getSpace()); + if (!is_null($spacing)) { + $styleWriter = new Spacing($this->xmlWriter, $spacing); $styleWriter->write(); } - // Pagination - if (!$this->style->hasWidowControl()) { - $this->xmlWriter->startElement('w:widowControl'); - $this->xmlWriter->writeAttribute('w:val', '0'); - $this->xmlWriter->endElement(); - } - if ($this->style->isKeepNext()) { - $this->xmlWriter->startElement('w:keepNext'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - if ($this->style->isKeepLines()) { - $this->xmlWriter->startElement('w:keepLines'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - if ($this->style->hasPageBreakBefore()) { - $this->xmlWriter->startElement('w:pageBreakBefore'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); - } - // Tabs - $tabs = $this->style->getTabs(); if (!empty($tabs)) { $this->xmlWriter->startElement("w:tabs"); foreach ($tabs as $tab) { From c4e8fdac846c8052919ca09f68de51f9e47cdf4d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 22:08:39 +0700 Subject: [PATCH 044/167] Refactoring for code quality improvement (based on Scrutinizer) --- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/Style/Table.php | 36 ++++ src/PhpWord/Writer/Word2007/Element/TOC.php | 211 +++++++++++--------- src/PhpWord/Writer/Word2007/Style/Table.php | 40 +--- 4 files changed, 165 insertions(+), 124 deletions(-) diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index a2dbba8b20..481f061bc5 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -138,7 +138,7 @@ public function getStyle() */ public function setAnchor($anchor) { - $anchor = null; + $this->anchor = $anchor; } /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 7aa108bfed..d636b7653e 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -441,4 +441,40 @@ public function setShading($value = null) return $this; } + + /** + * Has borders? + * + * @return bool + */ + public function hasBorders() + { + $hasBorders = false; + $borders = $this->getBorderSize(); + for ($i = 0; $i < 6; $i++) { + if (!is_null($borders[$i])) { + $hasBorders = true; + } + } + + return $hasBorders; + } + + /** + * Has margins? + * + * @return bool + */ + public function hasMargins() + { + $hasMargins = false; + $margins = $this->getCellMargin(); + for ($i = 0; $i < 4; $i++) { + if (!is_null($margins[$i])) { + $hasMargins = true; + } + } + + return $hasMargins; + } } diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 5c2496cb88..1ebde1a90e 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -35,125 +35,154 @@ class TOC extends Element public function write() { $titles = $this->element->getTitles(); + $writeFieldMark = true; + + foreach ($titles as $title) { + $this->writeTitle($title, $writeFieldMark); + if ($writeFieldMark) { + $writeFieldMark = false; + } + } + + $this->xmlWriter->startElement('w:p'); + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:fldChar'); + $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); + } + + /** + * Write title + */ + private function writeTitle($title, $writeFieldMark) + { $tocStyle = $this->element->getStyleTOC(); $fontStyle = $this->element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; + $anchor = '_Toc' . ($title->getBookmarkId() + 252634154); + $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); - $tocFieldWritten = false; - foreach ($titles as $title) { - $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); - $anchor = '_Toc' . ($title->getBookmarkId() + 252634154); + $this->xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:p'); + // Write style and field mark + $this->writeStyle($indent); + if ($writeFieldMark) { + $this->writeFieldMark(); + } - // Style - $this->xmlWriter->startElement('w:pPr'); + // Hyperlink + $this->xmlWriter->startElement('w:hyperlink'); + $this->xmlWriter->writeAttribute('w:anchor', $anchor); + $this->xmlWriter->writeAttribute('w:history', '1'); - // Paragraph - if ($isObject && !is_null($fontStyle->getParagraphStyle())) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $fontStyle->getParagraphStyle()); - $styleWriter->write(); - } + // Title text + $this->xmlWriter->startElement('w:r'); + if ($isObject) { + $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); + $styleWriter->write(); + } + $this->xmlWriter->startElement('w:t'); + $this->xmlWriter->writeRaw($title->getText()); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); // w:r - // Font - if (!empty($fontStyle) && !$isObject) { - $this->xmlWriter->startElement('w:rPr'); - $this->xmlWriter->startElement('w:rStyle'); - $this->xmlWriter->writeAttribute('w:val', $fontStyle); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); // w:rPr - } + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->writeElement('w:tab', null); + $this->xmlWriter->endElement(); - // Tab - $this->xmlWriter->startElement('w:tabs'); - $styleWriter = new TabStyleWriter($this->xmlWriter, $tocStyle); - $styleWriter->write(); - $this->xmlWriter->endElement(); + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:fldChar'); + $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); - // Indent - if ($indent > 0) { - $this->xmlWriter->startElement('w:ind'); - $this->xmlWriter->writeAttribute('w:left', $indent); - $this->xmlWriter->endElement(); - } + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:instrText'); + $this->xmlWriter->writeAttribute('xml:space', 'preserve'); + $this->xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); // w:pPr - - if ($tocFieldWritten !== true) { - $tocFieldWritten = true; - $minDepth = $this->element->getMinDepth(); - $maxDepth = $this->element->getMaxDepth(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw("TOC \o {$minDepth}-{$maxDepth} \h \z \u"); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - } + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:fldChar'); + $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); - $this->xmlWriter->startElement('w:hyperlink'); - $this->xmlWriter->writeAttribute('w:anchor', $anchor); - $this->xmlWriter->writeAttribute('w:history', '1'); + $this->xmlWriter->endElement(); // w:hyperlink - $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->endElement(); // w:p + } - if ($isObject) { - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->write(); - } + /** + * Write style + */ + private function writeStyle($indent) + { + $tocStyle = $this->element->getStyleTOC(); + $fontStyle = $this->element->getStyleFont(); + $isObject = ($fontStyle instanceof Font) ? true : false; - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeRaw($title->getText()); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->writeElement('w:tab', null); - $this->xmlWriter->endElement(); + // Paragraph + if ($isObject && !is_null($fontStyle->getParagraphStyle())) { + $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $fontStyle->getParagraphStyle()); + $styleWriter->write(); + } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->endElement(); + // Font + if (!empty($fontStyle) && !$isObject) { + $this->xmlWriter->startElement('w:rPr'); + $this->xmlWriter->startElement('w:rStyle'); + $this->xmlWriter->writeAttribute('w:val', $fontStyle); $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); // w:rPr + } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + // Tab + $this->xmlWriter->startElement('w:tabs'); + $styleWriter = new TabStyleWriter($this->xmlWriter, $tocStyle); + $styleWriter->write(); + $this->xmlWriter->endElement(); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement(); + // Indent + if ($indent > 0) { + $this->xmlWriter->startElement('w:ind'); + $this->xmlWriter->writeAttribute('w:left', $indent); $this->xmlWriter->endElement(); + } - $this->xmlWriter->endElement(); // w:hyperlink + $this->xmlWriter->endElement(); // w:pPr + } - $this->xmlWriter->endElement(); // w:p - } + /** + * Write TOC Field + */ + private function writeFieldMark() + { + $minDepth = $this->element->getMinDepth(); + $maxDepth = $this->element->getMaxDepth(); - $this->xmlWriter->startElement('w:p'); $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); + $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $this->xmlWriter->endElement(); + $this->xmlWriter->endElement(); + + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:instrText'); + $this->xmlWriter->writeAttribute('xml:space', 'preserve'); + $this->xmlWriter->writeRaw("TOC \o {$minDepth}-{$maxDepth} \h \z \u"); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); + + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:fldChar'); + $this->xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 4bc3e5f63a..08100118da 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -40,30 +40,14 @@ public function write() return; } - $brdCol = $this->style->getBorderColor(); - $brdSz = $this->style->getBorderSize(); - $cellMargin = $this->style->getCellMargin(); + $hasBorders = $this->style->hasBorders(); + $hasMargins = $this->style->hasMargins(); - // If any of the borders/margins is set, process them - $hasBorders = false; - for ($i = 0; $i < 6; $i++) { - if (!is_null($brdSz[$i])) { - $hasBorders = true; - break; - } - } - $hasMargins = false; - for ($i = 0; $i < 4; $i++) { - if (!is_null($cellMargin[$i])) { - $hasMargins = true; - break; - } - } if ($hasMargins || $hasBorders) { $this->xmlWriter->startElement('w:tblPr'); if ($hasMargins) { $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($cellMargin); + $mbWriter->setSizes($this->style->getCellMargin()); $this->xmlWriter->startElement('w:tblCellMar'); $mbWriter->write(); @@ -71,8 +55,8 @@ public function write() } if ($hasBorders) { $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($brdSz); - $mbWriter->setColors($brdCol); + $mbWriter->setSizes($this->style->getBorderSize()); + $mbWriter->setColors($this->style->getBorderColor()); $this->xmlWriter->startElement('w:tblBorders'); $mbWriter->write(); @@ -123,18 +107,10 @@ private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style, $type) } // Borders - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - $hasBorders = false; - for ($i = 0; $i < 6; $i++) { - if (!is_null($brdSz[$i])) { - $hasBorders = true; - } - } - if ($hasBorders) { + if ($style->hasBorders()) { $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($brdSz); - $mbWriter->setColors($brdCol); + $mbWriter->setSizes($style->getBorderSize()); + $mbWriter->setColors($style->getBorderColor()); $this->xmlWriter->startElement('w:tcBorders'); $mbWriter->write(); From 0c1e47d7a77287e3ba368ceded3034bb507f3778 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 6 May 2014 23:37:14 +0700 Subject: [PATCH 045/167] Type checking --- src/PhpWord/Writer/HTML/Element/Footnote.php | 4 ++++ src/PhpWord/Writer/HTML/Element/Image.php | 7 ++++--- src/PhpWord/Writer/HTML/Element/Link.php | 4 ++++ src/PhpWord/Writer/HTML/Element/ListItem.php | 4 ++++ src/PhpWord/Writer/HTML/Element/Table.php | 4 ++++ src/PhpWord/Writer/HTML/Element/Text.php | 10 ++++++++-- src/PhpWord/Writer/HTML/Element/TextRun.php | 4 ++++ src/PhpWord/Writer/HTML/Element/Title.php | 4 ++++ src/PhpWord/Writer/ODText/Element/Image.php | 4 ++++ src/PhpWord/Writer/ODText/Element/Link.php | 4 ++++ src/PhpWord/Writer/ODText/Element/Table.php | 4 ++++ src/PhpWord/Writer/ODText/Element/Text.php | 4 ++++ src/PhpWord/Writer/ODText/Element/TextRun.php | 7 ++++++- src/PhpWord/Writer/RTF/Element/Text.php | 4 ++++ src/PhpWord/Writer/RTF/Element/TextRun.php | 5 +++++ src/PhpWord/Writer/RTF/Element/Title.php | 5 +++++ src/PhpWord/Writer/Word2007/Element/CheckBox.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Footnote.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Image.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Link.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/ListItem.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Object.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/PreserveText.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/TOC.php | 7 +++++++ src/PhpWord/Writer/Word2007/Element/Table.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Text.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/TextRun.php | 4 ++++ src/PhpWord/Writer/Word2007/Element/Title.php | 4 ++++ src/PhpWord/Writer/Word2007/Part/Rels.php | 2 +- 29 files changed, 124 insertions(+), 7 deletions(-) diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index 888ba41109..f1570ed0ba 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -38,6 +38,10 @@ class Footnote extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { + return; + } + $noteId = count($this->parentWriter->getNotes()) + 1; $noteMark = $this->noteType . '-' . $this->element->getRelationId(); $this->parentWriter->addNote($noteId, $noteMark); diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 6ba272d939..3813146d47 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -34,10 +34,11 @@ class Image extends Element */ public function write() { - $html = ''; - if (!$this->element instanceof ImageElement) { - return $html; + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; } + + $html = ''; if (!$this->parentWriter->isPdf()) { $imageData = $this->getBase64ImageData($this->element); if (!is_null($imageData)) { diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 5906205f1a..2792eb6719 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -31,6 +31,10 @@ class Link extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } + $html = "element->getTarget()}\">{$this->element->getText()}" . PHP_EOL; if (!$this->withoutP) { $html = '

' . $html . '

' . PHP_EOL; diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 42675bbf93..89f2ad69f3 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -31,6 +31,10 @@ class ListItem extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { + return; + } + $text = htmlspecialchars($this->element->getTextObject()->getText()); $html = '

' . $text . '

' . PHP_EOL; diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index 2c96a97ad8..b3974554ac 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -31,6 +31,10 @@ class Table extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } + $html = ''; $rows = $this->element->getRows(); $rowCount = count($rows); diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 20b6ce7997..dceb7a4d20 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -36,6 +36,10 @@ class Text extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } + $html = ''; // Paragraph style $paragraphStyle = $this->element->getParagraphStyle(); @@ -44,6 +48,8 @@ public function write() $styleWriter = new ParagraphStyleWriter($paragraphStyle); $paragraphStyle = $styleWriter->write(); } + $hasParagraphStyle = $paragraphStyle && !$this->withoutP; + // Font style $fontStyle = $this->element->getFontStyle(); $fontStyleIsObject = ($fontStyle instanceof Font); @@ -52,7 +58,7 @@ public function write() $fontStyle = $styleWriter->write(); } - if ($paragraphStyle && !$this->withoutP) { + if ($hasParagraphStyle) { $attribute = $pStyleIsObject ? 'style' : 'class'; $html .= "

"; } @@ -64,7 +70,7 @@ public function write() if ($fontStyle) { $html .= ''; } - if ($paragraphStyle && !$this->withoutP) { + if ($hasParagraphStyle) { $html .= '

' . PHP_EOL; } diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index 02b244885f..b6848d8f0d 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -34,6 +34,10 @@ class TextRun extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { + return; + } + $html = ''; $elements = $this->element->getElements(); if (count($elements) > 0) { diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 68633f1f75..e22522417a 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -31,6 +31,10 @@ class Title extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { + return; + } + $tag = 'h' . $this->element->getDepth(); $text = htmlspecialchars($this->element->getText()); $html = "<{$tag}>{$text}" . PHP_EOL; diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index 14408d66e4..ffe2d0943b 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -31,6 +31,10 @@ class Image extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { + return; + } + $mediaIndex = $this->element->getMediaIndex(); $target = 'Pictures/' . $this->element->getTarget(); $style = $this->element->getStyle(); diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 9914b1cd50..4ff094d226 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -29,6 +29,10 @@ class Link extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } + if (!$this->withoutP) { $this->xmlWriter->startElement('text:p'); // text:p } diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index fcd1461a6d..dbe5b14c01 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -32,6 +32,10 @@ class Table extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } + $rows = $this->element->getRows(); $rowCount = count($rows); $colCount = $this->element->countColumns(); diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 0c94bf0bb3..ee2fafabda 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -29,6 +29,10 @@ class Text extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } + $fontStyle = $this->element->getFontStyle(); $paragraphStyle = $this->element->getParagraphStyle(); diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php index 3627f1483c..b03fc353a0 100644 --- a/src/PhpWord/Writer/ODText/Element/TextRun.php +++ b/src/PhpWord/Writer/ODText/Element/TextRun.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; +use PhpOffice\PhpWord\Element\Link as LinkElement; use PhpOffice\PhpWord\Element\Text as TextElement; /** @@ -31,6 +32,10 @@ class TextRun extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { + return; + } + $elements = $this->element->getElements(); $this->xmlWriter->startElement('text:p'); if (count($elements) > 0) { @@ -38,7 +43,7 @@ public function write() if ($element instanceof TextElement) { $elementWriter = new Text($this->xmlWriter, $this->parentWriter, $element, true); $elementWriter->write(); - } elseif ($element instanceof Link) { + } elseif ($element instanceof LinkElement) { $elementWriter = new Link($this->xmlWriter, $this->parentWriter, $element, true); $elementWriter->write(); } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 83ade9d248..8b71b39019 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -33,6 +33,10 @@ class Text extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } + $rtfText = ''; $fontStyle = $this->element->getFontStyle(); diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 775282e01f..f5df5d9698 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -33,7 +33,12 @@ class TextRun extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { + return; + } + $rtfText = ''; + $elements = $this->element->getElements(); if (count($elements) > 0) { $rtfText .= '\pard\nowidctlpar' . PHP_EOL; diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 524c005d00..5915c42e58 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -31,7 +31,12 @@ class Title extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { + return; + } + $rtfText = ''; + $rtfText .= '\pard\nowidctlpar' . PHP_EOL; $rtfText .= $this->element->getText(); $rtfText .= '\par' . PHP_EOL; diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 543a49b4b7..ef8c166d4f 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -33,6 +33,10 @@ class CheckBox extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\CheckBox) { + return; + } + $name = htmlspecialchars($this->element->getName()); $name = String::controlCharacterPHP2OOXML($name); $text = htmlspecialchars($this->element->getText()); diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index b5d887274e..f1f276aae4 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -36,6 +36,10 @@ class Footnote extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { + return; + } + if (!$this->withoutP) { $this->xmlWriter->startElement('w:p'); } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 214b8a2acf..6b948f1e69 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -43,6 +43,10 @@ public function write() */ private function writeImage() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { + return; + } + $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); $style = $this->element->getStyle(); $styleWriter = new ImageStyleWriter($this->xmlWriter, $style); diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 2342b31299..2e53b1a809 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -32,6 +32,10 @@ class Link extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } + $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); $fontStyle = $this->element->getFontStyle(); $paragraphStyle = $this->element->getParagraphStyle(); diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index df8621ffea..e43948622c 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -32,6 +32,10 @@ class ListItem extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { + return; + } + $textObject = $this->element->getTextObject(); $depth = $this->element->getDepth(); $numId = $this->element->getStyle()->getNumId(); diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index 6e6a1cbb53..db90d78c7b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -29,6 +29,10 @@ class Object extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Object) { + return; + } + $rIdObject = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); $rIdImage = $this->element->getImageRelationId() + ($this->element->isInSection() ? 6 : 0); $shapeId = md5($rIdObject . '_' . $rIdImage); diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index f09af49ce7..63c0389934 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -33,6 +33,10 @@ class PreserveText extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\PreserveText) { + return; + } + $fontStyle = $this->element->getFontStyle(); $paragraphStyle = $this->element->getParagraphStyle(); $texts = $this->element->getText(); diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 1ebde1a90e..e4542bcb9e 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -34,6 +34,10 @@ class TOC extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\TOC) { + return; + } + $titles = $this->element->getTitles(); $writeFieldMark = true; @@ -55,6 +59,9 @@ public function write() /** * Write title + * + * @param \PhpOffice\PhpWord\Element\Title $title + * @param bool $writeFieldMark */ private function writeTitle($title, $writeFieldMark) { diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 0786397977..3a29f4107f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -36,6 +36,10 @@ class Table extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } + $rows = $this->element->getRows(); $rowCount = count($rows); diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index a6621a0549..c271174f4a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -33,6 +33,10 @@ class Text extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } + $fontStyle = $this->element->getFontStyle(); $paragraphStyle = $this->element->getParagraphStyle(); $text = htmlspecialchars($this->element->getText()); diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index 6d761b4ff5..d4b2d29138 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -31,6 +31,10 @@ class TextRun extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { + return; + } + $paragraphStyle = $this->element->getParagraphStyle(); $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); $styleWriter->setIsInline(true); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index c55a60a793..e1c7a0aee2 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -31,6 +31,10 @@ class Title extends Element */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { + return; + } + $bookmarkId = $this->element->getBookmarkId(); $anchor = '_Toc' . ($bookmarkId + 252634154); $style = $this->element->getStyle(); diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 22480ce26c..95ac32b1c9 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -72,7 +72,7 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = } // Media relationships - if (!is_null($mediaRels) && is_array($mediaRels)) { + if (is_array($mediaRels)) { $mapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink'); $targetPaths = array('image' => 'media/', 'object' => 'embeddings/'); foreach ($mediaRels as $mediaRel) { From 51d69a44c6987d8c87e4a83a581da8dd5a730c64 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 7 May 2014 01:11:56 +0700 Subject: [PATCH 046/167] Refactoring based on Scrutinizer recommendation --- src/PhpWord/Writer/HTML/Element/Image.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 17 +++---- src/PhpWord/Writer/HTML/Element/TextRun.php | 4 +- src/PhpWord/Writer/HTML/Style/Font.php | 56 ++++++++++++--------- src/PhpWord/Writer/RTF/Element/Text.php | 33 ++++++++---- src/PhpWord/Writer/Word2007/Element/TOC.php | 2 + 6 files changed, 69 insertions(+), 45 deletions(-) diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 3813146d47..93c1082618 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -34,7 +34,7 @@ class Image extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { return; } diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index dceb7a4d20..7130ea2129 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -58,22 +58,21 @@ public function write() $fontStyle = $styleWriter->write(); } + $openingTags = ''; + $endingTags = ''; if ($hasParagraphStyle) { $attribute = $pStyleIsObject ? 'style' : 'class'; - $html .= "

"; + $openingTags = "

"; + $endingTags = '

' . PHP_EOL; } if ($fontStyle) { $attribute = $fontStyleIsObject ? 'style' : 'class'; - $html .= ""; - } - $html .= htmlspecialchars($this->element->getText()); - if ($fontStyle) { - $html .= ''; - } - if ($hasParagraphStyle) { - $html .= '

' . PHP_EOL; + $openingTags = $openingTags . ""; + $endingTags = '' . $endingTags; } + $html = $openingTags . htmlspecialchars($this->element->getText()) . $endingTags; + return $html; } } diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index b6848d8f0d..604150434d 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element; +use PhpOffice\PhpWord\Element\Footnote as FootnoteElement; +use PhpOffice\PhpWord\Element\TextRun as TextRunElement; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter; @@ -34,7 +36,7 @@ class TextRun extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { + if (!($this->element instanceof TextRunElement || $this->element instanceof FootnoteElement)) { return; } diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 7c8111f346..7ab4dc400b 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -34,40 +34,48 @@ class Font extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Font)) { + if (!$this->style instanceof \PhpOffice\PhpWord\Style\Font) { return; } + $font = $this->style->getName(); + $size = $this->style->getSize(); + $color = $this->style->getColor(); + $fgColor = $this->style->getFgColor(); + $underline = $this->style->getUnderline() != FontStyle::UNDERLINE_NONE; + $lineThrough = $this->style->isStrikethrough() || $this->style->isDoubleStrikethrough(); + $css = array(); - if (PhpWord::DEFAULT_FONT_NAME != $this->style->getName()) { - $css['font-family'] = "'" . $this->style->getName() . "'"; - } - if (PhpWord::DEFAULT_FONT_SIZE != $this->style->getSize()) { - $css['font-size'] = $this->style->getSize() . 'pt'; - } - if (PhpWord::DEFAULT_FONT_COLOR != $this->style->getColor()) { - $css['color'] = '#' . $this->style->getColor(); - } - $css['background'] = $this->style->getFgColor(); - if ($this->style->isBold()) { - $css['font-weight'] = 'bold'; - } - if ($this->style->isItalic()) { - $css['font-style'] = 'italic'; - } + + $css['font-family'] = $this->getValueIf($font != PhpWord::DEFAULT_FONT_NAME, "'{$font}'"); + $css['font-size'] = $this->getValueIf($size != PhpWord::DEFAULT_FONT_SIZE, "{$size}pt"); + $css['color'] = $this->getValueIf($color != PhpWord::DEFAULT_FONT_COLOR, "#{$color}"); + $css['background'] = $this->getValueIf($fgColor != '', $fgColor); + $css['font-weight'] = $this->getValueIf($this->style->isBold(), 'bold'); + $css['font-style'] = $this->getValueIf($this->style->isItalic(), 'italic'); + + $css['text-decoration'] = ''; + $css['text-decoration'] .= $this->getValueIf($underline, 'underline '); + $css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through '); + if ($this->style->isSuperScript()) { $css['vertical-align'] = 'super'; } elseif ($this->style->isSubScript()) { $css['vertical-align'] = 'sub'; } - $css['text-decoration'] = ''; - if ($this->style->getUnderline() != FontStyle::UNDERLINE_NONE) { - $css['text-decoration'] .= 'underline '; - } - if ($this->style->isStrikethrough()) { - $css['text-decoration'] .= 'line-through '; - } return $this->assembleCss($css); } + + /** + * Get value if ... + * + * @param bool $condition + * @param string $value + * @return string + */ + private function getValueIf($condition, $value) + { + return $condition ? $value : ''; + } } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 8b71b39019..f4225ead07 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -18,8 +18,9 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font as FontStyle; +use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; /** * Text element RTF writer @@ -51,15 +52,7 @@ public function write() if ($paragraphStyle && !$this->withoutP) { if ($this->parentWriter->getLastParagraphStyle() != $this->element->getParagraphStyle()) { - $rtfText .= '\pard\nowidctlpar'; - if ($paragraphStyle->getSpaceAfter() != null) { - $rtfText .= '\sa' . $paragraphStyle->getSpaceAfter(); - } - if ($paragraphStyle->getAlign() != null) { - if ($paragraphStyle->getAlign() == 'center') { - $rtfText .= '\qc'; - } - } + $rtfText .= $this->writeParagraphStyle($paragraphStyle); $this->parentWriter->setLastParagraphStyle($this->element->getParagraphStyle()); } else { $this->parentWriter->setLastParagraphStyle(); @@ -85,6 +78,26 @@ public function write() return $rtfText; } + /** + * Write paragraph style + * + * @return string + */ + private function writeParagraphStyle(ParagraphStyle $paragraphStyle) + { + $rtfText = '\pard\nowidctlpar'; + if ($paragraphStyle->getSpaceAfter() != null) { + $rtfText .= '\sa' . $paragraphStyle->getSpaceAfter(); + } + if ($paragraphStyle->getAlign() != null) { + if ($paragraphStyle->getAlign() == 'center') { + $rtfText .= '\qc'; + } + } + + return $rtfText; + } + /** * Write font style beginning * diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index e4542bcb9e..6f1e2cdf9c 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -125,6 +125,8 @@ private function writeTitle($title, $writeFieldMark) /** * Write style + * + * @param int $indent */ private function writeStyle($indent) { From e0638f56bdfbae61ffcbc76a78bd6fce6eb1d882 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 7 May 2014 01:44:51 +0700 Subject: [PATCH 047/167] Change Scrutinizer similarity analysis min mass --- .scrutinizer.yml | 7 +++---- src/PhpWord/Writer/HTML/Element/Text.php | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 8efd68d3d6..d6a58c0f58 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -8,9 +8,8 @@ tools: external_code_coverage: enabled: true timeout: 900 - php_code_coverage: - enabled: false - test_command: phpunit -c phpunit.xml.dist - php_sim: true + php_sim: + min_mass: 25 php_pdepend: true php_analyzer: true + sensiolabs_security_checker: true diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 7130ea2129..96e0c25e7b 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -40,7 +40,6 @@ public function write() return; } - $html = ''; // Paragraph style $paragraphStyle = $this->element->getParagraphStyle(); $pStyleIsObject = ($paragraphStyle instanceof Paragraph); From 88560de60173c21253e0d571d881c12ef63183ff Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 7 May 2014 09:47:02 +0700 Subject: [PATCH 048/167] Refactor writers --- .scrutinizer.yml | 2 +- src/PhpWord/Element/AbstractContainer.php | 7 +- src/PhpWord/Element/Section.php | 3 +- src/PhpWord/Element/Text.php | 4 +- src/PhpWord/Element/TextBreak.php | 14 +- src/PhpWord/Shared/XMLWriter.php | 35 ++ src/PhpWord/Style/AbstractStyle.php | 67 ++- src/PhpWord/Style/Border.php | 18 + src/PhpWord/Style/Cell.php | 17 +- src/PhpWord/Style/Font.php | 380 +++++++++--------- src/PhpWord/Style/Paragraph.php | 77 +--- src/PhpWord/Style/Section.php | 11 +- src/PhpWord/Style/Table.php | 31 +- src/PhpWord/Writer/HTML.php | 22 +- src/PhpWord/Writer/HTML/Element/Element.php | 13 +- src/PhpWord/Writer/ODText.php | 42 +- .../Writer/ODText/Element/AbstractElement.php | 27 ++ .../Writer/ODText/Element/Container.php | 27 ++ src/PhpWord/Writer/ODText/Element/Element.php | 87 ---- src/PhpWord/Writer/ODText/Element/Image.php | 47 ++- src/PhpWord/Writer/ODText/Element/Link.php | 21 +- src/PhpWord/Writer/ODText/Element/Table.php | 52 +-- src/PhpWord/Writer/ODText/Element/Text.php | 34 +- .../Writer/ODText/Element/TextBreak.php | 10 +- src/PhpWord/Writer/ODText/Element/TextRun.php | 30 +- src/PhpWord/Writer/ODText/Part/Content.php | 11 +- src/PhpWord/Writer/ODText/Part/Styles.php | 2 +- src/PhpWord/Writer/ODText/Style/Font.php | 59 +-- src/PhpWord/Writer/ODText/Style/Paragraph.php | 31 +- src/PhpWord/Writer/PDF.php | 2 +- src/PhpWord/Writer/RTF.php | 27 +- src/PhpWord/Writer/RTF/Element/Element.php | 13 +- src/PhpWord/Writer/Word2007.php | 84 ++-- .../{Element.php => AbstractElement.php} | 58 +-- .../Writer/Word2007/Element/CheckBox.php | 114 +++--- .../Writer/Word2007/Element/Container.php | 58 +++ .../Writer/Word2007/Element/Footnote.php | 37 +- src/PhpWord/Writer/Word2007/Element/Image.php | 88 ++-- src/PhpWord/Writer/Word2007/Element/Link.php | 50 +-- .../Writer/Word2007/Element/ListItem.php | 44 +- .../Writer/Word2007/Element/Object.php | 77 ++-- .../Writer/Word2007/Element/PageBreak.php | 18 +- .../Writer/Word2007/Element/PreserveText.php | 97 ++--- src/PhpWord/Writer/Word2007/Element/TOC.php | 184 +++++---- src/PhpWord/Writer/Word2007/Element/Table.php | 104 ++--- src/PhpWord/Writer/Word2007/Element/Text.php | 89 +++- .../Writer/Word2007/Element/TextBreak.php | 40 +- .../Writer/Word2007/Element/TextRun.php | 19 +- src/PhpWord/Writer/Word2007/Element/Title.php | 62 +-- .../Writer/Word2007/Part/AbstractPart.php | 55 +-- src/PhpWord/Writer/Word2007/Part/Document.php | 6 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 5 +- .../Writer/Word2007/Part/Footnotes.php | 4 +- src/PhpWord/Writer/Word2007/Part/Rels.php | 18 +- .../Writer/Word2007/Style/AbstractStyle.php | 55 +-- src/PhpWord/Writer/Word2007/Style/Cell.php | 70 ++-- src/PhpWord/Writer/Word2007/Style/Font.php | 80 ++-- src/PhpWord/Writer/Word2007/Style/Image.php | 26 +- .../Writer/Word2007/Style/Indentation.php | 21 +- .../Writer/Word2007/Style/LineNumbering.php | 15 +- .../Writer/Word2007/Style/MarginBorder.php | 18 +- .../Writer/Word2007/Style/Paragraph.php | 48 +-- src/PhpWord/Writer/Word2007/Style/Section.php | 76 ++-- src/PhpWord/Writer/Word2007/Style/Shading.php | 13 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 26 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 13 +- src/PhpWord/Writer/Word2007/Style/Table.php | 64 +-- tests/PhpWord/Tests/Style/FontTest.php | 3 +- 68 files changed, 1521 insertions(+), 1541 deletions(-) create mode 100644 src/PhpWord/Writer/ODText/Element/AbstractElement.php create mode 100644 src/PhpWord/Writer/ODText/Element/Container.php delete mode 100644 src/PhpWord/Writer/ODText/Element/Element.php rename src/PhpWord/Writer/Word2007/Element/{Element.php => AbstractElement.php} (57%) create mode 100644 src/PhpWord/Writer/Word2007/Element/Container.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d6a58c0f58..ab5f86209b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -9,7 +9,7 @@ tools: enabled: true timeout: 900 php_sim: - min_mass: 25 + min_mass: 30 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 4ac6c22be6..7d31797262 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -39,8 +39,7 @@ abstract class AbstractContainer extends AbstractElement */ protected function addElement(AbstractElement $element) { - // $type = get_class($element); - // $type = str_replace('PhpOffice\\PhpWord\\Element\\', '', $type); + // $type = basename(get_class($element)); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); $element->setPhpWord($this->phpWord); @@ -79,7 +78,7 @@ public function countElements() public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') { $this->checkValidity($elementName); - $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; + $elementClass = dirname(get_class($this)) . '\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { @@ -249,7 +248,7 @@ public function addObject($source, $style = null) public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { $this->checkValidity($elementName); - $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; + $elementClass = dirname(get_class($this)) . '\\' . $elementName; $docPart = strtolower($elementName); $addMethod = "add{$elementName}"; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 1ccdccc8c2..639f752e85 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -223,8 +223,7 @@ public function hasDifferentFirstPage() private function addHeaderFooter($type = Header::AUTO, $header = true) { $collectionArray = $header ? 'headers' : 'footers'; - $containerClass = 'PhpOffice\\PhpWord\\Element\\'; - $containerClass .= ($header ? 'Header' : 'Footer'); + $containerClass = dirname(get_class($this)) . '\\' . ($header ? 'Header' : 'Footer'); $collection = &$this->$collectionArray; if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index f992b07c5a..52fccb3f28 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -75,7 +75,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) $this->setParagraphStyle($paragraphStyle); } elseif (is_array($style)) { $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); + $this->fontStyle->setStyleByArray($style); } elseif (null === $style) { $this->fontStyle = new Font('text', $paragraphStyle); } else { @@ -106,7 +106,7 @@ public function setParagraphStyle($style = null) { if (is_array($style)) { $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); + $this->paragraphStyle->setStyleByArray($style); } elseif ($style instanceof Paragraph) { $this->paragraphStyle = $style; } elseif (null === $style) { diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index 02518373ed..aa6ab582b2 100644 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -69,7 +69,7 @@ public function setFontStyle($style = null, $paragraphStyle = null) $this->setParagraphStyle($paragraphStyle); } elseif (is_array($style)) { $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); + $this->fontStyle->setStyleByArray($style); } else { $this->fontStyle = $style; $this->setParagraphStyle($paragraphStyle); @@ -97,7 +97,7 @@ public function setParagraphStyle($style = null) { if (is_array($style)) { $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); + $this->paragraphStyle->setStyleByArray($style); } elseif ($style instanceof Paragraph) { $this->paragraphStyle = $style; } else { @@ -115,4 +115,14 @@ public function getParagraphStyle() { return $this->paragraphStyle; } + + /** + * Has font/paragraph style defined + * + * @return bool + */ + public function hasStyle() + { + return !is_null($this->fontStyle) || !is_null($this->paragraphStyle); + } } diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 417230021e..a16fe0b4b1 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -149,4 +149,39 @@ public function writeRaw($text) return $this->text($text); } + + /** + * Write element if ... + * + * @param bool $condition + * @param string $element + * @param string $attribute + * @param string $value + */ + public function writeElementIf($condition, $element, $attribute = null, $value = null) + { + if ($condition) { + if (is_null($attribute)) { + $this->xmlWriter->writeElement($element, $value); + } else { + $this->xmlWriter->startElement($element); + $this->xmlWriter->writeAttribute($attribute, $value); + $this->xmlWriter->endElement(); + } + } + } + + /** + * Write attribute if ... + * + * @param bool $condition + * @param string $attribute + * @param string $value + */ + public function writeAttributeIf($condition, $attribute, $value) + { + if ($condition) { + $this->xmlWriter->writeAttribute($attribute, $value); + } + } } diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index caceb46a63..f43aba906e 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -38,10 +38,17 @@ abstract class AbstractStyle * * This number starts from one and defined in Style::setStyleValues() * - * @var integer|null + * @var int|null */ protected $index; + /** + * Aliases + * + * @var array + */ + protected $aliases = array(); + /** * Get style name * @@ -68,7 +75,7 @@ public function setStyleName($value) /** * Get index number * - * @return integer|null + * @return int|null */ public function getIndex() { @@ -78,7 +85,7 @@ public function getIndex() /** * Set index number * - * @param integer|null $value + * @param int|null $value * @return self */ public function setIndex($value = null) @@ -102,6 +109,9 @@ public function setIndex($value = null) */ public function setStyleValue($key, $value) { + if (isset($this->aliases[$key])) { + $key = $this->aliases[$key]; + } $method = 'set' . String::removeUnderscorePrefix($key); if (method_exists($this, $method)) { $this->$method($value); @@ -150,6 +160,9 @@ protected function setNonEmptyVal($value, $default) */ protected function setBoolVal($value, $default = null) { + if (is_string($value)) { + $value = (bool)$value; + } if (!is_bool($value)) { $value = $default; } @@ -161,8 +174,8 @@ protected function setBoolVal($value, $default = null) * Set numeric value * * @param mixed $value - * @param integer|float|null $default - * @return integer|float|null + * @param int|float|null $default + * @return int|float|null */ protected function setNumericVal($value, $default = null) { @@ -177,11 +190,14 @@ protected function setNumericVal($value, $default = null) * Set integer value * * @param mixed $value - * @param integer|null $default - * @return integer|null + * @param int|null $default + * @return int|null */ protected function setIntVal($value, $default = null) { + if (is_string($value)) { + $value = intval($value); + } if (!is_int($value)) { $value = $default; } @@ -198,6 +214,9 @@ protected function setIntVal($value, $default = null) */ protected function setFloatVal($value, $default = null) { + if (is_string($value)) { + $value = floatval($value); + } if (!is_float($value)) { $value = $default; } @@ -220,4 +239,38 @@ protected function setEnumVal($value, $enum, $default = null) return $value; } + + /** + * Set object value + * + * @param mixed $value + * @param string $styleName + * @param mixed $style + */ + protected function setObjectVal($value, $styleName, &$style) + { + $styleClass = dirname(get_class($this)) . '\\' . $styleName; + if (is_array($value)) { + if (!$style instanceof $styleClass) { + $style = new $styleClass(); + } + $style->setStyleByArray($value); + } else { + $style = $value; + } + + return $style; + } + + /** + * Set style using associative array + * + * @param array $style + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function setArrayStyle(array $style = array()) + { + return $this->setStyleByArray($style); + } } diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index 433ee265d9..f7c479fe5a 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -323,4 +323,22 @@ public function getBorderBottomColor() { return $this->borderBottomColor; } + + /** + * Has borders? + * + * @return bool + */ + public function hasBorders() + { + $hasBorders = false; + $borders = $this->getBorderSize(); + for ($i = 0; $i < count($borders); $i++) { + if (!is_null($borders[$i])) { + $hasBorders = true; + } + } + + return $hasBorders; + } } diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 669df6b0bc..31b7e30792 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -42,7 +42,7 @@ class Cell extends Border * * @var string */ - private $valign; + private $vAlign; /** * Text Direction @@ -80,7 +80,7 @@ class Cell extends Border */ public function getVAlign() { - return $this->valign; + return $this->vAlign; } /** @@ -90,7 +90,7 @@ public function getVAlign() */ public function setVAlign($value = null) { - $this->valign = $value; + $this->vAlign = $value; } /** @@ -183,19 +183,12 @@ public function getShading() /** * Set shading * - * @param array $value + * @param mixed $value * @return self */ public function setShading($value = null) { - if (is_array($value)) { - if (!$this->shading instanceof Shading) { - $this->shading = new Shading(); - } - $this->shading->setStyleByArray($value); - } else { - $this->shading = null; - } + $this->setObjectVal($value, 'Shading', $this->shading); return $this; } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 7605312a3a..f0ee893e67 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -71,18 +71,18 @@ class Font extends AbstractStyle const FGCOLOR_BLACK = 'black'; /** - * Font style type + * Aliases * - * @var string + * @var array */ - private $type; + protected $aliases = array('line-height' => 'lineHeight'); /** - * Paragraph style + * Font style type * - * @var \PhpOffice\PhpWord\Style\Paragraph + * @var string */ - private $paragraphStyle; + private $type; /** * Font name @@ -91,6 +91,13 @@ class Font extends AbstractStyle */ private $name = PhpWord::DEFAULT_FONT_NAME; + /** + * Font Content Type + * + * @var string + */ + private $hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE; + /** * Font size * @@ -98,6 +105,13 @@ class Font extends AbstractStyle */ private $size = PhpWord::DEFAULT_FONT_SIZE; + /** + * Font color + * + * @var string + */ + private $color = PhpWord::DEFAULT_FONT_COLOR; + /** * Bold * @@ -112,6 +126,13 @@ class Font extends AbstractStyle */ private $italic = false; + /** + * Undeline + * + * @var string + */ + private $underline = self::UNDERLINE_NONE; + /** * Superscript * @@ -126,13 +147,6 @@ class Font extends AbstractStyle */ private $subScript = false; - /** - * Undeline - * - * @var string - */ - private $underline = self::UNDERLINE_NONE; - /** * Strikethrough * @@ -148,54 +162,40 @@ class Font extends AbstractStyle private $doubleStrikethrough = false; /** - * Font color + * Small caps * - * @var string + * @var bool + * @link http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html */ - private $color = PhpWord::DEFAULT_FONT_COLOR; + private $smallCaps = false; /** - * Foreground/highlight + * All caps * - * @var string + * @var bool + * @link http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html */ - private $fgColor = null; + private $allCaps = false; /** - * Text line height + * Foreground/highlight * - * @var int + * @var string */ + private $fgColor; /** * Text line height * * @var int */ - private $lineHeight = 1.0; /** - * Font Content Type - * - * @var string - */ - private $hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE; - - /** - * Small caps - * - * @var bool - * @link http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html - */ - private $smallCaps = false; - - /** - * All caps + * Paragraph style * - * @var bool - * @link http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html + * @var \PhpOffice\PhpWord\Style\Paragraph */ - private $allCaps = false; + private $paragraph; /** * Shading @@ -208,65 +208,60 @@ class Font extends AbstractStyle * Create new font style * * @param string $type Type of font - * @param array $paragraphStyle Paragraph styles definition + * @param array $paragraph Paragraph styles definition */ - public function __construct($type = 'text', $paragraphStyle = null) + public function __construct($type = 'text', $paragraph = null) { $this->type = $type; + $this->setParagraph($paragraph); + } - if ($paragraphStyle instanceof Paragraph) { - $this->paragraphStyle = $paragraphStyle; - } elseif (is_array($paragraphStyle)) { - $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($paragraphStyle); - } else { - $this->paragraphStyle = $paragraphStyle; - } + /** + * Get font name + * + * @return string + */ + public function getName() + { + return $this->name; } /** - * Set style using associative array + * Set font name * - * @param array $style - * @return $this + * @param string $value + * @return self */ - public function setArrayStyle(array $style = array()) + public function setName($value = PhpWord::DEFAULT_FONT_NAME) { - foreach ($style as $key => $value) { - if ($key === 'line-height') { - $this->setLineHeight($value); - null; - } - $this->setStyleValue($key, $value); - } + $this->name = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_NAME); return $this; } /** - * Get font name + * Get Font Content Type * * @return string */ - public function getName() + public function getHint() { - return $this->name; + return $this->hint; } /** - * Set font name + * Set Font Content Type * * @param string $value * @return self */ - public function setName($value = PhpWord::DEFAULT_FONT_NAME) + public function setHint($value = PhpWord::DEFAULT_FONT_CONTENT_TYPE) { - $this->name = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_NAME); + $this->hint = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_CONTENT_TYPE); return $this; } - /** * Get font size * @@ -290,6 +285,29 @@ public function setSize($value = PhpWord::DEFAULT_FONT_SIZE) return $this; } + /** + * Get font color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set font color + * + * @param string $value + * @return self + */ + public function setColor($value = PhpWord::DEFAULT_FONT_COLOR) + { + $this->color = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_COLOR); + + return $this; + } + /** * Get bold * @@ -336,6 +354,29 @@ public function setItalic($value = false) return $this; } + /** + * Get underline + * + * @return string + */ + public function getUnderline() + { + return $this->underline; + } + + /** + * Set underline + * + * @param string $value + * @return self + */ + public function setUnderline($value = self::UNDERLINE_NONE) + { + $this->underline = $this->setNonEmptyVal($value, self::UNDERLINE_NONE); + + return $this; + } + /** * Get superscript * @@ -355,9 +396,7 @@ public function isSuperScript() public function setSuperScript($value = false) { $this->superScript = $this->setBoolVal($value, $this->superScript); - if ($this->superScript) { - $this->subScript = false; - } + $this->toggleFalse($this->subScript, $this->superScript); return $this; } @@ -381,6 +420,7 @@ public function isSubScript() public function setSubScript($value = false) { $this->subScript = $this->setBoolVal($value, $this->subScript); + $this->toggleFalse($this->subScript, $this->superScript); if ($this->subScript) { $this->superScript = false; } @@ -389,99 +429,97 @@ public function setSubScript($value = false) } /** - * Get underline + * Get strikethrough * - * @return string + * @return bool */ - public function getUnderline() + public function isStrikethrough() { - return $this->underline; + return $this->strikethrough; } /** - * Set underline + * Set strikethrough * - * @param string $value + * @param bool $value * @return self */ - public function setUnderline($value = self::UNDERLINE_NONE) + public function setStrikethrough($value = false) { - $this->underline = $this->setNonEmptyVal($value, self::UNDERLINE_NONE); + $this->strikethrough = $this->setBoolVal($value, $this->strikethrough); + $this->toggleFalse($this->doubleStrikethrough, $this->strikethrough); return $this; } /** - * Get strikethrough + * Get double strikethrough * * @return bool */ - public function isStrikethrough() + public function isDoubleStrikethrough() { - return $this->strikethrough; + return $this->doubleStrikethrough; } /** - * Set strikethrough + * Set double strikethrough * * @param bool $value * @return self */ - public function setStrikethrough($value = false) + public function setDoubleStrikethrough($value = false) { - $this->strikethrough = $this->setBoolVal($value, $this->strikethrough); - if ($this->strikethrough) { - $this->doubleStrikethrough = false; - } + $this->doubleStrikethrough = $this->setBoolVal($value, $this->doubleStrikethrough); + $this->toggleFalse($this->strikethrough, $this->doubleStrikethrough); return $this; } /** - * Get double strikethrough + * Get small caps * * @return bool */ - public function isDoubleStrikethrough() + public function isSmallCaps() { - return $this->doubleStrikethrough; + return $this->smallCaps; } /** - * Set double strikethrough + * Set small caps * * @param bool $value * @return self */ - public function setDoubleStrikethrough($value = false) + public function setSmallCaps($value = false) { - $this->doubleStrikethrough = $this->setBoolVal($value, $this->doubleStrikethrough); - if ($this->doubleStrikethrough) { - $this->strikethrough = false; - } + $this->smallCaps = $this->setBoolVal($value, $this->smallCaps); + $this->toggleFalse($this->allCaps, $this->smallCaps); return $this; } /** - * Get font color + * Get all caps * - * @return string + * @return bool */ - public function getColor() + public function isAllCaps() { - return $this->color; + return $this->allCaps; } /** - * Set font color + * Set all caps * - * @param string $value + * @param bool $value * @return self */ - public function setColor($value = PhpWord::DEFAULT_FONT_COLOR) + public function setAllCaps($value = false) { - $this->color = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_COLOR); + $this->allCaps = $this->setBoolVal($value, $this->allCaps); + $this->toggleFalse($this->smallCaps, $this->allCaps); return $this; } @@ -542,38 +580,6 @@ public function getStyleType() return $this->type; } - /** - * Get paragraph style - * - * @return \PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->paragraphStyle; - } - - /** - * Set lineheight - * - * @param int|float|string $lineHeight - * @return $this - * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException - */ - public function setLineHeight($lineHeight) - { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } - - $this->lineHeight = $lineHeight; - $this->getParagraphStyle()->setLineHeight($lineHeight); - return $this; - } - /** * Get line height * @@ -581,112 +587,79 @@ public function setLineHeight($lineHeight) */ public function getLineHeight() { - return $this->lineHeight; + return $this->getParagraph()->getLineHeight(); } /** - * Get Font Content Type - * - * @return string - */ - public function getHint() - { - return $this->hint; - } - - /** - * Set Font Content Type + * Set lineheight * - * @param string $value + * @param int|float|string $value * @return self */ - public function setHint($value = PhpWord::DEFAULT_FONT_CONTENT_TYPE) + public function setLineHeight($value) { - $this->hint = $this->setNonEmptyVal($value, PhpWord::DEFAULT_FONT_CONTENT_TYPE); + $this->setParagraph(array('lineHeight' => $value)); return $this; } /** - * Get small caps + * Get paragraph style * - * @return bool + * @return \PhpOffice\PhpWord\Style\Paragraph */ - public function isSmallCaps() + public function getParagraph() { - return $this->smallCaps; + return $this->paragraph; } /** - * Set small caps + * Set shading * - * @param bool $value + * @param mixed $value * @return self */ - public function setSmallCaps($value = false) + public function setParagraph($value = null) { - $this->smallCaps = $this->setBoolVal($value, $this->smallCaps); - if ($this->smallCaps) { - $this->allCaps = false; - } + $this->setObjectVal($value, 'Paragraph', $this->paragraph); return $this; } /** - * Get all caps + * Get shading * - * @return bool + * @return \PhpOffice\PhpWord\Style\Shading */ - public function isAllCaps() + public function getShading() { - return $this->allCaps; + return $this->shading; } /** - * Set all caps + * Set shading * - * @param bool $value + * @param mixed $value * @return self */ - public function setAllCaps($value = false) + public function setShading($value = null) { - $this->allCaps = $this->setBoolVal($value, $this->allCaps); - if ($this->allCaps) { - $this->smallCaps = false; - } + $this->setObjectVal($value, 'Shading', $this->shading); return $this; } /** - * Get shading - * - * @return \PhpOffice\PhpWord\Style\Shading - */ - public function getShading() - { - return $this->shading; - } - - /** - * Set shading + * Toggle $target value to false when $source true * - * @param array $value - * @return self + * @param \PhpOffice\PhpWord\Style\AbstractStyle $target + * @param bool $sourceValue */ - public function setShading($value = null) + private function toggleFalse(&$target, $sourceValue) { - if (is_array($value)) { - if (!$this->shading instanceof Shading) { - $this->shading = new Shading(); - } - $this->shading->setStyleByArray($value); - } else { - $this->shading = null; + if ($sourceValue == true) { + $target = false; } - - return $this; } /** @@ -743,4 +716,15 @@ public function getStrikethrough() { return $this->isStrikethrough(); } + + /** + * Get paragraph style + * + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function getParagraphStyle() + { + return $this->getParagraph(); + } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index bd7686700c..b04646eac8 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -27,6 +27,13 @@ class Paragraph extends AbstractStyle { const LINE_HEIGHT = 240; + /** + * Aliases + * + * @var array + */ + protected $aliases = array('line-height' => 'lineHeight'); + /** * Paragraph alignment * @@ -104,24 +111,6 @@ class Paragraph extends AbstractStyle */ private $spacing; - /** - * Set style by array - * - * @param array $style - * @return $this - */ - public function setArrayStyle(array $style = array()) - { - foreach ($style as $key => $value) { - if ($key === 'line-height') { - null; - } - $this->setStyleValue($key, $value); - } - - return $this; - } - /** * Set Style value * @@ -135,9 +124,6 @@ public function setStyleValue($key, $value) $value = $value * 720; } elseif ($key == 'spacing') { $value += 240; // because line height of 1 matches 240 twips - } elseif ($key === 'line-height') { - $this->setLineHeight($value); - return; } $method = 'set' . $key; if (method_exists($this, $method)) { @@ -168,6 +154,7 @@ public function setAlign($value = null) $value = 'both'; } $this->align = $value; + return $this; } @@ -362,6 +349,7 @@ public function getBasedOn() public function setBasedOn($value = 'Normal') { $this->basedOn = $value; + return $this; } @@ -384,6 +372,7 @@ public function getNext() public function setNext($value = null) { $this->next = $value; + return $this; } @@ -405,10 +394,8 @@ public function hasWidowControl() */ public function setWidowControl($value = true) { - if (!is_bool($value)) { - $value = true; - } - $this->widowControl = $value; + $this->widowControl = $this->setBoolVal($value, $this->widowControl); + return $this; } @@ -430,10 +417,8 @@ public function isKeepNext() */ public function setKeepNext($value = false) { - if (!is_bool($value)) { - $value = false; - } - $this->keepNext = $value; + $this->keepNext = $this->setBoolVal($value, $this->keepNext); + return $this; } @@ -455,10 +440,8 @@ public function isKeepLines() */ public function setKeepLines($value = false) { - if (!is_bool($value)) { - $value = false; - } - $this->keepLines = $value; + $this->keepLines = $this->setBoolVal($value, $this->keepLines); + return $this; } @@ -480,10 +463,8 @@ public function hasPageBreakBefore() */ public function setPageBreakBefore($value = false) { - if (!is_bool($value)) { - $value = false; - } - $this->pageBreakBefore = $value; + $this->pageBreakBefore = $this->setBoolVal($value, $this->pageBreakBefore); + return $this; } @@ -500,19 +481,12 @@ public function getIndentation() /** * Set shading * - * @param array $value + * @param mixed $value * @return self */ public function setIndentation($value = null) { - if (is_array($value)) { - if (!$this->indentation instanceof Indentation) { - $this->indentation = new Indentation(); - } - $this->indentation->setStyleByArray($value); - } else { - $this->indentation = null; - } + $this->setObjectVal($value, 'Indentation', $this->indentation); return $this; } @@ -531,20 +505,13 @@ public function getSpace() /** * Set shading * - * @param array $value + * @param mixed $value * @return self * @todo Rename to setSpacing in 1.0 */ public function setSpace($value = null) { - if (is_array($value)) { - if (!$this->spacing instanceof Spacing) { - $this->spacing = new Spacing(); - } - $this->spacing->setStyleByArray($value); - } else { - $this->spacing = null; - } + $this->setObjectVal($value, 'Spacing', $this->spacing); return $this; } diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index cc458f06b9..7306c6a6c4 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -509,19 +509,12 @@ public function getLineNumbering() /** * Set line numbering * - * @param array $value + * @param mixed $value * @return self */ public function setLineNumbering($value = null) { - if (is_array($value)) { - if (!$this->lineNumbering instanceof LineNumbering) { - $this->lineNumbering = new LineNumbering($value); - } - $this->lineNumbering->setStyleByArray($value); - } else { - $this->lineNumbering = null; - } + $this->setObjectVal($value, 'LineNumbering', $this->lineNumbering); return $this; } diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index d636b7653e..9173d0d754 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -425,41 +425,16 @@ public function getShading() /** * Set shading * - * @param array $value + * @param mixed $value * @return self */ public function setShading($value = null) { - if (is_array($value)) { - if (!$this->shading instanceof Shading) { - $this->shading = new Shading(); - } - $this->shading->setStyleByArray($value); - } else { - $this->shading = null; - } + $this->setObjectVal($value, 'Shading', $this->shading); return $this; } - /** - * Has borders? - * - * @return bool - */ - public function hasBorders() - { - $hasBorders = false; - $borders = $this->getBorderSize(); - for ($i = 0; $i < 6; $i++) { - if (!is_null($borders[$i])) { - $hasBorders = true; - } - } - - return $hasBorders; - } - /** * Has margins? * @@ -469,7 +444,7 @@ public function hasMargins() { $hasMargins = false; $margins = $this->getCellMargin(); - for ($i = 0; $i < 4; $i++) { + for ($i = 0; $i < count($margins); $i++) { if (!is_null($margins[$i])) { $hasMargins = true; } diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index d8ecd31f36..e28d773319 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -67,19 +67,19 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - if (!is_null($this->getPhpWord())) { - $this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/'); - $hFile = fopen($filename, 'w'); - if ($hFile !== false) { - fwrite($hFile, $this->writeDocument()); - fclose($hFile); - } else { - throw new Exception("Can't open file"); - } - $this->clearTempDir(); + if (is_null($this->phpWord)) { + throw new Exception('PhpWord object unassigned.'); + } + + $this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/'); + $hFile = fopen($filename, 'w'); + if ($hFile !== false) { + fwrite($hFile, $this->writeDocument()); + fclose($hFile); } else { - throw new Exception("No PHPWord assigned."); + throw new Exception("Can't open file"); } + $this->clearTempDir(); } /** diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index bd8d38b6f3..b0d25b4497 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -72,14 +72,13 @@ public function __construct(HTML $parentWriter, AbstractElement $element, $witho */ public function write() { - $html = ''; - $elmName = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($this->element)); - $elmWriterClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $elmName; - if (class_exists($elmWriterClass) === true) { - $elmWriter = new $elmWriterClass($this->parentWriter, $this->element, $this->withoutP); - $html = $elmWriter->write(); + $content = ''; + $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($this->element)); + if (class_exists($writerClass)) { + $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); + $content = $writer->write(); } - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index fa290206df..72c4a0b5a1 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -47,7 +47,7 @@ public function __construct(PhpWord $phpWord = null) 'Manifest' => 'META-INF/manifest.xml', ); foreach (array_keys($this->parts) as $partName) { - $partClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\' . $partName; + $partClass = get_class($this) . '\\Part\\' . $partName; if (class_exists($partClass)) { $partObject = new $partClass(); $partObject->setParentWriter($this); @@ -67,31 +67,31 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - if (!is_null($this->phpWord)) { - $filename = $this->getTempFile($filename); - $objZip = $this->getZipArchive($filename); + if (is_null($this->phpWord)) { + throw new Exception('PhpWord object unassigned.'); + } - // Add section media files - $sectionMedia = Media::getElements('section'); - if (!empty($sectionMedia)) { - $this->addFilesToPackage($objZip, $sectionMedia); - } + $filename = $this->getTempFile($filename); + $objZip = $this->getZipArchive($filename); - // Write parts - foreach ($this->parts as $partName => $fileName) { - if ($fileName != '') { - $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); - } - } + // Add section media files + $sectionMedia = Media::getElements('section'); + if (!empty($sectionMedia)) { + $this->addFilesToPackage($objZip, $sectionMedia); + } - // Close file - if ($objZip->close() === false) { - throw new Exception("Could not close zip file $filename."); + // Write parts + foreach ($this->parts as $partName => $fileName) { + if ($fileName != '') { + $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); } + } - $this->cleanupTempFile(); - } else { - throw new Exception("PhpWord object unassigned."); + // Close file + if ($objZip->close() === false) { + throw new Exception("Could not close zip file $filename."); } + + $this->cleanupTempFile(); } } diff --git a/src/PhpWord/Writer/ODText/Element/AbstractElement.php b/src/PhpWord/Writer/ODText/Element/AbstractElement.php new file mode 100644 index 0000000000..42f86af441 --- /dev/null +++ b/src/PhpWord/Writer/ODText/Element/AbstractElement.php @@ -0,0 +1,27 @@ +xmlWriter = $xmlWriter; - $this->parentWriter = $parentWriter; - $this->element = $element; - $this->withoutP = $withoutP; - } - - /** - * Write element - * - * @return string - */ - public function write() - { - $elmName = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($this->element)); - $elmWriterClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $elmName; - if (class_exists($elmWriterClass) === true) { - $elmWriter = new $elmWriterClass($this->xmlWriter, $this->parentWriter, $this->element, $this->withoutP); - $elmWriter->write(); - } - } -} diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index ffe2d0943b..909a9aede3 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -24,43 +24,42 @@ * * @since 0.10.0 */ -class Image extends Element +class Image extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $mediaIndex = $this->element->getMediaIndex(); - $target = 'Pictures/' . $this->element->getTarget(); - $style = $this->element->getStyle(); + $mediaIndex = $element->getMediaIndex(); + $target = 'Pictures/' . $element->getTarget(); + $style = $element->getStyle(); $width = Drawing::pixelsToCentimeters($style->getWidth()); $height = Drawing::pixelsToCentimeters($style->getHeight()); - $this->xmlWriter->startElement('text:p'); - $this->xmlWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->startElement('text:p'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); - $this->xmlWriter->startElement('draw:frame'); - $this->xmlWriter->writeAttribute('draw:style-name', 'fr' . $mediaIndex); - $this->xmlWriter->writeAttribute('draw:name', $this->element->getElementId()); - $this->xmlWriter->writeAttribute('text:anchor-type', 'as-char'); - $this->xmlWriter->writeAttribute('svg:width', $width . 'cm'); - $this->xmlWriter->writeAttribute('svg:height', $height . 'cm'); - $this->xmlWriter->writeAttribute('draw:z-index', $mediaIndex); + $xmlWriter->startElement('draw:frame'); + $xmlWriter->writeAttribute('draw:style-name', 'fr' . $mediaIndex); + $xmlWriter->writeAttribute('draw:name', $element->getElementId()); + $xmlWriter->writeAttribute('text:anchor-type', 'as-char'); + $xmlWriter->writeAttribute('svg:width', $width . 'cm'); + $xmlWriter->writeAttribute('svg:height', $height . 'cm'); + $xmlWriter->writeAttribute('draw:z-index', $mediaIndex); - $this->xmlWriter->startElement('draw:image'); - $this->xmlWriter->writeAttribute('xlink:href', $target); - $this->xmlWriter->writeAttribute('xlink:type', 'simple'); - $this->xmlWriter->writeAttribute('xlink:show', 'embed'); - $this->xmlWriter->writeAttribute('xlink:actuate', 'onLoad'); - $this->xmlWriter->endElement(); // draw:image + $xmlWriter->startElement('draw:image'); + $xmlWriter->writeAttribute('xlink:href', $target); + $xmlWriter->writeAttribute('xlink:type', 'simple'); + $xmlWriter->writeAttribute('xlink:show', 'embed'); + $xmlWriter->writeAttribute('xlink:actuate', 'onLoad'); + $xmlWriter->endElement(); // draw:image - $this->xmlWriter->endElement(); // draw:frame + $xmlWriter->endElement(); // draw:frame - $this->xmlWriter->endElement(); // text:p + $xmlWriter->endElement(); // text:p } } diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 4ff094d226..1ccac435f5 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -22,29 +22,28 @@ * * @since 0.10.0 */ -class Link extends Element +class Link extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); if (!$this->withoutP) { - $this->xmlWriter->startElement('text:p'); // text:p + $xmlWriter->startElement('text:p'); // text:p } - $this->xmlWriter->startElement('text:a'); - $this->xmlWriter->writeAttribute('xlink:type', 'simple'); - $this->xmlWriter->writeAttribute('xlink:href', $this->element->getTarget()); - $this->xmlWriter->writeRaw($this->element->getText()); - $this->xmlWriter->endElement(); // text:a + $xmlWriter->startElement('text:a'); + $xmlWriter->writeAttribute('xlink:type', 'simple'); + $xmlWriter->writeAttribute('xlink:href', $element->getTarget()); + $xmlWriter->writeRaw($element->getText()); + $xmlWriter->endElement(); // text:a if (!$this->withoutP) { - $this->xmlWriter->endElement(); // text:p + $xmlWriter->endElement(); // text:p } } } diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index dbe5b14c01..d8664fac36 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -25,50 +25,42 @@ * * @since 0.10.0 */ -class Table extends Element +class Table extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { - return; - } - - $rows = $this->element->getRows(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + $rows = $element->getRows(); $rowCount = count($rows); - $colCount = $this->element->countColumns(); + $colCount = $element->countColumns(); + if ($rowCount > 0) { - $this->xmlWriter->startElement('table:table'); - $this->xmlWriter->writeAttribute('table:name', $this->element->getElementId()); - $this->xmlWriter->writeAttribute('table:style', $this->element->getElementId()); + $xmlWriter->startElement('table:table'); + $xmlWriter->writeAttribute('table:name', $element->getElementId()); + $xmlWriter->writeAttribute('table:style', $element->getElementId()); - $this->xmlWriter->startElement('table:table-column'); - $this->xmlWriter->writeAttribute('table:number-columns-repeated', $colCount); - $this->xmlWriter->endElement(); // table:table-column + $xmlWriter->startElement('table:table-column'); + $xmlWriter->writeAttribute('table:number-columns-repeated', $colCount); + $xmlWriter->endElement(); // table:table-column foreach ($rows as $row) { - $this->xmlWriter->startElement('table:table-row'); + $xmlWriter->startElement('table:table-row'); foreach ($row->getCells() as $cell) { - $this->xmlWriter->startElement('table:table-cell'); - $this->xmlWriter->writeAttribute('office:value-type', 'string'); - $elements = $cell->getElements(); - if (count($elements) > 0) { - foreach ($elements as $element) { - $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, $element); - $elementWriter->write(); - } - } else { - $element = new TextBreakElement(); - $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, $element); - $elementWriter->write(); - } - $this->xmlWriter->endElement(); // table:table-cell + $xmlWriter->startElement('table:table-cell'); + $xmlWriter->writeAttribute('office:value-type', 'string'); + + $containerWriter = new Container($xmlWriter, $cell); + $containerWriter->write(); + + $xmlWriter->endElement(); // table:table-cell } - $this->xmlWriter->endElement(); // table:table-row + $xmlWriter->endElement(); // table:table-row } - $this->xmlWriter->endElement(); // table:table + $xmlWriter->endElement(); // table:table } } } diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index ee2fafabda..e960dea855 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -22,19 +22,17 @@ * * @since 0.10.0 */ -class Text extends Element +class Text extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { - return; - } - - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + $fontStyle = $element->getFontStyle(); + $paragraphStyle = $element->getParagraphStyle(); // @todo Commented for TextRun. Should really checkout this value // $fStyleIsObject = ($fontStyle instanceof Font) ? true : false; @@ -45,31 +43,31 @@ public function write() throw new Exception('PhpWord : $fStyleIsObject wouldn\'t be an object'); } else { if (!$this->withoutP) { - $this->xmlWriter->startElement('text:p'); // text:p + $xmlWriter->startElement('text:p'); // text:p } if (empty($fontStyle)) { if (empty($paragraphStyle)) { - $this->xmlWriter->writeAttribute('text:style-name', 'P1'); + $xmlWriter->writeAttribute('text:style-name', 'P1'); } elseif (is_string($paragraphStyle)) { - $this->xmlWriter->writeAttribute('text:style-name', $paragraphStyle); + $xmlWriter->writeAttribute('text:style-name', $paragraphStyle); } - $this->xmlWriter->writeRaw($this->element->getText()); + $xmlWriter->writeRaw($element->getText()); } else { if (empty($paragraphStyle)) { - $this->xmlWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); } elseif (is_string($paragraphStyle)) { - $this->xmlWriter->writeAttribute('text:style-name', $paragraphStyle); + $xmlWriter->writeAttribute('text:style-name', $paragraphStyle); } // text:span - $this->xmlWriter->startElement('text:span'); + $xmlWriter->startElement('text:span'); if (is_string($fontStyle)) { - $this->xmlWriter->writeAttribute('text:style-name', $fontStyle); + $xmlWriter->writeAttribute('text:style-name', $fontStyle); } - $this->xmlWriter->writeRaw($this->element->getText()); - $this->xmlWriter->endElement(); + $xmlWriter->writeRaw($element->getText()); + $xmlWriter->endElement(); } if (!$this->withoutP) { - $this->xmlWriter->endElement(); // text:p + $xmlWriter->endElement(); // text:p } } } diff --git a/src/PhpWord/Writer/ODText/Element/TextBreak.php b/src/PhpWord/Writer/ODText/Element/TextBreak.php index 8e9b83faf5..ef3186f4f2 100644 --- a/src/PhpWord/Writer/ODText/Element/TextBreak.php +++ b/src/PhpWord/Writer/ODText/Element/TextBreak.php @@ -22,15 +22,17 @@ * * @since 0.10.0 */ -class TextBreak extends Element +class TextBreak extends AbstractElement { /** * Write element */ public function write() { - $this->xmlWriter->startElement('text:p'); - $this->xmlWriter->writeAttribute('text:style-name', 'Standard'); - $this->xmlWriter->endElement(); + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement('text:p'); + $xmlWriter->writeAttribute('text:style-name', 'Standard'); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php index b03fc353a0..52240e8fc4 100644 --- a/src/PhpWord/Writer/ODText/Element/TextRun.php +++ b/src/PhpWord/Writer/ODText/Element/TextRun.php @@ -17,38 +17,26 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; -use PhpOffice\PhpWord\Element\Link as LinkElement; -use PhpOffice\PhpWord\Element\Text as TextElement; - /** * TextRun element writer * * @since 0.10.0 */ -class TextRun extends Element +class TextRun extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $xmlWriter->startElement('text:p'); + + $containerWriter = new Container($xmlWriter, $element); + $containerWriter->write(); - $elements = $this->element->getElements(); - $this->xmlWriter->startElement('text:p'); - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof TextElement) { - $elementWriter = new Text($this->xmlWriter, $this->parentWriter, $element, true); - $elementWriter->write(); - } elseif ($element instanceof LinkElement) { - $elementWriter = new Link($this->xmlWriter, $this->parentWriter, $element, true); - $elementWriter->write(); - } - } - } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index c607bb2b76..d5f1353c5d 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -25,7 +25,7 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; +use PhpOffice\PhpWord\Writer\ODText\Element\Container; /** * ODText content part writer: content.xml @@ -73,12 +73,9 @@ public function write() $sectionCount = count($sections); if ($sectionCount > 0) { foreach ($sections as $section) { - $elements = $section->getElements(); // $xmlWriter->startElement('text:section'); - foreach ($elements as $element) { - $elementWriter = new ElementWriter($xmlWriter, $this, $element, false); - $elementWriter->write(); - } + $containerWriter = new Container($xmlWriter, $section); + $containerWriter->write(); // $xmlWriter->endElement(); // text:section } } @@ -104,7 +101,7 @@ private function writeAutomaticStyles(XMLWriter $xmlWriter, PhpWord $phpWord) if (preg_match('#^T[0-9]+$#', $styleName) != 0 || preg_match('#^P[0-9]+$#', $styleName) != 0 ) { - $styleClass = str_replace('Style', 'Writer\\ODText\\Style', get_class($style)); + $styleClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . basename(get_class($style)); if (class_exists($styleClass)) { $styleWriter = new $styleClass($xmlWriter, $style); $styleWriter->setIsAuto(true); diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index cc47dbb4e1..bc4bf4f367 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -91,7 +91,7 @@ public function write() if (preg_match('#^T[0-9]+$#', $styleName) == 0 && preg_match('#^P[0-9]+$#', $styleName) == 0 ) { - $styleClass = str_replace('Style', 'Writer\\ODText\\Style', get_class($style)); + $styleClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . basename(get_class($style)); if (class_exists($styleClass)) { $styleWriter = new $styleClass($xmlWriter, $style); $styleWriter->write(); diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 74bb5ec9eb..1a6d4fc0e0 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -34,37 +34,40 @@ class Font extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Font)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $this->xmlWriter->startElement('style:style'); - $this->xmlWriter->writeAttribute('style:name', $this->style->getStyleName()); - $this->xmlWriter->writeAttribute('style:family', 'text'); - $this->xmlWriter->startElement('style:text-properties'); - if ($this->style->getName()) { - $this->xmlWriter->writeAttribute('style:font-name', $this->style->getName()); - $this->xmlWriter->writeAttribute('style:font-name-complex', $this->style->getName()); - } - if ($this->style->getSize()) { - $this->xmlWriter->writeAttribute('fo:font-size', ($this->style->getSize()) . 'pt'); - $this->xmlWriter->writeAttribute('style:font-size-asian', ($this->style->getSize()) . 'pt'); - $this->xmlWriter->writeAttribute('style:font-size-complex', ($this->style->getSize()) . 'pt'); - } - if ($this->style->getColor()) { - $this->xmlWriter->writeAttribute('fo:color', '#' . $this->style->getColor()); - } - if ($this->style->isItalic()) { - $this->xmlWriter->writeAttribute('fo:font-style', 'italic'); - $this->xmlWriter->writeAttribute('style:font-style-asian', 'italic'); - $this->xmlWriter->writeAttribute('style:font-style-complex', 'italic'); - } - if ($this->style->isBold()) { - $this->xmlWriter->writeAttribute('fo:font-weight', 'bold'); - $this->xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); - } - $this->xmlWriter->endElement(); // style:text-properties - $this->xmlWriter->endElement(); // style:style + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $style->getStyleName()); + $xmlWriter->writeAttribute('style:family', 'text'); + $xmlWriter->startElement('style:text-properties'); + + // Name + $font = $style->getName(); + $xmlWriter->writeAttributeIf($font, 'style:font-name', $font); + $xmlWriter->writeAttributeIf($font, 'style:font-name-complex', $font); + $size = $style->getSize(); + + // Size + $xmlWriter->writeAttributeIf($size, 'fo:font-size', $size . 'pt'); + $xmlWriter->writeAttributeIf($size, 'style:font-size-asian', $size . 'pt'); + $xmlWriter->writeAttributeIf($size, 'style:font-size-complex', $size . 'pt'); + + // Color + $color = $style->getColor(); + $xmlWriter->writeAttributeIf($color, 'fo:color', '#' . $color); + + // Bold & italic + $xmlWriter->writeAttributeIf($style->isBold(), 'fo:font-weight', 'bold'); + $xmlWriter->writeAttributeIf($style->isBold(), 'style:font-weight-asian', 'bold'); + $xmlWriter->writeAttributeIf($style->isItalic(), 'fo:font-style', 'italic'); + $xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-asian', 'italic'); + $xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-complex', 'italic'); + + $xmlWriter->endElement(); // style:text-properties + $xmlWriter->endElement(); // style:style } /** diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index d5156365c9..143627cd64 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -34,32 +34,33 @@ class Paragraph extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Paragraph)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $marginTop = is_null($this->style->getSpaceBefore()) ? '0' : round(17.6 / $this->style->getSpaceBefore(), 2); - $marginBottom = is_null($this->style->getSpaceAfter()) ? '0' : round(17.6 / $this->style->getSpaceAfter(), 2); + $marginTop = is_null($style->getSpaceBefore()) ? '0' : round(17.6 / $style->getSpaceBefore(), 2); + $marginBottom = is_null($style->getSpaceAfter()) ? '0' : round(17.6 / $style->getSpaceAfter(), 2); - $this->xmlWriter->startElement('style:style'); - $this->xmlWriter->writeAttribute('style:name', $this->style->getStyleName()); - $this->xmlWriter->writeAttribute('style:family', 'paragraph'); + $xmlWriter->startElement('style:style'); + $xmlWriter->writeAttribute('style:name', $style->getStyleName()); + $xmlWriter->writeAttribute('style:family', 'paragraph'); if ($this->isAuto) { - $this->xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); - $this->xmlWriter->writeAttribute('style:master-page-name', 'Standard'); + $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); + $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); } - $this->xmlWriter->startElement('style:paragraph-properties'); + $xmlWriter->startElement('style:paragraph-properties'); if ($this->isAuto) { - $this->xmlWriter->writeAttribute('style:page-number', 'auto'); + $xmlWriter->writeAttribute('style:page-number', 'auto'); } else { - $this->xmlWriter->writeAttribute('fo:margin-top', $marginTop . 'cm'); - $this->xmlWriter->writeAttribute('fo:margin-bottom', $marginBottom . 'cm'); - $this->xmlWriter->writeAttribute('fo:text-align', $this->style->getAlign()); + $xmlWriter->writeAttribute('fo:margin-top', $marginTop . 'cm'); + $xmlWriter->writeAttribute('fo:margin-bottom', $marginBottom . 'cm'); + $xmlWriter->writeAttribute('fo:text-align', $style->getAlign()); } - $this->xmlWriter->endElement(); //style:paragraph-properties + $xmlWriter->endElement(); //style:paragraph-properties - $this->xmlWriter->endElement(); //style:style + $xmlWriter->endElement(); //style:style } /** diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index be253ec303..45e8a412fa 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -52,7 +52,7 @@ public function __construct(PhpWord $phpWord) set_include_path(get_include_path() . PATH_SEPARATOR . $pdfLibraryPath); } - $rendererName = 'PhpOffice\\PhpWord\\Writer\\PDF\\' . $pdfLibraryName; + $rendererName = get_class($this) . '\\' . $pdfLibraryName; $this->renderer = new $rendererName($phpWord); } diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 4a63fdcc84..829a6d81ca 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -66,25 +66,24 @@ public function __construct(PhpWord $phpWord = null) /** * Save PhpWord to file * - * @param string $pFilename + * @param string $filename * @throws \PhpOffice\PhpWord\Exception\Exception */ - public function save($pFilename = null) + public function save($filename = null) { - if (!is_null($this->phpWord)) { - $pFilename = $this->getTempFile($pFilename); - - $hFile = fopen($pFilename, 'w'); - if ($hFile !== false) { - fwrite($hFile, $this->writeDocument()); - fclose($hFile); - } else { - throw new Exception("Can't open file"); - } - $this->cleanupTempFile(); + if (is_null($this->phpWord)) { + throw new Exception('PhpWord object unassigned.'); + } + + $filename = $this->getTempFile($filename); + $hFile = fopen($filename, 'w'); + if ($hFile !== false) { + fwrite($hFile, $this->writeDocument()); + fclose($hFile); } else { - throw new Exception("PhpWord object unassigned."); + throw new Exception("Can't open file"); } + $this->cleanupTempFile(); } /** diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index fc192ffe76..f4d09e36de 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -67,14 +67,13 @@ public function __construct(RTF $parentWriter, AbstractElement $element, $withou */ public function write() { - $rtfText = ''; - $elmName = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($this->element)); - $elmWriterClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $elmName; - if (class_exists($elmWriterClass) === true) { - $elmWriter = new $elmWriterClass($this->parentWriter, $this->element, $this->withoutP); - $rtfText = $elmWriter->write(); + $content = ''; + $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($this->element)); + if (class_exists($writerClass)) { + $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); + $content = $writer->write(); } - return $rtfText; + return $content; } } diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 07eef989d6..44317bd2ae 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -72,7 +72,7 @@ public function __construct(PhpWord $phpWord = null) 'Endnotes' => '', ); foreach (array_keys($this->parts) as $partName) { - $partClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\' . $partName; + $partClass = get_class($this) . '\\Part\\' . $partName; if (class_exists($partClass)) { $partObject = new $partClass(); $partObject->setParentWriter($this); @@ -91,57 +91,57 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - if (!is_null($this->phpWord)) { - $filename = $this->getTempFile($filename); - $objZip = $this->getZipArchive($filename); - - // Content types - $this->contentTypes['default'] = array( - 'rels' => 'application/vnd.openxmlformats-package.relationships+xml', - 'xml' => 'application/xml', - ); + if (is_null($this->phpWord)) { + throw new Exception('PhpWord object unassigned.'); + } - // Add section media files - $sectionMedia = Media::getElements('section'); - if (!empty($sectionMedia)) { - $this->addFilesToPackage($objZip, $sectionMedia); - $this->registerContentTypes($sectionMedia); - foreach ($sectionMedia as $element) { - $this->relationships[] = $element; - } - } + $filename = $this->getTempFile($filename); + $objZip = $this->getZipArchive($filename); - // Add header/footer media files & relations - $this->addHeaderFooterMedia($objZip, 'header'); - $this->addHeaderFooterMedia($objZip, 'footer'); + // Content types + $this->contentTypes['default'] = array( + 'rels' => 'application/vnd.openxmlformats-package.relationships+xml', + 'xml' => 'application/xml', + ); - // Add header/footer contents - $rId = Media::countElements('section') + 6; // @see Rels::writeDocRels for 6 first elements - $sections = $this->phpWord->getSections(); - foreach ($sections as $section) { - $this->addHeaderFooterContent($section, $objZip, 'header', $rId); - $this->addHeaderFooterContent($section, $objZip, 'footer', $rId); + // Add section media files + $sectionMedia = Media::getElements('section'); + if (!empty($sectionMedia)) { + $this->addFilesToPackage($objZip, $sectionMedia); + $this->registerContentTypes($sectionMedia); + foreach ($sectionMedia as $element) { + $this->relationships[] = $element; } + } - $this->addNotes($objZip, $rId, 'footnote'); - $this->addNotes($objZip, $rId, 'endnote'); + // Add header/footer media files & relations + $this->addHeaderFooterMedia($objZip, 'header'); + $this->addHeaderFooterMedia($objZip, 'footer'); - // Write parts - foreach ($this->parts as $partName => $fileName) { - if ($fileName != '') { - $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); - } - } + // Add header/footer contents + $rId = Media::countElements('section') + 6; // @see Rels::writeDocRels for 6 first elements + $sections = $this->phpWord->getSections(); + foreach ($sections as $section) { + $this->addHeaderFooterContent($section, $objZip, 'header', $rId); + $this->addHeaderFooterContent($section, $objZip, 'footer', $rId); + } - // Close file - if ($objZip->close() === false) { - throw new Exception("Could not close zip file $filename."); + $this->addNotes($objZip, $rId, 'footnote'); + $this->addNotes($objZip, $rId, 'endnote'); + + // Write parts + foreach ($this->parts as $partName => $fileName) { + if ($fileName != '') { + $objZip->addFromString($fileName, $this->getWriterPart($partName)->write()); } + } - $this->cleanupTempFile(); - } else { - throw new Exception("PhpWord object unassigned."); + // Close file + if ($objZip->close() === false) { + throw new Exception("Could not close zip file $filename."); } + + $this->cleanupTempFile(); } /** diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php similarity index 57% rename from src/PhpWord/Writer/Word2007/Element/Element.php rename to src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 89d92ac542..67cffdc62e 100644 --- a/src/PhpWord/Writer/Word2007/Element/Element.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -17,37 +17,30 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Element\AbstractElement; +use PhpOffice\PhpWord\Element\AbstractElement as Element; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart; /** - * Generic element writer + * Abstract element writer * * @since 0.10.0 */ -class Element +abstract class AbstractElement { /** * XML writer * * @var \PhpOffice\PhpWord\Shared\XMLWriter */ - protected $xmlWriter; - - /** - * Parent writer - * - * @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart - */ - protected $parentWriter; + private $xmlWriter; /** * Element * * @var \PhpOffice\PhpWord\Element\AbstractElement */ - protected $element; + private $element; /** * Without paragraph @@ -56,32 +49,49 @@ class Element */ protected $withoutP = false; + /** + * Write element + */ + abstract public function write(); + /** * Create new instance * - * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param bool $withoutP */ - public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, $element, $withoutP = false) + public function __construct(XMLWriter $xmlWriter, Element $element, $withoutP = false) { $this->xmlWriter = $xmlWriter; - $this->parentWriter = $parentWriter; $this->element = $element; $this->withoutP = $withoutP; } /** - * Write element + * Get XML Writer + * + * @return \PhpOffice\PhpWord\Shared\XMLWriter + */ + protected function getXmlWriter() + { + return $this->xmlWriter; + } + + /** + * Get Element * - * @return string + * @return \PhpOffice\PhpWord\Element\AbstractElement */ - public function write() + protected function getElement() { - $elmName = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($this->element)); - $elmWriterClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $elmName; - if (class_exists($elmWriterClass) === true) { - $elmWriter = new $elmWriterClass($this->xmlWriter, $this->parentWriter, $this->element, $this->withoutP); - $elmWriter->write(); + if (!is_null($this->element)) { + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . basename(get_class($this->element)); + if ($this->element instanceof $elementClass) { + return $this->element; + } else { + throw new Exception('No valid element assigned.'); + } + } else { + throw new Exception('No element assigned.'); } } } diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index ef8c166d4f..96e210b56d 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -18,91 +18,77 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; /** * CheckBox element writer * * @since 0.10.0 */ -class CheckBox extends Element +class CheckBox extends Text { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\CheckBox) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $name = htmlspecialchars($this->element->getName()); + $name = htmlspecialchars($element->getName()); $name = String::controlCharacterPHP2OOXML($name); - $text = htmlspecialchars($this->element->getText()); + $text = htmlspecialchars($element->getText()); $text = String::controlCharacterPHP2OOXML($text); - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); - if (!$this->withoutP) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); + $this->writeOpeningWP(); - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); - } + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->startElement('w:ffData'); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $name); + $xmlWriter->endElement(); //w:name + $xmlWriter->writeAttribute('w:enabled', ''); + $xmlWriter->startElement('w:calcOnExit'); + $xmlWriter->writeAttribute('w:val', '0'); + $xmlWriter->endElement(); //w:calcOnExit + $xmlWriter->startElement('w:checkBox'); + $xmlWriter->writeAttribute('w:sizeAuto', ''); + $xmlWriter->startElement('w:default'); + $xmlWriter->writeAttribute('w:val', 0); + $xmlWriter->endElement(); //w:default + $xmlWriter->endElement(); //w:checkBox + $xmlWriter->endElement(); // w:ffData + $xmlWriter->endElement(); // w:fldChar + $xmlWriter->endElement(); // w:r - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->startElement('w:ffData'); - $this->xmlWriter->startElement('w:name'); - $this->xmlWriter->writeAttribute('w:val', $name); - $this->xmlWriter->endElement(); //w:name - $this->xmlWriter->writeAttribute('w:enabled', ''); - $this->xmlWriter->startElement('w:calcOnExit'); - $this->xmlWriter->writeAttribute('w:val', '0'); - $this->xmlWriter->endElement(); //w:calcOnExit - $this->xmlWriter->startElement('w:checkBox'); - $this->xmlWriter->writeAttribute('w:sizeAuto', ''); - $this->xmlWriter->startElement('w:default'); - $this->xmlWriter->writeAttribute('w:val', 0); - $this->xmlWriter->endElement(); //w:default - $this->xmlWriter->endElement(); //w:checkBox - $this->xmlWriter->endElement(); // w:ffData - $this->xmlWriter->endElement(); // w:fldChar - $this->xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw(' FORMCHECKBOX '); + $xmlWriter->endElement();// w:instrText + $xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'seperate'); + $xmlWriter->endElement();// w:fldChar + $xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement();// w:fldChar + $xmlWriter->endElement(); // w:r - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw(' FORMCHECKBOX '); - $this->xmlWriter->endElement();// w:instrText - $this->xmlWriter->endElement(); // w:r - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'seperate'); - $this->xmlWriter->endElement();// w:fldChar - $this->xmlWriter->endElement(); // w:r - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement();// w:fldChar - $this->xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:r'); - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); + $this->writeFontStyle(); - $this->xmlWriter->startElement('w:r'); - $styleWriter->write(); - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw($text); - $this->xmlWriter->endElement(); // w:t - $this->xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); // w:t + $xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p - } + $this->writeEndingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php new file mode 100644 index 0000000000..7baf7e3b36 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -0,0 +1,58 @@ +getXmlWriter(); + $element = $this->getElement(); + + // Loop through subelements + $containerClass = basename(get_class($element)); + $subelements = $element->getElements(); + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + if (count($subelements) > 0) { + foreach ($subelements as $subelement) { + $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($subelement)); + if (class_exists($writerClass)) { + $writer = new $writerClass($xmlWriter, $subelement, $withoutP); + $writer->write(); + } + } + } else { + // Special case for Cell: They have to contain a TextBreak at least + if ($containerClass == 'Cell') { + $writerClass = dirname(get_class($this)) . '\\TextBreak'; + $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); + $writer->write(); + } + } + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index f1f276aae4..646f70ed3f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Footnote extends Element +class Footnote extends Text { /** * Reference type footnoteReference|endnoteReference @@ -36,25 +36,22 @@ class Footnote extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - if (!$this->withoutP) { - $this->xmlWriter->startElement('w:p'); - } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:rPr'); - $this->xmlWriter->startElement('w:rStyle'); - $this->xmlWriter->writeAttribute('w:val', ucfirst($this->referenceType)); - $this->xmlWriter->endElement(); // w:rStyle - $this->xmlWriter->endElement(); // w:rPr - $this->xmlWriter->startElement("w:{$this->referenceType}"); - $this->xmlWriter->writeAttribute('w:id', $this->element->getRelationId()); - $this->xmlWriter->endElement(); // w:$referenceType - $this->xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p - } + $this->writeOpeningWP(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', ucfirst($this->referenceType)); + $xmlWriter->endElement(); // w:rStyle + $xmlWriter->endElement(); // w:rPr + $xmlWriter->startElement("w:{$this->referenceType}"); + $xmlWriter->writeAttribute('w:id', $element->getRelationId()); + $xmlWriter->endElement(); // w:$referenceType + $xmlWriter->endElement(); // w:r + + $this->writeEndingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 6b948f1e69..c7bd8d7ded 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -24,14 +24,16 @@ * * @since 0.10.0 */ -class Image extends Element +class Image extends AbstractElement { /** * Write element */ public function write() { - if ($this->element->isWatermark()) { + $element = $this->getElement(); + + if ($element->isWatermark()) { $this->writeWatermark(); } else { $this->writeImage(); @@ -43,41 +45,40 @@ public function write() */ private function writeImage() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); - $style = $this->element->getStyle(); - $styleWriter = new ImageStyleWriter($this->xmlWriter, $style); + $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); + $style = $element->getStyle(); + $styleWriter = new ImageStyleWriter($xmlWriter, $style); if (!$this->withoutP) { - $this->xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if (!is_null($style->getAlign())) { - $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:jc'); - $this->xmlWriter->writeAttribute('w:val', $style->getAlign()); - $this->xmlWriter->endElement(); // w:jc - $this->xmlWriter->endElement(); // w:pPr + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $style->getAlign()); + $xmlWriter->endElement(); // w:jc + $xmlWriter->endElement(); // w:pPr } } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:pict'); - $this->xmlWriter->startElement('v:shape'); - $this->xmlWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:pict'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); $styleWriter->write(); - $this->xmlWriter->startElement('v:imagedata'); - $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $this->xmlWriter->writeAttribute('o:title', ''); - $this->xmlWriter->endElement(); // v:imagedata + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); // v:imagedata $styleWriter->writeW10Wrap(); - $this->xmlWriter->endElement(); // v:shape - $this->xmlWriter->endElement(); // w:pict - $this->xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // v:shape + $xmlWriter->endElement(); // w:pict + $xmlWriter->endElement(); // w:r if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } /** @@ -85,24 +86,27 @@ private function writeImage() */ private function writeWatermark() { - $rId = $this->element->getRelationId(); - $style = $this->element->getStyle(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $rId = $element->getRelationId(); + $style = $element->getStyle(); $style->setPositioning('absolute'); - $styleWriter = new ImageStyleWriter($this->xmlWriter, $style); + $styleWriter = new ImageStyleWriter($xmlWriter, $style); - $this->xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:pict'); - $this->xmlWriter->startElement('v:shape'); - $this->xmlWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:pict'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); $styleWriter->write(); - $this->xmlWriter->startElement('v:imagedata'); - $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $this->xmlWriter->writeAttribute('o:title', ''); - $this->xmlWriter->endElement(); // v:imagedata - $this->xmlWriter->endElement(); // v:shape - $this->xmlWriter->endElement(); // w:pict - $this->xmlWriter->endElement(); // w:r - $this->xmlWriter->endElement(); // w:p + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); // v:imagedata + $xmlWriter->endElement(); // v:shape + $xmlWriter->endElement(); // w:pict + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 2e53b1a809..517e276db2 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -17,53 +17,39 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; - /** * Link element writer * * @since 0.10.0 */ -class Link extends Element +class Link extends Text { /** * Write link element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); - $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); + $this->writeOpeningWP(); - if (!$this->withoutP) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + $xmlWriter->writeAttribute('w:history', '1'); + $xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); - } + $this->writeFontStyle(); - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($element->getText()); + $xmlWriter->endElement(); // w:t + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:hyperlink - $this->xmlWriter->startElement('w:hyperlink'); - $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $this->xmlWriter->writeAttribute('w:history', '1'); - $this->xmlWriter->startElement('w:r'); - $styleWriter->write(); - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw($this->element->getText()); - $this->xmlWriter->endElement(); // w:t - $this->xmlWriter->endElement(); // w:r - $this->xmlWriter->endElement(); // w:hyperlink - if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p - } + $this->writeEndingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index e43948622c..e625114c39 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Writer\Word2007\Element\Element as ElementWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; /** @@ -25,42 +24,41 @@ * * @since 0.10.0 */ -class ListItem extends Element +class ListItem extends AbstractElement { /** * Write list item element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $textObject = $this->element->getTextObject(); - $depth = $this->element->getDepth(); - $numId = $this->element->getStyle()->getNumId(); - $paragraphStyle = $textObject->getParagraphStyle(); - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); + $textObject = $element->getTextObject(); + + $styleWriter = new ParagraphStyleWriter($xmlWriter, $textObject->getParagraphStyle()); $styleWriter->setWithoutPPR(true); $styleWriter->setIsInline(true); - $this->xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); $styleWriter->write(); - $this->xmlWriter->startElement('w:numPr'); - $this->xmlWriter->startElement('w:ilvl'); - $this->xmlWriter->writeAttribute('w:val', $depth); - $this->xmlWriter->endElement(); // w:ilvl - $this->xmlWriter->startElement('w:numId'); - $this->xmlWriter->writeAttribute('w:val', $numId); - $this->xmlWriter->endElement(); // w:numId - $this->xmlWriter->endElement(); // w:numPr - $this->xmlWriter->endElement(); // w:pPr - $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, $textObject, true); + $xmlWriter->startElement('w:numPr'); + $xmlWriter->startElement('w:ilvl'); + $xmlWriter->writeAttribute('w:val', $element->getDepth()); + $xmlWriter->endElement(); // w:ilvl + $xmlWriter->startElement('w:numId'); + $xmlWriter->writeAttribute('w:val', $element->getStyle()->getNumId()); + $xmlWriter->endElement(); // w:numId + $xmlWriter->endElement(); // w:numPr + + $xmlWriter->endElement(); // w:pPr + + $elementWriter = new Text($xmlWriter, $textObject, true); $elementWriter->write(); - $this->xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index db90d78c7b..5f56a7047e 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -22,60 +22,59 @@ * * @since 0.10.0 */ -class Object extends Element +class Object extends AbstractElement { /** * Write object element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Object) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $rIdObject = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0); - $rIdImage = $this->element->getImageRelationId() + ($this->element->isInSection() ? 6 : 0); + $rIdObject = $element->getRelationId() + ($element->isInSection() ? 6 : 0); + $rIdImage = $element->getImageRelationId() + ($element->isInSection() ? 6 : 0); $shapeId = md5($rIdObject . '_' . $rIdImage); - $objectId = $this->element->getRelationId() + 1325353440; - $style = $this->element->getStyle(); + $objectId = $element->getRelationId() + 1325353440; + $style = $element->getStyle(); $align = $style->getAlign(); if (!$this->withoutP) { - $this->xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); } if (!is_null($align)) { - $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:jc'); - $this->xmlWriter->writeAttribute('w:val', $align); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $align); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:object'); - $this->xmlWriter->writeAttribute('w:dxaOrig', '249'); - $this->xmlWriter->writeAttribute('w:dyaOrig', '160'); - $this->xmlWriter->startElement('v:shape'); - $this->xmlWriter->writeAttribute('id', $shapeId); - $this->xmlWriter->writeAttribute('type', '#_x0000_t75'); - $this->xmlWriter->writeAttribute('style', 'width:104px;height:67px'); - $this->xmlWriter->writeAttribute('o:ole', ''); - $this->xmlWriter->startElement('v:imagedata'); - $this->xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); - $this->xmlWriter->writeAttribute('o:title', ''); - $this->xmlWriter->endElement(); // v:imagedata - $this->xmlWriter->endElement(); // v:shape - $this->xmlWriter->startElement('o:OLEObject'); - $this->xmlWriter->writeAttribute('Type', 'Embed'); - $this->xmlWriter->writeAttribute('ProgID', 'Package'); - $this->xmlWriter->writeAttribute('ShapeID', $shapeId); - $this->xmlWriter->writeAttribute('DrawAspect', 'Icon'); - $this->xmlWriter->writeAttribute('ObjectID', '_' . $objectId); - $this->xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); - $this->xmlWriter->endElement(); // o:OLEObject - $this->xmlWriter->endElement(); // w:object - $this->xmlWriter->endElement(); // w:r + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:object'); + $xmlWriter->writeAttribute('w:dxaOrig', '249'); + $xmlWriter->writeAttribute('w:dyaOrig', '160'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('id', $shapeId); + $xmlWriter->writeAttribute('type', '#_x0000_t75'); + $xmlWriter->writeAttribute('style', 'width:104px;height:67px'); + $xmlWriter->writeAttribute('o:ole', ''); + $xmlWriter->startElement('v:imagedata'); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); + $xmlWriter->writeAttribute('o:title', ''); + $xmlWriter->endElement(); // v:imagedata + $xmlWriter->endElement(); // v:shape + $xmlWriter->startElement('o:OLEObject'); + $xmlWriter->writeAttribute('Type', 'Embed'); + $xmlWriter->writeAttribute('ProgID', 'Package'); + $xmlWriter->writeAttribute('ShapeID', $shapeId); + $xmlWriter->writeAttribute('DrawAspect', 'Icon'); + $xmlWriter->writeAttribute('ObjectID', '_' . $objectId); + $xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); + $xmlWriter->endElement(); // o:OLEObject + $xmlWriter->endElement(); // w:object + $xmlWriter->endElement(); // w:r if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } } diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index 47d6d3355a..fb285ac62c 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -22,19 +22,21 @@ * * @since 0.10.0 */ -class PageBreak extends Element +class PageBreak extends AbstractElement { /** * Write element */ public function write() { - $this->xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:br'); - $this->xmlWriter->writeAttribute('w:type', 'page'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:br'); + $xmlWriter->writeAttribute('w:type', 'page'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index 63c0389934..b3b00d16da 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -18,85 +18,76 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; /** * PreserveText element writer * * @since 0.10.0 */ -class PreserveText extends Element +class PreserveText extends Text { /** * Write preserve text element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\PreserveText) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); - $texts = $this->element->getText(); + $texts = $element->getText(); if (!is_array($texts)) { $texts = array($texts); } - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); - - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); + $this->writeOpeningWP(); foreach ($texts as $text) { if (substr($text, 0, 1) == '{') { $text = substr($text, 1, -1); - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $styleWriter->write(); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw($text); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + + $this->writeFontStyle(); + + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } else { $text = htmlspecialchars($text); $text = String::controlCharacterPHP2OOXML($text); - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); - - $this->xmlWriter->startElement('w:r'); - $styleWriter->write(); - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw($text); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + + $this->writeFontStyle(); + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } - $this->xmlWriter->endElement(); // p + $this->writeEndingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 6f1e2cdf9c..28d7bc3134 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -27,18 +27,17 @@ * * @since 0.10.0 */ -class TOC extends Element +class TOC extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\TOC) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $titles = $this->element->getTitles(); + $titles = $element->getTitles(); $writeFieldMark = true; foreach ($titles as $title) { @@ -48,13 +47,13 @@ public function write() } } - $this->xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } /** @@ -65,13 +64,16 @@ public function write() */ private function writeTitle($title, $writeFieldMark) { - $tocStyle = $this->element->getStyleTOC(); - $fontStyle = $this->element->getStyleFont(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $tocStyle = $element->getStyleTOC(); + $fontStyle = $element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; $anchor = '_Toc' . ($title->getBookmarkId() + 252634154); $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); - $this->xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); // Write style and field mark $this->writeStyle($indent); @@ -80,47 +82,47 @@ private function writeTitle($title, $writeFieldMark) } // Hyperlink - $this->xmlWriter->startElement('w:hyperlink'); - $this->xmlWriter->writeAttribute('w:anchor', $anchor); - $this->xmlWriter->writeAttribute('w:history', '1'); + $xmlWriter->startElement('w:hyperlink'); + $xmlWriter->writeAttribute('w:anchor', $anchor); + $xmlWriter->writeAttribute('w:history', '1'); // Title text - $this->xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:r'); if ($isObject) { - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); + $styleWriter = new FontStyleWriter($xmlWriter, $fontStyle); $styleWriter->write(); } - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeRaw($title->getText()); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); // w:r - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->writeElement('w:tab', null); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->endElement(); // w:hyperlink - - $this->xmlWriter->endElement(); // w:p + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($title->getText()); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // w:r + + $xmlWriter->startElement('w:r'); + $xmlWriter->writeElement('w:tab', null); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:hyperlink + + $xmlWriter->endElement(); // w:p } /** @@ -130,41 +132,44 @@ private function writeTitle($title, $writeFieldMark) */ private function writeStyle($indent) { - $tocStyle = $this->element->getStyleTOC(); - $fontStyle = $this->element->getStyleFont(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $tocStyle = $element->getStyleTOC(); + $fontStyle = $element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; - $this->xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); // Paragraph if ($isObject && !is_null($fontStyle->getParagraphStyle())) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $fontStyle->getParagraphStyle()); + $styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraphStyle()); $styleWriter->write(); } // Font if (!empty($fontStyle) && !$isObject) { - $this->xmlWriter->startElement('w:rPr'); - $this->xmlWriter->startElement('w:rStyle'); - $this->xmlWriter->writeAttribute('w:val', $fontStyle); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); // w:rPr + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $fontStyle); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // w:rPr } // Tab - $this->xmlWriter->startElement('w:tabs'); - $styleWriter = new TabStyleWriter($this->xmlWriter, $tocStyle); + $xmlWriter->startElement('w:tabs'); + $styleWriter = new TabStyleWriter($xmlWriter, $tocStyle); $styleWriter->write(); - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); // Indent if ($indent > 0) { - $this->xmlWriter->startElement('w:ind'); - $this->xmlWriter->writeAttribute('w:left', $indent); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:left', $indent); + $xmlWriter->endElement(); } - $this->xmlWriter->endElement(); // w:pPr + $xmlWriter->endElement(); // w:pPr } /** @@ -172,26 +177,29 @@ private function writeStyle($indent) */ private function writeFieldMark() { - $minDepth = $this->element->getMinDepth(); - $maxDepth = $this->element->getMaxDepth(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:instrText'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw("TOC \o {$minDepth}-{$maxDepth} \h \z \u"); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $minDepth = $element->getMinDepth(); + $maxDepth = $element->getMaxDepth(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw("TOC \o {$minDepth}-{$maxDepth} \h \z \u"); + $xmlWriter->endElement(); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 3a29f4107f..5c82114a1f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -29,22 +29,21 @@ * * @since 0.10.0 */ -class Table extends Element +class Table extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $rows = $this->element->getRows(); + $rows = $element->getRows(); $rowCount = count($rows); if ($rowCount > 0) { - $this->xmlWriter->startElement('w:tbl'); + $xmlWriter->startElement('w:tbl'); // Table grid $cellWidths = array(); @@ -59,37 +58,37 @@ public function write() $cellWidths[] = $cell->getWidth(); } } - $this->xmlWriter->startElement('w:tblGrid'); + $xmlWriter->startElement('w:tblGrid'); foreach ($cellWidths as $width) { - $this->xmlWriter->startElement('w:gridCol'); + $xmlWriter->startElement('w:gridCol'); if (!is_null($width)) { - $this->xmlWriter->writeAttribute('w:w', $width); - $this->xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', 'dxa'); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } - $this->xmlWriter->endElement(); // w:tblGrid + $xmlWriter->endElement(); // w:tblGrid // Table style - $tblStyle = $this->element->getStyle(); - $tblWidth = $this->element->getWidth(); + $tblStyle = $element->getStyle(); + $tblWidth = $element->getWidth(); if ($tblStyle instanceof TableStyle) { - $styleWriter = new TableStyleWriter($this->xmlWriter, $tblStyle); + $styleWriter = new TableStyleWriter($xmlWriter, $tblStyle); $styleWriter->setIsFullStyle(false); $styleWriter->write(); } else { if (!empty($tblStyle)) { - $this->xmlWriter->startElement('w:tblPr'); - $this->xmlWriter->startElement('w:tblStyle'); - $this->xmlWriter->writeAttribute('w:val', $tblStyle); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblStyle'); + $xmlWriter->writeAttribute('w:val', $tblStyle); + $xmlWriter->endElement(); if (!is_null($tblWidth)) { - $this->xmlWriter->startElement('w:tblW'); - $this->xmlWriter->writeAttribute('w:w', $tblWidth); - $this->xmlWriter->writeAttribute('w:type', 'pct'); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:tblW'); + $xmlWriter->writeAttribute('w:w', $tblWidth); + $xmlWriter->writeAttribute('w:type', 'pct'); + $xmlWriter->endElement(); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } @@ -97,7 +96,7 @@ public function write() for ($i = 0; $i < $rowCount; $i++) { $this->writeRow($rows[$i]); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } @@ -106,34 +105,36 @@ public function write() */ private function writeRow(RowElement $row) { + $xmlWriter = $this->getXmlWriter(); + $height = $row->getHeight(); $rowStyle = $row->getStyle(); - $this->xmlWriter->startElement('w:tr'); + $xmlWriter->startElement('w:tr'); if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:trPr'); + $xmlWriter->startElement('w:trPr'); if (!is_null($height)) { - $this->xmlWriter->startElement('w:trHeight'); - $this->xmlWriter->writeAttribute('w:val', $height); - $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:trHeight'); + $xmlWriter->writeAttribute('w:val', $height); + $xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); + $xmlWriter->endElement(); } if ($rowStyle->isTblHeader()) { - $this->xmlWriter->startElement('w:tblHeader'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:tblHeader'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } if ($rowStyle->isCantSplit()) { - $this->xmlWriter->startElement('w:cantSplit'); - $this->xmlWriter->writeAttribute('w:val', '1'); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:cantSplit'); + $xmlWriter->writeAttribute('w:val', '1'); + $xmlWriter->endElement(); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } foreach ($row->getCells() as $cell) { $this->writeCell($cell); } - $this->xmlWriter->endElement(); // w:tr + $xmlWriter->endElement(); // w:tr } /** @@ -141,20 +142,25 @@ private function writeRow(RowElement $row) */ private function writeCell(CellElement $cell) { + $xmlWriter = $this->getXmlWriter(); + $cellStyle = $cell->getStyle(); - $this->xmlWriter->startElement('w:tc'); - $this->xmlWriter->startElement('w:tcPr'); - $this->xmlWriter->startElement('w:tcW'); - $this->xmlWriter->writeAttribute('w:w', $cell->getWidth()); - $this->xmlWriter->writeAttribute('w:type', 'dxa'); - $this->xmlWriter->endElement(); // w:tcW + $xmlWriter->startElement('w:tc'); + $xmlWriter->startElement('w:tcPr'); + $xmlWriter->startElement('w:tcW'); + $xmlWriter->writeAttribute('w:w', $cell->getWidth()); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); // w:tcW if ($cellStyle instanceof CellStyle) { - $styleWriter = new CellStyleWriter($this->xmlWriter, $cellStyle); + $styleWriter = new CellStyleWriter($xmlWriter, $cellStyle); $styleWriter->write(); } - $this->xmlWriter->endElement(); // w:tcPr - $this->parentWriter->writeContainerElements($this->xmlWriter, $cell); - $this->xmlWriter->endElement(); // w:tc + $xmlWriter->endElement(); // w:tcPr + + $containerWriter = new Container($xmlWriter, $cell); + $containerWriter->write(); + + $xmlWriter->endElement(); // w:tc } } diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index c271174f4a..d6402dbf9a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -26,41 +26,88 @@ * * @since 0.10.0 */ -class Text extends Element +class Text extends AbstractElement { /** * Write text element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); - $text = htmlspecialchars($this->element->getText()); + $text = htmlspecialchars($element->getText()); $text = String::controlCharacterPHP2OOXML($text); + $this->writeOpeningWP(); + + $xmlWriter->startElement('w:r'); + + $this->writeFontStyle(); + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); // w:r + + $this->writeEndingWP(); + } + + /** + * Write opening + */ + protected function writeOpeningWP() + { + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + if (!$this->withoutP) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); + $xmlWriter->startElement('w:p'); - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); + if (method_exists($element, 'getParagraphStyle')) { + $this->writeParagraphStyle(); + } } - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); + } + + /** + * Write ending + */ + protected function writeEndingWP() + { + $xmlWriter = $this->getXmlWriter(); - $this->xmlWriter->startElement('w:r'); - $styleWriter->write(); - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeAttribute('xml:space', 'preserve'); - $this->xmlWriter->writeRaw($text); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); // w:r if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } + + /** + * Write ending + */ + protected function writeParagraphStyle() + { + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $paragraphStyle = $element->getParagraphStyle(); + $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); + $styleWriter->setIsInline(true); + $styleWriter->write(); + } + + /** + * Write ending + */ + protected function writeFontStyle() + { + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + + $fontStyle = $element->getFontStyle(); + $styleWriter = new FontStyleWriter($xmlWriter, $fontStyle); + $styleWriter->setIsInline(true); + $styleWriter->write(); + } } diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 99dece43c5..05de2917cf 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -17,50 +17,34 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; - /** * TextBreak element writer * * @since 0.10.0 */ -class TextBreak extends Element +class TextBreak extends Text { /** * Write text break element */ public function write() { + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + if (!$this->withoutP) { - $hasStyle = false; - $fontStyle = null; - $paragraphStyle = null; - if (!is_null($this->element)) { - $fontStyle = $this->element->getFontStyle(); - $paragraphStyle = $this->element->getParagraphStyle(); - $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle); - } + $hasStyle = $element->hasStyle(); if ($hasStyle) { - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); - - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); - if (!is_null($fontStyle)) { - $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle); - $styleWriter->setIsInline(true); - - $this->xmlWriter->startElement('w:pPr'); - $styleWriter->write(); - $this->xmlWriter->endElement(); // w:pPr - } - $this->xmlWriter->endElement(); // w:p + $this->writeOpeningWP(); + $xmlWriter->startElement('w:pPr'); + $this->writeFontStyle(); + $xmlWriter->endElement(); // w:pPr + $this->writeEndingWP(); } else { - $this->xmlWriter->writeElement('w:p'); + $xmlWriter->writeElement('w:p'); } } else { - $this->xmlWriter->writeElement('w:br'); + $xmlWriter->writeElement('w:br'); } } } diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index d4b2d29138..0343b16c1b 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -24,24 +24,21 @@ * * @since 0.10.0 */ -class TextRun extends Element +class TextRun extends Text { /** * Write textrun element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $paragraphStyle = $this->element->getParagraphStyle(); - $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); + $this->writeOpeningWP(); - $this->xmlWriter->startElement('w:p'); - $styleWriter->write(); - $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); - $this->xmlWriter->endElement(); // w:p + $containerWriter = new Container($xmlWriter, $element); + $containerWriter->write(); + + $this->writeEndingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index e1c7a0aee2..c5eda5fd6a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -24,54 +24,54 @@ * * @since 0.10.0 */ -class Title extends Element +class Title extends AbstractElement { /** * Write title element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { - return; - } + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); - $bookmarkId = $this->element->getBookmarkId(); + $bookmarkId = $element->getBookmarkId(); $anchor = '_Toc' . ($bookmarkId + 252634154); - $style = $this->element->getStyle(); - $text = htmlspecialchars($this->element->getText()); + $style = $element->getStyle(); + + $text = htmlspecialchars($element->getText()); $text = String::controlCharacterPHP2OOXML($text); - $this->xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:p'); if (!empty($style)) { - $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:pStyle'); - $this->xmlWriter->writeAttribute('w:val', $style); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $style); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:fldChar'); - $this->xmlWriter->writeAttribute('w:fldCharType', 'end'); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'end'); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $this->xmlWriter->startElement('w:bookmarkStart'); - $this->xmlWriter->writeAttribute('w:id', $bookmarkId); - $this->xmlWriter->writeAttribute('w:name', $anchor); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:bookmarkStart'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->writeAttribute('w:name', $anchor); + $xmlWriter->endElement(); - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:t'); - $this->xmlWriter->writeRaw($text); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw($text); + $xmlWriter->endElement(); + $xmlWriter->endElement(); - $this->xmlWriter->startElement('w:bookmarkEnd'); - $this->xmlWriter->writeAttribute('w:id', $bookmarkId); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:bookmarkEnd'); + $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index 141dd33aa7..b0454956e0 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -17,11 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Element\AbstractElement; -use PhpOffice\PhpWord\Element\TextBreak; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Writer\Word2007\Element\Element as ElementWriter; use PhpOffice\PhpWord\Writer\WriterInterface; /** @@ -39,11 +36,11 @@ abstract class AbstractPart /** * Set parent writer * - * @param \PhpOffice\PhpWord\Writer\WriterInterface $pWriter + * @param \PhpOffice\PhpWord\Writer\WriterInterface $writer */ - public function setParentWriter(WriterInterface $pWriter = null) + public function setParentWriter(WriterInterface $writer = null) { - $this->parentWriter = $pWriter; + $this->parentWriter = $writer; } /** @@ -57,7 +54,7 @@ public function getParentWriter() if (!is_null($this->parentWriter)) { return $this->parentWriter; } else { - throw new Exception("No parent WriterInterface assigned."); + throw new Exception('No parent WriterInterface assigned.'); } } @@ -80,48 +77,4 @@ protected function getXmlWriter() return new XMLWriter(XMLWriter::STORAGE_MEMORY); } } - - /** - * Write container elements - * - * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param \PhpOffice\PhpWord\Element\AbstractElement $container - */ - public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $container) - { - // Check allowed elements - $elmCommon = array('Text', 'Link', 'TextBreak', 'Image', 'Object'); - $elmMainCell = array_merge($elmCommon, array('TextRun', 'ListItem', 'CheckBox')); - $allowedElements = array( - 'Section' => array_merge($elmMainCell, array('Table', 'Footnote', 'Title', 'PageBreak', 'TOC')), - 'Header' => array_merge($elmMainCell, array('Table', 'PreserveText')), - 'Footer' => array_merge($elmMainCell, array('Table', 'PreserveText')), - 'Cell' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), - 'TextRun' => array_merge($elmCommon, array('Footnote', 'Endnote')), - 'Footnote' => $elmCommon, - 'Endnote' => $elmCommon, - ); - $containerName = get_class($container); - $containerName = substr($containerName, strrpos($containerName, '\\') + 1); - if (!array_key_exists($containerName, $allowedElements)) { - throw new Exception('Invalid container.'); - } - - // Loop through elements - $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof AbstractElement) { - $elementWriter = new ElementWriter($xmlWriter, $this, $element, $withoutP); - $elementWriter->write(); - } - } - } else { - if ($containerName == 'Cell') { - $elementWriter = new ElementWriter($xmlWriter, $this, new TextBreak(), $withoutP); - $elementWriter->write(); - } - } - } } diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index ccbd02d024..0f8a16af89 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -20,6 +20,7 @@ use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; /** @@ -60,7 +61,10 @@ public function write() if ($sectionCount > 0) { foreach ($sections as $section) { $currentSection++; - $this->writeContainerElements($xmlWriter, $section); + + $containerWriter = new Container($xmlWriter, $section); + $containerWriter->write(); + if ($currentSection == $sectionCount) { $this->writeSectionSettings($xmlWriter, $section); } else { diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php index 12a7b1aadf..db6a2b334b 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footer.php +++ b/src/PhpWord/Writer/Word2007/Part/Footer.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; +use PhpOffice\PhpWord\Writer\Word2007\Element\Container; + /** * Word2007 footer part writer: word/footerx.xml */ @@ -58,7 +60,8 @@ public function write() $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - $this->writeContainerElements($xmlWriter, $this->element); + $containerWriter = new Container($xmlWriter, $this->element); + $containerWriter->write(); $xmlWriter->endElement(); // $this->rootElement diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 7e09446db2..1eeabc9c4d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\Element\Footnote; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; /** @@ -165,7 +166,8 @@ protected function writeNote(XMLWriter $xmlWriter, $element) $xmlWriter->endElement(); // w:t $xmlWriter->endElement(); // w:r - $this->writeContainerElements($xmlWriter, $element); + $containerWriter = new Container($xmlWriter, $element); + $containerWriter->write(); $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // $this->elementNode diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 95ac32b1c9..44e62013eb 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -27,11 +27,6 @@ */ class Rels extends AbstractPart { - /** - * Base relationship URL - */ - const RELS_BASE = 'http://schemas.openxmlformats.org/'; - /** * Write part * @@ -62,7 +57,7 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = { $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', self::RELS_BASE . 'package/2006/relationships'); + $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // XML files relationships if (is_array($xmlRels)) { @@ -73,17 +68,18 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = // Media relationships if (is_array($mediaRels)) { - $mapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink'); + $typePrefix = 'officeDocument/2006/relationships/'; + $typeMapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink'); $targetPaths = array('image' => 'media/', 'object' => 'embeddings/'); + foreach ($mediaRels as $mediaRel) { $mediaType = $mediaRel['type']; - $type = array_key_exists($mediaType, $mapping) ? $mapping[$mediaType] : $mediaType; + $type = array_key_exists($mediaType, $typeMapping) ? $typeMapping[$mediaType] : $mediaType; $target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : ''; $target .= $mediaRel['target']; $targetMode = ($type == 'hyperlink') ? 'External' : ''; - $type = "officeDocument/2006/relationships/{$type}"; - $this->writeRel($xmlWriter, $relId++, $type, $target, $targetMode); + $this->writeRel($xmlWriter, $relId++, $typePrefix . $type, $target, $targetMode); } } @@ -110,7 +106,7 @@ private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetM } $xmlWriter->startElement('Relationship'); $xmlWriter->writeAttribute('Id', $relId); - $xmlWriter->writeAttribute('Type', self::RELS_BASE . $type); + $xmlWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/' . $type); $xmlWriter->writeAttribute('Target', $target); if ($targetMode != '') { $xmlWriter->writeAttribute('TargetMode', $targetMode); diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 41bbed3dcc..7213e4aae7 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -32,10 +33,10 @@ abstract class AbstractStyle * * @var \PhpOffice\PhpWord\Shared\XMLWriter */ - protected $xmlWriter; + private $xmlWriter; /** - * Style + * Style; set protected for a while * * @var string|\PhpOffice\PhpWord\Style\AbstractStyle */ @@ -57,6 +58,33 @@ public function __construct(XMLWriter $xmlWriter, $style = null) $this->style = $style; } + /** + * Get XML Writer + * + * @return \PhpOffice\PhpWord\Shared\XMLWriter + */ + protected function getXmlWriter() + { + return $this->xmlWriter; + } + + /** + * Get Style + * + * @return \PhpOffice\PhpWord\Style\AbstractStyle + */ + protected function getStyle() + { + if (!is_null($this->style)) { + $styleClass = 'PhpOffice\\PhpWord\\Style\\' . basename(get_class($this->style)); + if (is_object($this->style) && (!$this->style instanceof $styleClass)) { + throw new Exception('No valid style assigned.'); + } + } + + return $this->style; + } + /** * Convert twip value * @@ -73,27 +101,4 @@ protected function convertTwip($value, $default = 0) return $value * $unit; } } - - /** - * Write element when ... - * - * @param bool $condition - * @param string $element - * @param string $attribute - * @param string $value - */ - protected function writeElementIf($condition, $element, $attribute = null, $value = null) - { - if (!$condition) { - return; - } - - if (is_null($attribute)) { - $this->xmlWriter->writeElement($element, $value); - } else { - $this->xmlWriter->startElement($element); - $this->xmlWriter->writeAttribute($attribute, $value); - $this->xmlWriter->endElement(); - } - } } diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index 7021a449cb..5f38f77d45 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -31,64 +31,42 @@ class Cell extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Cell)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $brdSz = $this->style->getBorderSize(); - $brdCol = $this->style->getBorderColor(); - $hasBorders = false; - for ($i = 0; $i < 4; $i++) { - if (!is_null($brdSz[$i])) { - $hasBorders = true; - break; - } - } + // Text direction + $textDir = $style->getTextDirection(); + $xmlWriter->writeElementIf(!is_null($textDir), 'w:textDirection', 'w:val', $textDir); + + // Vertical alignment + $vAlign = $style->getVAlign(); + $xmlWriter->writeElementIf(!is_null($vAlign), 'w:vAlign', 'w:val', $vAlign); // Border - if ($hasBorders) { - $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($brdSz); - $mbWriter->setColors($brdCol); - $mbWriter->setAttributes(array('defaultColor' => CellStyle::DEFAULT_BORDER_COLOR)); + if ($style->hasBorders()) { + $xmlWriter->startElement('w:tcBorders'); - $this->xmlWriter->startElement('w:tcBorders'); - $mbWriter->write(); - $this->xmlWriter->endElement(); - } + $styleWriter = new MarginBorder($xmlWriter); + $styleWriter->setSizes($style->getBorderSize()); + $styleWriter->setColors($style->getBorderColor()); + $styleWriter->setAttributes(array('defaultColor' => CellStyle::DEFAULT_BORDER_COLOR)); + $styleWriter->write(); - // Text direction - if (!is_null($this->style->getTextDirection())) { - $this->xmlWriter->startElement('w:textDirection'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getTextDirection()); - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } // Shading - if (!is_null($this->style->getShading())) { - $styleWriter = new Shading($this->xmlWriter, $this->style->getShading()); + if (!is_null($style->getShading())) { + $styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter->write(); } - // Alignment - if (!is_null($this->style->getVAlign())) { - $this->xmlWriter->startElement('w:vAlign'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getVAlign()); - $this->xmlWriter->endElement(); - } - - // Colspan - if (!is_null($this->style->getGridSpan())) { - $this->xmlWriter->startElement('w:gridSpan'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getGridSpan()); - $this->xmlWriter->endElement(); - } - - // Row span - if (!is_null($this->style->getVMerge())) { - $this->xmlWriter->startElement('w:vMerge'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getVMerge()); - $this->xmlWriter->endElement(); - } + // Colspan & rowspan + $gridSpan = $style->getGridSpan(); + $vMerge = $style->getVMerge(); + $xmlWriter->writeElementIf(!is_null($gridSpan), 'w:gridSpan', 'w:val', $gridSpan); + $xmlWriter->writeElementIf(!is_null($vMerge), 'w:vMerge', 'w:val', $vMerge); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index b127da313a..aac53038f8 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -38,13 +38,15 @@ class Font extends AbstractStyle */ public function write() { + $xmlWriter = $this->getXmlWriter(); + $isStyleName = $this->isInline && !is_null($this->style) && is_string($this->style); if ($isStyleName) { - $this->xmlWriter->startElement('w:rPr'); - $this->xmlWriter->startElement('w:rStyle'); - $this->xmlWriter->writeAttribute('w:val', $this->style); - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rStyle'); + $xmlWriter->writeAttribute('w:val', $this->style); + $xmlWriter->endElement(); + $xmlWriter->endElement(); } else { $this->writeStyle(); } @@ -55,67 +57,65 @@ public function write() */ private function writeStyle() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Font)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); + $font = $style->getName(); + $color = $style->getColor(); + $size = $style->getSize(); + $underline = $style->getUnderline(); + $fgColor = $style->getFgColor(); + $hint = $style->getHint(); - $font = $this->style->getName(); - $color = $this->style->getColor(); - $size = $this->style->getSize(); - $underline = $this->style->getUnderline(); - $fgColor = $this->style->getFgColor(); - - $this->xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rPr'); // Font name/family if ($font != PhpWord::DEFAULT_FONT_NAME) { - $this->xmlWriter->startElement('w:rFonts'); - $this->xmlWriter->writeAttribute('w:ascii', $font); - $this->xmlWriter->writeAttribute('w:hAnsi', $font); - $this->xmlWriter->writeAttribute('w:eastAsia', $font); - $this->xmlWriter->writeAttribute('w:cs', $font); - //Font Content Type - if ($this->style->getHint() != PhpWord::DEFAULT_FONT_CONTENT_TYPE) { - $this->xmlWriter->writeAttribute('w:hint', $this->style->getHint()); - } - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttribute('w:ascii', $font); + $xmlWriter->writeAttribute('w:hAnsi', $font); + $xmlWriter->writeAttribute('w:eastAsia', $font); + $xmlWriter->writeAttribute('w:cs', $font); + $xmlWriter->writeAttributeIf($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE, 'w:hint', $hint); + $xmlWriter->endElement(); } // Color - $this->writeElementIf($color != PhpWord::DEFAULT_FONT_COLOR, 'w:color', 'w:val', $color); - $this->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:sz', 'w:val', $size * 2); - $this->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:szCs', 'w:val', $size * 2); + $xmlWriter->writeElementIf($color != PhpWord::DEFAULT_FONT_COLOR, 'w:color', 'w:val', $color); + $xmlWriter->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:sz', 'w:val', $size * 2); + $xmlWriter->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:szCs', 'w:val', $size * 2); // Bold, italic - $this->writeElementIf($this->style->isBold(), 'w:b'); - $this->writeElementIf($this->style->isItalic(), 'w:i'); - $this->writeElementIf($this->style->isItalic(), 'w:iCs'); + $xmlWriter->writeElementIf($style->isBold(), 'w:b'); + $xmlWriter->writeElementIf($style->isItalic(), 'w:i'); + $xmlWriter->writeElementIf($style->isItalic(), 'w:iCs'); // Strikethrough, double strikethrough - $this->writeElementIf($this->style->isStrikethrough(), 'w:strike'); - $this->writeElementIf($this->style->isDoubleStrikethrough(), 'w:dstrike'); + $xmlWriter->writeElementIf($style->isStrikethrough(), 'w:strike'); + $xmlWriter->writeElementIf($style->isDoubleStrikethrough(), 'w:dstrike'); // Small caps, all caps - $this->writeElementIf($this->style->isSmallCaps(), 'w:smallCaps'); - $this->writeElementIf($this->style->isAllCaps(), 'w:caps'); + $xmlWriter->writeElementIf($style->isSmallCaps(), 'w:smallCaps'); + $xmlWriter->writeElementIf($style->isAllCaps(), 'w:caps'); // Underline - $this->writeElementIf($underline != 'none', 'w:u', 'w:val', $underline); + $xmlWriter->writeElementIf($underline != 'none', 'w:u', 'w:val', $underline); // Foreground-Color - $this->writeElementIf(!is_null($fgColor), 'w:highlight', 'w:val', $fgColor); + $xmlWriter->writeElementIf(!is_null($fgColor), 'w:highlight', 'w:val', $fgColor); // Superscript/subscript - $this->writeElementIf($this->style->isSuperScript(), 'w:vertAlign', 'w:val', 'superscript'); - $this->writeElementIf($this->style->isSubScript(), 'w:vertAlign', 'w:val', 'subscript'); + $xmlWriter->writeElementIf($style->isSuperScript(), 'w:vertAlign', 'w:val', 'superscript'); + $xmlWriter->writeElementIf($style->isSubScript(), 'w:vertAlign', 'w:val', 'subscript'); // Background-Color - if (!is_null($this->style->getShading())) { - $styleWriter = new Shading($this->xmlWriter, $this->style->getShading()); + if (!is_null($style->getShading())) { + $styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter->write(); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } /** diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index b5e23e9a21..79b218d6fe 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -38,12 +38,12 @@ class Image extends AbstractStyle */ public function write() { - if (!$this->style instanceof \PhpOffice\PhpWord\Style\Image) { + if (is_null($style = $this->getStyle())) { return; } - - $wrapping = $this->style->getWrappingStyle(); - $positioning = $this->style->getPositioning(); + $xmlWriter = $this->getXmlWriter(); + $wrapping = $style->getWrappingStyle(); + $positioning = $style->getPositioning(); // Default style array $styleArray = array( @@ -60,10 +60,10 @@ public function write() $styleArray['mso-position-horizontal-relative'] = 'page'; $styleArray['mso-position-vertical-relative'] = 'page'; } elseif ($positioning == ImageStyle::POSITION_RELATIVE) { - $styleArray['mso-position-horizontal'] = $this->style->getPosHorizontal(); - $styleArray['mso-position-vertical'] = $this->style->getPosVertical(); - $styleArray['mso-position-horizontal-relative'] = $this->style->getPosHorizontalRel(); - $styleArray['mso-position-vertical-relative'] = $this->style->getPosVerticalRel(); + $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); + $styleArray['mso-position-vertical'] = $style->getPosVertical(); + $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); + $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); $styleArray['margin-left'] = 0; $styleArray['margin-top'] = 0; } @@ -88,7 +88,7 @@ public function write() $imageStyle = $this->assembleStyle($styleArray); - $this->xmlWriter->writeAttribute('style', $imageStyle); + $xmlWriter->writeAttribute('style', $imageStyle); } /** @@ -98,10 +98,12 @@ public function write() */ public function writeW10Wrap() { + $xmlWriter = $this->getXmlWriter(); + if (!is_null($this->w10wrap)) { - $this->xmlWriter->startElement('w10:wrap'); - $this->xmlWriter->writeAttribute('type', $this->w10wrap); - $this->xmlWriter->endElement(); // w10:wrap + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $this->w10wrap); + $xmlWriter->endElement(); // w10:wrap } } diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index b05e571152..60fbd5404a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -29,19 +29,18 @@ class Indentation extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Indentation)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); + $firstLine = $style->getFirstLine(); + $hanging = $style->getHanging(); - $this->xmlWriter->startElement('w:ind'); - $this->xmlWriter->writeAttribute('w:left', $this->convertTwip($this->style->getLeft())); - $this->xmlWriter->writeAttribute('w:right', $this->convertTwip($this->style->getRight())); - if (!is_null($this->style->getFirstLine())) { - $this->xmlWriter->writeAttribute('w:firstLine', $this->convertTwip($this->style->getFirstLine())); - } - if (!is_null($this->style->getHanging())) { - $this->xmlWriter->writeAttribute('w:hanging', $this->convertTwip($this->style->getHanging())); - } - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:left', $this->convertTwip($style->getLeft())); + $xmlWriter->writeAttribute('w:right', $this->convertTwip($style->getRight())); + $xmlWriter->writeAttributeIf(!is_null($firstLine), 'w:firstLine', $this->convertTwip($firstLine)); + $xmlWriter->writeAttributeIf(!is_null($hanging), 'w:hanging', $this->convertTwip($hanging)); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index 74d4682d5b..c4c1216b99 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -31,15 +31,16 @@ class LineNumbering extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\LineNumbering)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $this->xmlWriter->startElement('w:lnNumType'); - $this->xmlWriter->writeAttribute('w:start', $this->style->getStart() - 1); - $this->xmlWriter->writeAttribute('w:countBy', $this->style->getIncrement()); - $this->xmlWriter->writeAttribute('w:distance', $this->style->getDistance()); - $this->xmlWriter->writeAttribute('w:restart', $this->style->getRestart()); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:lnNumType'); + $xmlWriter->writeAttribute('w:start', $style->getStart() - 1); + $xmlWriter->writeAttribute('w:countBy', $style->getIncrement()); + $xmlWriter->writeAttribute('w:distance', $style->getDistance()); + $xmlWriter->writeAttribute('w:restart', $style->getRestart()); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index be2c115d8f..8f7c1c002f 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -50,31 +50,33 @@ class MarginBorder extends AbstractStyle */ public function write() { + $xmlWriter = $this->getXmlWriter(); + $sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV'); $sizeCount = count($this->sizes) - 1; for ($i = 0; $i < $sizeCount; $i++) { if (!is_null($this->sizes[$i])) { - $this->xmlWriter->startElement('w:' . $sides[$i]); + $xmlWriter->startElement('w:' . $sides[$i]); if (!empty($this->colors)) { if (is_null($this->colors[$i]) && !empty($this->attributes)) { if (array_key_exists('defaultColor', $this->attributes)) { $this->colors[$i] = $this->attributes['defaultColor']; } } - $this->xmlWriter->writeAttribute('w:val', 'single'); - $this->xmlWriter->writeAttribute('w:sz', $this->sizes[$i]); - $this->xmlWriter->writeAttribute('w:color', $this->colors[$i]); + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $this->sizes[$i]); + $xmlWriter->writeAttribute('w:color', $this->colors[$i]); if (!empty($this->attributes)) { if (array_key_exists('space', $this->attributes)) { - $this->xmlWriter->writeAttribute('w:space', $this->attributes['space']); + $xmlWriter->writeAttribute('w:space', $this->attributes['space']); } } } else { - $this->xmlWriter->writeAttribute('w:w', $this->sizes[$i]); - $this->xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->writeAttribute('w:w', $this->sizes[$i]); + $xmlWriter->writeAttribute('w:type', 'dxa'); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index af66abeda7..c2caea116b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -43,16 +43,18 @@ class Paragraph extends AbstractStyle */ public function write() { + $xmlWriter = $this->getXmlWriter(); + $isStyleName = $this->isInline && !is_null($this->style) && is_string($this->style); if ($isStyleName) { if (!$this->withoutPPR) { - $this->xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); } - $this->xmlWriter->startElement('w:pStyle'); - $this->xmlWriter->writeAttribute('w:val', $this->style); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:pStyle'); + $xmlWriter->writeAttribute('w:val', $this->style); + $xmlWriter->endElement(); if (!$this->withoutPPR) { - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } } else { $this->writeStyle(); @@ -64,52 +66,52 @@ public function write() */ private function writeStyle() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Paragraph)) { + if (is_null($style = $this->getStyle())) { return; } - - $align = $this->style->getAlign(); - $indentation = $this->style->getIndentation(); - $spacing = $this->style->getSpace(); - $tabs = $this->style->getTabs(); + $xmlWriter = $this->getXmlWriter(); + $align = $style->getAlign(); + $indentation = $style->getIndentation(); + $spacing = $style->getSpace(); + $tabs = $style->getTabs(); if (!$this->withoutPPR) { - $this->xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:pPr'); } // Alignment - $this->writeElementIf(!is_null($align), 'w:jc', 'w:val', $align); + $xmlWriter->writeElementIf(!is_null($align), 'w:jc', 'w:val', $align); // Pagination - $this->writeElementIf(!$this->style->hasWidowControl(), 'w:widowControl', 'w:val', '0'); - $this->writeElementIf($this->style->isKeepNext(), 'w:keepNext', 'w:val', '1'); - $this->writeElementIf($this->style->isKeepLines(), 'w:keepLines', 'w:val', '1'); - $this->writeElementIf($this->style->hasPageBreakBefore(), 'w:pageBreakBefore', 'w:val', '1'); + $xmlWriter->writeElementIf(!$style->hasWidowControl(), 'w:widowControl', 'w:val', '0'); + $xmlWriter->writeElementIf($style->isKeepNext(), 'w:keepNext', 'w:val', '1'); + $xmlWriter->writeElementIf($style->isKeepLines(), 'w:keepLines', 'w:val', '1'); + $xmlWriter->writeElementIf($style->hasPageBreakBefore(), 'w:pageBreakBefore', 'w:val', '1'); // Indentation if (!is_null($indentation)) { - $styleWriter = new Indentation($this->xmlWriter, $indentation); + $styleWriter = new Indentation($xmlWriter, $indentation); $styleWriter->write(); } // Spacing if (!is_null($spacing)) { - $styleWriter = new Spacing($this->xmlWriter, $spacing); + $styleWriter = new Spacing($xmlWriter, $spacing); $styleWriter->write(); } // Tabs if (!empty($tabs)) { - $this->xmlWriter->startElement("w:tabs"); + $xmlWriter->startElement("w:tabs"); foreach ($tabs as $tab) { - $styleWriter = new Tab($this->xmlWriter, $tab); + $styleWriter = new Tab($xmlWriter, $tab); $styleWriter->write(); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } if (!$this->withoutPPR) { - $this->xmlWriter->endElement(); // w:pPr + $xmlWriter->endElement(); // w:pPr } } diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index 05fc1d0821..b773564c88 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -31,23 +31,21 @@ class Section extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Section)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - // Section break - if (!is_null($this->style->getBreakType())) { - $this->xmlWriter->startElement('w:type'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getBreakType()); - $this->xmlWriter->endElement(); - } + // Break type + $breakType = $style->getBreakType(); + $xmlWriter->writeElementIf(!is_null($breakType), 'w:type', 'w:val', $breakType); // Page size & orientation - $this->xmlWriter->startElement('w:pgSz'); - $this->xmlWriter->writeAttribute('w:orient', $this->style->getOrientation()); - $this->xmlWriter->writeAttribute('w:w', $this->style->getPageSizeW()); - $this->xmlWriter->writeAttribute('w:h', $this->style->getPageSizeH()); - $this->xmlWriter->endElement(); // w:pgSz + $xmlWriter->startElement('w:pgSz'); + $xmlWriter->writeAttribute('w:orient', $style->getOrientation()); + $xmlWriter->writeAttribute('w:w', $style->getPageSizeW()); + $xmlWriter->writeAttribute('w:h', $style->getPageSizeH()); + $xmlWriter->endElement(); // w:pgSz // Margins $margins = array( @@ -59,52 +57,40 @@ public function write() 'w:footer' => array('getFooterHeight', SectionStyle::DEFAULT_FOOTER_HEIGHT), 'w:gutter' => array('getGutter', SectionStyle::DEFAULT_GUTTER), ); - $this->xmlWriter->startElement('w:pgMar'); + $xmlWriter->startElement('w:pgMar'); foreach ($margins as $attribute => $value) { list($method, $default) = $value; - $this->xmlWriter->writeAttribute($attribute, $this->convertTwip($this->style->$method(), $default)); + $xmlWriter->writeAttribute($attribute, $this->convertTwip($style->$method(), $default)); } - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); // Borders - $borders = $this->style->getBorderSize(); - $hasBorders = false; - for ($i = 0; $i < 4; $i++) { - if (!is_null($borders[$i])) { - $hasBorders = true; - break; - } - } - if ($hasBorders) { - $styleWriter = new MarginBorder($this->xmlWriter); - $styleWriter->setSizes($borders); - $styleWriter->setColors($this->style->getBorderColor()); - $styleWriter->setAttributes(array('space' => '24')); + if ($style->hasBorders()) { + $xmlWriter->startElement('w:pgBorders'); + $xmlWriter->writeAttribute('w:offsetFrom', 'page'); - $this->xmlWriter->startElement('w:pgBorders'); - $this->xmlWriter->writeAttribute('w:offsetFrom', 'page'); + $styleWriter = new MarginBorder($xmlWriter); + $styleWriter->setSizes($style->getBorderSize()); + $styleWriter->setColors($style->getBorderColor()); + $styleWriter->setAttributes(array('space' => '24')); $styleWriter->write(); - $this->xmlWriter->endElement(); - } - // Page numbering - if (!is_null($this->style->getPageNumberingStart())) { - $this->xmlWriter->startElement('w:pgNumType'); - $this->xmlWriter->writeAttribute('w:start', $this->style->getPageNumberingStart()); - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } // Columns - $this->xmlWriter->startElement('w:cols'); - $this->xmlWriter->writeAttribute('w:num', $this->style->getColsNum()); - $this->xmlWriter->writeAttribute('w:space', $this->convertTwip( - $this->style->getColsSpace(), - SectionStyle::DEFAULT_COLUMN_SPACING - )); - $this->xmlWriter->endElement(); + $colsSpace = $style->getColsSpace(); + $xmlWriter->startElement('w:cols'); + $xmlWriter->writeAttribute('w:num', $style->getColsNum()); + $xmlWriter->writeAttribute('w:space', $this->convertTwip($colsSpace, SectionStyle::DEFAULT_COLUMN_SPACING)); + $xmlWriter->endElement(); + + // Page numbering start + $pageNum = $style->getPageNumberingStart(); + $xmlWriter->writeElementIf(!is_null($pageNum), 'w:pgNumType', 'w:start', $pageNum); // Line numbering - $styleWriter = new LineNumbering($this->xmlWriter, $this->style->getLineNumbering()); + $styleWriter = new LineNumbering($xmlWriter, $style->getLineNumbering()); $styleWriter->write(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index 17c7298a30..cc7f9364b0 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -29,14 +29,15 @@ class Shading extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Shading)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $this->xmlWriter->startElement('w:shd'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getPattern()); - $this->xmlWriter->writeAttribute('w:color', $this->style->getColor()); - $this->xmlWriter->writeAttribute('w:fill', $this->style->getFill()); - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:shd'); + $xmlWriter->writeAttribute('w:val', $style->getPattern()); + $xmlWriter->writeAttribute('w:color', $style->getColor()); + $xmlWriter->writeAttribute('w:fill', $style->getFill()); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index 5a059047cc..faa9b7499c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -29,21 +29,21 @@ class Spacing extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Spacing)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); + $before = $style->getBefore(); + $after = $style->getAfter(); + $line = $style->getLine(); - $this->xmlWriter->startElement('w:spacing'); - if (!is_null($this->style->getBefore())) { - $this->xmlWriter->writeAttribute('w:before', $this->convertTwip($this->style->getBefore())); - } - if (!is_null($this->style->getAfter())) { - $this->xmlWriter->writeAttribute('w:after', $this->convertTwip($this->style->getAfter())); - } - if (!is_null($this->style->getLine())) { - $this->xmlWriter->writeAttribute('w:line', $this->style->getLine()); - $this->xmlWriter->writeAttribute('w:lineRule', $this->style->getRule()); - } - $this->xmlWriter->endElement(); + $xmlWriter->startElement('w:spacing'); + + $xmlWriter->writeAttributeIf(!is_null($before), 'w:before', $this->convertTwip($before)); + $xmlWriter->writeAttributeIf(!is_null($after), 'w:after', $this->convertTwip($after)); + $xmlWriter->writeAttributeIf(!is_null($line), 'w:line', $line); + $xmlWriter->writeAttributeIf(!is_null($line), 'w:lineRule', $style->getRule()); + + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index 92db7aca6d..c15d136406 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -29,14 +29,15 @@ class Tab extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Tab)) { + if (is_null($style = $this->getStyle())) { return; } + $xmlWriter = $this->getXmlWriter(); - $this->xmlWriter->startElement("w:tab"); - $this->xmlWriter->writeAttribute("w:val", $this->style->getType()); - $this->xmlWriter->writeAttribute("w:leader", $this->style->getLeader()); - $this->xmlWriter->writeAttribute('w:pos', $this->convertTwip($this->style->getPosition())); - $this->xmlWriter->endElement(); + $xmlWriter->startElement("w:tab"); + $xmlWriter->writeAttribute("w:val", $style->getType()); + $xmlWriter->writeAttribute("w:leader", $style->getLeader()); + $xmlWriter->writeAttribute('w:pos', $this->convertTwip($style->getPosition())); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 08100118da..6b5569cf6d 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -36,47 +36,47 @@ class Table extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Table)) { + if (is_null($style = $this->getStyle())) { return; } - - $hasBorders = $this->style->hasBorders(); - $hasMargins = $this->style->hasMargins(); + $xmlWriter = $this->getXmlWriter(); + $hasBorders = $style->hasBorders(); + $hasMargins = $style->hasMargins(); if ($hasMargins || $hasBorders) { - $this->xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblPr'); if ($hasMargins) { - $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($this->style->getCellMargin()); + $mbWriter = new MarginBorder($xmlWriter); + $mbWriter->setSizes($style->getCellMargin()); - $this->xmlWriter->startElement('w:tblCellMar'); + $xmlWriter->startElement('w:tblCellMar'); $mbWriter->write(); - $this->xmlWriter->endElement(); // w:tblCellMar + $xmlWriter->endElement(); // w:tblCellMar } if ($hasBorders) { - $mbWriter = new MarginBorder($this->xmlWriter); - $mbWriter->setSizes($this->style->getBorderSize()); - $mbWriter->setColors($this->style->getBorderColor()); + $mbWriter = new MarginBorder($xmlWriter); + $mbWriter->setSizes($style->getBorderSize()); + $mbWriter->setColors($style->getBorderColor()); - $this->xmlWriter->startElement('w:tblBorders'); + $xmlWriter->startElement('w:tblBorders'); $mbWriter->write(); - $this->xmlWriter->endElement(); // w:tblBorders + $xmlWriter->endElement(); // w:tblBorders } - $this->xmlWriter->endElement(); // w:tblPr + $xmlWriter->endElement(); // w:tblPr } // Only write background color and first row for full style if ($this->isFullStyle) { // Background color - if (!is_null($this->style->getShading())) { - $this->xmlWriter->startElement('w:tcPr'); - $styleWriter = new Shading($this->xmlWriter, $this->style->getShading()); + if (!is_null($style->getShading())) { + $xmlWriter->startElement('w:tcPr'); + $styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter->write(); - $this->xmlWriter->endElement(); + $xmlWriter->endElement(); } // First Row - $firstRow = $this->style->getFirstRow(); + $firstRow = $style->getFirstRow(); if ($firstRow instanceof \PhpOffice\PhpWord\Style\Table) { - $this->writeFirstRow($firstRow, 'firstRow'); + $this->writeFirstRow($firstRow); } } } @@ -96,28 +96,30 @@ public function setIsFullStyle($value) * * @param string $type */ - private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style, $type) + private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style) { - $this->xmlWriter->startElement('w:tblStylePr'); - $this->xmlWriter->writeAttribute('w:type', $type); - $this->xmlWriter->startElement('w:tcPr'); + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement('w:tblStylePr'); + $xmlWriter->writeAttribute('w:type', 'firstRow'); + $xmlWriter->startElement('w:tcPr'); if (!is_null($style->getShading())) { - $styleWriter = new Shading($this->xmlWriter, $style->getShading()); + $styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter->write(); } // Borders if ($style->hasBorders()) { - $mbWriter = new MarginBorder($this->xmlWriter); + $mbWriter = new MarginBorder($xmlWriter); $mbWriter->setSizes($style->getBorderSize()); $mbWriter->setColors($style->getBorderColor()); - $this->xmlWriter->startElement('w:tcBorders'); + $xmlWriter->startElement('w:tcBorders'); $mbWriter->write(); - $this->xmlWriter->endElement(); // w:tcBorders + $xmlWriter->endElement(); // w:tcBorders } - $this->xmlWriter->endElement(); // w:tcPr - $this->xmlWriter->endElement(); // w:tblStylePr + $xmlWriter->endElement(); // w:tcPr + $xmlWriter->endElement(); // w:tblStylePr } } diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index cfa518925e..2f5c49c6b3 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -97,8 +97,9 @@ public function testSetStyleValueNormal() 'fgColor' => Font::FGCOLOR_YELLOW, 'bgColor' => 'FFFF00', 'hint' => 'eastAsia', + 'line-height' => 2, ); - $object->setArrayStyle($attributes); + $object->setStyleByArray($attributes); foreach ($attributes as $key => $value) { $get = "get{$key}"; $this->assertEquals($value, $object->$get()); From 364131aa5d56b07b3a03936c4f4502be54029d44 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Wed, 7 May 2014 21:27:51 +0200 Subject: [PATCH 049/167] Added TextBox functionality --- .gitignore | 1 - .scrutinizer.yml | 14 + .travis.yml | 2 +- CHANGELOG.md | 4 +- README.md | 71 +- composer.json | 2 +- composer.lock | 3107 +++++++++++++++++ docs/intro.rst | 37 +- docs/references.rst | 14 +- docs/src/documentation.md | 30 +- samples/Sample_12_HeaderFooter.php | 1 + samples/Sample_13_Images.php | 31 + src/PhpWord/Autoloader.php | 12 +- src/PhpWord/Collection/AbstractCollection.php | 12 +- src/PhpWord/Collection/Endnotes.php | 12 +- src/PhpWord/Collection/Footnotes.php | 12 +- src/PhpWord/Collection/Titles.php | 12 +- src/PhpWord/DocumentProperties.php | 12 +- src/PhpWord/Element/AbstractContainer.php | 23 +- src/PhpWord/Element/AbstractElement.php | 18 +- src/PhpWord/Element/Cell.php | 12 +- src/PhpWord/Element/CheckBox.php | 12 +- src/PhpWord/Element/Endnote.php | 12 +- src/PhpWord/Element/Footer.php | 29 +- src/PhpWord/Element/Footnote.php | 12 +- src/PhpWord/Element/Header.php | 12 +- src/PhpWord/Element/Image.php | 12 +- src/PhpWord/Element/Link.php | 12 +- src/PhpWord/Element/ListItem.php | 12 +- src/PhpWord/Element/Object.php | 14 +- src/PhpWord/Element/PageBreak.php | 12 +- src/PhpWord/Element/PreserveText.php | 12 +- src/PhpWord/Element/Row.php | 12 +- src/PhpWord/Element/Section.php | 31 +- src/PhpWord/Element/TOC.php | 12 +- src/PhpWord/Element/Table.php | 12 +- src/PhpWord/Element/Text.php | 12 +- src/PhpWord/Element/TextBox.php | 57 + src/PhpWord/Element/TextBreak.php | 12 +- src/PhpWord/Element/TextRun.php | 12 +- src/PhpWord/Element/Title.php | 14 +- src/PhpWord/Exception/Exception.php | 12 +- .../Exception/InvalidImageException.php | 12 +- .../Exception/InvalidObjectException.php | 12 +- .../Exception/InvalidStyleException.php | 12 +- .../UnsupportedImageTypeException.php | 12 +- src/PhpWord/IOFactory.php | 12 +- src/PhpWord/Media.php | 12 +- src/PhpWord/PhpWord.php | 14 +- src/PhpWord/Reader/AbstractReader.php | 12 +- src/PhpWord/Reader/ODText.php | 12 +- src/PhpWord/Reader/ODText/AbstractPart.php | 12 +- src/PhpWord/Reader/ODText/Content.php | 12 +- src/PhpWord/Reader/ReaderInterface.php | 12 +- src/PhpWord/Reader/Word2007.php | 12 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 12 +- src/PhpWord/Reader/Word2007/DocPropsApp.php | 12 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 12 +- .../Reader/Word2007/DocPropsCustom.php | 12 +- src/PhpWord/Reader/Word2007/Document.php | 12 +- src/PhpWord/Reader/Word2007/Endnotes.php | 25 +- src/PhpWord/Reader/Word2007/Footnotes.php | 61 +- src/PhpWord/Reader/Word2007/Notes.php | 60 - src/PhpWord/Reader/Word2007/Numbering.php | 12 +- src/PhpWord/Reader/Word2007/Styles.php | 12 +- src/PhpWord/Settings.php | 12 +- src/PhpWord/Shared/Drawing.php | 12 +- src/PhpWord/Shared/Font.php | 12 +- src/PhpWord/Shared/String.php | 12 +- src/PhpWord/Shared/XMLReader.php | 12 +- src/PhpWord/Shared/XMLWriter.php | 12 +- src/PhpWord/Shared/ZipArchive.php | 12 +- src/PhpWord/Style.php | 12 +- src/PhpWord/Style/AbstractStyle.php | 12 +- src/PhpWord/Style/Border.php | 12 +- src/PhpWord/Style/Cell.php | 12 +- src/PhpWord/Style/Font.php | 12 +- src/PhpWord/Style/Image.php | 15 +- src/PhpWord/Style/Indentation.php | 12 +- src/PhpWord/Style/LineNumbering.php | 12 +- src/PhpWord/Style/ListItem.php | 12 +- src/PhpWord/Style/Numbering.php | 12 +- src/PhpWord/Style/NumberingLevel.php | 12 +- src/PhpWord/Style/Paragraph.php | 12 +- src/PhpWord/Style/Row.php | 12 +- src/PhpWord/Style/Section.php | 12 +- src/PhpWord/Style/Shading.php | 35 +- src/PhpWord/Style/Spacing.php | 12 +- src/PhpWord/Style/TOC.php | 22 +- src/PhpWord/Style/Tab.php | 12 +- src/PhpWord/Style/Table.php | 14 +- src/PhpWord/Style/TextBox.php | 641 ++++ src/PhpWord/Template.php | 12 +- src/PhpWord/Writer/AbstractWriter.php | 12 +- src/PhpWord/Writer/HTML.php | 12 +- src/PhpWord/Writer/HTML/Element/Element.php | 12 +- src/PhpWord/Writer/HTML/Element/Endnote.php | 12 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 12 +- src/PhpWord/Writer/HTML/Element/Image.php | 12 +- src/PhpWord/Writer/HTML/Element/Link.php | 12 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 12 +- src/PhpWord/Writer/HTML/Element/PageBreak.php | 12 +- src/PhpWord/Writer/HTML/Element/Table.php | 12 +- src/PhpWord/Writer/HTML/Element/Text.php | 12 +- src/PhpWord/Writer/HTML/Element/TextBreak.php | 12 +- src/PhpWord/Writer/HTML/Element/TextRun.php | 12 +- src/PhpWord/Writer/HTML/Element/Title.php | 12 +- .../Writer/HTML/Style/AbstractStyle.php | 12 +- src/PhpWord/Writer/HTML/Style/Font.php | 12 +- src/PhpWord/Writer/HTML/Style/Generic.php | 12 +- src/PhpWord/Writer/HTML/Style/Image.php | 12 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 12 +- src/PhpWord/Writer/ODText.php | 12 +- src/PhpWord/Writer/ODText/Element/Element.php | 12 +- src/PhpWord/Writer/ODText/Element/Image.php | 12 +- src/PhpWord/Writer/ODText/Element/Link.php | 12 +- src/PhpWord/Writer/ODText/Element/Table.php | 12 +- src/PhpWord/Writer/ODText/Element/Text.php | 12 +- .../Writer/ODText/Element/TextBreak.php | 12 +- src/PhpWord/Writer/ODText/Element/TextRun.php | 12 +- .../Writer/ODText/Part/AbstractPart.php | 12 +- src/PhpWord/Writer/ODText/Part/Content.php | 12 +- src/PhpWord/Writer/ODText/Part/Manifest.php | 12 +- src/PhpWord/Writer/ODText/Part/Meta.php | 12 +- src/PhpWord/Writer/ODText/Part/Mimetype.php | 12 +- src/PhpWord/Writer/ODText/Part/Styles.php | 12 +- .../Writer/ODText/Style/AbstractStyle.php | 12 +- src/PhpWord/Writer/ODText/Style/Font.php | 12 +- src/PhpWord/Writer/ODText/Style/Paragraph.php | 12 +- src/PhpWord/Writer/PDF.php | 12 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 12 +- src/PhpWord/Writer/PDF/DomPDF.php | 12 +- src/PhpWord/Writer/RTF.php | 12 +- src/PhpWord/Writer/RTF/Element/Element.php | 12 +- src/PhpWord/Writer/RTF/Element/Text.php | 12 +- src/PhpWord/Writer/RTF/Element/TextBreak.php | 12 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 12 +- src/PhpWord/Writer/RTF/Element/Title.php | 12 +- src/PhpWord/Writer/Word2007.php | 12 +- .../Writer/Word2007/Element/CheckBox.php | 12 +- .../Writer/Word2007/Element/Element.php | 12 +- .../Writer/Word2007/Element/Endnote.php | 12 +- .../Writer/Word2007/Element/Footnote.php | 12 +- src/PhpWord/Writer/Word2007/Element/Image.php | 12 +- src/PhpWord/Writer/Word2007/Element/Link.php | 12 +- .../Writer/Word2007/Element/ListItem.php | 12 +- .../Writer/Word2007/Element/Object.php | 12 +- .../Writer/Word2007/Element/PageBreak.php | 12 +- .../Writer/Word2007/Element/PreserveText.php | 12 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 12 +- src/PhpWord/Writer/Word2007/Element/Table.php | 12 +- src/PhpWord/Writer/Word2007/Element/Text.php | 12 +- .../Writer/Word2007/Element/TextBox.php | 72 + .../Writer/Word2007/Element/TextBreak.php | 12 +- .../Writer/Word2007/Element/TextRun.php | 12 +- src/PhpWord/Writer/Word2007/Element/Title.php | 12 +- .../Writer/Word2007/Part/AbstractPart.php | 21 +- .../Writer/Word2007/Part/ContentTypes.php | 12 +- src/PhpWord/Writer/Word2007/Part/DocProps.php | 12 +- src/PhpWord/Writer/Word2007/Part/Document.php | 12 +- src/PhpWord/Writer/Word2007/Part/Endnotes.php | 12 +- .../Writer/Word2007/Part/FontTable.php | 12 +- src/PhpWord/Writer/Word2007/Part/Footer.php | 33 +- .../Writer/Word2007/Part/Footnotes.php | 12 +- src/PhpWord/Writer/Word2007/Part/Header.php | 47 +- .../Writer/Word2007/Part/Numbering.php | 12 +- src/PhpWord/Writer/Word2007/Part/Rels.php | 12 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 12 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 12 +- src/PhpWord/Writer/Word2007/Part/Theme.php | 12 +- .../Writer/Word2007/Part/WebSettings.php | 12 +- .../Writer/Word2007/Style/AbstractStyle.php | 12 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 12 +- src/PhpWord/Writer/Word2007/Style/Font.php | 12 +- src/PhpWord/Writer/Word2007/Style/Image.php | 12 +- .../Writer/Word2007/Style/Indentation.php | 12 +- .../Writer/Word2007/Style/LineNumbering.php | 12 +- .../Writer/Word2007/Style/MarginBorder.php | 12 +- .../Writer/Word2007/Style/Paragraph.php | 12 +- src/PhpWord/Writer/Word2007/Style/Section.php | 12 +- src/PhpWord/Writer/Word2007/Style/Shading.php | 12 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 12 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 12 +- src/PhpWord/Writer/Word2007/Style/Table.php | 12 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 198 ++ src/PhpWord/Writer/WriterInterface.php | 12 +- tests/PhpWord/Tests/AutoloaderTest.php | 12 +- .../Tests/Collection/CollectionTest.php | 40 + .../PhpWord/Tests/DocumentPropertiesTest.php | 12 +- .../Tests/Element/AbstractElementTest.php | 12 +- tests/PhpWord/Tests/Element/CellTest.php | 12 +- tests/PhpWord/Tests/Element/CheckBoxTest.php | 12 +- tests/PhpWord/Tests/Element/FooterTest.php | 12 +- tests/PhpWord/Tests/Element/FootnoteTest.php | 12 +- tests/PhpWord/Tests/Element/HeaderTest.php | 12 +- tests/PhpWord/Tests/Element/ImageTest.php | 12 +- tests/PhpWord/Tests/Element/LinkTest.php | 12 +- tests/PhpWord/Tests/Element/ListItemTest.php | 12 +- tests/PhpWord/Tests/Element/ObjectTest.php | 12 +- tests/PhpWord/Tests/Element/PageBreakTest.php | 12 +- .../Tests/Element/PreserveTextTest.php | 12 +- tests/PhpWord/Tests/Element/RowTest.php | 12 +- tests/PhpWord/Tests/Element/SectionTest.php | 12 +- tests/PhpWord/Tests/Element/TOCTest.php | 25 +- tests/PhpWord/Tests/Element/TableTest.php | 12 +- tests/PhpWord/Tests/Element/TextBoxTest.php | 74 + tests/PhpWord/Tests/Element/TextBreakTest.php | 12 +- tests/PhpWord/Tests/Element/TextRunTest.php | 14 +- tests/PhpWord/Tests/Element/TextTest.php | 12 +- tests/PhpWord/Tests/Element/TitleTest.php | 12 +- .../PhpWord/Tests/Exception/ExceptionTest.php | 12 +- .../Exception/InvalidImageExceptionTest.php | 12 +- .../Exception/InvalidStyleExceptionTest.php | 12 +- .../UnsupportedImageTypeExceptionTest.php | 12 +- tests/PhpWord/Tests/IOFactoryTest.php | 12 +- tests/PhpWord/Tests/MediaTest.php | 12 +- tests/PhpWord/Tests/PhpWordTest.php | 13 +- tests/PhpWord/Tests/Reader/ODTextTest.php | 12 +- tests/PhpWord/Tests/Reader/Word2007Test.php | 12 +- tests/PhpWord/Tests/SettingsTest.php | 12 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 12 +- tests/PhpWord/Tests/Shared/FontTest.php | 13 +- tests/PhpWord/Tests/Shared/StringTest.php | 12 +- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 12 +- tests/PhpWord/Tests/Shared/ZipArchiveTest.php | 12 +- .../PhpWord/Tests/Style/AbstractStyleTest.php | 12 +- tests/PhpWord/Tests/Style/CellTest.php | 12 +- tests/PhpWord/Tests/Style/FontTest.php | 12 +- tests/PhpWord/Tests/Style/ImageTest.php | 12 +- tests/PhpWord/Tests/Style/IndentationTest.php | 53 + .../PhpWord/Tests/Style/LineNumberingTest.php | 53 + tests/PhpWord/Tests/Style/ListItemTest.php | 12 +- .../Tests/Style/NumberingLevelTest.php | 12 +- tests/PhpWord/Tests/Style/NumberingTest.php | 61 + tests/PhpWord/Tests/Style/ParagraphTest.php | 12 +- tests/PhpWord/Tests/Style/RowTest.php | 12 +- tests/PhpWord/Tests/Style/SectionTest.php | 12 +- tests/PhpWord/Tests/Style/ShadingTest.php | 52 + tests/PhpWord/Tests/Style/SpacingTest.php | 53 + tests/PhpWord/Tests/Style/TOCTest.php | 40 +- tests/PhpWord/Tests/Style/TabTest.php | 52 + tests/PhpWord/Tests/Style/TableTest.php | 15 +- tests/PhpWord/Tests/Style/TabsTest.php | 47 - tests/PhpWord/Tests/Style/TextBoxTest.php | 305 ++ tests/PhpWord/Tests/StyleTest.php | 12 +- tests/PhpWord/Tests/TemplateTest.php | 12 +- tests/PhpWord/Tests/Writer/HTMLTest.php | 12 +- .../Writer/ODText/Part/AbstractPartTest.php | 12 +- .../Tests/Writer/ODText/Part/ContentTest.php | 12 +- .../Tests/Writer/ODText/Part/MetaTest.php | 12 +- .../Tests/Writer/ODText/Part/StylesTest.php | 12 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 12 +- tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 12 +- tests/PhpWord/Tests/Writer/PDFTest.php | 12 +- tests/PhpWord/Tests/Writer/RTFTest.php | 12 +- .../Writer/Word2007/Part/AbstractPartTest.php | 12 +- .../Writer/Word2007/Part/DocPropsTest.php | 12 +- .../Writer/Word2007/Part/DocumentTest.php | 12 +- .../Tests/Writer/Word2007/Part/FooterTest.php | 12 +- .../Writer/Word2007/Part/FootnotesTest.php | 12 +- .../Tests/Writer/Word2007/Part/HeaderTest.php | 12 +- .../Writer/Word2007/Part/NumberingTest.php | 12 +- .../Tests/Writer/Word2007/Part/StylesTest.php | 12 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 12 +- .../Tests/_includes/TestHelperDOCX.php | 12 +- tests/PhpWord/Tests/_includes/XmlDocument.php | 12 +- tests/bootstrap.php | 12 +- 267 files changed, 7550 insertions(+), 734 deletions(-) create mode 100644 .scrutinizer.yml create mode 100644 composer.lock create mode 100644 src/PhpWord/Element/TextBox.php delete mode 100644 src/PhpWord/Reader/Word2007/Notes.php create mode 100644 src/PhpWord/Style/TextBox.php create mode 100644 src/PhpWord/Writer/Word2007/Element/TextBox.php create mode 100644 src/PhpWord/Writer/Word2007/Style/TextBox.php create mode 100644 tests/PhpWord/Tests/Collection/CollectionTest.php create mode 100644 tests/PhpWord/Tests/Element/TextBoxTest.php create mode 100644 tests/PhpWord/Tests/Style/IndentationTest.php create mode 100644 tests/PhpWord/Tests/Style/LineNumberingTest.php create mode 100644 tests/PhpWord/Tests/Style/NumberingTest.php create mode 100644 tests/PhpWord/Tests/Style/ShadingTest.php create mode 100644 tests/PhpWord/Tests/Style/SpacingTest.php create mode 100644 tests/PhpWord/Tests/Style/TabTest.php delete mode 100644 tests/PhpWord/Tests/Style/TabsTest.php create mode 100644 tests/PhpWord/Tests/Style/TextBoxTest.php diff --git a/.gitignore b/.gitignore index eb0f06791d..016060632c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ .Trashes Thumbs.db Desktop.ini -composer.lock composer.phar phpunit.xml /.buildpath diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000000..0b0464f7b0 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,14 @@ +filter: + excluded_paths: [ 'vendor/*', 'tests/*', 'samples/*', 'src/PhpWord/Shared/PCLZip/*' ] + +before_commands: + - "composer self-update" + - "composer install --prefer-source --dev" + +tools: + php_code_coverage: + enabled: true + test_command: phpunit -c phpunit.xml.dist + php_sim: true + php_pdepend: true + php_analyzer: true diff --git a/.travis.yml b/.travis.yml index 65b9de9aa7..41e3bebb25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ script: ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs -i ./src/PhpWord/Shared/PCLZip/* + - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/PCLZip/*" --template="responsive-twig" after_script: ## PHPDocumentor diff --git a/CHANGELOG.md b/CHANGELOG.md index 794c47ee4e..19e6d9f914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. ### Bugfixes -- ... +- Header: All images added to the second header were assigned to the first header - @basjan GH-222 ### Deprecated @@ -26,6 +26,8 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 - QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin - Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin +- Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 +- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 ## 0.10.0 - 4 May 2014 diff --git a/README.md b/README.md index 5a8db0ef1b..21e18a7e00 100644 --- a/README.md +++ b/README.md @@ -7,40 +7,44 @@ [![License](https://poser.pugx.org/phpoffice/phpword/license.png)](https://packagist.org/packages/phpoffice/phpword) -PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF). +PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF), HTML, and PDF. + +PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/LICENSE.md). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/). + +## Features With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your PHP 5.3+ scripts. Below are some of the things that you can do with PHPWord library: -* Set document properties, e.g. title, subject, and creator. -* Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering -* Create header and footer for each sections -* Set default font type, font size, and paragraph style -* Use UTF-8 and East Asia fonts/characters -* Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text -* Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements -* Insert titles (headers) and table of contents -* Insert text breaks and page breaks -* Insert and format images, either local, remote, or as page watermarks -* Insert binary OLE Objects such as Excel or Visio -* Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan) -* Insert list items as bulleted, numbered, or multilevel -* Insert hyperlinks -* Insert footnotes and endnotes -* Create document from templates -* Use XSL 1.0 style sheets to transform main document part of OOXML template -* ... and many more features on progress - -__Want to contribute?__ [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us. +- Set document properties, e.g. title, subject, and creator. +- Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering +- Create header and footer for each sections +- Set default font type, font size, and paragraph style +- Use UTF-8 and East Asia fonts/characters +- Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text +- Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements +- Insert titles (headers) and table of contents +- Insert text breaks and page breaks +- Insert and format images, either local, remote, or as page watermarks +- Insert binary OLE Objects such as Excel or Visio +- Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan) +- Insert list items as bulleted, numbered, or multilevel +- Insert hyperlinks +- Insert footnotes and endnotes +- Create document from templates +- Use XSL 1.0 style sheets to transform main document part of OOXML template +- ... and many more features on progress ## Requirements -* PHP 5.3+ -* PHP [Zip](http://php.net/manual/en/book.zip.php) extension -* PHP [XML Parser](http://www.php.net/manual/en/xml.installation.php) extension -### Optional PHP extensions -* PHP [GD](http://php.net/manual/en/book.image.php) extension -* PHP [XMLWriter](http://php.net/manual/en/book.xmlwriter.php) extension -* PHP [XSL](http://php.net/manual/en/book.xsl.php) extension +PHPWord requires the following: + +- PHP 5.3+ +- [Zip extension](http://php.net/manual/en/book.zip.php) +- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php) +- [GD extension](http://php.net/manual/en/book.image.php) (optional, used to add images) +- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write DOCX and ODT) +- [XSL extension](http://php.net/manual/en/book.xsl.php) (optional, used to apply XSL style sheet to template ) +- [dompdf](https://github.com/dompdf/dompdf) (optional, used to write PDF) ## Installation @@ -63,7 +67,7 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); ``` -## Basic usage +## Usages The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/). @@ -107,6 +111,11 @@ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); $objWriter->save('helloWorld.rtf'); ``` -## Documentation +## Contributing + +We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: -__Want to know more?__ Read the full documentation of PHPWord on [Read The Docs](http://phpword.readthedocs.org/). +- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md) +- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch +- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub +- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter diff --git a/composer.json b/composer.json index 20aca17b52..8396f07375 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "homepage": "http://phpoffice.github.io", "type": "library", - "license": "LGPL", + "license": "LGPL-3.0", "authors": [ { "name": "Mark Baker" diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000000..6d63264a83 --- /dev/null +++ b/composer.lock @@ -0,0 +1,3107 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "6daefa91649add98af3850b0a3f13415", + "packages": [ + + ], + "packages-dev": [ + { + "name": "cilex/cilex", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/Cilex/Cilex.git", + "reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Cilex/Cilex/zipball/7acd965a609a56d0345e8b6071c261fbdb926cb5", + "reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5", + "shasum": "" + }, + "require": { + "cilex/console-service-provider": "1.*", + "php": ">=5.3.3", + "pimple/pimple": "~1.0", + "symfony/finder": "~2.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*", + "symfony/validator": "~2.1" + }, + "suggest": { + "monolog/monolog": ">=1.0.0", + "symfony/validator": ">=1.0.0", + "symfony/yaml": ">=1.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Cilex": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "description": "The PHP micro-framework for Command line tools based on the Symfony2 Components", + "homepage": "http://cilex.github.com", + "keywords": [ + "cli", + "microframework" + ], + "time": "2014-03-29 14:03:13" + }, + { + "name": "cilex/console-service-provider", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Cilex/console-service-provider.git", + "reference": "25ee3d1875243d38e1a3448ff94bdf944f70d24e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Cilex/console-service-provider/zipball/25ee3d1875243d38e1a3448ff94bdf944f70d24e", + "reference": "25ee3d1875243d38e1a3448ff94bdf944f70d24e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "pimple/pimple": "1.*@dev", + "symfony/console": "~2.1" + }, + "require-dev": { + "cilex/cilex": "1.*@dev", + "silex/silex": "1.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Cilex\\Provider\\Console": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Beau Simensen", + "email": "beau@dflydev.com", + "homepage": "http://beausimensen.com" + }, + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "description": "Console Service Provider", + "keywords": [ + "cilex", + "console", + "pimple", + "service-provider", + "silex" + ], + "time": "2012-12-19 10:50:58" + }, + { + "name": "doctrine/annotations", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/40db0c96985aab2822edbc4848b3bd2429e02670", + "reference": "40db0c96985aab2822edbc4848b3bd2429e02670", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan H. Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/", + "role": "Creator" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2013-06-16 21:33:03" + }, + { + "name": "doctrine/lexer", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2013-01-12 18:59:04" + }, + { + "name": "dompdf/dompdf", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/dompdf.git", + "reference": "cf7d8a0a27270418850cc7d7ea532159e5eeb3eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/cf7d8a0a27270418850cc7d7ea532159e5eeb3eb", + "reference": "cf7d8a0a27270418850cc7d7ea532159e5eeb3eb", + "shasum": "" + }, + "require": { + "phenx/php-font-lib": "0.2.*" + }, + "type": "library", + "autoload": { + "classmap": [ + "include/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Fabien Ménager", + "email": "fabien.menager@gmail.com" + }, + { + "name": "Brian Sweeney", + "email": "eclecticgeek@gmail.com" + } + ], + "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", + "homepage": "https://github.com/dompdf/dompdf", + "time": "2014-03-11 01:59:52" + }, + { + "name": "erusev/parsedown", + "version": "0.9.4", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown.git", + "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/d29ff18299210b52a75a631a70963e7c8b35b04f", + "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "time": "2014-02-06 12:16:14" + }, + { + "name": "jms/metadata", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/metadata.git", + "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/88ffa28bc987e4c26229fc84a2e541b6ed4e1459", + "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "doctrine/cache": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Metadata\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Class/method/property metadata management in PHP", + "keywords": [ + "annotations", + "metadata", + "xml", + "yaml" + ], + "time": "2013-11-05 23:02:36" + }, + { + "name": "jms/parser-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/parser-lib.git", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "shasum": "" + }, + "require": { + "phpoption/phpoption": ">=0.9,<2.0-dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "description": "A library for easily creating recursive-descent parsers.", + "time": "2012-11-18 18:08:43" + }, + { + "name": "jms/serializer", + "version": "0.16.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/serializer.git", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/c8a171357ca92b6706e395c757f334902d430ea9", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "jms/metadata": "~1.1", + "jms/parser-lib": "1.*", + "php": ">=5.3.2", + "phpcollection/phpcollection": "~0.1" + }, + "require-dev": { + "doctrine/orm": "~2.1", + "doctrine/phpcr-odm": "~1.0.1", + "jackalope/jackalope-doctrine-dbal": "1.0.*", + "propel/propel1": "~1.7", + "symfony/filesystem": "2.*", + "symfony/form": "~2.1", + "symfony/translation": "~2.0", + "symfony/validator": "~2.0", + "symfony/yaml": "2.*", + "twig/twig": ">=1.8,<2.0-dev" + }, + "suggest": { + "symfony/yaml": "Required if you'd like to serialize data to YAML format." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.15-dev" + } + }, + "autoload": { + "psr-0": { + "JMS\\Serializer": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.", + "homepage": "http://jmsyst.com/libs/serializer", + "keywords": [ + "deserialization", + "jaxb", + "json", + "serialization", + "xml" + ], + "time": "2014-03-18 08:39:00" + }, + { + "name": "knplabs/knp-menu", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/KnpMenu.git", + "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/KnpMenu/zipball/f8e867268f63f561c1adadd6cbb5d8524f921873", + "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "pimple/pimple": "*", + "silex/silex": "1.0.*", + "twig/twig": ">=1.2,<2.0-dev" + }, + "suggest": { + "pimple/pimple": "for the built-in implementations of the menu provider and renderer provider", + "silex/silex": "for the integration with your silex application", + "twig/twig": "for the TwigRenderer and the integration with your templates" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Knp\\Menu\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christophe Coevoet", + "email": "stof@notk.org" + }, + { + "name": "KnpLabs", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/KnpLabs/KnpMenu/contributors" + } + ], + "description": "An object oriented menu library", + "homepage": "http://knplabs.com", + "keywords": [ + "menu", + "tree" + ], + "time": "2012-06-10 16:20:40" + }, + { + "name": "monolog/monolog", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "65026b610f8c19e61d7242f600530677b0466aac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/65026b610f8c19e61d7242f600530677b0466aac", + "reference": "65026b610f8c19e61d7242f600530677b0466aac", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "require-dev": { + "aws/aws-sdk-php": "~2.4, >2.4.8", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "phpunit/phpunit": "~3.7.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be", + "role": "Developer" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2014-04-24 13:29:03" + }, + { + "name": "nikic/php-parser", + "version": "v0.9.4", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "autoload": { + "psr-0": { + "PHPParser": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2013-08-25 17:11:40" + }, + { + "name": "phenx/php-font-lib", + "version": "0.2.2", + "source": { + "type": "git", + "url": "https://github.com/PhenX/php-font-lib.git", + "reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82", + "reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "classes/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Fabien Ménager", + "email": "fabien.menager@gmail.com" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/PhenX/php-font-lib", + "time": "2014-02-01 15:22:28" + }, + { + "name": "phpcollection/phpcollection", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-collection.git", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/b8bf55a0a929ca43b01232b36719f176f86c7e83", + "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83", + "shasum": "" + }, + "require": { + "phpoption/phpoption": "1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpCollection": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "General-Purpose Collection Library for PHP", + "keywords": [ + "collection", + "list", + "map", + "sequence", + "set" + ], + "time": "2014-03-11 13:46:42" + }, + { + "name": "phpdocumentor/fileset", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/Fileset.git", + "reference": "bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/Fileset/zipball/bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0", + "reference": "bfa78d8fa9763dfce6d0e5d3730c1d8ab25d34b0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/finder": "~2.1" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Fileset component for collecting a set of files given directories and file paths", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "files", + "fileset", + "phpdoc" + ], + "time": "2013-08-06 21:07:42" + }, + { + "name": "phpdocumentor/graphviz", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/GraphViz.git", + "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/GraphViz/zipball/13595130b9bc185109f40f1b70f0b231f490f5fc", + "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-02-26 17:45:01" + }, + { + "name": "phpdocumentor/phpdocumentor", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/phpDocumentor2.git", + "reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/d7503ada7386aa6b2956224d50a8d0226a22a99f", + "reference": "d7503ada7386aa6b2956224d50a8d0226a22a99f", + "shasum": "" + }, + "require": { + "cilex/cilex": "~1.0", + "dompdf/dompdf": "~0.6", + "erusev/parsedown": "~0.7", + "jms/serializer": "~0.12", + "knplabs/knp-menu": "~1.1", + "monolog/monolog": "~1.6", + "php": ">=5.3.3", + "phpdocumentor/fileset": "~1.0", + "phpdocumentor/graphviz": "~1.0", + "phpdocumentor/reflection": "~1.0", + "phpdocumentor/reflection-docblock": "~2.0", + "phpdocumentor/template-abstract": "~1.2", + "phpdocumentor/template-checkstyle": "~1.2", + "phpdocumentor/template-clean": "~1.0", + "phpdocumentor/template-new-black": "~1.3", + "phpdocumentor/template-old-ocean": "~1.3", + "phpdocumentor/template-responsive": "~1.3", + "phpdocumentor/template-responsive-twig": "~1.2", + "phpdocumentor/template-xml": "~1.0", + "phpdocumentor/template-zend": "~1.3", + "symfony/config": "~2.3", + "symfony/console": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/process": "~2.0", + "symfony/stopwatch": "~2.3", + "symfony/validator": "~2.2", + "twig/twig": "~1.3", + "zendframework/zend-cache": "2.1.*", + "zendframework/zend-config": "2.1.*", + "zendframework/zend-filter": "2.1.*", + "zendframework/zend-i18n": "2.1.*", + "zendframework/zend-serializer": "2.1.*", + "zendframework/zend-servicemanager": "2.1.*", + "zendframework/zend-stdlib": "2.1.*", + "zetacomponents/document": ">=1.3.1" + }, + "require-dev": { + "behat/behat": "~2.4", + "mikey179/vfsstream": "~1.2", + "mockery/mockery": ">=0.8.0", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "~1.4", + "symfony/expression-language": "~2.4" + }, + "suggest": { + "ext-twig": "Enabling the twig extension improves the generation of twig based templates.", + "ext-xslcache": "Enabling the XSLCache extension improves the generation of xml based templates." + }, + "bin": [ + "bin/phpdoc.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Documentation Generator for PHP", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "api", + "application", + "dga", + "documentation", + "phpdoc" + ], + "time": "2014-04-01 18:14:51" + }, + { + "name": "phpdocumentor/reflection", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/Reflection.git", + "reference": "df82db631acd60739c8796b3c6d5e4da970808f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/df82db631acd60739c8796b3c6d5e4da970808f3", + "reference": "df82db631acd60739c8796b3c6d5e4da970808f3", + "shasum": "" + }, + "require": { + "nikic/php-parser": "0.9.4", + "php": ">=5.3.3", + "phpdocumentor/reflection-docblock": "2.*", + "psr/log": "~1.0" + }, + "require-dev": { + "behat/behat": "~2.4", + "mockery/mockery": ">=0.7.0", + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/", + "tests/unit/", + "tests/mocks/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Reflection library to do Static Analysis for PHP Projects", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2014-03-28 11:20:22" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "0bca477a34baea39add016af90046f002a175619" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0bca477a34baea39add016af90046f002a175619", + "reference": "0bca477a34baea39add016af90046f002a175619", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "suggest": { + "dflydev/markdown": "1.0.*", + "erusev/parsedown": "~0.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-03-28 09:21:30" + }, + { + "name": "phpdocumentor/template-abstract", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.abstract.git", + "reference": "43fa2db351d7a150803397721e778f9dd8a20b47" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.abstract/zipball/43fa2db351d7a150803397721e778f9dd8a20b47", + "reference": "43fa2db351d7a150803397721e778f9dd8a20b47", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Simple bright template for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:11:13" + }, + { + "name": "phpdocumentor/template-checkstyle", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.checkstyle.git", + "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.checkstyle/zipball/22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", + "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Checkstyle XML output template for phpDocumentor2", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-01 19:43:19" + }, + { + "name": "phpdocumentor/template-clean", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.clean.git", + "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.clean/zipball/78f2048c5ecd62f0b79dbac093687d78a66d1806", + "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A clean, responsive modern template for phpDocumentor for Twig aimed at usability", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "responsive", + "template" + ], + "time": "2014-03-29 08:22:15" + }, + { + "name": "phpdocumentor/template-new-black", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.new_black.git", + "reference": "be38beba2b2674be292f32f88efe8a60c658a139" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.new_black/zipball/be38beba2b2674be292f32f88efe8a60c658a139", + "reference": "be38beba2b2674be292f32f88efe8a60c658a139", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/template-abstract": "1.*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Web 2.0 template with dark sidebar for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:16:30" + }, + { + "name": "phpdocumentor/template-old-ocean", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.old_ocean.git", + "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.old_ocean/zipball/3a0e2bcced4045a694d53b4607aad04e99d78489", + "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Blue template with high contrast for the foreground", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-02 06:21:07" + }, + { + "name": "phpdocumentor/template-responsive", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.responsive.git", + "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive/zipball/26f895a2ed3148e1686ae4d802f65a3ef04c04e1", + "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Responsive modern template for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2014-03-29 08:55:54" + }, + { + "name": "phpdocumentor/template-responsive-twig", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.responsive-twig.git", + "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive-twig/zipball/cd6d82be6a4626d865fd01d40aad170cea08db0a", + "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Responsive modern template for phpDocumentor for Twig", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2014-03-30 21:02:00" + }, + { + "name": "phpdocumentor/template-xml", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/mvriel/template.xml.git", + "reference": "a372713be8ee99b16497e2580592e474ff51190c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mvriel/template.xml/zipball/a372713be8ee99b16497e2580592e474ff51190c", + "reference": "a372713be8ee99b16497e2580592e474ff51190c", + "shasum": "" + }, + "require": { + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Generates an XML representation of the project's structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "documentation", + "phpdoc", + "template" + ], + "time": "2013-08-01 20:23:32" + }, + { + "name": "phpdocumentor/template-zend", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/template.zend.git", + "reference": "75913288bfd73d3bf4c1b1179c3963f3431e7a9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/template.zend/zipball/75913288bfd73d3bf4c1b1179c3963f3431e7a9d", + "reference": "75913288bfd73d3bf4c1b1179c3963f3431e7a9d", + "shasum": "" + }, + "require": { + "ext-xsl": "*", + "phpdocumentor/template-abstract": "1.*", + "phpdocumentor/unified-asset-installer": "~1.1" + }, + "type": "phpdocumentor-template", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Official Zend Framework Template for phpDocumentor2", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "ZendFramework", + "documentation", + "phpdoc", + "template", + "zend", + "zf" + ], + "time": "2013-12-05 08:51:57" + }, + { + "name": "phpdocumentor/unified-asset-installer", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/UnifiedAssetInstaller.git", + "reference": "241fb036268cd9da7d76da3db66e3eda66259c52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/UnifiedAssetInstaller/zipball/241fb036268cd9da7d76da3db66e3eda66259c52", + "reference": "241fb036268cd9da7d76da3db66e3eda66259c52", + "shasum": "" + }, + "require": { + "composer-plugin-api": "1.0.0" + }, + "require-dev": { + "composer/composer": "~1.0@dev", + "phpunit/phpunit": "~3.7" + }, + "type": "composer-installer", + "extra": { + "class": "\\phpDocumentor\\Composer\\UnifiedAssetInstaller" + }, + "autoload": { + "psr-0": { + "phpDocumentor\\Composer": [ + "src/", + "test/unit/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Asset installer for phpDocumentor", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "assets", + "installer", + "plugins", + "templates" + ], + "time": "2013-09-09 06:13:02" + }, + { + "name": "phpoption/phpoption", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "reference": "5d099bcf0393908bf4ad69cc47dafb785d51f7f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpOption\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "http://jmsyst.com", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "time": "2014-01-09 22:37:17" + }, + { + "name": "phpunit/php-code-coverage", + "version": "1.2.17", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": ">=1.3.0@stable", + "phpunit/php-text-template": ">=1.2.0@stable", + "phpunit/php-token-stream": ">=1.1.3@stable" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-03-28 10:53:45" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-03-03 05:10:30" + }, + { + "name": "phpunit/phpunit", + "version": "3.7.37", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~1.2", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.1", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~1.2", + "symfony/yaml": "~2.0" + }, + "require-dev": { + "pear-pear.php.net/pear": "1.9.4" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "composer/bin/phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-04-30 12:24:19" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-text-template": ">=1.1.1@stable" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHPUnit/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2013-01-13 10:24:48" + }, + { + "name": "pimple/pimple", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Pimple.git", + "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d", + "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2013-11-22 08:30:29" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "symfony/config", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "2effc67af6f21a0d267210b72d0b0b691d113528" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/2effc67af6f21a0d267210b72d0b0b691d113528", + "reference": "2effc67af6f21a0d267210b72d0b0b691d113528", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com", + "time": "2014-04-22 08:11:06" + }, + { + "name": "symfony/console", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "2e452005b1e1d003d23702d227e23614679eb5ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/2e452005b1e1d003d23702d227e23614679eb5ca", + "reference": "2e452005b1e1d003d23702d227e23614679eb5ca", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.4.4", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "e539602e5455aa086c0e81e604745af7789e4d8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e539602e5455aa086c0e81e604745af7789e4d8a", + "reference": "e539602e5455aa086c0e81e604745af7789e4d8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~2.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2014-04-16 10:34:31" + }, + { + "name": "symfony/filesystem", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a3af8294bcce4a7c1b2892363b0c9d8109affad4", + "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2014-04-16 10:34:31" + }, + { + "name": "symfony/finder", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/25e1e7d5e7376f8a92ae3b1d714d956edf33a730", + "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/process", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", + "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/property-access", + "version": "v2.4.4", + "target-dir": "Symfony/Component/PropertyAccess", + "source": { + "type": "git", + "url": "https://github.com/symfony/PropertyAccess.git", + "reference": "0456222bc00c40c1365065b603f7c397fb9a7134" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/0456222bc00c40c1365065b603f7c397fb9a7134", + "reference": "0456222bc00c40c1365065b603f7c397fb9a7134", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\PropertyAccess\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony PropertyAccess Component", + "homepage": "http://symfony.com", + "keywords": [ + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" + ], + "time": "2014-04-18 20:37:09" + }, + { + "name": "symfony/stopwatch", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Stopwatch", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/343bcc0360f2c22f371884b8f6a9fee8d1aa431a", + "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:37:09" + }, + { + "name": "symfony/translation", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Translation", + "source": { + "type": "git", + "url": "https://github.com/symfony/Translation.git", + "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Translation/zipball/d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", + "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.0", + "symfony/yaml": "~2.2" + }, + "suggest": { + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 21:02:05" + }, + { + "name": "symfony/validator", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Validator", + "source": { + "type": "git", + "url": "https://github.com/symfony/Validator.git", + "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Validator/zipball/5bbcdcc520bc7fb3826abb44020880f14c9c03a7", + "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/property-access": "~2.2", + "symfony/translation": "~2.0" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.0", + "symfony/config": "~2.2", + "symfony/http-foundation": "~2.1", + "symfony/intl": "~2.3", + "symfony/yaml": "~2.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Validator\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Validator Component", + "homepage": "http://symfony.com", + "time": "2014-04-27 13:34:57" + }, + { + "name": "symfony/yaml", + "version": "v2.4.4", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/65539ecde838f9c0d18b006b2101e3deb4b5c9ff", + "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:37:09" + }, + { + "name": "twig/twig", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Twig.git", + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher2", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2014-02-13 10:19:29" + }, + { + "name": "zendframework/zend-cache", + "version": "2.1.6", + "target-dir": "Zend/Cache", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendCache.git", + "reference": "560355160f06cdc3ef549a7eef843af3bead7e39" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendCache/zipball/560355160f06cdc3ef549a7eef843af3bead7e39", + "reference": "560355160f06cdc3ef549a7eef843af3bead7e39", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "zendframework/zend-serializer": "self.version" + }, + "suggest": { + "ext-apc": "APC >= 3.1.6 to use the APC storage adapter", + "ext-dba": "DBA, to use the DBA storage adapter", + "ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter", + "ext-wincache": "WinCache, to use the WinCache storage adapter", + "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-session": "Zend\\Session component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a generic way to cache any data", + "keywords": [ + "cache", + "zf2" + ], + "time": "2014-03-03 23:00:17" + }, + { + "name": "zendframework/zend-config", + "version": "2.1.6", + "target-dir": "Zend/Config", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendConfig.git", + "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendConfig/zipball/a31c3980cf7ec88418a931e9cf4ba21079f47a08", + "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-json": "Zend\\Json to use the Json reader or writer classes", + "zendframework/zend-servicemanager": "Zend\\ServiceManager for use with the Config Factory to retrieve reader and writer instances" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a nested object property based user interface for accessing this configuration data within application code", + "keywords": [ + "config", + "zf2" + ], + "time": "2014-01-02 18:00:10" + }, + { + "name": "zendframework/zend-eventmanager", + "version": "2.1.6", + "target-dir": "Zend/EventManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendEventManager.git", + "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/89368704bb37303fba64c3ddd6bce0506aa7187c", + "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\EventManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "eventmanager", + "zf2" + ], + "time": "2014-01-04 13:00:14" + }, + { + "name": "zendframework/zend-filter", + "version": "2.1.6", + "target-dir": "Zend/Filter", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendFilter.git", + "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/8ceece474b29d079e86976dbd3efffe6064b3d72", + "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "zendframework/zend-crypt": "self.version" + }, + "suggest": { + "zendframework/zend-crypt": "Zend\\Crypt component", + "zendframework/zend-i18n": "Zend\\I18n component", + "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter", + "zendframework/zend-validator": "Zend\\Validator component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Filter\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a set of commonly needed data filters", + "keywords": [ + "filter", + "zf2" + ], + "time": "2014-03-03 21:00:06" + }, + { + "name": "zendframework/zend-i18n", + "version": "2.1.6", + "target-dir": "Zend/I18n", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendI18n.git", + "reference": "10f56e0869761d62699782e4dd04eb77262cc353" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendI18n/zipball/10f56e0869761d62699782e4dd04eb77262cc353", + "reference": "10f56e0869761d62699782e4dd04eb77262cc353", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "ext-intl": "Required for most features of Zend\\I18n; included in default builds of PHP", + "zendframework/zend-eventmanager": "You should install this package to use the events in the translator", + "zendframework/zend-filter": "You should install this package to use the provided filters", + "zendframework/zend-resources": "Translation resources", + "zendframework/zend-validator": "You should install this package to use the provided validators", + "zendframework/zend-view": "You should install this package to use the provided view helpers" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\I18n\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "i18n", + "zf2" + ], + "time": "2014-01-04 13:00:19" + }, + { + "name": "zendframework/zend-json", + "version": "2.1.6", + "target-dir": "Zend/Json", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendJson.git", + "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendJson/zipball/dd8a8239a7c08c7449a6ea219da3e2369bd90d92", + "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-server": "Zend\\Server component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Json\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", + "keywords": [ + "json", + "zf2" + ], + "time": "2014-03-06 18:00:05" + }, + { + "name": "zendframework/zend-math", + "version": "2.1.6", + "target-dir": "Zend/Math", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendMath.git", + "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendMath/zipball/b982ee2edafd4075b22372596ab2e2fdd0f6424e", + "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-bcmath": "If using the bcmath functionality", + "ext-gmp": "If using the gmp functionality", + "ircmaxell/random-lib": "Fallback random byte generator for Zend\\Math\\Rand if OpenSSL/Mcrypt extensions are unavailable", + "zendframework/zend-servicemanager": ">= current version, if using the BigInteger::factory functionality" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Math\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "math", + "zf2" + ], + "time": "2014-03-05 18:00:06" + }, + { + "name": "zendframework/zend-serializer", + "version": "2.1.6", + "target-dir": "Zend/Serializer", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendSerializer.git", + "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendSerializer/zipball/d76b931d3ffa842a496c9fa319bbe285b5ddfade", + "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-json": "self.version", + "zendframework/zend-math": "self.version", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "zendframework/zend-servicemanager": "To support plugin manager support" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Serializer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover", + "keywords": [ + "serializer", + "zf2" + ], + "time": "2014-01-02 18:00:26" + }, + { + "name": "zendframework/zend-servicemanager", + "version": "2.1.6", + "target-dir": "Zend/ServiceManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendServiceManager.git", + "reference": "de182a20dfdcf978c49570514103c7477ef16e4f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/de182a20dfdcf978c49570514103c7477ef16e4f", + "reference": "de182a20dfdcf978c49570514103c7477ef16e4f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "zendframework/zend-di": "Zend\\Di component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\ServiceManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "servicemanager", + "zf2" + ], + "time": "2014-03-03 21:00:04" + }, + { + "name": "zendframework/zend-stdlib", + "version": "2.1.6", + "target-dir": "Zend/Stdlib", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendStdlib.git", + "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/e646729f2274f4552b6a92e38d8e458efe08ebc5", + "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Stdlib\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2014-01-04 13:00:28" + }, + { + "name": "zetacomponents/base", + "version": "1.8", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Base.git", + "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zetacomponents/Base/zipball/52ca69c1de55f3fa4f595779e5bc831da7ee176c", + "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "apache2" + ], + "authors": [ + { + "name": "Sergey Alexeev" + }, + { + "name": "Sebastian Bergmann" + }, + { + "name": "Jan Borsodi" + }, + { + "name": "Raymond Bosman" + }, + { + "name": "Frederik Holljen" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Vadym Savchuk" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + } + ], + "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.", + "homepage": "https://github.com/zetacomponents", + "time": "2009-12-21 12:14:16" + }, + { + "name": "zetacomponents/document", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Document.git", + "reference": "688abfde573cf3fe0730f82538fbd7aa9fc95bc8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zetacomponents/Document/zipball/688abfde573cf3fe0730f82538fbd7aa9fc95bc8", + "reference": "688abfde573cf3fe0730f82538fbd7aa9fc95bc8", + "shasum": "" + }, + "require": { + "zetacomponents/base": "*" + }, + "require-dev": { + "zetacomponents/unit-test": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Sebastian Bergmann" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + } + ], + "description": "The Document components provides a general conversion framework for different semantic document markup languages like XHTML, Docbook, RST and similar.", + "homepage": "https://github.com/zetacomponents", + "time": "2013-12-19 11:40:00" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.3.3", + "ext-xml": "*", + "ext-zip": "*" + }, + "platform-dev": [ + + ] +} diff --git a/docs/intro.rst b/docs/intro.rst index 3c2a47bde5..25a5020521 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -12,18 +12,14 @@ Applications `__ (OpenDocument or ODF), and `Rich Text Format `__ (RTF). -No Windows operating system is needed for usage because the resulting -DOCX, ODT, or RTF files can be opened by all major `word processing -softwares `__. - -PHPWord is an open source project licensed under LGPL version 3. PHPWord is `unit -tested `__ to make sure that -the released versions are stable. - -**Want to contribute?** `Fork -us `__ or -`submit `__ your bug -reports or feature requests to us. +PHPWord is an open source project licensed under the terms of `LGPL +version 3 `__. +PHPWord is aimed to be a high quality software product by incorporating +`continuous integration `__ and +`unit testing `__. +You can learn more about PHPWord by reading this Developers' +Documentation and the `API +Documentation `__. Features -------- @@ -180,3 +176,20 @@ Readers +---------------------------+----------------------+--------+-------+-------+ | | Protection | | | | +---------------------------+----------------------+--------+-------+-------+ + +Contributing +------------ + +We welcome everyone to contribute to PHPWord. Below are some of the +things that you can do to contribute: + +- Read `our contributing + guide `__ +- `Fork us `__ and `request + a pull `__ to the + `develop `__ + branch +- Submit `bug reports or feature + requests `__ to GitHub +- Follow `@PHPWord `__ and + `@PHPOffice `__ on Twitter diff --git a/docs/references.rst b/docs/references.rst index 4f19a8173a..20aa1ed061 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -3,11 +3,21 @@ References ========== +ISO/IEC 29500, Third edition, 2012-09-01 +--------------------- + +- `Part 1: Fundamentals and Markup Language Reference + `__ +- `Part 2: Open Packaging Conventions + `__ +- `Part 3: Markup Compatibility and Extensibility + `__ +- `Part 4: Transitional Migration Features + `__ + Formal specifications --------------------- -- `Office Open XML (OOXML) (ECMA-376) - Schema `__ - `Oasis OpenDocument Standard Version 1.2 `__ - `Rich Text Format (RTF) Specification, version diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 4ae1f50ec6..a140c5bae0 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -47,11 +47,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft [Office Open XML](http://en.wikipedia.org/wiki/Office_Open_XML) (OOXML or OpenXML), OASIS [Open Document Format for Office Applications](http://en.wikipedia.org/wiki/OpenDocument) (OpenDocument or ODF), and [Rich Text Format](http://en.wikipedia.org/wiki/Rich_Text_Format) (RTF). -No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major [word processing softwares](http://en.wikipedia.org/wiki/List_of_word_processors). - -PHPWord is an open source project licensed under LGPL version 3. PHPWord is [unit tested](https://travis-ci.org/PHPOffice/PHPWord) to make sure that the released versions are stable. - -**Want to contribute?** [Fork us](https://github.com/PHPOffice/PHPWord/fork) or [submit](https://github.com/PHPOffice/PHPWord/issues) your bug reports or feature requests to us. +PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/LICENSE.md). PHPWord is aimed to be a high quality software product by incorporating [continuous integration](https://travis-ci.org/PHPOffice/PHPWord) and [unit testing](http://phpoffice.github.io/PHPWord/coverage/develop/). You can learn more about PHPWord by reading this Developers' Documentation and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/). ## Features @@ -142,6 +138,15 @@ Below are the supported features for each file formats. | **Bonus** | Encryption | | | | | | Protection | | | | +## Contributing + +We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: + +- Read [our contributing guide](https://github.com/PHPOffice/PHPWord/blob/master/CONTRIBUTING.md) +- [Fork us](https://github.com/PHPOffice/PHPWord/fork) and [request a pull](https://github.com/PHPOffice/PHPWord/pulls) to the [develop](https://github.com/PHPOffice/PHPWord/tree/develop) branch +- Submit [bug reports or feature requests](https://github.com/PHPOffice/PHPWord/issues) to GitHub +- Follow [@PHPWord](https://twitter.com/PHPWord) and [@PHPOffice](https://twitter.com/PHPOffice) on Twitter + # Installing/configuring ## Requirements @@ -938,13 +943,18 @@ PHPWord requires PHP 5.3+ since 0.8, while PHPWord 0.6.3 from CodePlex can run w # References +## ISO/IEC 29500, Third edition, 2012-09-01 + +- [Part 1: Fundamentals and Markup Language Reference](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip) +- [Part 2: Open Packaging Conventions](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061796_ISO_IEC_29500-2_2012.zip) +- [Part 3: Markup Compatibility and Extensibility](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061797_ISO_IEC_29500-3_2012.zip) +- [Part 4: Transitional Migration Features](http://standards.iso.org/ittf/PubliclyAvailableStandards/c061798_ISO_IEC_29500-4_2012.zip) + ## Formal specifications -- [Office Open XML (OOXML) (ECMA-376) Schema](http://www.schemacentral.com/sc/ooxml/ss.html) -- [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html) -- [Rich Text Format (RTF) Specification, version 1.9.1](http://www.microsoft.com/en-us/download/details.aspx?id=10725) +- [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html) +- [Rich Text Format (RTF) Specification, version 1.9.1](http://www.microsoft.com/en-us/download/details.aspx?id=10725) ## Other resources -- [DocumentFormat.OpenXml.Wordprocessing Namespace on MSDN](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing%28v=office.14%29.aspx) - +- [DocumentFormat.OpenXml.Wordprocessing Namespace on MSDN](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing%28v=office.14%29.aspx) diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 8e05328697..0fd56edc0a 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -25,6 +25,7 @@ // Add header for all other pages $subsequent = $section->addHeader(); $subsequent->addText("Subsequent pages in Section 1 will Have this!"); +$subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80)); // Add footer $footer = $section->addFooter(); diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 784230650d..dd5209bf6d 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -31,6 +31,37 @@ $section->addText($text); } +//Absolute positioning +$section->addTextBreak(3); +$section->addText('Absolute positioning: see top right corner of page'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1.55) + ) +); + +//Relative positioning +$section->addTextBreak(3); +$section->addText('Relative positioning: Horizontal position center relative to column,'); +$section->addText('Vertical position top relative to line'); +$section->addImage( + 'resources/_mars.jpg', + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE, + 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, + 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_COLUMN, + 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE + ) +); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index 0688ffda57..6acfff21e5 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -1,9 +1,17 @@ $allContainers, 'Link' => $allContainers, @@ -355,7 +356,7 @@ private function checkElementDocPart() $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - + $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; return $inHeaderFooter ? $docPart . $docPartId : $docPart; } diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 9c0a48c49a..5ed5209ffd 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -1,9 +1,17 @@ type = self::EVEN; } + /** + * Add textbox element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\TextBox + * @todo Merge with the same function on Section + */ + public function addTextBox($style = null) + { + $textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($textbox); + + return $textbox; + } + /** * Add table element * diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index 79117d0adb..d59a10a5d0 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -1,9 +1,17 @@ addElement(new PageBreak()); } + /** + * Add textbox element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\TextBox + * @todo Merge with the same function on Footer + */ + public function addTextBox($style = null) + { + $textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($textbox); + + return $textbox; + } + /** * Add table element * diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index 3c8e6386e8..2ecb091d9b 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -1,9 +1,17 @@ container = 'textbox'; + $this->setDocPart($docPart, $docPartId); + $this->style = $this->setStyle(new TextBoxStyle(), $style); + } + + /** + * Get textbox style + * + * @return \PhpOffice\PhpWord\Style\TextBox + */ + public function getStyle() + { + return $this->style; + } +} \ No newline at end of file diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index d8157c02d4..02518373ed 100644 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -1,9 +1,17 @@ collection}"; + $collection = $phpWord->$getMethod()->getItems(); + + $xmlReader = new XMLReader(); + $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); + $nodes = $xmlReader->getElements('*'); + if ($nodes->length > 0) { + foreach ($nodes as $node) { + $id = $xmlReader->getAttribute('w:id', $node); + $type = $xmlReader->getAttribute('w:type', $node); + + // Avoid w:type "separator" and "continuationSeparator" + // Only look for or without w:type attribute + if (is_null($type) && array_key_exists($id, $collection)) { + $element = $collection[$id]; + $pNodes = $xmlReader->getElements('w:p/*', $node); + foreach ($pNodes as $pNode) { + $this->readRun($xmlReader, $pNode, $element, $this->collection); + } + $addMethod = "add{$this->element}"; + $phpWord->$addMethod($element); + } + } + } + } } diff --git a/src/PhpWord/Reader/Word2007/Notes.php b/src/PhpWord/Reader/Word2007/Notes.php deleted file mode 100644 index a213b7f154..0000000000 --- a/src/PhpWord/Reader/Word2007/Notes.php +++ /dev/null @@ -1,60 +0,0 @@ -type = ($this->type == 'endnotes') ? 'endnotes' : 'footnotes'; - $getMethod = 'get' . $this->type; - $collection = $phpWord->$getMethod()->getItems(); - - $xmlReader = new XMLReader(); - $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); - $nodes = $xmlReader->getElements('*'); - if ($nodes->length > 0) { - foreach ($nodes as $node) { - $id = $xmlReader->getAttribute('w:id', $node); - $type = $xmlReader->getAttribute('w:type', $node); - - // Avoid w:type "separator" and "continuationSeparator" - // Only look for or without w:type attribute - if (is_null($type) && array_key_exists($id, $collection)) { - $element = $collection[$id]; - $pNodes = $xmlReader->getElements('w:p/*', $node); - foreach ($pNodes as $pNode) { - $this->readRun($xmlReader, $pNode, $element, $this->type); - } - $addMethod = 'add' . ($this->type == 'endnotes' ? 'endnote' : 'footnote'); - $phpWord->$addMethod($element); - } - } - } - } -} diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index a45614924a..68a36d57ec 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -1,9 +1,17 @@ pattern = $value; + $enum = array(self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE, + self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS); + + $this->pattern = $this->setEnumVal($value, $enum, $this->pattern); return $this; } diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index 609ef5a058..9c9f3a8167 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -1,9 +1,17 @@ indent = 200; } /** diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index 6e44eeade9..4bbba164db 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -1,9 +1,17 @@ shading)) { return $this->shading->getFill(); + } else { + return null; } } diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php new file mode 100644 index 0000000000..7e83da6a05 --- /dev/null +++ b/src/PhpWord/Style/TextBox.php @@ -0,0 +1,641 @@ +setWrappingStyle(self::WRAPPING_STYLE_INLINE); + $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); + $this->setPosHorizontalRel(self::POSITION_RELATIVE_TO_CHAR); + $this->setPosVertical(self::POSITION_VERTICAL_TOP); + $this->setPosVerticalRel(self::POSITION_RELATIVE_TO_LINE); + } + + /** + * Get width + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set width + * + * @param int $value + */ + public function setWidth($value = null) + { + $this->width = $value; + } + + /** + * Get height + */ + public function getHeight() + { + return $this->height; + } + + /** + * Set height + * + * @param int $value + */ + public function setHeight($value = null) + { + $this->height = $value; + } + + /** + * Get alignment + */ + public function getAlign() + { + return $this->align; + } + + /** + * Set alignment + * + * @param string $value + */ + public function setAlign($value = null) + { + $this->align = $value; + } + + /** + * Get Margin Top + * + * @return int + */ + public function getMarginTop() + { + return $this->marginTop; + } + + /** + * Set Margin Top + * + * @param int $value + * @return self + */ + public function setMarginTop($value = null) + { + $this->marginTop = $value; + return $this; + } + + /** + * Get Margin Left + * + * @return int + */ + public function getMarginLeft() + { + return $this->marginLeft; + } + + /** + * Set Margin Left + * + * @param int $value + * @return self + */ + public function setMarginLeft($value = null) + { + $this->marginLeft = $value; + return $this; + } + + /** + * Get wrapping style + * + * @return string + */ + public function getWrappingStyle() + { + return $this->wrappingStyle; + } + + /** + * Set wrapping style + * + * @param string $wrappingStyle + * @throws \InvalidArgumentException + * @return self + */ + public function setWrappingStyle($wrappingStyle) + { + $enum = array(self::WRAPPING_STYLE_INLINE, self::WRAPPING_STYLE_INFRONT, self::WRAPPING_STYLE_BEHIND, + self::WRAPPING_STYLE_SQUARE, self::WRAPPING_STYLE_TIGHT); + + if (in_array($wrappingStyle, $enum)) { + $this->wrappingStyle = $wrappingStyle; + } else { + throw new \InvalidArgumentException('Invalid wrapping style.'); + } + + return $this; + } + + /** + * Get positioning type + * + * @return string + */ + public function getPositioning() + { + return $this->positioning; + } + + /** + * Set positioning type + * + * @param string $positioning + * @throws \InvalidArgumentException + * @return self + */ + public function setPositioning($positioning) + { + $enum = array(self::POSITION_RELATIVE, self::POSITION_ABSOLUTE); + + if (in_array($positioning, $enum)) { + $this->positioning = $positioning; + } else { + throw new \InvalidArgumentException('Invalid positioning.'); + } + + return $this; + } + + /** + * Get horizontal alignment + * + * @return string + */ + public function getPosHorizontal() + { + return $this->posHorizontal; + } + + /** + * Set horizontal alignment + * + * @param string $alignment + * @throws \InvalidArgumentException + * @return self + */ + public function setPosHorizontal($alignment) + { + $enum = array(self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, + self::POSITION_HORIZONTAL_RIGHT); + + if (in_array($alignment, $enum)) { + $this->posHorizontal = $alignment; + } else { + throw new \InvalidArgumentException('Invalid horizontal alignment.'); + } + + return $this; + } + + /** + * Get vertical alignment + * + * @return string + */ + public function getPosVertical() + { + return $this->posVertical; + } + + /** + * Set vertical alignment + * + * @param string $alignment + * @throws \InvalidArgumentException + * @return self + */ + public function setPosVertical($alignment) + { + $enum = array(self::POSITION_VERTICAL_TOP, self::POSITION_VERTICAL_CENTER, + self::POSITION_VERTICAL_BOTTOM, self::POSITION_VERTICAL_INSIDE, self::POSITION_VERTICAL_OUTSIDE); + + if (in_array($alignment, $enum)) { + $this->posVertical = $alignment; + } else { + throw new \InvalidArgumentException('Invalid vertical alignment.'); + } + + return $this; + } + + /** + * Get horizontal relation + * + * @return string + */ + public function getPosHorizontalRel() + { + return $this->posHorizontalRel; + } + + /** + * Set horizontal relation + * + * @param string $relto + * @throws \InvalidArgumentException + * @return self + */ + public function setPosHorizontalRel($relto) + { + $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + self::POSITION_RELATIVE_TO_COLUMN, self::POSITION_RELATIVE_TO_CHAR, + self::POSITION_RELATIVE_TO_LMARGIN, self::POSITION_RELATIVE_TO_RMARGIN, + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); + + if (in_array($relto, $enum)) { + $this->posHorizontalRel = $relto; + } else { + throw new \InvalidArgumentException('Invalid relative horizontal alignment.'); + } + + return $this; + } + + /** + * Get vertical relation + * + * @return string + */ + public function getPosVerticalRel() + { + return $this->posVerticalRel; + } + + /** + * Set vertical relation + * + * @param string $relto + * @throws \InvalidArgumentException + * @return self + */ + public function setPosVerticalRel($relto) + { + $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + self::POSITION_RELATIVE_TO_LINE, + self::POSITION_RELATIVE_TO_TMARGIN, self::POSITION_RELATIVE_TO_BMARGIN, + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); + + if (in_array($relto, $enum)) { + $this->posVerticalRel = $relto; + } else { + throw new \InvalidArgumentException('Invalid relative vertical alignment.'); + } + + return $this; + } + /** + * Set margin top + * + * @param int $value + */ + public function setInnerMarginTop($value = null) + { + $this->innerMarginTop = $value; + } + + /** + * Get margin top + * + * @return int + */ + public function getInnerMarginTop() + { + return $this->innerMarginTop; + } + + /** + * Set margin left + * + * @param int $value + */ + public function setInnerMarginLeft($value = null) + { + $this->innerMarginLeft = $value; + } + + /** + * Get margin left + * + * @return int + */ + public function getInnerMarginLeft() + { + return $this->innerMarginLeft; + } + + /** + * Set margin right + * + * @param int $value + */ + public function setInnerMarginRight($value = null) + { + $this->innerMarginRight = $value; + } + + /** + * Get margin right + * + * @return int + */ + public function getInnerMarginRight() + { + return $this->innerMarginRight; + } + + /** + * Set margin bottom + * + * @param int $value + */ + public function setInnerMarginBottom($value = null) + { + $this->innerMarginBottom = $value; + } + + /** + * Get margin bottom + * + * @return int + */ + public function getInnerMarginBottom() + { + return $this->innerMarginBottom; + } + + /** + * Set TLRB cell margin + * + * @param int $value Margin in twips + */ + public function setInnerMargin($value = null) + { + $this->setInnerMarginTop($value); + $this->setInnerMarginLeft($value); + $this->setInnerMarginRight($value); + $this->setInnerMarginBottom($value); + } + + /** + * Get cell margin + * + * @return int[] + */ + public function getInnerMargin() + { + return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom); + } + + /** + * Set border size + * + * @param int $value Size in points + */ + public function setBorderSize($value = null) + { + $this->borderSize = $value; + } + + /** + * Get border size + * + * @return int + */ + public function getBorderSize() + { + return $this->borderSize; + } + + /** + * Set border color + * + * @param string $value + */ + public function setBorderColor($value = null) + { + $this->borderColor = $value; + } + + /** + * Get border color + * + * @return string + */ + public function getBorderColor() + { + return $this->borderColor; + } +} \ No newline at end of file diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index bdc000c47f..97bd601ed6 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -1,9 +1,17 @@ element->getStyle(); + if ($tbxStyle instanceof TextBoxStyle) { + $styleWriter = new TextBoxStyleWriter($this->xmlWriter, $tbxStyle); + $styleWriter->write(); + } + + if (!$this->withoutP) { + $this->xmlWriter->startElement('w:p'); + if (!is_null($tbxStyle->getAlign())) { + $this->xmlWriter->startElement('w:pPr'); + $this->xmlWriter->startElement('w:jc'); + $this->xmlWriter->writeAttribute('w:val', $tbxStyle->getAlign()); + $this->xmlWriter->endElement(); // w:jc + $this->xmlWriter->endElement(); // w:pPr + } + } + + $this->xmlWriter->startElement('w:r'); + $this->xmlWriter->startElement('w:pict'); + $this->xmlWriter->startElement('v:shape'); + $this->xmlWriter->writeAttribute('type', '#_x0000_t0202'); + $styleWriter->write(); + $this->xmlWriter->startElement('v:textbox'); + $margins=implode(', ',$tbxStyle->getInnerMargin()); + $this->xmlWriter->writeAttribute('inset', $margins); + $this->xmlWriter->startElement('w:txbxContent'); + $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); + $this->xmlWriter->endElement(); // w:txbxContent + $this->xmlWriter->endElement(); // v: textbox + $styleWriter->writeW10Wrap(); + $this->xmlWriter->endElement(); // v:shape + $this->xmlWriter->endElement(); // w:pict + $this->xmlWriter->endElement(); // w:r + + if (!$this->withoutP) { + $this->xmlWriter->endElement(); // w:p + } + } +} \ No newline at end of file diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 67219f94eb..99dece43c5 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -1,9 +1,17 @@ array_merge($elmMainCell, array('Table', 'Footnote', 'Title', 'PageBreak', 'TOC')), - 'Header' => array_merge($elmMainCell, array('Table', 'PreserveText')), - 'Footer' => array_merge($elmMainCell, array('Table', 'PreserveText')), + 'Section' => array_merge($elmMainCell, array('Table', 'Footnote', 'Title', 'PageBreak', 'TOC', 'TextBox')), + 'Header' => array_merge($elmMainCell, array('Table', 'PreserveText', 'TextBox')), + 'Footer' => array_merge($elmMainCell, array('Table', 'PreserveText', 'TextBox')), 'Cell' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), + 'TextBox' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), 'TextRun' => array_merge($elmCommon, array('Footnote', 'Endnote')), 'Footnote' => $elmCommon, 'Endnote' => $elmCommon, @@ -96,7 +105,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co $containerName = get_class($container); $containerName = substr($containerName, strrpos($containerName, '\\') + 1); if (!array_key_exists($containerName, $allowedElements)) { - throw new Exception('Invalid container.'); + throw new Exception('Invalid container.'.$containerName. print_r($allowedElements, true)); } // Loop through elements diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 24df901146..73677d858d 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -1,9 +1,17 @@ getXmlWriter(); $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('w:ftr'); + $xmlWriter->startElement($this->rootElement); $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); @@ -37,9 +52,9 @@ public function writeFooter(FooterElement $footer) $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - $this->writeContainerElements($xmlWriter, $footer); + $this->writeContainerElements($xmlWriter, $element); - $xmlWriter->endElement(); // w:ftr + $xmlWriter->endElement(); // $this->rootElement return $xmlWriter->getData(); } diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 05bf17d190..42ea99058d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -1,9 +1,17 @@ getXmlWriter(); - - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('w:hdr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $this->writeContainerElements($xmlWriter, $header); - - $xmlWriter->endElement(); // w:hdr - - return $xmlWriter->getData(); + return $this->writeFooter($element); } } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 723a043f90..18c8f8f4d0 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -1,9 +1,17 @@ style instanceof \PhpOffice\PhpWord\Style\TextBox)) { + return; + } + + $wrapping = $this->style->getWrappingStyle(); + $positioning = $this->style->getPositioning(); + + // Default style array + $styleArray = array( + 'mso-width-percent' => '0', + 'mso-height-percent' => '0', + 'mso-width-relative' => 'margin', + 'mso-height-relative' => 'margin', + ); + $styleArray = array_merge($styleArray, $this->getElementStyle()); + + // Absolute/relative positioning + $styleArray['position'] = $positioning; + if ($positioning == TextBoxStyle::POSITION_ABSOLUTE) { + $styleArray['mso-position-horizontal-relative'] = 'page'; + $styleArray['mso-position-vertical-relative'] = 'page'; + } elseif ($positioning == TextBoxStyle::POSITION_RELATIVE) { + $styleArray['mso-position-horizontal'] = $this->style->getPosHorizontal(); + $styleArray['mso-position-vertical'] = $this->style->getPosVertical(); + $styleArray['mso-position-horizontal-relative'] = $this->style->getPosHorizontalRel(); + $styleArray['mso-position-vertical-relative'] = $this->style->getPosVerticalRel(); + $styleArray['margin-left'] = 0; + $styleArray['margin-top'] = 0; + } + + // Wrapping style + if ($wrapping == TextBoxStyle::WRAPPING_STYLE_INLINE) { + // Nothing to do when inline + } elseif ($wrapping == TextBoxStyle::WRAPPING_STYLE_BEHIND) { + $styleArray['z-index'] = -251658752; + } else { + $styleArray['z-index'] = 251659264; + $styleArray['mso-position-horizontal'] = 'absolute'; + $styleArray['mso-position-vertical'] = 'absolute'; + } + + // w10 wrapping + if ($wrapping == TextBoxStyle::WRAPPING_STYLE_SQUARE) { + $this->w10wrap = 'square'; + } elseif ($wrapping == TextBoxStyle::WRAPPING_STYLE_TIGHT) { + $this->w10wrap = 'tight'; + } + + $textboxStyle = $this->assembleStyle($styleArray); + + $this->xmlWriter->writeAttribute('style', $textboxStyle); + + $borderSize = $this->style->getBorderSize(); + if ($borderSize !== null) { + $this->xmlWriter->writeAttribute('strokeweight', $this->style->getBorderSize().'pt'); + } + + $borderColor = $this->style->getBorderColor(); + if (empty($borderColor)) { + $this->xmlWriter->writeAttribute('stroked', 'f'); + } else { + $this->xmlWriter->writeAttribute('strokecolor', $borderColor); + } + //@todo + + } + + /** + * Write w10 wrapping + * + * @return array + */ + public function writeW10Wrap() + { + if (!is_null($this->w10wrap)) { + $this->xmlWriter->startElement('w10:wrap'); + $this->xmlWriter->writeAttribute('type', $this->w10wrap); + + switch ($this->style->getPositioning()) { + case TextBoxStyle::POSITION_ABSOLUTE: + $this->xmlWriter->writeAttribute('anchorx', "page"); + $this->xmlWriter->writeAttribute('anchory', "page"); + break; + case TextBoxStyle::POSITION_RELATIVE: + switch ($this->style->getPosVerticalRel()) { + case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: + $this->xmlWriter->writeAttribute('anchory', "margin"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: + $this->xmlWriter->writeAttribute('anchory', "page"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_TMARGIN: + $this->xmlWriter->writeAttribute('anchory', "margin"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_BMARGIN: + $this->xmlWriter->writeAttribute('anchory', "page"); + break; + } + switch ($this->style->getPosHorizontalRel()) { + case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: + $this->xmlWriter->writeAttribute('anchorx', "margin"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: + $this->xmlWriter->writeAttribute('anchorx', "page"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_LMARGIN: + $this->xmlWriter->writeAttribute('anchorx', "margin"); + break; + case TextBoxStyle::POSITION_RELATIVE_TO_RMARGIN: + $this->xmlWriter->writeAttribute('anchorx', "page"); + break; + } + } + + $this->xmlWriter->endElement(); // w10:wrap + } + } + + /** + * Get element style + * + * @return array + */ + private function getElementStyle() + { + $styles = array(); + $styleValues = array( + 'width' => $this->style->getWidth(), + 'height' => $this->style->getHeight(), + 'margin-top' => $this->style->getMarginTop(), + 'margin-left' => $this->style->getMarginLeft() + ); + foreach ($styleValues as $key => $value) { + if (!is_null($value) && $value != '') { + $styles[$key] = $value . 'px'; + } + } + + return $styles; + } + + /** + * Assemble style array into style string + * + * @param array $styles + * @return string + */ + private function assembleStyle($styles = array()) + { + $style = ''; + foreach ($styles as $key => $value) { + if (!is_null($value) && $value != '') { + $style .= "{$key}:{$value}; "; + } + } + + return trim($style); + } +} diff --git a/src/PhpWord/Writer/WriterInterface.php b/src/PhpWord/Writer/WriterInterface.php index 3bc0c38da8..a56bcf8fd3 100644 --- a/src/PhpWord/Writer/WriterInterface.php +++ b/src/PhpWord/Writer/WriterInterface.php @@ -1,9 +1,17 @@ addItem(new Footnote()); // addItem #1 + + $this->assertEquals(2, $object->addItem(new Footnote())); // addItem #2. Should returns new item index + $this->assertEquals(2, $object->countItems()); // There are two items now + $this->assertEquals(2, count($object->getItems())); // getItems returns array + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $object->getItem(1)); // getItem returns object + $this->assertNull($object->getItem(3)); // getItem returns null when invalid index is referenced + + $object->setItem(2, null); // Set item #2 to null + + $this->assertNull($object->getItem(2)); // Check if it's null + } +} diff --git a/tests/PhpWord/Tests/DocumentPropertiesTest.php b/tests/PhpWord/Tests/DocumentPropertiesTest.php index 20545c1ec3..30b2a7bc48 100644 --- a/tests/PhpWord/Tests/DocumentPropertiesTest.php +++ b/tests/PhpWord/Tests/DocumentPropertiesTest.php @@ -1,9 +1,17 @@ assertEquals('Font Style', $object->getStyleFont()); } + /** + * Test when no PHPWord object is assigned: + */ + public function testNoPhpWord() + { + $object = new TOC(); + + $this->assertEmpty($object->getTitles()); + $this->assertNull($object->getPhpWord()); + } + /** * Set/get minDepth and maxDepth */ diff --git a/tests/PhpWord/Tests/Element/TableTest.php b/tests/PhpWord/Tests/Element/TableTest.php index b8325aca5f..1c87c2cf45 100644 --- a/tests/PhpWord/Tests/Element/TableTest.php +++ b/tests/PhpWord/Tests/Element/TableTest.php @@ -1,9 +1,17 @@ assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextBox', $oTextBox); + $this->assertEquals($oTextBox->getStyle(), null); + } + + /** + * Get style name + */ + public function testStyleText() + { + $oTextBox = new TextBox('section', 1, 'textBoxStyle'); + + $this->assertEquals($oTextBox->getStyle(), 'textBoxStyle'); + } + + /** + * Get style array + */ + public function testStyleArray() + { + $oTextBox = new TextBox( + 'section', + 1, + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4.5), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(17.5), + 'positioning' => 'absolute', + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.4), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(9.9), + 'stroke' => 0, + 'innerMargin' => 0, + 'borderSize' => 1, + 'borderColor' => '' + ) + ); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TextBox', $oTextBox->getStyle()); + } +} diff --git a/tests/PhpWord/Tests/Element/TextBreakTest.php b/tests/PhpWord/Tests/Element/TextBreakTest.php index 1ef33c6b7a..1d9479ee3e 100644 --- a/tests/PhpWord/Tests/Element/TextBreakTest.php +++ b/tests/PhpWord/Tests/Element/TextBreakTest.php @@ -1,9 +1,17 @@ array(0, 10), + 'right' => array(0, 10), + 'firstLine' => array(null, 20), + 'hanging' => array(null, 20), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/LineNumberingTest.php b/tests/PhpWord/Tests/Style/LineNumberingTest.php new file mode 100644 index 0000000000..bc4dc603f3 --- /dev/null +++ b/tests/PhpWord/Tests/Style/LineNumberingTest.php @@ -0,0 +1,53 @@ + array(1, 2), + 'increment' => array(1, 10), + 'distance' => array(null, 10), + 'restart' => array(null, 'continuous'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/ListItemTest.php b/tests/PhpWord/Tests/Style/ListItemTest.php index c6224d756f..a97c8dd604 100644 --- a/tests/PhpWord/Tests/Style/ListItemTest.php +++ b/tests/PhpWord/Tests/Style/ListItemTest.php @@ -1,9 +1,17 @@ object = new Numbering(); + $this->properties = array( + 'numId' => array(null, 1), + 'type' => array(null, 'singleLevel'), + ); + foreach ($this->properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $this->object->$get()); // Default value + + $this->object->$set($expected); + + $this->assertEquals($expected, $this->object->$get()); // New value + } + } + + /** + * Test get level + */ + public function testGetLevels() + { + $this->object = new Numbering(); + + $this->assertEmpty($this->object->getLevels()); + } +} diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index b51bd8ec16..357371c670 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -1,9 +1,17 @@ array('clear', 'solid'), + 'color' => array(null, 'FF0000'), + 'fill' => array(null, 'FF0000'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/SpacingTest.php b/tests/PhpWord/Tests/Style/SpacingTest.php new file mode 100644 index 0000000000..a4022b74bd --- /dev/null +++ b/tests/PhpWord/Tests/Style/SpacingTest.php @@ -0,0 +1,53 @@ + array(null, 10), + 'after' => array(null, 10), + 'line' => array(null, 10), + 'rule' => array('auto', 'exact'), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/TOCTest.php b/tests/PhpWord/Tests/Style/TOCTest.php index fd2a809e0d..e6e32e6b9d 100644 --- a/tests/PhpWord/Tests/Style/TOCTest.php +++ b/tests/PhpWord/Tests/Style/TOCTest.php @@ -1,9 +1,17 @@ 9062, - 'leader' => \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_DOT, - 'indent' => 200, + 'tabLeader' => array(TOC::TAB_LEADER_DOT, TOC::TAB_LEADER_UNDERSCORE), + 'tabPos' => array(9062, 10), + 'indent' => array(200, 10), ); - foreach ($properties as $key => $value) { - // set/get - $set = "set{$key}"; - $get = "get{$key}"; - $object->$set($value); - $this->assertEquals($value, $object->$get()); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value } } } diff --git a/tests/PhpWord/Tests/Style/TabTest.php b/tests/PhpWord/Tests/Style/TabTest.php new file mode 100644 index 0000000000..784b4e4709 --- /dev/null +++ b/tests/PhpWord/Tests/Style/TabTest.php @@ -0,0 +1,52 @@ + array(Tab::TAB_STOP_CLEAR, Tab::TAB_STOP_RIGHT), + 'leader' => array(Tab::TAB_LEADER_NONE, Tab::TAB_LEADER_DOT), + 'position' => array(0, 10), + ); + foreach ($properties as $property => $value) { + list($default, $expected) = $value; + $get = "get{$property}"; + $set = "set{$property}"; + + $this->assertEquals($default, $object->$get()); // Default value + + $object->$set($expected); + + $this->assertEquals($expected, $object->$get()); // New value + } + } +} diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index 76fd686441..a7b46c1f48 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -1,9 +1,17 @@ 'FF0000'); $styleFirstRow = array('borderBottomSize' => 3); + $object = new Table(); + $this->assertNull($object->getBgColor()); + $object = new Table($styleTable, $styleFirstRow); $this->assertEquals('FF0000', $object->getBgColor()); diff --git a/tests/PhpWord/Tests/Style/TabsTest.php b/tests/PhpWord/Tests/Style/TabsTest.php deleted file mode 100644 index 1b588168f6..0000000000 --- a/tests/PhpWord/Tests/Style/TabsTest.php +++ /dev/null @@ -1,47 +0,0 @@ -addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot')))); - $doc = TestHelperDOCX::getDocument($phpWord); - $file = 'word/styles.xml'; - $path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]'; - $element = $doc->getElement($path, $file); - $this->assertEquals('left', $element->getAttribute('w:val')); - $this->assertEquals(1440, $element->getAttribute('w:pos')); - $this->assertEquals('dot', $element->getAttribute('w:leader')); - } -} diff --git a/tests/PhpWord/Tests/Style/TextBoxTest.php b/tests/PhpWord/Tests/Style/TextBoxTest.php new file mode 100644 index 0000000000..cd2d86958d --- /dev/null +++ b/tests/PhpWord/Tests/Style/TextBoxTest.php @@ -0,0 +1,305 @@ + 200, + 'height' => 200, + 'align' => 'left', + 'marginTop' => 240, + 'marginLeft' => 240, + 'wrappingStyle' => 'inline', + 'positioning' => 'absolute', + 'posHorizontal' => 'center', + 'posVertical' => 'top', + 'posHorizontalRel' => 'margin', + 'posVerticalRel' => 'page', + 'innerMarginTop' => '5', + 'innerMarginRight' => '5', + 'innerMarginBottom' => '5', + 'innerMarginLeft' => '5', + 'borderSize' => '2', + 'borderColor' => 'red' + ); + foreach ($properties as $key => $value) { + $set = "set{$key}"; + $get = "get{$key}"; + $object->$set($value); + $this->assertEquals($value, $object->$get()); + } + } + + /** + * Test setStyleValue method + */ + public function testSetStyleValue() + { + $object = new TextBox(); + + $properties = array( + 'width' => 200, + 'height' => 200, + 'align' => 'left', + 'marginTop' => 240, + 'marginLeft' => 240, + 'wrappingStyle' => 'inline', + 'positioning' => 'absolute', + 'posHorizontal' => 'center', + 'posVertical' => 'top', + 'posHorizontalRel' => 'margin', + 'posVerticalRel' => 'page', + 'innerMarginTop' => '5', + 'innerMarginRight' => '5', + 'innerMarginBottom' => '5', + 'innerMarginLeft' => '5', + 'borderSize' => '2', + 'borderColor' => 'red' + ); + foreach ($properties as $key => $value) { + $get = "get{$key}"; + $object->setStyleValue("{$key}", $value); + $this->assertEquals($value, $object->$get()); + } + } + + /** + * Test setWrappingStyle exception + * + * @expectedException \InvalidArgumentException + */ + public function testSetWrappingStyleException() + { + $object = new TextBox(); + $object->setWrappingStyle('foo'); + } + + /** + * Test set/get width + */ + public function testSetGetWidth() + { + $expected=200; + $object = new TextBox(); + $object->setWidth($expected); + $this->assertEquals($expected, $object->getWidth()); + } + + /** + * Test set/get height + */ + public function testSetGetHeight() + { + $expected=200; + $object = new TextBox(); + $object->setHeight($expected); + $this->assertEquals($expected, $object->getHeight()); + } + + /** + * Test set/get height + */ + public function testSetGetAlign() + { + $expected='left'; + $object = new TextBox(); + $object->setAlign($expected); + $this->assertEquals($expected, $object->getAlign()); + } + + /** + * Test set/get marginTop + */ + public function testSetGetMarginTop() + { + $expected=5; + $object = new TextBox(); + $object->setMarginTop($expected); + $this->assertEquals($expected, $object->getMarginTop()); + } + + /** + * Test set/get marginLeft + */ + public function testSetGetMarginLeft() + { + $expected=5; + $object = new TextBox(); + $object->setMarginLeft($expected); + $this->assertEquals($expected, $object->getMarginLeft()); + } + /** + * Test set/get innerMarginTop + */ + public function testSetGetInnerMarginTop() + { + $expected=5; + $object = new TextBox(); + $object->setInnerMarginTop($expected); + $this->assertEquals($expected, $object->getInnerMarginTop()); + } + + /** + * Test set/get wrappingStyle + */ + public function testSetGetWrappingStyle() + { + $expected='inline'; + $object = new TextBox(); + $object->setWrappingStyle($expected); + $this->assertEquals($expected, $object->getWrappingStyle()); + } + + /** + * Test set/get positioning + */ + public function testSetGetPositioning() + { + $expected='absolute'; + $object = new TextBox(); + $object->setPositioning($expected); + $this->assertEquals($expected, $object->getPositioning()); + } + + /** + * Test set/get posHorizontal + */ + public function testSetGetPosHorizontal() + { + $expected='center'; + $object = new TextBox(); + $object->setPosHorizontal($expected); + $this->assertEquals($expected, $object->getPosHorizontal()); + } + + /** + * Test set/get posVertical + */ + public function testSetGetPosVertical() + { + $expected='top'; + $object = new TextBox(); + $object->setPosVertical($expected); + $this->assertEquals($expected, $object->getPosVertical()); + } + + /** + * Test set/get posHorizontalRel + */ + public function testSetGetPosHorizontalRel() + { + $expected='margin'; + $object = new TextBox(); + $object->setPosHorizontalRel($expected); + $this->assertEquals($expected, $object->getPosHorizontalRel()); + } + + /** + * Test set/get posVerticalRel + */ + public function testSetGetPosVerticalRel() + { + $expected='page'; + $object = new TextBox(); + $object->setPosVerticalRel($expected); + $this->assertEquals($expected, $object->getPosVerticalRel()); + } + + + /** + * Test set/get innerMarginRight + */ + public function testSetGetInnerMarginRight() + { + $expected=5; + $object = new TextBox(); + $object->setInnerMarginRight($expected); + $this->assertEquals($expected, $object->getInnerMarginRight()); + } + + /** + * Test set/get innerMarginBottom + */ + public function testSetGetInnerMarginBottom() + { + $expected=5; + $object = new TextBox(); + $object->setInnerMarginBottom($expected); + $this->assertEquals($expected, $object->getInnerMarginBottom()); + } + + /** + * Test set/get innerMarginLeft + */ + public function testSetGetInnerMarginLeft() + { + $expected=5; + $object = new TextBox(); + $object->setInnerMarginLeft($expected); + $this->assertEquals($expected, $object->getInnerMarginLeft()); + } + + /** + * Test set/get innerMarginLeft + */ + public function testSetGetInnerMargin() + { + $expected=5; + $object = new TextBox(); + $object->setInnerMargin($expected); + $this->assertEquals(array($expected, $expected, $expected, $expected), $object->getInnerMargin()); + } + + /** + * Test set/get borderSize + */ + public function testSetGetBorderSize() + { + $expected=2; + $object = new TextBox(); + $object->setBorderSize($expected); + $this->assertEquals($expected, $object->getBorderSize()); + } + + /** + * Test set/get borderColor + */ + public function testSetGetBorderColor() + { + $expected='red'; + $object = new TextBox(); + $object->setBorderColor($expected); + $this->assertEquals($expected, $object->getBorderColor()); + } +} diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index 0738e72119..f446ecdf9a 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -1,9 +1,17 @@ Date: Thu, 8 May 2014 09:52:11 +0700 Subject: [PATCH 050/167] Move `addTextBox` to `AbstractContainer` and add sample for textbox --- .travis.yml | 2 +- CHANGELOG.md | 1 + samples/Sample_25_TextBox.php | 22 + src/PhpWord/Element/AbstractContainer.php | 20 +- src/PhpWord/Element/AbstractElement.php | 6 +- src/PhpWord/Element/Footer.php | 15 - src/PhpWord/Element/Section.php | 15 - src/PhpWord/Element/TextBox.php | 7 +- src/PhpWord/Style/TextBox.php | 476 +----------------- .../Writer/Word2007/Element/TextBox.php | 10 +- .../Writer/Word2007/Part/AbstractPart.php | 4 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 8 +- tests/PhpWord/Tests/Element/TextBoxTest.php | 14 +- 13 files changed, 91 insertions(+), 509 deletions(-) create mode 100644 samples/Sample_25_TextBox.php diff --git a/.travis.yml b/.travis.yml index 7593379cf3..50587e4982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ script: ## PHP Copy/Paste Detector - php phpcpd.phar src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php + #- phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/CHANGELOG.md b/CHANGELOG.md index c34fbc22c5..b309236f48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Image: Ability to define relative and absolute positioning - @basjan GH-217 - Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 +- TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 ### Bugfixes diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php new file mode 100644 index 0000000000..575a1df5ce --- /dev/null +++ b/samples/Sample_25_TextBox.php @@ -0,0 +1,22 @@ +addSection(); +$textbox = $section->addTextBox(array('align' => 'left', 'width' => 300, 'borderSize' => 1, 'borderColor' => '#FF0000')); +$textbox->addText('Text box content '); +$textbox->addText('with bold text', array('bold' => true)); +$textbox->addText(', '); +$textbox->addLink('http://www.google.com', 'link'); +$textbox->addText(', and image '); +$textbox->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); +$textbox->addText('.'); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 920843b712..6e8a02413e 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -295,6 +295,23 @@ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = n return $element; } + /** + * Add textbox element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\TextBox + */ + public function addTextBox($style = null) + { + $this->checkValidity('TextBox'); + + $textbox = new TextBox($style); + $textbox->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($textbox); + + return $textbox; + } + /** * Check if a method is allowed for the current container * @@ -314,6 +331,7 @@ private function checkValidity($method) 'TextRun' => array('section', 'header', 'footer', 'cell'), 'ListItem' => array('section', 'header', 'footer', 'cell'), 'CheckBox' => array('section', 'header', 'footer', 'cell'), + 'TextBox' => array('section', 'header', 'footer'), 'Footnote' => array('section', 'textrun', 'cell'), 'Endnote' => array('section', 'textrun', 'cell'), 'PreserveText' => array('header', 'footer', 'cell'), @@ -352,7 +370,7 @@ private function checkValidity($method) */ private function checkElementDocPart() { - $isCellTextrun = in_array($this->container, array('cell', 'textrun')); + $isCellTextrun = in_array($this->container, array('cell', 'textrun', 'textbox')); $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 5ed5209ffd..a3987b5848 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -27,7 +27,11 @@ */ abstract class AbstractElement { - + /** + * PhpWord object + * + * @var \PhpOffice\PhpWord\PhpWord + */ protected $phpWord; /** diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 0e5a197598..2f23a3d371 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -115,21 +115,6 @@ public function evenPage() return $this->type = self::EVEN; } - /** - * Add textbox element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\TextBox - * @todo Merge with the same function on Section - */ - public function addTextBox($style = null) - { - $textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($textbox); - - return $textbox; - } - /** * Add table element * diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 3183a6cb64..1ccdccc8c2 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -117,21 +117,6 @@ public function addPageBreak() $this->addElement(new PageBreak()); } - /** - * Add textbox element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\TextBox - * @todo Merge with the same function on Footer - */ - public function addTextBox($style = null) - { - $textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($textbox); - - return $textbox; - } - /** * Add table element * diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 4cf7b906b0..1de7464995 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -30,7 +30,7 @@ class TextBox extends AbstractContainer * @var \PhpOffice\PhpWord\Style\TextBox */ private $style; - + /** * Create a new textbox * @@ -38,10 +38,9 @@ class TextBox extends AbstractContainer * @param integer $docPartId * @param mixed $style */ - public function __construct($docPart, $docPartId, $style = null) + public function __construct($style = null) { $this->container = 'textbox'; - $this->setDocPart($docPart, $docPartId); $this->style = $this->setStyle(new TextBoxStyle(), $style); } @@ -54,4 +53,4 @@ public function getStyle() { return $this->style; } -} \ No newline at end of file +} diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index 7e83da6a05..0411e5d9d4 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -20,163 +20,29 @@ /** * TextBox style */ -class TextBox extends AbstractStyle +class TextBox extends Image { - - /** - * Wrapping styles - * - * @const string - */ - const WRAPPING_STYLE_INLINE = 'inline'; - const WRAPPING_STYLE_SQUARE = 'square'; - const WRAPPING_STYLE_TIGHT = 'tight'; - const WRAPPING_STYLE_BEHIND = 'behind'; - const WRAPPING_STYLE_INFRONT = 'infront'; - - /** - * Horizontal alignment - * - * @const string - */ - const POSITION_HORIZONTAL_LEFT = 'left'; - const POSITION_HORIZONTAL_CENTER = 'center'; - const POSITION_HORIZONTAL_RIGHT = 'right'; - - /** - * Vertical alignment - * - * @const string - */ - const POSITION_VERTICAL_TOP = 'top'; - const POSITION_VERTICAL_CENTER = 'center'; - const POSITION_VERTICAL_BOTTOM = 'bottom'; - const POSITION_VERTICAL_INSIDE = 'inside'; - const POSITION_VERTICAL_OUTSIDE = 'outside'; - - /** - * Position relative to - * - * @const string - */ - const POSITION_RELATIVE_TO_MARGIN = 'margin'; - const POSITION_RELATIVE_TO_PAGE = 'page'; - const POSITION_RELATIVE_TO_COLUMN = 'column'; - const POSITION_RELATIVE_TO_CHAR = 'char'; - const POSITION_RELATIVE_TO_LMARGIN = 'left-margin-area'; - const POSITION_RELATIVE_TO_RMARGIN = 'right-margin-area'; - const POSITION_RELATIVE_TO_IMARGIN = 'inner-margin-area'; - const POSITION_RELATIVE_TO_OMARGIN = 'outer-margin-area'; - const POSITION_RELATIVE_TO_LINE = 'line'; - const POSITION_RELATIVE_TO_TMARGIN = 'top-margin-area'; - const POSITION_RELATIVE_TO_BMARGIN = 'bottom-margin-area'; - - /** - * Position type, relative/absolute - * - * @const string - */ - const POSITION_RELATIVE = 'relative'; - const POSITION_ABSOLUTE = 'absolute'; - - /** - * TextBox width - * - * @var int - */ - private $width; - - /** - * TextBox height - * - * @var int - */ - private $height; - - /** - * Alignment - * - * @var string - */ - private $align; - - /** - * Margin Top - * - * @var int - */ - private $marginTop; - - /** - * Margin Left - * - * @var int - */ - private $marginLeft; - - /** - * Wrapping style - * - * @var string - */ - private $wrappingStyle; - - /** - * Positioning type (relative or absolute) - * - * @var string - */ - private $positioning; - - /** - * Horizontal alignment - * - * @var string - */ - private $posHorizontal; - - /** - * Horizontal Relation - * - * @var string - */ - private $posHorizontalRel; - - /** - * Vertical alignment - * - * @var string - */ - private $posVertical; - - /** - * Vertical Relation - * - * @var string - */ - private $posVerticalRel; - /** * margin top * * @var int */ private $innerMarginTop = null; - + /** * margin left * * @var int */ private $innerMarginLeft = null; - + /** * margin right * * @var int */ private $innerMarginRight = null; - + /** * Cell margin bottom * @@ -186,7 +52,7 @@ class TextBox extends AbstractStyle /** * border size - * + * * @var int */ private $borderSize = null; @@ -197,305 +63,7 @@ class TextBox extends AbstractStyle * @var string */ private $borderColor; - - /** - * Create new textbox style - */ - public function __construct() - { - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); - $this->setPosHorizontalRel(self::POSITION_RELATIVE_TO_CHAR); - $this->setPosVertical(self::POSITION_VERTICAL_TOP); - $this->setPosVerticalRel(self::POSITION_RELATIVE_TO_LINE); - } - /** - * Get width - */ - public function getWidth() - { - return $this->width; - } - - /** - * Set width - * - * @param int $value - */ - public function setWidth($value = null) - { - $this->width = $value; - } - - /** - * Get height - */ - public function getHeight() - { - return $this->height; - } - - /** - * Set height - * - * @param int $value - */ - public function setHeight($value = null) - { - $this->height = $value; - } - - /** - * Get alignment - */ - public function getAlign() - { - return $this->align; - } - - /** - * Set alignment - * - * @param string $value - */ - public function setAlign($value = null) - { - $this->align = $value; - } - - /** - * Get Margin Top - * - * @return int - */ - public function getMarginTop() - { - return $this->marginTop; - } - - /** - * Set Margin Top - * - * @param int $value - * @return self - */ - public function setMarginTop($value = null) - { - $this->marginTop = $value; - return $this; - } - - /** - * Get Margin Left - * - * @return int - */ - public function getMarginLeft() - { - return $this->marginLeft; - } - - /** - * Set Margin Left - * - * @param int $value - * @return self - */ - public function setMarginLeft($value = null) - { - $this->marginLeft = $value; - return $this; - } - - /** - * Get wrapping style - * - * @return string - */ - public function getWrappingStyle() - { - return $this->wrappingStyle; - } - - /** - * Set wrapping style - * - * @param string $wrappingStyle - * @throws \InvalidArgumentException - * @return self - */ - public function setWrappingStyle($wrappingStyle) - { - $enum = array(self::WRAPPING_STYLE_INLINE, self::WRAPPING_STYLE_INFRONT, self::WRAPPING_STYLE_BEHIND, - self::WRAPPING_STYLE_SQUARE, self::WRAPPING_STYLE_TIGHT); - - if (in_array($wrappingStyle, $enum)) { - $this->wrappingStyle = $wrappingStyle; - } else { - throw new \InvalidArgumentException('Invalid wrapping style.'); - } - - return $this; - } - - /** - * Get positioning type - * - * @return string - */ - public function getPositioning() - { - return $this->positioning; - } - - /** - * Set positioning type - * - * @param string $positioning - * @throws \InvalidArgumentException - * @return self - */ - public function setPositioning($positioning) - { - $enum = array(self::POSITION_RELATIVE, self::POSITION_ABSOLUTE); - - if (in_array($positioning, $enum)) { - $this->positioning = $positioning; - } else { - throw new \InvalidArgumentException('Invalid positioning.'); - } - - return $this; - } - - /** - * Get horizontal alignment - * - * @return string - */ - public function getPosHorizontal() - { - return $this->posHorizontal; - } - - /** - * Set horizontal alignment - * - * @param string $alignment - * @throws \InvalidArgumentException - * @return self - */ - public function setPosHorizontal($alignment) - { - $enum = array(self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, - self::POSITION_HORIZONTAL_RIGHT); - - if (in_array($alignment, $enum)) { - $this->posHorizontal = $alignment; - } else { - throw new \InvalidArgumentException('Invalid horizontal alignment.'); - } - - return $this; - } - - /** - * Get vertical alignment - * - * @return string - */ - public function getPosVertical() - { - return $this->posVertical; - } - - /** - * Set vertical alignment - * - * @param string $alignment - * @throws \InvalidArgumentException - * @return self - */ - public function setPosVertical($alignment) - { - $enum = array(self::POSITION_VERTICAL_TOP, self::POSITION_VERTICAL_CENTER, - self::POSITION_VERTICAL_BOTTOM, self::POSITION_VERTICAL_INSIDE, self::POSITION_VERTICAL_OUTSIDE); - - if (in_array($alignment, $enum)) { - $this->posVertical = $alignment; - } else { - throw new \InvalidArgumentException('Invalid vertical alignment.'); - } - - return $this; - } - - /** - * Get horizontal relation - * - * @return string - */ - public function getPosHorizontalRel() - { - return $this->posHorizontalRel; - } - - /** - * Set horizontal relation - * - * @param string $relto - * @throws \InvalidArgumentException - * @return self - */ - public function setPosHorizontalRel($relto) - { - $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, - self::POSITION_RELATIVE_TO_COLUMN, self::POSITION_RELATIVE_TO_CHAR, - self::POSITION_RELATIVE_TO_LMARGIN, self::POSITION_RELATIVE_TO_RMARGIN, - self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); - - if (in_array($relto, $enum)) { - $this->posHorizontalRel = $relto; - } else { - throw new \InvalidArgumentException('Invalid relative horizontal alignment.'); - } - - return $this; - } - - /** - * Get vertical relation - * - * @return string - */ - public function getPosVerticalRel() - { - return $this->posVerticalRel; - } - - /** - * Set vertical relation - * - * @param string $relto - * @throws \InvalidArgumentException - * @return self - */ - public function setPosVerticalRel($relto) - { - $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, - self::POSITION_RELATIVE_TO_LINE, - self::POSITION_RELATIVE_TO_TMARGIN, self::POSITION_RELATIVE_TO_BMARGIN, - self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); - - if (in_array($relto, $enum)) { - $this->posVerticalRel = $relto; - } else { - throw new \InvalidArgumentException('Invalid relative vertical alignment.'); - } - - return $this; - } /** * Set margin top * @@ -505,7 +73,7 @@ public function setInnerMarginTop($value = null) { $this->innerMarginTop = $value; } - + /** * Get margin top * @@ -515,7 +83,7 @@ public function getInnerMarginTop() { return $this->innerMarginTop; } - + /** * Set margin left * @@ -525,7 +93,7 @@ public function setInnerMarginLeft($value = null) { $this->innerMarginLeft = $value; } - + /** * Get margin left * @@ -535,7 +103,7 @@ public function getInnerMarginLeft() { return $this->innerMarginLeft; } - + /** * Set margin right * @@ -545,7 +113,7 @@ public function setInnerMarginRight($value = null) { $this->innerMarginRight = $value; } - + /** * Get margin right * @@ -555,7 +123,7 @@ public function getInnerMarginRight() { return $this->innerMarginRight; } - + /** * Set margin bottom * @@ -565,7 +133,7 @@ public function setInnerMarginBottom($value = null) { $this->innerMarginBottom = $value; } - + /** * Get margin bottom * @@ -575,7 +143,7 @@ public function getInnerMarginBottom() { return $this->innerMarginBottom; } - + /** * Set TLRB cell margin * @@ -588,7 +156,7 @@ public function setInnerMargin($value = null) $this->setInnerMarginRight($value); $this->setInnerMarginBottom($value); } - + /** * Get cell margin * @@ -598,20 +166,20 @@ public function getInnerMargin() { return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom); } - + /** * Set border size - * + * * @param int $value Size in points */ public function setBorderSize($value = null) { $this->borderSize = $value; } - + /** * Get border size - * + * * @return int */ public function getBorderSize() @@ -621,21 +189,21 @@ public function getBorderSize() /** * Set border color - * + * * @param string $value */ public function setBorderColor($value = null) { $this->borderColor = $value; } - + /** * Get border color - * + * * @return string */ public function getBorderColor() { return $this->borderColor; } -} \ No newline at end of file +} diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 812d2218a4..fd1683aea9 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -47,26 +47,28 @@ public function write() $this->xmlWriter->endElement(); // w:pPr } } - + $this->xmlWriter->startElement('w:r'); $this->xmlWriter->startElement('w:pict'); $this->xmlWriter->startElement('v:shape'); $this->xmlWriter->writeAttribute('type', '#_x0000_t0202'); $styleWriter->write(); $this->xmlWriter->startElement('v:textbox'); - $margins=implode(', ',$tbxStyle->getInnerMargin()); + $margins = implode(', ', $tbxStyle->getInnerMargin()); $this->xmlWriter->writeAttribute('inset', $margins); $this->xmlWriter->startElement('w:txbxContent'); + $this->xmlWriter->startElement('w:p'); $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); + $this->xmlWriter->endElement(); // w:p $this->xmlWriter->endElement(); // w:txbxContent $this->xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); $this->xmlWriter->endElement(); // v:shape $this->xmlWriter->endElement(); // w:pict $this->xmlWriter->endElement(); // w:r - + if (!$this->withoutP) { $this->xmlWriter->endElement(); // w:p } } -} \ No newline at end of file +} diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index 8431075242..d1717e9b28 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -97,7 +97,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co 'Header' => array_merge($elmMainCell, array('Table', 'PreserveText', 'TextBox')), 'Footer' => array_merge($elmMainCell, array('Table', 'PreserveText', 'TextBox')), 'Cell' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), - 'TextBox' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), + 'TextBox' => array_merge($elmMainCell, array('PreserveText', 'Footnote', 'Endnote')), 'TextRun' => array_merge($elmCommon, array('Footnote', 'Endnote')), 'Footnote' => $elmCommon, 'Endnote' => $elmCommon, @@ -110,7 +110,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co // Loop through elements $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; if (count($elements) > 0) { foreach ($elements as $element) { if ($element instanceof AbstractElement) { diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index 6720279e9b..18c8a60f52 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -93,7 +93,7 @@ public function write() if ($borderSize !== null) { $this->xmlWriter->writeAttribute('strokeweight', $this->style->getBorderSize().'pt'); } - + $borderColor = $this->style->getBorderColor(); if (empty($borderColor)) { $this->xmlWriter->writeAttribute('stroked', 'f'); @@ -101,7 +101,7 @@ public function write() $this->xmlWriter->writeAttribute('strokecolor', $borderColor); } //@todo - + } /** @@ -114,7 +114,7 @@ public function writeW10Wrap() if (!is_null($this->w10wrap)) { $this->xmlWriter->startElement('w10:wrap'); $this->xmlWriter->writeAttribute('type', $this->w10wrap); - + switch ($this->style->getPositioning()) { case TextBoxStyle::POSITION_ABSOLUTE: $this->xmlWriter->writeAttribute('anchorx', "page"); @@ -150,7 +150,7 @@ public function writeW10Wrap() break; } } - + $this->xmlWriter->endElement(); // w10:wrap } } diff --git a/tests/PhpWord/Tests/Element/TextBoxTest.php b/tests/PhpWord/Tests/Element/TextBoxTest.php index a706c5a217..c3c89ed4cb 100644 --- a/tests/PhpWord/Tests/Element/TextBoxTest.php +++ b/tests/PhpWord/Tests/Element/TextBoxTest.php @@ -32,8 +32,8 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase */ public function testConstruct() { - $oTextBox = new TextBox('section', 1); - + $oTextBox = new TextBox(); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextBox', $oTextBox); $this->assertEquals($oTextBox->getStyle(), null); } @@ -43,19 +43,17 @@ public function testConstruct() */ public function testStyleText() { - $oTextBox = new TextBox('section', 1, 'textBoxStyle'); - + $oTextBox = new TextBox('textBoxStyle'); + $this->assertEquals($oTextBox->getStyle(), 'textBoxStyle'); } - + /** * Get style array */ public function testStyleArray() { $oTextBox = new TextBox( - 'section', - 1, array( 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4.5), 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(17.5), @@ -68,7 +66,7 @@ public function testStyleArray() 'borderColor' => '' ) ); - + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\TextBox', $oTextBox->getStyle()); } } From ea41b08a9adb2ad4229ce94bfb49f063668606d6 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 8 May 2014 12:58:44 +0700 Subject: [PATCH 051/167] Refactor the new textbox element --- src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/Section.php | 2 +- src/PhpWord/Element/TextBox.php | 4 +- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/TextBox.php | 2 + src/PhpWord/Writer/HTML/Element/Element.php | 2 +- src/PhpWord/Writer/RTF/Element/Element.php | 2 +- .../Writer/Word2007/Element/Container.php | 6 +- .../Writer/Word2007/Element/TextBox.php | 65 ++++---- src/PhpWord/Writer/Word2007/Style/Image.php | 8 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 141 ++++++------------ 11 files changed, 103 insertions(+), 135 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 2a8815d48c..c575f80e7a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -78,7 +78,7 @@ public function countElements() public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') { $this->checkValidity($elementName); - $elementClass = dirname(get_class($this)) . '\\' . $elementName; + $elementClass = __NAMESPACE__ . '\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { @@ -248,7 +248,7 @@ public function addObject($source, $style = null) public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { $this->checkValidity($elementName); - $elementClass = dirname(get_class($this)) . '\\' . $elementName; + $elementClass = __NAMESPACE__ . '\\' . $elementName; $docPart = strtolower($elementName); $addMethod = "add{$elementName}"; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 639f752e85..dc216fce46 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -223,7 +223,7 @@ public function hasDifferentFirstPage() private function addHeaderFooter($type = Header::AUTO, $header = true) { $collectionArray = $header ? 'headers' : 'footers'; - $containerClass = dirname(get_class($this)) . '\\' . ($header ? 'Header' : 'Footer'); + $containerClass = __NAMESPACE__ . '\\' . ($header ? 'Header' : 'Footer'); $collection = &$this->$collectionArray; if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 1de7464995..041c2657fd 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -20,7 +20,9 @@ use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle; /** - * Table element + * TextBox element + * + * @since 0.11.0 */ class TextBox extends AbstractContainer { diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index f43aba906e..082596af3b 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -249,7 +249,7 @@ protected function setEnumVal($value, $enum, $default = null) */ protected function setObjectVal($value, $styleName, &$style) { - $styleClass = dirname(get_class($this)) . '\\' . $styleName; + $styleClass = __NAMESPACE__ . '\\' . $styleName; if (is_array($value)) { if (!$style instanceof $styleClass) { $style = new $styleClass(); diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index 0411e5d9d4..401e2cc01f 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -19,6 +19,8 @@ /** * TextBox style + * + * @since 0.11.0 */ class TextBox extends Image { diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index b0d25b4497..7ad8a00db3 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -73,7 +73,7 @@ public function __construct(HTML $parentWriter, AbstractElement $element, $witho public function write() { $content = ''; - $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($this->element)); + $writerClass = __NAMESPACE__ . '\\' . basename(get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index f4d09e36de..d460deac5c 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -68,7 +68,7 @@ public function __construct(RTF $parentWriter, AbstractElement $element, $withou public function write() { $content = ''; - $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($this->element)); + $writerClass = __NAMESPACE__ . '\\' . basename(get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 7baf7e3b36..377241eeda 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -37,10 +37,10 @@ public function write() // Loop through subelements $containerClass = basename(get_class($element)); $subelements = $element->getElements(); - $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; if (count($subelements) > 0) { foreach ($subelements as $subelement) { - $writerClass = dirname(get_class($this)) . '\\' . basename(get_class($subelement)); + $writerClass = __NAMESPACE__ . '\\' . basename(get_class($subelement)); if (class_exists($writerClass)) { $writer = new $writerClass($xmlWriter, $subelement, $withoutP); $writer->write(); @@ -49,7 +49,7 @@ public function write() } else { // Special case for Cell: They have to contain a TextBreak at least if ($containerClass == 'Cell') { - $writerClass = dirname(get_class($this)) . '\\TextBreak'; + $writerClass = __NAMESPACE__ . '\\TextBreak'; $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); $writer->write(); } diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index fd1683aea9..1ee8a4cbcd 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -23,52 +23,61 @@ /** * TextBox element writer * + * @since 0.11.0 */ -class TextBox extends Element +class TextBox extends AbstractElement { /** * Write element */ public function write() { - $tbxStyle = $this->element->getStyle(); - if ($tbxStyle instanceof TextBoxStyle) { - $styleWriter = new TextBoxStyleWriter($this->xmlWriter, $tbxStyle); + $xmlWriter = $this->getXmlWriter(); + $element = $this->getElement(); + $style = $element->getStyle(); + + if ($style instanceof TextBoxStyle) { + $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); $styleWriter->write(); } if (!$this->withoutP) { - $this->xmlWriter->startElement('w:p'); - if (!is_null($tbxStyle->getAlign())) { - $this->xmlWriter->startElement('w:pPr'); - $this->xmlWriter->startElement('w:jc'); - $this->xmlWriter->writeAttribute('w:val', $tbxStyle->getAlign()); - $this->xmlWriter->endElement(); // w:jc - $this->xmlWriter->endElement(); // w:pPr + $xmlWriter->startElement('w:p'); + if (!is_null($style->getAlign())) { + $xmlWriter->startElement('w:pPr'); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $style->getAlign()); + $xmlWriter->endElement(); // w:jc + $xmlWriter->endElement(); // w:pPr } } - $this->xmlWriter->startElement('w:r'); - $this->xmlWriter->startElement('w:pict'); - $this->xmlWriter->startElement('v:shape'); - $this->xmlWriter->writeAttribute('type', '#_x0000_t0202'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:pict'); + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('type', '#_x0000_t0202'); $styleWriter->write(); - $this->xmlWriter->startElement('v:textbox'); - $margins = implode(', ', $tbxStyle->getInnerMargin()); - $this->xmlWriter->writeAttribute('inset', $margins); - $this->xmlWriter->startElement('w:txbxContent'); - $this->xmlWriter->startElement('w:p'); - $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); - $this->xmlWriter->endElement(); // w:p - $this->xmlWriter->endElement(); // w:txbxContent - $this->xmlWriter->endElement(); // v: textbox + + $xmlWriter->startElement('v:textbox'); + $margins = implode(', ', $style->getInnerMargin()); + $xmlWriter->writeAttribute('inset', $margins); + + $xmlWriter->startElement('w:txbxContent'); + $xmlWriter->startElement('w:p'); + $containerWriter = new Container($xmlWriter, $element); + $containerWriter->write(); + $xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:txbxContent + + $xmlWriter->endElement(); // v: textbox + $styleWriter->writeW10Wrap(); - $this->xmlWriter->endElement(); // v:shape - $this->xmlWriter->endElement(); // w:pict - $this->xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // v:shape + $xmlWriter->endElement(); // w:pict + $xmlWriter->endElement(); // w:r if (!$this->withoutP) { - $this->xmlWriter->endElement(); // w:p + $xmlWriter->endElement(); // w:p } } } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index 79b218d6fe..2dd3398cbd 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -31,7 +31,7 @@ class Image extends AbstractStyle * * @var string */ - private $w10wrap; + protected $w10wrap; /** * Write style @@ -52,7 +52,7 @@ public function write() 'mso-width-relative' => 'margin', 'mso-height-relative' => 'margin', ); - $styleArray = array_merge($styleArray, $this->getElementStyle($this->style)); + $styleArray = array_merge($styleArray, $this->getElementStyle($style)); // Absolute/relative positioning $styleArray['position'] = $positioning; @@ -112,7 +112,7 @@ public function writeW10Wrap() * * @return array */ - private function getElementStyle(ImageStyle $style) + protected function getElementStyle(ImageStyle $style) { $styles = array(); $styleValues = array( @@ -136,7 +136,7 @@ private function getElementStyle(ImageStyle $style) * @param array $styles * @return string */ - private function assembleStyle($styles = array()) + protected function assembleStyle($styles = array()) { $style = ''; foreach ($styles as $key => $value) { diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index 18c8a60f52..f526f888dd 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -1,19 +1,19 @@ style instanceof \PhpOffice\PhpWord\Style\TextBox)) { + if (is_null($style = $this->getStyle())) { return; } - - $wrapping = $this->style->getWrappingStyle(); - $positioning = $this->style->getPositioning(); + $xmlWriter = $this->getXmlWriter(); + $wrapping = $style->getWrappingStyle(); + $positioning = $style->getPositioning(); // Default style array $styleArray = array( @@ -51,7 +45,7 @@ public function write() 'mso-width-relative' => 'margin', 'mso-height-relative' => 'margin', ); - $styleArray = array_merge($styleArray, $this->getElementStyle()); + $styleArray = array_merge($styleArray, $this->getElementStyle($style)); // Absolute/relative positioning $styleArray['position'] = $positioning; @@ -59,10 +53,10 @@ public function write() $styleArray['mso-position-horizontal-relative'] = 'page'; $styleArray['mso-position-vertical-relative'] = 'page'; } elseif ($positioning == TextBoxStyle::POSITION_RELATIVE) { - $styleArray['mso-position-horizontal'] = $this->style->getPosHorizontal(); - $styleArray['mso-position-vertical'] = $this->style->getPosVertical(); - $styleArray['mso-position-horizontal-relative'] = $this->style->getPosHorizontalRel(); - $styleArray['mso-position-vertical-relative'] = $this->style->getPosVerticalRel(); + $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); + $styleArray['mso-position-vertical'] = $style->getPosVertical(); + $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); + $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); $styleArray['margin-left'] = 0; $styleArray['margin-top'] = 0; } @@ -87,18 +81,18 @@ public function write() $textboxStyle = $this->assembleStyle($styleArray); - $this->xmlWriter->writeAttribute('style', $textboxStyle); + $xmlWriter->writeAttribute('style', $textboxStyle); - $borderSize = $this->style->getBorderSize(); + $borderSize = $style->getBorderSize(); if ($borderSize !== null) { - $this->xmlWriter->writeAttribute('strokeweight', $this->style->getBorderSize().'pt'); + $xmlWriter->writeAttribute('strokeweight', $style->getBorderSize().'pt'); } - $borderColor = $this->style->getBorderColor(); + $borderColor = $style->getBorderColor(); if (empty($borderColor)) { - $this->xmlWriter->writeAttribute('stroked', 'f'); + $xmlWriter->writeAttribute('stroked', 'f'); } else { - $this->xmlWriter->writeAttribute('strokecolor', $borderColor); + $xmlWriter->writeAttribute('strokecolor', $borderColor); } //@todo @@ -111,88 +105,49 @@ public function write() */ public function writeW10Wrap() { + $xmlWriter = $this->getXmlWriter(); + if (!is_null($this->w10wrap)) { - $this->xmlWriter->startElement('w10:wrap'); - $this->xmlWriter->writeAttribute('type', $this->w10wrap); + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $this->w10wrap); - switch ($this->style->getPositioning()) { + switch ($style->getPositioning()) { case TextBoxStyle::POSITION_ABSOLUTE: - $this->xmlWriter->writeAttribute('anchorx', "page"); - $this->xmlWriter->writeAttribute('anchory', "page"); + $xmlWriter->writeAttribute('anchorx', "page"); + $xmlWriter->writeAttribute('anchory', "page"); break; case TextBoxStyle::POSITION_RELATIVE: - switch ($this->style->getPosVerticalRel()) { + switch ($style->getPosVerticalRel()) { case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: - $this->xmlWriter->writeAttribute('anchory', "margin"); + $xmlWriter->writeAttribute('anchory', "margin"); break; case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: - $this->xmlWriter->writeAttribute('anchory', "page"); + $xmlWriter->writeAttribute('anchory', "page"); break; case TextBoxStyle::POSITION_RELATIVE_TO_TMARGIN: - $this->xmlWriter->writeAttribute('anchory', "margin"); + $xmlWriter->writeAttribute('anchory', "margin"); break; case TextBoxStyle::POSITION_RELATIVE_TO_BMARGIN: - $this->xmlWriter->writeAttribute('anchory', "page"); + $xmlWriter->writeAttribute('anchory', "page"); break; } - switch ($this->style->getPosHorizontalRel()) { + switch ($style->getPosHorizontalRel()) { case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: - $this->xmlWriter->writeAttribute('anchorx', "margin"); + $xmlWriter->writeAttribute('anchorx', "margin"); break; case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: - $this->xmlWriter->writeAttribute('anchorx', "page"); + $xmlWriter->writeAttribute('anchorx', "page"); break; case TextBoxStyle::POSITION_RELATIVE_TO_LMARGIN: - $this->xmlWriter->writeAttribute('anchorx', "margin"); + $xmlWriter->writeAttribute('anchorx', "margin"); break; case TextBoxStyle::POSITION_RELATIVE_TO_RMARGIN: - $this->xmlWriter->writeAttribute('anchorx', "page"); + $xmlWriter->writeAttribute('anchorx', "page"); break; } } - $this->xmlWriter->endElement(); // w10:wrap - } - } - - /** - * Get element style - * - * @return array - */ - private function getElementStyle() - { - $styles = array(); - $styleValues = array( - 'width' => $this->style->getWidth(), - 'height' => $this->style->getHeight(), - 'margin-top' => $this->style->getMarginTop(), - 'margin-left' => $this->style->getMarginLeft() - ); - foreach ($styleValues as $key => $value) { - if (!is_null($value) && $value != '') { - $styles[$key] = $value . 'px'; - } - } - - return $styles; - } - - /** - * Assemble style array into style string - * - * @param array $styles - * @return string - */ - private function assembleStyle($styles = array()) - { - $style = ''; - foreach ($styles as $key => $value) { - if (!is_null($value) && $value != '') { - $style .= "{$key}:{$value}; "; - } + $xmlWriter->endElement(); // w10:wrap } - - return trim($style); } } From f7dd9dd07c803d6bb07618ceae664f84ba6ed0dc Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 8 May 2014 19:25:29 +0700 Subject: [PATCH 052/167] Refactor writers and styles --- src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/AbstractElement.php | 4 +- src/PhpWord/Element/Section.php | 3 +- src/PhpWord/Element/TOC.php | 18 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 206 +++++++++--------- src/PhpWord/Style/AbstractStyle.php | 19 +- src/PhpWord/Style/Cell.php | 65 ++++-- src/PhpWord/Style/Font.php | 24 +- src/PhpWord/Style/Image.php | 96 +++----- src/PhpWord/Style/ListItem.php | 12 +- src/PhpWord/Style/Numbering.php | 2 + src/PhpWord/Style/Paragraph.php | 6 +- src/PhpWord/Style/Row.php | 5 + src/PhpWord/Style/Section.php | 18 +- src/PhpWord/Style/Shading.php | 7 +- src/PhpWord/Style/TOC.php | 21 +- src/PhpWord/Style/Tab.php | 22 +- src/PhpWord/Style/Table.php | 8 +- src/PhpWord/Writer/HTML/Element/Element.php | 3 +- src/PhpWord/Writer/RTF/Element/Element.php | 3 +- .../Writer/Word2007/Element/Container.php | 11 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 28 ++- src/PhpWord/Writer/Word2007/Style/Cell.php | 5 +- src/PhpWord/Writer/Word2007/Style/Font.php | 23 +- src/PhpWord/Writer/Word2007/Style/Image.php | 52 +++-- .../Writer/Word2007/Style/Indentation.php | 8 +- .../Writer/Word2007/Style/Paragraph.php | 12 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 9 +- src/PhpWord/Writer/Word2007/Style/Table.php | 3 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 149 +++++-------- .../PhpWord/Tests/Style/AbstractStyleTest.php | 12 + tests/PhpWord/Tests/Style/FontTest.php | 2 +- tests/PhpWord/Tests/Style/SectionTest.php | 8 +- 33 files changed, 444 insertions(+), 424 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index c575f80e7a..b2e2aad4a1 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -78,7 +78,7 @@ public function countElements() public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') { $this->checkValidity($elementName); - $elementClass = __NAMESPACE__ . '\\' . $elementName; + $elementClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { @@ -248,7 +248,7 @@ public function addObject($source, $style = null) public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { $this->checkValidity($elementName); - $elementClass = __NAMESPACE__ . '\\' . $elementName; + $elementClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $elementName; $docPart = strtolower($elementName); $addMethod = "add{$elementName}"; diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index a3987b5848..7e3151e21e 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -231,9 +231,7 @@ public function isInSection() protected function setStyle($styleObject, $styleValue = null, $returnObject = false) { if (!is_null($styleValue) && is_array($styleValue)) { - foreach ($styleValue as $key => $value) { - $styleObject->setStyleValue($key, $value); - } + $styleObject->setStyleByArray($styleValue); $style = $styleObject; } else { $style = $returnObject ? $styleObject : $styleValue; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index dc216fce46..9067c73c0c 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -222,8 +222,9 @@ public function hasDifferentFirstPage() */ private function addHeaderFooter($type = Header::AUTO, $header = true) { + $containerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . + ($header ? 'Header' : 'Footer'); $collectionArray = $header ? 'headers' : 'footers'; - $containerClass = __NAMESPACE__ . '\\' . ($header ? 'Header' : 'Footer'); $collection = &$this->$collectionArray; if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index 2ecb091d9b..548f4f8a5b 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -68,20 +68,14 @@ public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $this->TOCStyle = new TOCStyle(); if (!is_null($tocStyle) && is_array($tocStyle)) { - foreach ($tocStyle as $key => $value) { - $this->TOCStyle->setStyleValue($key, $value); - } + $this->TOCStyle->setStyleByArray($tocStyle); } - if (!is_null($fontStyle)) { - if (is_array($fontStyle)) { - $this->fontStyle = new Font(); - foreach ($fontStyle as $key => $value) { - $this->fontStyle->setStyleValue($key, $value); - } - } else { - $this->fontStyle = $fontStyle; - } + if (!is_null($fontStyle) && is_array($fontStyle)) { + $this->fontStyle = new Font(); + $this->fontStyle->setStyleByArray($fontStyle); + } else { + $this->fontStyle = $fontStyle; } $this->minDepth = $minDepth; diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 4547b67ce9..a6efb32924 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -138,60 +138,59 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, /** * Read w:pPr * - * @return string|array|null + * @return array|null */ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode) { - $style = null; - if ($xmlReader->elementExists('w:pPr', $domNode)) { - if ($xmlReader->elementExists('w:pPr/w:pStyle', $domNode)) { - $style = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:pStyle'); - } else { - $style = array(); - $mapping = array( - 'w:ind' => 'indent', 'w:spacing' => 'spacing', - 'w:jc' => 'align', 'w:basedOn' => 'basedOn', 'w:next' => 'next', - 'w:widowControl' => 'widowControl', 'w:keepNext' => 'keepNext', - 'w:keepLines' => 'keepLines', 'w:pageBreakBefore' => 'pageBreakBefore', - ); - - $nodes = $xmlReader->getElements('w:pPr/*', $domNode); - foreach ($nodes as $node) { - if (!array_key_exists($node->nodeName, $mapping)) { - continue; - } - $property = $mapping[$node->nodeName]; - switch ($node->nodeName) { - - case 'w:ind': - $style['indent'] = $xmlReader->getAttribute('w:left', $node); - $style['hanging'] = $xmlReader->getAttribute('w:hanging', $node); - break; - - case 'w:spacing': - $style['spaceAfter'] = $xmlReader->getAttribute('w:after', $node); - $style['spaceBefore'] = $xmlReader->getAttribute('w:before', $node); - // Commented. Need to adjust the number when return value is null - // $style['spacing'] = $xmlReader->getAttribute('w:line', $node); - break; - - case 'w:keepNext': - case 'w:keepLines': - case 'w:pageBreakBefore': - $style[$property] = true; - break; - - case 'w:widowControl': - $style[$property] = false; - break; + if (!$xmlReader->elementExists('w:pPr', $domNode)) { + return; + } - case 'w:jc': - case 'w:basedOn': - case 'w:next': - $style[$property] = $xmlReader->getAttribute('w:val', $node); - break; - } - } + $style = array(); + $mapping = array( + 'w:pStyle' => 'styleName', + 'w:ind' => 'indent', 'w:spacing' => 'spacing', + 'w:jc' => 'align', 'w:basedOn' => 'basedOn', 'w:next' => 'next', + 'w:widowControl' => 'widowControl', 'w:keepNext' => 'keepNext', + 'w:keepLines' => 'keepLines', 'w:pageBreakBefore' => 'pageBreakBefore', + ); + + $nodes = $xmlReader->getElements('w:pPr/*', $domNode); + foreach ($nodes as $node) { + if (!array_key_exists($node->nodeName, $mapping)) { + continue; + } + $property = $mapping[$node->nodeName]; + switch ($node->nodeName) { + + case 'w:ind': + $style['indent'] = $xmlReader->getAttribute('w:left', $node); + $style['hanging'] = $xmlReader->getAttribute('w:hanging', $node); + break; + + case 'w:spacing': + $style['spaceAfter'] = $xmlReader->getAttribute('w:after', $node); + $style['spaceBefore'] = $xmlReader->getAttribute('w:before', $node); + // Commented. Need to adjust the number when return value is null + // $style['spacing'] = $xmlReader->getAttribute('w:line', $node); + break; + + case 'w:keepNext': + case 'w:keepLines': + case 'w:pageBreakBefore': + $style[$property] = true; + break; + + case 'w:widowControl': + $style[$property] = false; + break; + + case 'w:pStyle': + case 'w:jc': + case 'w:basedOn': + case 'w:next': + $style[$property] = $xmlReader->getAttribute('w:val', $node); + break; } } @@ -201,70 +200,69 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode /** * Read w:rPr * - * @return string|array|null + * @return array|null */ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode) { - $style = null; + if (is_null($domNode)) { + return; + } // Hyperlink has an extra w:r child if ($domNode->nodeName == 'w:hyperlink') { $domNode = $xmlReader->getElement('w:r', $domNode); } - if (is_null($domNode)) { - return $style; + if (!$xmlReader->elementExists('w:rPr', $domNode)) { + return; } - if ($xmlReader->elementExists('w:rPr', $domNode)) { - if ($xmlReader->elementExists('w:rPr/w:rStyle', $domNode)) { - $style = $xmlReader->getAttribute('w:val', $domNode, 'w:rPr/w:rStyle'); - } else { - $style = array(); - $mapping = array( - 'w:b' => 'bold', 'w:i' => 'italic', 'w:color' => 'color', - 'w:strike' => 'strikethrough', 'w:u' => 'underline', - 'w:highlight' => 'fgColor', 'w:sz' => 'size', - 'w:rFonts' => 'name', 'w:vertAlign' => 'superScript', - ); - $nodes = $xmlReader->getElements('w:rPr/*', $domNode); - foreach ($nodes as $node) { - if (!array_key_exists($node->nodeName, $mapping)) { - continue; - } - $property = $mapping[$node->nodeName]; - switch ($node->nodeName) { - - case 'w:rFonts': - $style['name'] = $xmlReader->getAttribute('w:ascii', $node); - $style['hint'] = $xmlReader->getAttribute('w:hint', $node); - break; - - case 'w:b': - case 'w:i': - case 'w:strike': - $style[$property] = true; - break; - - case 'w:u': - case 'w:highlight': - case 'w:color': - $style[$property] = $xmlReader->getAttribute('w:val', $node); - break; - - case 'w:sz': - $style[$property] = $xmlReader->getAttribute('w:val', $node) / 2; - break; - - case 'w:vertAlign': - $style[$property] = $xmlReader->getAttribute('w:val', $node); - if ($style[$property] == 'superscript') { - $style['superScript'] = true; - } else { - $style['superScript'] = false; - $style['subScript'] = true; - } - break; + $style = array(); + $mapping = array( + 'w:rStyle' => 'styleName', + 'w:b' => 'bold', 'w:i' => 'italic', 'w:color' => 'color', + 'w:strike' => 'strikethrough', 'w:u' => 'underline', + 'w:highlight' => 'fgColor', 'w:sz' => 'size', + 'w:rFonts' => 'name', 'w:vertAlign' => 'superScript', + ); + + $nodes = $xmlReader->getElements('w:rPr/*', $domNode); + foreach ($nodes as $node) { + if (!array_key_exists($node->nodeName, $mapping)) { + continue; + } + $property = $mapping[$node->nodeName]; + switch ($node->nodeName) { + + case 'w:rFonts': + $style['name'] = $xmlReader->getAttribute('w:ascii', $node); + $style['hint'] = $xmlReader->getAttribute('w:hint', $node); + break; + + case 'w:b': + case 'w:i': + case 'w:strike': + $style[$property] = true; + break; + + case 'w:rStyle': + case 'w:u': + case 'w:highlight': + case 'w:color': + $style[$property] = $xmlReader->getAttribute('w:val', $node); + break; + + case 'w:sz': + $style[$property] = $xmlReader->getAttribute('w:val', $node) / 2; + break; + + case 'w:vertAlign': + $style[$property] = $xmlReader->getAttribute('w:val', $node); + if ($style[$property] == 'superscript') { + $style['superScript'] = true; + } else { + $style['superScript'] = false; + $style['subScript'] = true; } - } + break; } } diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 082596af3b..e4fbb9a56c 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -160,9 +160,6 @@ protected function setNonEmptyVal($value, $default) */ protected function setBoolVal($value, $default = null) { - if (is_string($value)) { - $value = (bool)$value; - } if (!is_bool($value)) { $value = $default; } @@ -187,7 +184,7 @@ protected function setNumericVal($value, $default = null) } /** - * Set integer value + * Set float value: Convert string that contains only numeric into integer * * @param mixed $value * @param int|null $default @@ -195,7 +192,7 @@ protected function setNumericVal($value, $default = null) */ protected function setIntVal($value, $default = null) { - if (is_string($value)) { + if (is_string($value) && (preg_match('/[^\d]/', $value) == 0)) { $value = intval($value); } if (!is_int($value)) { @@ -206,7 +203,7 @@ protected function setIntVal($value, $default = null) } /** - * Set float value + * Set float value: Convert string that contains only numeric into float * * @param mixed $value * @param float|null $default @@ -214,7 +211,7 @@ protected function setIntVal($value, $default = null) */ protected function setFloatVal($value, $default = null) { - if (is_string($value)) { + if (is_string($value) && (preg_match('/[^\d\.\,]/', $value) == 0)) { $value = floatval($value); } if (!is_float($value)) { @@ -231,9 +228,11 @@ protected function setFloatVal($value, $default = null) * @param array $enum * @param mixed $default */ - protected function setEnumVal($value, $enum, $default = null) + protected function setEnumVal($value = null, $enum = array(), $default = null) { - if (!in_array($value, $enum)) { + if (!is_null($value) && !empty($enum) && !in_array($value, $enum)) { + throw new \InvalidArgumentException('Invalid style value.'); + } elseif (is_null($value)) { $value = $default; } @@ -249,7 +248,7 @@ protected function setEnumVal($value, $enum, $default = null) */ protected function setObjectVal($value, $styleName, &$style) { - $styleClass = __NAMESPACE__ . '\\' . $styleName; + $styleClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $styleName; if (is_array($value)) { if (!$style instanceof $styleClass) { $style = new $styleClass(); diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 31b7e30792..e44ffa38d3 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -22,6 +22,16 @@ */ class Cell extends Border { + /** + * Vertical alignment constants + * + * @const string + */ + const VALIGN_TOP = 'top'; + const VALIGN_CENTER = 'center'; + const VALIGN_BOTTOM = 'bottom'; + const VALIGN_BOTH = 'both'; + /** * Text direction constants * @@ -30,6 +40,14 @@ class Cell extends Border const TEXT_DIR_BTLR = 'btLr'; const TEXT_DIR_TBRL = 'tbRl'; + /** + * Vertical merge (rowspan) constants + * + * @const string + */ + const VMERGE_RESTART = 'restart'; + const VMERGE_CONTINUE = 'continue'; + /** * Default border color * @@ -56,7 +74,7 @@ class Cell extends Border * * @var integer */ - private $gridSpan = null; + private $gridSpan; /** * rowspan (restart, continue) @@ -66,7 +84,7 @@ class Cell extends Border * * @var string */ - private $vMerge = null; + private $vMerge; /** * Shading @@ -87,10 +105,14 @@ public function getVAlign() * Set vertical align * * @param string $value + * @return self */ public function setVAlign($value = null) { - $this->vAlign = $value; + $enum = array(self::VALIGN_TOP, self::VALIGN_CENTER, self::VALIGN_BOTTOM, self::VALIGN_BOTH); + $this->vAlign = $this->setEnumVal($value, $enum, $this->vAlign); + + return $this; } /** @@ -105,10 +127,14 @@ public function getTextDirection() * Set text direction * * @param string $value + * @return self */ public function setTextDirection($value = null) { - $this->textDirection = $value; + $enum = array(self::TEXT_DIR_BTLR, self::TEXT_DIR_TBRL); + $this->textDirection = $this->setEnumVal($value, $enum, $this->textDirection); + + return $this; } /** @@ -134,40 +160,47 @@ public function setBgColor($value = null) return $this->setShading(array('fill' => $value)); } + /** + * Get grid span (colspan) + */ + public function getGridSpan() + { + return $this->gridSpan; + } + /** * Set grid span (colspan) * * @param int $value + * @return self */ public function setGridSpan($value = null) { - $this->gridSpan = $value; + $this->gridSpan = $this->setIntVal($value, $this->gridSpan); + + return $this; } /** - * Get grid span (colspan) + * Get vertical merge (rowspan) */ - public function getGridSpan() + public function getVMerge() { - return $this->gridSpan; + return $this->vMerge; } /** * Set vertical merge (rowspan) * * @param string $value + * @return self */ public function setVMerge($value = null) { - $this->vMerge = $value; - } + $enum = array(self::VMERGE_RESTART, self::VMERGE_CONTINUE); + $this->vMerge = $this->setEnumVal($value, $enum, $this->vMerge); - /** - * Get vertical merge (rowspan) - */ - public function getVMerge() - { - return $this->vMerge; + return $this; } /** diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index f0ee893e67..57d0770aeb 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -216,6 +216,16 @@ public function __construct($type = 'text', $paragraph = null) $this->setParagraph($paragraph); } + /** + * Get style type + * + * @return string + */ + public function getStyleType() + { + return $this->type; + } + /** * Get font name * @@ -570,16 +580,6 @@ public function setBgColor($value = null) $this->setShading(array('fill' => $value)); } - /** - * Get style type - * - * @return string - */ - public function getStyleType() - { - return $this->type; - } - /** * Get line height * @@ -650,9 +650,9 @@ public function setShading($value = null) } /** - * Toggle $target value to false when $source true + * Toggle $target property to false when $source true * - * @param \PhpOffice\PhpWord\Style\AbstractStyle $target + * @param mixed $target Target property * @param bool $sourceValue */ private function toggleFalse(&$target, $sourceValue) diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 540d3d4f0b..5dc82d0b9f 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -117,7 +117,7 @@ class Image extends AbstractStyle * * @var string */ - private $wrappingStyle; + private $wrappingStyle = self::WRAPPING_STYLE_INLINE; /** * Positioning type (relative or absolute) @@ -131,40 +131,28 @@ class Image extends AbstractStyle * * @var string */ - private $posHorizontal; + private $posHorizontal = self::POSITION_HORIZONTAL_LEFT; /** * Horizontal Relation * * @var string */ - private $posHorizontalRel; + private $posHorizontalRel = self::POSITION_RELATIVE_TO_CHAR; /** * Vertical alignment * * @var string */ - private $posVertical; + private $posVertical = self::POSITION_VERTICAL_TOP; /** * Vertical Relation * * @var string */ - private $posVerticalRel; - - /** - * Create new image style - */ - public function __construct() - { - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - $this->setPosHorizontal(self::POSITION_HORIZONTAL_LEFT); - $this->setPosHorizontalRel(self::POSITION_RELATIVE_TO_CHAR); - $this->setPosVertical(self::POSITION_VERTICAL_TOP); - $this->setPosVerticalRel(self::POSITION_RELATIVE_TO_LINE); - } + private $posVerticalRel = self::POSITION_RELATIVE_TO_LINE; /** * Get width @@ -283,14 +271,12 @@ public function getWrappingStyle() */ public function setWrappingStyle($wrappingStyle) { - $enum = array(self::WRAPPING_STYLE_INLINE, self::WRAPPING_STYLE_INFRONT, self::WRAPPING_STYLE_BEHIND, - self::WRAPPING_STYLE_SQUARE, self::WRAPPING_STYLE_TIGHT); - - if (in_array($wrappingStyle, $enum)) { - $this->wrappingStyle = $wrappingStyle; - } else { - throw new \InvalidArgumentException('Invalid wrapping style.'); - } + $enum = array( + self::WRAPPING_STYLE_INLINE, + self::WRAPPING_STYLE_INFRONT, self::WRAPPING_STYLE_BEHIND, + self::WRAPPING_STYLE_SQUARE, self::WRAPPING_STYLE_TIGHT, + ); + $this->wrappingStyle = $this->setEnumVal($wrappingStyle, $enum, $this->wrappingStyle); return $this; } @@ -315,12 +301,7 @@ public function getPositioning() public function setPositioning($positioning) { $enum = array(self::POSITION_RELATIVE, self::POSITION_ABSOLUTE); - - if (in_array($positioning, $enum)) { - $this->positioning = $positioning; - } else { - throw new \InvalidArgumentException('Invalid positioning.'); - } + $this->positioning = $this->setEnumVal($positioning, $enum, $this->positioning); return $this; } @@ -344,14 +325,11 @@ public function getPosHorizontal() */ public function setPosHorizontal($alignment) { - $enum = array(self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, - self::POSITION_HORIZONTAL_RIGHT); - - if (in_array($alignment, $enum)) { - $this->posHorizontal = $alignment; - } else { - throw new \InvalidArgumentException('Invalid horizontal alignment.'); - } + $enum = array( + self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, + self::POSITION_HORIZONTAL_RIGHT, + ); + $this->posHorizontal = $this->setEnumVal($alignment, $enum, $this->posHorizontal); return $this; } @@ -375,14 +353,12 @@ public function getPosVertical() */ public function setPosVertical($alignment) { - $enum = array(self::POSITION_VERTICAL_TOP, self::POSITION_VERTICAL_CENTER, - self::POSITION_VERTICAL_BOTTOM, self::POSITION_VERTICAL_INSIDE, self::POSITION_VERTICAL_OUTSIDE); - - if (in_array($alignment, $enum)) { - $this->posVertical = $alignment; - } else { - throw new \InvalidArgumentException('Invalid vertical alignment.'); - } + $enum = array( + self::POSITION_VERTICAL_TOP, self::POSITION_VERTICAL_CENTER, + self::POSITION_VERTICAL_BOTTOM, self::POSITION_VERTICAL_INSIDE, + self::POSITION_VERTICAL_OUTSIDE, + ); + $this->posVertical = $this->setEnumVal($alignment, $enum, $this->posVertical); return $this; } @@ -406,16 +382,13 @@ public function getPosHorizontalRel() */ public function setPosHorizontalRel($relto) { - $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + $enum = array( + self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, self::POSITION_RELATIVE_TO_COLUMN, self::POSITION_RELATIVE_TO_CHAR, self::POSITION_RELATIVE_TO_LMARGIN, self::POSITION_RELATIVE_TO_RMARGIN, - self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); - - if (in_array($relto, $enum)) { - $this->posHorizontalRel = $relto; - } else { - throw new \InvalidArgumentException('Invalid relative horizontal alignment.'); - } + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN, + ); + $this->posHorizontalRel = $this->setEnumVal($relto, $enum, $this->posHorizontalRel); return $this; } @@ -439,16 +412,13 @@ public function getPosVerticalRel() */ public function setPosVerticalRel($relto) { - $enum = array(self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, + $enum = array( + self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, self::POSITION_RELATIVE_TO_LINE, self::POSITION_RELATIVE_TO_TMARGIN, self::POSITION_RELATIVE_TO_BMARGIN, - self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN); - - if (in_array($relto, $enum)) { - $this->posVerticalRel = $relto; - } else { - throw new \InvalidArgumentException('Invalid relative vertical alignment.'); - } + self::POSITION_RELATIVE_TO_IMARGIN, self::POSITION_RELATIVE_TO_OMARGIN, + ); + $this->posVerticalRel = $this->setEnumVal($relto, $enum, $this->posVerticalRel); return $this; } diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 6b5366cd46..554d75b025 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -86,14 +86,19 @@ public function getListType() * Set legacy list type for version < 0.10.0 * * @param integer $value + * @return self */ public function setListType($value = self::TYPE_BULLET_FILLED) { - $enum = array(self::TYPE_SQUARE_FILLED, self::TYPE_BULLET_FILLED, + $enum = array( + self::TYPE_SQUARE_FILLED, self::TYPE_BULLET_FILLED, self::TYPE_BULLET_EMPTY, self::TYPE_NUMBER, - self::TYPE_NUMBER_NESTED, self::TYPE_ALPHANUM); + self::TYPE_NUMBER_NESTED, self::TYPE_ALPHANUM + ); $this->listType = $this->setEnumVal($value, $enum, $this->listType); $this->getListTypeStyle(); + + return $this; } /** @@ -110,6 +115,7 @@ public function getNumStyle() * Set numbering style name * * @param string $value + * @return self */ public function setNumStyle($value) { @@ -119,6 +125,8 @@ public function setNumStyle($value) $this->numId = $numStyleObject->getIndex(); $numStyleObject->setNumId($this->numId); } + + return $this; } /** diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php index d92f6f3fed..726af2bec7 100644 --- a/src/PhpWord/Style/Numbering.php +++ b/src/PhpWord/Style/Numbering.php @@ -69,6 +69,7 @@ public function getNumId() public function setNumId($value) { $this->numId = $this->setIntVal($value, $this->numId); + return $this; } @@ -92,6 +93,7 @@ public function setType($value) { $enum = array('singleLevel', 'multilevel', 'hybridMultilevel'); $this->type = $this->setEnumVal($value, $enum, $this->type); + return $this; } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index b04646eac8..2765aca455 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -125,10 +125,8 @@ public function setStyleValue($key, $value) } elseif ($key == 'spacing') { $value += 240; // because line height of 1 matches 240 twips } - $method = 'set' . $key; - if (method_exists($this, $method)) { - $this->$method($value); - } + + return parent::setStyleValue($key, $value); } /** diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index c3f2722aae..310564d89d 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -71,6 +71,8 @@ public function isTblHeader() public function setTblHeader($value = false) { $this->tblHeader = $this->setBoolVal($value, $this->tblHeader); + + return $this; } /** @@ -92,6 +94,8 @@ public function isCantSplit() public function setCantSplit($value = false) { $this->cantSplit = $this->setBoolVal($value, $this->cantSplit); + + return $this; } /** @@ -113,6 +117,7 @@ public function isExactHeight() public function setExactHeight($value = false) { $this->exactHeight = $this->setBoolVal($value, $this->exactHeight); + return $this; } diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index 7306c6a6c4..8a0c071d74 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -261,7 +261,7 @@ public function getMarginTop() * @param int|float $value * @return self */ - public function setMarginTop($value = '') + public function setMarginTop($value = null) { $this->marginTop = $this->setNumericVal($value, self::DEFAULT_MARGIN); @@ -284,7 +284,7 @@ public function getMarginLeft() * @param int|float $value * @return self */ - public function setMarginLeft($value = '') + public function setMarginLeft($value = null) { $this->marginLeft = $this->setNumericVal($value, self::DEFAULT_MARGIN); @@ -307,7 +307,7 @@ public function getMarginRight() * @param int|float $value * @return self */ - public function setMarginRight($value = '') + public function setMarginRight($value = null) { $this->marginRight = $this->setNumericVal($value, self::DEFAULT_MARGIN); @@ -330,7 +330,7 @@ public function getMarginBottom() * @param int|float $value * @return self */ - public function setMarginBottom($value = '') + public function setMarginBottom($value = null) { $this->marginBottom = $this->setNumericVal($value, self::DEFAULT_MARGIN); @@ -353,7 +353,7 @@ public function getGutter() * @param int|float $value * @return self */ - public function setGutter($value = '') + public function setGutter($value = null) { $this->gutter = $this->setNumericVal($value, self::DEFAULT_GUTTER); @@ -376,7 +376,7 @@ public function getHeaderHeight() * @param int|float $value * @return self */ - public function setHeaderHeight($value = '') + public function setHeaderHeight($value = null) { $this->headerHeight = $this->setNumericVal($value, self::DEFAULT_HEADER_HEIGHT); @@ -399,7 +399,7 @@ public function getFooterHeight() * @param int|float $value * @return self */ - public function setFooterHeight($value = '') + public function setFooterHeight($value = null) { $this->footerHeight = $this->setNumericVal($value, self::DEFAULT_FOOTER_HEIGHT); @@ -444,7 +444,7 @@ public function getColsNum() * @param int $value * @return self */ - public function setColsNum($value = '') + public function setColsNum($value = null) { $this->colsNum = $this->setIntVal($value, self::DEFAULT_COLUMN_COUNT); @@ -467,7 +467,7 @@ public function getColsSpace() * @param int|float $value * @return self */ - public function setColsSpace($value = '') + public function setColsSpace($value = null) { $this->colsSpace = $this->setNumericVal($value, self::DEFAULT_COLUMN_SPACING); diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php index 3e970e6e0b..5c9742c962 100644 --- a/src/PhpWord/Style/Shading.php +++ b/src/PhpWord/Style/Shading.php @@ -89,9 +89,10 @@ public function getPattern() */ public function setPattern($value = null) { - $enum = array(self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE, - self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS); - + $enum = array( + self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE, + self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS + ); $this->pattern = $this->setEnumVal($value, $enum, $this->pattern); return $this; diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 6ec4318f04..5285565278 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -36,7 +36,7 @@ class TOC extends Tab /** * Indent * - * @var int + * @var int|float (twip) */ private $indent = 200; @@ -51,7 +51,7 @@ public function __construct() /** * Get Tab Position * - * @return int + * @return int|float */ public function getTabPos() { @@ -61,11 +61,12 @@ public function getTabPos() /** * Set Tab Position * - * @param int $value + * @param int|float $value + * @return self */ public function setTabPos($value) { - $this->setPosition($value); + return $this->setPosition($value); } /** @@ -82,16 +83,17 @@ public function getTabLeader() * Set Tab Leader * * @param string $value + * @return self */ public function setTabLeader($value = self::TAB_LEADER_DOT) { - $this->setLeader($value); + return $this->setLeader($value); } /** * Get Indent * - * @return int + * @return int|float */ public function getIndent() { @@ -101,10 +103,13 @@ public function getIndent() /** * Set Indent * - * @param string $value + * @param int|float $value + * @return self */ public function setIndent($value) { - $this->indent = $value; + $this->indent = $this->setNumericVal($value, $this->indent); + + return $this; } } diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index 4bbba164db..900e1fbdf9 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -107,12 +107,18 @@ public function getType() * Set stop type * * @param string $value + * @return self */ public function setType($value) { - $enum = array(self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER, - self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM); + $enum = array( + self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER, + self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, + self::TAB_STOP_NUM, + ); $this->type = $this->setEnumVal($value, $enum, $this->type); + + return $this; } /** @@ -129,12 +135,17 @@ public function getLeader() * Set leader * * @param string $value + * @return self */ public function setLeader($value) { - $enum = array(self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN, - self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT); + $enum = array( + self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN, + self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT, + ); $this->leader = $this->setEnumVal($value, $enum, $this->leader); + + return $this; } /** @@ -151,9 +162,12 @@ public function getPosition() * Set position * * @param int|float $value + * @return self */ public function setPosition($value) { $this->position = $this->setNumericVal($value, $this->position); + + return $this; } } diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 9173d0d754..c9850e73c4 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -112,15 +112,11 @@ public function __construct($styleTable = null, $styleFirstRow = null) unset($this->firstRow->borderInsideVSize); unset($this->firstRow->borderInsideHColor); unset($this->firstRow->borderInsideHSize); - foreach ($styleFirstRow as $key => $value) { - $this->firstRow->setStyleValue($key, $value); - } + $this->firstRow->setStyleByArray($styleFirstRow); } if (!is_null($styleTable) && is_array($styleTable)) { - foreach ($styleTable as $key => $value) { - $this->setStyleValue($key, $value); - } + $this->setStyleByArray($styleTable); } } diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index 7ad8a00db3..85525129fb 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -73,7 +73,8 @@ public function __construct(HTML $parentWriter, AbstractElement $element, $witho public function write() { $content = ''; - $writerClass = __NAMESPACE__ . '\\' . basename(get_class($this->element)); + $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . + basename(get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index d460deac5c..7a2126e470 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -68,7 +68,8 @@ public function __construct(RTF $parentWriter, AbstractElement $element, $withou public function write() { $content = ''; - $writerClass = __NAMESPACE__ . '\\' . basename(get_class($this->element)); + $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . + basename(get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 377241eeda..4b3c8109df 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -32,15 +32,16 @@ class Container extends AbstractElement public function write() { $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); + $container = $this->getElement(); // Loop through subelements - $containerClass = basename(get_class($element)); - $subelements = $element->getElements(); + $containerClass = basename(get_class($container)); + $subelements = $container->getElements(); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; if (count($subelements) > 0) { foreach ($subelements as $subelement) { - $writerClass = __NAMESPACE__ . '\\' . basename(get_class($subelement)); + $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . + basename(get_class($subelement)); if (class_exists($writerClass)) { $writer = new $writerClass($xmlWriter, $subelement, $withoutP); $writer->write(); @@ -49,7 +50,7 @@ public function write() } else { // Special case for Cell: They have to contain a TextBreak at least if ($containerClass == 'Cell') { - $writerClass = __NAMESPACE__ . '\\TextBreak'; + $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\TextBreak'; $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); $writer->write(); } diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 02af5b4ed6..108e7a0eb3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -85,18 +85,20 @@ public function write() $xmlWriter->startElement('w:name'); $xmlWriter->writeAttribute('w:val', $styleName); $xmlWriter->endElement(); - if (!is_null($paragraphStyle)) { - // Point parent style to Normal - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', 'Normal'); - $xmlWriter->endElement(); + // Parent style + $xmlWriter->writeElementIf(!is_null($paragraphStyle), 'w:basedOn', 'w:val', 'Normal'); + + // w:pPr + if (!is_null($paragraphStyle)) { $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); $styleWriter->write(); } + // w:rPr $styleWriter = new FontStyleWriter($xmlWriter, $style); $styleWriter->write(); + $xmlWriter->endElement(); // Paragraph style @@ -108,23 +110,19 @@ public function write() $xmlWriter->startElement('w:name'); $xmlWriter->writeAttribute('w:val', $styleName); $xmlWriter->endElement(); + // Parent style $basedOn = $style->getBasedOn(); - if (!is_null($basedOn)) { - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', $basedOn); - $xmlWriter->endElement(); - } + $xmlWriter->writeElementIf(!is_null($basedOn), 'w:basedOn', 'w:val', $basedOn); + // Next paragraph style $next = $style->getNext(); - if (!is_null($next)) { - $xmlWriter->startElement('w:next'); - $xmlWriter->writeAttribute('w:val', $next); - $xmlWriter->endElement(); - } + $xmlWriter->writeElementIf(!is_null($next), 'w:next', 'w:val', $next); + // w:pPr $styleWriter = new ParagraphStyleWriter($xmlWriter, $style); $styleWriter->write(); + $xmlWriter->endElement(); // Table style diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index 5f38f77d45..76c347f057 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -58,8 +58,9 @@ public function write() } // Shading - if (!is_null($style->getShading())) { - $styleWriter = new Shading($xmlWriter, $style->getShading()); + $shading = $style->getShading(); + if (!is_null($shading)) { + $styleWriter = new Shading($xmlWriter, $shading); $styleWriter->write(); } diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index aac53038f8..5965d5a4c4 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -61,16 +61,16 @@ private function writeStyle() return; } $xmlWriter = $this->getXmlWriter(); - $font = $style->getName(); - $color = $style->getColor(); - $size = $style->getSize(); - $underline = $style->getUnderline(); - $fgColor = $style->getFgColor(); - $hint = $style->getHint(); $xmlWriter->startElement('w:rPr'); + // Style name + $styleName = $style->getStyleName(); + $xmlWriter->writeElementIf(!is_null($styleName), 'w:rStyle', 'w:val', $styleName); + // Font name/family + $font = $style->getName(); + $hint = $style->getHint(); if ($font != PhpWord::DEFAULT_FONT_NAME) { $xmlWriter->startElement('w:rFonts'); $xmlWriter->writeAttribute('w:ascii', $font); @@ -82,7 +82,11 @@ private function writeStyle() } // Color + $color = $style->getColor(); $xmlWriter->writeElementIf($color != PhpWord::DEFAULT_FONT_COLOR, 'w:color', 'w:val', $color); + + // Size + $size = $style->getSize(); $xmlWriter->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:sz', 'w:val', $size * 2); $xmlWriter->writeElementIf($size != PhpWord::DEFAULT_FONT_SIZE, 'w:szCs', 'w:val', $size * 2); @@ -100,9 +104,11 @@ private function writeStyle() $xmlWriter->writeElementIf($style->isAllCaps(), 'w:caps'); // Underline + $underline = $style->getUnderline(); $xmlWriter->writeElementIf($underline != 'none', 'w:u', 'w:val', $underline); // Foreground-Color + $fgColor = $style->getFgColor(); $xmlWriter->writeElementIf(!is_null($fgColor), 'w:highlight', 'w:val', $fgColor); // Superscript/subscript @@ -110,8 +116,9 @@ private function writeStyle() $xmlWriter->writeElementIf($style->isSubScript(), 'w:vertAlign', 'w:val', 'subscript'); // Background-Color - if (!is_null($style->getShading())) { - $styleWriter = new Shading($xmlWriter, $style->getShading()); + $shading = $style->getShading(); + if (!is_null($shading)) { + $styleWriter = new Shading($xmlWriter, $shading); $styleWriter->write(); } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index 2dd3398cbd..f933875974 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -38,12 +38,35 @@ class Image extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + if (!is_null($this->getStyle())) { + $this->writeStyle(); + } + } + + /** + * Write w10 wrapping + * + * @return array + */ + public function writeW10Wrap() + { + if (is_null($this->w10wrap)) { return; } + $xmlWriter = $this->getXmlWriter(); - $wrapping = $style->getWrappingStyle(); - $positioning = $style->getPositioning(); + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $this->w10wrap); + $xmlWriter->endElement(); // w10:wrap + } + + /** + * Write style attribute + */ + protected function writeStyle() + { + $xmlWriter = $this->getXmlWriter(); + $style = $this->getStyle(); // Default style array $styleArray = array( @@ -52,9 +75,10 @@ public function write() 'mso-width-relative' => 'margin', 'mso-height-relative' => 'margin', ); - $styleArray = array_merge($styleArray, $this->getElementStyle($style)); + $styleArray = array_merge($styleArray, $this->getElementStyle()); // Absolute/relative positioning + $positioning = $style->getPositioning(); $styleArray['position'] = $positioning; if ($positioning == ImageStyle::POSITION_ABSOLUTE) { $styleArray['mso-position-horizontal-relative'] = 'page'; @@ -69,6 +93,7 @@ public function write() } // Wrapping style + $wrapping = $style->getWrappingStyle(); if ($wrapping == ImageStyle::WRAPPING_STYLE_INLINE) { // Nothing to do when inline } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_BEHIND) { @@ -91,29 +116,14 @@ public function write() $xmlWriter->writeAttribute('style', $imageStyle); } - /** - * Write w10 wrapping - * - * @return array - */ - public function writeW10Wrap() - { - $xmlWriter = $this->getXmlWriter(); - - if (!is_null($this->w10wrap)) { - $xmlWriter->startElement('w10:wrap'); - $xmlWriter->writeAttribute('type', $this->w10wrap); - $xmlWriter->endElement(); // w10:wrap - } - } - /** * Get element style * * @return array */ - protected function getElementStyle(ImageStyle $style) + private function getElementStyle() { + $style = $this->getStyle(); $styles = array(); $styleValues = array( 'width' => $style->getWidth(), diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index 60fbd5404a..797179b7cd 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -33,14 +33,18 @@ public function write() return; } $xmlWriter = $this->getXmlWriter(); - $firstLine = $style->getFirstLine(); - $hanging = $style->getHanging(); $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttribute('w:left', $this->convertTwip($style->getLeft())); $xmlWriter->writeAttribute('w:right', $this->convertTwip($style->getRight())); + + $firstLine = $style->getFirstLine(); $xmlWriter->writeAttributeIf(!is_null($firstLine), 'w:firstLine', $this->convertTwip($firstLine)); + + $hanging = $style->getHanging(); $xmlWriter->writeAttributeIf(!is_null($hanging), 'w:hanging', $this->convertTwip($hanging)); + $xmlWriter->endElement(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index c2caea116b..7056028aa6 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -70,16 +70,17 @@ private function writeStyle() return; } $xmlWriter = $this->getXmlWriter(); - $align = $style->getAlign(); - $indentation = $style->getIndentation(); - $spacing = $style->getSpace(); - $tabs = $style->getTabs(); if (!$this->withoutPPR) { $xmlWriter->startElement('w:pPr'); } + // Style name + $styleName = $style->getStyleName(); + $xmlWriter->writeElementIf(!is_null($styleName), 'w:pStyle', 'w:val', $styleName); + // Alignment + $align = $style->getAlign(); $xmlWriter->writeElementIf(!is_null($align), 'w:jc', 'w:val', $align); // Pagination @@ -89,18 +90,21 @@ private function writeStyle() $xmlWriter->writeElementIf($style->hasPageBreakBefore(), 'w:pageBreakBefore', 'w:val', '1'); // Indentation + $indentation = $style->getIndentation(); if (!is_null($indentation)) { $styleWriter = new Indentation($xmlWriter, $indentation); $styleWriter->write(); } // Spacing + $spacing = $style->getSpace(); if (!is_null($spacing)) { $styleWriter = new Spacing($xmlWriter, $spacing); $styleWriter->write(); } // Tabs + $tabs = $style->getTabs(); if (!empty($tabs)) { $xmlWriter->startElement("w:tabs"); foreach ($tabs as $tab) { diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index faa9b7499c..b594d9c0dc 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -33,15 +33,18 @@ public function write() return; } $xmlWriter = $this->getXmlWriter(); - $before = $style->getBefore(); - $after = $style->getAfter(); - $line = $style->getLine(); $xmlWriter->startElement('w:spacing'); + $before = $style->getBefore(); $xmlWriter->writeAttributeIf(!is_null($before), 'w:before', $this->convertTwip($before)); + + $after = $style->getAfter(); $xmlWriter->writeAttributeIf(!is_null($after), 'w:after', $this->convertTwip($after)); + + $line = $style->getLine(); $xmlWriter->writeAttributeIf(!is_null($line), 'w:line', $line); + $xmlWriter->writeAttributeIf(!is_null($line), 'w:lineRule', $style->getRule()); $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 6b5569cf6d..7be6e6ae79 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -40,9 +40,9 @@ public function write() return; } $xmlWriter = $this->getXmlWriter(); + $hasBorders = $style->hasBorders(); $hasMargins = $style->hasMargins(); - if ($hasMargins || $hasBorders) { $xmlWriter->startElement('w:tblPr'); if ($hasMargins) { @@ -64,6 +64,7 @@ public function write() } $xmlWriter->endElement(); // w:tblPr } + // Only write background color and first row for full style if ($this->isFullStyle) { // Background color diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index f526f888dd..ee9c74cc19 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle; /** @@ -31,63 +32,69 @@ class TextBox extends Image */ public function write() { - if (is_null($style = $this->getStyle())) { - return; + if (!is_null($this->getStyle())) { + $this->writeStyle(); + $this->writeBorder(); } - $xmlWriter = $this->getXmlWriter(); - $wrapping = $style->getWrappingStyle(); - $positioning = $style->getPositioning(); - - // Default style array - $styleArray = array( - 'mso-width-percent' => '0', - 'mso-height-percent' => '0', - 'mso-width-relative' => 'margin', - 'mso-height-relative' => 'margin', - ); - $styleArray = array_merge($styleArray, $this->getElementStyle($style)); + } - // Absolute/relative positioning - $styleArray['position'] = $positioning; - if ($positioning == TextBoxStyle::POSITION_ABSOLUTE) { - $styleArray['mso-position-horizontal-relative'] = 'page'; - $styleArray['mso-position-vertical-relative'] = 'page'; - } elseif ($positioning == TextBoxStyle::POSITION_RELATIVE) { - $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); - $styleArray['mso-position-vertical'] = $style->getPosVertical(); - $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); - $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); - $styleArray['margin-left'] = 0; - $styleArray['margin-top'] = 0; + /** + * Write w10 wrapping + * + * @return array + */ + public function writeW10Wrap() + { + if (is_null($this->w10wrap)) { + return; } - // Wrapping style - if ($wrapping == TextBoxStyle::WRAPPING_STYLE_INLINE) { - // Nothing to do when inline - } elseif ($wrapping == TextBoxStyle::WRAPPING_STYLE_BEHIND) { - $styleArray['z-index'] = -251658752; - } else { - $styleArray['z-index'] = 251659264; - $styleArray['mso-position-horizontal'] = 'absolute'; - $styleArray['mso-position-vertical'] = 'absolute'; - } + $relativePositions = array( + TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin', + TextBoxStyle::POSITION_RELATIVE_TO_PAGE => 'page', + TextBoxStyle::POSITION_RELATIVE_TO_TMARGIN => 'margin', + TextBoxStyle::POSITION_RELATIVE_TO_BMARGIN => 'page', + TextBoxStyle::POSITION_RELATIVE_TO_LMARGIN => 'margin', + TextBoxStyle::POSITION_RELATIVE_TO_RMARGIN => 'page', + ); + $pos = $style->getPositioning(); + $vPos = $style->getPosVerticalRel(); + $hPos = $style->getPosHorizontalRel(); - // w10 wrapping - if ($wrapping == TextBoxStyle::WRAPPING_STYLE_SQUARE) { - $this->w10wrap = 'square'; - } elseif ($wrapping == TextBoxStyle::WRAPPING_STYLE_TIGHT) { - $this->w10wrap = 'tight'; + $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $this->w10wrap); + + if ($pos == TextBoxStyle::POSITION_ABSOLUTE) { + $xmlWriter->writeAttribute('anchorx', "page"); + $xmlWriter->writeAttribute('anchory', "page"); + } elseif ($pos == TextBoxStyle::POSITION_RELATIVE) { + if (array_key_exists($vPos, $relativePositions)) { + $xmlWriter->writeAttribute('anchory', $relativePositions[$vPos]); + } + if (array_key_exists($hPos, $relativePositions)) { + $xmlWriter->writeAttribute('anchorx', $relativePositions[$hPos]); + } } - $textboxStyle = $this->assembleStyle($styleArray); + $xmlWriter->endElement(); // w10:wrap + } - $xmlWriter->writeAttribute('style', $textboxStyle); + /** + * Writer border + */ + private function writeBorder() + { + $xmlWriter = $this->getXmlWriter(); + $style = $this->getStyle(); + // Border size $borderSize = $style->getBorderSize(); if ($borderSize !== null) { - $xmlWriter->writeAttribute('strokeweight', $style->getBorderSize().'pt'); + $xmlWriter->writeAttribute('strokeweight', $borderSize . 'pt'); } + // Border color $borderColor = $style->getBorderColor(); if (empty($borderColor)) { $xmlWriter->writeAttribute('stroked', 'f'); @@ -95,59 +102,5 @@ public function write() $xmlWriter->writeAttribute('strokecolor', $borderColor); } //@todo - - } - - /** - * Write w10 wrapping - * - * @return array - */ - public function writeW10Wrap() - { - $xmlWriter = $this->getXmlWriter(); - - if (!is_null($this->w10wrap)) { - $xmlWriter->startElement('w10:wrap'); - $xmlWriter->writeAttribute('type', $this->w10wrap); - - switch ($style->getPositioning()) { - case TextBoxStyle::POSITION_ABSOLUTE: - $xmlWriter->writeAttribute('anchorx', "page"); - $xmlWriter->writeAttribute('anchory', "page"); - break; - case TextBoxStyle::POSITION_RELATIVE: - switch ($style->getPosVerticalRel()) { - case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: - $xmlWriter->writeAttribute('anchory', "margin"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: - $xmlWriter->writeAttribute('anchory', "page"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_TMARGIN: - $xmlWriter->writeAttribute('anchory', "margin"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_BMARGIN: - $xmlWriter->writeAttribute('anchory', "page"); - break; - } - switch ($style->getPosHorizontalRel()) { - case TextBoxStyle::POSITION_RELATIVE_TO_MARGIN: - $xmlWriter->writeAttribute('anchorx', "margin"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_PAGE: - $xmlWriter->writeAttribute('anchorx', "page"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_LMARGIN: - $xmlWriter->writeAttribute('anchorx', "margin"); - break; - case TextBoxStyle::POSITION_RELATIVE_TO_RMARGIN: - $xmlWriter->writeAttribute('anchorx', "page"); - break; - } - } - - $xmlWriter->endElement(); // w10:wrap - } } } diff --git a/tests/PhpWord/Tests/Style/AbstractStyleTest.php b/tests/PhpWord/Tests/Style/AbstractStyleTest.php index 3822252013..15ff8facdc 100644 --- a/tests/PhpWord/Tests/Style/AbstractStyleTest.php +++ b/tests/PhpWord/Tests/Style/AbstractStyleTest.php @@ -58,6 +58,18 @@ public function testSetValDefault() $this->assertEquals(false, self::callProtectedMethod($stub, 'setBoolVal', array('a', false))); $this->assertEquals(200, self::callProtectedMethod($stub, 'setIntVal', array('foo', 200))); $this->assertEquals(2.1, self::callProtectedMethod($stub, 'setFloatVal', array('foo', 2.1))); + $this->assertEquals('b', self::callProtectedMethod($stub, 'setEnumVal', array(null, array('a', 'b'), 'b'))); + } + + /** + * Test setEnumVal exception + * + * @expectedException \InvalidArgumentException + */ + public function testSetValEnumException() + { + $stub = $this->getMockForAbstractClass('\PhpOffice\PhpWord\Style\AbstractStyle'); + $this->assertEquals('b', self::callProtectedMethod($stub, 'setEnumVal', array('z', array('a', 'b'), 'b'))); } diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 2f5c49c6b3..74aa5e2e48 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -97,7 +97,7 @@ public function testSetStyleValueNormal() 'fgColor' => Font::FGCOLOR_YELLOW, 'bgColor' => 'FFFF00', 'hint' => 'eastAsia', - 'line-height' => 2, + 'lineHeight' => 2, ); $object->setStyleByArray($attributes); foreach ($attributes as $key => $value) { diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index a6b386d925..dd7273cb0f 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -249,12 +249,14 @@ public function testColumnsNum() // Default $this->assertEquals(1, $oSettings->getColsNum()); + // Null value + $oSettings->setColsNum(); + $this->assertEquals(1, $oSettings->getColsNum()); + + // Random value $iVal = rand(1, 1000); $oSettings->setColsNum($iVal); $this->assertEquals($iVal, $oSettings->getColsNum()); - - $oSettings->setColsNum(); - $this->assertEquals(1, $oSettings->getColsNum()); } /** From 8a1d07f71a7e8feba54f893a266e2a3b6dcf2f59 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 8 May 2014 22:42:56 +0700 Subject: [PATCH 053/167] Fix Travis test errors --- CHANGELOG.md | 2 +- composer.json | 4 ++-- src/PhpWord/Element/TextBox.php | 2 -- src/PhpWord/Style/AbstractStyle.php | 4 ++-- src/PhpWord/Style/Font.php | 3 +-- src/PhpWord/Style/NumberingLevel.php | 3 ++- src/PhpWord/Style/TextBox.php | 18 ++++++++++++++++++ src/PhpWord/Writer/ODText/Element/Table.php | 3 --- .../Writer/Word2007/Element/TextBox.php | 14 ++------------ .../Writer/Word2007/Element/TextRun.php | 2 -- src/PhpWord/Writer/Word2007/Part/Styles.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 2 -- src/PhpWord/Writer/Word2007/Style/TextBox.php | 16 ++++++++++++++++ tests/PhpWord/Tests/Style/CellTest.php | 4 ++-- 14 files changed, 47 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b309236f48..f23ca1476a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin - Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 - QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 -- Word2007 Writer: Refactor writer parts using composite pattern - @ivanlanin +- Writer: Refactor writer parts using composite pattern - @ivanlanin - Docs: Show code quality and test code coverage badge on README ## 0.10.0 - 4 May 2014 diff --git a/composer.json b/composer.json index 8396f07375..a7b16860ef 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { "name": "phpoffice/phpword", - "description": "PHPWord - Read, Create, and Write DOCX, ODT, and RTF documents in PHP", + "description": "PHPWord - A pure PHP library for reading and writing word processing documents (DOCX, ODT, RTF, HTML, PDF)", "keywords": [ "PHP", "PhpOffice", "office", "PhpWord", "word", "template", "reader", "writer", "docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML", - "RTF", "Rich Text Format", "doc", "odt", "OpenDocument" + "RTF", "Rich Text Format", "doc", "odt", "OpenDocument", "PDF", "HTML" ], "homepage": "http://phpoffice.github.io", "type": "library", diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 041c2657fd..c3c83d8122 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -36,8 +36,6 @@ class TextBox extends AbstractContainer /** * Create a new textbox * - * @param string $docPart - * @param integer $docPartId * @param mixed $style */ public function __construct($style = null) diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index e4fbb9a56c..d909a20af0 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -230,9 +230,9 @@ protected function setFloatVal($value, $default = null) */ protected function setEnumVal($value = null, $enum = array(), $default = null) { - if (!is_null($value) && !empty($enum) && !in_array($value, $enum)) { + if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) { throw new \InvalidArgumentException('Invalid style value.'); - } elseif (is_null($value)) { + } elseif (is_null($value) || trim($value) == '') { $value = $default; } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 57d0770aeb..32874b2f0a 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Exception\InvalidStyleException; use PhpOffice\PhpWord\PhpWord; /** @@ -652,7 +651,7 @@ public function setShading($value = null) /** * Toggle $target property to false when $source true * - * @param mixed $target Target property + * @param bool $target Target property * @param bool $sourceValue */ private function toggleFalse(&$target, $sourceValue) diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index be9b9b258d..465231a75c 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -377,10 +377,11 @@ public function getHint() * @param string $value * @return self */ - public function setHint($value) + public function setHint($value = null) { $enum = array('default', 'eastAsia', 'cs'); $this->hint = $this->setEnumVal($value, $enum, $this->hint); + return $this; } } diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index 401e2cc01f..2beeaed1d2 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -169,6 +169,24 @@ public function getInnerMargin() return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom); } + /** + * Has inner margin? + * + * @return bool + */ + public function hasInnerMargins() + { + $hasInnerMargins = false; + $margins = $this->getInnerMargins(); + for ($i = 0; $i < count($margins); $i++) { + if (!is_null($margins[$i])) { + $hasInnerMargins = true; + } + } + + return $hasInnerMargins; + } + /** * Set border size * diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index d8664fac36..411f1f38a3 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -17,9 +17,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; -use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; -use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter; - /** * Table element writer * diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 1ee8a4cbcd..d464b967df 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\TextBox as TextBoxStyleWriter; /** @@ -35,11 +34,7 @@ public function write() $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); $style = $element->getStyle(); - - if ($style instanceof TextBoxStyle) { - $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); - $styleWriter->write(); - } + $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); if (!$this->withoutP) { $xmlWriter->startElement('w:p'); @@ -57,20 +52,15 @@ public function write() $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('type', '#_x0000_t0202'); $styleWriter->write(); - $xmlWriter->startElement('v:textbox'); - $margins = implode(', ', $style->getInnerMargin()); - $xmlWriter->writeAttribute('inset', $margins); - + $styleWriter->writeInnerMargin(); $xmlWriter->startElement('w:txbxContent'); $xmlWriter->startElement('w:p'); $containerWriter = new Container($xmlWriter, $element); $containerWriter->write(); $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // w:txbxContent - $xmlWriter->endElement(); // v: textbox - $styleWriter->writeW10Wrap(); $xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // w:pict diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index 0343b16c1b..cb72ab18ae 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; - /** * TextRun element writer * diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 108e7a0eb3..13e07e71c8 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -62,7 +62,7 @@ public function write() // Font style if ($style instanceof Font) { - $paragraphStyle = $style->getParagraphStyle(); + $paragraphStyle = $style->getParagraph(); $styleType = $style->getStyleType(); $type = ($styleType == 'title') ? 'paragraph' : 'character'; if (!is_null($paragraphStyle)) { diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 7be6e6ae79..7c59fd03b5 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -94,8 +94,6 @@ public function setIsFullStyle($value) /** * Write row style - * - * @param string $type */ private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style) { diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index ee9c74cc19..6020a2b057 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -48,6 +48,7 @@ public function writeW10Wrap() if (is_null($this->w10wrap)) { return; } + $style = $this->getStyle(); $relativePositions = array( TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin', @@ -80,6 +81,21 @@ public function writeW10Wrap() $xmlWriter->endElement(); // w10:wrap } + /** + * Writer inner margin + */ + public function writeInnerMargin() + { + $style = $this->getStyle(); + if (!$style->hasInnerMargins()) { + return; + } + + $xmlWriter = $this->getXmlWriter(); + $margins = implode(', ', $style->getInnerMargin()); + $xmlWriter->writeAttribute('inset', $margins); + } + /** * Writer border */ diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index cb08cd2ba6..1a02671043 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -35,7 +35,7 @@ public function testSetGetNormal() $object = new Cell(); $attributes = array( - 'valign' => 'left', + 'valign' => Cell::VALIGN_TOP, 'textDirection' => Cell::TEXT_DIR_BTLR, 'bgColor' => 'FFFF00', 'borderTopSize' => 120, @@ -47,7 +47,7 @@ public function testSetGetNormal() 'borderBottomSize' => 120, 'borderBottomColor' => 'FFFF00', 'gridSpan' => 2, - 'vMerge' => 2, + 'vMerge' => Cell::VMERGE_RESTART, ); foreach ($attributes as $key => $value) { $set = "set{$key}"; From 6f0579c78f523b1f7bec9c41a8047a78008c28fe Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 9 May 2014 00:28:29 +0700 Subject: [PATCH 054/167] Fix Travis build error --- src/PhpWord/Element/AbstractContainer.php | 2 +- src/PhpWord/Writer/HTML/Element/Element.php | 3 +-- src/PhpWord/Writer/ODText/Element/Container.php | 6 ++++++ src/PhpWord/Writer/ODText/Part/Content.php | 2 +- src/PhpWord/Writer/ODText/Part/Styles.php | 2 +- src/PhpWord/Writer/RTF/Element/Element.php | 3 +-- .../Writer/Word2007/Element/AbstractElement.php | 7 +------ src/PhpWord/Writer/Word2007/Element/Container.php | 14 ++++++++++---- .../Writer/Word2007/Style/AbstractStyle.php | 7 ------- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index b2e2aad4a1..290c54d994 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -39,7 +39,7 @@ abstract class AbstractContainer extends AbstractElement */ protected function addElement(AbstractElement $element) { - // $type = basename(get_class($element)); + // $type = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($element))); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); $element->setPhpWord($this->phpWord); diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php index 85525129fb..5098ba2e3f 100644 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/Element.php @@ -73,8 +73,7 @@ public function __construct(HTML $parentWriter, AbstractElement $element, $witho public function write() { $content = ''; - $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . - basename(get_class($this->element)); + $writerClass = str_replace('\\Element\\', '\\Writer\\HTML\\Element\\', get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/ODText/Element/Container.php b/src/PhpWord/Writer/ODText/Element/Container.php index 4f3080a911..30517bb959 100644 --- a/src/PhpWord/Writer/ODText/Element/Container.php +++ b/src/PhpWord/Writer/ODText/Element/Container.php @@ -24,4 +24,10 @@ */ class Container extends \PhpOffice\PhpWord\Writer\Word2007\Element\Container { + /** + * Namespace; Can't use __NAMESPACE__ in inherited class (ODText) + * + * @var string + */ + protected $namespace = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element'; } diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index d5f1353c5d..f5ae1883dc 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -101,7 +101,7 @@ private function writeAutomaticStyles(XMLWriter $xmlWriter, PhpWord $phpWord) if (preg_match('#^T[0-9]+$#', $styleName) != 0 || preg_match('#^P[0-9]+$#', $styleName) != 0 ) { - $styleClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . basename(get_class($style)); + $styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style)); if (class_exists($styleClass)) { $styleWriter = new $styleClass($xmlWriter, $style); $styleWriter->setIsAuto(true); diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index bc4bf4f367..7641d94f86 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -91,7 +91,7 @@ public function write() if (preg_match('#^T[0-9]+$#', $styleName) == 0 && preg_match('#^P[0-9]+$#', $styleName) == 0 ) { - $styleClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . basename(get_class($style)); + $styleClass = str_replace('\\Style\\', '\\Writer\\ODText\\Style\\', get_class($style)); if (class_exists($styleClass)) { $styleWriter = new $styleClass($xmlWriter, $style); $styleWriter->write(); diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/RTF/Element/Element.php index 7a2126e470..8464a37721 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/RTF/Element/Element.php @@ -68,8 +68,7 @@ public function __construct(RTF $parentWriter, AbstractElement $element, $withou public function write() { $content = ''; - $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . - basename(get_class($this->element)); + $writerClass = str_replace('\\Element\\', '\\Writer\\RTF\\Element\\', get_class($this->element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); $content = $writer->write(); diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 67cffdc62e..65b3c400fc 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -84,12 +84,7 @@ protected function getXmlWriter() protected function getElement() { if (!is_null($this->element)) { - $elementClass = 'PhpOffice\\PhpWord\\Element\\' . basename(get_class($this->element)); - if ($this->element instanceof $elementClass) { - return $this->element; - } else { - throw new Exception('No valid element assigned.'); - } + return $this->element; } else { throw new Exception('No element assigned.'); } diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 4b3c8109df..de2e90d925 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -26,6 +26,13 @@ */ class Container extends AbstractElement { + /** + * Namespace; Can't use __NAMESPACE__ in inherited class (ODText) + * + * @var string + */ + protected $namespace = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element'; + /** * Write element */ @@ -35,13 +42,12 @@ public function write() $container = $this->getElement(); // Loop through subelements - $containerClass = basename(get_class($container)); + $containerClass = substr(get_class($container), strrpos(get_class($this), '\\') + 1); $subelements = $container->getElements(); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; if (count($subelements) > 0) { foreach ($subelements as $subelement) { - $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . - basename(get_class($subelement)); + $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, get_class($subelement)); if (class_exists($writerClass)) { $writer = new $writerClass($xmlWriter, $subelement, $withoutP); $writer->write(); @@ -50,7 +56,7 @@ public function write() } else { // Special case for Cell: They have to contain a TextBreak at least if ($containerClass == 'Cell') { - $writerClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\TextBreak'; + $writerClass = "{$this->namespace}\\TextBreak"; $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); $writer->write(); } diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 7213e4aae7..dad0ce07eb 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -75,13 +75,6 @@ protected function getXmlWriter() */ protected function getStyle() { - if (!is_null($this->style)) { - $styleClass = 'PhpOffice\\PhpWord\\Style\\' . basename(get_class($this->style)); - if (is_object($this->style) && (!$this->style instanceof $styleClass)) { - throw new Exception('No valid style assigned.'); - } - } - return $this->style; } From ade740b562793670155d2c081de97265410abdcc Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 8 May 2014 21:38:54 +0200 Subject: [PATCH 055/167] Fixed a bug in TextBox; addText to a TextBox was treated 'withoutP'. This is not the expected behaviour --- src/PhpWord/Writer/Word2007/Element/TextBox.php | 2 -- src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index fd1683aea9..b732ffaba4 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -57,9 +57,7 @@ public function write() $margins = implode(', ', $tbxStyle->getInnerMargin()); $this->xmlWriter->writeAttribute('inset', $margins); $this->xmlWriter->startElement('w:txbxContent'); - $this->xmlWriter->startElement('w:p'); $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); - $this->xmlWriter->endElement(); // w:p $this->xmlWriter->endElement(); // w:txbxContent $this->xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index d1717e9b28..b09613a638 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -110,7 +110,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co // Loop through elements $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; + $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; if (count($elements) > 0) { foreach ($elements as $element) { if ($element instanceof AbstractElement) { From 841bc2ac69ac24bcec92f6c6d679526a6955526b Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 8 May 2014 21:41:30 +0200 Subject: [PATCH 056/167] Revert "Fixed a bug in TextBox; addText to a TextBox was treated 'withoutP'. This is not the expected behaviour" This reverts commit ade740b562793670155d2c081de97265410abdcc. --- src/PhpWord/Writer/Word2007/Element/TextBox.php | 2 ++ src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index b732ffaba4..fd1683aea9 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -57,7 +57,9 @@ public function write() $margins = implode(', ', $tbxStyle->getInnerMargin()); $this->xmlWriter->writeAttribute('inset', $margins); $this->xmlWriter->startElement('w:txbxContent'); + $this->xmlWriter->startElement('w:p'); $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); + $this->xmlWriter->endElement(); // w:p $this->xmlWriter->endElement(); // w:txbxContent $this->xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index b09613a638..d1717e9b28 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -110,7 +110,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co // Loop through elements $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; if (count($elements) > 0) { foreach ($elements as $element) { if ($element instanceof AbstractElement) { From 474d36040a6578fdb2c9194f2a816ed07d649a3b Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 8 May 2014 21:43:55 +0200 Subject: [PATCH 057/167] Fixed a bug in TextBox; addText to a TextBox was treated 'withoutP'. This is not the expected behaviour --- src/PhpWord/Writer/Word2007/Element/TextBox.php | 2 -- src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index fd1683aea9..b732ffaba4 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -57,9 +57,7 @@ public function write() $margins = implode(', ', $tbxStyle->getInnerMargin()); $this->xmlWriter->writeAttribute('inset', $margins); $this->xmlWriter->startElement('w:txbxContent'); - $this->xmlWriter->startElement('w:p'); $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); - $this->xmlWriter->endElement(); // w:p $this->xmlWriter->endElement(); // w:txbxContent $this->xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index d1717e9b28..b09613a638 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -110,7 +110,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co // Loop through elements $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; + $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; if (count($elements) > 0) { foreach ($elements as $element) { if ($element instanceof AbstractElement) { From 246557e3be6d7a689723abb61deea489d6f66a39 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 9 May 2014 02:09:20 +0700 Subject: [PATCH 058/167] Reactivate PHPMD and fix some rules for textbox --- .travis.yml | 2 +- samples/Sample_25_TextBox.php | 31 ++++++++++++++----- src/PhpWord/Element/AbstractContainer.php | 19 ++++++------ src/PhpWord/Style/TextBox.php | 2 +- .../Writer/Word2007/Element/Container.php | 4 +-- .../Writer/Word2007/Element/TextBox.php | 5 +-- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50587e4982..7593379cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ script: ## PHP Copy/Paste Detector - php phpcpd.phar src/ tests/ --verbose ## PHP Mess Detector - #- phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php + - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php index 575a1df5ce..1946315f0f 100644 --- a/samples/Sample_25_TextBox.php +++ b/samples/Sample_25_TextBox.php @@ -6,14 +6,29 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$textbox = $section->addTextBox(array('align' => 'left', 'width' => 300, 'borderSize' => 1, 'borderColor' => '#FF0000')); -$textbox->addText('Text box content '); -$textbox->addText('with bold text', array('bold' => true)); -$textbox->addText(', '); -$textbox->addLink('http://www.google.com', 'link'); -$textbox->addText(', and image '); -$textbox->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); -$textbox->addText('.'); + +// In section +$textbox = $section->addTextBox(array('align' => 'left', 'width' => 400, 'borderSize' => 1, 'borderColor' => '#FF0000')); +$textbox->addText('Text box content in section.'); +$textbox->addText('Another line.'); + +// Inside table +$section->addTextBreak(2); +$cell = $section->addTable()->addRow()->addCell(300); +$textbox = $cell->addTextBox(array('borderSize' => 1, 'borderColor' => '#0000FF', 'innerMargin' => 100)); +$textbox->addText('Inside table'); + +// Inside header with textrun +$header = $section->addHeader(); +$textbox = $header->addTextBox(array('align' => 'center', 'width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00')); +$textrun = $textbox->addTextRun(); +$textrun->addText('TextBox in header. TextBox can contain a TextRun '); +$textrun->addText('with bold text', array('bold' => true)); +$textrun->addText(', '); +$textrun->addLink('http://www.google.com', 'link'); +$textrun->addText(', and image '); +$textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); +$textrun->addText('.'); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 290c54d994..8b72f6608a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -100,7 +100,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme */ public function addTextRun($paragraphStyle = null) { - $this->checkValidity('Textrun'); + $this->checkValidity('TextRun'); $element = new TextRun($paragraphStyle); $element->setDocPart($this->getDocPart(), $this->getDocPartId()); @@ -327,10 +327,10 @@ private function checkValidity($method) 'TextBreak' => $allContainers, 'Image' => $allContainers, 'Object' => $allContainers, - 'TextRun' => array('section', 'header', 'footer', 'cell'), - 'ListItem' => array('section', 'header', 'footer', 'cell'), + 'TextRun' => array('section', 'header', 'footer', 'cell', 'textbox'), + 'ListItem' => array('section', 'header', 'footer', 'cell', 'textbox'), 'CheckBox' => array('section', 'header', 'footer', 'cell'), - 'TextBox' => array('section', 'header', 'footer'), + 'TextBox' => array('section', 'header', 'footer', 'cell'), 'Footnote' => array('section', 'textrun', 'cell'), 'Endnote' => array('section', 'textrun', 'cell'), 'PreserveText' => array('header', 'footer', 'cell'), @@ -346,7 +346,7 @@ private function checkValidity($method) // 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(); + throw new \BadMethodCallException("Cannot put $method in $this->container."); } } // Check if a method is valid for current container, located in other container @@ -356,7 +356,7 @@ private function checkValidity($method) $allowedDocParts = $rules[1]; foreach ($containers as $container) { if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { - throw new \BadMethodCallException(); + throw new \BadMethodCallException("Cannot put $method in $this->container."); } } } @@ -369,11 +369,12 @@ private function checkValidity($method) */ private function checkElementDocPart() { - $isCellTextrun = in_array($this->container, array('cell', 'textrun', 'textbox')); - $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; - $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; + $inOtherPart = in_array($this->container, array('cell', 'textrun', 'textbox')); + $docPart = $inOtherPart ? $this->getDocPart() : $this->container; + $docPartId = $inOtherPart ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; + return $inHeaderFooter ? $docPart . $docPartId : $docPart; } diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index 2beeaed1d2..da19cd101f 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -177,7 +177,7 @@ public function getInnerMargin() public function hasInnerMargins() { $hasInnerMargins = false; - $margins = $this->getInnerMargins(); + $margins = $this->getInnerMargin(); for ($i = 0; $i < count($margins); $i++) { if (!is_null($margins[$i])) { $hasInnerMargins = true; diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index de2e90d925..0561509d4e 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -42,9 +42,9 @@ public function write() $container = $this->getElement(); // Loop through subelements - $containerClass = substr(get_class($container), strrpos(get_class($this), '\\') + 1); + $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $subelements = $container->getElements(); - $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; if (count($subelements) > 0) { foreach ($subelements as $subelement) { $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, get_class($subelement)); diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index d464b967df..6b63c31ae8 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -54,12 +54,13 @@ public function write() $styleWriter->write(); $xmlWriter->startElement('v:textbox'); $styleWriter->writeInnerMargin(); + + // TextBox content, serving as a container $xmlWriter->startElement('w:txbxContent'); - $xmlWriter->startElement('w:p'); $containerWriter = new Container($xmlWriter, $element); $containerWriter->write(); - $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // w:txbxContent + $xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); $xmlWriter->endElement(); // v:shape From 0b13b22e07af71d9781f04fdaa8f931eea6f5134 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 9 May 2014 14:57:06 +0700 Subject: [PATCH 059/167] Refactor HTML & PDF writer with composite pattern --- src/PhpWord/Reader/Word2007/Document.php | 4 +- src/PhpWord/Style/Paragraph.php | 1 - src/PhpWord/Writer/HTML.php | 115 +++++++------ .../Element/AbstractElement.php} | 31 ++-- src/PhpWord/Writer/HTML/Element/Container.php | 50 ++++++ src/PhpWord/Writer/HTML/Element/Element.php | 84 ---------- src/PhpWord/Writer/HTML/Element/Footnote.php | 13 +- src/PhpWord/Writer/HTML/Element/Image.php | 17 +- src/PhpWord/Writer/HTML/Element/Link.php | 16 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 10 +- src/PhpWord/Writer/HTML/Element/Table.php | 34 ++-- src/PhpWord/Writer/HTML/Element/Text.php | 155 +++++++++++++++--- src/PhpWord/Writer/HTML/Element/TextBreak.php | 8 +- src/PhpWord/Writer/HTML/Element/TextRun.php | 32 +--- src/PhpWord/Writer/HTML/Element/Title.php | 10 +- .../Writer/HTML/Style/AbstractStyle.php | 30 +++- src/PhpWord/Writer/HTML/Style/Font.php | 45 ++--- src/PhpWord/Writer/HTML/Style/Generic.php | 1 + src/PhpWord/Writer/HTML/Style/Image.php | 14 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 21 ++- src/PhpWord/Writer/RTF.php | 73 ++++----- .../Writer/RTF/Element/AbstractElement.php | 27 +++ src/PhpWord/Writer/RTF/Element/Container.php | 52 ++++++ src/PhpWord/Writer/RTF/Element/Text.php | 147 ++++++++--------- src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 29 +--- src/PhpWord/Writer/RTF/Element/Title.php | 12 +- .../Writer/RTF/Style/AbstractStyle.php | 29 ++++ src/PhpWord/Writer/RTF/Style/Font.php | 102 ++++++++++++ src/PhpWord/Writer/RTF/Style/Paragraph.php | 51 ++++++ .../Word2007/Element/AbstractElement.php | 2 +- .../Writer/Word2007/Element/Container.php | 4 +- 32 files changed, 736 insertions(+), 485 deletions(-) rename src/PhpWord/Writer/{RTF/Element/Element.php => HTML/Element/AbstractElement.php} (62%) create mode 100644 src/PhpWord/Writer/HTML/Element/Container.php delete mode 100644 src/PhpWord/Writer/HTML/Element/Element.php create mode 100644 src/PhpWord/Writer/RTF/Element/AbstractElement.php create mode 100644 src/PhpWord/Writer/RTF/Element/Container.php create mode 100644 src/PhpWord/Writer/RTF/Style/AbstractStyle.php create mode 100644 src/PhpWord/Writer/RTF/Style/Font.php create mode 100644 src/PhpWord/Writer/RTF/Style/Paragraph.php diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 7f5635e371..d38b3fb94b 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -133,8 +133,8 @@ private function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$par $headingMatches = array(); if ($xmlReader->elementExists('w:pPr', $domNode)) { $paragraphStyle = $this->readParagraphStyle($xmlReader, $domNode); - if (is_string($paragraphStyle)) { - preg_match('/Heading(\d)/', $paragraphStyle, $headingMatches); + if (is_array($paragraphStyle) && array_key_exists('styleName', $paragraphStyle)) { + preg_match('/Heading(\d)/', $paragraphStyle['styleName'], $headingMatches); } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 2765aca455..79a12242a0 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -148,7 +148,6 @@ public function getAlign() public function setAlign($value = null) { if (strtolower($value) == 'justify') { - // justify becames both $value = 'both'; } $this->align = $value; diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index e28d773319..d292d9ab73 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -23,7 +23,7 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Writer\HTML\Element\Element as ElementWriter; +use PhpOffice\PhpWord\Writer\HTML\Element\Container; use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Generic as GenericStyleWriter; @@ -89,20 +89,20 @@ public function save($filename = null) */ public function writeDocument() { - $html = ''; - $html .= '' . PHP_EOL; - $html .= '' . PHP_EOL; - $html .= '' . PHP_EOL; - $html .= '' . PHP_EOL; - $html .= $this->writeHTMLHead(); - $html .= '' . PHP_EOL; - $html .= '' . PHP_EOL; - $html .= $this->writeHTMLBody(); - $html .= $this->writeNotes(); - $html .= '' . PHP_EOL; - $html .= '' . PHP_EOL; + $content = ''; + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; + $content .= $this->writeHead(); + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; + $content .= $this->writeBody(); + $content .= $this->writeNotes(); + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; - return $html; + return $content; } /** @@ -110,7 +110,7 @@ public function writeDocument() * * @return string */ - private function writeHTMLHead() + private function writeHead() { $properties = $this->getPhpWord()->getDocumentProperties(); $propertiesMapping = array( @@ -126,20 +126,20 @@ private function writeHTMLHead() $title = $properties->getTitle(); $title = ($title != '') ? $title : 'PHPWord'; - $html = ''; - $html .= '' . PHP_EOL; - $html .= '' . htmlspecialchars($title) . '' . PHP_EOL; + $content = ''; + $content .= '' . PHP_EOL; + $content .= '' . htmlspecialchars($title) . '' . PHP_EOL; foreach ($propertiesMapping as $key => $value) { $value = ($value == '') ? $key : $value; $method = "get" . $key; if ($properties->$method() != '') { - $html .= '' . PHP_EOL; } } - $html .= $this->writeStyles(); + $content .= $this->writeStyles(); - return $html; + return $content; } /** @@ -147,55 +147,22 @@ private function writeHTMLHead() * * @return string */ - private function writeHTMLBody() + private function writeBody() { $phpWord = $this->getPhpWord(); - $html = ''; + $content = ''; $sections = $phpWord->getSections(); $countSections = count($sections); if ($countSections > 0) { foreach ($sections as $section) { - $elements = $section->getElements(); - foreach ($elements as $element) { - if ($element instanceof AbstractElement) { - $elementWriter = new ElementWriter($this, $element, false); - $html .= $elementWriter->write(); - } - } - } - } - - return $html; - } - - /** - * Write footnote/endnote contents as textruns - */ - private function writeNotes() - { - $phpWord = $this->getPhpWord(); - $html = ''; - - if (!empty($this->notes)) { - $html .= "
"; - foreach ($this->notes as $noteId => $noteMark) { - $noteAnchor = "note-{$noteId}"; - list($noteType, $noteTypeId) = explode('-', $noteMark); - $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); - $collection = $phpWord->$method()->getItems(); - if (array_key_exists($noteTypeId, $collection)) { - $element = $collection[$noteTypeId]; - $elmWriter = new TextRunWriter($this, $element, true); - $content = "{$noteId}"; - $content .= $elmWriter->write(); - $html .= "

{$content}

" . PHP_EOL; - } + $writer = new Container($this, $section); + $content .= $writer->write(); } } - return $html; + return $content; } /** @@ -253,6 +220,36 @@ private function writeStyles() return $css; } + /** + * Write footnote/endnote contents as textruns + */ + private function writeNotes() + { + $phpWord = $this->getPhpWord(); + $content = PHP_EOL; + + if (!empty($this->notes)) { + $content .= "
" . PHP_EOL; + foreach ($this->notes as $noteId => $noteMark) { + list($noteType, $noteTypeId) = explode('-', $noteMark); + $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); + $collection = $phpWord->$method()->getItems(); + + if (array_key_exists($noteTypeId, $collection)) { + $element = $collection[$noteTypeId]; + $noteAnchor = "
"; + $noteAnchor .= "{$noteId}"; + + $writer = new TextRunWriter($this, $element); + $writer->setOpeningText($noteAnchor); + $content .= $writer->write(); + } + } + } + + return $content; + } + /** * Get is PDF * diff --git a/src/PhpWord/Writer/RTF/Element/Element.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php similarity index 62% rename from src/PhpWord/Writer/RTF/Element/Element.php rename to src/PhpWord/Writer/HTML/Element/AbstractElement.php index 8464a37721..8da094144e 100644 --- a/src/PhpWord/Writer/RTF/Element/Element.php +++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php @@ -15,22 +15,22 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ -namespace PhpOffice\PhpWord\Writer\RTF\Element; +namespace PhpOffice\PhpWord\Writer\HTML\Element; -use PhpOffice\PhpWord\Element\AbstractElement; -use PhpOffice\PhpWord\Writer\RTF; +use PhpOffice\PhpWord\Element\AbstractElement as Element; +use PhpOffice\PhpWord\Writer\AbstractWriter; /** - * Generic element writer + * Abstract HTML element writer * - * @since 0.10.0 + * @since 0.11.0 */ -class Element +abstract class AbstractElement { /** * Parent writer * - * @var \PhpOffice\PhpWord\Writer\RTF + * @var \PhpOffice\PhpWord\Writer\AbstractWriter */ protected $parentWriter; @@ -53,7 +53,7 @@ class Element * * @param bool $withoutP */ - public function __construct(RTF $parentWriter, AbstractElement $element, $withoutP = false) + public function __construct(AbstractWriter $parentWriter, Element $element, $withoutP = false) { $this->parentWriter = $parentWriter; $this->element = $element; @@ -61,19 +61,12 @@ public function __construct(RTF $parentWriter, AbstractElement $element, $withou } /** - * Write element + * Set without paragraph * - * @return string + * @param bool $value */ - public function write() + public function setWithoutP($value) { - $content = ''; - $writerClass = str_replace('\\Element\\', '\\Writer\\RTF\\Element\\', get_class($this->element)); - if (class_exists($writerClass)) { - $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); - $content = $writer->write(); - } - - return $content; + $this->withoutP = $value; } } diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php new file mode 100644 index 0000000000..6249426aa5 --- /dev/null +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -0,0 +1,50 @@ +element; + $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $content = ''; + + $elements = $container->getElements(); + foreach ($elements as $element) { + $writerClass = str_replace('\\Element', '\\Writer\\HTML\\Element', get_class($element)); + if (class_exists($writerClass)) { + $writer = new $writerClass($this->parentWriter, $element, $withoutP); + $content .= $writer->write(); + } + } + + return $content; + } +} diff --git a/src/PhpWord/Writer/HTML/Element/Element.php b/src/PhpWord/Writer/HTML/Element/Element.php deleted file mode 100644 index 5098ba2e3f..0000000000 --- a/src/PhpWord/Writer/HTML/Element/Element.php +++ /dev/null @@ -1,84 +0,0 @@ -parentWriter = $parentWriter; - $this->element = $element; - $this->withoutP = $withoutP; - } - - /** - * Write element - * - * @return string - */ - public function write() - { - $content = ''; - $writerClass = str_replace('\\Element\\', '\\Writer\\HTML\\Element\\', get_class($this->element)); - if (class_exists($writerClass)) { - $writer = new $writerClass($this->parentWriter, $this->element, $this->withoutP); - $content = $writer->write(); - } - - return $content; - } -} diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index f1570ed0ba..cd1baacbd9 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Footnote extends Element +class Footnote extends AbstractElement { /** * Note type footnote|endnote @@ -32,21 +32,18 @@ class Footnote extends Element protected $noteType = 'footnote'; /** - * Write footnote/endnote marks + * Write footnote/endnote marks; The actual content is written in parent writer (HTML) * * @return string */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { - return; - } - $noteId = count($this->parentWriter->getNotes()) + 1; $noteMark = $this->noteType . '-' . $this->element->getRelationId(); + $content = "{$noteId}"; + $this->parentWriter->addNote($noteId, $noteMark); - $html = "{$noteId}"; - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 93c1082618..2ae8786584 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -25,7 +25,7 @@ * * @since 0.10.0 */ -class Image extends Element +class Image extends Text { /** * Write image @@ -34,25 +34,20 @@ class Image extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { - return; - } - - $html = ''; + $content = ''; if (!$this->parentWriter->isPdf()) { $imageData = $this->getBase64ImageData($this->element); if (!is_null($imageData)) { $styleWriter = new ImageStyleWriter($this->element->getStyle()); $style = $styleWriter->write(); - $html = ""; - if (!$this->withoutP) { - $html = "

{$html}

" . PHP_EOL; - } + $content .= $this->writeOpening(); + $content .= ""; + $content .= $this->writeClosing(); } } - return $html; + return $content; } /** diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 2792eb6719..6f1977f8aa 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Link extends Element +class Link extends Text { /** * Write link @@ -31,15 +31,11 @@ class Link extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { - return; - } + $content = ''; + $content .= $this->writeOpening(); + $content .= "element->getTarget()}\">{$this->element->getText()}"; + $content .= $this->writeClosing(); - $html = "element->getTarget()}\">{$this->element->getText()}" . PHP_EOL; - if (!$this->withoutP) { - $html = '

' . $html . '

' . PHP_EOL; - } - - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 89f2ad69f3..722d920a55 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class ListItem extends Element +class ListItem extends AbstractElement { /** * Write list item @@ -31,13 +31,9 @@ class ListItem extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { - return; - } - $text = htmlspecialchars($this->element->getTextObject()->getText()); - $html = '

' . $text . '

' . PHP_EOL; + $content = '

' . $text . '

' . PHP_EOL; - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index b3974554ac..a92deea6b7 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Table extends Element +class Table extends AbstractElement { /** * Write table @@ -31,40 +31,28 @@ class Table extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { - return; - } - - $html = ''; + $content = ''; $rows = $this->element->getRows(); $rowCount = count($rows); if ($rowCount > 0) { - $html .= '' . PHP_EOL; + $content .= '
' . PHP_EOL; foreach ($rows as $row) { // $height = $row->getHeight(); $rowStyle = $row->getStyle(); $tblHeader = $rowStyle->getTblHeader(); - $html .= '' . PHP_EOL; + $content .= '' . PHP_EOL; foreach ($row->getCells() as $cell) { + $writer = new Container($this->parentWriter, $cell); $cellTag = $tblHeader ? 'th' : 'td'; - $cellContents = $cell->getElements(); - $html .= "<{$cellTag}>" . PHP_EOL; - if (count($cellContents) > 0) { - foreach ($cellContents as $content) { - $writer = new Element($this->parentWriter, $content, false); - $html .= $writer->write(); - } - } else { - $writer = new Element($this->parentWriter, new \PhpOffice\PhpWord\Element\TextBreak(), false); - $html .= $writer->write(); - } - $html .= '' . PHP_EOL; + $content .= "<{$cellTag}>" . PHP_EOL; + $content .= $writer->write(); + $content .= '' . PHP_EOL; } - $html .= '' . PHP_EOL; + $content .= '' . PHP_EOL; } - $html .= '
' . PHP_EOL; + $content .= '' . PHP_EOL; } - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 96e0c25e7b..883a8cd33e 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -27,8 +27,36 @@ * * @since 0.10.0 */ -class Text extends Element +class Text extends AbstractElement { + /** + * Text written after opening + * + * @var string + */ + private $openingText = ''; + + /** + * Text written before closing + * + * @var string + */ + private $closingText = ''; + + /** + * Opening tags + * + * @var string + */ + private $openingTags = ''; + + /** + * Closing tag + * + * @var strings + */ + private $closingTags = ''; + /** * Write text * @@ -36,42 +64,117 @@ class Text extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { - return; + $this->getFontStyle(); + + $content = ''; + $content .= $this->writeOpening(); + $content .= $this->openingTags; + $content .= htmlspecialchars($this->element->getText()); + $content .= $this->closingTags; + $content .= $this->closingText; + $content .= $this->writeClosing(); + + return $content; + } + + /** + * Set opening text + * + * @param string $value + */ + public function setOpeningText($value) + { + $this->openingText = $value; + } + + /** + * Set closing text + * + * @param string $value + */ + public function setClosingText($value) + { + $this->closingText = $value; + } + + /** + * Write opening + * + * @return string + */ + protected function writeOpening() + { + $content = ''; + if (!$this->withoutP) { + $style = ''; + if (method_exists($this->element, 'getParagraphStyle')) { + $style = $this->getParagraphStyle(); + } + $content .= ""; + $content .= $this->openingText; + } + + return $content; + } + + /** + * Write ending + * + * @return string + */ + protected function writeClosing() + { + $content = ''; + if (!$this->withoutP) { + $content .= $this->closingText; + $content .= "

" . PHP_EOL; + } + + return $content; + } + + /** + * Write paragraph style + * + * @return string + */ + private function getParagraphStyle() + { + $style = ''; + if (method_exists($this->element, 'getParagraphStyle')) { + return $style; } - // Paragraph style $paragraphStyle = $this->element->getParagraphStyle(); $pStyleIsObject = ($paragraphStyle instanceof Paragraph); if ($pStyleIsObject) { $styleWriter = new ParagraphStyleWriter($paragraphStyle); - $paragraphStyle = $styleWriter->write(); + $style = $styleWriter->write(); } - $hasParagraphStyle = $paragraphStyle && !$this->withoutP; + if ($style) { + $attribute = $pStyleIsObject ? 'style' : 'class'; + $style = " {$attribute}=\"{$style}\""; + } + + return $style; + } - // Font style + /** + * Get font style + */ + private function getFontStyle() + { + $style = ''; $fontStyle = $this->element->getFontStyle(); - $fontStyleIsObject = ($fontStyle instanceof Font); - if ($fontStyleIsObject) { + $fStyleIsObject = ($fontStyle instanceof Font); + if ($fStyleIsObject) { $styleWriter = new FontStyleWriter($fontStyle); - $fontStyle = $styleWriter->write(); - } - - $openingTags = ''; - $endingTags = ''; - if ($hasParagraphStyle) { - $attribute = $pStyleIsObject ? 'style' : 'class'; - $openingTags = "

"; - $endingTags = '

' . PHP_EOL; + $style = $styleWriter->write(); } - if ($fontStyle) { - $attribute = $fontStyleIsObject ? 'style' : 'class'; - $openingTags = $openingTags . ""; - $endingTags = '' . $endingTags; + if ($style) { + $attribute = $fStyleIsObject ? 'style' : 'class'; + $this->openingTags = ""; + $this->closingTags = ""; } - - $html = $openingTags . htmlspecialchars($this->element->getText()) . $endingTags; - - return $html; } } diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php index 2e2c142a83..30560e9684 100644 --- a/src/PhpWord/Writer/HTML/Element/TextBreak.php +++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class TextBreak extends Element +class TextBreak extends AbstractElement { /** * Write text break @@ -32,11 +32,11 @@ class TextBreak extends Element public function write() { if ($this->withoutP) { - $html = '
' . PHP_EOL; + $content = '
' . PHP_EOL; } else { - $html = '

 

' . PHP_EOL; + $content = '

 

' . PHP_EOL; } - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index 604150434d..d8ea6d7263 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -27,7 +27,7 @@ * * @since 0.10.0 */ -class TextRun extends Element +class TextRun extends Text { /** * Write text run @@ -36,31 +36,13 @@ class TextRun extends Element */ public function write() { - if (!($this->element instanceof TextRunElement || $this->element instanceof FootnoteElement)) { - return; - } + $content = ''; - $html = ''; - $elements = $this->element->getElements(); - if (count($elements) > 0) { - // Paragraph style - $paragraphStyle = $this->element->getParagraphStyle(); - $pStyleIsObject = ($paragraphStyle instanceof Paragraph); - if ($pStyleIsObject) { - $styleWriter = new ParagraphStyleWriter($paragraphStyle); - $paragraphStyle = $styleWriter->write(); - } - $tag = $this->withoutP ? 'span' : 'p'; - $attribute = $pStyleIsObject ? 'style' : 'class'; - $html .= "<{$tag} {$attribute}=\"{$paragraphStyle}\">"; - foreach ($elements as $element) { - $elementWriter = new Element($this->parentWriter, $element, true); - $html .= $elementWriter->write(); - } - $html .= ""; - $html .= PHP_EOL; - } + $content .= $this->writeOpening(); + $writer = new Container($this->parentWriter, $this->element); + $content .= $writer->write(); + $content .= $this->writeClosing(); - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index e22522417a..2a33a2827a 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Title extends Element +class Title extends AbstractElement { /** * Write heading @@ -31,14 +31,10 @@ class Title extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { - return; - } - $tag = 'h' . $this->element->getDepth(); $text = htmlspecialchars($this->element->getText()); - $html = "<{$tag}>{$text}" . PHP_EOL; + $content = "<{$tag}>{$text}" . PHP_EOL; - return $html; + return $content; } } diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index a747e0e366..d25e7b6a5c 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\HTML\Style; +use PhpOffice\PhpWord\Style\AbstractStyle as Style; + /** * Style writer * @@ -29,7 +31,7 @@ abstract class AbstractStyle * * @var array|\PhpOffice\PhpWord\Style\AbstractStyle */ - protected $style; + private $style; /** * Write style @@ -46,6 +48,20 @@ public function __construct($style = null) $this->style = $style; } + /** + * Get style + * + * @return array|\PhpOffice\PhpWord\Style\AbstractStyle $style + */ + public function getStyle() + { + if (!$this->style instanceof Style && !is_array($this->style)) { + return; + } + + return $this->style; + } + /** * Takes array where of CSS properties / values and converts to CSS string * @@ -67,4 +83,16 @@ protected function assembleCss($css) return $string; } + + /** + * Get value if ... + * + * @param bool $condition + * @param string $value + * @return string + */ + protected function getValueIf($condition, $value) + { + return $condition ? $value : ''; + } } diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 7ab4dc400b..0c416e8f92 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -34,48 +34,29 @@ class Font extends AbstractStyle */ public function write() { - if (!$this->style instanceof \PhpOffice\PhpWord\Style\Font) { - return; - } - - $font = $this->style->getName(); - $size = $this->style->getSize(); - $color = $this->style->getColor(); - $fgColor = $this->style->getFgColor(); - $underline = $this->style->getUnderline() != FontStyle::UNDERLINE_NONE; - $lineThrough = $this->style->isStrikethrough() || $this->style->isDoubleStrikethrough(); - + $style = $this->getStyle(); $css = array(); + $font = $style->getName(); + $size = $style->getSize(); + $color = $style->getColor(); + $fgColor = $style->getFgColor(); + $underline = $style->getUnderline() != FontStyle::UNDERLINE_NONE; + $lineThrough = $style->isStrikethrough() || $style->isDoubleStrikethrough(); + $css['font-family'] = $this->getValueIf($font != PhpWord::DEFAULT_FONT_NAME, "'{$font}'"); $css['font-size'] = $this->getValueIf($size != PhpWord::DEFAULT_FONT_SIZE, "{$size}pt"); $css['color'] = $this->getValueIf($color != PhpWord::DEFAULT_FONT_COLOR, "#{$color}"); $css['background'] = $this->getValueIf($fgColor != '', $fgColor); - $css['font-weight'] = $this->getValueIf($this->style->isBold(), 'bold'); - $css['font-style'] = $this->getValueIf($this->style->isItalic(), 'italic'); - + $css['font-weight'] = $this->getValueIf($style->isBold(), 'bold'); + $css['font-style'] = $this->getValueIf($style->isItalic(), 'italic'); + $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'italic'); + $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'super'); + $css['vertical-align'] = $this->getValueIf($style->isSubScript(), 'sub'); $css['text-decoration'] = ''; $css['text-decoration'] .= $this->getValueIf($underline, 'underline '); $css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through '); - if ($this->style->isSuperScript()) { - $css['vertical-align'] = 'super'; - } elseif ($this->style->isSubScript()) { - $css['vertical-align'] = 'sub'; - } - return $this->assembleCss($css); } - - /** - * Get value if ... - * - * @param bool $condition - * @param string $value - * @return string - */ - private function getValueIf($condition, $value) - { - return $condition ? $value : ''; - } } diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php index 1009ce2d87..9c9107b6c1 100644 --- a/src/PhpWord/Writer/HTML/Style/Generic.php +++ b/src/PhpWord/Writer/HTML/Style/Generic.php @@ -31,6 +31,7 @@ class Generic extends AbstractStyle */ public function write() { + $this->style = $this->getStyle(); $css = array(); if (is_array($this->style) && !empty($this->style)) { diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index ea8b3b3d6f..7e700aa4d2 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -31,17 +31,11 @@ class Image extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Image)) { - return; - } - + $this->style = $this->getStyle(); $css = array(); - if ($this->style->getWidth()) { - $css['width'] = $this->style->getWidth() . 'px'; - } - if ($this->style->getWidth()) { - $css['height'] = $this->style->getHeight() . 'px'; - } + + $css['width'] = $this->getValueIf($this->style->getWidth(), $this->style->getWidth() . 'px'); + $css['height'] = $this->getValueIf($this->style->getHeight(), $this->style->getHeight() . 'px'); return $this->assembleCss($css); } diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index 605533a4ba..27618061ff 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\HTML\Style; +use PhpOffice\PhpWord\Settings; + /** * Paragraph style HTML writer * @@ -31,13 +33,20 @@ class Paragraph extends AbstractStyle */ public function write() { - if (!($this->style instanceof \PhpOffice\PhpWord\Style\Paragraph)) { - return; - } - + $style = $this->getStyle(); $css = array(); - if ($this->style->getAlign()) { - $css['text-align'] = $this->style->getAlign(); + + // Alignment + $align = $style->getAlign(); + $css['text-align'] = $this->getValueIf(!is_null($align), $align); + + // Spacing + $spacing = $style->getSpace(); + if (!is_null($spacing)) { + $before = $spacing->getBefore(); + $after = $spacing->getAfter(); + $css['margin-top'] = $this->getValueIf(!is_null($before), ($before / Settings::UNIT_POINT) . 'pt'); + $css['margin-bottom'] = $this->getValueIf(!is_null($after), ($after / Settings::UNIT_POINT) . 'pt'); } return $this->assembleCss($css); diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 829a6d81ca..434ffd6770 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -23,7 +23,7 @@ use PhpOffice\PhpWord\Shared\Drawing; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Writer\RTF\Element\Element as ElementWriter; +use PhpOffice\PhpWord\Writer\RTF\Element\Container; /** * RTF writer @@ -131,43 +131,43 @@ private function writeDocument() $this->colorTable = $this->populateColorTable(); // Set the default character set - $sRTFContent = '{\rtf1'; - $sRTFContent .= '\ansi\ansicpg1252'; // Set the default font (the first one) - $sRTFContent .= '\deff0'; // Set the default tab size (720 twips) - $sRTFContent .= '\deftab720'; - $sRTFContent .= PHP_EOL; + $content = '{\rtf1'; + $content .= '\ansi\ansicpg1252'; // Set the default font (the first one) + $content .= '\deff0'; // Set the default tab size (720 twips) + $content .= '\deftab720'; + $content .= PHP_EOL; // Set the font tbl group - $sRTFContent .= '{\fonttbl'; + $content .= '{\fonttbl'; foreach ($this->fontTable as $idx => $font) { - $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; + $content .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; } - $sRTFContent .= '}' . PHP_EOL; + $content .= '}' . PHP_EOL; // Set the color tbl group - $sRTFContent .= '{\colortbl '; + $content .= '{\colortbl '; foreach ($this->colorTable as $idx => $color) { $arrColor = Drawing::htmlToRGB($color); - $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; + $content .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; } - $sRTFContent .= ';}' . PHP_EOL; - - $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; // Set the generator - $sRTFContent .= '\viewkind4'; // Set the view mode of the document - $sRTFContent .= '\uc1'; // Set the numberof bytes that follows a unicode character - $sRTFContent .= '\pard'; // Resets to default paragraph properties. - $sRTFContent .= '\nowidctlpar'; // No widow/orphan control - $sRTFContent .= '\lang1036'; // Applies a language to a text run (1036 : French (France)) - $sRTFContent .= '\kerning1'; // Point size (in half-points) above which to kern character pairs - $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); // Set the font size in half-points - $sRTFContent .= PHP_EOL; + $content .= ';}' . PHP_EOL; + + $content .= '{\*\generator PhpWord;}' . PHP_EOL; // Set the generator + $content .= '\viewkind4'; // Set the view mode of the document + $content .= '\uc1'; // Set the numberof bytes that follows a unicode character + $content .= '\pard'; // Resets to default paragraph properties. + $content .= '\nowidctlpar'; // No widow/orphan control + $content .= '\lang1036'; // Applies a language to a text run (1036 : French (France)) + $content .= '\kerning1'; // Point size (in half-points) above which to kern character pairs + $content .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); // Set the font size in half-points + $content .= PHP_EOL; // Body - $sRTFContent .= $this->writeContent(); + $content .= $this->writeContent(); - $sRTFContent .= '}'; + $content .= '}'; - return $sRTFContent; + return $content; } /** @@ -177,24 +177,15 @@ private function writeDocument() */ private function writeContent() { - $phpWord = $this->phpWord; - $sRTFBody = ''; - - $sections = $phpWord->getSections(); - $countSections = count($sections); - $pSection = 0; + $content = ''; - if ($countSections > 0) { - foreach ($sections as $section) { - $pSection++; - $elements = $section->getElements(); - foreach ($elements as $element) { - $elementWriter = new ElementWriter($this, $element); - $sRTFBody .= $elementWriter->write(); - } - } + $sections = $this->getPhpWord()->getSections(); + foreach ($sections as $section) { + $writer = new Container($this, $section); + $content .= $writer->write(); } - return $sRTFBody; + + return $content; } /** diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php new file mode 100644 index 0000000000..fbf8114e1a --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -0,0 +1,27 @@ +element; + $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $content = ''; + + $elements = $container->getElements(); + foreach ($elements as $element) { + $writerClass = str_replace('\\Element', '\\Writer\\RTF\\Element', get_class($element)); + if (class_exists($writerClass)) { + $writer = new $writerClass($this->parentWriter, $element, $withoutP); + $content .= '{'; + $content .= $writer->write(); + $content .= '}' . PHP_EOL; + } + } + + return $content; + } +} diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index f4225ead07..ae7466d866 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -17,42 +17,62 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; +use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; +use PhpOffice\PhpWord\Writer\RTF\Style\Paragraph as ParagraphStyleWriter; /** * Text element RTF writer * * @since 0.10.0 */ -class Text extends Element +class Text extends AbstractElement { /** * Write element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { - return; - } + $fontStyle = $this->getFontStyle(); - $rtfText = ''; + $content = ''; + $content .= $this->writeParagraphStyle(); + $content .= $this->writeFontStyleBegin($fontStyle); + if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { + $content .= ' '; + } + $content .= $this->element->getText(); + $content .= $this->writeFontStyleEnd($fontStyle); - $fontStyle = $this->element->getFontStyle(); - if (is_string($fontStyle)) { - $fontStyle = Style::getStyle($fontStyle); + if (!$this->withoutP) { + $content .= '\par' . PHP_EOL; } + return $content; + } + + /** + * Write paragraph style + * + * @return string + */ + private function writeParagraphStyle() + { + $content = ''; + + // Get paragraph style $paragraphStyle = $this->element->getParagraphStyle(); if (is_string($paragraphStyle)) { $paragraphStyle = Style::getStyle($paragraphStyle); } + // Write style when applicable if ($paragraphStyle && !$this->withoutP) { if ($this->parentWriter->getLastParagraphStyle() != $this->element->getParagraphStyle()) { - $rtfText .= $this->writeParagraphStyle($paragraphStyle); + $styleWriter = new ParagraphStyleWriter($paragraphStyle); + $content = $styleWriter->write(); $this->parentWriter->setLastParagraphStyle($this->element->getParagraphStyle()); } else { $this->parentWriter->setLastParagraphStyle(); @@ -61,101 +81,72 @@ public function write() $this->parentWriter->setLastParagraphStyle(); } - if ($fontStyle instanceof FontStyle) { - $rtfText .= $this->writeFontStyleBegin($fontStyle); - } - if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { - $rtfText .= ' '; - } - $rtfText .= $this->element->getText(); - if ($fontStyle instanceof FontStyle) { - $rtfText .= $this->writeFontStyleEnd($fontStyle); - } - if (!$this->withoutP) { - $rtfText .= '\par' . PHP_EOL; - } - - return $rtfText; + return $content; } /** - * Write paragraph style + * Write font style beginning * + * @param \PhpOffice\PhpWord\Style\Font $style * @return string */ - private function writeParagraphStyle(ParagraphStyle $paragraphStyle) + private function writeFontStyleBegin($style) { - $rtfText = '\pard\nowidctlpar'; - if ($paragraphStyle->getSpaceAfter() != null) { - $rtfText .= '\sa' . $paragraphStyle->getSpaceAfter(); + if (!$style instanceof FontStyle) { + return ''; + } + + // Create style writer and set color/name index + $styleWriter = new FontStyleWriter($style); + if ($style->getColor() != null) { + $colorIndex = array_search($style->getColor(), $this->parentWriter->getColorTable()); + if ($colorIndex !== false) { + $styleWriter->setColorIndex($colorIndex + 1); + } } - if ($paragraphStyle->getAlign() != null) { - if ($paragraphStyle->getAlign() == 'center') { - $rtfText .= '\qc'; + if ($style->getName() != null) { + $fontIndex = array_search($style->getName(), $this->parentWriter->getFontTable()); + if ($fontIndex !== false) { + $styleWriter->setNameIndex($fontIndex + 1); } } - return $rtfText; + // Write style + $content = $styleWriter->write(); + + return $content; } /** - * Write font style beginning + * Write font style ending * + * @param \PhpOffice\PhpWord\Style\Font $style * @return string */ - private function writeFontStyleBegin(FontStyle $style) + private function writeFontStyleEnd($style) { - $rtfText = ''; - if ($style->getColor() != null) { - $idxColor = array_search($style->getColor(), $this->parentWriter->getColorTable()); - if ($idxColor !== false) { - $rtfText .= '\cf' . ($idxColor + 1); - } - } else { - $rtfText .= '\cf0'; - } - if ($style->getName() != null) { - $idxFont = array_search($style->getName(), $this->parentWriter->getFontTable()); - if ($idxFont !== false) { - $rtfText .= '\f' . $idxFont; - } - } else { - $rtfText .= '\f0'; - } - if ($style->isBold()) { - $rtfText .= '\b'; - } - if ($style->isItalic()) { - $rtfText .= '\i'; - } - if ($style->getSize()) { - $rtfText .= '\fs' . ($style->getSize() * 2); + if (!$style instanceof FontStyle) { + return ''; } - return $rtfText; + $styleWriter = new FontStyleWriter($style); + $content = $styleWriter->writeEnd(); + + return $content; } /** - * Write font style ending + * Get font style * - * @return string + * @return \PhpOffice\PhpWord\Style\Font */ - private function writeFontStyleEnd(FontStyle $style) + private function getFontStyle() { - $rtfText = ''; - $rtfText .= '\cf0'; - $rtfText .= '\f0'; - - if ($style->isBold()) { - $rtfText .= '\b0'; - } - if ($style->isItalic()) { - $rtfText .= '\i0'; - } - if ($style->getSize()) { - $rtfText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); + $fontStyle = $this->element->getFontStyle(); + if (is_string($fontStyle)) { + $fontStyle = Style::getStyle($fontStyle); } - return $rtfText; + return $fontStyle; } } diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index 2762503cf2..760f34e823 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class TextBreak extends Element +class TextBreak extends AbstractElement { /** * Write element diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index f5df5d9698..174aebd97f 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -17,14 +17,14 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Element\Text as TextElement; +use PhpOffice\PhpWord\Writer\RTF\Element\Container; /** * TextRun element RTF writer * * @since 0.10.0 */ -class TextRun extends Element +class TextRun extends AbstractElement { /** * Write element @@ -33,26 +33,13 @@ class TextRun extends Element */ public function write() { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\TextRun) { - return; - } + $content = ''; - $rtfText = ''; + $content .= '\pard\nowidctlpar' . PHP_EOL; + $writer = new Container($this->parentWriter, $this->element); + $content .= $writer->write(); + $content .= '\par' . PHP_EOL; - $elements = $this->element->getElements(); - if (count($elements) > 0) { - $rtfText .= '\pard\nowidctlpar' . PHP_EOL; - foreach ($elements as $element) { - if ($element instanceof TextElement) { - $elementWriter = new Element($this->parentWriter, $element, true); - $rtfText .= '{'; - $rtfText .= $elementWriter->write(); - $rtfText .= '}' . PHP_EOL; - } - } - $rtfText .= '\par' . PHP_EOL; - } - - return $rtfText; + return $content; } } diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 5915c42e58..d78bb6f4e3 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -22,7 +22,7 @@ * * @since 0.10.0 */ -class Title extends Element +class Title extends AbstractElement { /** * Write element @@ -35,12 +35,12 @@ public function write() return; } - $rtfText = ''; + $content = ''; - $rtfText .= '\pard\nowidctlpar' . PHP_EOL; - $rtfText .= $this->element->getText(); - $rtfText .= '\par' . PHP_EOL; + $content .= '\pard\nowidctlpar' . PHP_EOL; + $content .= $this->element->getText(); + $content .= '\par' . PHP_EOL; - return $rtfText; + return $content; } } diff --git a/src/PhpWord/Writer/RTF/Style/AbstractStyle.php b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php new file mode 100644 index 0000000000..55d6588e2a --- /dev/null +++ b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php @@ -0,0 +1,29 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { + return; + } + + $content = ''; + $content .= '\cf' . $this->colorIndex; + $content .= '\f' . $this->nameIndex; + $content .= $this->getValueIf($style->isBold(), '\b'); + $content .= $this->getValueIf($style->isItalic(), '\i'); + $content .= $this->getValueIf($style->getSize(), '\fs' . ($style->getSize() * 2)); + + return $content; + } + + /** + * Write end style + * + * @return string + */ + public function writeEnd() + { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { + return; + } + + $content = ''; + $content .= '\cf0'; + $content .= '\f0'; + $content .= $this->getValueIf($style->isBold(), '\b0'); + $content .= $this->getValueIf($style->isItalic(), '\i0'); + $content .= $this->getValueIf($style->getSize(), '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2)); + + return $content; + } + + /** + * Set font name index + * + * @param int $value + */ + public function setNameIndex($value = 0) + { + $this->nameIndex = $value; + } + + /** + * Set font color index + * + * @param int $value + */ + public function setColorIndex($value = 0) + { + $this->colorIndex = $value; + } +} diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php new file mode 100644 index 0000000000..512e577497 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -0,0 +1,51 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { + return; + } + + $content = '\pard\nowidctlpar'; + + // Alignment + $align = $style->getAlign(); + $content .= $this->getValueIf(!is_null($align) && $align == 'center', '\qc'); + + // Spacing + $spaceAfter = $style->getSpaceAfter(); + $content .= $this->getValueIf(!is_null($spaceAfter), '\sa' . $spaceAfter); + + return $content; + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 65b3c400fc..4b38d01f28 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -24,7 +24,7 @@ /** * Abstract element writer * - * @since 0.10.0 + * @since 0.11.0 */ abstract class AbstractElement { diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 0561509d4e..384fbd5bb2 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -40,11 +40,11 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $container = $this->getElement(); + $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; // Loop through subelements - $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $subelements = $container->getElements(); - $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; if (count($subelements) > 0) { foreach ($subelements as $subelement) { $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, get_class($subelement)); From 530f8ee357d030dd81e7e066f2447f6a0d1156a6 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 10 May 2014 14:45:51 +0700 Subject: [PATCH 060/167] Writers refactoring fixes --- src/PhpWord/Writer/HTML.php | 1 - src/PhpWord/Writer/HTML/Element/TextRun.php | 5 ----- src/PhpWord/Writer/HTML/Style/Generic.php | 6 +++--- src/PhpWord/Writer/HTML/Style/Image.php | 6 +++--- src/PhpWord/Writer/RTF/Element/Text.php | 1 - src/PhpWord/Writer/Word2007/Style/AbstractStyle.php | 1 - src/PhpWord/Writer/Word2007/Style/TextBox.php | 1 - 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index d292d9ab73..f871bc188f 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Font; diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php index d8ea6d7263..b6bfaceaeb 100644 --- a/src/PhpWord/Writer/HTML/Element/TextRun.php +++ b/src/PhpWord/Writer/HTML/Element/TextRun.php @@ -17,11 +17,6 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element; -use PhpOffice\PhpWord\Element\Footnote as FootnoteElement; -use PhpOffice\PhpWord\Element\TextRun as TextRunElement; -use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter; - /** * TextRun element HTML writer * diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php index 9c9107b6c1..df94d4922e 100644 --- a/src/PhpWord/Writer/HTML/Style/Generic.php +++ b/src/PhpWord/Writer/HTML/Style/Generic.php @@ -31,11 +31,11 @@ class Generic extends AbstractStyle */ public function write() { - $this->style = $this->getStyle(); + $style = $this->getStyle(); $css = array(); - if (is_array($this->style) && !empty($this->style)) { - $css = $this->style; + if (is_array($style) && !empty($style)) { + $css = $style; } return $this->assembleCss($css); diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index 7e700aa4d2..cdb4f8a2f0 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -31,11 +31,11 @@ class Image extends AbstractStyle */ public function write() { - $this->style = $this->getStyle(); + $style = $this->getStyle(); $css = array(); - $css['width'] = $this->getValueIf($this->style->getWidth(), $this->style->getWidth() . 'px'); - $css['height'] = $this->getValueIf($this->style->getHeight(), $this->style->getHeight() . 'px'); + $css['width'] = $this->getValueIf($style->getWidth(), $style->getWidth() . 'px'); + $css['height'] = $this->getValueIf($style->getHeight(), $style->getHeight() . 'px'); return $this->assembleCss($css); } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index ae7466d866..a52b207174 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -19,7 +19,6 @@ use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; -use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\RTF\Style\Paragraph as ParagraphStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index dad0ce07eb..06c351175e 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\XMLWriter; diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index 6020a2b057..bb9b3a24bf 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle; /** From aa151c40109bb7979655edf83dcb58b92177ae41 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sat, 10 May 2014 14:03:16 +0200 Subject: [PATCH 061/167] Added function to add elements via HTML --- samples/Sample_26_Html.php | 19 +++ src/PhpWord/Shared/Html.php | 228 ++++++++++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 samples/Sample_26_Html.php create mode 100644 src/PhpWord/Shared/Html.php diff --git a/samples/Sample_26_Html.php b/samples/Sample_26_Html.php new file mode 100644 index 0000000000..9b46557dec --- /dev/null +++ b/samples/Sample_26_Html.php @@ -0,0 +1,19 @@ +addSection(); +$html='

Adding element via HTML

'; +$html.='

Some well formed HTML snippet needs to be used

'; +$html.='

With for example some inline formatting'; + +\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} \ No newline at end of file diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php new file mode 100644 index 0000000000..43a9b6cb8d --- /dev/null +++ b/src/PhpWord/Shared/Html.php @@ -0,0 +1,228 @@ +preserveWhiteSpace = true; + $dom->loadXML('' . html_entity_decode($html) . ''); + + $node = $dom->getElementsByTagName('body'); + + self::parseNode($node->item(0), $object); + } + + /** + * parse Inline style of a node + * + * @param $node node to check on attributes and to compile a style array + * @param $style is supplied, the inline style attributes are added to the already existing style + * + */ + protected static function parseInlineStyle($node, $style = array()) + { + if ($node->nodeType == XML_ELEMENT_NODE) { + $attributes = $node->attributes; // get all the attributes(eg: id, class) + + foreach ($attributes as $attribute) { + switch ($attribute->name) { + case 'style': + $properties = explode(';', trim($attribute->value, " \t\n\r\0\x0B;")); + foreach ($properties as $property) { + list ($cKey, $cValue) = explode(':', $property, 2); + $cValue = trim($cValue); + switch (trim($cKey)) { + case 'text-decoration': + switch ($cValue) { + case 'underline': + $style['underline'] = 'single'; + break; + case 'line-through': + $style['strikethrough'] = true; + break; + } + break; + case 'text-align': + $style['align'] = $cValue; + break; + case 'color': + $style['color'] = trim($cValue, "#"); + break; + case 'background-color': + $style['bgColor'] = trim($cValue, "#"); + break; + } + } + break; + } + } + } + return $style; + } + + /** + * parse a node and add a corresponding element to the object + * + * @param $node node to parse + * @param $object object to add an element corresponding with the node + * @param $styles array with all styles + * @param $data array to transport data to a next level in the DOM tree, for example level of listitems + * + */ + protected static function parseNode($node, $object, $styles = array('fontStyle' => array(), 'paragraphStyle' => array(), 'listStyle' => array()), $data = array()) + { + $newobject = null; + switch ($node->nodeName) { + case 'p': + $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + + /* + * @todo Think of a clever way of defining header styles, now it is only based on the assumption, that + * Heading1 - Heading6 are already defined somewhere + */ + case 'h1': + $styles['paragraphStyle'] = 'Heading1'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case 'h2': + $styles['paragraphStyle'] = 'Heading2'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case 'h3': + $styles['paragraphStyle'] = 'Heading3'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case 'h4': + $styles['paragraphStyle'] = 'Heading4'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case 'h5': + $styles['paragraphStyle'] = 'Heading5'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case 'h6': + $styles['paragraphStyle'] = 'Heading6'; + $newobject = $object->addTextRun($styles['paragraphStyle']); + break; + case '#text': + $styles['fontStyle'] = self::parseInlineStyle($node, $styles['fontStyle']); + $object->AddText($node->nodeValue, $styles['fontStyle'], $styles['paragraphStyle']); + break; + case 'strong': + $styles['fontStyle']['bold'] = true; + break; + case 'em': + $styles['fontStyle']['italic'] = true; + break; + case 'sup': + $styles['fontStyle']['superScript'] = true; + break; + case 'sub': + $styles['fontStyle']['subScript'] = true; + break; + + /* + * @todo As soon as TableItem, RowItem and CellItem support relative width and height + */ + case 'table': + $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); + $newobject = $object->addTable(); + // if ($attributes->getNamedItem('width') !== null)$newobject->setWidth($attributes->getNamedItem('width')->value); + break; + case 'tr': + $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); + $newobject = $object->addRow(); + // if ($attributes->getNamedItem('height') !== null)$newobject->setHeight($attributes->getNamedItem('height')->value); + break; + case 'td': + $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); + // if ($attributes->getNamedItem('width') !== null)$newobject=$object->addCell($width=$attributes->getNamedItem('width')->value); + // else $newobject=$object->addCell(); + $newobject = $object->addCell(); + break; + case 'ul': + if (isset($data['listdepth'])) { + $data['listdepth'] ++; + } else { + $data['listdepth'] = 0; + } + $styles['listStyle']['listType'] = 3; // TYPE_BULLET_FILLED = 3; + break; + case 'ol': + if (isset($data['listdepth'])) { + $data['listdepth'] ++; + } else { + $data['listdepth'] = 0; + } + $styles['listStyle']['listType'] = 7; // TYPE_NUMBER = 7; + break; + + /* + * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes + */ + case 'li': + $cNodes = $node->childNodes; + if (count($cNodes) > 0) { + foreach ($cNodes as $cNode) { + if ($cNode->nodeName == '#text') { + $text = $cNode->nodeValue; + } + } + $object->addListItem($text, $data['listdepth'], $styles['fontStyle'], $styles['listStyle'], $styles['paragraphStyle']); + } + } + + if ($newobject === null) { + $newobject = $object; + } + + /* + * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete condition + */ + if ($node->nodeName != 'li') { + $cNodes = $node->childNodes; + if (count($cNodes) > 0) { + foreach ($cNodes as $cNode) { + self::parseNode($cNode, $newobject, $styles, $data); + } + } + } + } +} From 07b4ae2c0fcf91f7ca861a683ef25f4337789eba Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sat, 10 May 2014 14:04:15 +0200 Subject: [PATCH 062/167] Added possiblity to add tables inside textbox --- src/PhpWord/Element/TextBox.php | 15 +++++++++++++++ src/PhpWord/Writer/Word2007/Element/TextBox.php | 2 -- src/PhpWord/Writer/Word2007/Part/AbstractPart.php | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 1de7464995..979b7c1f8f 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -53,4 +53,19 @@ public function getStyle() { return $this->style; } + + /** + * Add table element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Table + * @todo Merge with the same function on Footer + */ + public function addTable($style = null) + { + $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); + $this->addElement($table); + + return $table; + } } diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index fd1683aea9..b732ffaba4 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -57,9 +57,7 @@ public function write() $margins = implode(', ', $tbxStyle->getInnerMargin()); $this->xmlWriter->writeAttribute('inset', $margins); $this->xmlWriter->startElement('w:txbxContent'); - $this->xmlWriter->startElement('w:p'); $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element); - $this->xmlWriter->endElement(); // w:p $this->xmlWriter->endElement(); // w:txbxContent $this->xmlWriter->endElement(); // v: textbox $styleWriter->writeW10Wrap(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index d1717e9b28..b09613a638 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -110,7 +110,7 @@ public function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $co // Loop through elements $elements = $container->getElements(); - $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false; + $withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false; if (count($elements) > 0) { foreach ($elements as $element) { if ($element instanceof AbstractElement) { From 62ed72503228bc2fe785f49a1eed80cc19dbd320 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 10 May 2014 21:38:44 +0700 Subject: [PATCH 063/167] Some modifications for the new `Html::addHtml` feature --- .scrutinizer.yml | 9 ++++ .travis.yml | 2 +- CHANGELOG.md | 2 + phpmd.xml.dist | 20 +++++++++ samples/Sample_26_Html.php | 6 +-- src/PhpWord/Element/AbstractContainer.php | 54 +++++++++++++++++------ src/PhpWord/Element/Footer.php | 15 ------- src/PhpWord/Element/Section.php | 15 ------- src/PhpWord/Element/Table.php | 3 +- src/PhpWord/Element/TextBox.php | 15 ------- src/PhpWord/Shared/Html.php | 43 +++++++++--------- 11 files changed, 98 insertions(+), 86 deletions(-) create mode 100644 phpmd.xml.dist diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ab5f86209b..d253de3001 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -5,6 +5,15 @@ before_commands: - "composer install --prefer-source --dev" tools: + php_code_sniffer: + enabled: true + config: + standard: PSR2 + php_cpd: true + php_mess_detector: + enabled: true + config: + ruleset: phpmd.xml.dist external_code_coverage: enabled: true timeout: 900 diff --git a/.travis.yml b/.travis.yml index 7593379cf3..190c0a3cdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ script: ## PHP Copy/Paste Detector - php phpcpd.phar src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/,tests/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php + - phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/CHANGELOG.md b/CHANGELOG.md index f23ca1476a..403a32bd5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Image: Ability to define relative and absolute positioning - @basjan GH-217 - Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 - TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 +- TextBox: Ability to add textbox in table - @basjan GH-231 +- HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 ### Bugfixes diff --git a/phpmd.xml.dist b/phpmd.xml.dist new file mode 100644 index 0000000000..18d5b2a9fc --- /dev/null +++ b/phpmd.xml.dist @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Sample_26_Html.php b/samples/Sample_26_Html.php index 9b46557dec..5843691561 100644 --- a/samples/Sample_26_Html.php +++ b/samples/Sample_26_Html.php @@ -6,9 +6,9 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$html='

Adding element via HTML

'; -$html.='

Some well formed HTML snippet needs to be used

'; -$html.='

With for example some inline formatting'; +$html = '

Adding element via HTML

'; +$html .= '

Some well formed HTML snippet needs to be used

'; +$html .= '

With for example some inline formatting

'; \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html); diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 8b72f6608a..431a306624 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -66,6 +66,31 @@ public function countElements() return count($this->elements); } + /** + * Add generic element with style + * + * This is how all elements should be added with dependency injection: with + * just one simple $style. Currently this function supports TextRun, Table, + * and TextBox since all other elements have different arguments + * + * @todo Change the function name into something better? + * + * @param string $elementName + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\AbstractElement + */ + private function addGenericElement($elementName, $style) + { + $elementClass = __NAMESPACE__ . '\\' . $elementName; + + $this->checkValidity($elementName); + $element = new $elementClass($style); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); + + return $element; + } + /** * Add text/preservetext element * @@ -100,13 +125,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme */ public function addTextRun($paragraphStyle = null) { - $this->checkValidity('TextRun'); - - $element = new TextRun($paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; + return $this->addGenericElement('TextRun', $paragraphStyle); } /** @@ -186,6 +205,18 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n return $element; } + /** + * Add table element + * + * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Table + * @todo Merge with the same function on Footer + */ + public function addTable($style = null) + { + return $this->addGenericElement('Table', $style); + } + /** * Add image element * @@ -302,13 +333,7 @@ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = n */ public function addTextBox($style = null) { - $this->checkValidity('TextBox'); - - $textbox = new TextBox($style); - $textbox->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textbox); - - return $textbox; + return $this->addGenericElement('TextBox', $style); } /** @@ -329,6 +354,7 @@ private function checkValidity($method) 'Object' => $allContainers, 'TextRun' => array('section', 'header', 'footer', 'cell', 'textbox'), 'ListItem' => array('section', 'header', 'footer', 'cell', 'textbox'), + 'Table' => array('section', 'header', 'footer', 'textbox'), 'CheckBox' => array('section', 'header', 'footer', 'cell'), 'TextBox' => array('section', 'header', 'footer', 'cell'), 'Footnote' => array('section', 'textrun', 'cell'), diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 2f23a3d371..265c2c4c8f 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -114,19 +114,4 @@ public function evenPage() { return $this->type = self::EVEN; } - - /** - * Add table element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\Table - * @todo Merge with the same function on Section - */ - public function addTable($style = null) - { - $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($table); - - return $table; - } } diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 9067c73c0c..04ff5aa2d2 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -117,21 +117,6 @@ public function addPageBreak() $this->addElement(new PageBreak()); } - /** - * Add table element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\Table - * @todo Merge with the same function on Footer - */ - public function addTable($style = null) - { - $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($table); - - return $table; - } - /** * Add a Table-of-Contents Element * diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index af802d1214..87d44e415a 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -53,9 +53,8 @@ class Table extends AbstractElement * @param integer $docPartId * @param mixed $style */ - public function __construct($docPart, $docPartId, $style = null) + public function __construct($style = null) { - $this->setDocPart($docPart, $docPartId); $this->style = $this->setStyle(new TableStyle(), $style); } diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 56645321cc..c3c83d8122 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -53,19 +53,4 @@ public function getStyle() { return $this->style; } - - /** - * Add table element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\Table - * @todo Merge with the same function on Footer - */ - public function addTable($style = null) - { - $table = new Table($this->getDocPart(), $this->getDocPartId(), $style); - $this->addElement($table); - - return $table; - } } diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 43a9b6cb8d..bcefb98536 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -22,28 +22,29 @@ */ class Html { - /** - * add HTML parts + * Add HTML parts + * + * Note: $stylesheet parameter is removed to avoid PHPMD error for unused parameter + * + * @param \PhpOffice\PhpWord\Element\AbstractElement $object Where the parts need to be added + * @param string $html the code to parse * - * @param $object where the parts need to be added - * @param $html the code to parse - * */ - public static function addHtml($object, $html, $stylesheet = '') + public static function addHtml($object, $html) { /* - * @todo parse $stylesheet for default styles. Should result in an array based on id, class and element, + * @todo parse $stylesheet for default styles. Should result in an array based on id, class and element, * which could be applied when such an element occurs in the parseNode function. */ $html = str_replace(array("\n","\r"), '', $html); - + $dom = new \DOMDocument(); $dom->preserveWhiteSpace = true; $dom->loadXML('' . html_entity_decode($html) . ''); - + $node = $dom->getElementsByTagName('body'); - + self::parseNode($node->item(0), $object); } @@ -58,7 +59,7 @@ protected static function parseInlineStyle($node, $style = array()) { if ($node->nodeType == XML_ELEMENT_NODE) { $attributes = $node->attributes; // get all the attributes(eg: id, class) - + foreach ($attributes as $attribute) { switch ($attribute->name) { case 'style': @@ -94,7 +95,7 @@ protected static function parseInlineStyle($node, $style = array()) } return $style; } - + /** * parse a node and add a corresponding element to the object * @@ -112,8 +113,8 @@ protected static function parseNode($node, $object, $styles = array('fontStyle' $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); $newobject = $object->addTextRun($styles['paragraphStyle']); break; - - /* + + /** * @todo Think of a clever way of defining header styles, now it is only based on the assumption, that * Heading1 - Heading6 are already defined somewhere */ @@ -157,8 +158,8 @@ protected static function parseNode($node, $object, $styles = array('fontStyle' case 'sub': $styles['fontStyle']['subScript'] = true; break; - - /* + + /** * @todo As soon as TableItem, RowItem and CellItem support relative width and height */ case 'table': @@ -193,8 +194,8 @@ protected static function parseNode($node, $object, $styles = array('fontStyle' } $styles['listStyle']['listType'] = 7; // TYPE_NUMBER = 7; break; - - /* + + /** * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes */ case 'li': @@ -208,12 +209,12 @@ protected static function parseNode($node, $object, $styles = array('fontStyle' $object->addListItem($text, $data['listdepth'], $styles['fontStyle'], $styles['listStyle'], $styles['paragraphStyle']); } } - + if ($newobject === null) { $newobject = $object; } - - /* + + /** * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete condition */ if ($node->nodeName != 'li') { From feff87e769057ec0b1f33c620d765920ec48746a Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 10 May 2014 21:56:06 +0700 Subject: [PATCH 064/167] Fix Travis test errors --- src/PhpWord/Element/Table.php | 2 -- src/PhpWord/Shared/Html.php | 18 +++++++++++------- tests/PhpWord/Tests/Element/TableTest.php | 14 +++++++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 87d44e415a..e87c591fe1 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -49,8 +49,6 @@ class Table extends AbstractElement /** * Create a new table * - * @param string $docPart - * @param integer $docPartId * @param mixed $style */ public function __construct($style = null) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index bcefb98536..b09afddb17 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -51,8 +51,8 @@ public static function addHtml($object, $html) /** * parse Inline style of a node * - * @param $node node to check on attributes and to compile a style array - * @param $style is supplied, the inline style attributes are added to the already existing style + * @param \DOMNode $node Node to check on attributes and to compile a style array + * @param array $style is supplied, the inline style attributes are added to the already existing style * */ protected static function parseInlineStyle($node, $style = array()) @@ -99,14 +99,18 @@ protected static function parseInlineStyle($node, $style = array()) /** * parse a node and add a corresponding element to the object * - * @param $node node to parse - * @param $object object to add an element corresponding with the node - * @param $styles array with all styles + * @param \DOMNode $node node to parse + * @param \PhpOffice\PhpWord\Element\AbstractElement $object object to add an element corresponding with the node + * @param array $styles Array with all styles * @param $data array to transport data to a next level in the DOM tree, for example level of listitems * */ - protected static function parseNode($node, $object, $styles = array('fontStyle' => array(), 'paragraphStyle' => array(), 'listStyle' => array()), $data = array()) - { + protected static function parseNode( + $node, + $object, + $styles = array('fontStyle' => array(), 'paragraphStyle' => array(), 'listStyle' => array()), + $data = array() + ) { $newobject = null; switch ($node->nodeName) { case 'p': diff --git a/tests/PhpWord/Tests/Element/TableTest.php b/tests/PhpWord/Tests/Element/TableTest.php index 1c87c2cf45..0977639f32 100644 --- a/tests/PhpWord/Tests/Element/TableTest.php +++ b/tests/PhpWord/Tests/Element/TableTest.php @@ -32,7 +32,7 @@ class TableTest extends \PHPUnit_Framework_TestCase */ public function testConstruct() { - $oTable = new Table('section', 1); + $oTable = new Table(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Table', $oTable); $this->assertEquals($oTable->getStyle(), null); @@ -46,7 +46,7 @@ public function testConstruct() */ public function testStyleText() { - $oTable = new Table('section', 1, 'tableStyle'); + $oTable = new Table('tableStyle'); $this->assertEquals($oTable->getStyle(), 'tableStyle'); } @@ -56,7 +56,7 @@ public function testStyleText() */ public function testStyleArray() { - $oTable = new Table('section', 1, array( + $oTable = new Table(array( 'borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80 @@ -70,7 +70,7 @@ public function testStyleArray() */ public function testWidth() { - $oTable = new Table('section', 1); + $oTable = new Table(); $iVal = rand(1, 1000); $oTable->setWidth($iVal); $this->assertEquals($oTable->getWidth(), $iVal); @@ -81,7 +81,7 @@ public function testWidth() */ public function testRow() { - $oTable = new Table('section', 1); + $oTable = new Table(); $element = $oTable->addRow(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Row', $element); $this->assertCount(1, $oTable->getRows()); @@ -92,7 +92,7 @@ public function testRow() */ public function testCell() { - $oTable = new Table('section', 1); + $oTable = new Table(); $oTable->addRow(); $element = $oTable->addCell(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element); @@ -103,7 +103,7 @@ public function testCell() */ public function testCountColumns() { - $oTable = new Table('section', 1); + $oTable = new Table(); $oTable->addRow(); $element = $oTable->addCell(); $this->assertEquals($oTable->countColumns(), 1); From 9ea767ea91bb32c6ec31f2891af8db5772705d37 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 10 May 2014 22:04:10 +0700 Subject: [PATCH 065/167] Table inside textbox sample --- CHANGELOG.md | 2 +- samples/Sample_25_TextBox.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 403a32bd5d..a337da6955 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Image: Ability to define relative and absolute positioning - @basjan GH-217 - Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 - TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 -- TextBox: Ability to add textbox in table - @basjan GH-231 +- TextBox: Ability to add table inside textbox - @basjan GH-231 - HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 ### Bugfixes diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php index 1946315f0f..4beb9553ed 100644 --- a/samples/Sample_25_TextBox.php +++ b/samples/Sample_25_TextBox.php @@ -8,15 +8,17 @@ $section = $phpWord->addSection(); // In section -$textbox = $section->addTextBox(array('align' => 'left', 'width' => 400, 'borderSize' => 1, 'borderColor' => '#FF0000')); +$textbox = $section->addTextBox(array('align' => 'left', 'width' => 400, 'height' => 150, 'borderSize' => 1, 'borderColor' => '#FF0000')); $textbox->addText('Text box content in section.'); $textbox->addText('Another line.'); +$cell = $textbox->addTable()->addRow()->addCell(); +$cell->addText('Table inside textbox'); // Inside table $section->addTextBreak(2); $cell = $section->addTable()->addRow()->addCell(300); $textbox = $cell->addTextBox(array('borderSize' => 1, 'borderColor' => '#0000FF', 'innerMargin' => 100)); -$textbox->addText('Inside table'); +$textbox->addText('Textbox inside table'); // Inside header with textrun $header = $section->addHeader(); From 516c13e032fde63ffadbe00bd6a34015bcd8b75c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 10 May 2014 23:40:34 +0700 Subject: [PATCH 066/167] Some unit tests for the new features --- src/PhpWord/Shared/Html.php | 8 ++- tests/PhpWord/Tests/Shared/HtmlTest.php | 65 +++++++++++++++++++ .../Writer/Word2007/Part/DocumentTest.php | 6 ++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 tests/PhpWord/Tests/Shared/HtmlTest.php diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index b09afddb17..1df56e6836 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -37,7 +37,7 @@ public static function addHtml($object, $html) * @todo parse $stylesheet for default styles. Should result in an array based on id, class and element, * which could be applied when such an element occurs in the parseNode function. */ - $html = str_replace(array("\n","\r"), '', $html); + $html = str_replace(array("\n", "\r"), '', $html); $dom = new \DOMDocument(); $dom->preserveWhiteSpace = true; @@ -102,7 +102,7 @@ protected static function parseInlineStyle($node, $style = array()) * @param \DOMNode $node node to parse * @param \PhpOffice\PhpWord\Element\AbstractElement $object object to add an element corresponding with the node * @param array $styles Array with all styles - * @param $data array to transport data to a next level in the DOM tree, for example level of listitems + * @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems * */ protected static function parseNode( @@ -148,7 +148,9 @@ protected static function parseNode( break; case '#text': $styles['fontStyle'] = self::parseInlineStyle($node, $styles['fontStyle']); - $object->AddText($node->nodeValue, $styles['fontStyle'], $styles['paragraphStyle']); + if (method_exists($object, 'addText')) { + $object->addText($node->nodeValue, $styles['fontStyle'], $styles['paragraphStyle']); + } break; case 'strong': $styles['fontStyle']['bold'] = true; diff --git a/tests/PhpWord/Tests/Shared/HtmlTest.php b/tests/PhpWord/Tests/Shared/HtmlTest.php new file mode 100644 index 0000000000..81714432b9 --- /dev/null +++ b/tests/PhpWord/Tests/Shared/HtmlTest.php @@ -0,0 +1,65 @@ +assertEquals(0, $section->countElements()); + + // Heading + $styles = array('strong', 'em', 'sup', 'sub'); + for ($level = 1; $level <= 6; $level++) { + $content .= "Heading {$level}"; + } + + // Styles + $content .= '

'; + foreach ($styles as $style) { + $content .= "<{$style}>{$style}"; + } + $content .= '

'; + + // Add HTML + Html::addHtml($section, $content); + $this->assertEquals(7, $section->countElements()); + + // Other parts + $section = new Section(1); + $content = ''; + $content .= '
HeaderContent
'; + $content .= '
  • Bullet
'; + $content .= '
  1. Bullet
'; + Html::addHtml($section, $content, null, array('listdepth' => 2)); + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 8971133e2c..b036c21b45 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -75,6 +75,12 @@ public function testElements() $section = $phpWord->addSection(); $section->addTitle('Title 2', 2); $section->addObject($objectSrc); + $section->addTextBox(array()); + $section->addTextBox(array('wrappingStyle' => 'square', 'positioning' => 'relative', + 'posHorizontalRel' => 'margin', 'posVerticalRel' => 'margin', + 'innerMargin' => 10, 'borderSize' => 1, 'borderColor' => '#FF0')); + $section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center')); + $doc = TestHelperDOCX::getDocument($phpWord); // TOC From c524394f5f3e080dd6696a43bec6265a5a61992f Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sat, 10 May 2014 23:52:10 +0200 Subject: [PATCH 067/167] Fixed conversion factor Centimeters to Pixels and vice versa. --- src/PhpWord/Shared/Drawing.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 825ce8f175..f1d61eb6aa 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -108,7 +108,7 @@ public static function angleToDegrees($value = 0) */ public static function pixelsToCentimeters($value = 0) { - return $value * 0.028; + return $value * 0.026458333; } /** @@ -120,7 +120,7 @@ public static function pixelsToCentimeters($value = 0) public static function centimetersToPixels($value = 0) { if ($value != 0) { - return $value / 0.028; + return $value / 0.026458333; } else { return 0; } From 967c8b273ebf09e5ec3e9fffebbefb0c1d814c99 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 10:39:39 +0700 Subject: [PATCH 068/167] Fix unit test for px2cm and cm2px conversion --- tests/PhpWord/Tests/Shared/DrawingTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 02eeda9b23..3fce6dc751 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -56,10 +56,10 @@ public function testUnitConversions() $this->assertEquals(round($value / 60000), $result); $result = Drawing::pixelsToCentimeters($value); - $this->assertEquals($value * 0.028, $result); + $this->assertEquals($value * 0.026458333, $result); $result = Drawing::centimetersToPixels($value); - $this->assertEquals($value / 0.028, $result); + $this->assertEquals($value / 0.026458333, $result); } } From 17e2f0281796fc551580c8af2e31f89308ee648e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 11:23:46 +0700 Subject: [PATCH 069/167] Type checks on style writers --- src/PhpWord/Writer/HTML/Style/Font.php | 3 ++ src/PhpWord/Writer/HTML/Style/Image.php | 3 ++ src/PhpWord/Writer/HTML/Style/Paragraph.php | 3 ++ src/PhpWord/Writer/ODText/Style/Font.php | 3 +- src/PhpWord/Writer/ODText/Style/Paragraph.php | 3 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 3 +- src/PhpWord/Writer/Word2007/Style/Font.php | 3 +- src/PhpWord/Writer/Word2007/Style/Image.php | 6 ++- .../Writer/Word2007/Style/Indentation.php | 3 +- .../Writer/Word2007/Style/LineNumbering.php | 3 +- .../Writer/Word2007/Style/MarginBorder.php | 4 +- .../Writer/Word2007/Style/Paragraph.php | 3 +- src/PhpWord/Writer/Word2007/Style/Section.php | 3 +- src/PhpWord/Writer/Word2007/Style/Shading.php | 3 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 3 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 3 +- src/PhpWord/Writer/Word2007/Style/Table.php | 3 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 8 ++-- tests/PhpWord/Tests/Writer/HTML/StyleTest.php | 39 ++++++++++++++++ .../PhpWord/Tests/Writer/ODText/StyleTest.php | 41 +++++++++++++++++ tests/PhpWord/Tests/Writer/RTF/StyleTest.php | 39 ++++++++++++++++ .../Tests/Writer/Word2007/StyleTest.php | 44 +++++++++++++++++++ 22 files changed, 207 insertions(+), 19 deletions(-) create mode 100644 tests/PhpWord/Tests/Writer/HTML/StyleTest.php create mode 100644 tests/PhpWord/Tests/Writer/ODText/StyleTest.php create mode 100644 tests/PhpWord/Tests/Writer/RTF/StyleTest.php create mode 100644 tests/PhpWord/Tests/Writer/Word2007/StyleTest.php diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 0c416e8f92..33c23f7a61 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -35,6 +35,9 @@ class Font extends AbstractStyle public function write() { $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { + return; + } $css = array(); $font = $style->getName(); diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index cdb4f8a2f0..fcf18395d1 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -32,6 +32,9 @@ class Image extends AbstractStyle public function write() { $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Image) { + return; + } $css = array(); $css['width'] = $this->getValueIf($style->getWidth(), $style->getWidth() . 'px'); diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index 27618061ff..cc3ad785f2 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -34,6 +34,9 @@ class Paragraph extends AbstractStyle public function write() { $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { + return; + } $css = array(); // Alignment diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 1a6d4fc0e0..eb96946c6a 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -34,7 +34,8 @@ class Font extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index 143627cd64..e5f52cfe2c 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -34,7 +34,8 @@ class Paragraph extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index 76c347f057..c6e216251e 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -31,7 +31,8 @@ class Cell extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Cell) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 5965d5a4c4..851bca227d 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -57,7 +57,8 @@ public function write() */ private function writeStyle() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index f933875974..a891625b2b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -38,9 +38,11 @@ class Image extends AbstractStyle */ public function write() { - if (!is_null($this->getStyle())) { - $this->writeStyle(); + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Image) { + return; } + $this->writeStyle(); } /** diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index 797179b7cd..f9bb696f1b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -29,7 +29,8 @@ class Indentation extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Indentation) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index c4c1216b99..b3c103b6d4 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -31,7 +31,8 @@ class LineNumbering extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\LineNumbering) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 8f7c1c002f..28cf1224b4 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -29,14 +29,14 @@ class MarginBorder extends AbstractStyle * * @var int[] */ - private $sizes; + private $sizes = array(); /** * Colors * * @var string[] */ - private $colors; + private $colors = array(); /** * Other attributes diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 7056028aa6..88a75845c3 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -66,7 +66,8 @@ public function write() */ private function writeStyle() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index b773564c88..61658e03e6 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -31,7 +31,8 @@ class Section extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Section) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index cc7f9364b0..72054c207b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -29,7 +29,8 @@ class Shading extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Shading) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index b594d9c0dc..5dfb5c43cf 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -29,7 +29,8 @@ class Spacing extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Spacing) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index c15d136406..865a5a9c6e 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -29,7 +29,8 @@ class Tab extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Tab) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 7c59fd03b5..0a0241c325 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -36,7 +36,8 @@ class Table extends AbstractStyle */ public function write() { - if (is_null($style = $this->getStyle())) { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Table) { return; } $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index bb9b3a24bf..2bbe40e94e 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -31,10 +31,12 @@ class TextBox extends Image */ public function write() { - if (!is_null($this->getStyle())) { - $this->writeStyle(); - $this->writeBorder(); + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\TextBox) { + return; } + $this->writeStyle(); + $this->writeBorder(); } /** diff --git a/tests/PhpWord/Tests/Writer/HTML/StyleTest.php b/tests/PhpWord/Tests/Writer/HTML/StyleTest.php new file mode 100644 index 0000000000..8af1e47930 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/HTML/StyleTest.php @@ -0,0 +1,39 @@ +assertEquals('', $object->write()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/ODText/StyleTest.php b/tests/PhpWord/Tests/Writer/ODText/StyleTest.php new file mode 100644 index 0000000000..387accfcfe --- /dev/null +++ b/tests/PhpWord/Tests/Writer/ODText/StyleTest.php @@ -0,0 +1,41 @@ +write(); + + $this->assertEquals('', $xmlWriter->getData()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/RTF/StyleTest.php b/tests/PhpWord/Tests/Writer/RTF/StyleTest.php new file mode 100644 index 0000000000..8b4a4441ba --- /dev/null +++ b/tests/PhpWord/Tests/Writer/RTF/StyleTest.php @@ -0,0 +1,39 @@ +assertEquals('', $object->write()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php new file mode 100644 index 0000000000..97a6c6bdea --- /dev/null +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -0,0 +1,44 @@ +write(); + + $this->assertEquals('', $xmlWriter->getData()); + } + } +} From afc3d5cb64a2430df0d14ae4f3dd8241e19f5b6a Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 11 May 2014 09:16:36 +0200 Subject: [PATCH 070/167] Minor fix. If conversion factor from pointToPixel is 1.333333, then the conversion factor for PixelTopoint should be 0.75 --- src/PhpWord/Shared/Drawing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index f1d61eb6aa..5ee7e96087 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -56,7 +56,7 @@ public static function emuToPixels($value = 0) */ public static function pixelsToPoints($value = 0) { - return $value * 0.67777777; + return $value * 0.75; } /** From 539a173dc216fb243301113492bb3eb5ea62aad0 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 11 May 2014 09:18:19 +0200 Subject: [PATCH 071/167] Amended the corresponding test --- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 3fce6dc751..25fd3a3886 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -44,7 +44,7 @@ public function testUnitConversions() $this->assertEquals(round($value / 9525), $result); $result = Drawing::pixelsToPoints($value); - $this->assertEquals($value * 0.67777777, $result); + $this->assertEquals($value * 0.75, $result); $result = Drawing::pointsToPixels($value); $this->assertEquals($value * 1.333333333, $result); From 467f15a48054cf3609a81f28c3c09818da8d279e Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Sun, 11 May 2014 11:08:39 +0200 Subject: [PATCH 072/167] Added ListItemRun Element --- samples/Sample_14_ListItem.php | 12 ++ src/PhpWord/Element/AbstractContainer.php | 27 ++- src/PhpWord/Element/ListItemRun.php | 80 ++++++++ src/PhpWord/Element/TextRun.php | 2 +- .../Writer/Word2007/Element/Container.php | 2 +- .../Writer/Word2007/Element/ListItemRun.php | 61 +++++++ .../PhpWord/Tests/Element/ListItemRunTest.php | 171 ++++++++++++++++++ 7 files changed, 350 insertions(+), 5 deletions(-) create mode 100644 src/PhpWord/Element/ListItemRun.php create mode 100644 src/PhpWord/Writer/Word2007/Element/ListItemRun.php create mode 100644 tests/PhpWord/Tests/Element/ListItemRunTest.php diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index cd22df8e06..892771bc62 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -54,6 +54,18 @@ $section->addListItem('List Item 7', 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); $section->addTextBreak(2); +$section->addText('List with inline formatting.'); +$listItemRun = $section->addListItemRun(); +$listItemRun->addText('List item 1'); +$listItemRun->addText(' in bold', array('bold'=>true)); +$listItemRun = $section->addListItemRun(); +$listItemRun->addText('List item 2'); +$listItemRun->addText(' in italic', array('italic'=>true)); +$listItemRun = $section->addListItemRun(); +$listItemRun->addText('List item 3'); +$listItemRun->addText(' underlined', array('underline'=>'dash')); +$section->addTextBreak(2); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 431a306624..2c14d9a3b1 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -106,7 +106,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme $elementClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own - if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { + if (in_array($this->container, array('textrun', 'footnote', 'endnote', 'listitemrun'))) { $paragraphStyle = null; } @@ -205,6 +205,26 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n return $element; } + /** + * Add listitemrun element + * + * @param int $depth + * @param mixed $fontStyle + * @param mixed $listStyle + * @param mixed $paragraphStyle + * @return \PhpOffice\PhpWord\Element\ListItemRun + */ + public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) + { + $this->checkValidity('ListItemRun'); + + $element = new ListItemRun($depth, $fontStyle, $listStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); + + return $element; + } + /** * Add table element * @@ -345,7 +365,7 @@ public function addTextBox($style = null) private function checkValidity($method) { // Valid containers for each element - $allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote', 'endnote', 'textbox'); + $allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote', 'endnote', 'textbox', 'listitemrun'); $validContainers = array( 'Text' => $allContainers, 'Link' => $allContainers, @@ -354,6 +374,7 @@ private function checkValidity($method) 'Object' => $allContainers, 'TextRun' => array('section', 'header', 'footer', 'cell', 'textbox'), 'ListItem' => array('section', 'header', 'footer', 'cell', 'textbox'), + 'ListItemRun' => array('section', 'header', 'footer', 'cell', 'textbox'), 'Table' => array('section', 'header', 'footer', 'textbox'), 'CheckBox' => array('section', 'header', 'footer', 'cell'), 'TextBox' => array('section', 'header', 'footer', 'cell'), @@ -395,7 +416,7 @@ private function checkValidity($method) */ private function checkElementDocPart() { - $inOtherPart = in_array($this->container, array('cell', 'textrun', 'textbox')); + $inOtherPart = in_array($this->container, array('cell', 'textrun', 'textbox', 'listitemrun')); $docPart = $inOtherPart ? $this->getDocPart() : $this->container; $docPartId = $inOtherPart ? $this->getDocPartId() : $this->sectionId; $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php new file mode 100644 index 0000000000..1a52bd8912 --- /dev/null +++ b/src/PhpWord/Element/ListItemRun.php @@ -0,0 +1,80 @@ +container = 'listitemrun'; + $this->depth = $depth; + + // Version >= 0.10.0 will pass numbering style name. Older version will use old method + if (!is_null($listStyle) && is_string($listStyle)) { + $this->style = new ListItemStyle($listStyle); + } else { + $this->style = $this->setStyle(new ListItemStyle(), $listStyle, true); + } + $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + } + + /** + * Get ListItem style + */ + public function getStyle() + { + return $this->style; + } + + /** + * Get ListItem depth + */ + public function getDepth() + { + return $this->depth; + } +} diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index ecf5716b9a..6c8aa010db 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -29,7 +29,7 @@ class TextRun extends AbstractContainer * * @var string|\PhpOffice\PhpWord\Style\Paragraph */ - private $paragraphStyle; + protected $paragraphStyle; /** * Create new instance diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 384fbd5bb2..bf45e760fa 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -41,7 +41,7 @@ public function write() $xmlWriter = $this->getXmlWriter(); $container = $this->getElement(); $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); - $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; + $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')) ? true : false; // Loop through subelements $subelements = $container->getElements(); diff --git a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php new file mode 100644 index 0000000000..4431ffe60e --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php @@ -0,0 +1,61 @@ +getXmlWriter(); + $element = $this->getElement(); + + $xmlWriter->startElement('w:p'); + + $xmlWriter->startElement('w:pPr'); + $paragraphStyle = $element->getParagraphStyle(); + $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); + $styleWriter->setIsInline(true); + $styleWriter->write(); + + $xmlWriter->startElement('w:numPr'); + $xmlWriter->startElement('w:ilvl'); + $xmlWriter->writeAttribute('w:val', $element->getDepth()); + $xmlWriter->endElement(); // w:ilvl + $xmlWriter->startElement('w:numId'); + $xmlWriter->writeAttribute('w:val', $element->getStyle()->getNumId()); + $xmlWriter->endElement(); // w:numId + $xmlWriter->endElement(); // w:numPr + + $xmlWriter->endElement(); // w:pPr + + $containerWriter = new Container($xmlWriter, $element); + $containerWriter->write(); + + $xmlWriter->endElement(); // w:p + } +} diff --git a/tests/PhpWord/Tests/Element/ListItemRunTest.php b/tests/PhpWord/Tests/Element/ListItemRunTest.php new file mode 100644 index 0000000000..5b3f72c822 --- /dev/null +++ b/tests/PhpWord/Tests/Element/ListItemRunTest.php @@ -0,0 +1,171 @@ +assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); + $this->assertCount(0, $oListItemRun->getElements()); + $this->assertEquals($oListItemRun->getParagraphStyle(), null); + } + + /** + * New instance with string + */ + public function testConstructString() + { + $oListItemRun = new ListItemRun(0, null, null, 'pStyle'); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); + $this->assertCount(0, $oListItemRun->getElements()); + $this->assertEquals($oListItemRun->getParagraphStyle(), 'pStyle'); + } + + /** + * New instance with array + */ + public function testConstructArray() + { + $oListItemRun = new ListItemRun(0, null, null, array('spacing' => 100)); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); + $this->assertCount(0, $oListItemRun->getElements()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oListItemRun->getParagraphStyle()); + } + + /** + * Get style + */ + public function testStyle() + { + $oListItemRun = new ListItemRun( + 1, + null, + array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) + ); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItemRun->getStyle()); + $this->assertEquals( + $oListItemRun->getStyle()->getListType(), + \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER + ); + } + /** + * getDepth + */ + public function testDepth() + { + $iVal = rand(1, 1000); + $oListItemRun = new ListItemRun($iVal); + + $this->assertEquals($oListItemRun->getDepth(), $iVal); + } + + /** + * Add text + */ + public function testAddText() + { + $oListItemRun = new ListItemRun(); + $element = $oListItemRun->addText('text'); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element); + $this->assertCount(1, $oListItemRun->getElements()); + $this->assertEquals($element->getText(), 'text'); + } + + /** + * Add text non-UTF8 + */ + public function testAddTextNotUTF8() + { + $oListItemRun = new ListItemRun(); + $element = $oListItemRun->addText(utf8_decode('ééé')); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element); + $this->assertCount(1, $oListItemRun->getElements()); + $this->assertEquals($element->getText(), 'ééé'); + } + + /** + * Add link + */ + public function testAddLink() + { + $oListItemRun = new ListItemRun(); + $element = $oListItemRun->addLink('http://www.google.fr'); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); + $this->assertCount(1, $oListItemRun->getElements()); + $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + } + + /** + * Add link with name + */ + public function testAddLinkWithName() + { + $oListItemRun = new ListItemRun(); + $element = $oListItemRun->addLink('http://www.google.fr', utf8_decode('ééé')); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); + $this->assertCount(1, $oListItemRun->getElements()); + $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + $this->assertEquals($element->getText(), 'ééé'); + } + + /** + * Add text break + */ + public function testAddTextBreak() + { + $oListItemRun = new ListItemRun(); + $oListItemRun->addTextBreak(2); + + $this->assertCount(2, $oListItemRun->getElements()); + } + + /** + * Add image + */ + public function testAddImage() + { + $src = __DIR__ . "/../_files/images/earth.jpg"; + + $oListItemRun = new ListItemRun(); + $element = $oListItemRun->addImage($src); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Image', $element); + $this->assertCount(1, $oListItemRun->getElements()); + } +} From ded651d947f9f83c0c3bc6072542c4b75998a15e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 17:30:23 +0700 Subject: [PATCH 073/167] #149: Ability to add table inside a cell (nested table) --- CHANGELOG.md | 1 + samples/Sample_09_Tables.php | 10 +++++++++ src/PhpWord/Element/AbstractContainer.php | 2 +- .../Writer/Word2007/Element/Container.php | 22 +++++++++++-------- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a337da6955..9656a3ca8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 - TextBox: Ability to add table inside textbox - @basjan GH-231 - HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 +- Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 ### Bugfixes diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 5b4b130098..5f77f8db85 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -84,6 +84,16 @@ $table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered); $table->addCell(null, $cellRowContinue); +// 4. Nested table + +$section->addTextBreak(2); +$section->addText('Nested table', $header); + +$cell = $section->addTable()->addRow()->addCell(); +$cell->addText('This cell contains nested table.'); +$innerCell = $cell->addTable()->addRow()->addCell(); +$innerCell->addText('Inside nested table'); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 431a306624..8989007a93 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -354,7 +354,7 @@ private function checkValidity($method) 'Object' => $allContainers, 'TextRun' => array('section', 'header', 'footer', 'cell', 'textbox'), 'ListItem' => array('section', 'header', 'footer', 'cell', 'textbox'), - 'Table' => array('section', 'header', 'footer', 'textbox'), + 'Table' => array('section', 'header', 'footer', 'cell', 'textbox'), 'CheckBox' => array('section', 'header', 'footer', 'cell'), 'TextBox' => array('section', 'header', 'footer', 'cell'), 'Footnote' => array('section', 'textrun', 'cell'), diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 384fbd5bb2..cca79cca67 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -43,19 +43,23 @@ public function write() $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; - // Loop through subelements - $subelements = $container->getElements(); - if (count($subelements) > 0) { - foreach ($subelements as $subelement) { - $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, get_class($subelement)); + // Loop through elements + $elements = $container->getElements(); + $elementClass = ''; + if (count($elements) > 0) { + foreach ($elements as $element) { + $elementClass = get_class($element); + $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass); if (class_exists($writerClass)) { - $writer = new $writerClass($xmlWriter, $subelement, $withoutP); + $writer = new $writerClass($xmlWriter, $element, $withoutP); $writer->write(); } } - } else { - // Special case for Cell: They have to contain a TextBreak at least - if ($containerClass == 'Cell') { + } + + // Special case for Cell: They have to contain a w:p element at the end + if ($containerClass == 'Cell') { + if ($elementClass == '' || $elementClass == 'PhpOffice\\PhpWord\\Element\\Table') { $writerClass = "{$this->namespace}\\TextBreak"; $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); $writer->write(); From 8c9e5116c456de07bd71fdfb2eb53d06dd2a4688 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 18:10:47 +0700 Subject: [PATCH 074/167] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a337da6955..eadf99a647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,13 +10,15 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Image: Ability to define relative and absolute positioning - @basjan GH-217 - Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 -- TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 +- TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 GH-229 - TextBox: Ability to add table inside textbox - @basjan GH-231 - HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 +- ListItemRun: New element that can add a list item with inline formatting like a textrun - @basjan GH-235 ### Bugfixes - Header: All images added to the second header were assigned to the first header - @basjan GH-222 +- Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234 ### Deprecated From c243a11e5756c0dfb00c1b4155d8283f60a29e1d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 18:57:58 +0700 Subject: [PATCH 075/167] Additional type checks in style writers --- src/PhpWord/Element/ListItemRun.php | 1 - src/PhpWord/Shared/XMLWriter.php | 8 ++++---- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Writer/HTML/Style/AbstractStyle.php | 4 ++-- src/PhpWord/Writer/Word2007/Style/Image.php | 10 ++++------ src/PhpWord/Writer/Word2007/Style/TextBox.php | 12 +++++++----- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php index 1a52bd8912..a6dbd93265 100644 --- a/src/PhpWord/Element/ListItemRun.php +++ b/src/PhpWord/Element/ListItemRun.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; use PhpOffice\PhpWord\Style\Paragraph; diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index a16fe0b4b1..fd1f1f60d2 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -153,14 +153,14 @@ public function writeRaw($text) /** * Write element if ... * - * @param bool $condition + * @param bool|null $condition * @param string $element * @param string $attribute * @param string $value */ public function writeElementIf($condition, $element, $attribute = null, $value = null) { - if ($condition) { + if ($condition == true) { if (is_null($attribute)) { $this->xmlWriter->writeElement($element, $value); } else { @@ -174,13 +174,13 @@ public function writeElementIf($condition, $element, $attribute = null, $value = /** * Write attribute if ... * - * @param bool $condition + * @param bool|null $condition * @param string $attribute * @param string $value */ public function writeAttributeIf($condition, $attribute, $value) { - if ($condition) { + if ($condition == true) { $this->xmlWriter->writeAttribute($attribute, $value); } } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 32874b2f0a..85ad52b9be 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -651,7 +651,7 @@ public function setShading($value = null) /** * Toggle $target property to false when $source true * - * @param bool $target Target property + * @param bool|null $target Target property * @param bool $sourceValue */ private function toggleFalse(&$target, $sourceValue) diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index d25e7b6a5c..3b6d99c10b 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -87,12 +87,12 @@ protected function assembleCss($css) /** * Get value if ... * - * @param bool $condition + * @param bool|null $condition * @param string $value * @return string */ protected function getValueIf($condition, $value) { - return $condition ? $value : ''; + return $condition == true ? $value : ''; } } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index a891625b2b..0b25f4b9b0 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -42,7 +42,7 @@ public function write() if (!$style instanceof \PhpOffice\PhpWord\Style\Image) { return; } - $this->writeStyle(); + $this->writeStyle($style); } /** @@ -65,10 +65,9 @@ public function writeW10Wrap() /** * Write style attribute */ - protected function writeStyle() + protected function writeStyle(ImageStyle $style) { $xmlWriter = $this->getXmlWriter(); - $style = $this->getStyle(); // Default style array $styleArray = array( @@ -77,7 +76,7 @@ protected function writeStyle() 'mso-width-relative' => 'margin', 'mso-height-relative' => 'margin', ); - $styleArray = array_merge($styleArray, $this->getElementStyle()); + $styleArray = array_merge($styleArray, $this->getElementStyle($style)); // Absolute/relative positioning $positioning = $style->getPositioning(); @@ -123,9 +122,8 @@ protected function writeStyle() * * @return array */ - private function getElementStyle() + private function getElementStyle(ImageStyle $style) { - $style = $this->getStyle(); $styles = array(); $styleValues = array( 'width' => $style->getWidth(), diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index 2bbe40e94e..d8456ae8bb 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -35,8 +35,8 @@ public function write() if (!$style instanceof \PhpOffice\PhpWord\Style\TextBox) { return; } - $this->writeStyle(); - $this->writeBorder(); + $this->writeStyle($style); + $this->writeBorder($style); } /** @@ -50,6 +50,9 @@ public function writeW10Wrap() return; } $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\TextBox) { + return; + } $relativePositions = array( TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin', @@ -88,7 +91,7 @@ public function writeW10Wrap() public function writeInnerMargin() { $style = $this->getStyle(); - if (!$style->hasInnerMargins()) { + if (!$style instanceof \PhpOffice\PhpWord\Style\TextBox || !$style->hasInnerMargins()) { return; } @@ -100,10 +103,9 @@ public function writeInnerMargin() /** * Writer border */ - private function writeBorder() + private function writeBorder(TextBoxStyle $style) { $xmlWriter = $this->getXmlWriter(); - $style = $this->getStyle(); // Border size $borderSize = $style->getBorderSize(); From c7e4ed0c182ec0470701cda65e9db0e894063dca Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 19:41:48 +0700 Subject: [PATCH 076/167] Type check in element writers --- src/PhpWord/Writer/HTML/Element/Container.php | 3 ++ src/PhpWord/Writer/HTML/Element/Footnote.php | 4 ++ src/PhpWord/Writer/HTML/Element/Image.php | 4 ++ src/PhpWord/Writer/HTML/Element/Link.php | 4 ++ src/PhpWord/Writer/HTML/Element/ListItem.php | 4 ++ src/PhpWord/Writer/HTML/Element/Table.php | 4 ++ src/PhpWord/Writer/HTML/Element/Title.php | 4 ++ src/PhpWord/Writer/ODText/Element/Image.php | 3 ++ src/PhpWord/Writer/ODText/Element/Link.php | 3 ++ src/PhpWord/Writer/ODText/Element/Table.php | 3 ++ src/PhpWord/Writer/ODText/Element/Text.php | 3 ++ src/PhpWord/Writer/RTF/Element/Container.php | 3 ++ src/PhpWord/Writer/RTF/Element/Text.php | 21 +++++---- .../Writer/Word2007/Element/CheckBox.php | 3 ++ .../Writer/Word2007/Element/Container.php | 3 ++ .../Writer/Word2007/Element/Footnote.php | 3 ++ src/PhpWord/Writer/Word2007/Element/Image.php | 19 ++++---- src/PhpWord/Writer/Word2007/Element/Link.php | 3 ++ .../Writer/Word2007/Element/ListItem.php | 3 ++ .../Writer/Word2007/Element/ListItemRun.php | 3 ++ .../Writer/Word2007/Element/Object.php | 3 ++ .../Writer/Word2007/Element/PreserveText.php | 3 ++ src/PhpWord/Writer/Word2007/Element/TOC.php | 3 ++ src/PhpWord/Writer/Word2007/Element/Table.php | 16 +++---- src/PhpWord/Writer/Word2007/Element/Text.php | 3 ++ .../Writer/Word2007/Element/TextBox.php | 3 ++ .../Writer/Word2007/Element/TextBreak.php | 3 ++ src/PhpWord/Writer/Word2007/Element/Title.php | 3 ++ .../PhpWord/Tests/Writer/HTML/ElementTest.php | 41 +++++++++++++++++ .../Tests/Writer/ODText/ElementTest.php | 42 +++++++++++++++++ .../PhpWord/Tests/Writer/RTF/ElementTest.php | 41 +++++++++++++++++ .../Tests/Writer/Word2007/ElementTest.php | 45 +++++++++++++++++++ 32 files changed, 281 insertions(+), 25 deletions(-) create mode 100644 tests/PhpWord/Tests/Writer/HTML/ElementTest.php create mode 100644 tests/PhpWord/Tests/Writer/ODText/ElementTest.php create mode 100644 tests/PhpWord/Tests/Writer/RTF/ElementTest.php create mode 100644 tests/PhpWord/Tests/Writer/Word2007/ElementTest.php diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php index 6249426aa5..c55a79212a 100644 --- a/src/PhpWord/Writer/HTML/Element/Container.php +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -32,6 +32,9 @@ class Container extends AbstractElement public function write() { $container = $this->element; + if (!$this->element instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + return; + } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; $content = ''; diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index cd1baacbd9..30398b17fb 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -38,6 +38,10 @@ class Footnote extends AbstractElement */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { + return; + } + $noteId = count($this->parentWriter->getNotes()) + 1; $noteMark = $this->noteType . '-' . $this->element->getRelationId(); $content = "{$noteId}"; diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 2ae8786584..5c2edbb216 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -34,6 +34,10 @@ class Image extends Text */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { + return; + } + $content = ''; if (!$this->parentWriter->isPdf()) { $imageData = $this->getBase64ImageData($this->element); diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 6f1977f8aa..820a1526ff 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -31,6 +31,10 @@ class Link extends Text */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } + $content = ''; $content .= $this->writeOpening(); $content .= "element->getTarget()}\">{$this->element->getText()}"; diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 722d920a55..8e302b03ad 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -31,6 +31,10 @@ class ListItem extends AbstractElement */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { + return; + } + $text = htmlspecialchars($this->element->getTextObject()->getText()); $content = '

' . $text . '

' . PHP_EOL; diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index a92deea6b7..bd7795efd7 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -31,6 +31,10 @@ class Table extends AbstractElement */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } + $content = ''; $rows = $this->element->getRows(); $rowCount = count($rows); diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 2a33a2827a..64d47ec2e0 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -31,6 +31,10 @@ class Title extends AbstractElement */ public function write() { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { + return; + } + $tag = 'h' . $this->element->getDepth(); $text = htmlspecialchars($this->element->getText()); $content = "<{$tag}>{$text}" . PHP_EOL; diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php index 909a9aede3..3229b59c67 100644 --- a/src/PhpWord/Writer/ODText/Element/Image.php +++ b/src/PhpWord/Writer/ODText/Element/Image.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Image) { + return; + } $mediaIndex = $element->getMediaIndex(); $target = 'Pictures/' . $element->getTarget(); diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 1ccac435f5..79d3aa246f 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } if (!$this->withoutP) { $xmlWriter->startElement('text:p'); // text:p diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 411f1f38a3..19e5b40830 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } $rows = $element->getRows(); $rowCount = count($rows); $colCount = $element->countColumns(); diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index e960dea855..6baf32001f 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } $fontStyle = $element->getFontStyle(); $paragraphStyle = $element->getParagraphStyle(); diff --git a/src/PhpWord/Writer/RTF/Element/Container.php b/src/PhpWord/Writer/RTF/Element/Container.php index 57127eb8e4..4ce4334c28 100644 --- a/src/PhpWord/Writer/RTF/Element/Container.php +++ b/src/PhpWord/Writer/RTF/Element/Container.php @@ -32,6 +32,9 @@ class Container extends \PhpOffice\PhpWord\Writer\HTML\Element\Container public function write() { $container = $this->element; + if (!$this->element instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + return; + } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; $content = ''; diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index a52b207174..701a5be112 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; +use PhpOffice\PhpWord\Element\Text as TextElement; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; @@ -34,10 +35,14 @@ class Text extends AbstractElement */ public function write() { - $fontStyle = $this->getFontStyle(); + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } + + $fontStyle = $this->getFontStyle($this->element); $content = ''; - $content .= $this->writeParagraphStyle(); + $content .= $this->writeParagraphStyle($this->element); $content .= $this->writeFontStyleBegin($fontStyle); if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { $content .= ' '; @@ -57,22 +62,22 @@ public function write() * * @return string */ - private function writeParagraphStyle() + private function writeParagraphStyle(TextElement $element) { $content = ''; // Get paragraph style - $paragraphStyle = $this->element->getParagraphStyle(); + $paragraphStyle = $element->getParagraphStyle(); if (is_string($paragraphStyle)) { $paragraphStyle = Style::getStyle($paragraphStyle); } // Write style when applicable if ($paragraphStyle && !$this->withoutP) { - if ($this->parentWriter->getLastParagraphStyle() != $this->element->getParagraphStyle()) { + if ($this->parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { $styleWriter = new ParagraphStyleWriter($paragraphStyle); $content = $styleWriter->write(); - $this->parentWriter->setLastParagraphStyle($this->element->getParagraphStyle()); + $this->parentWriter->setLastParagraphStyle($element->getParagraphStyle()); } else { $this->parentWriter->setLastParagraphStyle(); } @@ -139,9 +144,9 @@ private function writeFontStyleEnd($style) * * @return \PhpOffice\PhpWord\Style\Font */ - private function getFontStyle() + private function getFontStyle(TextElement $element) { - $fontStyle = $this->element->getFontStyle(); + $fontStyle = $element->getFontStyle(); if (is_string($fontStyle)) { $fontStyle = Style::getStyle($fontStyle); } diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 96e210b56d..1d7811cd28 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\CheckBox) { + return; + } $name = htmlspecialchars($element->getName()); $name = String::controlCharacterPHP2OOXML($name); diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 150cb32477..57a2720886 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -40,6 +40,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $container = $this->getElement(); + if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + return; + } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')) ? true : false; diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 646f70ed3f..d33a0dc9d6 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -38,6 +38,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Footnote) { + return; + } $this->writeOpeningWP(); diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index c7bd8d7ded..1b4284d28d 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; +use PhpOffice\PhpWord\Element\Image as ImageElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Image as ImageStyleWriter; /** @@ -31,22 +33,24 @@ class Image extends AbstractElement */ public function write() { + $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Image) { + return; + } if ($element->isWatermark()) { - $this->writeWatermark(); + $this->writeWatermark($xmlWriter, $element); } else { - $this->writeImage(); + $this->writeImage($xmlWriter, $element); } } /** * Write image element */ - private function writeImage() + private function writeImage(XMLWriter $xmlWriter, ImageElement $element) { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); $style = $element->getStyle(); @@ -84,11 +88,8 @@ private function writeImage() /** * Write watermark element */ - private function writeWatermark() + private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); - $rId = $element->getRelationId(); $style = $element->getStyle(); $style->setPositioning('absolute'); diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 517e276db2..3b595b4cc2 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index e625114c39..7b86efaeb8 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\ListItem) { + return; + } $textObject = $element->getTextObject(); diff --git a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php index 4431ffe60e..747c262525 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\ListItemRun) { + return; + } $xmlWriter->startElement('w:p'); diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index 5f56a7047e..07580a42fd 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Object) { + return; + } $rIdObject = $element->getRelationId() + ($element->isInSection() ? 6 : 0); $rIdImage = $element->getImageRelationId() + ($element->isInSection() ? 6 : 0); diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index b3b00d16da..97693d9ba4 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\PreserveText) { + return; + } $texts = $element->getText(); if (!is_array($texts)) { diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 28d7bc3134..98486b0126 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -36,6 +36,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\TOC) { + return; + } $titles = $element->getTitles(); $writeFieldMark = true; diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 5c82114a1f..4ce97d10b1 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\Element\Cell as CellElement; use PhpOffice\PhpWord\Element\Row as RowElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; @@ -38,6 +39,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Table) { + return; + } $rows = $element->getRows(); $rowCount = count($rows); @@ -94,7 +98,7 @@ public function write() // Table rows for ($i = 0; $i < $rowCount; $i++) { - $this->writeRow($rows[$i]); + $this->writeRow($xmlWriter, $rows[$i]); } $xmlWriter->endElement(); } @@ -103,10 +107,8 @@ public function write() /** * Write row */ - private function writeRow(RowElement $row) + private function writeRow(XMLWriter $xmlWriter, RowElement $row) { - $xmlWriter = $this->getXmlWriter(); - $height = $row->getHeight(); $rowStyle = $row->getStyle(); @@ -132,7 +134,7 @@ private function writeRow(RowElement $row) $xmlWriter->endElement(); } foreach ($row->getCells() as $cell) { - $this->writeCell($cell); + $this->writeCell($xmlWriter, $cell); } $xmlWriter->endElement(); // w:tr } @@ -140,10 +142,8 @@ private function writeRow(RowElement $row) /** * Write cell */ - private function writeCell(CellElement $cell) + private function writeCell(XMLWriter $xmlWriter, CellElement $cell) { - $xmlWriter = $this->getXmlWriter(); - $cellStyle = $cell->getStyle(); $xmlWriter->startElement('w:tc'); diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index d6402dbf9a..1385e6e6c7 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -35,6 +35,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Text) { + return; + } $text = htmlspecialchars($element->getText()); $text = String::controlCharacterPHP2OOXML($text); diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 6b63c31ae8..bb1629bcdc 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) { + return; + } $style = $element->getStyle(); $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 05de2917cf..c74cdc7a47 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -31,6 +31,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\TextBreak) { + return; + } if (!$this->withoutP) { $hasStyle = $element->hasStyle(); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index c5eda5fd6a..703188ef82 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -33,6 +33,9 @@ public function write() { $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Title) { + return; + } $bookmarkId = $element->getBookmarkId(); $anchor = '_Toc' . ($bookmarkId + 252634154); diff --git a/tests/PhpWord/Tests/Writer/HTML/ElementTest.php b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php new file mode 100644 index 0000000000..d2ed70ea64 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php @@ -0,0 +1,41 @@ +assertEquals('', $object->write()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/ODText/ElementTest.php b/tests/PhpWord/Tests/Writer/ODText/ElementTest.php new file mode 100644 index 0000000000..6354520a61 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/ODText/ElementTest.php @@ -0,0 +1,42 @@ +write(); + + $this->assertEquals('', $xmlWriter->getData()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php new file mode 100644 index 0000000000..9f597c1512 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php @@ -0,0 +1,41 @@ +assertEquals('', $object->write()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php new file mode 100644 index 0000000000..0a9eb4cedc --- /dev/null +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -0,0 +1,45 @@ +write(); + + $this->assertEquals('', $xmlWriter->getData()); + } + } +} From c9179d681f64fac0190bc33ea79f24cd863abf56 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 11 May 2014 22:54:51 +0700 Subject: [PATCH 077/167] Refactor elements and containers --- CHANGELOG.md | 1 + src/PhpWord/Element/AbstractContainer.php | 270 ++++++++---------- src/PhpWord/Element/AbstractElement.php | 29 +- src/PhpWord/Element/Cell.php | 17 +- src/PhpWord/Element/Endnote.php | 6 +- src/PhpWord/Element/Footer.php | 6 +- src/PhpWord/Element/Footnote.php | 6 +- src/PhpWord/Element/Header.php | 7 +- src/PhpWord/Element/ListItemRun.php | 6 +- src/PhpWord/Element/Row.php | 10 +- src/PhpWord/Element/Section.php | 23 +- src/PhpWord/Element/Table.php | 20 +- src/PhpWord/Element/TextBox.php | 6 +- src/PhpWord/Element/TextRun.php | 6 +- src/PhpWord/Element/Title.php | 59 ++-- src/PhpWord/Shared/Html.php | 1 + src/PhpWord/Writer/HTML/Element/Container.php | 2 +- src/PhpWord/Writer/ODText/Style/Font.php | 12 +- src/PhpWord/Writer/RTF/Element/Container.php | 2 +- src/PhpWord/Writer/Word2007/Element/Image.php | 1 - src/PhpWord/Writer/Word2007/Element/TOC.php | 25 +- src/PhpWord/Writer/Word2007/Element/Title.php | 8 +- tests/PhpWord/Tests/Element/CellTest.php | 69 ++--- tests/PhpWord/Tests/Element/RowTest.php | 15 +- tests/PhpWord/Tests/Element/TitleTest.php | 2 +- 25 files changed, 266 insertions(+), 343 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f4cd81052..af3ca78674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - Static classes `Footnotes`, `Endnotes`, and `TOC` - `Writer\Word2007\Part`: `Numbering::writeNumbering()`, `Settings::writeSettings()`, `WebSettings::writeWebSettings()`, `ContentTypes::writeContentTypes()`, `Styles::writeStyles()`, `Document::writeDocument()` all changed into `write()` - `Writer\Word2007\Part\DocProps`: Split into `Writer\Word2007\Part\DocPropsCore` and `Writer\Word2007\Part\DocPropsApp` +- `Element\Title::getBookmarkId()` replaced by `Element\Title::getRelationId()` ### Miscellaneous diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 86b604f4b7..39193031c1 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -35,15 +35,78 @@ abstract class AbstractContainer extends AbstractElement protected $elements = array(); /** - * Set element index and unique id, and add element into elements collection + * Container type section|header|footer|footnote|endnote|cell|textrun|textbox + * + * @var string + */ + protected $container; + + /** + * Add element + * + * Each element has different number of parameters passed + * + * @param string $elementName + * @return \PhpOffice\PhpWord\Element\AbstractElement */ - protected function addElement(AbstractElement $element) + protected function addElement($elementName) { - // $type = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($element))); + $elementClass = __NAMESPACE__ . '\\' . $elementName; + $this->checkValidity($elementName); + + // Get arguments + $args = func_get_args(); + $argsCount = func_num_args(); + $withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')); + if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) { + $args[3] = null; + } + + // Create element + if ($argsCount == 1) { // Page Break + $element = new $elementClass(); + } elseif ($argsCount == 2) { // TextRun, TextBox, Table, Footnote, Endnote + $element = new $elementClass($args[1]); + } elseif ($argsCount == 3) { // Object, TextBreak, Title + $element = new $elementClass($args[1], $args[2]); + } elseif ($argsCount == 4) { // PreserveText, Text, Image + $element = new $elementClass($args[1], $args[2], $args[3]); + } elseif ($argsCount == 5) { // CheckBox, Link, ListItemRun, TOC + $element = new $elementClass($args[1], $args[2], $args[3], $args[4]); + } elseif ($argsCount == 6) { // ListItem + $element = new $elementClass($args[1], $args[2], $args[3], $args[4], $args[5]); + } + + // Set relation Id for media collection + if (in_array($elementName, array('Link', 'Image', 'Object'))) { + $mediaContainer = $this->getMediaContainer(); + if ($elementName == 'Image') { + $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $element); + } else { + $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1]); + } + $element->setRelationId($rId); + } + if ($elementName == 'Object') { + $rIdIcon = Media::addElement($mediaContainer, 'image', $element->getIcon(), new Image($element->getIcon())); + $element->setImageRelationId($rIdIcon); + } + + // Set relation Id for other collection + if (in_array($elementName, array('Footnote', 'Endnote', 'Title')) && $this->phpWord instanceof PhpWord) { + $addMethod = "add{$elementName}"; + $rId = $this->phpWord->$addMethod($element); + $element->setRelationId($rId); + } + + // Set other properties and add element into collection + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); $element->setPhpWord($this->phpWord); $this->elements[] = $element; + + return $element; } /** @@ -59,62 +122,24 @@ public function getElements() /** * Count elements * - * @return integer + * @return int */ public function countElements() { return count($this->elements); } - /** - * Add generic element with style - * - * This is how all elements should be added with dependency injection: with - * just one simple $style. Currently this function supports TextRun, Table, - * and TextBox since all other elements have different arguments - * - * @todo Change the function name into something better? - * - * @param string $elementName - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\AbstractElement - */ - private function addGenericElement($elementName, $style) - { - $elementClass = __NAMESPACE__ . '\\' . $elementName; - - $this->checkValidity($elementName); - $element = new $elementClass($style); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; - } - /** * Add text/preservetext element * * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @param string $elementName Text|PreserveText * @return \PhpOffice\PhpWord\Element\Text|\PhpOffice\PhpWord\Element\PreserveText */ - public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') + public function addText($text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity($elementName); - $elementClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $elementName; - - // Reset paragraph style for footnote and textrun. They have their own - if (in_array($this->container, array('textrun', 'footnote', 'endnote', 'listitemrun'))) { - $paragraphStyle = null; - } - - $element = new $elementClass($text, $fontStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; + return $this->addElement('Text', $text, $fontStyle, $paragraphStyle); } /** @@ -125,7 +150,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme */ public function addTextRun($paragraphStyle = null) { - return $this->addGenericElement('TextRun', $paragraphStyle); + return $this->addElement('TextRun', $paragraphStyle); } /** @@ -139,18 +164,7 @@ public function addTextRun($paragraphStyle = null) */ public function addLink($target, $text = null, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('Link'); - $elementDocPart = $this->checkElementDocPart(); - - $element = new Link($target, $text, $fontStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - - $rId = Media::addElement($elementDocPart, 'link', $target); - $element->setRelationId($rId); - - $this->addElement($element); - - return $element; + return $this->addElement('Link', $target, $text, $fontStyle, $paragraphStyle); } /** @@ -163,7 +177,7 @@ public function addLink($target, $text = null, $fontStyle = null, $paragraphStyl */ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) { - return $this->addText($text, $fontStyle, $paragraphStyle, 'PreserveText'); + return $this->addElement('PreserveText', $text, $fontStyle, $paragraphStyle); } /** @@ -175,12 +189,8 @@ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null */ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('TextBreak'); - for ($i = 1; $i <= $count; $i++) { - $element = new TextBreak($fontStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); + $this->addElement('TextBreak', $fontStyle, $paragraphStyle); } } @@ -196,13 +206,7 @@ public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = nu */ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->checkValidity('ListItem'); - - $element = new ListItem($text, $depth, $fontStyle, $listStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; + return $this->addElement('ListItem', $text, $depth, $fontStyle, $listStyle, $paragraphStyle); } /** @@ -216,13 +220,7 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n */ public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->checkValidity('ListItemRun'); - - $element = new ListItemRun($depth, $fontStyle, $listStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; + return $this->addElement('ListItemRun', $depth, $fontStyle, $listStyle, $paragraphStyle); } /** @@ -234,7 +232,7 @@ public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, */ public function addTable($style = null) { - return $this->addGenericElement('Table', $style); + return $this->addElement('Table', $style); } /** @@ -242,23 +240,12 @@ public function addTable($style = null) * * @param string $source * @param mixed $style Image style - * @param boolean $isWatermark + * @param bool $isWatermark * @return \PhpOffice\PhpWord\Element\Image */ public function addImage($source, $style = null, $isWatermark = false) { - $this->checkValidity('Image'); - $elementDocPart = $this->checkElementDocPart(); - - $element = new Image($source, $style, $isWatermark); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - - $rId = Media::addElement($elementDocPart, 'image', $source, $element); - $element->setRelationId($rId); - - $this->addElement($element); - - return $element; + return $this->addElement('Image', $source, $style, $isWatermark); } /** @@ -269,49 +256,21 @@ public function addImage($source, $style = null, $isWatermark = false) * @param string $source * @param mixed $style * @return \PhpOffice\PhpWord\Element\Object - * @throws \PhpOffice\PhpWord\Exception\Exception */ public function addObject($source, $style = null) { - $this->checkValidity('Object'); - $elementDocPart = $this->checkElementDocPart(); - - $element = new Object($source, $style); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - - $rId = Media::addElement($elementDocPart, 'object', $source); - $element->setRelationId($rId); - $rIdIcon = Media::addElement($elementDocPart, 'image', $element->getIcon(), new Image($element->getIcon())); - $element->setImageRelationId($rIdIcon); - - $this->addElement($element); - - return $element; + return $this->addElement('Object', $source, $style); } /** * Add footnote element * * @param mixed $paragraphStyle - * @param string $elementName * @return \PhpOffice\PhpWord\Element\Footnote */ - public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') + public function addFootnote($paragraphStyle = null) { - $this->checkValidity($elementName); - $elementClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $elementName; - $docPart = strtolower($elementName); - $addMethod = "add{$elementName}"; - - $element = new $elementClass($paragraphStyle); - $element->setDocPart($docPart, $this->getDocPartId()); - if ($this->phpWord instanceof PhpWord) { - $rId = $this->phpWord->$addMethod($element); - $element->setRelationId($rId); - } - $this->addElement($element); - - return $element; + return $this->addElement('Footnote', $paragraphStyle); } /** @@ -322,7 +281,7 @@ public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') */ public function addEndnote($paragraphStyle = null) { - return $this->addFootnote($paragraphStyle, 'Endnote'); + return $this->addElement('Endnote', $paragraphStyle); } /** @@ -336,13 +295,7 @@ public function addEndnote($paragraphStyle = null) */ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('CheckBox'); - - $element = new CheckBox($name, $text, $fontStyle, $paragraphStyle); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); - - return $element; + return $this->addElement('CheckBox', $name, $text, $fontStyle, $paragraphStyle); } /** @@ -353,47 +306,50 @@ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = n */ public function addTextBox($style = null) { - return $this->addGenericElement('TextBox', $style); + return $this->addElement('TextBox', $style); } /** * Check if a method is allowed for the current container * * @param string $method - * @return boolean + * @return bool */ private function checkValidity($method) { // Valid containers for each element - $allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote', 'endnote', 'textbox', 'listitemrun'); + $allContainers = array( + 'Section', 'Header', 'Footer', 'Footnote', 'Endnote', + 'Cell', 'TextRun', 'TextBox', 'ListItemRun', + ); $validContainers = array( 'Text' => $allContainers, 'Link' => $allContainers, 'TextBreak' => $allContainers, 'Image' => $allContainers, 'Object' => $allContainers, - 'TextRun' => array('section', 'header', 'footer', 'cell', 'textbox'), - 'ListItem' => array('section', 'header', 'footer', 'cell', 'textbox'), - 'ListItemRun' => array('section', 'header', 'footer', 'cell', 'textbox'), - 'Table' => array('section', 'header', 'footer', 'cell', 'textbox'), - 'CheckBox' => array('section', 'header', 'footer', 'cell'), - 'TextBox' => array('section', 'header', 'footer', 'cell'), - 'Footnote' => array('section', 'textrun', 'cell'), - 'Endnote' => array('section', 'textrun', 'cell'), - 'PreserveText' => array('header', 'footer', 'cell'), + 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), + 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), + 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), + 'Table' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), + 'CheckBox' => array('Section', 'Header', 'Footer', 'Cell'), + 'TextBox' => array('Section', 'Header', 'Footer', 'Cell'), + 'Footnote' => array('Section', 'TextRun', 'Cell'), + 'Endnote' => array('Section', 'TextRun', 'Cell'), + 'PreserveText' => array('Header', 'Footer', 'Cell'), ); // 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')), + '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("Cannot put $method in $this->container."); + throw new \BadMethodCallException("Cannot add $method in $this->container."); } } // Check if a method is valid for current container, located in other container @@ -403,7 +359,7 @@ private function checkValidity($method) $allowedDocParts = $rules[1]; foreach ($containers as $container) { if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { - throw new \BadMethodCallException("Cannot put $method in $this->container."); + throw new \BadMethodCallException("Cannot add $method in $this->container."); } } } @@ -412,17 +368,21 @@ private function checkValidity($method) } /** - * Return element location in document: section, headerx, or footerx + * Return media element (image, object, link) container name + * + * @return string section|headerx|footerx|footnote|endnote */ - private function checkElementDocPart() + private function getMediaContainer() { - $inOtherPart = in_array($this->container, array('cell', 'textrun', 'textbox', 'listitemrun')); - $docPart = $inOtherPart ? $this->getDocPart() : $this->container; - $docPartId = $inOtherPart ? $this->getDocPartId() : $this->sectionId; - $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - $docPartId = $inHeaderFooter ? $this->getDocPartId() : $docPartId; + $partName = $this->container; + if (in_array($partName, array('Cell', 'TextRun', 'TextBox', 'ListItemRun'))) { + $partName = $this->getDocPart(); + } + if ($partName == 'Header' || $partName == 'Footer') { + $partName .= $this->getDocPartId(); + } - return $inHeaderFooter ? $docPart . $docPartId : $docPart; + return strtolower($partName); } /** diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 7e3151e21e..40e65c1230 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -34,13 +34,6 @@ abstract class AbstractElement */ protected $phpWord; - /** - * Container type section|header|footer|cell|textrun|footnote|endnote|textbox - * - * @var string - */ - protected $container; - /** * Section Id * @@ -57,7 +50,7 @@ abstract class AbstractElement * * @var string */ - protected $docPart = 'section'; + protected $docPart = 'Section'; /** * Document part Id @@ -66,21 +59,21 @@ abstract class AbstractElement * because the max number of header/footer in every page is 3, i.e. * AUTO, FIRST, and EVEN (AUTO = ODD) * - * @var integer + * @var int */ protected $docPartId = 1; /** * Index of element in the elements collection (start with 1) * - * @var integer + * @var int */ protected $elementIndex = 1; /** * Unique Id for element * - * @var integer + * @var int */ protected $elementId; @@ -114,7 +107,7 @@ public function setPhpWord(PhpWord &$phpWord = null) /** * Get section number * - * @return integer + * @return int */ public function getSectionId() { @@ -125,7 +118,7 @@ public function getSectionId() * Set doc part * * @param string $docPart - * @param integer $docPartId + * @param int $docPartId */ public function setDocPart($docPart, $docPartId = 1) { @@ -146,7 +139,7 @@ public function getDocPart() /** * Get doc part Id * - * @return integer + * @return int */ public function getDocPartId() { @@ -212,13 +205,13 @@ public function setRelationId($rId) } /** - * Check if element is located in section doc part (as opposed to header/footer) + * Check if element is located in Section doc part (as opposed to Header/Footer) * - * @return boolean + * @return bool */ public function isInSection() { - return ($this->docPart == 'section'); + return ($this->docPart == 'Section'); } /** @@ -226,7 +219,7 @@ public function isInSection() * * @param mixed $styleObject Style object * @param mixed $styleValue Style value - * @param boolean $returnObject Always return object + * @param bool $returnObject Always return object */ protected function setStyle($styleObject, $styleValue = null, $returnObject = false) { diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index bc9b47b4e9..ea49bc7bc8 100644 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -24,6 +24,11 @@ */ class Cell extends AbstractContainer { + /** + * @var string Container type + */ + protected $container = 'Cell'; + /** * Cell width * @@ -36,22 +41,18 @@ class Cell extends AbstractContainer * * @var \PhpOffice\PhpWord\Style\Cell */ - private $cellStyle; + private $style; /** * Create new instance * - * @param string $docPart section|header|footer - * @param int $docPartId * @param int $width * @param array|\PhpOffice\PhpWord\Style\Cell $style */ - public function __construct($docPart, $docPartId, $width = null, $style = null) + public function __construct($width = null, $style = null) { - $this->container = 'cell'; - $this->setDocPart($docPart, $docPartId); $this->width = $width; - $this->cellStyle = $this->setStyle(new CellStyle(), $style, true); + $this->style = $this->setStyle(new CellStyle(), $style, true); } /** @@ -61,7 +62,7 @@ public function __construct($docPart, $docPartId, $width = null, $style = null) */ public function getStyle() { - return $this->cellStyle; + return $this->style; } /** diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php index 03ef3b68e6..20278898f8 100644 --- a/src/PhpWord/Element/Endnote.php +++ b/src/PhpWord/Element/Endnote.php @@ -26,6 +26,11 @@ */ class Endnote extends Footnote { + /** + * @var string Container type + */ + protected $container = 'Endnote'; + /** * Create new instance * @@ -33,7 +38,6 @@ class Endnote extends Footnote */ public function __construct($paragraphStyle = null) { - $this->container = 'endnote'; $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); } } diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 265c2c4c8f..142ccfda1a 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -33,11 +33,9 @@ class Footer extends AbstractContainer const EVEN = 'even'; /** - * Container type - * - * @var string + * @var string Container type */ - protected $container = 'footer'; + protected $container = 'Footer'; /** * Header type diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index d59a10a5d0..76311c6bbd 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -24,6 +24,11 @@ */ class Footnote extends AbstractContainer { + /** + * @var string Container type + */ + protected $container = 'Footnote'; + /** * Paragraph style * @@ -38,7 +43,6 @@ class Footnote extends AbstractContainer */ public function __construct($paragraphStyle = null) { - $this->container = 'footnote'; $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); } diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index be95936c6b..feaa86e81a 100644 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -22,13 +22,10 @@ */ class Header extends Footer { - /** - * Container type - * - * @var string + * @var string Container type */ - protected $container = 'header'; + protected $container = 'Header'; /** * Add a Watermark Element diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php index a6dbd93265..2a2a51afc4 100644 --- a/src/PhpWord/Element/ListItemRun.php +++ b/src/PhpWord/Element/ListItemRun.php @@ -25,6 +25,11 @@ */ class ListItemRun extends TextRun { + /** + * @var string Container type + */ + protected $container = 'ListItemRun'; + /** * ListItem Style * @@ -49,7 +54,6 @@ class ListItemRun extends TextRun */ public function __construct($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->container = 'listitemrun'; $this->depth = $depth; // Version >= 0.10.0 will pass numbering style name. Older version will use old method diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index 0eb18784b4..3aef453986 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -50,14 +50,11 @@ class Row extends AbstractElement /** * Create a new table row * - * @param string $docPart - * @param int $docPartId * @param int $height * @param mixed $style */ - public function __construct($docPart, $docPartId, $height = null, $style = null) + public function __construct($height = null, $style = null) { - $this->setDocPart($docPart, $docPartId); $this->height = $height; $this->style = $this->setStyle(new RowStyle(), $style, true); } @@ -67,12 +64,15 @@ public function __construct($docPart, $docPartId, $height = null, $style = null) * * @param int $width * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Cell */ public function addCell($width = null, $style = null) { - $cell = new Cell($this->getDocPart(), $this->getDocPartId(), $width, $style); + $cell = new Cell($width, $style); + $cell->setDocPart($this->getDocPart(), $this->getDocPartId()); $cell->setPhpWord($this->phpWord); $this->cells[] = $cell; + return $cell; } diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 04ff5aa2d2..8a2b474f91 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -26,6 +26,11 @@ */ class Section extends AbstractContainer { + /** + * @var string Container type + */ + protected $container = 'Section'; + /** * Section settings * @@ -55,7 +60,6 @@ class Section extends AbstractContainer */ public function __construct($sectionCount, $settings = null) { - $this->container = 'section'; $this->sectionId = $sectionCount; $this->setDocPart($this->container, $this->sectionId); $this->settings = new SectionSettings(); @@ -98,15 +102,7 @@ public function getSettings() */ public function addTitle($text, $depth = 1) { - $title = new Title($text, $depth); - $title->setDocPart($this->getDocPart(), $this->getDocPartId()); - if ($this->phpWord instanceof PhpWord) { - $bookmarkId = $this->phpWord->addTitle($title); - $title->setBookmarkId($bookmarkId); - } - $this->addElement($title); - - return $title; + return $this->addElement('Title', $text, $depth); } /** @@ -114,7 +110,7 @@ public function addTitle($text, $depth = 1) */ public function addPageBreak() { - $this->addElement(new PageBreak()); + return $this->addElement('PageBreak'); } /** @@ -128,10 +124,7 @@ public function addPageBreak() */ public function addTOC($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9) { - $toc = new TOC($fontStyle, $tocStyle, $minDepth, $maxDepth); - $this->addElement($toc); - - return $toc; + return $this->addElement('TOC', $fontStyle, $tocStyle, $minDepth, $maxDepth); } /** diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index e87c591fe1..ee45e36f60 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -41,7 +41,7 @@ class Table extends AbstractElement /** * Table width * - * @var integer + * @var int */ private $width = null; @@ -59,28 +59,32 @@ public function __construct($style = null) /** * Add a row * - * @param integer $height + * @param int $height * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Row */ public function addRow($height = null, $style = null) { - $row = new Row($this->getDocPart(), $this->getDocPartId(), $height, $style); + $row = new Row($height, $style); + $row->setDocPart($this->getDocPart(), $this->getDocPartId()); $row->setPhpWord($this->phpWord); $this->rows[] = $row; + return $row; } /** * Add a cell * - * @param integer $width + * @param int $width * @param mixed $style - * @return Cell + * @return \PhpOffice\PhpWord\Element\Cell */ public function addCell($width = null, $style = null) { $index = count($this->rows) - 1; $cell = $this->rows[$index]->addCell($width, $style); + return $cell; } @@ -107,7 +111,7 @@ public function getStyle() /** * Set table width * - * @param integer $width + * @param int $width */ public function setWidth($width) { @@ -117,7 +121,7 @@ public function setWidth($width) /** * Get table width * - * @return integer + * @return int */ public function getWidth() { @@ -127,7 +131,7 @@ public function getWidth() /** * Get column count * - * @return integer + * @return int */ public function countColumns() { diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index c3c83d8122..06c9518167 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -26,6 +26,11 @@ */ class TextBox extends AbstractContainer { + /** + * @var string Container type + */ + protected $container = 'TextBox'; + /** * TextBox style * @@ -40,7 +45,6 @@ class TextBox extends AbstractContainer */ public function __construct($style = null) { - $this->container = 'textbox'; $this->style = $this->setStyle(new TextBoxStyle(), $style); } diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index 6c8aa010db..7583710404 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -24,6 +24,11 @@ */ class TextRun extends AbstractContainer { + /** + * @var string Container type + */ + protected $container = 'TextRun'; + /** * Paragraph style * @@ -38,7 +43,6 @@ class TextRun extends AbstractContainer */ public function __construct($paragraphStyle = null) { - $this->container = 'textrun'; $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); } diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 481f061bc5..3a1b304968 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -39,13 +39,6 @@ class Title extends AbstractElement */ private $depth = 1; - /** - * Title Bookmark ID - * - * @var int - */ - private $bookmarkId = 1; - /** * Name of the heading style, e.g. 'Heading1' * @@ -56,7 +49,7 @@ class Title extends AbstractElement /** * Title anchor * - * @var int + * @var string * @deprecated 0.10.0 */ private $anchor; @@ -79,26 +72,6 @@ public function __construct($text, $depth = 1) return $this; } - /** - * Set Bookmark ID - * - * @param int $bookmarkId - */ - public function setBookmarkId($bookmarkId) - { - $this->bookmarkId = $bookmarkId; - } - - /** - * Get Anchor - * - * @return int - */ - public function getBookmarkId() - { - return $this->bookmarkId; - } - /** * Get Title Text content * @@ -132,7 +105,7 @@ public function getStyle() /** * Set Anchor * - * @param int $anchor + * @param string $anchor * @deprecated 0.10.0 * @codeCoverageIgnore */ @@ -144,12 +117,36 @@ public function setAnchor($anchor) /** * Get Anchor * - * @return int + * @return string * @deprecated 0.10.0 * @codeCoverageIgnore */ public function getAnchor() { - return '_Toc' . (252634154 + $this->bookmarkId); + return '_Toc' . (252634154 + $this->getRelationId()); + } + + /** + * Set Bookmark ID + * + * @param int $value + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function setBookmarkId($value) + { + $this->setRelationId($value); + } + + /** + * Get bookmark ID + * + * @return int + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function getBookmarkId() + { + return $this->getRelationId(); } } diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 1df56e6836..c56e418b9c 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -207,6 +207,7 @@ protected static function parseNode( case 'li': $cNodes = $node->childNodes; if (count($cNodes) > 0) { + $text = ''; foreach ($cNodes as $cNode) { if ($cNode->nodeName == '#text') { $text = $cNode->nodeValue; diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php index c55a79212a..c4bbc2f83b 100644 --- a/src/PhpWord/Writer/HTML/Element/Container.php +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -32,7 +32,7 @@ class Container extends AbstractElement public function write() { $container = $this->element; - if (!$this->element instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { return; } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index eb96946c6a..148c8dbc96 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -47,18 +47,18 @@ public function write() // Name $font = $style->getName(); - $xmlWriter->writeAttributeIf($font, 'style:font-name', $font); - $xmlWriter->writeAttributeIf($font, 'style:font-name-complex', $font); + $xmlWriter->writeAttributeIf($font != '', 'style:font-name', $font); + $xmlWriter->writeAttributeIf($font != '', 'style:font-name-complex', $font); $size = $style->getSize(); // Size - $xmlWriter->writeAttributeIf($size, 'fo:font-size', $size . 'pt'); - $xmlWriter->writeAttributeIf($size, 'style:font-size-asian', $size . 'pt'); - $xmlWriter->writeAttributeIf($size, 'style:font-size-complex', $size . 'pt'); + $xmlWriter->writeAttributeIf(is_numeric($size), 'fo:font-size', $size . 'pt'); + $xmlWriter->writeAttributeIf(is_numeric($size), 'style:font-size-asian', $size . 'pt'); + $xmlWriter->writeAttributeIf(is_numeric($size), 'style:font-size-complex', $size . 'pt'); // Color $color = $style->getColor(); - $xmlWriter->writeAttributeIf($color, 'fo:color', '#' . $color); + $xmlWriter->writeAttributeIf($color != '', 'fo:color', '#' . $color); // Bold & italic $xmlWriter->writeAttributeIf($style->isBold(), 'fo:font-weight', 'bold'); diff --git a/src/PhpWord/Writer/RTF/Element/Container.php b/src/PhpWord/Writer/RTF/Element/Container.php index 4ce4334c28..67caba1d67 100644 --- a/src/PhpWord/Writer/RTF/Element/Container.php +++ b/src/PhpWord/Writer/RTF/Element/Container.php @@ -32,7 +32,7 @@ class Container extends \PhpOffice\PhpWord\Writer\HTML\Element\Container public function write() { $container = $this->element; - if (!$this->element instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { return; } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 1b4284d28d..c41199f828 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -51,7 +51,6 @@ public function write() */ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) { - $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); $style = $element->getStyle(); $styleWriter = new ImageStyleWriter($xmlWriter, $style); diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 98486b0126..88dd0dbd57 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; +use PhpOffice\PhpWord\Element\TOC as TOCElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; @@ -44,7 +46,7 @@ public function write() $writeFieldMark = true; foreach ($titles as $title) { - $this->writeTitle($title, $writeFieldMark); + $this->writeTitle($xmlWriter, $element, $title, $writeFieldMark); if ($writeFieldMark) { $writeFieldMark = false; } @@ -65,23 +67,20 @@ public function write() * @param \PhpOffice\PhpWord\Element\Title $title * @param bool $writeFieldMark */ - private function writeTitle($title, $writeFieldMark) + private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $writeFieldMark) { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); - $tocStyle = $element->getStyleTOC(); $fontStyle = $element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; - $anchor = '_Toc' . ($title->getBookmarkId() + 252634154); + $anchor = '_Toc' . ($title->getRelationId() + 252634154); $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); $xmlWriter->startElement('w:p'); // Write style and field mark - $this->writeStyle($indent); + $this->writeStyle($xmlWriter, $element, $indent); if ($writeFieldMark) { - $this->writeFieldMark(); + $this->writeFieldMark($xmlWriter, $element); } // Hyperlink @@ -133,11 +132,8 @@ private function writeTitle($title, $writeFieldMark) * * @param int $indent */ - private function writeStyle($indent) + private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent) { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); - $tocStyle = $element->getStyleTOC(); $fontStyle = $element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; @@ -178,11 +174,8 @@ private function writeStyle($indent) /** * Write TOC Field */ - private function writeFieldMark() + private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element) { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); - $minDepth = $element->getMinDepth(); $maxDepth = $element->getMaxDepth(); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 703188ef82..6f2bd31470 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -37,8 +37,8 @@ public function write() return; } - $bookmarkId = $element->getBookmarkId(); - $anchor = '_Toc' . ($bookmarkId + 252634154); + $rId = $element->getRelationId(); + $anchor = '_Toc' . ($rId + 252634154); $style = $element->getStyle(); $text = htmlspecialchars($element->getText()); @@ -61,7 +61,7 @@ public function write() $xmlWriter->endElement(); $xmlWriter->startElement('w:bookmarkStart'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->writeAttribute('w:id', $rId); $xmlWriter->writeAttribute('w:name', $anchor); $xmlWriter->endElement(); @@ -72,7 +72,7 @@ public function write() $xmlWriter->endElement(); $xmlWriter->startElement('w:bookmarkEnd'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); + $xmlWriter->writeAttribute('w:id', $rId); $xmlWriter->endElement(); $xmlWriter->endElement(); diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index 466188f6b9..af924bc8b0 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -31,8 +31,7 @@ class CellTest extends \PHPUnit_Framework_TestCase */ public function testConstruct() { - $iVal = rand(1, 1000); - $oCell = new Cell('section', $iVal); + $oCell = new Cell(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $oCell); $this->assertEquals($oCell->getWidth(), null); @@ -43,8 +42,7 @@ public function testConstruct() */ public function testConstructWithStyleArray() { - $iVal = rand(1, 1000); - $oCell = new Cell('section', $iVal, null, array('valign' => 'center')); + $oCell = new Cell(null, array('valign' => 'center')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Cell', $oCell->getStyle()); $this->assertEquals($oCell->getWidth(), null); @@ -55,7 +53,7 @@ public function testConstructWithStyleArray() */ public function testAddText() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addText('text'); $this->assertCount(1, $oCell->getElements()); @@ -67,7 +65,7 @@ public function testAddText() */ public function testAddTextNotUTF8() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addText(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); @@ -80,7 +78,7 @@ public function testAddTextNotUTF8() */ public function testAddLink() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addLink(utf8_decode('ééé'), utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); @@ -92,7 +90,7 @@ public function testAddLink() */ public function testAddTextBreak() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $oCell->addTextBreak(); $this->assertCount(1, $oCell->getElements()); @@ -103,7 +101,7 @@ public function testAddTextBreak() */ public function testAddListItem() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addListItem('text'); $this->assertCount(1, $oCell->getElements()); @@ -116,7 +114,7 @@ public function testAddListItem() */ public function testAddListItemNotUTF8() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addListItem(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); @@ -130,7 +128,7 @@ public function testAddListItemNotUTF8() public function testAddImageSection() { $src = __DIR__ . "/../_files/images/earth.jpg"; - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addImage($src); $this->assertCount(1, $oCell->getElements()); @@ -168,35 +166,7 @@ public function testAddImageFooter() */ public function testAddImageSectionByUrl() { - $oCell = new Cell('section', 1); - $element = $oCell->addImage( - 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' - ); - - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Image', $element); - } - - /** - * Add image header by URL - */ - public function testAddImageHeaderByUrl() - { - $oCell = new Cell('header', 1); - $element = $oCell->addImage( - 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' - ); - - $this->assertCount(1, $oCell->getElements()); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Image', $element); - } - - /** - * Add image footer by URL - */ - public function testAddImageFooterByUrl() - { - $oCell = new Cell('footer', 1); + $oCell = new Cell(); $element = $oCell->addImage( 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' ); @@ -211,7 +181,7 @@ public function testAddImageFooterByUrl() public function testAddObjectXLS() { $src = __DIR__ . "/../_files/documents/sheet.xls"; - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addObject($src); $this->assertCount(1, $oCell->getElements()); @@ -226,7 +196,7 @@ public function testAddObjectXLS() public function testAddObjectException() { $src = __DIR__ . "/../_files/xsl/passthrough.xsl"; - $oCell = new Cell('section', 1); + $oCell = new Cell(); $oCell->addObject($src); } @@ -235,7 +205,8 @@ public function testAddObjectException() */ public function testAddPreserveText() { - $oCell = new Cell('header', 1); + $oCell = new Cell(); + $oCell->setDocPart('Header', 1); $element = $oCell->addPreserveText('text'); $this->assertCount(1, $oCell->getElements()); @@ -247,7 +218,8 @@ public function testAddPreserveText() */ public function testAddPreserveTextNotUTF8() { - $oCell = new Cell('header', 1); + $oCell = new Cell(); + $oCell->setDocPart('Header', 1); $element = $oCell->addPreserveText(utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); @@ -262,7 +234,8 @@ public function testAddPreserveTextNotUTF8() */ public function testAddPreserveTextException() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); + $oCell->setDocPart('Section', 1); $oCell->addPreserveText('text'); } @@ -271,7 +244,7 @@ public function testAddPreserveTextException() */ public function testCreateTextRun() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addTextRun(); $this->assertCount(1, $oCell->getElements()); @@ -283,7 +256,7 @@ public function testCreateTextRun() */ public function testAddCheckBox() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $element = $oCell->addCheckBox(utf8_decode('ééé'), utf8_decode('ééé')); $this->assertCount(1, $oCell->getElements()); @@ -295,7 +268,7 @@ public function testAddCheckBox() */ public function testGetElements() { - $oCell = new Cell('section', 1); + $oCell = new Cell(); $this->assertInternalType('array', $oCell->getElements()); } diff --git a/tests/PhpWord/Tests/Element/RowTest.php b/tests/PhpWord/Tests/Element/RowTest.php index b0de3910de..c377bb7cd2 100644 --- a/tests/PhpWord/Tests/Element/RowTest.php +++ b/tests/PhpWord/Tests/Element/RowTest.php @@ -32,8 +32,7 @@ class RowTest extends \PHPUnit_Framework_TestCase */ public function testConstruct() { - $iVal = rand(1, 1000); - $oRow = new Row('section', $iVal); + $oRow = new Row(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Row', $oRow); $this->assertEquals($oRow->getHeight(), null); @@ -48,15 +47,9 @@ public function testConstruct() public function testConstructWithParams() { $iVal = rand(1, 1000); - $iVal2 = rand(1, 1000); - $oRow = new Row( - 'section', - $iVal, - $iVal2, - array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF') - ); + $oRow = new Row($iVal, array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF')); - $this->assertEquals($oRow->getHeight(), $iVal2); + $this->assertEquals($oRow->getHeight(), $iVal); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle()); } @@ -65,7 +58,7 @@ public function testConstructWithParams() */ public function testAddCell() { - $oRow = new Row('section', 1); + $oRow = new Row(); $element = $oRow->addCell(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element); diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 5b54cce697..301d8becf8 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -57,6 +57,6 @@ public function testBookmarkID() $iVal = rand(1, 1000); $oTitle->setBookmarkId($iVal); - $this->assertEquals($oTitle->getBookmarkId(), $iVal); + $this->assertEquals($oTitle->getRelationId(), $iVal); } } From 55e715b5b1af53976ec02a7d0e93b37535eb82fa Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 12 May 2014 14:24:13 +0700 Subject: [PATCH 078/167] Add variable type hints --- src/PhpWord/Element/AbstractContainer.php | 11 ++++----- src/PhpWord/Writer/HTML/Element/Footnote.php | 6 +++-- src/PhpWord/Writer/HTML/Element/Image.php | 4 +++- src/PhpWord/Writer/HTML/Element/Text.php | 14 +++++++---- src/PhpWord/Writer/HTML/Style/Image.php | 6 +++-- src/PhpWord/Writer/RTF/Element/Text.php | 24 ++++++++++++------- src/PhpWord/Writer/RTF/Element/TextBreak.php | 4 +++- src/PhpWord/Writer/RTF/Style/Font.php | 8 +++++-- src/PhpWord/Writer/Word2007/Element/Text.php | 6 +++-- .../Writer/Word2007/Part/ContentTypes.php | 4 +++- .../Writer/Word2007/Part/Footnotes.php | 5 ++-- .../Writer/Word2007/Part/RelsDocument.php | 5 +++- src/PhpWord/Writer/Word2007/Part/Settings.php | 2 ++ 13 files changed, 67 insertions(+), 32 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 39193031c1..6caa00561c 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -35,7 +35,7 @@ abstract class AbstractContainer extends AbstractElement protected $elements = array(); /** - * Container type section|header|footer|footnote|endnote|cell|textrun|textbox + * Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun * * @var string */ @@ -63,9 +63,7 @@ protected function addElement($elementName) } // Create element - if ($argsCount == 1) { // Page Break - $element = new $elementClass(); - } elseif ($argsCount == 2) { // TextRun, TextBox, Table, Footnote, Endnote + if ($argsCount == 2) { // TextRun, TextBox, Table, Footnote, Endnote $element = new $elementClass($args[1]); } elseif ($argsCount == 3) { // Object, TextBreak, Title $element = new $elementClass($args[1], $args[2]); @@ -75,11 +73,13 @@ protected function addElement($elementName) $element = new $elementClass($args[1], $args[2], $args[3], $args[4]); } elseif ($argsCount == 6) { // ListItem $element = new $elementClass($args[1], $args[2], $args[3], $args[4], $args[5]); + } else { // Page Break + $element = new $elementClass(); } // Set relation Id for media collection + $mediaContainer = $this->getMediaContainer(); if (in_array($elementName, array('Link', 'Image', 'Object'))) { - $mediaContainer = $this->getMediaContainer(); if ($elementName == 'Image') { $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $element); } else { @@ -228,7 +228,6 @@ public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, * * @param mixed $style * @return \PhpOffice\PhpWord\Element\Table - * @todo Merge with the same function on Footer */ public function addTable($style = null) { diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index 30398b17fb..ba5ced560d 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -41,12 +41,14 @@ public function write() if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { return; } + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; - $noteId = count($this->parentWriter->getNotes()) + 1; + $noteId = count($parentWriter->getNotes()) + 1; $noteMark = $this->noteType . '-' . $this->element->getRelationId(); $content = "{$noteId}"; - $this->parentWriter->addNote($noteId, $noteMark); + $parentWriter->addNote($noteId, $noteMark); return $content; } diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 5c2edbb216..1d07acd745 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -37,9 +37,11 @@ public function write() if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { return; } + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; $content = ''; - if (!$this->parentWriter->isPdf()) { + if (!$parentWriter->isPdf()) { $imageData = $this->getBase64ImageData($this->element); if (!is_null($imageData)) { $styleWriter = new ImageStyleWriter($this->element->getStyle()); diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 883a8cd33e..8ace129ca4 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -64,12 +64,14 @@ class Text extends AbstractElement */ public function write() { + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $element = $this->element; $this->getFontStyle(); $content = ''; $content .= $this->writeOpening(); $content .= $this->openingTags; - $content .= htmlspecialchars($this->element->getText()); + $content .= htmlspecialchars($element->getText()); $content .= $this->closingTags; $content .= $this->closingText; $content .= $this->writeClosing(); @@ -140,12 +142,14 @@ protected function writeClosing() */ private function getParagraphStyle() { + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $element = $this->element; $style = ''; - if (method_exists($this->element, 'getParagraphStyle')) { + if (method_exists($element, 'getParagraphStyle')) { return $style; } - $paragraphStyle = $this->element->getParagraphStyle(); + $paragraphStyle = $element->getParagraphStyle(); $pStyleIsObject = ($paragraphStyle instanceof Paragraph); if ($pStyleIsObject) { $styleWriter = new ParagraphStyleWriter($paragraphStyle); @@ -164,8 +168,10 @@ private function getParagraphStyle() */ private function getFontStyle() { + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $element = $this->element; $style = ''; - $fontStyle = $this->element->getFontStyle(); + $fontStyle = $element->getFontStyle(); $fStyleIsObject = ($fontStyle instanceof Font); if ($fStyleIsObject) { $styleWriter = new FontStyleWriter($fontStyle); diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index fcf18395d1..db6ac57b3b 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -37,8 +37,10 @@ public function write() } $css = array(); - $css['width'] = $this->getValueIf($style->getWidth(), $style->getWidth() . 'px'); - $css['height'] = $this->getValueIf($style->getHeight(), $style->getHeight() . 'px'); + $width = $style->getWidth(); + $height = $style->getHeight(); + $css['width'] = $this->getValueIf(is_numeric($width), $width . 'px'); + $css['height'] = $this->getValueIf(is_numeric($height), $height . 'px'); return $this->assembleCss($css); } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 701a5be112..27172df3f8 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -39,12 +39,15 @@ public function write() return; } + /** @var \PhpOffice\PhpWord\Style\Font $fontStyle Scrutinizer type hint */ $fontStyle = $this->getFontStyle($this->element); + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; $content = ''; $content .= $this->writeParagraphStyle($this->element); $content .= $this->writeFontStyleBegin($fontStyle); - if ($this->parentWriter->getLastParagraphStyle() != '' || $fontStyle) { + if ($parentWriter->getLastParagraphStyle() != '' || $fontStyle) { $content .= ' '; } $content .= $this->element->getText(); @@ -64,6 +67,8 @@ public function write() */ private function writeParagraphStyle(TextElement $element) { + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; $content = ''; // Get paragraph style @@ -74,15 +79,15 @@ private function writeParagraphStyle(TextElement $element) // Write style when applicable if ($paragraphStyle && !$this->withoutP) { - if ($this->parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { + if ($parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { $styleWriter = new ParagraphStyleWriter($paragraphStyle); $content = $styleWriter->write(); - $this->parentWriter->setLastParagraphStyle($element->getParagraphStyle()); + $parentWriter->setLastParagraphStyle($element->getParagraphStyle()); } else { - $this->parentWriter->setLastParagraphStyle(); + $parentWriter->setLastParagraphStyle(); } } else { - $this->parentWriter->setLastParagraphStyle(); + $parentWriter->setLastParagraphStyle(); } return $content; @@ -91,7 +96,7 @@ private function writeParagraphStyle(TextElement $element) /** * Write font style beginning * - * @param \PhpOffice\PhpWord\Style\Font $style + * @param mixed $style * @return string */ private function writeFontStyleBegin($style) @@ -100,16 +105,19 @@ private function writeFontStyleBegin($style) return ''; } + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; + // Create style writer and set color/name index $styleWriter = new FontStyleWriter($style); if ($style->getColor() != null) { - $colorIndex = array_search($style->getColor(), $this->parentWriter->getColorTable()); + $colorIndex = array_search($style->getColor(), $parentWriter->getColorTable()); if ($colorIndex !== false) { $styleWriter->setColorIndex($colorIndex + 1); } } if ($style->getName() != null) { - $fontIndex = array_search($style->getName(), $this->parentWriter->getFontTable()); + $fontIndex = array_search($style->getName(), $parentWriter->getFontTable()); if ($fontIndex !== false) { $styleWriter->setNameIndex($fontIndex + 1); } diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index 760f34e823..ff836a88a6 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -31,7 +31,9 @@ class TextBreak extends AbstractElement */ public function write() { - $this->parentWriter->setLastParagraphStyle(); + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; + $parentWriter->setLastParagraphStyle(); return '\par' . PHP_EOL; } diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index 5c14eb3a9a..49c9889c3b 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -53,7 +53,9 @@ public function write() $content .= '\f' . $this->nameIndex; $content .= $this->getValueIf($style->isBold(), '\b'); $content .= $this->getValueIf($style->isItalic(), '\i'); - $content .= $this->getValueIf($style->getSize(), '\fs' . ($style->getSize() * 2)); + + $size = $style->getSize(); + $content .= $this->getValueIf(is_numeric($size), '\fs' . ($size * 2)); return $content; } @@ -75,7 +77,9 @@ public function writeEnd() $content .= '\f0'; $content .= $this->getValueIf($style->isBold(), '\b0'); $content .= $this->getValueIf($style->isItalic(), '\i0'); - $content .= $this->getValueIf($style->getSize(), '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2)); + + $size = $style->getSize(); + $content .= $this->getValueIf(is_numeric($size), '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2)); return $content; } diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 1385e6e6c7..e06bde6b28 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -92,8 +92,9 @@ protected function writeEndingWP() protected function writeParagraphStyle() { $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $element = $this->getElement(); $paragraphStyle = $element->getParagraphStyle(); $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); $styleWriter->setIsInline(true); @@ -106,8 +107,9 @@ protected function writeParagraphStyle() protected function writeFontStyle() { $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $element = $this->getElement(); $fontStyle = $element->getFontStyle(); $styleWriter = new FontStyleWriter($xmlWriter, $fontStyle); $styleWriter->setIsInline(true); diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 3af62a44c5..417df64dce 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -32,7 +32,9 @@ class ContentTypes extends AbstractPart */ public function write() { - $contentTypes = $this->getParentWriter()->getContentTypes(); + /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */ + $parentWriter = $this->getParentWriter(); + $contentTypes = $parentWriter->getContentTypes(); $openXMLPrefix = 'application/vnd.openxmlformats-'; $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 1eeabc9c4d..d7a1caaa24 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -106,8 +106,9 @@ public function write() $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // $this->elementNode - // Content - foreach ($this->elements as $element) { + /** @var array $elements Scrutinizer type hint */ + $elements = $this->elements; + foreach ($elements as $element) { if ($element instanceof Footnote) { $this->writeNote($xmlWriter, $element); } diff --git a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php index e0773a4a8c..2a58421ccb 100644 --- a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php +++ b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php @@ -40,7 +40,10 @@ public function write() 'fontTable.xml' => 'officeDocument/2006/relationships/fontTable', ); $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, $xmlRels, $this->getParentWriter()->getRelationships()); + + /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */ + $parentWriter = $this->getParentWriter(); + $this->writeRels($xmlWriter, $xmlRels, $parentWriter->getRelationships()); return $xmlWriter->getData(); } diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index 862e419e0a..c296581f2e 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -126,6 +126,8 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) $xmlWriter->writeElement($settingKey); } else { $xmlWriter->startElement($settingKey); + + /** @var array $settingValue Scrutinizer type hint */ foreach ($settingValue as $childKey => $childValue) { if ($childKey == '@attributes') { foreach ($childValue as $key => $val) { From e589961e68a7f6e9cb666a87fbce4c545be80431 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 12 May 2014 22:55:06 +0700 Subject: [PATCH 079/167] #158: Convert UTF8 text to Unicode before writing RTF (support UTF8 in RTF) --- CHANGELOG.md | 3 +- composer.lock | 2 +- src/PhpWord/Shared/String.php | 48 +++++++++++++++++++ src/PhpWord/Style/Paragraph.php | 19 ++++++-- src/PhpWord/Writer/RTF/Element/Container.php | 2 - src/PhpWord/Writer/RTF/Element/Text.php | 23 +++++---- src/PhpWord/Writer/RTF/Element/TextRun.php | 4 +- src/PhpWord/Writer/RTF/Element/Title.php | 4 +- src/PhpWord/Writer/RTF/Style/Font.php | 21 ++++++-- src/PhpWord/Writer/RTF/Style/Paragraph.php | 22 ++++++--- .../Word2007/Element/AbstractElement.php | 14 +++++- .../Writer/Word2007/Element/CheckBox.php | 13 ++--- .../Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- .../Writer/Word2007/Element/PreserveText.php | 9 +--- src/PhpWord/Writer/Word2007/Element/Text.php | 10 ++-- .../Writer/Word2007/Element/TextBreak.php | 2 +- .../Writer/Word2007/Element/TextRun.php | 2 +- src/PhpWord/Writer/Word2007/Element/Title.php | 7 +-- 19 files changed, 144 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af3ca78674..556292573b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release changed PHPWord license from LGPL 2.1 to LGPL 3. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new relative and absolute positioning for image; new `TextBox` and `ListItemRun` element; refactorings of writer classes into parts, elements, and styles; and ability to add elements to PHPWord object via HTML. ### Features @@ -15,6 +15,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3. - HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 - ListItemRun: New element that can add a list item with inline formatting like a textrun - @basjan GH-235 - Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 +- RTF: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 ### Bugfixes diff --git a/composer.lock b/composer.lock index 6d63264a83..9bc868ac8e 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "6daefa91649add98af3850b0a3f13415", + "hash": "77631436badcf4f49d673498ab6f1916", "packages": [ ], diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 6ebcc65d01..259e904c1f 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -85,6 +85,54 @@ public static function toUTF8($value = '') return $value; } + /** + * Returns unicode from UTF8 text + * + * @param string $text UTF8 text + * @return string Unicode text + * @since 0.11.0 + * @link http://www.randomchaos.com/documents/?source=php_and_unicode + */ + public static function toUnicode($text) + { + $unicode = array(); + $values = array(); + $lookingFor = 1; + + // Gets unicode for each character + for ($i = 0; $i < strlen($text); $i++) { + $thisValue = ord($text[$i]); + if ($thisValue < 128) { + $unicode[] = $thisValue; + } else { + if (count($values) == 0) { + $lookingFor = $thisValue < 224 ? 2 : 3; + } + $values[] = $thisValue; + if (count($values) == $lookingFor) { + if ($lookingFor == 3) { + $number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64); + } else { + $number = (($values[0] % 32) * 64) + ($values[1] % 64); + } + $unicode[] = $number; + $values = array(); + $lookingFor = 1; + } + } + } + + // Converts text with utf8 characters into rtf utf8 entites preserving ascii + $entities = ''; + foreach ($unicode as $value) { + if ($value != 65279) { + $entities .= $value > 127 ? '\uc0{\u' . $value . '}' : chr($value); + } + } + + return $entities; + } + /** * Return name without underscore for < 0.10.0 variable name compatibility * diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 79a12242a0..9867afe357 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -25,8 +25,20 @@ */ class Paragraph extends AbstractStyle { + /** + * @const int One line height equals 240 twip + */ const LINE_HEIGHT = 240; + /** + * @const string Alignment http://www.schemacentral.com/sc/ooxml/t-w_ST_Jc.html + */ + const ALIGN_LEFT = 'left'; // Align left + const ALIGN_RIGHT = 'right'; // Align right + const ALIGN_CENTER = 'center'; // Align center + const ALIGN_BOTH = 'both'; // Align both + const ALIGN_JUSTIFY = 'justify'; // Alias for align both + /** * Aliases * @@ -147,10 +159,11 @@ public function getAlign() */ public function setAlign($value = null) { - if (strtolower($value) == 'justify') { - $value = 'both'; + if (strtolower($value) == self::ALIGN_JUSTIFY) { + $value = self::ALIGN_BOTH; } - $this->align = $value; + $enum = array(self::ALIGN_LEFT, self::ALIGN_RIGHT, self::ALIGN_CENTER, self::ALIGN_BOTH, self::ALIGN_JUSTIFY); + $this->align = $this->setEnumVal($value, $enum, $this->align); return $this; } diff --git a/src/PhpWord/Writer/RTF/Element/Container.php b/src/PhpWord/Writer/RTF/Element/Container.php index 67caba1d67..f4b5f2acfd 100644 --- a/src/PhpWord/Writer/RTF/Element/Container.php +++ b/src/PhpWord/Writer/RTF/Element/Container.php @@ -44,9 +44,7 @@ public function write() $writerClass = str_replace('\\Element', '\\Writer\\RTF\\Element', get_class($element)); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $element, $withoutP); - $content .= '{'; $content .= $writer->write(); - $content .= '}' . PHP_EOL; } } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 27172df3f8..51b2494191 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -18,6 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\Element\Text as TextElement; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; @@ -46,12 +47,17 @@ public function write() $content = ''; $content .= $this->writeParagraphStyle($this->element); - $content .= $this->writeFontStyleBegin($fontStyle); - if ($parentWriter->getLastParagraphStyle() != '' || $fontStyle) { + $content .= '{'; + $content .= $this->writeFontStyle($fontStyle); + if ($fontStyle || $parentWriter->getLastParagraphStyle() != '') { $content .= ' '; } - $content .= $this->element->getText(); - $content .= $this->writeFontStyleEnd($fontStyle); + $content .= String::toUnicode($this->element->getText()); + $content .= '}'; + + // Remarked to test using closure {} to avoid closing tags + // @since 0.11.0 + // $content .= $this->writeFontStyleClosing($fontStyle); if (!$this->withoutP) { $content .= '\par' . PHP_EOL; @@ -80,9 +86,10 @@ private function writeParagraphStyle(TextElement $element) // Write style when applicable if ($paragraphStyle && !$this->withoutP) { if ($parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { + $parentWriter->setLastParagraphStyle($element->getParagraphStyle()); + $styleWriter = new ParagraphStyleWriter($paragraphStyle); $content = $styleWriter->write(); - $parentWriter->setLastParagraphStyle($element->getParagraphStyle()); } else { $parentWriter->setLastParagraphStyle(); } @@ -99,7 +106,7 @@ private function writeParagraphStyle(TextElement $element) * @param mixed $style * @return string */ - private function writeFontStyleBegin($style) + private function writeFontStyle($style) { if (!$style instanceof FontStyle) { return ''; @@ -135,14 +142,14 @@ private function writeFontStyleBegin($style) * @param \PhpOffice\PhpWord\Style\Font $style * @return string */ - private function writeFontStyleEnd($style) + private function writeFontStyleClosing($style) { if (!$style instanceof FontStyle) { return ''; } $styleWriter = new FontStyleWriter($style); - $content = $styleWriter->writeEnd(); + $content = $styleWriter->writeClosing(); return $content; } diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 174aebd97f..8d7324a303 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -35,10 +35,10 @@ public function write() { $content = ''; - $content .= '\pard\nowidctlpar' . PHP_EOL; + $content .= '{\pard\nowidctlpar'; $writer = new Container($this->parentWriter, $this->element); $content .= $writer->write(); - $content .= '\par' . PHP_EOL; + $content .= '\par}' . PHP_EOL; return $content; } diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index d78bb6f4e3..2be72ff8c8 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -37,8 +37,8 @@ public function write() $content = ''; - $content .= '\pard\nowidctlpar' . PHP_EOL; - $content .= $this->element->getText(); + $content .= '\pard\nowidctlpar'; + $content .= String::toUnicode($this->element->getText()); $content .= '\par' . PHP_EOL; return $content; diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index 49c9889c3b..c20558db59 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -18,6 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Style\Font as FontStyle; /** * RTF font style writer @@ -51,12 +52,17 @@ public function write() $content = ''; $content .= '\cf' . $this->colorIndex; $content .= '\f' . $this->nameIndex; - $content .= $this->getValueIf($style->isBold(), '\b'); - $content .= $this->getValueIf($style->isItalic(), '\i'); $size = $style->getSize(); $content .= $this->getValueIf(is_numeric($size), '\fs' . ($size * 2)); + $content .= $this->getValueIf($style->isBold(), '\b'); + $content .= $this->getValueIf($style->isItalic(), '\i'); + $content .= $this->getValueIf($style->getUnderline() != FontStyle::UNDERLINE_NONE, '\ul'); + $content .= $this->getValueIf($style->isStrikethrough(), '\strike'); + $content .= $this->getValueIf($style->isSuperScript(), '\super'); + $content .= $this->getValueIf($style->isSubScript(), '\sub'); + return $content; } @@ -65,7 +71,7 @@ public function write() * * @return string */ - public function writeEnd() + public function writeClosing() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { @@ -75,12 +81,17 @@ public function writeEnd() $content = ''; $content .= '\cf0'; $content .= '\f0'; - $content .= $this->getValueIf($style->isBold(), '\b0'); - $content .= $this->getValueIf($style->isItalic(), '\i0'); $size = $style->getSize(); $content .= $this->getValueIf(is_numeric($size), '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2)); + $content .= $this->getValueIf($style->isBold(), '\b0'); + $content .= $this->getValueIf($style->isItalic(), '\i0'); + $content .= $this->getValueIf($style->getUnderline() != FontStyle::UNDERLINE_NONE, '\ul0'); + $content .= $this->getValueIf($style->isStrikethrough(), '\strike0'); + $content .= $this->getValueIf($style->isSuperScript(), '\super0'); + $content .= $this->getValueIf($style->isSubScript(), '\sub0'); + return $content; } diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index 512e577497..8abdf2fb0c 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; +use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; + /** * RTF paragraph style writer * @@ -36,15 +38,23 @@ public function write() return; } - $content = '\pard\nowidctlpar'; + $alignments = array( + ParagraphStyle::ALIGN_LEFT => '\ql', + ParagraphStyle::ALIGN_RIGHT => '\qr', + ParagraphStyle::ALIGN_CENTER => '\qc', + ParagraphStyle::ALIGN_BOTH => '\qj', + ); - // Alignment $align = $style->getAlign(); - $content .= $this->getValueIf(!is_null($align) && $align == 'center', '\qc'); - - // Spacing $spaceAfter = $style->getSpaceAfter(); - $content .= $this->getValueIf(!is_null($spaceAfter), '\sa' . $spaceAfter); + $spaceBefore = $style->getSpaceBefore(); + + $content = '\pard\nowidctlpar'; + if (isset($alignments[$align])) { + $content .= $alignments[$align]; + } + $content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore); + $content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter); return $content; } diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 4b38d01f28..bbb2c83e14 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\XMLWriter; /** @@ -77,7 +78,7 @@ protected function getXmlWriter() } /** - * Get Element + * Get element * * @return \PhpOffice\PhpWord\Element\AbstractElement */ @@ -89,4 +90,15 @@ protected function getElement() throw new Exception('No element assigned.'); } } + + /** + * Convert text to valid format + * + * @param string $text + * @return string + */ + protected function getText($text) + { + return String::controlCharacterPHP2OOXML(htmlspecialchars($text)); + } } diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 1d7811cd28..ea13b8f943 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\String; - /** * CheckBox element writer * @@ -37,11 +35,6 @@ public function write() return; } - $name = htmlspecialchars($element->getName()); - $name = String::controlCharacterPHP2OOXML($name); - $text = htmlspecialchars($element->getText()); - $text = String::controlCharacterPHP2OOXML($text); - $this->writeOpeningWP(); $xmlWriter->startElement('w:r'); @@ -49,7 +42,7 @@ public function write() $xmlWriter->writeAttribute('w:fldCharType', 'begin'); $xmlWriter->startElement('w:ffData'); $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $name); + $xmlWriter->writeAttribute('w:val', $this->getText($element->getName())); $xmlWriter->endElement(); //w:name $xmlWriter->writeAttribute('w:enabled', ''); $xmlWriter->startElement('w:calcOnExit'); @@ -88,10 +81,10 @@ public function write() $xmlWriter->startElement('w:t'); $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); + $xmlWriter->writeRaw($this->getText($element->getText())); $xmlWriter->endElement(); // w:t $xmlWriter->endElement(); // w:r - $this->writeEndingWP(); + $this->writeClosingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index d33a0dc9d6..240a8a00a8 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -55,6 +55,6 @@ public function write() $xmlWriter->endElement(); // w:$referenceType $xmlWriter->endElement(); // w:r - $this->writeEndingWP(); + $this->writeClosingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 3b595b4cc2..ec531bacaa 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -53,6 +53,6 @@ public function write() $xmlWriter->endElement(); // w:r $xmlWriter->endElement(); // w:hyperlink - $this->writeEndingWP(); + $this->writeClosingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index 97693d9ba4..dd5d900874 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\String; - /** * PreserveText element writer * @@ -76,21 +74,18 @@ public function write() $xmlWriter->endElement(); $xmlWriter->endElement(); } else { - $text = htmlspecialchars($text); - $text = String::controlCharacterPHP2OOXML($text); - $xmlWriter->startElement('w:r'); $this->writeFontStyle(); $xmlWriter->startElement('w:t'); $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); + $xmlWriter->writeRaw($this->getText($text)); $xmlWriter->endElement(); $xmlWriter->endElement(); } } - $this->writeEndingWP(); + $this->writeClosingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index e06bde6b28..5cb33a289c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; @@ -39,9 +38,6 @@ public function write() return; } - $text = htmlspecialchars($element->getText()); - $text = String::controlCharacterPHP2OOXML($text); - $this->writeOpeningWP(); $xmlWriter->startElement('w:r'); @@ -50,11 +46,11 @@ public function write() $xmlWriter->startElement('w:t'); $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); + $xmlWriter->writeRaw($this->getText($element->getText())); $xmlWriter->endElement(); $xmlWriter->endElement(); // w:r - $this->writeEndingWP(); + $this->writeClosingWP(); } /** @@ -77,7 +73,7 @@ protected function writeOpeningWP() /** * Write ending */ - protected function writeEndingWP() + protected function writeClosingWP() { $xmlWriter = $this->getXmlWriter(); diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index c74cdc7a47..227b1b3046 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -42,7 +42,7 @@ public function write() $xmlWriter->startElement('w:pPr'); $this->writeFontStyle(); $xmlWriter->endElement(); // w:pPr - $this->writeEndingWP(); + $this->writeClosingWP(); } else { $xmlWriter->writeElement('w:p'); } diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index cb72ab18ae..330e297c13 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -37,6 +37,6 @@ public function write() $containerWriter = new Container($xmlWriter, $element); $containerWriter->write(); - $this->writeEndingWP(); + $this->writeClosingWP(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 6f2bd31470..298bd9b103 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\String; - /** * TextRun element writer * @@ -41,9 +39,6 @@ public function write() $anchor = '_Toc' . ($rId + 252634154); $style = $element->getStyle(); - $text = htmlspecialchars($element->getText()); - $text = String::controlCharacterPHP2OOXML($text); - $xmlWriter->startElement('w:p'); if (!empty($style)) { @@ -67,7 +62,7 @@ public function write() $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:t'); - $xmlWriter->writeRaw($text); + $xmlWriter->writeRaw($this->getText($element->getText())); $xmlWriter->endElement(); $xmlWriter->endElement(); From f8f98cccabf58e456730459762ffea12e46d43eb Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 13 May 2014 01:32:44 +0700 Subject: [PATCH 080/167] #237: Ability to define table width (in percent and twip) and position --- CHANGELOG.md | 1 + samples/Sample_09_Tables.php | 7 +- src/PhpWord/Shared/Html.php | 24 ++-- src/PhpWord/Style/Alignment.php | 78 +++++++++++ src/PhpWord/Style/Paragraph.php | 43 +++--- src/PhpWord/Style/Table.php | 129 +++++++++++++++--- src/PhpWord/Writer/RTF/Element/Text.php | 22 --- src/PhpWord/Writer/RTF/Element/Title.php | 2 + src/PhpWord/Writer/RTF/Style/Font.php | 29 ---- src/PhpWord/Writer/RTF/Style/Paragraph.php | 9 +- .../Writer/Word2007/Style/Alignment.php | 44 ++++++ .../Writer/Word2007/Style/Paragraph.php | 6 +- src/PhpWord/Writer/Word2007/Style/Table.php | 60 +++++--- .../Tests/Writer/Word2007/StyleTest.php | 2 +- 14 files changed, 323 insertions(+), 133 deletions(-) create mode 100644 src/PhpWord/Style/Alignment.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Alignment.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 556292573b..7bcc5a2f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - ListItemRun: New element that can add a list item with inline formatting like a textrun - @basjan GH-235 - Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 - RTF: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 +- Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 ### Bugfixes diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 5f77f8db85..6732e33600 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -87,11 +87,12 @@ // 4. Nested table $section->addTextBreak(2); -$section->addText('Nested table', $header); +$section->addText('Nested table in a centered and 50% width table.', $header); -$cell = $section->addTable()->addRow()->addCell(); +$table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'align' => 'center')); +$cell = $table->addRow()->addCell(); $cell->addText('This cell contains nested table.'); -$innerCell = $cell->addTable()->addRow()->addCell(); +$innerCell = $cell->addTable(array('align' => 'center'))->addRow()->addCell(); $innerCell->addText('Inside nested table'); // Save file diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index c56e418b9c..59795af7e7 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -27,9 +27,8 @@ class Html * * Note: $stylesheet parameter is removed to avoid PHPMD error for unused parameter * - * @param \PhpOffice\PhpWord\Element\AbstractElement $object Where the parts need to be added + * @param \PhpOffice\PhpWord\Element\AbstractContainer $object Where the parts need to be added * @param string $html the code to parse - * */ public static function addHtml($object, $html) { @@ -53,7 +52,6 @@ public static function addHtml($object, $html) * * @param \DOMNode $node Node to check on attributes and to compile a style array * @param array $style is supplied, the inline style attributes are added to the already existing style - * */ protected static function parseInlineStyle($node, $style = array()) { @@ -100,10 +98,9 @@ protected static function parseInlineStyle($node, $style = array()) * parse a node and add a corresponding element to the object * * @param \DOMNode $node node to parse - * @param \PhpOffice\PhpWord\Element\AbstractElement $object object to add an element corresponding with the node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $object object to add an element corresponding with the node * @param array $styles Array with all styles * @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems - * */ protected static function parseNode( $node, @@ -171,17 +168,26 @@ protected static function parseNode( case 'table': $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); $newobject = $object->addTable(); - // if ($attributes->getNamedItem('width') !== null)$newobject->setWidth($attributes->getNamedItem('width')->value); + // if ($attributes->getNamedItem('width') !== null) { + // $newobject->setWidth($attributes->getNamedItem('width')->value); + // } break; case 'tr': + /** @var \PhpOffice\PhpWord\Element\Table $object Scrutinizer type hint */ $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); $newobject = $object->addRow(); - // if ($attributes->getNamedItem('height') !== null)$newobject->setHeight($attributes->getNamedItem('height')->value); + // if ($attributes->getNamedItem('height') !== null) { + // $newobject->setHeight($attributes->getNamedItem('height')->value); + // } break; case 'td': + /** @var \PhpOffice\PhpWord\Element\Row $object Scrutinizer type hint */ $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); - // if ($attributes->getNamedItem('width') !== null)$newobject=$object->addCell($width=$attributes->getNamedItem('width')->value); - // else $newobject=$object->addCell(); + // if ($attributes->getNamedItem('width') !== null) { + // $newobject=$object->addCell($width=$attributes->getNamedItem('width')->value); + // } else { + // $newobject=$object->addCell(); + // } $newobject = $object->addCell(); break; case 'ul': diff --git a/src/PhpWord/Style/Alignment.php b/src/PhpWord/Style/Alignment.php new file mode 100644 index 0000000000..3beabe376a --- /dev/null +++ b/src/PhpWord/Style/Alignment.php @@ -0,0 +1,78 @@ +setStyleByArray($style); + } + + /** + * Get alignment + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set alignment + * + * @param string $value + * @return self + */ + public function setValue($value = null) + { + if (strtolower($value) == self::ALIGN_JUSTIFY) { + $value = self::ALIGN_BOTH; + } + $enum = array(self::ALIGN_LEFT, self::ALIGN_RIGHT, self::ALIGN_CENTER, self::ALIGN_BOTH, self::ALIGN_JUSTIFY); + $this->value = $this->setEnumVal($value, $enum, $this->value); + + return $this; + } +} diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 9867afe357..56609119e2 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -30,15 +30,6 @@ class Paragraph extends AbstractStyle */ const LINE_HEIGHT = 240; - /** - * @const string Alignment http://www.schemacentral.com/sc/ooxml/t-w_ST_Jc.html - */ - const ALIGN_LEFT = 'left'; // Align left - const ALIGN_RIGHT = 'right'; // Align right - const ALIGN_CENTER = 'center'; // Align center - const ALIGN_BOTH = 'both'; // Align both - const ALIGN_JUSTIFY = 'justify'; // Alias for align both - /** * Aliases * @@ -46,13 +37,6 @@ class Paragraph extends AbstractStyle */ protected $aliases = array('line-height' => 'lineHeight'); - /** - * Paragraph alignment - * - * @var string - */ - private $align; - /** * Text line height * @@ -123,6 +107,21 @@ class Paragraph extends AbstractStyle */ private $spacing; + /** + * Alignment + * + * @var \PhpOffice\PhpWord\Style\Alignment + */ + private $alignment; + + /** + * Create new instance + */ + public function __construct() + { + $this->alignment = new Alignment(); + } + /** * Set Style value * @@ -142,28 +141,24 @@ public function setStyleValue($key, $value) } /** - * Get Paragraph Alignment + * Get alignment * * @return string */ public function getAlign() { - return $this->align; + return $this->alignment->getValue(); } /** - * Set Paragraph Alignment + * Set alignment * * @param string $value * @return self */ public function setAlign($value = null) { - if (strtolower($value) == self::ALIGN_JUSTIFY) { - $value = self::ALIGN_BOTH; - } - $enum = array(self::ALIGN_LEFT, self::ALIGN_RIGHT, self::ALIGN_CENTER, self::ALIGN_BOTH, self::ALIGN_JUSTIFY); - $this->align = $this->setEnumVal($value, $enum, $this->align); + $this->alignment->setValue($value); return $this; } diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c9850e73c4..c077f499e6 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -22,6 +22,13 @@ */ class Table extends Border { + /** + * @const string Table width units http://www.schemacentral.com/sc/ooxml/t-w_ST_TblWidth.html + */ + const WIDTH_AUTO = 'auto'; // Automatically determined width + const WIDTH_PERCENT = 'pct'; // Width in fiftieths (1/50) of a percent (1% = 50 unit) + const WIDTH_TWIP = 'dxa'; // Width in twentieths (1/20) of a point (twip) + /** * Style for first row * @@ -92,15 +99,31 @@ class Table extends Border */ private $shading; + /** + * @var \PhpOffice\PhpWord\Style\Alignment Alignment + */ + private $alignment; + + /** + * @var int|float Width value + */ + private $width = 0; + + /** + * @var string Width unit + */ + private $unit = self::WIDTH_AUTO; + /** * Create new table style * - * @param mixed $styleTable - * @param mixed $styleFirstRow + * @param mixed $tableStyle + * @param mixed $firstRowStyle */ - public function __construct($styleTable = null, $styleFirstRow = null) + public function __construct($tableStyle = null, $firstRowStyle = null) { - if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { + $this->alignment = new Alignment(); + if (!is_null($firstRowStyle) && is_array($firstRowStyle)) { $this->firstRow = clone $this; unset($this->firstRow->firstRow); @@ -112,11 +135,11 @@ public function __construct($styleTable = null, $styleFirstRow = null) unset($this->firstRow->borderInsideVSize); unset($this->firstRow->borderInsideHColor); unset($this->firstRow->borderInsideHSize); - $this->firstRow->setStyleByArray($styleFirstRow); + $this->firstRow->setStyleByArray($firstRowStyle); } - if (!is_null($styleTable) && is_array($styleTable)) { - $this->setStyleByArray($styleTable); + if (!is_null($tableStyle) && is_array($tableStyle)) { + $this->setStyleByArray($tableStyle); } } @@ -408,6 +431,24 @@ public function getCellMargin() return array($this->cellMarginTop, $this->cellMarginLeft, $this->cellMarginRight, $this->cellMarginBottom); } + /** + * Has margins? + * + * @return bool + */ + public function hasMargins() + { + $hasMargins = false; + $margins = $this->getCellMargin(); + for ($i = 0; $i < count($margins); $i++) { + if (!is_null($margins[$i])) { + $hasMargins = true; + } + } + + return $hasMargins; + } + /** * Get shading * @@ -432,20 +473,72 @@ public function setShading($value = null) } /** - * Has margins? + * Get alignment * - * @return bool + * @return string */ - public function hasMargins() + public function getAlign() { - $hasMargins = false; - $margins = $this->getCellMargin(); - for ($i = 0; $i < count($margins); $i++) { - if (!is_null($margins[$i])) { - $hasMargins = true; - } - } + return $this->alignment->getValue(); + } - return $hasMargins; + /** + * Set alignment + * + * @param string $value + * @return self + */ + public function setAlign($value = null) + { + $this->alignment->setValue($value); + + return $this; + } + + /** + * Get width + * + * @return int|float + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set width + * + * @param int|float $value + * @return self + */ + public function setWidth($value = null) + { + $this->width = $this->setNumericVal($value, $this->width); + + return $this; + } + + /** + * Get width unit + * + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * Set width unit + * + * @param string $value + * @return self + */ + public function setUnit($value = null) + { + $enum = array(self::WIDTH_AUTO, self::WIDTH_PERCENT, self::WIDTH_TWIP); + $this->unit = $this->setEnumVal($value, $enum, $this->unit); + + return $this; } } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 51b2494191..ae97fd3a67 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -55,10 +55,6 @@ public function write() $content .= String::toUnicode($this->element->getText()); $content .= '}'; - // Remarked to test using closure {} to avoid closing tags - // @since 0.11.0 - // $content .= $this->writeFontStyleClosing($fontStyle); - if (!$this->withoutP) { $content .= '\par' . PHP_EOL; } @@ -136,24 +132,6 @@ private function writeFontStyle($style) return $content; } - /** - * Write font style ending - * - * @param \PhpOffice\PhpWord\Style\Font $style - * @return string - */ - private function writeFontStyleClosing($style) - { - if (!$style instanceof FontStyle) { - return ''; - } - - $styleWriter = new FontStyleWriter($style); - $content = $styleWriter->writeClosing(); - - return $content; - } - /** * Get font style * diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 2be72ff8c8..d7db8f2dbe 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; +use PhpOffice\PhpWord\Shared\String; + /** * TextBreak element RTF writer * diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index c20558db59..d14ee9c50b 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -66,35 +66,6 @@ public function write() return $content; } - /** - * Write end style - * - * @return string - */ - public function writeClosing() - { - $style = $this->getStyle(); - if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { - return; - } - - $content = ''; - $content .= '\cf0'; - $content .= '\f0'; - - $size = $style->getSize(); - $content .= $this->getValueIf(is_numeric($size), '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2)); - - $content .= $this->getValueIf($style->isBold(), '\b0'); - $content .= $this->getValueIf($style->isItalic(), '\i0'); - $content .= $this->getValueIf($style->getUnderline() != FontStyle::UNDERLINE_NONE, '\ul0'); - $content .= $this->getValueIf($style->isStrikethrough(), '\strike0'); - $content .= $this->getValueIf($style->isSuperScript(), '\super0'); - $content .= $this->getValueIf($style->isSubScript(), '\sub0'); - - return $content; - } - /** * Set font name index * diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index 8abdf2fb0c..8811cacf32 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; +use PhpOffice\PhpWord\Style\Alignment; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; /** @@ -39,10 +40,10 @@ public function write() } $alignments = array( - ParagraphStyle::ALIGN_LEFT => '\ql', - ParagraphStyle::ALIGN_RIGHT => '\qr', - ParagraphStyle::ALIGN_CENTER => '\qc', - ParagraphStyle::ALIGN_BOTH => '\qj', + Alignment::ALIGN_LEFT => '\ql', + Alignment::ALIGN_RIGHT => '\qr', + Alignment::ALIGN_CENTER => '\qc', + Alignment::ALIGN_BOTH => '\qj', ); $align = $style->getAlign(); diff --git a/src/PhpWord/Writer/Word2007/Style/Alignment.php b/src/PhpWord/Writer/Word2007/Style/Alignment.php new file mode 100644 index 0000000000..cefadb5740 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Alignment.php @@ -0,0 +1,44 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Alignment) { + return; + } + $value = $style->getValue(); + if ($value !== null) { + $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w:jc'); + $xmlWriter->writeAttribute('w:val', $value); + $xmlWriter->endElement(); // w:jc + } + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 88a75845c3..7322fd9142 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; + /** * Paragraph style writer * @@ -81,8 +83,8 @@ private function writeStyle() $xmlWriter->writeElementIf(!is_null($styleName), 'w:pStyle', 'w:val', $styleName); // Alignment - $align = $style->getAlign(); - $xmlWriter->writeElementIf(!is_null($align), 'w:jc', 'w:val', $align); + $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign()))); + $styleWriter->write(); // Pagination $xmlWriter->writeElementIf(!$style->hasWidowControl(), 'w:widowControl', 'w:val', '0'); diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 0a0241c325..3fbf849746 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; + /** * Table style writer * @@ -42,30 +44,46 @@ public function write() } $xmlWriter = $this->getXmlWriter(); - $hasBorders = $style->hasBorders(); + + // w:tblPr $hasMargins = $style->hasMargins(); - if ($hasMargins || $hasBorders) { - $xmlWriter->startElement('w:tblPr'); - if ($hasMargins) { - $mbWriter = new MarginBorder($xmlWriter); - $mbWriter->setSizes($style->getCellMargin()); - - $xmlWriter->startElement('w:tblCellMar'); - $mbWriter->write(); - $xmlWriter->endElement(); // w:tblCellMar - } - if ($hasBorders) { - $mbWriter = new MarginBorder($xmlWriter); - $mbWriter->setSizes($style->getBorderSize()); - $mbWriter->setColors($style->getBorderColor()); - - $xmlWriter->startElement('w:tblBorders'); - $mbWriter->write(); - $xmlWriter->endElement(); // w:tblBorders - } - $xmlWriter->endElement(); // w:tblPr + $hasBorders = $style->hasBorders(); + $align = $style->getAlign(); + + $xmlWriter->startElement('w:tblPr'); + + $xmlWriter->startElement('w:tblW'); + $xmlWriter->writeAttribute('w:w', $style->getWidth()); + $xmlWriter->writeAttribute('w:type', $style->getUnit()); + $xmlWriter->endElement(); // w:tblW + + // Alignment + $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $align))); + $styleWriter->write(); + + // Margins + if ($hasMargins) { + $mbWriter = new MarginBorder($xmlWriter); + $mbWriter->setSizes($style->getCellMargin()); + + $xmlWriter->startElement('w:tblCellMar'); + $mbWriter->write(); + $xmlWriter->endElement(); // w:tblCellMar } + // Borders + if ($hasBorders) { + $mbWriter = new MarginBorder($xmlWriter); + $mbWriter->setSizes($style->getBorderSize()); + $mbWriter->setColors($style->getBorderColor()); + + $xmlWriter->startElement('w:tblBorders'); + $mbWriter->write(); + $xmlWriter->endElement(); // w:tblBorders + } + + $xmlWriter->endElement(); // w:tblPr + // Only write background color and first row for full style if ($this->isFullStyle) { // Background color diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index 97a6c6bdea..dfcf3fee7b 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -29,7 +29,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase public function testEmptyStyles() { $styles = array( - 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', + 'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', 'Paragraph', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', 'TextBox' ); foreach ($styles as $style) { From 4b1a16006d44d36e91e676ea76ea02f89927cb90 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 13 May 2014 02:43:44 +0700 Subject: [PATCH 081/167] #196: Ability to add links and page breaks in RTF --- CHANGELOG.md | 1 + docs/intro.rst | 4 +- docs/src/documentation.md | 4 +- samples/Sample_01_SimpleText.php | 6 ++- src/PhpWord/Writer/RTF/Element/Link.php | 54 +++++++++++++++++++ src/PhpWord/Writer/RTF/Element/PageBreak.php | 36 +++++++++++++ src/PhpWord/Writer/RTF/Element/Title.php | 2 +- .../PhpWord/Tests/Writer/RTF/ElementTest.php | 2 +- 8 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 src/PhpWord/Writer/RTF/Element/Link.php create mode 100644 src/PhpWord/Writer/RTF/Element/PageBreak.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bcc5a2f07..8878e3dba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 - RTF: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 - Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 +- RTF: Ability to add links and page breaks in RTF - @ivanlanin GH-196 ### Bugfixes diff --git a/docs/intro.rst b/docs/intro.rst index 25a5020521..0b0c1dfe2b 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -73,13 +73,13 @@ Writers +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Title | ✓ | | | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| | Link | ✓ | ✓ | | ✓ | ✓ | +| | Link | ✓ | ✓ | ✓ | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Preserve Text | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Text Break | ✓ | ✓ | ✓ | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| | Page Break | ✓ | | | | | +| | Page Break | ✓ | | ✓ | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | List | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index a140c5bae0..5b969687a4 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -84,10 +84,10 @@ Below are the supported features for each file formats. | **Element Type** | Text | ✓ | ✓ | ✓ | ✓ | ✓ | | | Text Run | ✓ | ✓ | ✓ | ✓ | ✓ | | | Title | ✓ | | | ✓ | ✓ | -| | Link | ✓ | ✓ | | ✓ | ✓ | +| | Link | ✓ | ✓ | ✓ | ✓ | ✓ | | | Preserve Text | ✓ | | | | | | | Text Break | ✓ | ✓ | ✓ | ✓ | ✓ | -| | Page Break | ✓ | | | | | +| | Page Break | ✓ | | ✓ | | | | | List | ✓ | | | | | | | Table | ✓ | ✓ | | ✓ | ✓ | | | Image | ✓ | ✓ | | ✓ | | diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 7202ed7edb..311f33508f 100644 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -22,7 +22,8 @@ $section->addText('I am styled by a font style definition.', 'rStyle'); $section->addText('I am styled by a paragraph style definition.', null, 'pStyle'); $section->addText('I am styled by both font and paragraph style.', 'rStyle', 'pStyle'); -$section->addTextBreak(); + +$section->addPageBreak(); // Inline font style $fontStyle['name'] = 'Times New Roman'; @@ -36,10 +37,11 @@ $fontStyle['fgColor'] = 'yellow'; $fontStyle['smallCaps'] = true; $section->addText('I am inline styled.', $fontStyle); + $section->addTextBreak(); // Link -$section->addLink('http://www.google.com', null, 'NLink'); +$section->addLink('http://www.google.com', 'Google'); $section->addTextBreak(); // Image diff --git a/src/PhpWord/Writer/RTF/Element/Link.php b/src/PhpWord/Writer/RTF/Element/Link.php new file mode 100644 index 0000000000..bb87e29111 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/Link.php @@ -0,0 +1,54 @@ +element; + if (!$element instanceof \PhpOffice\PhpWord\Element\Link) { + return; + } + + $content = ''; + if (!$this->withoutP) { + $content .= '{'; + } + $content .= '{\field {\*\fldinst {HYPERLINK "' . $element->getTarget() . '"}}{\\fldrslt {'; + $content .= String::toUnicode($element->getText()); + $content .= '}}}'; + if (!$this->withoutP) { + $content .= '}'; + } + + return $content; + } +} diff --git a/src/PhpWord/Writer/RTF/Element/PageBreak.php b/src/PhpWord/Writer/RTF/Element/PageBreak.php new file mode 100644 index 0000000000..c8d16e0678 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/PageBreak.php @@ -0,0 +1,36 @@ +element->getText()); $content .= '\par' . PHP_EOL; diff --git a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php index 9f597c1512..b63c8a5ed4 100644 --- a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php @@ -28,7 +28,7 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $styles = array('Container', 'Text', 'Title'); + $styles = array('Container', 'Text', 'Title', 'Link'); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $style; $parentWriter = new RTF(); From 8745c5ee303faf8b6e363b2f418fd19f7bde9958 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 13 May 2014 11:05:12 +0700 Subject: [PATCH 082/167] Change behaviour of `set...` function of boolean properties; Some bug fixing based on Scrutinizer; New `Row` Word2007 style writer --- .scrutinizer.yml | 2 +- CHANGELOG.md | 1 + phpmd.xml.dist | 7 +- samples/Sample_09_Tables.php | 2 +- samples/Sample_25_TextBox.php | 4 +- src/PhpWord/Shared/Html.php | 8 ++- src/PhpWord/Style/AbstractStyle.php | 12 ++-- src/PhpWord/Style/Font.php | 19 +++--- src/PhpWord/Style/Image.php | 41 ++++++++--- src/PhpWord/Style/Paragraph.php | 6 +- src/PhpWord/Style/Row.php | 6 +- src/PhpWord/Writer/HTML/Element/Container.php | 11 ++- src/PhpWord/Writer/RTF/Element/Container.php | 26 +------ src/PhpWord/Writer/RTF/Style/Paragraph.php | 1 - .../Writer/Word2007/Element/Container.php | 16 ++--- src/PhpWord/Writer/Word2007/Element/Image.php | 9 +-- .../Writer/Word2007/Element/Object.php | 12 ++-- src/PhpWord/Writer/Word2007/Element/Table.php | 46 +++++-------- .../Writer/Word2007/Element/TextBox.php | 8 +-- src/PhpWord/Writer/Word2007/Style/Cell.php | 25 +++++++ src/PhpWord/Writer/Word2007/Style/Image.php | 50 +++++++++----- src/PhpWord/Writer/Word2007/Style/Row.php | 68 +++++++++++++++++++ tests/PhpWord/Tests/Style/FontTest.php | 15 ++-- .../Writer/Word2007/Part/DocumentTest.php | 2 +- .../Tests/Writer/Word2007/StyleTest.php | 2 +- 25 files changed, 251 insertions(+), 148 deletions(-) create mode 100644 src/PhpWord/Writer/Word2007/Style/Row.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d253de3001..c7d3c9e5db 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,7 @@ tools: enabled: true timeout: 900 php_sim: - min_mass: 30 + min_mass: 16 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 8878e3dba3..45b35a2148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 - Writer: Refactor writer parts using composite pattern - @ivanlanin - Docs: Show code quality and test code coverage badge on README +- Style: Change behaviour of `set...` function of boolean properties; when none is defined, assumed true - @ivanlanin ## 0.10.0 - 4 May 2014 diff --git a/phpmd.xml.dist b/phpmd.xml.dist index 18d5b2a9fc..34759560fa 100644 --- a/phpmd.xml.dist +++ b/phpmd.xml.dist @@ -8,11 +8,12 @@ - - + + + - + diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 6732e33600..882653bc71 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -51,7 +51,7 @@ // 3. colspan (gridSpan) and rowspan (vMerge) -$section->addTextBreak(1); +$section->addPageBreak(); $section->addText("Table with colspan and rowspan", $header); $styleTable = array('borderSize' => 6, 'borderColor' => '999999'); diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php index 4beb9553ed..0a659ddb3d 100644 --- a/samples/Sample_25_TextBox.php +++ b/samples/Sample_25_TextBox.php @@ -8,7 +8,7 @@ $section = $phpWord->addSection(); // In section -$textbox = $section->addTextBox(array('align' => 'left', 'width' => 400, 'height' => 150, 'borderSize' => 1, 'borderColor' => '#FF0000')); +$textbox = $section->addTextBox(array('align' => 'center', 'width' => 400, 'height' => 150, 'borderSize' => 1, 'borderColor' => '#FF0000')); $textbox->addText('Text box content in section.'); $textbox->addText('Another line.'); $cell = $textbox->addTable()->addRow()->addCell(); @@ -22,7 +22,7 @@ // Inside header with textrun $header = $section->addHeader(); -$textbox = $header->addTextBox(array('align' => 'center', 'width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00')); +$textbox = $header->addTextBox(array('width' => 600, 'borderSize' => 1, 'borderColor' => '#00FF00')); $textrun = $textbox->addTextRun(); $textrun->addText('TextBox in header. TextBox can contain a TextRun '); $textrun->addText('with bold text', array('bold' => true)); diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 59795af7e7..78f1d99de9 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -219,7 +219,13 @@ protected static function parseNode( $text = $cNode->nodeValue; } } - $object->addListItem($text, $data['listdepth'], $styles['fontStyle'], $styles['listStyle'], $styles['paragraphStyle']); + $object->addListItem( + $text, + $data['listdepth'], + $styles['fontStyle'], + $styles['listStyle'], + $styles['paragraphStyle'] + ); } } diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index d909a20af0..00fe6a09ed 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -152,13 +152,13 @@ protected function setNonEmptyVal($value, $default) } /** - * Set boolean value + * Set bool value * - * @param mixed $value - * @param boolean|null $default - * @return boolean|null + * @param bool $value + * @param bool $default + * @return bool */ - protected function setBoolVal($value, $default = null) + protected function setBoolVal($value, $default) { if (!is_bool($value)) { $value = $default; @@ -184,7 +184,7 @@ protected function setNumericVal($value, $default = null) } /** - * Set float value: Convert string that contains only numeric into integer + * Set integer value: Convert string that contains only numeric into integer * * @param mixed $value * @param int|null $default diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 85ad52b9be..4fe70068a7 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -333,7 +333,7 @@ public function isBold() * @param bool $value * @return self */ - public function setBold($value = false) + public function setBold($value = true) { $this->bold = $this->setBoolVal($value, $this->bold); @@ -356,7 +356,7 @@ public function isItalic() * @param bool $value * @return self */ - public function setItalic($value = false) + public function setItalic($value = true) { $this->italic = $this->setBoolVal($value, $this->italic); @@ -402,7 +402,7 @@ public function isSuperScript() * @param bool $value * @return self */ - public function setSuperScript($value = false) + public function setSuperScript($value = true) { $this->superScript = $this->setBoolVal($value, $this->superScript); $this->toggleFalse($this->subScript, $this->superScript); @@ -426,13 +426,10 @@ public function isSubScript() * @param bool $value * @return self */ - public function setSubScript($value = false) + public function setSubScript($value = true) { $this->subScript = $this->setBoolVal($value, $this->subScript); $this->toggleFalse($this->subScript, $this->superScript); - if ($this->subScript) { - $this->superScript = false; - } return $this; } @@ -453,7 +450,7 @@ public function isStrikethrough() * @param bool $value * @return self */ - public function setStrikethrough($value = false) + public function setStrikethrough($value = true) { $this->strikethrough = $this->setBoolVal($value, $this->strikethrough); $this->toggleFalse($this->doubleStrikethrough, $this->strikethrough); @@ -477,7 +474,7 @@ public function isDoubleStrikethrough() * @param bool $value * @return self */ - public function setDoubleStrikethrough($value = false) + public function setDoubleStrikethrough($value = true) { $this->doubleStrikethrough = $this->setBoolVal($value, $this->doubleStrikethrough); $this->toggleFalse($this->strikethrough, $this->doubleStrikethrough); @@ -501,7 +498,7 @@ public function isSmallCaps() * @param bool $value * @return self */ - public function setSmallCaps($value = false) + public function setSmallCaps($value = true) { $this->smallCaps = $this->setBoolVal($value, $this->smallCaps); $this->toggleFalse($this->allCaps, $this->smallCaps); @@ -525,7 +522,7 @@ public function isAllCaps() * @param bool $value * @return self */ - public function setAllCaps($value = false) + public function setAllCaps($value = true) { $this->allCaps = $this->setBoolVal($value, $this->allCaps); $this->toggleFalse($this->smallCaps, $this->allCaps); diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 5dc82d0b9f..fc9f963071 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -94,9 +94,9 @@ class Image extends AbstractStyle /** * Alignment * - * @var string + * @var \PhpOffice\PhpWord\Style\Alignment */ - private $align; + private $alignment; /** * Margin Top @@ -154,8 +154,18 @@ class Image extends AbstractStyle */ private $posVerticalRel = self::POSITION_RELATIVE_TO_LINE; + /** + * Create new instance + */ + public function __construct() + { + $this->alignment = new Alignment(); + } + /** * Get width + * + * @return int */ public function getWidth() { @@ -166,14 +176,19 @@ public function getWidth() * Set width * * @param int $value + * @return self */ public function setWidth($value = null) { $this->width = $value; + + return $this; } /** * Get height + * + * @return int */ public function getHeight() { @@ -184,32 +199,40 @@ public function getHeight() * Set height * * @param int $value + * @return self */ public function setHeight($value = null) { $this->height = $value; + + return $this; } /** * Get alignment + * + * @return string */ public function getAlign() { - return $this->align; + return $this->alignment->getValue(); } /** * Set alignment * * @param string $value + * @return self */ public function setAlign($value = null) { - $this->align = $value; + $this->alignment->setValue($value); + + return $this; } /** - * Get Margin Top + * Get margin top * * @return int */ @@ -219,7 +242,7 @@ public function getMarginTop() } /** - * Set Margin Top + * Set margin top * * @param int $value * @return self @@ -227,11 +250,12 @@ public function getMarginTop() public function setMarginTop($value = null) { $this->marginTop = $value; + return $this; } /** - * Get Margin Left + * Get margin left * * @return int */ @@ -241,7 +265,7 @@ public function getMarginLeft() } /** - * Set Margin Left + * Set margin left * * @param int $value * @return self @@ -249,6 +273,7 @@ public function getMarginLeft() public function setMarginLeft($value = null) { $this->marginLeft = $value; + return $this; } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 56609119e2..9c8e0c5b9d 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -420,7 +420,7 @@ public function isKeepNext() * @param bool $value * @return self */ - public function setKeepNext($value = false) + public function setKeepNext($value = true) { $this->keepNext = $this->setBoolVal($value, $this->keepNext); @@ -443,7 +443,7 @@ public function isKeepLines() * @param bool $value * @return self */ - public function setKeepLines($value = false) + public function setKeepLines($value = true) { $this->keepLines = $this->setBoolVal($value, $this->keepLines); @@ -466,7 +466,7 @@ public function hasPageBreakBefore() * @param bool $value * @return self */ - public function setPageBreakBefore($value = false) + public function setPageBreakBefore($value = true) { $this->pageBreakBefore = $this->setBoolVal($value, $this->pageBreakBefore); diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index 310564d89d..45897aed5e 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -68,7 +68,7 @@ public function isTblHeader() * @param bool $value * @return self */ - public function setTblHeader($value = false) + public function setTblHeader($value = true) { $this->tblHeader = $this->setBoolVal($value, $this->tblHeader); @@ -91,7 +91,7 @@ public function isCantSplit() * @param bool $value * @return self */ - public function setCantSplit($value = false) + public function setCantSplit($value = true) { $this->cantSplit = $this->setBoolVal($value, $this->cantSplit); @@ -114,7 +114,7 @@ public function isExactHeight() * @param bool $value * @return self */ - public function setExactHeight($value = false) + public function setExactHeight($value = true) { $this->exactHeight = $this->setBoolVal($value, $this->exactHeight); diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php index c4bbc2f83b..079e16c2a1 100644 --- a/src/PhpWord/Writer/HTML/Element/Container.php +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -24,6 +24,13 @@ */ class Container extends AbstractElement { + /** + * Namespace; Can't use __NAMESPACE__ in inherited class (RTF) + * + * @var string + */ + protected $namespace = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element'; + /** * Write container * @@ -40,8 +47,10 @@ public function write() $content = ''; $elements = $container->getElements(); + $elementClass = ''; foreach ($elements as $element) { - $writerClass = str_replace('\\Element', '\\Writer\\HTML\\Element', get_class($element)); + $elementClass = get_class($element); + $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass); if (class_exists($writerClass)) { $writer = new $writerClass($this->parentWriter, $element, $withoutP); $content .= $writer->write(); diff --git a/src/PhpWord/Writer/RTF/Element/Container.php b/src/PhpWord/Writer/RTF/Element/Container.php index f4b5f2acfd..38c7789466 100644 --- a/src/PhpWord/Writer/RTF/Element/Container.php +++ b/src/PhpWord/Writer/RTF/Element/Container.php @@ -25,29 +25,9 @@ class Container extends \PhpOffice\PhpWord\Writer\HTML\Element\Container { /** - * Write container + * Namespace; Can't use __NAMESPACE__ in inherited class (RTF) * - * @return string + * @var string */ - public function write() - { - $container = $this->element; - if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { - return; - } - $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); - $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; - $content = ''; - - $elements = $container->getElements(); - foreach ($elements as $element) { - $writerClass = str_replace('\\Element', '\\Writer\\RTF\\Element', get_class($element)); - if (class_exists($writerClass)) { - $writer = new $writerClass($this->parentWriter, $element, $withoutP); - $content .= $writer->write(); - } - } - - return $content; - } + protected $namespace = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element'; } diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index 8811cacf32..26c62f0208 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; use PhpOffice\PhpWord\Style\Alignment; -use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; /** * RTF paragraph style writer diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 57a2720886..20e0018a61 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -38,25 +38,23 @@ class Container extends AbstractElement */ public function write() { - $xmlWriter = $this->getXmlWriter(); $container = $this->getElement(); if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { return; } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')) ? true : false; + $xmlWriter = $this->getXmlWriter(); // Loop through elements $elements = $container->getElements(); $elementClass = ''; - if (count($elements) > 0) { - foreach ($elements as $element) { - $elementClass = get_class($element); - $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass); - if (class_exists($writerClass)) { - $writer = new $writerClass($xmlWriter, $element, $withoutP); - $writer->write(); - } + foreach ($elements as $element) { + $elementClass = get_class($element); + $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass); + if (class_exists($writerClass)) { + $writer = new $writerClass($xmlWriter, $element, $withoutP); + $writer->write(); } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index c41199f828..e044606e70 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -57,15 +57,8 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) if (!$this->withoutP) { $xmlWriter->startElement('w:p'); - if (!is_null($style->getAlign())) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $style->getAlign()); - $xmlWriter->endElement(); // w:jc - $xmlWriter->endElement(); // w:pPr - } + $styleWriter->writeAlignment(); } - $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index 07580a42fd..ae03f04f5b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; +use PhpOffice\PhpWord\Writer\Word2007\Style\Image as ImageStyleWriter; + /** * Object element writer * @@ -40,17 +42,11 @@ public function write() $shapeId = md5($rIdObject . '_' . $rIdImage); $objectId = $element->getRelationId() + 1325353440; $style = $element->getStyle(); - $align = $style->getAlign(); + $styleWriter = new ImageStyleWriter($xmlWriter, $style); if (!$this->withoutP) { $xmlWriter->startElement('w:p'); - } - if (!is_null($align)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - $xmlWriter->endElement(); + $styleWriter->writeAlignment(); } $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:object'); diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 4ce97d10b1..f62dfbb42c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -21,8 +21,10 @@ use PhpOffice\PhpWord\Element\Row as RowElement; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Cell as CellStyle; +use PhpOffice\PhpWord\Style\Row as RowStyle; use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; +use PhpOffice\PhpWord\Writer\Word2007\Style\Row as RowStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; /** @@ -109,33 +111,21 @@ public function write() */ private function writeRow(XMLWriter $xmlWriter, RowElement $row) { - $height = $row->getHeight(); - $rowStyle = $row->getStyle(); - $xmlWriter->startElement('w:tr'); - if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { - $xmlWriter->startElement('w:trPr'); - if (!is_null($height)) { - $xmlWriter->startElement('w:trHeight'); - $xmlWriter->writeAttribute('w:val', $height); - $xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); - $xmlWriter->endElement(); - } - if ($rowStyle->isTblHeader()) { - $xmlWriter->startElement('w:tblHeader'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($rowStyle->isCantSplit()) { - $xmlWriter->startElement('w:cantSplit'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); + + // Write style + $rowStyle = $row->getStyle(); + if ($rowStyle instanceof RowStyle) { + $styleWriter = new RowStyleWriter($xmlWriter, $rowStyle); + $styleWriter->setHeight($row->getHeight()); + $styleWriter->write(); } + + // Write cells foreach ($row->getCells() as $cell) { $this->writeCell($xmlWriter, $cell); } + $xmlWriter->endElement(); // w:tr } @@ -144,20 +134,18 @@ private function writeRow(XMLWriter $xmlWriter, RowElement $row) */ private function writeCell(XMLWriter $xmlWriter, CellElement $cell) { - $cellStyle = $cell->getStyle(); $xmlWriter->startElement('w:tc'); - $xmlWriter->startElement('w:tcPr'); - $xmlWriter->startElement('w:tcW'); - $xmlWriter->writeAttribute('w:w', $cell->getWidth()); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); // w:tcW + + // Write style + $cellStyle = $cell->getStyle(); if ($cellStyle instanceof CellStyle) { $styleWriter = new CellStyleWriter($xmlWriter, $cellStyle); + $styleWriter->setWidth($cell->getWidth()); $styleWriter->write(); } - $xmlWriter->endElement(); // w:tcPr + // Write content $containerWriter = new Container($xmlWriter, $cell); $containerWriter->write(); diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index bb1629bcdc..4ee5e68e61 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -41,13 +41,7 @@ public function write() if (!$this->withoutP) { $xmlWriter->startElement('w:p'); - if (!is_null($style->getAlign())) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $style->getAlign()); - $xmlWriter->endElement(); // w:jc - $xmlWriter->endElement(); // w:pPr - } + $styleWriter->writeAlignment(); } $xmlWriter->startElement('w:r'); diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index c6e216251e..ce7efb3bbc 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -26,6 +26,11 @@ */ class Cell extends AbstractStyle { + /** + * @var int Cell width + */ + private $width; + /** * Write style */ @@ -37,6 +42,14 @@ public function write() } $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w:tcPr'); + + // Width + $xmlWriter->startElement('w:tcW'); + $xmlWriter->writeAttribute('w:w', $this->width); + $xmlWriter->writeAttribute('w:type', 'dxa'); + $xmlWriter->endElement(); // w:tcW + // Text direction $textDir = $style->getTextDirection(); $xmlWriter->writeElementIf(!is_null($textDir), 'w:textDirection', 'w:val', $textDir); @@ -70,5 +83,17 @@ public function write() $vMerge = $style->getVMerge(); $xmlWriter->writeElementIf(!is_null($gridSpan), 'w:gridSpan', 'w:val', $gridSpan); $xmlWriter->writeElementIf(!is_null($vMerge), 'w:vMerge', 'w:val', $vMerge); + + $xmlWriter->endElement(); // w:tcPr + } + + /** + * Set width + * + * @param int $value + */ + public function setWidth($value = null) + { + $this->width = $value; } } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index 0b25f4b9b0..ecc3fb7b4e 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; use PhpOffice\PhpWord\Style\Image as ImageStyle; /** @@ -45,23 +46,6 @@ public function write() $this->writeStyle($style); } - /** - * Write w10 wrapping - * - * @return array - */ - public function writeW10Wrap() - { - if (is_null($this->w10wrap)) { - return; - } - - $xmlWriter = $this->getXmlWriter(); - $xmlWriter->startElement('w10:wrap'); - $xmlWriter->writeAttribute('type', $this->w10wrap); - $xmlWriter->endElement(); // w10:wrap - } - /** * Write style attribute */ @@ -117,6 +101,38 @@ protected function writeStyle(ImageStyle $style) $xmlWriter->writeAttribute('style', $imageStyle); } + /** + * Write alignment + */ + public function writeAlignment() + { + $style = $this->getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Image) { + return; + } + + $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w:pPr'); + $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign()))); + $styleWriter->write(); + $xmlWriter->endElement(); // w:pPr + } + + /** + * Write w10 wrapping + */ + public function writeW10Wrap() + { + if (is_null($this->w10wrap)) { + return; + } + + $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $this->w10wrap); + $xmlWriter->endElement(); // w10:wrap + } + /** * Get element style * diff --git a/src/PhpWord/Writer/Word2007/Style/Row.php b/src/PhpWord/Writer/Word2007/Style/Row.php new file mode 100644 index 0000000000..175aa16b6b --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Row.php @@ -0,0 +1,68 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Row) { + return; + } + + $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w:trPr'); + + if ($this->height !== null) { + $xmlWriter->startElement('w:trHeight'); + $xmlWriter->writeAttribute('w:val', $this->height); + $xmlWriter->writeAttribute('w:hRule', ($style->isExactHeight() ? 'exact' : 'atLeast')); + $xmlWriter->endElement(); + } + $xmlWriter->writeElementIf($style->isTblHeader(), 'w:tblHeader', 'w:val', '1'); + $xmlWriter->writeElementIf($style->isCantSplit(), 'w:cantSplit', 'w:val', '1'); + + $xmlWriter->endElement(); // w:trPr + } + + /** + * Set height + * + * @param int $value + */ + public function setHeight($value = null) + { + $this->height = $value; + } +} diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 74aa5e2e48..68342efd12 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -59,17 +59,21 @@ public function testSetStyleValueWithNullOrEmpty() 'size' => PhpWord::DEFAULT_FONT_SIZE, 'bold' => false, 'italic' => false, + 'underline' => Font::UNDERLINE_NONE, 'superScript' => false, 'subScript' => false, - 'underline' => Font::UNDERLINE_NONE, 'strikethrough' => false, + 'doubleStrikethrough' => false, + 'smallCaps' => false, + 'allCaps' => false, + 'doubleStrikethrough' => false, 'color' => PhpWord::DEFAULT_FONT_COLOR, 'fgColor' => null, 'bgColor' => null, 'hint' => PhpWord::DEFAULT_FONT_CONTENT_TYPE, ); foreach ($attributes as $key => $default) { - $get = "get{$key}"; + $get = is_bool($default) ? "is{$key}" : "get{$key}"; $object->setStyleValue("$key", null); $this->assertEquals($default, $object->$get()); $object->setStyleValue("$key", ''); @@ -89,10 +93,13 @@ public function testSetStyleValueNormal() 'size' => 9, 'bold' => true, 'italic' => true, + 'underline' => Font::UNDERLINE_HEAVY, 'superScript' => true, 'subScript' => false, - 'underline' => Font::UNDERLINE_HEAVY, 'strikethrough' => true, + 'doubleStrikethrough' => false, + 'smallCaps' => true, + 'allCaps' => false, 'color' => '999999', 'fgColor' => Font::FGCOLOR_YELLOW, 'bgColor' => 'FFFF00', @@ -101,7 +108,7 @@ public function testSetStyleValueNormal() ); $object->setStyleByArray($attributes); foreach ($attributes as $key => $value) { - $get = "get{$key}"; + $get = is_bool($value) ? "is{$key}" : "get{$key}"; $this->assertEquals($value, $object->$get()); } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index b036c21b45..7798f30e92 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -179,7 +179,7 @@ public function testWriteTextRun() $textrun->addTextBreak(); $textrun = $section->addTextRun($aStyle); $textrun->addLink('http://test.com'); - $textrun->addImage($imageSrc, array('align' => 'top')); + $textrun->addImage($imageSrc, array('align' => 'center')); $textrun->addFootnote(); $doc = TestHelperDOCX::getDocument($phpWord); diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index dfcf3fee7b..cc722efbf4 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -30,7 +30,7 @@ public function testEmptyStyles() { $styles = array( 'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', - 'Paragraph', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', 'TextBox' + 'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', 'TextBox' ); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style; From 7ae8c3cb81708d459f91e0ad2c55e4e04d3db16b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 13 May 2014 14:54:40 +0700 Subject: [PATCH 083/167] Refactoring: Word2007 table and marginborder style writer --- phpmd.xml.dist | 9 +- src/PhpWord/Settings.php | 2 +- src/PhpWord/Style/AbstractStyle.php | 4 +- src/PhpWord/Writer/HTML/Element/Container.php | 1 - src/PhpWord/Writer/RTF/Element/Text.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 86 +++++---- .../Writer/Word2007/Style/MarginBorder.php | 58 +++--- src/PhpWord/Writer/Word2007/Style/Row.php | 2 - src/PhpWord/Writer/Word2007/Style/Table.php | 170 +++++++++++------- 9 files changed, 191 insertions(+), 143 deletions(-) diff --git a/phpmd.xml.dist b/phpmd.xml.dist index 34759560fa..f0b62b2d6e 100644 --- a/phpmd.xml.dist +++ b/phpmd.xml.dist @@ -9,9 +9,14 @@ - + + + + + + - + diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index b8dfe8cd87..ebd79cd925 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -95,7 +95,7 @@ class Settings /** * Measurement unit * - * @var string + * @var int|float */ private static $measurementUnit = self::UNIT_TWIP; diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 00fe6a09ed..5be042bd84 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -138,7 +138,7 @@ public function setStyleByArray($styles = array()) /** * Set default for null and empty value * - * @param mixed $value + * @param string $value * @param mixed $default * @return mixed */ @@ -186,7 +186,7 @@ protected function setNumericVal($value, $default = null) /** * Set integer value: Convert string that contains only numeric into integer * - * @param mixed $value + * @param int|null $value * @param int|null $default * @return int|null */ diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php index 079e16c2a1..54ec7ee68a 100644 --- a/src/PhpWord/Writer/HTML/Element/Container.php +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -47,7 +47,6 @@ public function write() $content = ''; $elements = $container->getElements(); - $elementClass = ''; foreach ($elements as $element) { $elementClass = get_class($element); $writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass); diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index ae97fd3a67..31966c7d0d 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -99,7 +99,7 @@ private function writeParagraphStyle(TextElement $element) /** * Write font style beginning * - * @param mixed $style + * @param \PhpOffice\PhpWord\Style\Font $style * @return string */ private function writeFontStyle($style) diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index f62dfbb42c..6349172a70 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\Element\Cell as CellElement; use PhpOffice\PhpWord\Element\Row as RowElement; +use PhpOffice\PhpWord\Element\Table as TableElement; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Row as RowStyle; @@ -51,59 +52,54 @@ public function write() if ($rowCount > 0) { $xmlWriter->startElement('w:tbl'); - // Table grid - $cellWidths = array(); + // Write columns + $this->writeColumns($xmlWriter, $element); + + // Write style + $styleWriter = new TableStyleWriter($xmlWriter, $element->getStyle()); + $styleWriter->setWidth($element->getWidth()); + $styleWriter->write(); + + // Write rows for ($i = 0; $i < $rowCount; $i++) { - $row = $rows[$i]; - $cells = $row->getCells(); - if (count($cells) <= count($cellWidths)) { - continue; - } - $cellWidths = array(); - foreach ($cells as $cell) { - $cellWidths[] = $cell->getWidth(); - } + $this->writeRow($xmlWriter, $rows[$i]); } - $xmlWriter->startElement('w:tblGrid'); - foreach ($cellWidths as $width) { - $xmlWriter->startElement('w:gridCol'); - if (!is_null($width)) { - $xmlWriter->writeAttribute('w:w', $width); - $xmlWriter->writeAttribute('w:type', 'dxa'); - } - $xmlWriter->endElement(); + + $xmlWriter->endElement(); // w:tbl + } + } + + /** + * Write column + */ + private function writeColumns(XMLWriter $xmlWriter, TableElement $element) + { + $rows = $element->getRows(); + $rowCount = count($rows); + + $cellWidths = array(); + for ($i = 0; $i < $rowCount; $i++) { + $row = $rows[$i]; + $cells = $row->getCells(); + if (count($cells) <= count($cellWidths)) { + continue; } - $xmlWriter->endElement(); // w:tblGrid - - // Table style - $tblStyle = $element->getStyle(); - $tblWidth = $element->getWidth(); - if ($tblStyle instanceof TableStyle) { - $styleWriter = new TableStyleWriter($xmlWriter, $tblStyle); - $styleWriter->setIsFullStyle(false); - $styleWriter->write(); - } else { - if (!empty($tblStyle)) { - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblStyle'); - $xmlWriter->writeAttribute('w:val', $tblStyle); - $xmlWriter->endElement(); - if (!is_null($tblWidth)) { - $xmlWriter->startElement('w:tblW'); - $xmlWriter->writeAttribute('w:w', $tblWidth); - $xmlWriter->writeAttribute('w:type', 'pct'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } + $cellWidths = array(); + foreach ($cells as $cell) { + $cellWidths[] = $cell->getWidth(); } + } - // Table rows - for ($i = 0; $i < $rowCount; $i++) { - $this->writeRow($xmlWriter, $rows[$i]); + $xmlWriter->startElement('w:tblGrid'); + foreach ($cellWidths as $width) { + $xmlWriter->startElement('w:gridCol'); + if ($width !== null) { + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', 'dxa'); } $xmlWriter->endElement(); } + $xmlWriter->endElement(); // w:tblGrid } /** diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 28cf1224b4..b5c05ca985 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; + /** * Margin border style writer * @@ -56,29 +58,45 @@ public function write() $sizeCount = count($this->sizes) - 1; for ($i = 0; $i < $sizeCount; $i++) { - if (!is_null($this->sizes[$i])) { - $xmlWriter->startElement('w:' . $sides[$i]); - if (!empty($this->colors)) { - if (is_null($this->colors[$i]) && !empty($this->attributes)) { - if (array_key_exists('defaultColor', $this->attributes)) { - $this->colors[$i] = $this->attributes['defaultColor']; - } - } - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $this->sizes[$i]); - $xmlWriter->writeAttribute('w:color', $this->colors[$i]); - if (!empty($this->attributes)) { - if (array_key_exists('space', $this->attributes)) { - $xmlWriter->writeAttribute('w:space', $this->attributes['space']); - } - } - } else { - $xmlWriter->writeAttribute('w:w', $this->sizes[$i]); - $xmlWriter->writeAttribute('w:type', 'dxa'); + if ($this->sizes[$i] !== null) { + $color = null; + if (isset($this->colors[$i])) { + $color = $this->colors[$i]; + } + $this->writeSide($xmlWriter, $sides[$i], $this->sizes[$i], $color); + } + } + } + + /** + * Write side + * + * @param string $side + * @param int $width + * @param string $color + */ + private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null) + { + $xmlWriter->startElement('w:' . $side); + if (!empty($this->colors)) { + if ($color === null && !empty($this->attributes)) { + if (array_key_exists('defaultColor', $this->attributes)) { + $color = $this->attributes['defaultColor']; + } + } + $xmlWriter->writeAttribute('w:val', 'single'); + $xmlWriter->writeAttribute('w:sz', $width); + $xmlWriter->writeAttribute('w:color', $color); + if (!empty($this->attributes)) { + if (array_key_exists('space', $this->attributes)) { + $xmlWriter->writeAttribute('w:space', $this->attributes['space']); } - $xmlWriter->endElement(); } + } else { + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', 'dxa'); } + $xmlWriter->endElement(); } /** diff --git a/src/PhpWord/Writer/Word2007/Style/Row.php b/src/PhpWord/Writer/Word2007/Style/Row.php index 175aa16b6b..5517cc2b82 100644 --- a/src/PhpWord/Writer/Word2007/Style/Row.php +++ b/src/PhpWord/Writer/Word2007/Style/Row.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Style\Row as RowStyle; - /** * Row style writer * diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 3fbf849746..d996df007c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -17,7 +17,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; +use PhpOffice\PhpWord\Style\Table as TableStyle; /** * Table style writer @@ -27,11 +29,9 @@ class Table extends AbstractStyle { /** - * Is full style - * - * @var bool + * @var int Table width */ - private $isFullStyle = true; + private $width; /** * Write style @@ -39,105 +39,137 @@ class Table extends AbstractStyle public function write() { $style = $this->getStyle(); - if (!$style instanceof \PhpOffice\PhpWord\Style\Table) { - return; - } $xmlWriter = $this->getXmlWriter(); + if ($style instanceof \PhpOffice\PhpWord\Style\Table) { + $this->writeStyle($xmlWriter, $style); + } elseif (is_string($style)) { + $xmlWriter->startElement('w:tblPr'); + $xmlWriter->startElement('w:tblStyle'); + $xmlWriter->writeAttribute('w:val', $style); + $xmlWriter->endElement(); + if ($this->width !== null) { + $this->writeWidth($xmlWriter, $this->width, 'pct'); + } + $xmlWriter->endElement(); + } + } + /** + * Write full style + */ + private function writeStyle(XMLWriter $xmlWriter, TableStyle $style) + { // w:tblPr - $hasMargins = $style->hasMargins(); - $hasBorders = $style->hasBorders(); - $align = $style->getAlign(); - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblW'); - $xmlWriter->writeAttribute('w:w', $style->getWidth()); - $xmlWriter->writeAttribute('w:type', $style->getUnit()); - $xmlWriter->endElement(); // w:tblW - // Alignment - $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $align))); + $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign()))); $styleWriter->write(); - // Margins - if ($hasMargins) { - $mbWriter = new MarginBorder($xmlWriter); - $mbWriter->setSizes($style->getCellMargin()); + $this->writeWidth($xmlWriter, $style->getWidth(), $style->getUnit()); + $this->writeMargin($xmlWriter, $style); + $this->writeBorder($xmlWriter, $style); - $xmlWriter->startElement('w:tblCellMar'); - $mbWriter->write(); - $xmlWriter->endElement(); // w:tblCellMar - } + $xmlWriter->endElement(); // w:tblPr - // Borders - if ($hasBorders) { - $mbWriter = new MarginBorder($xmlWriter); - $mbWriter->setSizes($style->getBorderSize()); - $mbWriter->setColors($style->getBorderColor()); + $this->writeShading($xmlWriter, $style); - $xmlWriter->startElement('w:tblBorders'); - $mbWriter->write(); - $xmlWriter->endElement(); // w:tblBorders + // First row style + $firstRow = $style->getFirstRow(); + if ($firstRow instanceof \PhpOffice\PhpWord\Style\Table) { + $this->writeFirstRow($xmlWriter, $firstRow); } + } - $xmlWriter->endElement(); // w:tblPr + /** + * Write width + * + * @param int $width + * @param string $unit + */ + private function writeWidth(XMLWriter $xmlWriter, $width, $unit) + { + $xmlWriter->startElement('w:tblW'); + $xmlWriter->writeAttribute('w:w', $width); + $xmlWriter->writeAttribute('w:type', $unit); + $xmlWriter->endElement(); // w:tblW + } - // Only write background color and first row for full style - if ($this->isFullStyle) { - // Background color - if (!is_null($style->getShading())) { - $xmlWriter->startElement('w:tcPr'); - $styleWriter = new Shading($xmlWriter, $style->getShading()); - $styleWriter->write(); - $xmlWriter->endElement(); - } - // First Row - $firstRow = $style->getFirstRow(); - if ($firstRow instanceof \PhpOffice\PhpWord\Style\Table) { - $this->writeFirstRow($firstRow); - } + /** + * Write margin + */ + private function writeMargin(XMLWriter $xmlWriter, TableStyle $style) + { + if ($style->hasMargins()) { + $xmlWriter->startElement('w:tblCellMar'); + + $styleWriter = new MarginBorder($xmlWriter); + $styleWriter->setSizes($style->getCellMargin()); + $styleWriter->write(); + + $xmlWriter->endElement(); // w:tblCellMar } } /** - * Set is full style - * - * @param bool $value + * Write border */ - public function setIsFullStyle($value) + private function writeBorder(XMLWriter $xmlWriter, TableStyle $style) { - $this->isFullStyle = $value; + if ($style->hasBorders()) { + $xmlWriter->startElement('w:tblBorders'); + + $styleWriter = new MarginBorder($xmlWriter); + $styleWriter->setSizes($style->getBorderSize()); + $styleWriter->setColors($style->getBorderColor()); + $styleWriter->write(); + + $xmlWriter->endElement(); // w:tblBorders + } } /** * Write row style */ - private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style) + private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style) { - $xmlWriter = $this->getXmlWriter(); - $xmlWriter->startElement('w:tblStylePr'); $xmlWriter->writeAttribute('w:type', 'firstRow'); $xmlWriter->startElement('w:tcPr'); - if (!is_null($style->getShading())) { + + $this->writeBorder($xmlWriter, $style); + $this->writeShading($xmlWriter, $style); + + $xmlWriter->endElement(); // w:tcPr + $xmlWriter->endElement(); // w:tblStylePr + } + + /** + * Write shading + * + * @param int $width + * @param string $unit + */ + private function writeShading(XMLWriter $xmlWriter, TableStyle $style) + { + if ($style->getShading() !== null) { + $xmlWriter->startElement('w:tcPr'); + $styleWriter = new Shading($xmlWriter, $style->getShading()); $styleWriter->write(); - } - // Borders - if ($style->hasBorders()) { - $mbWriter = new MarginBorder($xmlWriter); - $mbWriter->setSizes($style->getBorderSize()); - $mbWriter->setColors($style->getBorderColor()); - - $xmlWriter->startElement('w:tcBorders'); - $mbWriter->write(); - $xmlWriter->endElement(); // w:tcBorders + $xmlWriter->endElement(); } + } - $xmlWriter->endElement(); // w:tcPr - $xmlWriter->endElement(); // w:tblStylePr + /** + * Set width + * + * @param int $value + */ + public function setWidth($value = null) + { + $this->width = $value; } } From 1ee43da4de7895201c8f038c085c6f3a666b437d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 13 May 2014 23:36:33 +0700 Subject: [PATCH 084/167] #196: RTF link styling --- src/PhpWord/Element/ListItem.php | 32 +++-- src/PhpWord/Writer/RTF.php | 4 +- .../Writer/RTF/Element/AbstractElement.php | 132 ++++++++++++++++++ src/PhpWord/Writer/RTF/Element/Link.php | 20 ++- src/PhpWord/Writer/RTF/Element/ListItem.php | 29 ++++ src/PhpWord/Writer/RTF/Element/Text.php | 112 ++------------- src/PhpWord/Writer/RTF/Element/TextRun.php | 10 +- src/PhpWord/Writer/RTF/Element/Title.php | 25 +--- src/PhpWord/Writer/RTF/Style/Font.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 1 - src/PhpWord/Writer/Word2007/Style/Table.php | 3 - 11 files changed, 214 insertions(+), 156 deletions(-) create mode 100644 src/PhpWord/Writer/RTF/Element/ListItem.php diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 1042362c18..59bd83917c 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -26,27 +26,26 @@ class ListItem extends AbstractElement { /** - * ListItem Style + * Element style * * @var \PhpOffice\PhpWord\Style\ListItem */ private $style; /** - * Textrun + * Text object * - * @var Text + * @var \PhpOffice\PhpWord\Element\Text */ private $textObject; /** - * ListItem Depth + * Depth * * @var int */ private $depth; - /** * Create a new ListItem * @@ -70,7 +69,9 @@ public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = n } /** - * Get ListItem style + * Get style + * + * @return \PhpOffice\PhpWord\Style\ListItem */ public function getStyle() { @@ -78,7 +79,9 @@ public function getStyle() } /** - * Get ListItem TextRun + * Get Text object + * + * @return \PhpOffice\PhpWord\Element\Text */ public function getTextObject() { @@ -86,10 +89,23 @@ public function getTextObject() } /** - * Get ListItem depth + * Get depth + * + * @return int */ public function getDepth() { return $this->depth; } + + /** + * Get text + * + * @return string + * @since 0.11.0 + */ + public function getText() + { + return $this->textObject->getText(); + } } diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 434ffd6770..27329db2b0 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -226,7 +226,7 @@ private function populateFontTable() $elements = $section->getElements(); foreach ($elements as $element) { - if ($element instanceof Text) { + if (method_exists($element, 'getFontStyle')) { $fontStyle = $element->getFontStyle(); if ($fontStyle instanceof Font) { @@ -284,7 +284,7 @@ private function populateColorTable() $elements = $section->getElements(); foreach ($elements as $element) { - if ($element instanceof Text) { + if (method_exists($element, 'getFontStyle')) { $fontStyle = $element->getFontStyle(); if ($fontStyle instanceof Font) { diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index fbf8114e1a..e6e42c1827 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -17,6 +17,13 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; +use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font as FontStyle; +use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; +use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; +use PhpOffice\PhpWord\Writer\RTF\Style\Paragraph as ParagraphStyleWriter; + /** * Abstract RTF element writer * @@ -24,4 +31,129 @@ */ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractElement { + /** + * Font style + * + * @var \PhpWord\PhpOffice\Style\Font + */ + private $fontStyle; + + /** + * Paragraph style + * + * @var \PhpWord\PhpOffice\Style\Paragraph + */ + private $paragraphStyle; + + /** + * Get font and paragraph styles + */ + protected function getStyles() + { + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; + + // Font style + if (method_exists($this->element, 'getFontStyle')) { + $this->fontStyle = $this->element->getFontStyle(); + if (is_string($this->fontStyle)) { + $this->fontStyle = Style::getStyle($this->fontStyle); + } + } + + // Paragraph style + if (method_exists($this->element, 'getParagraphStyle')) { + $this->paragraphStyle = $this->element->getParagraphStyle(); + if (is_string($this->paragraphStyle)) { + $this->paragraphStyle = Style::getStyle($this->paragraphStyle); + } + + if ($this->paragraphStyle !== null && !$this->withoutP) { + if ($parentWriter->getLastParagraphStyle() != $this->element->getParagraphStyle()) { + $parentWriter->setLastParagraphStyle($this->element->getParagraphStyle()); + } else { + $parentWriter->setLastParagraphStyle(); + $this->paragraphStyle = null; + } + } else { + $parentWriter->setLastParagraphStyle(); + $this->paragraphStyle = null; + } + } + } + + /** + * Write opening + * + * @return string + */ + protected function writeOpening() + { + if ($this->withoutP || !$this->paragraphStyle instanceof ParagraphStyle) { + return; + } + + $styleWriter = new ParagraphStyleWriter($this->paragraphStyle); + return $styleWriter->write(); + } + + /** + * Write text + * + * @param string $text + * @return string + */ + protected function writeText($text) + { + return String::toUnicode($text); + } + + /** + * Write closing + * + * @return string + */ + protected function writeClosing() + { + if ($this->withoutP) { + return; + } + + return '\par' . PHP_EOL; + } + + /** + * Write font style + * + * @return string + */ + protected function writeFontStyle() + { + if (!$this->fontStyle instanceof FontStyle) { + return ''; + } + + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + $parentWriter = $this->parentWriter; + + // Create style writer and set color/name index + $styleWriter = new FontStyleWriter($this->fontStyle); + if ($this->fontStyle->getColor() != null) { + $colorIndex = array_search($this->fontStyle->getColor(), $parentWriter->getColorTable()); + if ($colorIndex !== false) { + $styleWriter->setColorIndex($colorIndex + 1); + } + } + if ($this->fontStyle->getName() != null) { + $fontIndex = array_search($this->fontStyle->getName(), $parentWriter->getFontTable()); + if ($fontIndex !== false) { + $styleWriter->setNameIndex($fontIndex + 1); + } + } + + // Write style + $content = $styleWriter->write(); + + return $content; + } } diff --git a/src/PhpWord/Writer/RTF/Element/Link.php b/src/PhpWord/Writer/RTF/Element/Link.php index bb87e29111..684f6e65bb 100644 --- a/src/PhpWord/Writer/RTF/Element/Link.php +++ b/src/PhpWord/Writer/RTF/Element/Link.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Shared\String; - /** * Link element RTF writer * @@ -33,21 +31,19 @@ class Link extends AbstractElement */ public function write() { - $element = $this->element; - if (!$element instanceof \PhpOffice\PhpWord\Element\Link) { + if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { return; } + $this->getStyles(); + $content = ''; - if (!$this->withoutP) { - $content .= '{'; - } - $content .= '{\field {\*\fldinst {HYPERLINK "' . $element->getTarget() . '"}}{\\fldrslt {'; - $content .= String::toUnicode($element->getText()); + $content .= $this->writeOpening(); + $content .= '{\field {\*\fldinst {HYPERLINK "' . $this->element->getTarget() . '"}}{\\fldrslt {'; + $content .= $this->writeFontStyle(); + $content .= $this->writeText($this->element->getText()); $content .= '}}}'; - if (!$this->withoutP) { - $content .= '}'; - } + $content .= $this->writeClosing(); return $content; } diff --git a/src/PhpWord/Writer/RTF/Element/ListItem.php b/src/PhpWord/Writer/RTF/Element/ListItem.php new file mode 100644 index 0000000000..96375a4ace --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/ListItem.php @@ -0,0 +1,29 @@ +element instanceof \PhpOffice\PhpWord\Element\Text) { + $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); + if (!$this->element instanceof $elementClass) { return; } - /** @var \PhpOffice\PhpWord\Style\Font $fontStyle Scrutinizer type hint */ - $fontStyle = $this->getFontStyle($this->element); - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ - $parentWriter = $this->parentWriter; + $this->getStyles(); $content = ''; - $content .= $this->writeParagraphStyle($this->element); + $content .= $this->writeOpening(); $content .= '{'; - $content .= $this->writeFontStyle($fontStyle); - if ($fontStyle || $parentWriter->getLastParagraphStyle() != '') { - $content .= ' '; - } - $content .= String::toUnicode($this->element->getText()); + $content .= $this->writeFontStyle(); + $content .= $this->writeText($this->element->getText()); $content .= '}'; - - if (!$this->withoutP) { - $content .= '\par' . PHP_EOL; - } - - return $content; - } - - /** - * Write paragraph style - * - * @return string - */ - private function writeParagraphStyle(TextElement $element) - { - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ - $parentWriter = $this->parentWriter; - $content = ''; - - // Get paragraph style - $paragraphStyle = $element->getParagraphStyle(); - if (is_string($paragraphStyle)) { - $paragraphStyle = Style::getStyle($paragraphStyle); - } - - // Write style when applicable - if ($paragraphStyle && !$this->withoutP) { - if ($parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { - $parentWriter->setLastParagraphStyle($element->getParagraphStyle()); - - $styleWriter = new ParagraphStyleWriter($paragraphStyle); - $content = $styleWriter->write(); - } else { - $parentWriter->setLastParagraphStyle(); - } - } else { - $parentWriter->setLastParagraphStyle(); - } + $content .= $this->writeClosing(); return $content; } - - /** - * Write font style beginning - * - * @param \PhpOffice\PhpWord\Style\Font $style - * @return string - */ - private function writeFontStyle($style) - { - if (!$style instanceof FontStyle) { - return ''; - } - - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ - $parentWriter = $this->parentWriter; - - // Create style writer and set color/name index - $styleWriter = new FontStyleWriter($style); - if ($style->getColor() != null) { - $colorIndex = array_search($style->getColor(), $parentWriter->getColorTable()); - if ($colorIndex !== false) { - $styleWriter->setColorIndex($colorIndex + 1); - } - } - if ($style->getName() != null) { - $fontIndex = array_search($style->getName(), $parentWriter->getFontTable()); - if ($fontIndex !== false) { - $styleWriter->setNameIndex($fontIndex + 1); - } - } - - // Write style - $content = $styleWriter->write(); - - return $content; - } - - /** - * Get font style - * - * @return \PhpOffice\PhpWord\Style\Font - */ - private function getFontStyle(TextElement $element) - { - $fontStyle = $element->getFontStyle(); - if (is_string($fontStyle)) { - $fontStyle = Style::getStyle($fontStyle); - } - - return $fontStyle; - } } diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 8d7324a303..8d70366c01 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -33,12 +33,14 @@ class TextRun extends AbstractElement */ public function write() { - $content = ''; - - $content .= '{\pard\nowidctlpar'; $writer = new Container($this->parentWriter, $this->element); + + $content = ''; + $content .= $this->writeOpening(); + $content .= '{'; $content .= $writer->write(); - $content .= '\par}' . PHP_EOL; + $content .= '}'; + $content .= $this->writeClosing(); return $content; } diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 78bb3c2e4d..998bcedc14 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -20,29 +20,10 @@ use PhpOffice\PhpWord\Shared\String; /** - * TextBreak element RTF writer + * Title element RTF writer; extends from text * - * @since 0.10.0 + * @since 0.11.0 */ -class Title extends AbstractElement +class Title extends Text { - /** - * Write element - * - * @return string - */ - public function write() - { - if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { - return; - } - - $content = ''; - - $content .= '\pard\nowidctlpar '; - $content .= String::toUnicode($this->element->getText()); - $content .= '\par' . PHP_EOL; - - return $content; - } } diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index d14ee9c50b..b70c089f6a 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -63,7 +63,7 @@ public function write() $content .= $this->getValueIf($style->isSuperScript(), '\super'); $content .= $this->getValueIf($style->isSubScript(), '\sub'); - return $content; + return $content . ' '; } /** diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 6349172a70..b936d69777 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -23,7 +23,6 @@ use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Row as RowStyle; -use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Row as RowStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index d996df007c..590e819b47 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -147,9 +147,6 @@ private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style) /** * Write shading - * - * @param int $width - * @param string $unit */ private function writeShading(XMLWriter $xmlWriter, TableStyle $style) { From e03e121e8550700e6fc4c1399b889932ba75d503 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 14 May 2014 00:42:05 +0700 Subject: [PATCH 085/167] #196: RTF link styling fixes --- src/PhpWord/Writer/RTF.php | 1 - .../Writer/RTF/Element/AbstractElement.php | 17 ++++++++++------- src/PhpWord/Writer/RTF/Element/ListItem.php | 2 -- src/PhpWord/Writer/RTF/Element/Text.php | 11 +++++------ src/PhpWord/Writer/RTF/Element/Title.php | 2 -- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 27329db2b0..8670cb40ab 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\Drawing; diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index e6e42c1827..d6b48ca8a5 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -51,26 +51,29 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle protected function getStyles() { /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $parentWriter = $this->parentWriter; + $element = $this->element; // Font style - if (method_exists($this->element, 'getFontStyle')) { - $this->fontStyle = $this->element->getFontStyle(); + if (method_exists($element, 'getFontStyle')) { + $this->fontStyle = $element->getFontStyle(); if (is_string($this->fontStyle)) { $this->fontStyle = Style::getStyle($this->fontStyle); } } // Paragraph style - if (method_exists($this->element, 'getParagraphStyle')) { - $this->paragraphStyle = $this->element->getParagraphStyle(); + if (method_exists($element, 'getParagraphStyle')) { + $this->paragraphStyle = $element->getParagraphStyle(); if (is_string($this->paragraphStyle)) { $this->paragraphStyle = Style::getStyle($this->paragraphStyle); } if ($this->paragraphStyle !== null && !$this->withoutP) { - if ($parentWriter->getLastParagraphStyle() != $this->element->getParagraphStyle()) { - $parentWriter->setLastParagraphStyle($this->element->getParagraphStyle()); + if ($parentWriter->getLastParagraphStyle() != $element->getParagraphStyle()) { + $parentWriter->setLastParagraphStyle($element->getParagraphStyle()); } else { $parentWriter->setLastParagraphStyle(); $this->paragraphStyle = null; @@ -147,7 +150,7 @@ protected function writeFontStyle() if ($this->fontStyle->getName() != null) { $fontIndex = array_search($this->fontStyle->getName(), $parentWriter->getFontTable()); if ($fontIndex !== false) { - $styleWriter->setNameIndex($fontIndex + 1); + $styleWriter->setNameIndex($fontIndex); } } diff --git a/src/PhpWord/Writer/RTF/Element/ListItem.php b/src/PhpWord/Writer/RTF/Element/ListItem.php index 96375a4ace..b795143cdb 100644 --- a/src/PhpWord/Writer/RTF/Element/ListItem.php +++ b/src/PhpWord/Writer/RTF/Element/ListItem.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Shared\String; - /** * ListItem element RTF writer; extends from text * diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 7cefd9652d..cee1b1571f 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -17,10 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Element\Text as TextElement; -use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Style; - /** * Text element RTF writer * @@ -35,8 +31,11 @@ class Text extends AbstractElement */ public function write() { + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); - if (!$this->element instanceof $elementClass) { + $element = $this->element; + if (!$element instanceof $elementClass) { return; } @@ -46,7 +45,7 @@ public function write() $content .= $this->writeOpening(); $content .= '{'; $content .= $this->writeFontStyle(); - $content .= $this->writeText($this->element->getText()); + $content .= $this->writeText($element->getText()); $content .= '}'; $content .= $this->writeClosing(); diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php index 998bcedc14..b9645a6897 100644 --- a/src/PhpWord/Writer/RTF/Element/Title.php +++ b/src/PhpWord/Writer/RTF/Element/Title.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Shared\String; - /** * Title element RTF writer; extends from text * From 6ba6ed40fc6ef42f47aaf7bbc954db4635a57eda Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 14 May 2014 08:40:21 +0700 Subject: [PATCH 086/167] Reactivate php_sim in Scrutinizer and fix some minor issues --- .scrutinizer.yml | 3 ++- src/PhpWord/Shared/XMLReader.php | 21 ++++++++++--------- .../Writer/RTF/Element/AbstractElement.php | 4 ++-- src/PhpWord/Writer/RTF/Element/Text.php | 3 +-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c7d3c9e5db..40cc99a4bf 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,8 @@ tools: enabled: true timeout: 900 php_sim: - min_mass: 16 + enabled: true + min_mass: 30 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 415526ee70..1b9553cbe9 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -96,7 +96,7 @@ public function getElements($path, \DOMElement $contextNode = null) * @param string $path * @return \DOMElement|null */ - public function getElement($path, \DOMElement $contextNode) + public function getElement($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { @@ -113,16 +113,17 @@ public function getElement($path, \DOMElement $contextNode) * @param string $path * @return string|null */ - public function getAttribute($attribute, \DOMElement $contextNode, $path = null) + public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null) { - if (is_null($path)) { - $return = $contextNode->getAttribute($attribute); - } else { + $return = null; + if ($path !== null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { $return = $elements->item(0)->getAttribute($attribute); - } else { - $return = null; + } + } else { + if ($contextNode !== null) { + $return = $contextNode->getAttribute($attribute); } } @@ -135,7 +136,7 @@ public function getAttribute($attribute, \DOMElement $contextNode, $path = null) * @param string $path * @return string|null */ - public function getValue($path, \DOMElement $contextNode) + public function getValue($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { @@ -151,7 +152,7 @@ public function getValue($path, \DOMElement $contextNode) * @param string $path * @return integer */ - public function countElements($path, \DOMElement $contextNode) + public function countElements($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); @@ -164,7 +165,7 @@ public function countElements($path, \DOMElement $contextNode) * @param string $path * @return boolean */ - public function elementExists($path, \DOMElement $contextNode) + public function elementExists($path, \DOMElement $contextNode = null) { return $this->getElements($path, $contextNode)->length > 0; } diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index d6b48ca8a5..89bcfd3775 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -51,9 +51,9 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle protected function getStyles() { /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ - $parentWriter = $this->parentWriter; + + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ $element = $this->element; // Font style diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index cee1b1571f..abdf888dd4 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -32,9 +32,8 @@ class Text extends AbstractElement public function write() { /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ - - $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); $element = $this->element; + $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); if (!$element instanceof $elementClass) { return; } From 7b673af176a715b603f290b697b9f9b57c1996fa Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 14 May 2014 13:39:06 +0200 Subject: [PATCH 087/167] QA : PHP CodeSniffer (PEAR to Composer) --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a7b16860ef..a201a03376 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ }, "require-dev": { "phpunit/phpunit": "3.7.*", - "phpdocumentor/phpdocumentor":"2.*" + "phpdocumentor/phpdocumentor":"2.*", + "squizlabs/php_codesniffer": "1.*" }, "suggest": { "ext-gd2": "Required to add images", From e94e2738e3e774e74967897874f521c8b26b074c Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 14 May 2014 13:40:30 +0200 Subject: [PATCH 088/167] QA : PHP CodeSniffer (PEAR to Composer) --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 190c0a3cdc..4ddf3f5404 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,8 @@ before_script: # - php composer.phar install --prefer-source - composer self-update - composer require dompdf/dompdf:0.6.* + - composer update --prefer-source --dev - composer install --prefer-source --dev - ## PHP_CodeSniffer - - pyrus install pear/PHP_CodeSniffer - - phpenv rehash ## PHP Copy/Paste Detector - curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar ## PHP Mess Detector @@ -48,7 +46,7 @@ before_script: script: ## PHP_CodeSniffer - - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip + - ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP Copy/Paste Detector - php phpcpd.phar src/ tests/ --verbose ## PHP Mess Detector From 04a62f3255a9d99670cd70ed4dae08ae29e46daa Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 14 May 2014 19:41:44 +0700 Subject: [PATCH 089/167] QA: Code cleanup and some additional tests --- src/PhpWord/DocumentProperties.php | 6 ++- src/PhpWord/Element/AbstractContainer.php | 4 ++ src/PhpWord/Element/AbstractElement.php | 1 + src/PhpWord/Element/Image.php | 2 + src/PhpWord/Element/Object.php | 1 + src/PhpWord/Element/PreserveText.php | 2 +- src/PhpWord/Element/Section.php | 1 - src/PhpWord/PhpWord.php | 6 +-- src/PhpWord/Reader/ODText/AbstractPart.php | 2 + src/PhpWord/Reader/Word2007/AbstractPart.php | 12 ++++-- src/PhpWord/Reader/Word2007/Document.php | 8 ++++ src/PhpWord/Reader/Word2007/Numbering.php | 2 + src/PhpWord/Shared/Html.php | 6 ++- src/PhpWord/Shared/XMLReader.php | 7 ++++ src/PhpWord/Shared/ZipArchive.php | 6 ++- src/PhpWord/Style.php | 6 +-- src/PhpWord/Style/AbstractStyle.php | 5 +++ src/PhpWord/Style/Cell.php | 2 + src/PhpWord/Style/Font.php | 2 + src/PhpWord/Style/Paragraph.php | 13 +++++- src/PhpWord/Style/Section.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 2 + src/PhpWord/Writer/HTML.php | 2 +- .../Writer/HTML/Element/AbstractElement.php | 2 + src/PhpWord/Writer/HTML/Element/Container.php | 2 +- src/PhpWord/Writer/HTML/Element/Footnote.php | 4 +- src/PhpWord/Writer/HTML/Element/Image.php | 5 ++- src/PhpWord/Writer/HTML/Element/Link.php | 2 +- src/PhpWord/Writer/HTML/Element/ListItem.php | 2 +- src/PhpWord/Writer/HTML/Element/Table.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 8 ++-- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- .../Writer/HTML/Style/AbstractStyle.php | 2 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/HTML/Style/Image.php | 2 +- src/PhpWord/Writer/HTML/Style/Paragraph.php | 2 +- src/PhpWord/Writer/ODText/Element/Text.php | 2 + .../Writer/ODText/Part/AbstractPart.php | 2 +- src/PhpWord/Writer/ODText/Part/Content.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 2 - src/PhpWord/Writer/PDF.php | 2 + src/PhpWord/Writer/PDF/AbstractRenderer.php | 3 ++ src/PhpWord/Writer/PDF/DomPDF.php | 1 + src/PhpWord/Writer/RTF.php | 2 +- .../Writer/RTF/Element/AbstractElement.php | 16 ++++---- src/PhpWord/Writer/RTF/Element/Link.php | 2 +- src/PhpWord/Writer/RTF/Element/Text.php | 4 +- src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Element/TextRun.php | 2 - .../Writer/RTF/Style/AbstractStyle.php | 2 - src/PhpWord/Writer/RTF/Style/Font.php | 3 +- src/PhpWord/Writer/RTF/Style/Paragraph.php | 2 +- src/PhpWord/Writer/Word2007.php | 2 + .../Word2007/Element/AbstractElement.php | 9 ++-- src/PhpWord/Writer/Word2007/Element/TOC.php | 8 +++- src/PhpWord/Writer/Word2007/Element/Text.php | 4 +- .../Writer/Word2007/Part/ContentTypes.php | 18 ++++---- .../Writer/Word2007/Part/DocPropsApp.php | 2 - .../Writer/Word2007/Part/DocPropsCore.php | 2 - src/PhpWord/Writer/Word2007/Part/Document.php | 1 - .../Writer/Word2007/Part/Footnotes.php | 2 +- .../Writer/Word2007/Part/Numbering.php | 2 +- src/PhpWord/Writer/Word2007/Part/Rels.php | 1 + .../Writer/Word2007/Part/RelsDocument.php | 2 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 2 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 3 +- .../Writer/Word2007/Style/AbstractStyle.php | 1 + src/PhpWord/Writer/Word2007/Style/Image.php | 1 + .../Writer/Word2007/Style/MarginBorder.php | 1 + src/PhpWord/Writer/Word2007/Style/Table.php | 1 + .../PhpWord/Tests/Writer/HTML/ElementTest.php | 10 ++--- tests/PhpWord/Tests/Writer/HTMLTest.php | 1 + .../Tests/Writer/ODText/ElementTest.php | 10 ++--- .../PhpWord/Tests/Writer/RTF/ElementTest.php | 10 ++--- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- .../Tests/Writer/Word2007/ElementTest.php | 10 ++--- .../Writer/Word2007/Part/DocumentTest.php | 17 ++++++-- .../Tests/Writer/Word2007/PartTest.php | 41 +++++++++++++++++++ 78 files changed, 234 insertions(+), 115 deletions(-) create mode 100644 tests/PhpWord/Tests/Writer/Word2007/PartTest.php diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index a2d869b023..17d57c1de5 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -416,8 +416,9 @@ public function getCustomPropertyValue($propertyName) { if ($this->isCustomPropertySet($propertyName)) { return $this->customProperties[$propertyName]['value']; + } else { + return null; } - } /** @@ -430,8 +431,9 @@ public function getCustomPropertyType($propertyName) { if ($this->isCustomPropertySet($propertyName)) { return $this->customProperties[$propertyName]['type']; + } else { + return null; } - } /** diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 6caa00561c..5afddc5f6e 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -313,6 +313,7 @@ public function addTextBox($style = null) * * @param string $method * @return bool + * @throws \BadMethodCallException */ private function checkValidity($method) { @@ -389,6 +390,7 @@ private function getMediaContainer() * * @param string $src * @param mixed $style + * @return \PhpOffice\PhpWord\Element\Image * @deprecated 0.9.0 * @codeCoverageIgnore */ @@ -401,6 +403,7 @@ public function addMemoryImage($src, $style = null) * Create textrun element * * @param mixed $paragraphStyle + * @return \PhpOffice\PhpWord\Element\TextRun * @deprecated 0.10.0 * @codeCoverageIgnore */ @@ -413,6 +416,7 @@ public function createTextRun($paragraphStyle = null) * Create footnote element * * @param mixed $paragraphStyle + * @return \PhpOffice\PhpWord\Element\Footnote * @deprecated 0.10.0 * @codeCoverageIgnore */ diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 40e65c1230..4531136479 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -220,6 +220,7 @@ public function isInSection() * @param mixed $styleObject Style object * @param mixed $styleValue Style value * @param bool $returnObject Always return object + * @return mixed */ protected function setStyle($styleObject, $styleValue = null, $returnObject = false) { diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 6cfd61766f..44829ba5b5 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -283,6 +283,8 @@ public function setMediaIndex($value) * Check memory image, supported type, image functions, and proportional width/height * * @param string $source + * @throws \PhpOffice\PhpWord\Exception\InvalidImageException + * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException */ private function checkImage($source) { diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index a87da019c4..a63c186936 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -58,6 +58,7 @@ class Object extends AbstractElement * * @param string $source * @param mixed $style + * @throws \PhpOffice\PhpWord\Exception\InvalidObjectException */ public function __construct($source, $style = null) { diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 004ffbc3ba..100385c93e 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -54,7 +54,7 @@ class PreserveText extends AbstractElement * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return $this + * @return self */ public function __construct($text = null, $fontStyle = null, $paragraphStyle = null) { diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 8a2b474f91..cfa101cf3c 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Section as SectionSettings; /** diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 50890ad30f..a56578b074 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -301,13 +301,13 @@ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) /** * Adds a heading style definition to styles.xml * - * @param int $titleCount + * @param int $depth * @param mixed $fontStyle * @param mixed $paragraphStyle */ - public function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null) + public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null) { - Style::addTitleStyle($titleCount, $fontStyle, $paragraphStyle); + Style::addTitleStyle($depth, $fontStyle, $paragraphStyle); } /** diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 8ffb9f1bbc..4488492215 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -27,6 +27,8 @@ abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractP /** * Read w:r (override) * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart * @param mixed $paragraphStyle diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index a6efb32924..34088b1700 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -138,12 +138,14 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, /** * Read w:pPr * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @return array|null */ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode) { if (!$xmlReader->elementExists('w:pPr', $domNode)) { - return; + return ''; } $style = array(); @@ -200,19 +202,21 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode /** * Read w:rPr * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @return array|null */ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode) { if (is_null($domNode)) { - return; + return null; } // Hyperlink has an extra w:r child if ($domNode->nodeName == 'w:hyperlink') { $domNode = $xmlReader->getElement('w:r', $domNode); } if (!$xmlReader->elementExists('w:rPr', $domNode)) { - return; + return null; } $style = array(); @@ -272,6 +276,8 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode) /** * Read w:tblPr * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @return string|array|null * @todo Capture w:tblStylePr w:type="firstRow" */ diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index d38b3fb94b..52456cf73f 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -121,6 +121,8 @@ private function readHeaderFooter($settings, &$section) /** * Read w:p * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart * @@ -209,6 +211,8 @@ private function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$par /** * Read w:tbl * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart */ @@ -266,6 +270,8 @@ private function readTable(XMLReader $xmlReader, \DOMElement $domNode, &$parent, /** * Read w:sectPr * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @return array|null */ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode) @@ -326,6 +332,8 @@ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode) /** * Read w:tcPr * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $domNode * @return array|null */ private function readCellStyle(XMLReader $xmlReader, \DOMElement $domNode) diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index 68a36d57ec..81939ae8ef 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -87,6 +87,8 @@ public function read(PhpWord &$phpWord) /** * Read numbering level definition from w:abstractNum and w:num * + * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader + * @param \DOMElement $subnode * @param integer $levelId * @return array */ diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 78f1d99de9..501d24046a 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -52,6 +52,7 @@ public static function addHtml($object, $html) * * @param \DOMNode $node Node to check on attributes and to compile a style array * @param array $style is supplied, the inline style attributes are added to the already existing style + * @return array */ protected static function parseInlineStyle($node, $style = array()) { @@ -91,6 +92,7 @@ protected static function parseInlineStyle($node, $style = array()) } } } + return $style; } @@ -173,7 +175,7 @@ protected static function parseNode( // } break; case 'tr': - /** @var \PhpOffice\PhpWord\Element\Table $object Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Table $object Type hint */ $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); $newobject = $object->addRow(); // if ($attributes->getNamedItem('height') !== null) { @@ -181,7 +183,7 @@ protected static function parseNode( // } break; case 'td': - /** @var \PhpOffice\PhpWord\Element\Row $object Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Row $object Type hint */ $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); // if ($attributes->getNamedItem('width') !== null) { // $newobject=$object->addCell($width=$attributes->getNamedItem('width')->value); diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 1b9553cbe9..6b118c5669 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -47,6 +47,7 @@ class XMLReader * @param string $zipFile * @param string $xmlFile * @return \DOMDocument|false + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function getDomFromZip($zipFile, $xmlFile) { @@ -76,6 +77,7 @@ public function getDomFromZip($zipFile, $xmlFile) * Get elements * * @param string $path + * @param \DOMElement $contextNode * @return \DOMNodeList */ public function getElements($path, \DOMElement $contextNode = null) @@ -94,6 +96,7 @@ public function getElements($path, \DOMElement $contextNode = null) * Get element * * @param string $path + * @param \DOMElement $contextNode * @return \DOMElement|null */ public function getElement($path, \DOMElement $contextNode = null) @@ -110,6 +113,7 @@ public function getElement($path, \DOMElement $contextNode = null) * Get element attribute * * @param string $attribute + * @param \DOMElement $contextNode * @param string $path * @return string|null */ @@ -134,6 +138,7 @@ public function getAttribute($attribute, \DOMElement $contextNode = null, $path * Get element value * * @param string $path + * @param \DOMElement $contextNode * @return string|null */ public function getValue($path, \DOMElement $contextNode = null) @@ -150,6 +155,7 @@ public function getValue($path, \DOMElement $contextNode = null) * Count elements * * @param string $path + * @param \DOMElement $contextNode * @return integer */ public function countElements($path, \DOMElement $contextNode = null) @@ -163,6 +169,7 @@ public function countElements($path, \DOMElement $contextNode = null) * Element exists * * @param string $path + * @param \DOMElement $contextNode * @return boolean */ public function elementExists($path, \DOMElement $contextNode = null) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 8c9f10b83d..84d6ab85f2 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -84,8 +84,9 @@ public function close() /** * Add a new file to the zip archive (emulate \ZipArchive) * - * @param string $filename Directory/Name of the file to add to the zip archive + * @param string $filename Directory/Name of the file to add to the zip archive * @param string $localname Directory/Name of the file added to the zip + * @return bool */ public function addFile($filename, $localname = null) { @@ -117,7 +118,8 @@ public function addFile($filename, $localname = null) * Add a new file to the zip archive from a string of raw data (emulate \ZipArchive) * * @param string $localname Directory/Name of the file to add to the zip archive - * @param string $contents String of data to add to the zip archive + * @param string $contents String of data to add to the zip archive + * @return bool */ public function addFromString($localname, $contents) { diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 25e5785bd5..ef3310d7f5 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -83,13 +83,13 @@ public static function addTableStyle($styleName, $styleTable, $styleFirstRow = n /** * Add title style * - * @param int $titleCount + * @param int $depth * @param array $fontStyle * @param array $paragraphStyle */ - public static function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null) + public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null) { - self::setStyleValues("Heading_{$titleCount}", new Font('title', $paragraphStyle), $fontStyle); + self::setStyleValues("Heading_{$depth}", new Font('title', $paragraphStyle), $fontStyle); } /** diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 5be042bd84..0ac71ab2d3 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -227,6 +227,8 @@ protected function setFloatVal($value, $default = null) * @param mixed $value * @param array $enum * @param mixed $default + * @return mixed + * @throws \InvalidArgumentException */ protected function setEnumVal($value = null, $enum = array(), $default = null) { @@ -245,11 +247,13 @@ protected function setEnumVal($value = null, $enum = array(), $default = null) * @param mixed $value * @param string $styleName * @param mixed $style + * @return mixed */ protected function setObjectVal($value, $styleName, &$style) { $styleClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $styleName; if (is_array($value)) { + /** @var \PhpOffice\PhpWord\Style\AbstractStyle $style Type hint */ if (!$style instanceof $styleClass) { $style = new $styleClass(); } @@ -265,6 +269,7 @@ protected function setObjectVal($value, $styleName, &$style) * Set style using associative array * * @param array $style + * @return self * @deprecated 0.11.0 * @codeCoverageIgnore */ diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index e44ffa38d3..95ed13b4e3 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -146,6 +146,8 @@ public function getBgColor() { if (!is_null($this->shading)) { return $this->shading->getFill(); + } else { + return null; } } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 4fe70068a7..a4d56dd421 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -562,6 +562,8 @@ public function getBgColor() { if (!is_null($this->shading)) { return $this->shading->getFill(); + } else { + return null; } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 9c8e0c5b9d..8609b5abb9 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -127,6 +127,7 @@ public function __construct() * * @param string $key * @param mixed $value + * @return self */ public function setStyleValue($key, $value) { @@ -172,6 +173,8 @@ public function getSpaceBefore() { if (!is_null($this->spacing)) { return $this->spacing->getBefore(); + } else { + return null; } } @@ -195,6 +198,8 @@ public function getSpaceAfter() { if (!is_null($this->spacing)) { return $this->spacing->getAfter(); + } else { + return null; } } @@ -218,6 +223,8 @@ public function getSpacing() { if (!is_null($this->spacing)) { return $this->spacing->getLine(); + } else { + return null; } } @@ -246,7 +253,7 @@ public function getLineHeight() * Set the line height * * @param int|float|string $lineHeight - * @return $this + * @return self * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException */ public function setLineHeight($lineHeight) @@ -273,6 +280,8 @@ public function getIndent() { if (!is_null($this->indentation)) { return $this->indentation->getLeft(); + } else { + return null; } } @@ -296,6 +305,8 @@ public function getHanging() { if (!is_null($this->indentation)) { return $this->indentation->getHanging(); + } else { + return null; } } diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index 8a0c071d74..d47703c296 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -420,7 +420,7 @@ public function getPageNumberingStart() * Set page numbering start * * @param null|int $pageNumberingStart - * @return $this + * @return self */ public function setPageNumberingStart($pageNumberingStart = null) { diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index f1a3002688..bc1c1bf986 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -149,6 +149,7 @@ public function isUseDiskCaching() * @param bool $value * @param string $directory * @return self + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function setUseDiskCaching($value = false, $directory = null) { @@ -257,6 +258,7 @@ protected function clearTempDir() * * @param string $filename * @return mixed ZipArchive object + * @throws \PhpOffice\PhpWord\Exception\Exception */ protected function getZipArchive($filename) { diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index f871bc188f..6c1a534f32 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -19,9 +19,9 @@ use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\HTML\Element\Container; use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter; use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter; diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php index 8da094144e..a5dee60a0c 100644 --- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php +++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php @@ -51,6 +51,8 @@ abstract class AbstractElement /** * Create new instance * + * @param \PhpOffice\PhpWord\Writer\AbstractWriter $parentWriter + * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param bool $withoutP */ public function __construct(AbstractWriter $parentWriter, Element $element, $withoutP = false) diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php index 54ec7ee68a..e9b2d869ac 100644 --- a/src/PhpWord/Writer/HTML/Element/Container.php +++ b/src/PhpWord/Writer/HTML/Element/Container.php @@ -40,7 +40,7 @@ public function write() { $container = $this->element; if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { - return; + return ''; } $containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1); $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false; diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php index ba5ced560d..f59545de10 100644 --- a/src/PhpWord/Writer/HTML/Element/Footnote.php +++ b/src/PhpWord/Writer/HTML/Element/Footnote.php @@ -39,9 +39,9 @@ class Footnote extends AbstractElement public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) { - return; + return ''; } - /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ $parentWriter = $this->parentWriter; $noteId = count($parentWriter->getNotes()) + 1; diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 1d07acd745..361babf30f 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -35,9 +35,9 @@ class Image extends Text public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) { - return; + return ''; } - /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ $parentWriter = $this->parentWriter; $content = ''; @@ -59,6 +59,7 @@ public function write() /** * Get Base64 image data * + * @param \PhpOffice\PhpWord\Element\Image $element * @return string|null */ private function getBase64ImageData(ImageElement $element) diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index 820a1526ff..d1256eb066 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -32,7 +32,7 @@ class Link extends Text public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { - return; + return ''; } $content = ''; diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 8e302b03ad..79a3b393d2 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -32,7 +32,7 @@ class ListItem extends AbstractElement public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) { - return; + return ''; } $text = htmlspecialchars($this->element->getTextObject()->getText()); diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index bd7795efd7..fc5f0d30f6 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -32,7 +32,7 @@ class Table extends AbstractElement public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) { - return; + return ''; } $content = ''; diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 8ace129ca4..44740f724d 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -53,7 +53,7 @@ class Text extends AbstractElement /** * Closing tag * - * @var strings + * @var string */ private $closingTags = ''; @@ -64,7 +64,7 @@ class Text extends AbstractElement */ public function write() { - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; $this->getFontStyle(); @@ -142,7 +142,7 @@ protected function writeClosing() */ private function getParagraphStyle() { - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; $style = ''; if (method_exists($element, 'getParagraphStyle')) { @@ -168,7 +168,7 @@ private function getParagraphStyle() */ private function getFontStyle() { - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; $style = ''; $fontStyle = $element->getFontStyle(); diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 64d47ec2e0..20747bf9ec 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -32,7 +32,7 @@ class Title extends AbstractElement public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) { - return; + return ''; } $tag = 'h' . $this->element->getDepth(); diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index 3b6d99c10b..cd37174aed 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -56,7 +56,7 @@ public function __construct($style = null) public function getStyle() { if (!$this->style instanceof Style && !is_array($this->style)) { - return; + return ''; } return $this->style; diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 33c23f7a61..dc95eb1a0e 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -36,7 +36,7 @@ public function write() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { - return; + return ''; } $css = array(); diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php index db6ac57b3b..13be3665cd 100644 --- a/src/PhpWord/Writer/HTML/Style/Image.php +++ b/src/PhpWord/Writer/HTML/Style/Image.php @@ -33,7 +33,7 @@ public function write() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Image) { - return; + return ''; } $css = array(); diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index cc3ad785f2..4a77e49647 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -35,7 +35,7 @@ public function write() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { - return; + return ''; } $css = array(); diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 6baf32001f..4fc53bfee5 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -17,6 +17,8 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; +use PhpOffice\PhpWord\Exception\Exception; + /** * Text element writer * diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index c5a3b0c6c0..8b53f26b4c 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -19,8 +19,8 @@ use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; /** * ODText writer part abstract diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index f5ae1883dc..bebc5b86da 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -23,8 +23,8 @@ use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Writer\ODText\Element\Container; /** diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index 6ed58213e7..0d2a761aac 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\PhpWord; - /** * ODText meta part writer: meta.xml */ diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index 45e8a412fa..fc4599c925 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -37,6 +37,7 @@ class PDF * Instantiate a new renderer of the configured type within this container class * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function __construct(PhpWord $phpWord) { @@ -62,6 +63,7 @@ public function __construct(PhpWord $phpWord) * @param string $name Renderer library method name * @param mixed[] $arguments Array of arguments to pass to the renderer method * @return mixed Returned data from the PDF renderer wrapper method + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function __call($name, $arguments) { diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index 342cdf5808..4feefdae83 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -90,10 +90,12 @@ public function getFont() * 'arialunicid0-japanese' * * @param string $fontName + * @return self */ public function setFont($fontName) { $this->font = $fontName; + return $this; } @@ -146,6 +148,7 @@ public function setOrientation($pValue = 'default') * * @param string $pFilename Name of the file to save as * @return resource + * @throws \PhpOffice\PhpWord\Exception\Exception */ protected function prepareForSave($pFilename = null) { diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index cf18d7a513..2b8f951f13 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -30,6 +30,7 @@ class DomPDF extends AbstractRenderer implements \PhpOffice\PhpWord\Writer\Write * Create new instance * * @param PhpWord $phpWord PhpWord object + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function __construct(PhpWord $phpWord) { diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 8670cb40ab..888166e69d 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -145,7 +145,7 @@ private function writeDocument() // Set the color tbl group $content .= '{\colortbl '; - foreach ($this->colorTable as $idx => $color) { + foreach ($this->colorTable as $color) { $arrColor = Drawing::htmlToRGB($color); $content .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; } diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index 89bcfd3775..e04aff3cc9 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -18,8 +18,8 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\RTF\Style\Paragraph as ParagraphStyleWriter; @@ -34,14 +34,14 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle /** * Font style * - * @var \PhpWord\PhpOffice\Style\Font + * @var \PhpOffice\PhpWord\Style\Font */ private $fontStyle; /** * Paragraph style * - * @var \PhpWord\PhpOffice\Style\Paragraph + * @var \PhpOffice\PhpWord\Style\Paragraph */ private $paragraphStyle; @@ -50,10 +50,10 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle */ protected function getStyles() { - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */ $parentWriter = $this->parentWriter; - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; // Font style @@ -93,7 +93,7 @@ protected function getStyles() protected function writeOpening() { if ($this->withoutP || !$this->paragraphStyle instanceof ParagraphStyle) { - return; + return ''; } $styleWriter = new ParagraphStyleWriter($this->paragraphStyle); @@ -119,7 +119,7 @@ protected function writeText($text) protected function writeClosing() { if ($this->withoutP) { - return; + return ''; } return '\par' . PHP_EOL; @@ -136,7 +136,7 @@ protected function writeFontStyle() return ''; } - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */ $parentWriter = $this->parentWriter; // Create style writer and set color/name index diff --git a/src/PhpWord/Writer/RTF/Element/Link.php b/src/PhpWord/Writer/RTF/Element/Link.php index 684f6e65bb..22b085886c 100644 --- a/src/PhpWord/Writer/RTF/Element/Link.php +++ b/src/PhpWord/Writer/RTF/Element/Link.php @@ -32,7 +32,7 @@ class Link extends AbstractElement public function write() { if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) { - return; + return ''; } $this->getStyles(); diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index abdf888dd4..38ef4c948c 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -31,11 +31,11 @@ class Text extends AbstractElement */ public function write() { - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); if (!$element instanceof $elementClass) { - return; + return ''; } $this->getStyles(); diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index ff836a88a6..4449be6515 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -31,7 +31,7 @@ class TextBreak extends AbstractElement */ public function write() { - /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */ $parentWriter = $this->parentWriter; $parentWriter->setLastParagraphStyle(); diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php index 8d70366c01..e756371633 100644 --- a/src/PhpWord/Writer/RTF/Element/TextRun.php +++ b/src/PhpWord/Writer/RTF/Element/TextRun.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Writer\RTF\Element\Container; - /** * TextRun element RTF writer * diff --git a/src/PhpWord/Writer/RTF/Style/AbstractStyle.php b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php index 55d6588e2a..6ad31e418a 100644 --- a/src/PhpWord/Writer/RTF/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; -use PhpOffice\PhpWord\Style\AbstractStyle as Style; - /** * Abstract RTF style writer * diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index b70c089f6a..e28cb69176 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Font as FontStyle; /** @@ -46,7 +45,7 @@ public function write() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Font) { - return; + return ''; } $content = ''; diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index 26c62f0208..e5f5d85e5e 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -35,7 +35,7 @@ public function write() { $style = $this->getStyle(); if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { - return; + return ''; } $alignments = array( diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 44317bd2ae..d55cfff542 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -88,6 +88,7 @@ public function __construct(PhpWord $phpWord = null) * Save document by name * * @param string $filename + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function save($filename = null) { @@ -191,6 +192,7 @@ private function addHeaderFooterMedia($objZip, $docPart) /** * Add header/footer content * + * @param \PhpOffice\PhpWord\Element\Section $section * @param mixed $objZip * @param string $elmType header|footer * @param integer $rId diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index bbb2c83e14..be3e8463b0 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -58,6 +58,8 @@ abstract public function write(); /** * Create new instance * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param bool $withoutP */ public function __construct(XMLWriter $xmlWriter, Element $element, $withoutP = false) @@ -81,14 +83,11 @@ protected function getXmlWriter() * Get element * * @return \PhpOffice\PhpWord\Element\AbstractElement + * @throws \PhpOffice\PhpWord\Exception\Exception */ protected function getElement() { - if (!is_null($this->element)) { - return $this->element; - } else { - throw new Exception('No element assigned.'); - } + return $this->element; } /** diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 88dd0dbd57..00da355ee6 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -64,6 +64,8 @@ public function write() /** * Write title * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\TOC $element * @param \PhpOffice\PhpWord\Element\Title $title * @param bool $writeFieldMark */ @@ -130,6 +132,8 @@ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $ /** * Write style * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\TOC $element * @param int $indent */ private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent) @@ -141,8 +145,8 @@ private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent) $xmlWriter->startElement('w:pPr'); // Paragraph - if ($isObject && !is_null($fontStyle->getParagraphStyle())) { - $styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraphStyle()); + if ($isObject && !is_null($fontStyle->getParagraph())) { + $styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraph()); $styleWriter->write(); } diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 5cb33a289c..87a56dd24f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -89,7 +89,7 @@ protected function writeParagraphStyle() { $xmlWriter = $this->getXmlWriter(); - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->getElement(); $paragraphStyle = $element->getParagraphStyle(); $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); @@ -104,7 +104,7 @@ protected function writeFontStyle() { $xmlWriter = $this->getXmlWriter(); - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->getElement(); $fontStyle = $element->getFontStyle(); $styleWriter = new FontStyleWriter($xmlWriter, $fontStyle); diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 417df64dce..c97654bea2 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -32,7 +32,7 @@ class ContentTypes extends AbstractPart */ public function write() { - /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Type hint */ $parentWriter = $this->getParentWriter(); $contentTypes = $parentWriter->getContentTypes(); @@ -82,16 +82,12 @@ public function write() private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault) { foreach ($parts as $partName => $contentType) { - if ($partName != '' && $contentType != '') { - $partType = $isDefault ? 'Default' : 'Override'; - $partAttribute = $isDefault ? 'Extension' : 'PartName'; - $xmlWriter->startElement($partType); - $xmlWriter->writeAttribute($partAttribute, $partName); - $xmlWriter->writeAttribute('ContentType', $contentType); - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } + $partType = $isDefault ? 'Default' : 'Override'; + $partAttribute = $isDefault ? 'Extension' : 'PartName'; + $xmlWriter->startElement($partType); + $xmlWriter->writeAttribute($partAttribute, $partName); + $xmlWriter->writeAttribute('ContentType', $contentType); + $xmlWriter->endElement(); } } } diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php index 17d38a1048..1e6549c52e 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; - /** * Word2007 extended document properties part writer: docProps/app.xml * diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php index 5140084624..2b3bce5a1d 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\PhpWord; - /** * Word2007 core document properties part writer: docProps/core.xml * diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 0f8a16af89..9957033859 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; use PhpOffice\PhpWord\Element\Section; -use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index d7a1caaa24..903e5fe55d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -106,7 +106,7 @@ public function write() $xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // $this->elementNode - /** @var array $elements Scrutinizer type hint */ + /** @var array $elements Type hint */ $elements = $this->elements; foreach ($elements as $element) { if ($element instanceof Footnote) { diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 2678ac5551..6310fbf16d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -18,9 +18,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Numbering as NumberingStyle; use PhpOffice\PhpWord\Style\NumberingLevel; +use PhpOffice\PhpWord\Style; /** * Word2007 numbering part writer: word/numbering.xml diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 44e62013eb..af57a76896 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -97,6 +97,7 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = * @param string $type Relationship type * @param string $target Relationship target * @param string $targetMode Relationship target mode + * @throws \PhpOffice\PhpWord\Exception\Exception */ private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '') { diff --git a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php index 2a58421ccb..744e14f9a2 100644 --- a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php +++ b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php @@ -41,7 +41,7 @@ public function write() ); $xmlWriter = $this->getXmlWriter(); - /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */ + /** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Type hint */ $parentWriter = $this->getParentWriter(); $this->writeRels($xmlWriter, $xmlRels, $parentWriter->getRelationships()); diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index c296581f2e..80a1b4272d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -127,7 +127,7 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) } else { $xmlWriter->startElement($settingKey); - /** @var array $settingValue Scrutinizer type hint */ + /** @var array $settingValue Type hint */ foreach ($settingValue as $childKey => $childValue) { if ($childKey == '@attributes') { foreach ($childValue as $key => $val) { diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 13e07e71c8..09ee43edfa 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -19,9 +19,9 @@ use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Table; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; @@ -155,6 +155,7 @@ public function write() * Write default font and other default styles * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param array $styles */ private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles) diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 06c351175e..ae97b62e70 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -49,6 +49,7 @@ abstract public function write(); /** * Create new instance * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style */ public function __construct(XMLWriter $xmlWriter, $style = null) diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index ecc3fb7b4e..5dde00c83f 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -136,6 +136,7 @@ public function writeW10Wrap() /** * Get element style * + * @param \PhpOffice\PhpWord\Style\Image $style * @return array */ private function getElementStyle(ImageStyle $style) diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index b5c05ca985..23143ef58b 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -71,6 +71,7 @@ public function write() /** * Write side * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $side * @param int $width * @param string $color diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 590e819b47..68a074ead2 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -85,6 +85,7 @@ private function writeStyle(XMLWriter $xmlWriter, TableStyle $style) /** * Write width * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param int $width * @param string $unit */ diff --git a/tests/PhpWord/Tests/Writer/HTML/ElementTest.php b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php index d2ed70ea64..e12193e87f 100644 --- a/tests/PhpWord/Tests/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php @@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $styles = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title'); - foreach ($styles as $style) { - $objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $style; + $elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title'); + foreach ($elements as $element) { + $objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $element; $parentWriter = new HTML(); - $element = new \PhpOffice\PhpWord\Element\PageBreak(); - $object = new $objectClass($parentWriter, $element); + $newElement = new \PhpOffice\PhpWord\Element\PageBreak(); + $object = new $objectClass($parentWriter, $newElement); $this->assertEquals('', $object->write()); } diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 1c2a504960..34e9d2bda4 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -64,6 +64,7 @@ public function testSave() $docProps = $phpWord->getDocumentProperties(); $docProps->setTitle('HTML Test'); + $phpWord->addTitleStyle(1, array('bold' => true)); $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); diff --git a/tests/PhpWord/Tests/Writer/ODText/ElementTest.php b/tests/PhpWord/Tests/Writer/ODText/ElementTest.php index 6354520a61..c5fdfb41b6 100644 --- a/tests/PhpWord/Tests/Writer/ODText/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/ElementTest.php @@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $styles = array('Image', 'Link', 'Table', 'Text'); - foreach ($styles as $style) { - $objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $style; + $elements = array('Image', 'Link', 'Table', 'Text'); + foreach ($elements as $element) { + $objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $element; $xmlWriter = new XMLWriter(); - $element = new \PhpOffice\PhpWord\Element\PageBreak(); - $object = new $objectClass($xmlWriter, $element); + $newElement = new \PhpOffice\PhpWord\Element\PageBreak(); + $object = new $objectClass($xmlWriter, $newElement); $object->write(); $this->assertEquals('', $xmlWriter->getData()); diff --git a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php index b63c8a5ed4..a31117e6b8 100644 --- a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php @@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $styles = array('Container', 'Text', 'Title', 'Link'); - foreach ($styles as $style) { - $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $style; + $elements = array('Container', 'Text', 'Title', 'Link'); + foreach ($elements as $element) { + $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element; $parentWriter = new RTF(); - $element = new \PhpOffice\PhpWord\Element\PageBreak(); - $object = new $objectClass($parentWriter, $element); + $newElement = new \PhpOffice\PhpWord\Element\PageBreak(); + $object = new $objectClass($parentWriter, $newElement); $this->assertEquals('', $object->write()); } diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index ad5a13e112..a8b10bb508 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -59,7 +59,7 @@ public function testSave() $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, - 'color' => 'FF0000', 'fgColor' => 'FF0000')); + 'color' => 'FF0000', 'fgColor' => '00FF00')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 0a9eb4cedc..4d1d7ce217 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -28,15 +28,15 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $styles = array( + $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC' ); - foreach ($styles as $style) { - $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $style; + foreach ($elements as $element) { + $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; $xmlWriter = new XMLWriter(); - $element = new \PhpOffice\PhpWord\Element\PageBreak(); - $object = new $objectClass($xmlWriter, $element); + $newElement = new \PhpOffice\PhpWord\Element\PageBreak(); + $object = new $objectClass($xmlWriter, $newElement); $object->write(); $this->assertEquals('', $xmlWriter->getData()); diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 7798f30e92..ae0fe1d222 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -72,6 +72,7 @@ public function testElements() $section->addListItem('List Item 1', 0); $section->addListItem('List Item 2', 0); $section->addListItem('List Item 3', 0); + $section = $phpWord->addSection(); $section->addTitle('Title 2', 2); $section->addObject($objectSrc); @@ -80,6 +81,7 @@ public function testElements() 'posHorizontalRel' => 'margin', 'posVerticalRel' => 'margin', 'innerMargin' => 10, 'borderSize' => 1, 'borderColor' => '#FF0')); $section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center')); + $section->addListItemRun()->addText('List item run 1'); $doc = TestHelperDOCX::getDocument($phpWord); @@ -113,22 +115,27 @@ public function testElementStyles() { $objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls"; + $tabs = array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)); $phpWord = new PhpWord(); - $phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1 + $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'tabs' => $tabs)); // Style #1 $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true)); // Style #2 $phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3 + $phpWord->addTableStyle('tStyle', array('borderSize' => 1)); $fontStyle = new Font('text', array('align' => 'center')); + $section = $phpWord->addSection(); - $section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4 + $section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #5 $section->addObject($objectSrc, array('align' => 'center')); $section->addTOC($fontStyle); $section->addTitle('Title 1', 1); $section->addTOC('fStyle'); + $table = $section->addTable('tStyle'); + $table->setWidth(100); $doc = TestHelperDOCX::getDocument($phpWord); // List item $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId'); - $this->assertEquals(4, $element->getAttribute('w:val')); + $this->assertEquals(5, $element->getAttribute('w:val')); // Object $element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject'); @@ -497,6 +504,10 @@ public function testWriteCellStyleCellGridSpan() $table->addCell(40); $table->addCell(40); + $table->addRow(); + $cell = $table->addCell(200, array('borderRightColor' => 'FF0000')); + $cell->getStyle()->setGridSpan(5); + $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan'); diff --git a/tests/PhpWord/Tests/Writer/Word2007/PartTest.php b/tests/PhpWord/Tests/Writer/Word2007/PartTest.php new file mode 100644 index 0000000000..8748169dd3 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/Word2007/PartTest.php @@ -0,0 +1,41 @@ +setMedia(array(array('foo' => 'bar'))); + $object->write(); + } +} From 4edf8ed9b4961f1d06ad7d6d0bacfe3e2e714787 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 14 May 2014 20:18:35 +0700 Subject: [PATCH 090/167] Fix unit tests --- tests/PhpWord/Tests/Element/CellTest.php | 2 +- tests/PhpWord/Tests/Element/FooterTest.php | 2 +- tests/PhpWord/Tests/Element/HeaderTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007/PartTest.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/PhpWord/Tests/Element/CellTest.php b/tests/PhpWord/Tests/Element/CellTest.php index af924bc8b0..aa07ec0394 100644 --- a/tests/PhpWord/Tests/Element/CellTest.php +++ b/tests/PhpWord/Tests/Element/CellTest.php @@ -168,7 +168,7 @@ public function testAddImageSectionByUrl() { $oCell = new Cell(); $element = $oCell->addImage( - 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' + 'http://php.net/images/logos/php-med-trans-light.gif' ); $this->assertCount(1, $oCell->getElements()); diff --git a/tests/PhpWord/Tests/Element/FooterTest.php b/tests/PhpWord/Tests/Element/FooterTest.php index d2a76705a5..c5d04b410a 100644 --- a/tests/PhpWord/Tests/Element/FooterTest.php +++ b/tests/PhpWord/Tests/Element/FooterTest.php @@ -119,7 +119,7 @@ public function testAddImageByUrl() { $oFooter = new Footer(1); $element = $oFooter->addImage( - 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' + 'http://php.net/images/logos/php-med-trans-light.gif' ); $this->assertCount(1, $oFooter->getElements()); diff --git a/tests/PhpWord/Tests/Element/HeaderTest.php b/tests/PhpWord/Tests/Element/HeaderTest.php index 5b64b11168..796b24f012 100644 --- a/tests/PhpWord/Tests/Element/HeaderTest.php +++ b/tests/PhpWord/Tests/Element/HeaderTest.php @@ -128,7 +128,7 @@ public function testAddImageByUrl() { $oHeader = new Header(1); $element = $oHeader->addImage( - 'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png' + 'http://php.net/images/logos/php-med-trans-light.gif' ); $this->assertCount(1, $oHeader->getElements()); diff --git a/tests/PhpWord/Tests/Writer/Word2007/PartTest.php b/tests/PhpWord/Tests/Writer/Word2007/PartTest.php index 8748169dd3..c3d2933190 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/PartTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/PartTest.php @@ -14,7 +14,7 @@ * @copyright 2010-2014 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ -namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part; +namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\Writer\Word2007\Part\RelsPart; @@ -35,7 +35,7 @@ class PartTest extends \PHPUnit_Framework_TestCase public function testRelsWriteRelException() { $object = new RelsPart(); - $object->setMedia(array(array('foo' => 'bar'))); + $object->setMedia(array(array('type' => '', 'target' => ''))); $object->write(); } } From e40b377fc8ac55bc48ee1f557c1f7b12ac3f95df Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 14 May 2014 20:36:15 +0700 Subject: [PATCH 091/167] Remove PHP 5.3.3 and 5.6 from Travis allowed failures and update composer.lock file. --- .travis.yml | 2 -- composer.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ddf3f5404..96d8bbee8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ php: matrix: allow_failures: - - php: 5.3.3 - - php: 5.6 - php: hhvm env: diff --git a/composer.lock b/composer.lock index 9bc868ac8e..aab180be2f 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "77631436badcf4f49d673498ab6f1916", + "hash": "d46ea4154e935e4be01ffbad0a67bab2", "packages": [ ], @@ -1863,6 +1863,81 @@ ], "time": "2012-12-21 11:40:51" }, + { + "name": "squizlabs/php_codesniffer", + "version": "1.5.3", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "396178ada8499ec492363587f037125bf7b07fcc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/396178ada8499ec492363587f037125bf7b07fcc", + "reference": "396178ada8499ec492363587f037125bf7b07fcc", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.1.2" + }, + "suggest": { + "phpunit/php-timer": "dev-master" + }, + "bin": [ + "scripts/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-phpcs-fixer": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/CommentParser/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2014-05-01 03:07:07" + }, { "name": "symfony/config", "version": "v2.4.4", From 27fa3ba2337de7be653d516ca688b460c8c481e4 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 15 May 2014 01:13:22 +0700 Subject: [PATCH 092/167] Remove fontStyle parameter from ListItemRun and various small fixes --- .scrutinizer.yml | 1 - CHANGELOG.md | 1 + src/PhpWord/Element/AbstractContainer.php | 5 +- src/PhpWord/Element/ListItemRun.php | 3 +- src/PhpWord/Element/Title.php | 56 ----- src/PhpWord/Style/Border.php | 122 +++++------ src/PhpWord/Style/Table.php | 207 ++++++++++-------- src/PhpWord/Writer/HTML/Element/Text.php | 2 +- .../Word2007/Element/AbstractElement.php | 2 - .../Writer/Word2007/Part/ContentTypes.php | 2 - src/PhpWord/Writer/Word2007/Style/Cell.php | 2 +- src/PhpWord/Writer/Word2007/Style/Section.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 4 +- 13 files changed, 184 insertions(+), 225 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 40cc99a4bf..ab53c762f4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -9,7 +9,6 @@ tools: enabled: true config: standard: PSR2 - php_cpd: true php_mess_detector: enabled: true config: diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b35a2148..3bed301295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - RTF: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 - Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 - RTF: Ability to add links and page breaks in RTF - @ivanlanin GH-196 +- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin ### Bugfixes diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 5afddc5f6e..81dbedc28a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -213,14 +213,13 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n * Add listitemrun element * * @param int $depth - * @param mixed $fontStyle * @param mixed $listStyle * @param mixed $paragraphStyle * @return \PhpOffice\PhpWord\Element\ListItemRun */ - public function addListItemRun($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) + public function addListItemRun($depth = 0, $listStyle = null, $paragraphStyle = null) { - return $this->addElement('ListItemRun', $depth, $fontStyle, $listStyle, $paragraphStyle); + return $this->addElement('ListItemRun', $depth, $listStyle, $paragraphStyle); } /** diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php index 2a2a51afc4..fb219f91fb 100644 --- a/src/PhpWord/Element/ListItemRun.php +++ b/src/PhpWord/Element/ListItemRun.php @@ -48,11 +48,10 @@ class ListItemRun extends TextRun * Create a new ListItem * * @param int $depth - * @param mixed $fontStyle * @param array|string|null $listStyle * @param mixed $paragraphStyle */ - public function __construct($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) + public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null) { $this->depth = $depth; diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 3a1b304968..d5206879dc 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -46,14 +46,6 @@ class Title extends AbstractElement */ private $style; - /** - * Title anchor - * - * @var string - * @deprecated 0.10.0 - */ - private $anchor; - /** * Create a new Title Element * @@ -101,52 +93,4 @@ public function getStyle() { return $this->style; } - - /** - * Set Anchor - * - * @param string $anchor - * @deprecated 0.10.0 - * @codeCoverageIgnore - */ - public function setAnchor($anchor) - { - $this->anchor = $anchor; - } - - /** - * Get Anchor - * - * @return string - * @deprecated 0.10.0 - * @codeCoverageIgnore - */ - public function getAnchor() - { - return '_Toc' . (252634154 + $this->getRelationId()); - } - - /** - * Set Bookmark ID - * - * @param int $value - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function setBookmarkId($value) - { - $this->setRelationId($value); - } - - /** - * Get bookmark ID - * - * @return int - * @deprecated 0.11.0 - * @codeCoverageIgnore - */ - public function getBookmarkId() - { - return $this->getRelationId(); - } } diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index f7c479fe5a..f0fd865040 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -78,22 +78,6 @@ class Border extends AbstractStyle */ protected $borderBottomColor; - /** - * Set border size - * - * @param int|float $value - * @return self - */ - public function setBorderSize($value = null) - { - $this->setBorderTopSize($value); - $this->setBorderLeftSize($value); - $this->setBorderRightSize($value); - $this->setBorderBottomSize($value); - - return $this; - } - /** * Get border size * @@ -110,17 +94,17 @@ public function getBorderSize() } /** - * Set border color + * Set border size * - * @param string $value + * @param int|float $value * @return self */ - public function setBorderColor($value = null) + public function setBorderSize($value = null) { - $this->setBorderTopColor($value); - $this->setBorderLeftColor($value); - $this->setBorderRightColor($value); - $this->setBorderBottomColor($value); + $this->setBorderTopSize($value); + $this->setBorderLeftSize($value); + $this->setBorderRightSize($value); + $this->setBorderBottomSize($value); return $this; } @@ -141,14 +125,17 @@ public function getBorderColor() } /** - * Set border top size + * Set border color * - * @param int|float $value + * @param string $value * @return self */ - public function setBorderTopSize($value = null) + public function setBorderColor($value = null) { - $this->borderTopSize = $value; + $this->setBorderTopColor($value); + $this->setBorderLeftColor($value); + $this->setBorderRightColor($value); + $this->setBorderBottomColor($value); return $this; } @@ -164,14 +151,14 @@ public function getBorderTopSize() } /** - * Set border top color + * Set border top size * - * @param string $value + * @param int|float $value * @return self */ - public function setBorderTopColor($value = null) + public function setBorderTopSize($value = null) { - $this->borderTopColor = $value; + $this->borderTopSize = $this->setNumericVal($value, $this->borderTopSize); return $this; } @@ -187,14 +174,14 @@ public function getBorderTopColor() } /** - * Set border left size + * Set border top color * - * @param int|float $value + * @param string $value * @return self */ - public function setBorderLeftSize($value = null) + public function setBorderTopColor($value = null) { - $this->borderLeftSize = $value; + $this->borderTopColor = $value; return $this; } @@ -210,14 +197,14 @@ public function getBorderLeftSize() } /** - * Set border left color + * Set border left size * - * @param string $value + * @param int|float $value * @return self */ - public function setBorderLeftColor($value = null) + public function setBorderLeftSize($value = null) { - $this->borderLeftColor = $value; + $this->borderLeftSize = $this->setNumericVal($value, $this->borderLeftSize); return $this; } @@ -233,14 +220,14 @@ public function getBorderLeftColor() } /** - * Set border right size + * Set border left color * - * @param int|float $value + * @param string $value * @return self */ - public function setBorderRightSize($value = null) + public function setBorderLeftColor($value = null) { - $this->borderRightSize = $value; + $this->borderLeftColor = $value; return $this; } @@ -256,14 +243,14 @@ public function getBorderRightSize() } /** - * Set border right color + * Set border right size * - * @param string $value + * @param int|float $value * @return self */ - public function setBorderRightColor($value = null) + public function setBorderRightSize($value = null) { - $this->borderRightColor = $value; + $this->borderRightSize = $this->setNumericVal($value, $this->borderRightSize); return $this; } @@ -279,14 +266,14 @@ public function getBorderRightColor() } /** - * Set border bottom size + * Set border right color * - * @param int|float $value + * @param string $value * @return self */ - public function setBorderBottomSize($value = null) + public function setBorderRightColor($value = null) { - $this->borderBottomSize = $value; + $this->borderRightColor = $value; return $this; } @@ -302,14 +289,14 @@ public function getBorderBottomSize() } /** - * Set border bottom color + * Set border bottom size * - * @param string $value + * @param int|float $value * @return self */ - public function setBorderBottomColor($value = null) + public function setBorderBottomSize($value = null) { - $this->borderBottomColor = $value; + $this->borderBottomSize = $this->setNumericVal($value, $this->borderBottomSize); return $this; } @@ -325,20 +312,27 @@ public function getBorderBottomColor() } /** - * Has borders? + * Set border bottom color + * + * @param string $value + * @return self + */ + public function setBorderBottomColor($value = null) + { + $this->borderBottomColor = $value; + + return $this; + } + + /** + * Check if any of the border is not null * * @return bool */ - public function hasBorders() + public function hasBorder() { - $hasBorders = false; $borders = $this->getBorderSize(); - for ($i = 0; $i < count($borders); $i++) { - if (!is_null($borders[$i])) { - $hasBorders = true; - } - } - return $hasBorders; + return $borders !== array_filter($borders, 'is_null'); } } diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c077f499e6..9d5cca8791 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -34,35 +34,35 @@ class Table extends Border * * @var \PhpOffice\PhpWord\Style\Table */ - private $firstRow = null; + private $firstRow; /** * Cell margin top * * @var int */ - private $cellMarginTop = null; + private $cellMarginTop; /** * Cell margin left * * @var int */ - private $cellMarginLeft = null; + private $cellMarginLeft; /** * Cell margin right * * @var int */ - private $cellMarginRight = null; + private $cellMarginRight; /** * Cell margin bottom * * @var int */ - private $cellMarginBottom = null; + private $cellMarginBottom; /** * Border size inside horizontal @@ -123,9 +123,12 @@ class Table extends Border public function __construct($tableStyle = null, $firstRowStyle = null) { $this->alignment = new Alignment(); - if (!is_null($firstRowStyle) && is_array($firstRowStyle)) { - $this->firstRow = clone $this; + if ($tableStyle !== null && is_array($tableStyle)) { + $this->setStyleByArray($tableStyle); + } + if ($firstRowStyle !== null && is_array($firstRowStyle)) { + $this->firstRow = clone $this; unset($this->firstRow->firstRow); unset($this->firstRow->cellMarginBottom); unset($this->firstRow->cellMarginTop); @@ -137,10 +140,6 @@ public function __construct($tableStyle = null, $firstRowStyle = null) unset($this->firstRow->borderInsideHSize); $this->firstRow->setStyleByArray($firstRowStyle); } - - if (!is_null($tableStyle) && is_array($tableStyle)) { - $this->setStyleByArray($tableStyle); - } } /** @@ -162,20 +161,39 @@ public function getBgColor() { if (!is_null($this->shading)) { return $this->shading->getFill(); - } else { - return null; } + + return null; } /** * Set background * * @param string $value - * @return \PhpOffice\PhpWord\Style\Table + * @return self */ public function setBgColor($value = null) { $this->setShading(array('fill' => $value)); + + return $this; + } + + /** + * Get TLRBHV Border Size + * + * @return int[] + */ + public function getBorderSize() + { + return array( + $this->getBorderTopSize(), + $this->getBorderLeftSize(), + $this->getBorderRightSize(), + $this->getBorderBottomSize(), + $this->getBorderInsideHSize(), + $this->getBorderInsideVSize(), + ); } /** @@ -197,19 +215,19 @@ public function setBorderSize($value = null) } /** - * Get TLRBHV Border Size + * Get TLRBHV Border Color * - * @return int[] + * @return string[] */ - public function getBorderSize() + public function getBorderColor() { return array( - $this->getBorderTopSize(), - $this->getBorderLeftSize(), - $this->getBorderRightSize(), - $this->getBorderBottomSize(), - $this->getBorderInsideHSize(), - $this->getBorderInsideVSize(), + $this->getBorderTopColor(), + $this->getBorderLeftColor(), + $this->getBorderRightColor(), + $this->getBorderBottomColor(), + $this->getBorderInsideHColor(), + $this->getBorderInsideVColor(), ); } @@ -232,50 +250,49 @@ public function setBorderColor($value = null) } /** - * Get TLRBHV Border Color + * Get border size inside horizontal * - * @return string[] + * @return int */ - public function getBorderColor() + public function getBorderInsideHSize() { - return array( - $this->getBorderTopColor(), - $this->getBorderLeftColor(), - $this->getBorderRightColor(), - $this->getBorderBottomColor(), - $this->getBorderInsideHColor(), - $this->getBorderInsideVColor(), - ); + return isset($this->borderInsideHSize) ? $this->borderInsideHSize : null; } /** * Set border size inside horizontal * * @param int $value + * @return self */ public function setBorderInsideHSize($value = null) { - $this->borderInsideHSize = $value; + $this->borderInsideHSize = $this->setNumericVal($value, $this->borderInsideHSize); + + return $this; } /** - * Get border size inside horizontal + * Get border color inside horizontal * - * @return int + * @return string */ - public function getBorderInsideHSize() + public function getBorderInsideHColor() { - return (isset($this->borderInsideHSize)) ? $this->borderInsideHSize : null; + return isset($this->borderInsideHColor) ? $this->borderInsideHColor : null; } /** - * Set border size inside vertical + * Set border color inside horizontal * - * @param int $value + * @param string $value + * @return self */ - public function setBorderInsideVSize($value = null) + public function setBorderInsideHColor($value = null) { - $this->borderInsideVSize = $value; + $this->borderInsideHColor = $value ; + + return $this; } /** @@ -285,133 +302,157 @@ public function setBorderInsideVSize($value = null) */ public function getBorderInsideVSize() { - return (isset($this->borderInsideVSize)) ? $this->borderInsideVSize : null; + return isset($this->borderInsideVSize) ? $this->borderInsideVSize : null; } /** - * Set border color inside horizontal + * Set border size inside vertical * - * @param string $value + * @param int $value + * @return self */ - public function setBorderInsideHColor($value = null) + public function setBorderInsideVSize($value = null) { - $this->borderInsideHColor = $value; + $this->borderInsideVSize = $this->setNumericVal($value, $this->borderInsideVSize); + + return $this; } /** - * Get border color inside horizontal + * Get border color inside vertical * * @return string */ - public function getBorderInsideHColor() + public function getBorderInsideVColor() { - return (isset($this->borderInsideHColor)) ? $this->borderInsideHColor : null; + return isset($this->borderInsideVColor) ? $this->borderInsideVColor : null; } /** * Set border color inside vertical * * @param string $value + * @return self */ public function setBorderInsideVColor($value = null) { $this->borderInsideVColor = $value; + + return $this; } /** - * Get border color inside vertical + * Get cell margin top * - * @return string + * @return int */ - public function getBorderInsideVColor() + public function getCellMarginTop() { - return (isset($this->borderInsideVColor)) ? $this->borderInsideVColor : null; + return $this->cellMarginTop; } /** * Set cell margin top * * @param int $value + * @return self */ public function setCellMarginTop($value = null) { - $this->cellMarginTop = $value; + $this->cellMarginTop = $this->setNumericVal($value, $this->cellMarginTop); + + return $this; } /** - * Get cell margin top + * Get cell margin left * * @return int */ - public function getCellMarginTop() + public function getCellMarginLeft() { - return $this->cellMarginTop; + return $this->cellMarginLeft; } /** * Set cell margin left * * @param int $value + * @return self */ public function setCellMarginLeft($value = null) { - $this->cellMarginLeft = $value; + $this->cellMarginLeft = $this->setNumericVal($value, $this->cellMarginLeft); + + return $this; } /** - * Get cell margin left + * Get cell margin right * * @return int */ - public function getCellMarginLeft() + public function getCellMarginRight() { - return $this->cellMarginLeft; + return $this->cellMarginRight; } /** * Set cell margin right * * @param int $value + * @return self */ public function setCellMarginRight($value = null) { - $this->cellMarginRight = $value; + $this->cellMarginRight = $this->setNumericVal($value, $this->cellMarginRight); + + return $this; } /** - * Get cell margin right + * Get cell margin bottom * * @return int */ - public function getCellMarginRight() + public function getCellMarginBottom() { - return $this->cellMarginRight; + return $this->cellMarginBottom; } /** * Set cell margin bottom * * @param int $value + * @return self */ public function setCellMarginBottom($value = null) { - $this->cellMarginBottom = $value; + $this->cellMarginBottom = $this->setNumericVal($value, $this->cellMarginBottom); + + return $this; } /** - * Get cell margin bottom + * Get cell margin * - * @return int + * @return int[] */ - public function getCellMarginBottom() + public function getCellMargin() { - return $this->cellMarginBottom; + return array( + $this->cellMarginTop, + $this->cellMarginLeft, + $this->cellMarginRight, + $this->cellMarginBottom + ); } /** * Set TLRB cell margin * * @param int $value Margin in twips + * @return self */ public function setCellMargin($value = null) { @@ -419,34 +460,20 @@ public function setCellMargin($value = null) $this->setCellMarginLeft($value); $this->setCellMarginRight($value); $this->setCellMarginBottom($value); - } - /** - * Get cell margin - * - * @return int[] - */ - public function getCellMargin() - { - return array($this->cellMarginTop, $this->cellMarginLeft, $this->cellMarginRight, $this->cellMarginBottom); + return $this; } /** - * Has margins? + * Check if any of the margin is not null * * @return bool */ - public function hasMargins() + public function hasMargin() { - $hasMargins = false; $margins = $this->getCellMargin(); - for ($i = 0; $i < count($margins); $i++) { - if (!is_null($margins[$i])) { - $hasMargins = true; - } - } - return $hasMargins; + return $margins !== array_filter($margins, 'is_null'); } /** diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 44740f724d..cbabc645e5 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -145,7 +145,7 @@ private function getParagraphStyle() /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ $element = $this->element; $style = ''; - if (method_exists($element, 'getParagraphStyle')) { + if (!method_exists($element, 'getParagraphStyle')) { return $style; } diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index be3e8463b0..82465afeda 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Element\AbstractElement as Element; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -83,7 +82,6 @@ protected function getXmlWriter() * Get element * * @return \PhpOffice\PhpWord\Element\AbstractElement - * @throws \PhpOffice\PhpWord\Exception\Exception */ protected function getElement() { diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index c97654bea2..f8cb2f26d1 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; /** @@ -77,7 +76,6 @@ public function write() * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer * @param array $parts * @param boolean $isDefault - * @throws \PhpOffice\PhpWord\Exception\Exception */ private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault) { diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index ce7efb3bbc..ae2668aebf 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -59,7 +59,7 @@ public function write() $xmlWriter->writeElementIf(!is_null($vAlign), 'w:vAlign', 'w:val', $vAlign); // Border - if ($style->hasBorders()) { + if ($style->hasBorder()) { $xmlWriter->startElement('w:tcBorders'); $styleWriter = new MarginBorder($xmlWriter); diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index 61658e03e6..5758e3a800 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -66,7 +66,7 @@ public function write() $xmlWriter->endElement(); // Borders - if ($style->hasBorders()) { + if ($style->hasBorder()) { $xmlWriter->startElement('w:pgBorders'); $xmlWriter->writeAttribute('w:offsetFrom', 'page'); diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 68a074ead2..f6babe6da0 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -102,7 +102,7 @@ private function writeWidth(XMLWriter $xmlWriter, $width, $unit) */ private function writeMargin(XMLWriter $xmlWriter, TableStyle $style) { - if ($style->hasMargins()) { + if ($style->hasMargin()) { $xmlWriter->startElement('w:tblCellMar'); $styleWriter = new MarginBorder($xmlWriter); @@ -118,7 +118,7 @@ private function writeMargin(XMLWriter $xmlWriter, TableStyle $style) */ private function writeBorder(XMLWriter $xmlWriter, TableStyle $style) { - if ($style->hasBorders()) { + if ($style->hasBorder()) { $xmlWriter->startElement('w:tblBorders'); $styleWriter = new MarginBorder($xmlWriter); From abbf60a3be97eddfb4d4f58478b8c70a8c934984 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 15 May 2014 10:24:20 +0700 Subject: [PATCH 093/167] Increase minimum mass for php_sim and some test fixes --- .scrutinizer.yml | 2 +- src/PhpWord/Style/Table.php | 17 +++++++------- .../PhpWord/Tests/Element/ListItemRunTest.php | 23 +++++++------------ tests/PhpWord/Tests/Element/TitleTest.php | 12 ---------- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ab53c762f4..ded9a39f2c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,7 @@ tools: timeout: 900 php_sim: enabled: true - min_mass: 30 + min_mass: 40 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 9d5cca8791..4559e677f1 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -123,23 +123,24 @@ class Table extends Border public function __construct($tableStyle = null, $firstRowStyle = null) { $this->alignment = new Alignment(); - if ($tableStyle !== null && is_array($tableStyle)) { - $this->setStyleByArray($tableStyle); - } if ($firstRowStyle !== null && is_array($firstRowStyle)) { $this->firstRow = clone $this; unset($this->firstRow->firstRow); - unset($this->firstRow->cellMarginBottom); + unset($this->firstRow->borderInsideHSize); + unset($this->firstRow->borderInsideHColor); + unset($this->firstRow->borderInsideVSize); + unset($this->firstRow->borderInsideVColor); unset($this->firstRow->cellMarginTop); unset($this->firstRow->cellMarginLeft); unset($this->firstRow->cellMarginRight); - unset($this->firstRow->borderInsideVColor); - unset($this->firstRow->borderInsideVSize); - unset($this->firstRow->borderInsideHColor); - unset($this->firstRow->borderInsideHSize); + unset($this->firstRow->cellMarginBottom); $this->firstRow->setStyleByArray($firstRowStyle); } + + if ($tableStyle !== null && is_array($tableStyle)) { + $this->setStyleByArray($tableStyle); + } } /** diff --git a/tests/PhpWord/Tests/Element/ListItemRunTest.php b/tests/PhpWord/Tests/Element/ListItemRunTest.php index 5b3f72c822..c034a8f890 100644 --- a/tests/PhpWord/Tests/Element/ListItemRunTest.php +++ b/tests/PhpWord/Tests/Element/ListItemRunTest.php @@ -44,7 +44,7 @@ public function testConstructNull() */ public function testConstructString() { - $oListItemRun = new ListItemRun(0, null, null, 'pStyle'); + $oListItemRun = new ListItemRun(0, null, 'pStyle'); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); $this->assertCount(0, $oListItemRun->getElements()); @@ -56,29 +56,22 @@ public function testConstructString() */ public function testConstructArray() { - $oListItemRun = new ListItemRun(0, null, null, array('spacing' => 100)); + $oListItemRun = new ListItemRun(0, null, array('spacing' => 100)); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\ListItemRun', $oListItemRun); $this->assertCount(0, $oListItemRun->getElements()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oListItemRun->getParagraphStyle()); } - + /** * Get style */ public function testStyle() { - $oListItemRun = new ListItemRun( - 1, - null, - array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER) - ); - + $oListItemRun = new ListItemRun(1, array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER)); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItemRun->getStyle()); - $this->assertEquals( - $oListItemRun->getStyle()->getListType(), - \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER - ); + $this->assertEquals($oListItemRun->getStyle()->getListType(), \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER); } /** * getDepth @@ -87,10 +80,10 @@ public function testDepth() { $iVal = rand(1, 1000); $oListItemRun = new ListItemRun($iVal); - + $this->assertEquals($oListItemRun->getDepth(), $iVal); } - + /** * Add text */ diff --git a/tests/PhpWord/Tests/Element/TitleTest.php b/tests/PhpWord/Tests/Element/TitleTest.php index 301d8becf8..ca65c8eb94 100644 --- a/tests/PhpWord/Tests/Element/TitleTest.php +++ b/tests/PhpWord/Tests/Element/TitleTest.php @@ -47,16 +47,4 @@ public function testStyleNull() $this->assertEquals($oTitle->getStyle(), null); } - - /** - * Get bookmark Id - */ - public function testBookmarkID() - { - $oTitle = new Title('text'); - - $iVal = rand(1, 1000); - $oTitle->setBookmarkId($iVal); - $this->assertEquals($oTitle->getRelationId(), $iVal); - } } From 1c3735fc080645324924a4a2639ea7e8378007ff Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 15 May 2014 11:46:28 +0700 Subject: [PATCH 094/167] Refactor table and font styles to reduce duplication --- .scrutinizer.yml | 1 - src/PhpWord/Style/Font.php | 47 ++++------ src/PhpWord/Style/Table.php | 93 ++++++++++++------- .../Tests/Writer/Word2007/Part/StylesTest.php | 19 ++-- 4 files changed, 85 insertions(+), 75 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ded9a39f2c..a35530a9fd 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -17,7 +17,6 @@ tools: enabled: true timeout: 900 php_sim: - enabled: true min_mass: 40 php_pdepend: true php_analyzer: true diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index a4d56dd421..f56a478911 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -404,10 +404,7 @@ public function isSuperScript() */ public function setSuperScript($value = true) { - $this->superScript = $this->setBoolVal($value, $this->superScript); - $this->toggleFalse($this->subScript, $this->superScript); - - return $this; + return $this->setPairedProperty($this->superScript, $this->subScript, $value); } /** @@ -428,10 +425,7 @@ public function isSubScript() */ public function setSubScript($value = true) { - $this->subScript = $this->setBoolVal($value, $this->subScript); - $this->toggleFalse($this->subScript, $this->superScript); - - return $this; + return $this->setPairedProperty($this->subScript, $this->superScript, $value); } /** @@ -452,10 +446,7 @@ public function isStrikethrough() */ public function setStrikethrough($value = true) { - $this->strikethrough = $this->setBoolVal($value, $this->strikethrough); - $this->toggleFalse($this->doubleStrikethrough, $this->strikethrough); - - return $this; + return $this->setPairedProperty($this->strikethrough, $this->doubleStrikethrough, $value); } /** @@ -476,10 +467,7 @@ public function isDoubleStrikethrough() */ public function setDoubleStrikethrough($value = true) { - $this->doubleStrikethrough = $this->setBoolVal($value, $this->doubleStrikethrough); - $this->toggleFalse($this->strikethrough, $this->doubleStrikethrough); - - return $this; + return $this->setPairedProperty($this->doubleStrikethrough, $this->strikethrough, $value); } /** @@ -500,10 +488,7 @@ public function isSmallCaps() */ public function setSmallCaps($value = true) { - $this->smallCaps = $this->setBoolVal($value, $this->smallCaps); - $this->toggleFalse($this->allCaps, $this->smallCaps); - - return $this; + return $this->setPairedProperty($this->smallCaps, $this->allCaps, $value); } /** @@ -524,10 +509,7 @@ public function isAllCaps() */ public function setAllCaps($value = true) { - $this->allCaps = $this->setBoolVal($value, $this->allCaps); - $this->toggleFalse($this->smallCaps, $this->allCaps); - - return $this; + return $this->setPairedProperty($this->allCaps, $this->smallCaps, $value); } /** @@ -648,16 +630,21 @@ public function setShading($value = null) } /** - * Toggle $target property to false when $source true + * Set $property value and set $pairProperty = false when $value = true * - * @param bool|null $target Target property - * @param bool $sourceValue + * @param bool $property + * @param bool $pair + * @param bool $value + * @return self */ - private function toggleFalse(&$target, $sourceValue) + private function setPairedProperty(&$property, &$pairProperty, $value) { - if ($sourceValue == true) { - $target = false; + $property = $this->setBoolVal($value, $property); + if ($value == true) { + $pairProperty = false; } + + return $this; } /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 4559e677f1..32821793dc 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -124,7 +124,8 @@ public function __construct($tableStyle = null, $firstRowStyle = null) { $this->alignment = new Alignment(); - if ($firstRowStyle !== null && is_array($firstRowStyle)) { + // Clone first row from table style, but with certain properties disabled + if ($firstRowStyle !== null && is_array($firstRowStyle)) { $this->firstRow = clone $this; unset($this->firstRow->firstRow); unset($this->firstRow->borderInsideHSize); @@ -257,7 +258,7 @@ public function setBorderColor($value = null) */ public function getBorderInsideHSize() { - return isset($this->borderInsideHSize) ? $this->borderInsideHSize : null; + return $this->getTableOnlyProperty('borderInsideHSize'); } /** @@ -268,9 +269,7 @@ public function getBorderInsideHSize() */ public function setBorderInsideHSize($value = null) { - $this->borderInsideHSize = $this->setNumericVal($value, $this->borderInsideHSize); - - return $this; + return $this->setTableOnlyProperty('borderInsideHSize', $value); } /** @@ -280,7 +279,7 @@ public function setBorderInsideHSize($value = null) */ public function getBorderInsideHColor() { - return isset($this->borderInsideHColor) ? $this->borderInsideHColor : null; + return $this->getTableOnlyProperty('borderInsideHColor'); } /** @@ -291,9 +290,7 @@ public function getBorderInsideHColor() */ public function setBorderInsideHColor($value = null) { - $this->borderInsideHColor = $value ; - - return $this; + return $this->setTableOnlyProperty('borderInsideHColor', $value, false); } /** @@ -303,7 +300,7 @@ public function setBorderInsideHColor($value = null) */ public function getBorderInsideVSize() { - return isset($this->borderInsideVSize) ? $this->borderInsideVSize : null; + return $this->getTableOnlyProperty('borderInsideVSize'); } /** @@ -314,9 +311,7 @@ public function getBorderInsideVSize() */ public function setBorderInsideVSize($value = null) { - $this->borderInsideVSize = $this->setNumericVal($value, $this->borderInsideVSize); - - return $this; + return $this->setTableOnlyProperty('borderInsideVSize', $value); } /** @@ -326,7 +321,7 @@ public function setBorderInsideVSize($value = null) */ public function getBorderInsideVColor() { - return isset($this->borderInsideVColor) ? $this->borderInsideVColor : null; + return $this->getTableOnlyProperty('borderInsideVColor'); } /** @@ -337,9 +332,7 @@ public function getBorderInsideVColor() */ public function setBorderInsideVColor($value = null) { - $this->borderInsideVColor = $value; - - return $this; + return $this->setTableOnlyProperty('borderInsideVColor', $value, false); } /** @@ -349,7 +342,7 @@ public function setBorderInsideVColor($value = null) */ public function getCellMarginTop() { - return $this->cellMarginTop; + return $this->getTableOnlyProperty('cellMarginTop'); } /** @@ -360,9 +353,7 @@ public function getCellMarginTop() */ public function setCellMarginTop($value = null) { - $this->cellMarginTop = $this->setNumericVal($value, $this->cellMarginTop); - - return $this; + return $this->setTableOnlyProperty('cellMarginTop', $value); } /** @@ -372,7 +363,7 @@ public function setCellMarginTop($value = null) */ public function getCellMarginLeft() { - return $this->cellMarginLeft; + return $this->getTableOnlyProperty('cellMarginLeft'); } /** @@ -383,9 +374,7 @@ public function getCellMarginLeft() */ public function setCellMarginLeft($value = null) { - $this->cellMarginLeft = $this->setNumericVal($value, $this->cellMarginLeft); - - return $this; + return $this->setTableOnlyProperty('cellMarginLeft', $value); } /** @@ -395,7 +384,7 @@ public function setCellMarginLeft($value = null) */ public function getCellMarginRight() { - return $this->cellMarginRight; + return $this->getTableOnlyProperty('cellMarginRight'); } /** @@ -406,9 +395,7 @@ public function getCellMarginRight() */ public function setCellMarginRight($value = null) { - $this->cellMarginRight = $this->setNumericVal($value, $this->cellMarginRight); - - return $this; + return $this->setTableOnlyProperty('cellMarginRight', $value); } /** @@ -418,7 +405,7 @@ public function setCellMarginRight($value = null) */ public function getCellMarginBottom() { - return $this->cellMarginBottom; + return $this->getTableOnlyProperty('cellMarginBottom'); } /** @@ -429,9 +416,7 @@ public function getCellMarginBottom() */ public function setCellMarginBottom($value = null) { - $this->cellMarginBottom = $this->setNumericVal($value, $this->cellMarginBottom); - - return $this; + return $this->setTableOnlyProperty('cellMarginBottom', $value); } /** @@ -569,4 +554,46 @@ public function setUnit($value = null) return $this; } + + /** + * Get table style only property by checking if firstRow is set + * + * This is necessary since firstRow style is cloned from table style but + * without certain properties activated, e.g. margins + * + * @param string $property + * @return int|string|null + */ + private function getTableOnlyProperty($property) + { + if (isset($this->firstRow)) { + return $this->$property; + } + + return null; + } + + /** + * Set table style only property by checking if firstRow is set + * + * This is necessary since firstRow style is cloned from table style but + * without certain properties activated, e.g. margins + * + * @param string $property + * @param int|string $value + * @param bool $isNumeric + * @return self + */ + private function setTableOnlyProperty($property, $value, $isNumeric = true) + { + if (isset($this->firstRow)) { + if ($isNumeric) { + $this->$property = $this->setNumericVal($value, $this->$property); + } else { + $this->$property = $value; + } + } + + return $this; + } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php index 795d3e8a1d..103caa81b5 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php @@ -49,22 +49,19 @@ public function testWriteStyles() $rStyle = array('size' => 20); $tStyle = array( 'bgColor' => 'FF0000', - 'cellMarginTop' => 120, - 'cellMarginBottom' => 120, - 'cellMarginLeft' => 120, - 'cellMarginRight' => 120, - 'borderTopSize' => 120, - 'borderBottomSize' => 120, - 'borderLeftSize' => 120, - 'borderRightSize' => 120, - 'borderInsideHSize' => 120, - 'borderInsideVSize' => 120, + 'cellMargin' => 120, + 'borderSize' => 120, + ); + $firstRowStyle = array( + 'bgColor' => '0000FF', + 'borderSize' => 120, + 'borderColor' => '00FF00', ); $phpWord->setDefaultParagraphStyle($pStyle); $phpWord->addParagraphStyle('Base Style', $pBase); $phpWord->addParagraphStyle('New Style', $pNew); $phpWord->addFontStyle('New Style', $rStyle, $pStyle); - $phpWord->addTableStyle('Table Style', $tStyle, $tStyle); + $phpWord->addTableStyle('Table Style', $tStyle, $firstRowStyle); $phpWord->addTitleStyle(1, $rStyle, $pStyle); $doc = TestHelperDOCX::getDocument($phpWord); From 4d9e4062c34df16cb50d64a2f92089856fbf626c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 15 May 2014 14:41:08 +0700 Subject: [PATCH 095/167] QA: Scrutinizer dedup --- src/PhpWord/Reader/AbstractReader.php | 24 ++++---- src/PhpWord/Reader/ODText/AbstractPart.php | 3 +- src/PhpWord/Reader/ReaderInterface.php | 8 +-- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Style/Table.php | 46 +++++++++------ src/PhpWord/Writer/AbstractWriter.php | 2 +- src/PhpWord/Writer/HTML.php | 14 ++--- src/PhpWord/Writer/HTML/Element/Container.php | 4 +- src/PhpWord/Writer/HTML/Element/Image.php | 5 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/ODText.php | 4 -- .../Writer/ODText/Element/AbstractElement.php | 4 +- .../Writer/ODText/Element/Container.php | 4 +- .../Writer/ODText/Part/AbstractPart.php | 3 +- .../Writer/ODText/Style/AbstractStyle.php | 4 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 23 ++++---- src/PhpWord/Writer/PDF/DomPDF.php | 9 +-- src/PhpWord/Writer/RTF.php | 58 ++++++------------- .../Writer/RTF/Element/AbstractElement.php | 3 +- src/PhpWord/Writer/RTF/Element/Container.php | 4 +- .../Writer/RTF/Style/AbstractStyle.php | 4 +- src/PhpWord/Writer/RTF/Style/Font.php | 2 +- src/PhpWord/Writer/Word2007.php | 10 ++-- .../Writer/Word2007/Element/Container.php | 3 +- src/PhpWord/Writer/Word2007/Element/Image.php | 2 +- src/PhpWord/Writer/Word2007/Element/TOC.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 2 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 2 +- src/PhpWord/Writer/Word2007/Style/Image.php | 4 +- src/PhpWord/Writer/Word2007/Style/Section.php | 2 +- src/PhpWord/Writer/Word2007/Style/Table.php | 4 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 6 +- src/PhpWord/Writer/WriterInterface.php | 4 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 12 ---- tests/PhpWord/Tests/Writer/RTFTest.php | 12 ---- tests/PhpWord/Tests/Writer/Word2007Test.php | 12 ---- 36 files changed, 136 insertions(+), 173 deletions(-) diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 73d1866612..a243c5d234 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -54,47 +54,47 @@ public function isReadDataOnly() /** * Set read data only * - * @param bool $pValue + * @param bool $value * @return self */ - public function setReadDataOnly($pValue = true) + public function setReadDataOnly($value = true) { - $this->readDataOnly = $pValue; + $this->readDataOnly = $value; return $this; } /** * Open file for reading * - * @param string $pFilename + * @param string $filename * @return resource * @throws \PhpOffice\PhpWord\Exception\Exception */ - protected function openFile($pFilename) + protected function openFile($filename) { // Check if file exists - if (!file_exists($pFilename) || !is_readable($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + if (!file_exists($filename) || !is_readable($filename)) { + throw new Exception("Could not open " . $filename . " for reading! File does not exist."); } // Open file - $this->fileHandle = fopen($pFilename, 'r'); + $this->fileHandle = fopen($filename, 'r'); if ($this->fileHandle === false) { - throw new Exception("Could not open file " . $pFilename . " for reading."); + throw new Exception("Could not open file " . $filename . " for reading."); } } /** * Can the current ReaderInterface read the file? * - * @param string $pFilename + * @param string $filename * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { // Check if file exists try { - $this->openFile($pFilename); + $this->openFile($filename); } catch (Exception $e) { return false; } diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 4488492215..7a91e12ded 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -18,11 +18,12 @@ namespace PhpOffice\PhpWord\Reader\ODText; use PhpOffice\PhpWord\Shared\XMLReader; +use PhpOffice\PhpWord\Reader\Word2007\AbstractPart as Word2007AbstractPart; /** * Abstract part reader */ -abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractPart +abstract class AbstractPart extends Word2007AbstractPart { /** * Read w:r (override) diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php index f207aa6f65..df663197bc 100644 --- a/src/PhpWord/Reader/ReaderInterface.php +++ b/src/PhpWord/Reader/ReaderInterface.php @@ -25,15 +25,15 @@ interface ReaderInterface /** * Can the current ReaderInterface read the file? * - * @param string $pFilename + * @param string $filename * @return boolean */ - public function canRead($pFilename); + public function canRead($filename); /** * Loads PhpWord from file * - * @param string $pFilename + * @param string $filename */ - public function load($pFilename); + public function load($filename); } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index f56a478911..5440f51257 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -633,7 +633,7 @@ public function setShading($value = null) * Set $property value and set $pairProperty = false when $value = true * * @param bool $property - * @param bool $pair + * @param bool $pairProperty * @param bool $value * @return self */ diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 32821793dc..90e8282fc5 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -29,12 +29,19 @@ class Table extends Border const WIDTH_PERCENT = 'pct'; // Width in fiftieths (1/50) of a percent (1% = 50 unit) const WIDTH_TWIP = 'dxa'; // Width in twentieths (1/20) of a point (twip) + /** + * Is this a first row style? + * + * @var bool + */ + private $isFirstRow = false; + /** * Style for first row * * @var \PhpOffice\PhpWord\Style\Table */ - private $firstRow; + private $firstRowStyle; /** * Cell margin top @@ -126,17 +133,18 @@ public function __construct($tableStyle = null, $firstRowStyle = null) // Clone first row from table style, but with certain properties disabled if ($firstRowStyle !== null && is_array($firstRowStyle)) { - $this->firstRow = clone $this; - unset($this->firstRow->firstRow); - unset($this->firstRow->borderInsideHSize); - unset($this->firstRow->borderInsideHColor); - unset($this->firstRow->borderInsideVSize); - unset($this->firstRow->borderInsideVColor); - unset($this->firstRow->cellMarginTop); - unset($this->firstRow->cellMarginLeft); - unset($this->firstRow->cellMarginRight); - unset($this->firstRow->cellMarginBottom); - $this->firstRow->setStyleByArray($firstRowStyle); + $this->firstRowStyle = clone $this; + $this->firstRowStyle->isFirstRow = true; + unset($this->firstRowStyle->firstRowStyle); + unset($this->firstRowStyle->borderInsideHSize); + unset($this->firstRowStyle->borderInsideHColor); + unset($this->firstRowStyle->borderInsideVSize); + unset($this->firstRowStyle->borderInsideVColor); + unset($this->firstRowStyle->cellMarginTop); + unset($this->firstRowStyle->cellMarginLeft); + unset($this->firstRowStyle->cellMarginRight); + unset($this->firstRowStyle->cellMarginBottom); + $this->firstRowStyle->setStyleByArray($firstRowStyle); } if ($tableStyle !== null && is_array($tableStyle)) { @@ -145,13 +153,13 @@ public function __construct($tableStyle = null, $firstRowStyle = null) } /** - * Get First Row Style + * Set first row * * @return \PhpOffice\PhpWord\Style\Table */ public function getFirstRow() { - return $this->firstRow; + return $this->firstRowStyle; } /** @@ -556,7 +564,7 @@ public function setUnit($value = null) } /** - * Get table style only property by checking if firstRow is set + * Get table style only property by checking if it's a firstRow * * This is necessary since firstRow style is cloned from table style but * without certain properties activated, e.g. margins @@ -566,7 +574,7 @@ public function setUnit($value = null) */ private function getTableOnlyProperty($property) { - if (isset($this->firstRow)) { + if ($this->isFirstRow === false) { return $this->$property; } @@ -574,7 +582,7 @@ private function getTableOnlyProperty($property) } /** - * Set table style only property by checking if firstRow is set + * Set table style only property by checking if it's a firstRow * * This is necessary since firstRow style is cloned from table style but * without certain properties activated, e.g. margins @@ -586,8 +594,8 @@ private function getTableOnlyProperty($property) */ private function setTableOnlyProperty($property, $value, $isNumeric = true) { - if (isset($this->firstRow)) { - if ($isNumeric) { + if ($this->isFirstRow === false) { + if ($isNumeric === true) { $this->$property = $this->setNumericVal($value, $this->$property); } else { $this->$property = $value; diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index bc1c1bf986..628dd04591 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -335,7 +335,7 @@ protected function addFileToPackage($objZip, $source, $target) $source = substr($source, 6); list($zipFilename, $imageFilename) = explode('#', $source); - $zipClass = \PhpOffice\PhpWord\Settings::getZipClass(); + $zipClass = Settings::getZipClass(); $zip = new $zipClass(); if ($zip->open($zipFilename) !== false) { if ($zip->locateName($imageFilename)) { diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 6c1a534f32..db1723aa15 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -62,14 +62,10 @@ public function __construct(PhpWord $phpWord = null) * Save PhpWord to file * * @param string $filename - * @throws Exception + * @throws \PhpOffice\PhpWord\Exception\Exception */ public function save($filename = null) { - if (is_null($this->phpWord)) { - throw new Exception('PhpWord object unassigned.'); - } - $this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/'); $hFile = fopen($filename, 'w'); if ($hFile !== false) { @@ -111,7 +107,8 @@ public function writeDocument() */ private function writeHead() { - $properties = $this->getPhpWord()->getDocumentProperties(); + $phpWord = $this->getPhpWord(); + $properties = $phpWord->getDocumentProperties(); $propertiesMapping = array( 'creator' => 'author', 'title' => '', @@ -171,13 +168,14 @@ private function writeBody() */ private function writeStyles() { + $phpWord = $this->getPhpWord(); $css = '' . PHP_EOL; - - return $css; - } - - /** - * Write footnote/endnote contents as textruns - */ - private function writeNotes() - { - $phpWord = $this->getPhpWord(); - $content = PHP_EOL; - - if (!empty($this->notes)) { - $content .= "
" . PHP_EOL; - foreach ($this->notes as $noteId => $noteMark) { - list($noteType, $noteTypeId) = explode('-', $noteMark); - $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); - $collection = $phpWord->$method()->getItems(); - - if (array_key_exists($noteTypeId, $collection)) { - $element = $collection[$noteTypeId]; - $noteAnchor = ""; - $noteAnchor .= "{$noteId}"; - - $writer = new TextRunWriter($this, $element); - $writer->setOpeningText($noteAnchor); - $content .= $writer->write(); - } - } - } - - return $content; - } - /** * Get is PDF * diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index dafc1c38fc..698b7e86cf 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -88,7 +88,7 @@ private function getBase64ImageData(ImageElement $element) } else { $actualSource = $source; } - if (is_null($actualSource)) { + if ($actualSource === null) { return null; } @@ -100,12 +100,13 @@ private function getBase64ImageData(ImageElement $element) $imageBinary = ob_get_contents(); ob_end_clean(); } else { - if ($fileHandle = fopen($actualSource, 'rb', false)) { + $fileHandle = fopen($actualSource, 'rb', false); + if ($fileHandle !== false) { $imageBinary = fread($fileHandle, filesize($actualSource)); fclose($fileHandle); } } - if (!is_null($imageBinary)) { + if ($imageBinary !== null) { $base64 = chunk_split(base64_encode($imageBinary)); $imageData = 'data:' . $imageType . ';base64,' . $base64; } diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php new file mode 100644 index 0000000000..319aa20fbf --- /dev/null +++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php @@ -0,0 +1,68 @@ +parentWriter = $writer; + } + + /** + * Get parent writer + * + * @return \PhpOffice\PhpWord\Writer\AbstractWriter + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + public function getParentWriter() + { + if ($this->parentWriter !== null) { + return $this->parentWriter; + } else { + throw new Exception('No parent WriterInterface assigned.'); + } + } +} diff --git a/src/PhpWord/Writer/HTML/Part/Body.php b/src/PhpWord/Writer/HTML/Part/Body.php new file mode 100644 index 0000000000..4fd61a834f --- /dev/null +++ b/src/PhpWord/Writer/HTML/Part/Body.php @@ -0,0 +1,89 @@ +getParentWriter()->getPhpWord(); + + $content = ''; + + $content .= '' . PHP_EOL; + $sections = $phpWord->getSections(); + foreach ($sections as $section) { + $writer = new Container($this->getParentWriter(), $section); + $content .= $writer->write(); + } + + $content .= $this->writeNotes(); + $content .= '' . PHP_EOL; + + return $content; + } + + /** + * Write footnote/endnote contents as textruns + * + * @return string + */ + private function writeNotes() + { + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ + $parentWriter = $this->getParentWriter(); + $phpWord = $parentWriter->getPhpWord(); + $notes = $parentWriter->getNotes(); + + $content = ''; + + if (!empty($notes)) { + $content .= "
" . PHP_EOL; + foreach ($notes as $noteId => $noteMark) { + list($noteType, $noteTypeId) = explode('-', $noteMark); + $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); + $collection = $phpWord->$method()->getItems(); + + if (array_key_exists($noteTypeId, $collection)) { + $element = $collection[$noteTypeId]; + $noteAnchor = ""; + $noteAnchor .= "{$noteId}"; + + $writer = new TextRunWriter($this->getParentWriter(), $element); + $writer->setOpeningText($noteAnchor); + $content .= $writer->write(); + } + } + } + + return $content; + } +} diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php new file mode 100644 index 0000000000..389d568b34 --- /dev/null +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -0,0 +1,129 @@ +getParentWriter()->getPhpWord()->getDocumentProperties(); + $propertiesMapping = array( + 'creator' => 'author', + 'title' => '', + 'description' => '', + 'subject' => '', + 'keywords' => '', + 'category' => '', + 'company' => '', + 'manager' => '' + ); + $title = $docProps->getTitle(); + $title = ($title != '') ? $title : 'PHPWord'; + + $content = ''; + + $content .= '' . PHP_EOL; + $content .= '' . PHP_EOL; + $content .= '' . htmlspecialchars($title) . '' . PHP_EOL; + foreach ($propertiesMapping as $key => $value) { + $value = ($value == '') ? $key : $value; + $method = "get" . $key; + if ($docProps->$method() != '') { + $content .= '' . PHP_EOL; + } + } + $content .= $this->writeStyles(); + $content .= '' . PHP_EOL; + + return $content; + } + /** + * Get styles + * + * @return string + */ + private function writeStyles() + { + $css = '' . PHP_EOL; + + return $css; + } +} diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index f7266d1ab0..83b02251cb 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -84,6 +84,7 @@ public function __construct(PhpWord $phpWord) parent::__construct($phpWord); $includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile; if (file_exists($includeFile)) { + /** @noinspection PhpIncludeInspection Dynamic includes */ require_once $includeFile; } else { throw new Exception('Unable to load PDF Rendering library'); diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index aaf412deb3..ef94b26422 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -35,7 +35,8 @@ class RTF extends AbstractWriter implements WriterInterface private $lastParagraphStyle; /** - * Create new RTF writer + * Create new instance + * * @param \PhpOffice\PhpWord\PhpWord $phpWord */ public function __construct(PhpWord $phpWord = null) @@ -52,7 +53,6 @@ public function __construct(PhpWord $phpWord = null) $this->writerParts[strtolower($partName)] = $part; } } - } /** diff --git a/src/PhpWord/Writer/RTF/Part/AbstractPart.php b/src/PhpWord/Writer/RTF/Part/AbstractPart.php index 3a73a22602..b10e5654c7 100644 --- a/src/PhpWord/Writer/RTF/Part/AbstractPart.php +++ b/src/PhpWord/Writer/RTF/Part/AbstractPart.php @@ -17,52 +17,13 @@ namespace PhpOffice\PhpWord\Writer\RTF\Part; -use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Writer\AbstractWriter; +use PhpOffice\PhpWord\Writer\HTML\Part\AbstractPart as HTMLAbstractPart; /** * Abstract RTF part writer * * @since 0.11.0 */ -abstract class AbstractPart +abstract class AbstractPart extends HTMLAbstractPart { - /** - * Parent writer - * - * @var \PhpOffice\PhpWord\Writer\AbstractWriter - */ - private $parentWriter; - - /** - * Write part - * - * @return string - */ - abstract public function write(); - - /** - * Set parent writer - * - * @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer - */ - public function setParentWriter(AbstractWriter $writer = null) - { - $this->parentWriter = $writer; - } - - /** - * Get parent writer - * - * @return \PhpOffice\PhpWord\Writer\AbstractWriter - * @throws \PhpOffice\PhpWord\Exception\Exception - */ - public function getParentWriter() - { - if ($this->parentWriter !== null) { - return $this->parentWriter; - } else { - throw new Exception('No parent WriterInterface assigned.'); - } - } } diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 7d1c81048d..3dad824df1 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -17,8 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; +use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement; use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Container element writer (section, textrun, header, footnote, cell, etc.) @@ -51,36 +53,52 @@ public function write() $elements = $container->getElements(); $elementClass = ''; foreach ($elements as $element) { - $elementClass = substr(get_class($element), strrpos(get_class($element), '\\') + 1); - $writerClass = $this->namespace . '\\' . $elementClass; + $elementClass = $this->writeElement($xmlWriter, $element, $withoutP); + } - // Check it's a page break. No need to write it, instead, flag containers' pageBreakBefore - // to be assigned to the next element - if ($elementClass == 'PageBreak') { - $this->setPageBreakBefore(true); - continue; - } - if (class_exists($writerClass)) { - // Get container's page break before and reset it - $pageBreakBefore = $this->hasPageBreakBefore(); - $this->setPageBreakBefore(false); + // Special case for Cell: They have to contain a w:p element at the end. + // The $elementClass contains the last element name. If it's empty string + // or Table, the last element is not w:p + $writeLastTextBreak = ($containerClass == 'Cell') && ($elementClass == '' || $elementClass == 'Table'); + if ($writeLastTextBreak) { + $writerClass = $this->namespace . '\\TextBreak'; + /** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */ + $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); + $writer->write(); + } + } + + /** + * Write individual element + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\AbstractElement $element + * @param bool $withoutP + * @return string + */ + private function writeElement(XMLWriter $xmlWriter, Element $element, $withoutP) + { + $elementClass = substr(get_class($element), strrpos(get_class($element), '\\') + 1); + $writerClass = $this->namespace . '\\' . $elementClass; - /** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */ - $writer = new $writerClass($xmlWriter, $element, $withoutP); - $writer->setPageBreakBefore($pageBreakBefore); - $writer->write(); - } + // Check it's a page break. No need to write it, instead, flag containers' + // pageBreakBefore to be assigned to the next element + if ($elementClass == 'PageBreak') { + $this->setPageBreakBefore(true); + return $elementClass; } - // Special case for Cell: They have to contain a w:p element at the end. The $elementClass contains - // the last element name. If it's empty string or Table, the last element is not w:p - if ($containerClass == 'Cell') { - if ($elementClass == '' || $elementClass == 'Table') { - $writerClass = $this->namespace . '\\TextBreak'; - /** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */ - $writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP); - $writer->write(); - } + if (class_exists($writerClass)) { + // Get container's page break before and reset it + $pageBreakBefore = $this->hasPageBreakBefore(); + $this->setPageBreakBefore(false); + + /** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */ + $writer = new $writerClass($xmlWriter, $element, $withoutP); + $writer->setPageBreakBefore($pageBreakBefore); + $writer->write(); } + + return $elementClass; } } From a65c3c3cf1d2628502fbf5f766405466f2b20f68 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 23 May 2014 18:32:56 +0700 Subject: [PATCH 134/167] RTF Writer: Ability to write image --- CHANGELOG.md | 1 + docs/intro.rst | 2 +- docs/src/documentation.md | 2 +- src/PhpWord/Element/AbstractContainer.php | 1 + src/PhpWord/Element/Image.php | 59 +++++++++++++++++++++ src/PhpWord/Style/Table.php | 2 +- src/PhpWord/Writer/HTML/Element/Image.php | 63 ++--------------------- src/PhpWord/Writer/HTML/Part/Head.php | 1 - src/PhpWord/Writer/RTF/Element/Image.php | 57 ++++++++++++++++++++ 9 files changed, 124 insertions(+), 64 deletions(-) create mode 100644 src/PhpWord/Writer/RTF/Element/Image.php diff --git a/CHANGELOG.md b/CHANGELOG.md index daaddb6052..68ea9d2ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - Word2007 Writer: Enable the missing custom document properties writer - @ivanlanin - Image: Enable "image float left" - @ivanlanin GH-244 - RTF Writer: Ability to write document properties - @ivanlanin +- RTF Writer: Ability to write image - @ivanlanin ### Bugfixes diff --git a/docs/intro.rst b/docs/intro.rst index 55a0764ca8..a64fb2add6 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -83,7 +83,7 @@ Writers +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Table | ✓ | ✓ | | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| | Image | ✓ | ✓ | | ✓ | | +| | Image | ✓ | ✓ | ✓ | ✓ | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Object | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index dce1f5dbe4..abb8777e97 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -89,7 +89,7 @@ Below are the supported features for each file formats. | | Page Break | ✓ | | ✓ | | | | | List | ✓ | | | | | | | Table | ✓ | ✓ | | ✓ | ✓ | -| | Image | ✓ | ✓ | | ✓ | | +| | Image | ✓ | ✓ | ✓ | ✓ | | | | Object | ✓ | | | | | | | Watermark | ✓ | | | | | | | Table of Contents | ✓ | | | | | diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index f469686dbe..06a94489ef 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -83,6 +83,7 @@ protected function addElement($elementName) $mediaContainer = $this->getMediaContainer(); if (in_array($elementName, array('Link', 'Image', 'Object'))) { if ($elementName == 'Image') { + /** @var \PhpOffice\PhpWord\Element\Image $element Type hint */ $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $element); } else { $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1]); diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 8e30b78c59..c38fda2cbe 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -279,6 +279,65 @@ public function setMediaIndex($value) $this->mediaIndex = $value; } + /** + * Get image string data + * + * @param bool $base64 + * @return string|null + */ + public function getImageStringData($base64 = false) + { + $source = $this->source; + $actualSource = null; + $imageBinary = null; + $imageData = null; + + // Get actual source from archive image or other source + // Return null if not found + if ($this->sourceType == self::SOURCE_ARCHIVE) { + $source = substr($source, 6); + list($zipFilename, $imageFilename) = explode('#', $source); + + $zip = new ZipArchive(); + if ($zip->open($zipFilename) !== false) { + if ($zip->locateName($imageFilename)) { + $zip->extractTo(sys_get_temp_dir(), $imageFilename); + $actualSource = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $imageFilename; + } + } + $zip->close(); + } else { + $actualSource = $source; + } + if ($actualSource === null) { + return null; + } + + // Read image binary data and convert to hex + if ($this->sourceType == self::SOURCE_GD) { + $imageResource = call_user_func($this->imageCreateFunc, $actualSource); + ob_start(); + call_user_func($this->imageFunc, $imageResource); + $imageBinary = ob_get_contents(); + ob_end_clean(); + } else { + $fileHandle = fopen($actualSource, 'rb', false); + if ($fileHandle !== false) { + $imageBinary = fread($fileHandle, filesize($actualSource)); + fclose($fileHandle); + } + } + if ($imageBinary !== null) { + if ($base64) { + $imageData = chunk_split(base64_encode($imageBinary)); + } else { + $imageData = chunk_split(bin2hex($imageBinary)); + } + } + + return $imageData; + } + /** * Check memory image, supported type, image functions, and proportional width/height * diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 68b53463ab..90e8282fc5 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -430,7 +430,7 @@ public function setCellMarginBottom($value = null) /** * Get cell margin * - * @return integer[] + * @return int[] */ public function getCellMargin() { diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php index 698b7e86cf..ab78990bd4 100644 --- a/src/PhpWord/Writer/HTML/Element/Image.php +++ b/src/PhpWord/Writer/HTML/Element/Image.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\HTML\Element; use PhpOffice\PhpWord\Element\Image as ImageElement; -use PhpOffice\PhpWord\Shared\ZipArchive; use PhpOffice\PhpWord\Writer\HTML\Style\Image as ImageStyleWriter; /** @@ -43,10 +42,11 @@ public function write() $content = ''; if (!$parentWriter->isPdf()) { - $imageData = $this->getBase64ImageData($this->element); - if (!is_null($imageData)) { + $imageData = $this->element->getImageStringData(true); + if ($imageData !== null) { $styleWriter = new ImageStyleWriter($this->element->getStyle()); $style = $styleWriter->write(); + $imageData = 'data:' . $this->element->getImageType() . ';base64,' . $imageData; $content .= $this->writeOpening(); $content .= ""; @@ -56,61 +56,4 @@ public function write() return $content; } - - /** - * Get Base64 image data - * - * @param \PhpOffice\PhpWord\Element\Image $element - * @return string|null - */ - private function getBase64ImageData(ImageElement $element) - { - $source = $element->getSource(); - $imageType = $element->getImageType(); - $imageData = null; - $imageBinary = null; - $actualSource = null; - - // Get actual source from archive image or other source - // Return null if not found - if ($element->getSourceType() == ImageElement::SOURCE_ARCHIVE) { - $source = substr($source, 6); - list($zipFilename, $imageFilename) = explode('#', $source); - - $zip = new ZipArchive(); - if ($zip->open($zipFilename) !== false) { - if ($zip->locateName($imageFilename)) { - $zip->extractTo($this->parentWriter->getTempDir(), $imageFilename); - $actualSource = $this->parentWriter->getTempDir() . DIRECTORY_SEPARATOR . $imageFilename; - } - } - $zip->close(); - } else { - $actualSource = $source; - } - if ($actualSource === null) { - return null; - } - - // Read image binary data and convert into Base64 - if ($element->getSourceType() == ImageElement::SOURCE_GD) { - $imageResource = call_user_func($element->getImageCreateFunction(), $actualSource); - ob_start(); - call_user_func($element->getImageFunction(), $imageResource); - $imageBinary = ob_get_contents(); - ob_end_clean(); - } else { - $fileHandle = fopen($actualSource, 'rb', false); - if ($fileHandle !== false) { - $imageBinary = fread($fileHandle, filesize($actualSource)); - fclose($fileHandle); - } - } - if ($imageBinary !== null) { - $base64 = chunk_split(base64_encode($imageBinary)); - $imageData = 'data:' . $imageType . ';base64,' . $base64; - } - - return $imageData; - } } diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index 389d568b34..edbc8dcf7f 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -32,7 +32,6 @@ */ class Head extends AbstractPart { - /** * Write part * diff --git a/src/PhpWord/Writer/RTF/Element/Image.php b/src/PhpWord/Writer/RTF/Element/Image.php new file mode 100644 index 0000000000..1daae2a0f3 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/Image.php @@ -0,0 +1,57 @@ +element instanceof ImageElement) { + return ''; + } + + $this->getStyles(); + $style = $this->element->getStyle(); + + $content = ''; + $content .= $this->writeOpening(); + $content .= '{\*\shppict {\pict'; + $content .= '\pngblip\picscalex100\picscaley100'; + $content .= '\picwgoal' . round(Font::pixelSizeToTwips($style->getWidth())); + $content .= '\pichgoal' . round(Font::pixelSizeToTwips($style->getHeight())); + $content .= PHP_EOL; + $content .= $this->element->getImageStringData(); + $content .= '}}'; + $content .= $this->writeClosing(); + + return $content; + } +} From 991016a48b73d566dce6bc6982c81a2378bbe1fb Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 24 May 2014 00:11:06 +0700 Subject: [PATCH 135/167] Additional writer test --- src/PhpWord/Shared/String.php | 4 ++-- src/PhpWord/Writer/ODText/Part/Content.php | 10 ++++++---- tests/PhpWord/Tests/Writer/HTMLTest.php | 4 ++-- tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php | 8 +++++--- tests/PhpWord/Tests/Writer/ODText/StyleTest.php | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 99b8cca35a..1e4504cc01 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -86,7 +86,7 @@ public static function toUTF8($value = '') } /** - * Returns unicode array from UTF8 text + * Returns unicode from UTF8 text * * The function is splitted to reduce cyclomatic complexity * @@ -100,7 +100,7 @@ public static function toUnicode($text) } /** - * Returns unicode from UTF8 text + * Returns unicode array from UTF8 text * * @param string $text UTF8 text * @return array diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 900edfdd15..f16937a0e2 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -115,12 +115,14 @@ private function writeAutoStyles(XMLWriter $xmlWriter) $xmlWriter->startElement('office:automatic-styles'); $this->writeTextStyles($xmlWriter); - foreach ($this->autoStyles as $element => $style) { + foreach ($this->autoStyles as $element => $styles) { $writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element; + foreach ($styles as $style) { - /** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */ - $styleWriter = new $writerClass($xmlWriter, $style); - $styleWriter->write(); + /** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */ + $styleWriter = new $writerClass($xmlWriter, $style); + $styleWriter->write(); + } } $xmlWriter->endElement(); // office:automatic-styles diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 34e9d2bda4..0a59b3df94 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -92,8 +92,8 @@ public function testSave() $textrun = $section->addTextRun('Paragraph'); $textrun->addLink('http://test.com'); $textrun->addImage($localImage); - $textrun->addFootnote(); - $textrun->addEndnote(); + $textrun->addFootnote()->addText('Footnote'); + $textrun->addEndnote()->addText('Endnote'); $section = $phpWord->addSection(); diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index 03f0cfebf7..42c95bcb32 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -51,7 +51,7 @@ public function testWriteContent() $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $phpWord->addSection(); + $section = $phpWord->addSection(array('colsNum' => 2)); $section->addText($expected); $section->addText('Test font style', 'Font'); $section->addText('Test paragraph style', null, 'Paragraph'); @@ -60,14 +60,14 @@ public function testWriteContent() $section->addTextBreak(); $section->addPageBreak(); $section->addListItem('Test list item'); - $section->addImage($imageSrc); + $section->addImage($imageSrc, array('width' => 50)); $section->addObject($objectSrc); $section->addTOC(); $textrun = $section->addTextRun(); $textrun->addText('Test text run'); - $table = $section->addTable(); + $table = $section->addTable(array('width' => 50)); $cell = $table->addRow()->addCell(); $cell = $table->addRow()->addCell(); $cell->addText('Test'); @@ -82,6 +82,8 @@ public function testWriteContent() $footer = $section->addFooter(); $footer->addPreserveText('{PAGE}'); + $table = $section->addTable('tblStyle')->addRow()->addCell(); + $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); $element = "/office:document-content/office:body/office:text/text:section/text:p"; diff --git a/tests/PhpWord/Tests/Writer/ODText/StyleTest.php b/tests/PhpWord/Tests/Writer/ODText/StyleTest.php index 387accfcfe..cd5ea0eb15 100644 --- a/tests/PhpWord/Tests/Writer/ODText/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/StyleTest.php @@ -28,7 +28,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase */ public function testEmptyStyles() { - $styles = array('Font', 'Paragraph'); + $styles = array('Font', 'Paragraph', 'Image', 'Section', 'Table'); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style; $xmlWriter = new XMLWriter(); From 248d82d3c300ef5881ede2e29787207c94cb368e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 24 May 2014 10:53:09 +0700 Subject: [PATCH 136/167] Add two recipes --- docs/recipes.rst | 39 +++++++++++++++++++++++++++++++++++++++ docs/src/documentation.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/docs/recipes.rst b/docs/recipes.rst index 033452b3de..d900af8a4b 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -2,3 +2,42 @@ Recipes ======= + +Create float left image +----------------------- + +Use absolute positioning relative to margin horizontally and to line +vertically. + +.. code-block:: php + + $imageStyle = array( + 'width' => 40, + 'height' => 40 + 'wrappingStyle' => 'square', + 'positioning' => 'absolute', + 'posHorizontalRel' => 'margin', + 'posVerticalRel' => 'line', + ); + $textrun->addImage('resources/_earth.jpg', $imageStyle); + $textrun->addText($lipsumText); + +Download the produced file automatically +---------------------------------------- + +Use ``php://output`` as the filename. + +.. code-block:: php + + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $section = $phpWord->createSection(); + $section->addText('Hello World!'); + $file = 'HelloWorld.docx'; + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="' . $file . '"'); + header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); + header('Content-Transfer-Encoding: binary'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Expires: 0'); + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); + $xmlWriter->save("php://output"); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index abb8777e97..6d34ff9fbb 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -40,6 +40,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [RTF](#rtf) - [HTML](#html) - [PDF](#pdf) +- [Recipes](#recipes) - [Frequently asked questions](#frequently-asked-questions) - [References](#references) @@ -929,6 +930,44 @@ To be completed. To be completed. +# Recipes + +## Create float left image + +Use absolute positioning relative to margin horizontally and to line vertically. + +```php +$imageStyle = array( + 'width' => 40, + 'height' => 40 + 'wrappingStyle' => 'square', + 'positioning' => 'absolute', + 'posHorizontalRel' => 'margin', + 'posVerticalRel' => 'line', +); +$textrun->addImage('resources/_earth.jpg', $imageStyle); +$textrun->addText($lipsumText); +``` + +## Download the produced file automatically + +Use `php://output` as the filename. + +```php +$phpWord = new \PhpOffice\PhpWord\PhpWord(); +$section = $phpWord->createSection(); +$section->addText('Hello World!'); +$file = 'HelloWorld.docx'; +header("Content-Description: File Transfer"); +header('Content-Disposition: attachment; filename="' . $file . '"'); +header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); +header('Content-Transfer-Encoding: binary'); +header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); +header('Expires: 0'); +$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); +$xmlWriter->save("php://output"); +``` + # Frequently asked questions ## Is this the same with PHPWord that I found in CodePlex? From 5ff47f44e982f510b00b4256f985455b077d077c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 24 May 2014 11:11:12 +0700 Subject: [PATCH 137/167] QA: Misc. bugfixes and docblock improvements --- src/PhpWord/Style/Border.php | 2 +- src/PhpWord/Style/Table.php | 4 ++-- src/PhpWord/Style/TextBox.php | 2 +- src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 4 ++-- tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php index f0fd865040..84116d7a70 100644 --- a/src/PhpWord/Style/Border.php +++ b/src/PhpWord/Style/Border.php @@ -81,7 +81,7 @@ class Border extends AbstractStyle /** * Get border size * - * @return int[] + * @return integer[] */ public function getBorderSize() { diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 90e8282fc5..9875cc2662 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -192,7 +192,7 @@ public function setBgColor($value = null) /** * Get TLRBHV Border Size * - * @return int[] + * @return integer[] */ public function getBorderSize() { @@ -430,7 +430,7 @@ public function setCellMarginBottom($value = null) /** * Get cell margin * - * @return int[] + * @return integer[] */ public function getCellMargin() { diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index da19cd101f..eb215c06d4 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -162,7 +162,7 @@ public function setInnerMargin($value = null) /** * Get cell margin * - * @return int[] + * @return integer[] */ public function getInnerMargin() { diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 23143ef58b..88bb010972 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -29,7 +29,7 @@ class MarginBorder extends AbstractStyle /** * Sizes * - * @var int[] + * @var integer[] */ private $sizes = array(); @@ -103,7 +103,7 @@ private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null) /** * Set sizes * - * @param int[] $value + * @param integer[] $value */ public function setSizes($value) { diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index 42c95bcb32..f75946ccab 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -50,6 +50,7 @@ public function testWriteContent() $phpWord->setDefaultFontName('Verdana'); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); + $phpWord->addTableStyle('tblStyle', array('width' => 100)); $section = $phpWord->addSection(array('colsNum' => 2)); $section->addText($expected); From 1e9a498ca20f0619fb752b52dbdec4c61bc96cf6 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 24 May 2014 13:48:27 +0700 Subject: [PATCH 138/167] QA: Reduce some complexities: https://scrutinizer-ci.com/g/PHPOffice/PHPWord/code-structure/develop?elementType=operation --- src/PhpWord/Element/AbstractContainer.php | 32 ++---- src/PhpWord/Element/Image.php | 10 +- src/PhpWord/Media.php | 42 +++++--- src/PhpWord/Reader/Word2007/AbstractPart.php | 40 ++++--- src/PhpWord/Shared/Html.php | 4 +- .../Writer/Word2007/Element/TextBreak.php | 6 +- .../Writer/Word2007/Part/Numbering.php | 100 ++++++++++-------- src/PhpWord/Writer/Word2007/Part/Rels.php | 52 +++++---- src/PhpWord/Writer/Word2007/Part/RelsPart.php | 2 +- 9 files changed, 166 insertions(+), 122 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 06a94489ef..dc87cf1880 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -56,38 +56,24 @@ protected function addElement($elementName) // Get arguments $args = func_get_args(); - $argsCount = func_num_args(); $withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')); if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) { - $args[3] = null; + $args[3] = null; // Remove paragraph style for texts in textrun } - // Create element dynamically - + // Create element using reflection + $reflection = new \ReflectionClass($elementClass); + $elementArgs = $args; + array_shift($elementArgs); // Shift an element off the beginning of array: the $elementName /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */ - if ($argsCount == 2) { // TextRun, TextBox, Table, Footnote, Endnote - $element = new $elementClass($args[1]); - } elseif ($argsCount == 3) { // Object, TextBreak, Title - $element = new $elementClass($args[1], $args[2]); - } elseif ($argsCount == 4) { // PreserveText, Text, Image - $element = new $elementClass($args[1], $args[2], $args[3]); - } elseif ($argsCount == 5) { // CheckBox, Link, ListItemRun, TOC - $element = new $elementClass($args[1], $args[2], $args[3], $args[4]); - } elseif ($argsCount == 6) { // ListItem - $element = new $elementClass($args[1], $args[2], $args[3], $args[4], $args[5]); - } else { // Page Break - $element = new $elementClass(); - } + $element = $reflection->newInstanceArgs($elementArgs); // Set relation Id for media collection $mediaContainer = $this->getMediaContainer(); if (in_array($elementName, array('Link', 'Image', 'Object'))) { - if ($elementName == 'Image') { - /** @var \PhpOffice\PhpWord\Element\Image $element Type hint */ - $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $element); - } else { - $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1]); - } + /** @var \PhpOffice\PhpWord\Element\Image $element Type hint */ + $image = ($elementName == 'Image') ? $element : null; + $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $image); $element->setRelationId($rId); } if ($elementName == 'Object') { diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index c38fda2cbe..de859ad285 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -284,6 +284,7 @@ public function setMediaIndex($value) * * @param bool $base64 * @return string|null + * @since 0.11.0 */ public function getImageStringData($base64 = false) { @@ -291,6 +292,7 @@ public function getImageStringData($base64 = false) $actualSource = null; $imageBinary = null; $imageData = null; + $isTemp = false; // Get actual source from archive image or other source // Return null if not found @@ -301,6 +303,7 @@ public function getImageStringData($base64 = false) $zip = new ZipArchive(); if ($zip->open($zipFilename) !== false) { if ($zip->locateName($imageFilename)) { + $isTemp = true; $zip->extractTo(sys_get_temp_dir(), $imageFilename); $actualSource = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $imageFilename; } @@ -313,7 +316,7 @@ public function getImageStringData($base64 = false) return null; } - // Read image binary data and convert to hex + // Read image binary data and convert to hex/base64 string if ($this->sourceType == self::SOURCE_GD) { $imageResource = call_user_func($this->imageCreateFunc, $actualSource); ob_start(); @@ -335,6 +338,11 @@ public function getImageStringData($base64 = false) } } + // Delete temporary file if necessary + if ($isTemp === true) { + @unlink($actualSource); + } + return $imageData; } diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 8cb8201370..7f35841c43 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -139,37 +139,53 @@ public static function countElements($container, $mediaType = null) * Get media elements * * @param string $container section|headerx|footerx|footnote|endnote - * @param string $mediaType image|object|link + * @param string $type image|object|link * @return array * @since 0.10.0 */ - public static function getElements($container, $mediaType = null) + public static function getElements($container, $type = null) { - $mediaElements = array(); + $elements = array(); // If header/footer, search for headerx and footerx where x is number if ($container == 'header' || $container == 'footer') { foreach (self::$elements as $key => $val) { if (substr($key, 0, 6) == $container) { - $mediaElements[$key] = $val; + $elements[$key] = $val; } } + return $elements; } else { if (!array_key_exists($container, self::$elements)) { - return $mediaElements; + return $elements; } - foreach (self::$elements[$container] as $mediaKey => $mediaData) { - if (!is_null($mediaType)) { - if ($mediaType == $mediaData['type']) { - $mediaElements[$mediaKey] = $mediaData; - } - } else { - $mediaElements[$mediaKey] = $mediaData; + return self::getElementsByType($container, $type); + } + } + + /** + * Get elements by media type + * + * @param string $container section|footnote|endnote + * @param string $type image|object|link + * @return array + * @since 0.11.0 Splitted from `getElements` to reduce complexity + */ + private static function getElementsByType($container, $type = null) + { + $elements = array(); + + foreach (self::$elements[$container] as $key => $data) { + if ($type !== null) { + if ($type == $data['type']) { + $elements[$key] = $data; } + } else { + $elements[$key] = $data; } } - return $mediaElements; + return $elements; } /** diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 2936884f0a..8f14daed1c 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -453,25 +453,41 @@ protected function readStyleDefs(XMLReader $xmlReader, \DOMElement $parentNode = $attribute = ($attribute === null) ? 'w:val' : $attribute; $attributeValue = $xmlReader->getAttribute($attribute, $node); - // Assign style value based on conversion model - if ($method == self::READ_VALUE) { - $styles[$styleProp] = $attributeValue; - } elseif ($method == self::READ_SIZE) { - $styles[$styleProp] = $attributeValue / 2; - } elseif ($method == self::READ_TRUE) { - $styles[$styleProp] = true; - } elseif ($method == self::READ_FALSE) { - $styles[$styleProp] = false; - } elseif ($method == self::READ_EQUAL && $attributeValue == $expected) { - $styles[$styleProp] = true; + $styleValue = $this->readStyleDef($method, $attributeValue, $expected); + if ($styleValue !== null) { + $styles[$styleProp] = $styleValue; } } } - /** @var array $styles Type hint */ return $styles; } + /** + * Return style definition based on conversion method + * + * @param string $method + * @param mixed $attributeValue + * @param mixed $expected + * @return mixed + */ + private function readStyleDef($method, $attributeValue, $expected) + { + $style = $attributeValue; + + if ($method == self::READ_SIZE) { + $style = $attributeValue / 2; + } elseif ($method == self::READ_TRUE) { + $style = true; + } elseif ($method == self::READ_FALSE) { + $style = false; + } elseif ($method == self::READ_EQUAL && $attributeValue == $expected) { + $style = true; + } + + return $style; + } + /** * Returns the target of image, object, or link as stored in ::readMainRels * diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 501d24046a..4faacfb1a6 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -214,7 +214,7 @@ protected static function parseNode( */ case 'li': $cNodes = $node->childNodes; - if (count($cNodes) > 0) { + if ($cNodes->length > 0) { $text = ''; foreach ($cNodes as $cNode) { if ($cNode->nodeName == '#text') { @@ -240,7 +240,7 @@ protected static function parseNode( */ if ($node->nodeName != 'li') { $cNodes = $node->childNodes; - if (count($cNodes) > 0) { + if ($cNodes->length > 0) { foreach ($cNodes as $cNode) { self::parseNode($cNode, $newobject, $styles, $data); } diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 227b1b3046..5f4bd3ce59 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -37,15 +37,13 @@ public function write() if (!$this->withoutP) { $hasStyle = $element->hasStyle(); + $this->writeOpeningWP(); if ($hasStyle) { - $this->writeOpeningWP(); $xmlWriter->startElement('w:pPr'); $this->writeFontStyle(); $xmlWriter->endElement(); // w:pPr - $this->writeClosingWP(); - } else { - $xmlWriter->writeElement('w:p'); } + $this->writeClosingWP(); } else { $xmlWriter->writeElement('w:br'); } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 2678ac5551..df5abd9b58 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -24,6 +24,8 @@ /** * Word2007 numbering part writer: word/numbering.xml + * + * @since 0.10.0 */ class Numbering extends AbstractPart { @@ -97,12 +99,6 @@ public function write() */ private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) { - $tabPos = $level->getTabPos(); - $left = $level->getLeft(); - $hanging = $level->getHanging(); - $font = $level->getFont(); - $hint = $level->getHint(); - $xmlWriter->startElement('w:lvl'); $xmlWriter->writeAttribute('w:ilvl', $level->getLevel()); @@ -124,48 +120,64 @@ private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) } } - // Paragraph styles - if (!is_null($tabPos) || !is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:pPr'); - if (!is_null($tabPos)) { - $xmlWriter->startElement('w:tabs'); - $xmlWriter->startElement('w:tab'); - $xmlWriter->writeAttribute('w:val', 'num'); - $xmlWriter->writeAttribute('w:pos', $tabPos); - $xmlWriter->endElement(); // w:tab - $xmlWriter->endElement(); // w:tabs - } - if (!is_null($left) || !is_null($hanging)) { - $xmlWriter->startElement('w:ind'); - if (!is_null($left)) { - $xmlWriter->writeAttribute('w:left', $left); - } - if (!is_null($hanging)) { - $xmlWriter->writeAttribute('w:hanging', $hanging); - } - $xmlWriter->endElement(); // w:ind - } - $xmlWriter->endElement(); // w:pPr - } + // Paragraph & font styles + $this->writeParagraph($xmlWriter, $level); + $this->writeFont($xmlWriter, $level); - // Font styles - if (!is_null($font) || !is_null($hint)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rFonts'); - if (!is_null($font)) { - $xmlWriter->writeAttribute('w:ascii', $font); - $xmlWriter->writeAttribute('w:hAnsi', $font); - $xmlWriter->writeAttribute('w:cs', $font); - } - if (!is_null($hint)) { - $xmlWriter->writeAttribute('w:hint', $hint); - } - $xmlWriter->endElement(); // w:rFonts - $xmlWriter->endElement(); // w:rPr - } $xmlWriter->endElement(); // w:lvl } + /** + * Write level paragraph + * + * @since 0.11.0 + * @todo Use paragraph style writer + */ + private function writeParagraph(XMLWriter $xmlWriter, NumberingLevel $level) + { + $tabPos = $level->getTabPos(); + $left = $level->getLeft(); + $hanging = $level->getHanging(); + + $xmlWriter->startElement('w:pPr'); + + $xmlWriter->startElement('w:tabs'); + $xmlWriter->startElement('w:tab'); + $xmlWriter->writeAttribute('w:val', 'num'); + $xmlWriter->writeAttributeIf($tabPos !== null, 'w:pos', $tabPos); + $xmlWriter->writeAttribute('w:pos', $tabPos); + $xmlWriter->endElement(); // w:tab + $xmlWriter->endElement(); // w:tabs + + $xmlWriter->startElement('w:ind'); + $xmlWriter->writeAttributeIf($left !== null, 'w:left', $left); + $xmlWriter->writeAttributeIf($hanging !== null, 'w:hanging', $hanging); + $xmlWriter->endElement(); // w:ind + + $xmlWriter->endElement(); // w:pPr + } + + /** + * Write level font + * + * @since 0.11.0 + * @todo Use font style writer + */ + private function writeFont(XMLWriter $xmlWriter, NumberingLevel $level) + { + $font = $level->getFont(); + $hint = $level->getHint(); + + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:rFonts'); + $xmlWriter->writeAttributeIf($font !== null, 'w:ascii', $font); + $xmlWriter->writeAttributeIf($font !== null, 'w:hAnsi', $font); + $xmlWriter->writeAttributeIf($font !== null, 'w:cs', $font); + $xmlWriter->writeAttributeIf($hint !== null, 'w:hint', $hint); + $xmlWriter->endElement(); // w:rFonts + $xmlWriter->endElement(); // w:rPr + } + /** * Get random hexadecimal number value * diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index c1405258c0..562deb35b5 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -50,43 +50,51 @@ public function write() * Write relationships * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param null|array $xmlRels - * @param null|array $mediaRels - * @param integer $relId + * @param array $xmlRels + * @param array $mediaRels + * @param int $relId */ - protected function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1) + protected function writeRels(XMLWriter $xmlWriter, $xmlRels = array(), $mediaRels = array(), $relId = 1) { $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); $xmlWriter->startElement('Relationships'); $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // XML files relationships - if (is_array($xmlRels)) { - foreach ($xmlRels as $target => $type) { - $this->writeRel($xmlWriter, $relId++, $type, $target); - } + foreach ($xmlRels as $target => $type) { + $this->writeRel($xmlWriter, $relId++, $type, $target); } // Media relationships - if (is_array($mediaRels)) { - $typePrefix = 'officeDocument/2006/relationships/'; - $typeMapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink'); - $targetPaths = array('image' => 'media/', 'object' => 'embeddings/'); - - foreach ($mediaRels as $mediaRel) { - $mediaType = $mediaRel['type']; - $type = array_key_exists($mediaType, $typeMapping) ? $typeMapping[$mediaType] : $mediaType; - $target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : ''; - $target .= $mediaRel['target']; - $targetMode = ($type == 'hyperlink') ? 'External' : ''; - - $this->writeRel($xmlWriter, $relId++, $typePrefix . $type, $target, $targetMode); - } + foreach ($mediaRels as $mediaRel) { + $this->writeMediaRel($xmlWriter, $relId++, $mediaRel); } $xmlWriter->endElement(); // Relationships } + /** + * Write media relationships + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param int $relId + * @param array $mediaRel + */ + private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel) + { + $typePrefix = 'officeDocument/2006/relationships/'; + $typeMapping = array('image' => 'image', 'object' => 'oleObject', 'link' => 'hyperlink'); + $targetMapping = array('image' => 'media/', 'object' => 'embeddings/'); + + $mediaType = $mediaRel['type']; + $type = array_key_exists($mediaType, $typeMapping) ? $typeMapping[$mediaType] : $mediaType; + $targetPrefix = array_key_exists($mediaType, $targetMapping) ? $targetMapping[$mediaType] : ''; + $target = $mediaRel['target']; + $targetMode = ($type == 'hyperlink') ? 'External' : ''; + + $this->writeRel($xmlWriter, $relId, $typePrefix . $type, $targetPrefix . $target, $targetMode); + } + /** * Write individual rels entry * diff --git a/src/PhpWord/Writer/Word2007/Part/RelsPart.php b/src/PhpWord/Writer/Word2007/Part/RelsPart.php index a3697834ae..627a2bcd1b 100644 --- a/src/PhpWord/Writer/Word2007/Part/RelsPart.php +++ b/src/PhpWord/Writer/Word2007/Part/RelsPart.php @@ -39,7 +39,7 @@ class RelsPart extends Rels public function write() { $xmlWriter = $this->getXmlWriter(); - $this->writeRels($xmlWriter, null, $this->media); + $this->writeRels($xmlWriter, array(), $this->media); return $xmlWriter->getData(); } From dc6c487cd02afbf135463db364f61f768afa6597 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 24 May 2014 23:07:34 +0700 Subject: [PATCH 139/167] Fix test error --- src/PhpWord/Element/Image.php | 10 +++++++--- src/PhpWord/Settings.php | 2 +- src/PhpWord/Shared/Html.php | 4 ++-- src/PhpWord/Writer/Word2007/Part/Numbering.php | 1 - tests/PhpWord/Tests/Element/ImageTest.php | 1 + tests/PhpWord/Tests/Element/SectionTest.php | 2 +- tests/PhpWord/Tests/SettingsTest.php | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index de859ad285..a1cb8250f7 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -312,9 +312,13 @@ public function getImageStringData($base64 = false) } else { $actualSource = $source; } - if ($actualSource === null) { - return null; - } + + // Can't find any case where $actualSource = null hasn't captured by + // preceding exceptions. Please uncomment when you find the case and + // put the case into Element\ImageTest. + // if ($actualSource === null) { + // return null; + // } // Read image binary data and convert to hex/base64 string if ($this->sourceType == self::SOURCE_GD) { diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 8d9e2ace0d..cb74389a20 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -344,7 +344,7 @@ public static function loadConfig($filename = null) // Parse config file $config = array(); if ($configFile !== null) { - $config = parse_ini_file($configFile); + $config = @parse_ini_file($configFile); if ($config === false) { return $config; } diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 4faacfb1a6..501d24046a 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -214,7 +214,7 @@ protected static function parseNode( */ case 'li': $cNodes = $node->childNodes; - if ($cNodes->length > 0) { + if (count($cNodes) > 0) { $text = ''; foreach ($cNodes as $cNode) { if ($cNode->nodeName == '#text') { @@ -240,7 +240,7 @@ protected static function parseNode( */ if ($node->nodeName != 'li') { $cNodes = $node->childNodes; - if ($cNodes->length > 0) { + if (count($cNodes) > 0) { foreach ($cNodes as $cNode) { self::parseNode($cNode, $newobject, $styles, $data); } diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index df5abd9b58..05cbf7b91b 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -145,7 +145,6 @@ private function writeParagraph(XMLWriter $xmlWriter, NumberingLevel $level) $xmlWriter->startElement('w:tab'); $xmlWriter->writeAttribute('w:val', 'num'); $xmlWriter->writeAttributeIf($tabPos !== null, 'w:pos', $tabPos); - $xmlWriter->writeAttribute('w:pos', $tabPos); $xmlWriter->endElement(); // w:tab $xmlWriter->endElement(); // w:tabs diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index b04b5fe6ad..11b33d8785 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -38,6 +38,7 @@ public function testConstruct() $this->assertEquals($oImage->getSource(), $src); $this->assertEquals($oImage->getMediaId(), md5($src)); $this->assertEquals($oImage->isWatermark(), false); + $this->assertEquals($oImage->getSourceType(), Image::SOURCE_LOCAL); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index 271e81e333..af7595e208 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -73,7 +73,7 @@ public function testSetSettings() { $expected = 'landscape'; $object = new Section(0); - $object->setSettings(array('orientation' => $expected)); + $object->setSettings(array('orientation' => $expected, 'foo' => null)); $this->assertEquals($expected, $object->getSettings()->getOrientation()); } diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 36565eb1d8..6136403449 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -111,6 +111,6 @@ public function testLoadConfig() $this->assertEquals($expected, Settings::loadConfig(__DIR__ . '/../../../phpword.ini.dist')); // Test with invalid file - $this->assertEmpty(Settings::loadConfig(__DIR__ . '/files/xsl/passthrough.xsl')); + $this->assertEmpty(Settings::loadConfig(__DIR__ . '/../../../phpunit.xml.dist')); } } From 92c7a24c38ebeb1bf90c38d0fe989b0bde2f12a7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 25 May 2014 22:51:14 +0700 Subject: [PATCH 140/167] QA: Additional unit tests and docblock fixes --- CHANGELOG.md | 1 + src/PhpWord/Autoloader.php | 1 + src/PhpWord/DocumentProperties.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 10 +- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Cell.php | 2 +- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Style/LineNumbering.php | 3 +- src/PhpWord/Style/ListItem.php | 4 +- src/PhpWord/Style/Paragraph.php | 10 +- src/PhpWord/Style/Table.php | 2 +- src/PhpWord/Style/TextBox.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 37 +++- src/PhpWord/Writer/HTML.php | 30 ++- src/PhpWord/Writer/PDF.php | 8 +- src/PhpWord/Writer/PDF/DomPDF.php | 2 +- src/PhpWord/Writer/PDF/MPDF.php | 2 +- src/PhpWord/Writer/PDF/TCPDF.php | 2 +- src/PhpWord/Writer/RTF.php | 36 +-- src/PhpWord/Writer/Word2007/Part/Styles.php | 205 ++++++++++-------- tests/PhpWord/Tests/Shared/XMLWriterTest.php | 40 ++++ .../PhpWord/Tests/Style/AbstractStyleTest.php | 1 + tests/PhpWord/Tests/Style/CellTest.php | 4 + tests/PhpWord/Tests/Style/FontTest.php | 1 + tests/PhpWord/Tests/Style/ParagraphTest.php | 14 ++ tests/PhpWord/Tests/Style/TableTest.php | 4 + .../Tests/_files/documents/reader.docx | Bin 74101 -> 74121 bytes 27 files changed, 289 insertions(+), 138 deletions(-) create mode 100644 tests/PhpWord/Tests/Shared/XMLWriterTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 84cc2cb10e..fcaf1388ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - `Writer\Word2007\Part`: `Numbering::writeNumbering()`, `Settings::writeSettings()`, `WebSettings::writeWebSettings()`, `ContentTypes::writeContentTypes()`, `Styles::writeStyles()`, `Document::writeDocument()` all changed into `write()` - `Writer\Word2007\Part\DocProps`: Split into `Writer\Word2007\Part\DocPropsCore` and `Writer\Word2007\Part\DocPropsApp` - `Element\Title::getBookmarkId()` replaced by `Element\Title::getRelationId()` +- `Writer\HTML::writeDocument`: Replaced by `Writer\HTML::getContent` ### Miscellaneous diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index c60ae9a632..c467f836c3 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -22,6 +22,7 @@ */ class Autoloader { + /** @const string */ const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\'; /** diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 95159ec0e9..5644c3d96c 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -22,7 +22,7 @@ */ class DocumentProperties { - /** Constants */ + /** @const string Property type constants */ const PROPERTY_TYPE_BOOLEAN = 'b'; const PROPERTY_TYPE_INTEGER = 'i'; const PROPERTY_TYPE_FLOAT = 'f'; diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index dc85bfc1eb..81e8e286a0 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -68,9 +68,8 @@ public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = // Create temporary filename $this->tempFile = @tempnam($tempFolder, 'xml'); - // Open storage + // Fallback to memory when temporary file cannot be used if ($this->xmlWriter->openUri($this->tempFile) === false) { - // Fallback to memory... $this->xmlWriter->openMemory(); } } @@ -105,9 +104,16 @@ public function __destruct() * * @param mixed $function * @param mixed $args + * @throws \BadMethodCallException */ public function __call($function, $args) { + // Catch exception + if (method_exists($this->xmlWriter, $function) === false) { + throw new \BadMethodCallException("Method '{$function}' does not exists."); + } + + // Run method try { @call_user_func_array(array($this->xmlWriter, $function), $args); } catch (\Exception $ex) { diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 1b91693434..8167c4d266 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -265,7 +265,7 @@ protected function setEnumVal($value = null, $enum = array(), $default = null) { if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) { throw new \InvalidArgumentException('Invalid style value.'); - } elseif (is_null($value) || trim($value) == '') { + } elseif ($value === null || trim($value) == '') { $value = $default; } diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 95ed13b4e3..2d1b88d08f 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -144,7 +144,7 @@ public function setTextDirection($value = null) */ public function getBgColor() { - if (!is_null($this->shading)) { + if ($this->shading !== null) { return $this->shading->getFill(); } else { return null; diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 07eebdb288..0775b8b33b 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -540,7 +540,7 @@ public function setFgColor($value = null) */ public function getBgColor() { - if (!is_null($this->shading)) { + if ($this->shading !== null) { return $this->shading->getFill(); } else { return null; diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php index d49c7f4e62..b93ce03f0f 100644 --- a/src/PhpWord/Style/LineNumbering.php +++ b/src/PhpWord/Style/LineNumbering.php @@ -20,11 +20,12 @@ /** * Line numbering style * - * @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html + * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_LineNumber.html * @since 0.10.0 */ class LineNumbering extends AbstractStyle { + /** @const string Line numbering restart setting http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html */ const LINE_NUMBERING_CONTINUOUS = 'continuous'; const LINE_NUMBERING_NEW_PAGE = 'newPage'; const LINE_NUMBERING_NEW_SECTION = 'newSection'; diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 554d75b025..a689c691c0 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -65,7 +65,7 @@ class ListItem extends AbstractStyle */ public function __construct($numStyle = null) { - if (!is_null($numStyle)) { + if ($numStyle !== null) { $this->setNumStyle($numStyle); } else { $this->setListType(); @@ -149,7 +149,7 @@ private function getListTypeStyle() { // Check if legacy style already registered in global Style collection $numStyle = "PHPWordList{$this->listType}"; - if (!is_null(Style::getStyle($numStyle))) { + if (Style::getStyle($numStyle) !== null) { $this->setNumStyle($numStyle); return; } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 8609b5abb9..e70833cabf 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -171,7 +171,7 @@ public function setAlign($value = null) */ public function getSpaceBefore() { - if (!is_null($this->spacing)) { + if ($this->spacing !== null) { return $this->spacing->getBefore(); } else { return null; @@ -196,7 +196,7 @@ public function setSpaceBefore($value = null) */ public function getSpaceAfter() { - if (!is_null($this->spacing)) { + if ($this->spacing !== null) { return $this->spacing->getAfter(); } else { return null; @@ -221,7 +221,7 @@ public function setSpaceAfter($value = null) */ public function getSpacing() { - if (!is_null($this->spacing)) { + if ($this->spacing !== null) { return $this->spacing->getLine(); } else { return null; @@ -278,7 +278,7 @@ public function setLineHeight($lineHeight) */ public function getIndent() { - if (!is_null($this->indentation)) { + if ($this->indentation !== null) { return $this->indentation->getLeft(); } else { return null; @@ -303,7 +303,7 @@ public function setIndent($value = null) */ public function getHanging() { - if (!is_null($this->indentation)) { + if ($this->indentation !== null) { return $this->indentation->getHanging(); } else { return null; diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 9875cc2662..24f5066777 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -169,7 +169,7 @@ public function getFirstRow() */ public function getBgColor() { - if (!is_null($this->shading)) { + if ($this->shading !== null) { return $this->shading->getFill(); } diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index eb215c06d4..9f0a1ddec7 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -179,7 +179,7 @@ public function hasInnerMargins() $hasInnerMargins = false; $margins = $this->getInnerMargin(); for ($i = 0; $i < count($margins); $i++) { - if (!is_null($margins[$i])) { + if ($margins[$i] !== null) { $hasInnerMargins = true; } } diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 52a1a28c86..367b7729a2 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -258,7 +258,7 @@ protected function clearTempDir() * * @param string $filename * @return \PhpOffice\PhpWord\Shared\ZipArchive - * @throws \PhpOffice\PhpWord\Exception\Exception + * @throws \Exception */ protected function getZipArchive($filename) { @@ -271,13 +271,46 @@ protected function getZipArchive($filename) $zip = new ZipArchive(); if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) { if ($zip->open($filename, ZipArchive::CREATE) !== true) { - throw new Exception("Could not open " . $filename . " for writing."); + throw new \Exception("Could not open '{$filename}' for writing."); } } return $zip; } + /** + * Open file for writing + * + * @param string $filename + * @return resource + * @throws \Exception + * @since 0.11.0 + */ + protected function openFile($filename) + { + $filename = $this->getTempFile($filename); + $fileHandle = fopen($filename, 'w'); + if ($fileHandle === false) { + throw new \Exception("Could not open '{$filename}' for writing."); + } + + return $fileHandle; + } + + /** + * Write content to file + * + * @param resource $fileHandle + * @param string $content + * @since 0.11.0 + */ + protected function writeFile(&$fileHandle, $content) + { + fwrite($fileHandle, $content); + fclose($fileHandle); + $this->cleanupTempFile(); + } + /** * Add files to package * diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 88e7658d8e..29173ff23c 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /** @@ -69,25 +68,20 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - $this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/'); - $hFile = fopen($filename, 'w'); - if ($hFile !== false) { - fwrite($hFile, $this->writeDocument()); - fclose($hFile); - } else { - throw new Exception("Can't open file"); - } - $this->clearTempDir(); + $fileHandle = $this->openFile($filename); + $this->writeFile($fileHandle, $this->getContent()); } /** - * Get phpWord data + * Get content * * @return string + * @since 0.11.0 */ - public function writeDocument() + public function getContent() { $content = ''; + $content .= '' . PHP_EOL; $content .= '' . PHP_EOL; $content .= '' . PHP_EOL; @@ -128,4 +122,16 @@ public function addNote($noteId, $noteMark) { $this->notes[$noteId] = $noteMark; } + + /** + * Write document + * + * @return string + * @deprecated 0.11.0 + * @codeCoverageIgnore + */ + public function writeDocument() + { + return $this->getContent(); + } } diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php index 98dc122085..178655633c 100644 --- a/src/PhpWord/Writer/PDF.php +++ b/src/PhpWord/Writer/PDF.php @@ -65,13 +65,13 @@ public function __construct(PhpWord $phpWord) * @param string $name Renderer library method name * @param mixed[] $arguments Array of arguments to pass to the renderer method * @return mixed Returned data from the PDF renderer wrapper method - * @throws \PhpOffice\PhpWord\Exception\Exception */ public function __call($name, $arguments) { - if ($this->renderer === null) { - throw new Exception("PDF Rendering library has not been defined."); - } + // Note: Commented because all exceptions should already be catched by `__construct` + // if ($this->renderer === null) { + // throw new Exception("PDF Rendering library has not been defined."); + // } return call_user_func_array(array($this->renderer, $name), $arguments); } diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index 4effc154b9..a40e2ceac3 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -50,7 +50,7 @@ public function save($filename = null) // Create PDF $pdf = new \DOMPDF(); $pdf->set_paper(strtolower($paperSize), $orientation); - $pdf->load_html($this->writeDocument()); + $pdf->load_html($this->getContent()); $pdf->render(); // Write to file diff --git a/src/PhpWord/Writer/PDF/MPDF.php b/src/PhpWord/Writer/PDF/MPDF.php index d38d5b66d3..9d4e050c87 100644 --- a/src/PhpWord/Writer/PDF/MPDF.php +++ b/src/PhpWord/Writer/PDF/MPDF.php @@ -61,7 +61,7 @@ public function save($filename = null) $pdf->setKeywords($docProps->getKeywords()); $pdf->setCreator($docProps->getCreator()); - $pdf->writeHTML($this->writeDocument()); + $pdf->writeHTML($this->getContent()); // Write to file fwrite($fileHandle, $pdf->output($filename, 'S')); diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php index 05f027566d..669a2cddee 100644 --- a/src/PhpWord/Writer/PDF/TCPDF.php +++ b/src/PhpWord/Writer/PDF/TCPDF.php @@ -54,7 +54,7 @@ public function save($filename = null) $pdf->setPrintFooter(false); $pdf->addPage(); $pdf->setFont($this->getFont()); - $pdf->writeHTML($this->writeDocument()); + $pdf->writeHTML($this->getContent()); // Write document properties $phpWord = $this->getPhpWord(); diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index ef94b26422..d7fed942dc 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer; -use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; /** @@ -56,29 +55,34 @@ public function __construct(PhpWord $phpWord = null) } /** - * Save PhpWord to file + * Save content to file * * @param string $filename * @throws \PhpOffice\PhpWord\Exception\Exception */ public function save($filename = null) + { + $fileHandle = $this->openFile($filename); + $this->writeFile($fileHandle, $this->getContent()); + } + + /** + * Get content + * + * @return string + * @since 0.11.0 + */ + private function getContent() { $content = ''; - $filename = $this->getTempFile($filename); - $hFile = fopen($filename, 'w'); - if ($hFile !== false) { - $content .= '{'; - $content .= '\rtf1' . PHP_EOL; - $content .= $this->getWriterPart('Header')->write(); - $content .= $this->getWriterPart('Document')->write(); - $content .= '}'; - fwrite($hFile, $content); - fclose($hFile); - } else { - throw new Exception("Can't open file"); - } - $this->cleanupTempFile(); + $content .= '{'; + $content .= '\rtf1' . PHP_EOL; + $content .= $this->getWriterPart('Header')->write(); + $content .= $this->getWriterPart('Document')->write(); + $content .= '}'; + + return $content; } /** diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index a0a6317a46..0d688e366f 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -20,9 +20,9 @@ use PhpOffice\PhpWord\Settings as PhpWordSettings; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Style\Font; -use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Style\Table; +use PhpOffice\PhpWord\Style\Font as FontStyle; +use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; +use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter; @@ -31,6 +31,7 @@ * Word2007 styles part writer: word/styles.xml * * @todo Do something with the numbering style introduced in 0.10.0 + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) For writeFontStyle, writeParagraphStyle, and writeTableStyle */ class Styles extends AbstractPart { @@ -59,88 +60,11 @@ public function write() continue; } - // Font style - if ($style instanceof Font) { - $paragraphStyle = $style->getParagraph(); - $styleType = $style->getStyleType(); - $type = ($styleType == 'title') ? 'paragraph' : 'character'; - if (!is_null($paragraphStyle)) { - $type = 'paragraph'; - } - - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', $type); - if ($styleType == 'title') { - $arrStyle = explode('_', $styleName); - $styleId = 'Heading' . $arrStyle[1]; - $styleName = 'heading ' . $arrStyle[1]; - $styleLink = 'Heading' . $arrStyle[1] . 'Char'; - $xmlWriter->writeAttribute('w:styleId', $styleId); - - $xmlWriter->startElement('w:link'); - $xmlWriter->writeAttribute('w:val', $styleLink); - $xmlWriter->endElement(); - } - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - // Parent style - $xmlWriter->writeElementIf(!is_null($paragraphStyle), 'w:basedOn', 'w:val', 'Normal'); - - // w:pPr - if (!is_null($paragraphStyle)) { - $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); - $styleWriter->write(); - } - - // w:rPr - $styleWriter = new FontStyleWriter($xmlWriter, $style); - $styleWriter->write(); - - $xmlWriter->endElement(); - - // Paragraph style - } elseif ($style instanceof Paragraph) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'paragraph'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - // Parent style - $basedOn = $style->getBasedOn(); - $xmlWriter->writeElementIf(!is_null($basedOn), 'w:basedOn', 'w:val', $basedOn); - - // Next paragraph style - $next = $style->getNext(); - $xmlWriter->writeElementIf(!is_null($next), 'w:next', 'w:val', $next); - - // w:pPr - $styleWriter = new ParagraphStyleWriter($xmlWriter, $style); - $styleWriter->write(); - - $xmlWriter->endElement(); - - // Table style - } elseif ($style instanceof Table) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'table'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - $xmlWriter->startElement('w:uiPriority'); - $xmlWriter->writeAttribute('w:val', '99'); - $xmlWriter->endElement(); - - $styleWriter = new TableStyleWriter($xmlWriter, $style); - $styleWriter->write(); - - $xmlWriter->endElement(); // w:style + // Get style class and execute if the private method exists + $styleClass = substr(get_class($style), strrpos(get_class($style), '\\') + 1); + $method = "write{$styleClass}Style"; + if (method_exists($this, $method)) { + $this->$method($xmlWriter, $styleName, $style); } } } @@ -213,4 +137,115 @@ private function writeDefaultStyles(XMLWriter $xmlWriter, $styles) $xmlWriter->endElement(); // w:style } } + + /** + * Write font style + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $styleName + * @param \PhpOffice\PhpWord\Style\Font $style + */ + private function writeFontStyle(XMLWriter $xmlWriter, $styleName, FontStyle $style) + { + $paragraphStyle = $style->getParagraph(); + $styleType = $style->getStyleType(); + $type = ($styleType == 'title') ? 'paragraph' : 'character'; + if (!is_null($paragraphStyle)) { + $type = 'paragraph'; + } + + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', $type); + + // Heading style + if ($styleType == 'title') { + $arrStyle = explode('_', $styleName); + $styleId = 'Heading' . $arrStyle[1]; + $styleName = 'heading ' . $arrStyle[1]; + $styleLink = 'Heading' . $arrStyle[1] . 'Char'; + $xmlWriter->writeAttribute('w:styleId', $styleId); + + $xmlWriter->startElement('w:link'); + $xmlWriter->writeAttribute('w:val', $styleLink); + $xmlWriter->endElement(); + } + + // Style name + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + + // Parent style + $xmlWriter->writeElementIf(!is_null($paragraphStyle), 'w:basedOn', 'w:val', 'Normal'); + + // w:pPr + if (!is_null($paragraphStyle)) { + $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); + $styleWriter->write(); + } + + // w:rPr + $styleWriter = new FontStyleWriter($xmlWriter, $style); + $styleWriter->write(); + + $xmlWriter->endElement(); + } + + /** + * Write paragraph style + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $styleName + * @param \PhpOffice\PhpWord\Style\Paragraph $style + */ + private function writeParagraphStyle(XMLWriter $xmlWriter, $styleName, ParagraphStyle $style) + { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'paragraph'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + + // Parent style + $basedOn = $style->getBasedOn(); + $xmlWriter->writeElementIf(!is_null($basedOn), 'w:basedOn', 'w:val', $basedOn); + + // Next paragraph style + $next = $style->getNext(); + $xmlWriter->writeElementIf(!is_null($next), 'w:next', 'w:val', $next); + + // w:pPr + $styleWriter = new ParagraphStyleWriter($xmlWriter, $style); + $styleWriter->write(); + + $xmlWriter->endElement(); + } + + /** + * Write table style + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $styleName + * @param \PhpOffice\PhpWord\Style\Table $style + */ + private function writeTableStyle(XMLWriter $xmlWriter, $styleName, TableStyle $style) + { + $xmlWriter->startElement('w:style'); + $xmlWriter->writeAttribute('w:type', 'table'); + $xmlWriter->writeAttribute('w:customStyle', '1'); + $xmlWriter->writeAttribute('w:styleId', $styleName); + $xmlWriter->startElement('w:name'); + $xmlWriter->writeAttribute('w:val', $styleName); + $xmlWriter->endElement(); + $xmlWriter->startElement('w:uiPriority'); + $xmlWriter->writeAttribute('w:val', '99'); + $xmlWriter->endElement(); + + $styleWriter = new TableStyleWriter($xmlWriter, $style); + $styleWriter->write(); + + $xmlWriter->endElement(); // w:style + } } diff --git a/tests/PhpWord/Tests/Shared/XMLWriterTest.php b/tests/PhpWord/Tests/Shared/XMLWriterTest.php new file mode 100644 index 0000000000..08db39184f --- /dev/null +++ b/tests/PhpWord/Tests/Shared/XMLWriterTest.php @@ -0,0 +1,40 @@ +foo(); + } +} diff --git a/tests/PhpWord/Tests/Style/AbstractStyleTest.php b/tests/PhpWord/Tests/Style/AbstractStyleTest.php index 15ff8facdc..d35e109076 100644 --- a/tests/PhpWord/Tests/Style/AbstractStyleTest.php +++ b/tests/PhpWord/Tests/Style/AbstractStyleTest.php @@ -45,6 +45,7 @@ public function testSetValNormal() $this->assertEquals(true, self::callProtectedMethod($stub, 'setBoolVal', array(true, false))); $this->assertEquals(12, self::callProtectedMethod($stub, 'setIntVal', array(12, 200))); $this->assertEquals(871.1, self::callProtectedMethod($stub, 'setFloatVal', array(871.1, 2.1))); + $this->assertEquals(871.1, self::callProtectedMethod($stub, 'setFloatVal', array('871.1', 2.1))); $this->assertEquals('a', self::callProtectedMethod($stub, 'setEnumVal', array('a', array('a', 'b'), 'b'))); } diff --git a/tests/PhpWord/Tests/Style/CellTest.php b/tests/PhpWord/Tests/Style/CellTest.php index 1a02671043..f913172806 100644 --- a/tests/PhpWord/Tests/Style/CellTest.php +++ b/tests/PhpWord/Tests/Style/CellTest.php @@ -52,7 +52,11 @@ public function testSetGetNormal() foreach ($attributes as $key => $value) { $set = "set{$key}"; $get = "get{$key}"; + + $this->assertNull($object->$get()); // Init with null value + $object->$set($value); + $this->assertEquals($value, $object->$get()); } } diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index ca2105fb5e..432b29fb22 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -74,6 +74,7 @@ public function testSetStyleValueWithNullOrEmpty() ); foreach ($attributes as $key => $default) { $get = is_bool($default) ? "is{$key}" : "get{$key}"; + $this->assertEquals($default, $object->$get()); $object->setStyleValue("$key", null); $this->assertEquals($default, $object->$get()); $object->setStyleValue("$key", ''); diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 357371c670..32e4698505 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -96,6 +96,20 @@ public function testSetStyleValueNormal() } } + /** + * Test get null style value + */ + public function testGetNullStyleValue() + { + $object = new Paragraph(); + + $attributes = array('spacing', 'indent', 'hanging', 'spaceBefore', 'spaceAfter'); + foreach ($attributes as $key) { + $get = "get{$key}"; + $this->assertNull($object->$get()); + } + } + /** * Test tabs */ diff --git a/tests/PhpWord/Tests/Style/TableTest.php b/tests/PhpWord/Tests/Style/TableTest.php index a7b46c1f48..2afbab744a 100644 --- a/tests/PhpWord/Tests/Style/TableTest.php +++ b/tests/PhpWord/Tests/Style/TableTest.php @@ -74,6 +74,9 @@ public function testSetGetNormal() 'cellMarginLeft' => 240, 'cellMarginRight' => 240, 'cellMarginBottom' => 240, + 'align' => 'center', + 'width' => 100, + 'unit' => 'pct', ); foreach ($attributes as $key => $value) { $set = "set{$key}"; @@ -146,6 +149,7 @@ public function testCellMargin() $this->assertEquals($value, $object->$get()); } $this->assertEquals($values, $object->getCellMargin()); + $this->assertTrue($object->hasMargin()); } /** diff --git a/tests/PhpWord/Tests/_files/documents/reader.docx b/tests/PhpWord/Tests/_files/documents/reader.docx index 5f37ef4b17d05dc992c92922b5591eb978a429a8..d09091b11983772d56172c519b702ede44df8989 100644 GIT binary patch delta 2647 zcmZWrc{H1O7tV{K*4QEvB+-P{Ui%(e)UJzC)iTziwpu<#D}#=zbf{>(gih_cpkocD z)}Xea=$NKuN~?=)Y}Hs2U&QI0^PTVa$9?YdywAPop7)RYt&8Ull}GrrJvWaeWdGf3 zXs!|F;o@dvog|k6z;O(@{m|U9jm>q1M~nnHnJIO7WsbwTAet>qZ)mnmEZH-E!v}#l zWFr=lg#PMrP06VvtD@(zIiuafjPAn5=T>ON<7qKuUPP9yExik7mg@Wy6~8Lj^wqN8 z-sk0HnU$yc+rQdYO*gL%w^E#2_r63)ZssKB@Y(K~zgm7`HyJE{&X9odF{*0lE-&9w^ar5w#?VRju7-_cY`0qi{6hrQ|iV{T&6MmX#ZFx zfw;J}qNdNdGx)6)%*rlHxj*1$X>jnCI!%0JB+BQ?$6kAVx5iJ!PaCk`e8(7=egz5| zRhP;B*i3EgkM8(+Sf>tu%B)~b71>z3pW8pH$IU|`_PfMI(Pp|s;7%(#qh?T<#Q z1XvbIdQNU94@EM>UNaLNOF>?)%Ie)3?yK#;<1eYagBy)*(`_1lClzN1FU@0xXde|A z%%fbGa7mYP&;Kj4Ft6*;catG(WXkpMa-{>f!_ z)p^!A!J}rx&t6xhdd`7YIXg}}_FPv-AK{Pqwc}1&u?Uh(7H&aoB4Hu4$^?5V!p&+wSO_GIOp=LNp4nS8Iq)uYFeWye~cMpU(Zi`pVz)YrFfksOjf)=R6h@k zmpX%3rbG35FX#_B+BaR&=lSR#s}ZRg&{JJ!9Utn{V_V;Du-=M}q_!qeSf6jcCCDvJ zv$oHL$Len2CG!WrKC3K%UW?jkSva{|bnko633JN5mgQ-Dw9u?Bzem+FKSRi zE@8q|MeOo*>OgpJi6u@kuVQcNelU7y0x~MDlmV4xgqQ{OzE+FKs%5fk@mF8TEYtop?Vw_VT3(*yl-shu&|Yq^BHfX>CZ6c(Hics(Sr_q`(1 zVj33oC5zG${N$-o(WTqkZrEqfLUy!lXBE7@3(fkNE{UpJ1i#h23e}ME3q;)-w}Nl? z{Mvzq{2no%tE?HedZSz==QB{@?2O z{N&3&WlfgJ1@9^!>KT6ihz-LEEQ^Pa$ycZicYah<<9oeLAq1H++{_y2%o3VI<4!E! z$)?Ac(#h?nP%{H}Gi&<8Qq#UC1-ER^k{rx^uLoduMDc@lkEfjJSX|X3&3-$-LThH` z%4%DKZ2C?69Ut7}lvqxH;zqMWjEsUhNzmecIzPMK zm4wqhnXM_dUoTWT8Z`fa?}eGHkgkc$n(6z7tdyZUzRHp~$BQn%TyaWLAt$ew*K#Q< zhAR_`p>gNjaZ;8EY;%%reyM1!BqhJ{bhYgnWgAT32s{S<;4$^IQcGFJuhr+rii}PW zQWnJKJ#kWP1wO@s0P#%~RE3e-%qUDoTIF88-ihIXBtr*g*0^}X-lO?%tj+-X>6$!k z?|*_oEcm&+e%tuWE0WwHt+CO3<`!mUPi2Ajv@+I3?$?+hcLzAKQQN|$hX;}ev49=- z*|T)XdT{7?)4%{%cM(=aFgZH4QZj>0P5%k$NQ1<_0Q5npyHQ{*j z6n7ic&%-N_*|p}bR+o#m>`)k7`5?(h62ia#{!|Fx5uGN4?;iC`MXl6>GkowRe+DLX zQ)~CSxxEoU$A&VtkJap$O1lz{+ zvnq~)kG9;D0W74=`E{}Lxu`y@2wC-JC zfT8iN~hZU_6)UYYGGoe@6SXAvW~I7AijSFWV0^7D7(CXD&N16g$Qt*XFsCEhy!Oi zcLX>f0qBY-$$!z;ygmXPAZR89AV4KaU~r!chQR?O2$cfRA_i6mv;*9yrE(ZAr2riX z52q!L#t)q6mH{JRfE48j49EcXPZh9U8qk#JF}(PCzt<1s>V|T7pb#AJ`q9u>WTk4E zBX@uxUIsu=UcmumVKlocdSdn3f0ti4BkR)9{M)4~fzcfS@^301!BYmzT+rJwT9# z0(1ZmkP8ij0^wi;8nEW5G@}9Ju^Zw5zVG?G?|Gi{Jm-yVhA%h41y0&+P@c zWdd+6?j0-_Cf4*f*HD`+xQhNn+g-o4r-MwApV%Hs1V9U)&m=Xn4G| z*p%Sym(JRfn=HvWXpbAM|9T||t(I4mLl+IBddBNEx)hAad7T&g?9`YOcFi#0E8^6c zm(~3nD!AXQdhHEv@*iz%v}Tgm4&tO6mD1x|ThZ^%m1^r$gbysYQA+DR z2T-$ri)*_Vw|MvaYoV9NPQVf z5u*7kemKj?%%}R2X}^TWFi}U99Wabaf`%*GUZkVzQnUizk$=fD+lbT{-7BjzBs5R$ z+-CaM6&~xyQ~#MwjNWR!a7{NnJ59&T&CfM>D(TXJiSP_mw<@F5ehzkQdCktusYb^zkcP4(HmifIy znjooy!ipF1GA)CKp7x}6NQ)O)@s?esyPz~Ej|2u^*VeRadz@;zbdI5oG%In>RLayh zsvr@xRU8nW^o-EvGmhGhs@+@k8cGn(r6q)tPj?qYytnK0*b2(vDTf58TOPUWvIqMj z2R9KRXBiJHM!pmm6n~)w;5vusf0i<5+vQ{9ZiJIjnCZc-Pa+SW6_N!$7BunCMqa5! znl@IarNbk{Pv9N*zv!rspuzGz={z^zg-t$rwH2w`cr`WK?6eGhh16>_KId-;qj)Y` zS7_cOc)w|D+%y_zJ0tk0SEEc^&JJ6$?U8)zo6f3H{*C56@%W$|+&! zox|ra>a%{Ce6e1f)#uxNc(6D?Z7QWcq=7jVSgi=v2bD6Xmfmi=tgNiRy5HB(bNHaq zO1unLF%3!i)SnUAdM+g;v!+L3Dl3bXVDk65ak~$*6+BY5e%%2lsj3Zj)4+AT_hPF> z<{!ST!9u1+y{PU>>VBC*g!WcTeajCCS$y)g$;qBvlFb@>2dHe7)x7Ij6;{?RS;Uvt zp1J1R_vROBE2ZuR*=+E;M})qC8xM-iI`!Z!;(biygJ?z52E}ua&MGcf2xk`ixP_ zgq_zZFa4|@7MFspW8{%BGe3yj**4U zpJSx>VML_NSbO=_5X%_3HlARh6G!CQqF$~iRW2tM=a(hw#qoMHUst$OoDOpnC9q^) z%;Z=qGns_wUr3~g{!~vdiG>> zZRex$D5f{R;f(c~dtzU#m#((!ntE5CdUpcdWMMVAa4?pT7mFR_YcKh2iR#tY})^4D%-^BiTg{Lakj(`wZ|c zu^Qd+@ISnZb%jgQ>5|hb=wQ;J)f-}poz2fgSQJwBU9U<_58pqUI}Hn;ejjvA%yAsU ztQx+IkK?0*--&7S+p9}d9i6yTtntFALLHExCCyD1JgbR~M9sG-GHXaQ;d!3I$2)%1 z{N(DEpBHYn#`nil!*->*U;fC^%FTeUL=Sim_fRs=Y3rUqz46lm@3qU{&rJ@W?aAk>Hk z7$`{+?1A*fKs!f<7Y+0gD6-6M4pfH*Sco745YS~bxWtJMqJgF$Hu(TY;|Eqri-Si$ zDzsq$QM9^HkrVxiTr3oHOA??Vf&_5=Sp*AZO8^4Gtz3dr$#x%*shX4kI^3KDycEzD zeJv=((fNso3?zQ&giC>Th$so*nE%F`2pCKRCeIm|V6X_tLmKRdx+DP-N|FXgxYoWx zucd)IcnBTB0h6B~ww+4~YLA zL*fJhEZ9H56H-S5Q9-8|VNRPr5MtwjCa{3S3E(m~3(*L`oO7^)0I>2D5dd=y@bbN; k#s?#CnguWkSRzx1Bk%(uewiJCc*s}=nCz(&1v_c~0z)^0d;kCd From d9a2c4c3ca235c20adc7c9bf75b108b5f9b75786 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 27 May 2014 00:46:18 +0700 Subject: [PATCH 141/167] Bugfix #248: Image: `marginLeft` and `marginTop` cannot accept float value --- CHANGELOG.md | 1 + src/PhpWord/Style/Image.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcaf1388ba..41f0c3ee9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - Header: All images added to the second header were assigned to the first header - @basjan GH-222 - Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234 - PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin GH-150 +- Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin GH-248 ### Deprecated diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 33c85ddf23..f816b32f5d 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -102,14 +102,14 @@ class Image extends AbstractStyle /** * Margin Top * - * @var int + * @var int|float */ private $marginTop = 0; /** * Margin Left * - * @var int + * @var int|float */ private $marginLeft = 0; @@ -235,7 +235,7 @@ public function setAlign($value = null) /** * Get margin top * - * @return int + * @return int|float */ public function getMarginTop() { @@ -245,12 +245,12 @@ public function getMarginTop() /** * Set margin top * - * @param int $value + * @param int|float $value * @return self */ public function setMarginTop($value = 0) { - $this->marginTop = $this->setIntVal($value, 0); + $this->marginTop = $this->setFloatVal($value, 0); return $this; } @@ -258,7 +258,7 @@ public function setMarginTop($value = 0) /** * Get margin left * - * @return int + * @return int|float */ public function getMarginLeft() { @@ -268,12 +268,12 @@ public function getMarginLeft() /** * Set margin left * - * @param int $value + * @param int|float $value * @return self */ public function setMarginLeft($value = 0) { - $this->marginLeft = $this->setIntVal($value, 0); + $this->marginLeft = $this->setFloatVal($value, 0); return $this; } From d7f3d25b2aa8e81ff6a8a65a71437f562dace15c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 27 May 2014 01:08:54 +0700 Subject: [PATCH 142/167] #248 More flexible checking for float value --- src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Image.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 8167c4d266..13ef8f9b26 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -245,7 +245,7 @@ protected function setFloatVal($value, $default = null) if (is_string($value) && (preg_match('/[^\d\.\,]/', $value) == 0)) { $value = floatval($value); } - if (!is_float($value)) { + if (!is_numeric($value)) { $value = $default; } diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index f816b32f5d..1de518700f 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -250,7 +250,7 @@ public function getMarginTop() */ public function setMarginTop($value = 0) { - $this->marginTop = $this->setFloatVal($value, 0); + $this->marginTop = $this->setNumericVal($value, 0); return $this; } @@ -273,7 +273,7 @@ public function getMarginLeft() */ public function setMarginLeft($value = 0) { - $this->marginLeft = $this->setFloatVal($value, 0); + $this->marginLeft = $this->setNumericVal($value, 0); return $this; } From 88f65184060e8d4e33c5bd8c5fadac8c1b271dfe Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 28 May 2014 07:42:50 +0700 Subject: [PATCH 143/167] Init VERSION and improve requirement checking --- VERSION | 1 + samples/Sample_Header.php | 4 ++-- samples/index.php | 36 +++++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..142464bf22 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.11.0 \ No newline at end of file diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index b752848d63..f39bda169b 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -6,13 +6,13 @@ use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\IOFactory; -error_reporting(E_ALL & ~E_DEPRECATED); +error_reporting(E_ALL); define('CLI', (PHP_SAPI == 'cli') ? true : false); define('EOL', CLI ? PHP_EOL : '
'); define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php')); define('IS_INDEX', SCRIPT_FILENAME == 'index'); -require_once '../src/PhpWord/Autoloader.php'; +require_once __DIR__ . '/../src/PhpWord/Autoloader.php'; Autoloader::register(); Settings::loadConfig(); diff --git a/samples/index.php b/samples/index.php index 94b9890136..420c542019 100644 --- a/samples/index.php +++ b/samples/index.php @@ -1,5 +1,13 @@ array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), + 'xml' => array('PHP extension XML', extension_loaded('xml')), + 'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')), + 'gd' => array('PHP extension GD (optional)', extension_loaded('gd')), + 'xmlw' => array('PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')), + 'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')), +); if (!CLI) { ?>
@@ -11,20 +19,22 @@

array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), - 'zip' => array('PHP extension ZipArchive', extension_loaded('zip')), - 'xml' => array('PHP extension XML', extension_loaded('xml')), - 'gd' => array('PHP extension GD (optional)', extension_loaded('gd')), -); -echo "

Requirements

"; -echo "
    "; -foreach ($requirements as $key => $value) { - $status = $value[1] ? 'passed' : 'failed'; - echo "
  • {$value[0]} ... {$status}
  • "; -} -echo "
"; } if (!CLI) { + echo "

Requirement check:

"; + echo "
    "; + foreach ($requirements as $key => $value) { + list($label, $result) = $value; + $status = $result ? 'passed' : 'failed'; + echo "
  • {$label} ... {$status}
  • "; + } + echo "
"; include_once 'Sample_Footer.php'; +} else { + echo 'Requirement check:' . PHP_EOL; + foreach ($requirements as $key => $value) { + list($label, $result) = $value; + $status = $result ? '32m passed' : '31m failed'; + echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL; + } } From eb32ff2e151f516ad0d0a91019ca6565e9911c07 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 28 May 2014 08:50:09 +0200 Subject: [PATCH 144/167] #244 : Fix typo in recipe sample --- docs/recipes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/recipes.rst b/docs/recipes.rst index d900af8a4b..eef3152775 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -13,7 +13,7 @@ vertically. $imageStyle = array( 'width' => 40, - 'height' => 40 + 'height' => 40, 'wrappingStyle' => 'square', 'positioning' => 'absolute', 'posHorizontalRel' => 'margin', From 87f071d1b63183ffaf8801840386c65b4b9978e5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 27 May 2014 23:41:15 +0700 Subject: [PATCH 145/167] #72: Basic RTF Reader --- samples/Sample_27_ReadRTF.php | 17 ++ samples/resources/rtf.rtf | 21 ++ src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Reader/AbstractReader.php | 2 +- src/PhpWord/Reader/RTF.php | 50 ++++ src/PhpWord/Reader/RTF/Document.php | 351 +++++++++++++++++++++++++ src/PhpWord/Shared/XMLReader.php | 22 +- src/PhpWord/Writer/RTF/Part/Header.php | 2 +- 8 files changed, 459 insertions(+), 8 deletions(-) create mode 100644 samples/Sample_27_ReadRTF.php create mode 100644 samples/resources/rtf.rtf create mode 100644 src/PhpWord/Reader/RTF.php create mode 100644 src/PhpWord/Reader/RTF/Document.php diff --git a/samples/Sample_27_ReadRTF.php b/samples/Sample_27_ReadRTF.php new file mode 100644 index 0000000000..a28ba40b5b --- /dev/null +++ b/samples/Sample_27_ReadRTF.php @@ -0,0 +1,17 @@ +canRead($docFile)) { + $doc = new Document(); + $doc->rtf = file_get_contents($docFile); + $doc->read($phpWord); + } else { + throw new \Exception("Cannot read {$docFile}."); + } + + return $phpWord; + } +} diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php new file mode 100644 index 0000000000..ccb9b59532 --- /dev/null +++ b/src/PhpWord/Reader/RTF/Document.php @@ -0,0 +1,351 @@ + 'markOpening', // { + 125 => 'markClosing', // } + 92 => 'markBackslash', // \ + 10 => 'markNewline', // LF + 13 => 'markNewline' // CR + ); + + $this->phpWord = $phpWord; + $this->section = $phpWord->addSection(); + $this->textrun = $this->section->addTextRun(); + $this->length = strlen($this->rtf); + + $this->flags['paragraph'] = true; // Set paragraph flag from the beginning + + // Walk each characters + while ($this->offset < $this->length) { + $char = $this->rtf[$this->offset]; + $ascii = ord($char); + + if (array_key_exists($ascii, $markers)) { // Marker found: {, }, \, LF, or CR + $markerFunction = $markers[$ascii]; + $this->$markerFunction(); + } else { + if ($this->isControl === false) { // Non control word: Push character + $this->pushText($char); + } else { + if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control + $this->control .= $char; + $this->isFirst = false; + } else { // Delimiter found: Parse buffered control + if ($this->isFirst) { + $this->isFirst = false; + } else { + if ($char == ' ') { // Discard space as a control word delimiter + $this->flushControl(true); + } + } + } + } + } + $this->offset++; + } + $this->flushText(); + } + + /** + * Mark opening braket `{` character + */ + private function markOpening() + { + $this->flush(true); + array_push($this->groups, $this->flags); + } + + /** + * Mark closing braket `}` character + */ + private function markClosing() + { + $this->flush(true); + $this->flags = array_pop($this->groups); + } + + /** + * Mark backslash `\` character + */ + private function markBackslash() + { + if ($this->isFirst) { + $this->setControl(false); + $this->text .= '\\'; + } else { + $this->flush(); + $this->setControl(true); + $this->control = ''; + } + } + + /** + * Mark newline character: Flush control word because it's not possible to span multiline + */ + private function markNewline() + { + if ($this->isControl) { + $this->flushControl(true); + } + } + + /** + * Flush control word or text + * + * @param bool $isControl + */ + private function flush($isControl = false) + { + if ($this->isControl) { + $this->flushControl($isControl); + } else { + $this->flushText(); + } + } + + /** + * Flush control word + * + * @param bool $isControl + */ + private function flushControl($isControl = false) + { + if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) { + list(, $control, $parameter) = $match; + $this->parseControl($control, $parameter); + } + + if ($isControl === true) { + $this->setControl(false); + } + } + + /* + * Flush text in queue + */ + private function flushText() + { + if ($this->text != '') { + if (isset($this->flags['property'])) { + $this->flags['value'] = $this->text; + var_dump($this->flags); + } else { + if ($this->flags['paragraph'] === true) { + $this->flags['paragraph'] = false; + $this->flags['text'] = $this->text; + } + } + if (!isset($this->flags['skipped'])) { + $this->textrun->addText($this->text); + } + + $this->text = ''; + } + } + + /** + * Reset control word and first char state + * + * @param bool $state + */ + private function setControl($value) + { + $this->isControl = $value; + $this->isFirst = $value; + } + + /** + * Push text into queue + * + * @param string $char + */ + private function pushText($char) + { + if ($char == '<') { + $this->text .= "<"; + } elseif ($char == '>') { + $this->text .= ">"; + } else { + $this->text .= $char; + } + } + + /** + * Parse control + * + * @param string $control + * @param string $parameter + */ + private function parseControl($control, $parameter) + { + $controls = array( + 'par' => array(self::PARA, 'paragraph', true), + 'b' => array(self::STYL, 'bold', true), + 'i' => array(self::STYL, 'italic', true), + 'u' => array(self::STYL, 'underline', true), + 'fonttbl' => array(self::SKIP, 'fonttbl', null), + 'colortbl' => array(self::SKIP, 'colortbl', null), + 'info' => array(self::SKIP, 'info', null), + 'generator' => array(self::SKIP, 'generator', null), + 'title' => array(self::SKIP, 'title', null), + 'subject' => array(self::SKIP, 'subject', null), + 'category' => array(self::SKIP, 'category', null), + 'keywords' => array(self::SKIP, 'keywords', null), + 'comment' => array(self::SKIP, 'comment', null), + 'shppict' => array(self::SKIP, 'pic', null), + 'fldinst' => array(self::SKIP, 'link', null), + ); + + if (array_key_exists($control, $controls)) { + list($mode, $property, $value) = $controls[$control]; + switch ($mode) { + case self::PARA: // Paragraph + $this->textrun = $this->section->addTextRun(); + $this->flags[$property] = $value; + break; + case self::STYL: // Style + $this->flags[$property] = $value; + break; + case self::SKIP: // Destination + $this->flags['property'] = $property; + $this->flags['skipped'] = true; + } + } + } +} diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 60474ce9f3..153152ee63 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -56,18 +56,30 @@ public function getDomFromZip($zipFile, $xmlFile) $zip = new ZipArchive(); $zip->open($zipFile); - $contents = $zip->getFromName($xmlFile); + $content = $zip->getFromName($xmlFile); $zip->close(); - if ($contents === false) { + if ($content === false) { return false; } else { - $this->dom = new \DOMDocument(); - $this->dom->loadXML($contents); - return $this->dom; + return $this->getDomFromString($content); } } + /** + * Get DOMDocument from content string + * + * @param string $content + * @return \DOMDocument + */ + public function getDomFromString($content) + { + $this->dom = new \DOMDocument(); + $this->dom->loadXML($content); + + return $this->dom; + } + /** * Get elements * diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index c401b50078..15a0c303e8 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -123,7 +123,7 @@ private function writeFontTable() $content .= '{'; $content .= '\fonttbl'; foreach ($this->fontTable as $index => $font) { - $content .= "{\\f{$index}\\fnil\\fcharset0{$font};}"; + $content .= "{\\f{$index}\\fnil\\fcharset0 {$font};}"; } $content .= '}'; $content .= PHP_EOL; From 079d08e94a431341c4e8ebb5e092dca4493032dd Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Wed, 28 May 2014 17:59:44 +0200 Subject: [PATCH 146/167] Added Field Element --- samples/Sample_27_Field.php | 21 +++++ src/PhpWord/Element/AbstractContainer.php | 12 +-- src/PhpWord/Element/Field.php | 75 ++++++++-------- src/PhpWord/Writer/Word2007/Element/Field.php | 88 +++++++++++++++++++ tests/PhpWord/Tests/Element/FieldTest.php | 75 ++++++++++++++++ 5 files changed, 225 insertions(+), 46 deletions(-) create mode 100644 samples/Sample_27_Field.php create mode 100644 src/PhpWord/Writer/Word2007/Element/Field.php create mode 100644 tests/PhpWord/Tests/Element/FieldTest.php diff --git a/samples/Sample_27_Field.php b/samples/Sample_27_Field.php new file mode 100644 index 0000000000..6a556cca92 --- /dev/null +++ b/samples/Sample_27_Field.php @@ -0,0 +1,21 @@ +addSection(); + +// Add Field elements +// See Element/Field.php for all options +$section->addField('DATE', array('dateformat'=>'d-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar')); +$section->addField('PAGE', array('format'=>'ArabicDash')); +$section->addField('NUMPAGES', array('format'=>'Arabic', 'numformat'=>'0,00'), array('PreserveFormat')); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 56425f4f31..85aa5d5a6d 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -56,7 +56,7 @@ protected function addElement($elementName) // Get arguments $args = func_get_args(); - $withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun')); + $withoutP = in_array($this->container, array('TextRun', 'Footnote', 'Endnote', 'ListItemRun', 'Field')); if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) { $args[3] = null; // Remove paragraph style for texts in textrun } @@ -147,14 +147,10 @@ public function addTextRun($paragraphStyle = null) * Add field element * @param */ - public function addField($type = null, $properties = array(), $options = array()){ - //$this->checkValidity('Field'); - $elementDocPart = $this->checkElementDocPart(); - $element = new Field($type, $properties, $options); - $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($element); + public function addField($type = null, $properties = array(), $options = array()) + { + return $this->addElement('Field', $type, $properties, $options); - return $element; } /** diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index 111d774e9c..5d6101e225 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -15,19 +15,6 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ -/* - * - - - - - 5 - - - - */ - - namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Shared\String; @@ -37,22 +24,35 @@ */ class Field extends AbstractElement { - /** @const */ - //self::$fieldsArray; + + /** + * Field properties and options. Depending on type, a field can have different properties + * and options + * + * @var array + */ protected $fieldsArray = array( - 'PAGE'=>array( - 'properties'=>array( - 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'), - ), - 'options'=>array() + 'PAGE'=>array( + 'properties'=>array( + 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'), + ), + 'options'=>array('PreserveFormat') ), 'NUMPAGES'=>array( - 'properties'=>array( - 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'), - 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%') - ), - 'options'=>array() + 'properties'=>array( + 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'), + 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%') + ), + 'options'=>array('PreserveFormat') + ), + 'DATE'=>array( + 'properties'=> array( + 'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd', + 'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss', + 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss') + ), + 'options'=>array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat') ) ); @@ -128,15 +128,14 @@ public function getType() public function setProperties($properties = array()) { if (is_array($properties)) { -//CREATE FUNCTION, WHICH MATCHES SUBARRAY - - if (array_key_exists($properties, $this->fieldsArray[$this->type])) { - $this->properties=array_merge($this->properties, $properties); - } else { - throw new \InvalidArgumentException("Invalid property"); + foreach ($properties as $propkey => $propval) { + if (!(array_key_exists($propkey, $this->fieldsArray[$this->type]['properties']))) { + throw new \InvalidArgumentException("Invalid property"); + } } + $this->properties=array_merge($this->properties, $properties); } - return self; + return $this->properties; } /** @@ -158,13 +157,14 @@ public function getProperties() public function setOptions($options = array()) { if (is_array($options)) { - if (array_key_exists($options, self::$fieldsArray[$this->type])) { - $this->options=array_merge($this->options, $options); - } else { - throw new \InvalidArgumentException("Invalid option"); + foreach ($options as $optionkey => $optionval) { + if (!(array_key_exists($optionkey, $this->fieldsArray[$this->type]['options']))) { + throw new \InvalidArgumentException("Invalid option"); + } } + $this->options=array_merge($this->options, $options); } - return self; + return $this->options; } /** @@ -176,5 +176,4 @@ public function getOptions() { return $this->options; } - } diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php new file mode 100644 index 0000000000..24656537c6 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Field.php @@ -0,0 +1,88 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Field) { + return; + } + + $instruction=' '.$element->getType().' '; + $properties=$element->getProperties(); + foreach ($properties as $propkey => $propval) { + switch ($propkey) { + case 'format': + $instruction.='\* '.$propval.' '; + break; + case 'numformat': + $instruction.='\* '.$propval.' '; + break; + case 'dateformat': + $instruction.='\@ "'.$propval.'" '; + break; + } + } + + $options=$element->getOptions(); + foreach ($options as $option) { + switch ($option) { + case 'PreserveFormat': + $instruction.='\* MERGEFORMAT '; + break; + case 'LunarCalendar': + $instruction.='\h '; + break; + case 'SakaEraCalendar': + $instruction.='\s '; + break; + case 'LastUsedFormat': + $instruction.='\l '; + break; + } + } + $this->writeOpeningWP(); + $xmlWriter->startElement('w:fldSimple'); + $xmlWriter->writeAttribute('w:instr', $instruction); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:rPr'); + $xmlWriter->startElement('w:noProof'); + $xmlWriter->endElement(); // w:noProof + $xmlWriter->endElement(); // w:rPr + + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw('1'); + $xmlWriter->endElement(); // w:t + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:fldSimple + + $this->writeClosingWP(); + } +} diff --git a/tests/PhpWord/Tests/Element/FieldTest.php b/tests/PhpWord/Tests/Element/FieldTest.php new file mode 100644 index 0000000000..68fd8a8479 --- /dev/null +++ b/tests/PhpWord/Tests/Element/FieldTest.php @@ -0,0 +1,75 @@ +assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); + } + + /** + * New instance with type + */ + public function testConstructWithType() + { + $oField = new Field('DATE'); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); + $this->assertEquals($oField->getType(), 'DATE'); + } + + /** + * New instance with type and properties + */ + public function testConstructWithTypeProperties() + { + $oField = new Field('DATE', array('dateformat'=>'d-M-yyyy')); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); + $this->assertEquals($oField->getType(), 'DATE'); + $this->assertEquals($oField->getProperties(), array('dateformat'=>'d-M-yyyy')); + } + + /** + * New instance with type and properties and options + */ + public function testConstructWithTypePropertiesOptions() + { + $oField = new Field('DATE', array('dateformat'=>'d-M-yyyy'), array('SakaEraCalendar', 'PreserveFormat')); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); + $this->assertEquals($oField->getType(), 'DATE'); + $this->assertEquals($oField->getProperties(), array('dateformat'=>'d-M-yyyy')); + $this->assertEquals($oField->getOptions(), array('SakaEraCalendar', 'PreserveFormat')); + } +} From 8f74f26fd483d9ef8f56250388df37bf708d0072 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Wed, 28 May 2014 20:35:24 +0200 Subject: [PATCH 147/167] Travis build error fix --- src/PhpWord/Element/Field.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index 5d6101e225..0bde038770 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -128,7 +128,7 @@ public function getType() public function setProperties($properties = array()) { if (is_array($properties)) { - foreach ($properties as $propkey => $propval) { + foreach (array_keys($properties) as $propkey) { if (!(array_key_exists($propkey, $this->fieldsArray[$this->type]['properties']))) { throw new \InvalidArgumentException("Invalid property"); } @@ -157,7 +157,7 @@ public function getProperties() public function setOptions($options = array()) { if (is_array($options)) { - foreach ($options as $optionkey => $optionval) { + foreach (array_keys($options) as $optionkey) { if (!(array_key_exists($optionkey, $this->fieldsArray[$this->type]['options']))) { throw new \InvalidArgumentException("Invalid option"); } From 2d88ea22b4f0bd3ea6f62a81ff3fc4b676f3e016 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 29 May 2014 15:09:02 +0700 Subject: [PATCH 148/167] RTF Reader: Split control parsers into functions --- samples/Sample_11_ReadWord2007.php | 3 +- samples/Sample_24_ReadODText.php | 3 +- samples/Sample_27_ReadRTF.php | 4 +- samples/Sample_Header.php | 4 +- .../{rtf.rtf => Sample_27_ReadRTF.rtf} | 0 src/PhpWord/Reader/RTF.php | 1 + src/PhpWord/Reader/RTF/Document.php | 82 +++++++++++++------ 7 files changed, 64 insertions(+), 33 deletions(-) rename samples/resources/{rtf.rtf => Sample_27_ReadRTF.rtf} (100%) diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index 09d9cab079..c0b54c7a49 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -3,7 +3,8 @@ // Read contents $name = basename(__FILE__, '.php'); -$source = "resources/{$name}.docx"; +$source = __DIR__ . "/resources/{$name}.docx"; + echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::load($source); diff --git a/samples/Sample_24_ReadODText.php b/samples/Sample_24_ReadODText.php index bb5332e662..42df23ae2b 100644 --- a/samples/Sample_24_ReadODText.php +++ b/samples/Sample_24_ReadODText.php @@ -3,7 +3,8 @@ // Read contents $name = basename(__FILE__, '.php'); -$source = "resources/{$name}.odt"; +$source = __DIR__ . "/resources/{$name}.odt"; + echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'ODText'); diff --git a/samples/Sample_27_ReadRTF.php b/samples/Sample_27_ReadRTF.php index a28ba40b5b..76ac3d48bb 100644 --- a/samples/Sample_27_ReadRTF.php +++ b/samples/Sample_27_ReadRTF.php @@ -3,9 +3,7 @@ // Read contents $name = basename(__FILE__, '.php'); -$source = "results/Sample_01_SimpleText.rtf"; -$source = "resources/rtf.rtf"; -$source = "results/Sample_11_ReadWord2007.rtf"; +$source = __DIR__ . "/resources/{$name}.rtf"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'RTF'); diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index f39bda169b..7af23c94d2 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -63,8 +63,8 @@ function write($phpWord, $filename, $writers) $result .= date('H:i:s') . " Write to {$writer} format"; if (!is_null($extension)) { $xmlWriter = IOFactory::createWriter($phpWord, $writer); - $xmlWriter->save("{$filename}.{$extension}"); - rename("{$filename}.{$extension}", "results/{$filename}.{$extension}"); + $xmlWriter->save(__DIR__ . "/{$filename}.{$extension}"); + rename(__DIR__ . "/{$filename}.{$extension}", __DIR__ . "/results/{$filename}.{$extension}"); } else { $result .= ' ... NOT DONE!'; } diff --git a/samples/resources/rtf.rtf b/samples/resources/Sample_27_ReadRTF.rtf similarity index 100% rename from samples/resources/rtf.rtf rename to samples/resources/Sample_27_ReadRTF.rtf diff --git a/src/PhpWord/Reader/RTF.php b/src/PhpWord/Reader/RTF.php index 1856116cd7..9d5d813bf4 100644 --- a/src/PhpWord/Reader/RTF.php +++ b/src/PhpWord/Reader/RTF.php @@ -31,6 +31,7 @@ class RTF extends AbstractReader implements ReaderInterface * Loads PhpWord from file * * @param string $docFile + * @throws \Exception * @return \PhpOffice\PhpWord\PhpWord */ public function load($docFile) diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index ccb9b59532..84e9c1ed72 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -18,8 +18,6 @@ namespace PhpOffice\PhpWord\Reader\RTF; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Element\Section; -use PhpOffice\PhpWord\Element\TextRun; /** * RTF document reader @@ -35,9 +33,9 @@ class Document { /** @const int */ - const PARA = 0; - const STYL = 1; - const SKIP = 2; + const PARA = 'readParagraph'; + const STYL = 'readStyle'; + const SKIP = 'readSkip'; /** * PhpWord object @@ -247,8 +245,8 @@ private function flush($isControl = false) private function flushControl($isControl = false) { if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) { - list(, $control, $parameter) = $match; - $this->parseControl($control, $parameter); + list(, $control) = $match; + $this->parseControl($control); } if ($isControl === true) { @@ -256,23 +254,25 @@ private function flushControl($isControl = false) } } - /* + /** * Flush text in queue */ private function flushText() { if ($this->text != '') { - if (isset($this->flags['property'])) { + if (isset($this->flags['property'])) { // Set property $this->flags['value'] = $this->text; - var_dump($this->flags); - } else { + } else { // Set text if ($this->flags['paragraph'] === true) { $this->flags['paragraph'] = false; $this->flags['text'] = $this->text; } } + + // Add text if it's not flagged as skipped if (!isset($this->flags['skipped'])) { - $this->textrun->addText($this->text); + $textrun = $this->textrun->addText($this->text); + $this->flags['element'] = &$textrun; } $this->text = ''; @@ -282,7 +282,7 @@ private function flushText() /** * Reset control word and first char state * - * @param bool $state + * @param bool $value */ private function setControl($value) { @@ -312,7 +312,7 @@ private function pushText($char) * @param string $control * @param string $parameter */ - private function parseControl($control, $parameter) + private function parseControl($control) { $controls = array( 'par' => array(self::PARA, 'paragraph', true), @@ -333,19 +333,49 @@ private function parseControl($control, $parameter) ); if (array_key_exists($control, $controls)) { - list($mode, $property, $value) = $controls[$control]; - switch ($mode) { - case self::PARA: // Paragraph - $this->textrun = $this->section->addTextRun(); - $this->flags[$property] = $value; - break; - case self::STYL: // Style - $this->flags[$property] = $value; - break; - case self::SKIP: // Destination - $this->flags['property'] = $property; - $this->flags['skipped'] = true; + list($function) = $controls[$control]; + if (method_exists($this, $function)) { + $this->$function($controls[$control]); } } } + + /** + * Read paragraph + * + * @param array $directives + */ + private function readParagraph($directives) + { + list(, $property, $value) = $directives; + $this->textrun = $this->section->addTextRun(); + $this->flags[$property] = $value; + } + + /** + * Read style + * + * @param array $directives + */ + private function readStyle($directives) + { + list(, $property, $value) = $directives; + $this->flags[$property] = $value; + if (isset($this->flags['element'])) { + $element = &$this->flags['element']; + $element->getFontStyle()->setStyleValue($property, $value); + } + } + + /** + * Read skip + * + * @param array $directives + */ + private function readSkip($directives) + { + list(, $property) = $directives; + $this->flags['property'] = $property; + $this->flags['skipped'] = true; + } } From e81d92e26529ced07481f898661526c6ca7f4a9d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 29 May 2014 16:21:15 +0700 Subject: [PATCH 149/167] Update changelog, docs, and unit tests for new `Field` element #251 --- CHANGELOG.md | 8 +-- docs/elements.rst | 18 +++++- docs/src/documentation.md | 16 +++++- samples/Sample_27_Field.php | 12 +++- src/PhpWord/Element/AbstractContainer.php | 10 +++- src/PhpWord/Element/Field.php | 55 +++++++++---------- src/PhpWord/Writer/Word2007/Element/Field.php | 29 +++++----- .../Tests/Writer/Word2007/ElementTest.php | 2 +- .../Writer/Word2007/Part/DocumentTest.php | 4 ++ 9 files changed, 98 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f0c3ee9a..4584c4a4db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,15 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new relative and absolute positioning for image; new `TextBox` and `ListItemRun` element; refactorings of writer classes into parts, elements, and styles; and ability to add elements to PHPWord object via HTML. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. ### Features - Image: Ability to define relative and absolute positioning - @basjan GH-217 - Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 -- TextBox: Ability to add textbox in section, header, and footer - @basjan @ivanlanin GH-228 GH-229 -- TextBox: Ability to add table inside textbox - @basjan GH-231 +- Element: New `TextBox` element - @basjan @ivanlanin GH-228 GH-229 GH-231 - HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 -- ListItemRun: New element that can add a list item with inline formatting like a textrun - @basjan GH-235 +- Element: New `ListItemRun` element that can add a list item with inline formatting like a textrun - @basjan GH-235 - Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 - RTF Writer: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 - Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 @@ -30,6 +29,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3; new r - Image: Enable "image float left" - @ivanlanin GH-244 - RTF Writer: Ability to write document properties - @ivanlanin - RTF Writer: Ability to write image - @ivanlanin +- Element: New `Field` element - @basjan GH-251 ### Bugfixes diff --git a/docs/elements.rst b/docs/elements.rst index c86d107483..7e0c33f62d 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -17,7 +17,7 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 4 | Title | v | ? | ? | ? | ? | ? | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 5 | Preserve Text | ? | v | v | v\* | ? | ? | +| 5 | Preserve Text | ? | v | v | v\* | - | - | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 6 | Text Break | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ @@ -39,7 +39,11 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 15 | Endnote | v | - | - | v\*\* | v\*\* | - | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 16 | CheckBox | v | v | v | v | ? | ? | +| 16 | CheckBox | v | v | v | v | - | - | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 17 | TextBox | v | v | v | v | - | - | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 18 | Field | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -473,3 +477,13 @@ Checkbox elements can be added to sections or table cells by using - ``$text`` Text following the check box - ``$fontStyle`` See "Font style" section. - ``$paragraphStyle`` See "Paragraph style" section. + +Textboxes +--------- + +To be completed + +Fields +------ + +To be completed diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 6d34ff9fbb..889842f9b9 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -33,6 +33,8 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Table of contents](#table-of-contents) - [Footnotes & endnotes](#footnotes-endnotes) - [Checkboxes](#checkboxes) + - [Textboxes](#textboxes) + - [Fields](#fields) - [Templates](#templates) - [Writers & readers](#writers-readers) - [OOXML](#ooxml) @@ -447,7 +449,7 @@ Below are the matrix of element availability in each container. The column shows | 2 | Text Run | v | v | v | v | - | - | | 3 | Link | v | v | v | v | v | v | | 4 | Title | v | ? | ? | ? | ? | ? | -| 5 | Preserve Text | ? | v | v | v* | ? | ? | +| 5 | Preserve Text | ? | v | v | v* | - | - | | 6 | Text Break | v | v | v | v | v | v | | 7 | Page Break | v | - | - | - | - | - | | 8 | List | v | v | v | v | - | - | @@ -458,7 +460,9 @@ Below are the matrix of element availability in each container. The column shows | 13 | TOC | v | - | - | - | - | - | | 14 | Footnote | v | - | - | v** | v** | - | | 15 | Endnote | v | - | - | v** | v** | - | -| 16 | CheckBox | v | v | v | v | ? | ? | +| 16 | CheckBox | v | v | v | v | - | - | +| 17 | TextBox | v | v | v | v | - | - | +| 18 | Field | v | v | v | v | v | v | Legend: @@ -832,6 +836,14 @@ $section->addCheckBox($name, $text, [$fontStyle], [$paragraphStyle]) - `$fontStyle` See "Font style" section. - `$paragraphStyle` See "Paragraph style" section. +## Textboxes + +To be completed. + +## Fields + +To be completed. + # Templates You can create a docx template with included search-patterns that can be replaced by any value you wish. Only single-line values can be replaced. To load a template file, use the `loadTemplate` method. After loading the docx template, you can use the `setValue` method to change the value of a search pattern. The search-pattern model is: `${search-pattern}`. It is not possible to add new PHPWord elements to a loaded template file. diff --git a/samples/Sample_27_Field.php b/samples/Sample_27_Field.php index 6a556cca92..fd75037275 100644 --- a/samples/Sample_27_Field.php +++ b/samples/Sample_27_Field.php @@ -10,10 +10,20 @@ // Add Field elements // See Element/Field.php for all options -$section->addField('DATE', array('dateformat'=>'d-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar')); +$section->addText('Date field:'); +$section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat')); + +$section->addText('Page field:'); $section->addField('PAGE', array('format'=>'ArabicDash')); + +$section->addText('Number of pages field:'); $section->addField('NUMPAGES', array('format'=>'Arabic', 'numformat'=>'0,00'), array('PreserveFormat')); +$textrun = $section->addTextRun(array('align' => 'center')); +$textrun->addText('This is the date of lunar calendar '); +$textrun->addField('DATE', array('dateformat'=>'d-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar')); +$textrun->addText(' written in a textrun.'); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 85aa5d5a6d..71c5ae2a5e 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -145,14 +145,17 @@ public function addTextRun($paragraphStyle = null) /** * Add field element - * @param + * + * @param string $type + * @param array $properties + * @param array $options */ public function addField($type = null, $properties = array(), $options = array()) { return $this->addElement('Field', $type, $properties, $options); - + } - + /** * Add link element * @@ -327,6 +330,7 @@ private function checkValidity($method) 'TextBreak' => $allContainers, 'Image' => $allContainers, 'Object' => $allContainers, + 'Field' => $allContainers, 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index 0bde038770..7503dc9ba8 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -1,35 +1,34 @@ array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat') ) ); - + /** * Field type * @@ -81,8 +80,8 @@ class Field extends AbstractElement * Create a new Field Element * * @param string $type - * @param mixed $properties - * @param mixed $options + * @param array $properties + * @param array $options */ public function __construct($type = null, $properties = array(), $options = array()) { @@ -94,7 +93,7 @@ public function __construct($type = null, $properties = array(), $options = arra /** * Set Field type * - * @param string + * @param string $type * @return string */ public function setType($type = null) @@ -122,7 +121,7 @@ public function getType() /** * Set Field properties * - * @param array + * @param array $properties * @return self */ public function setProperties($properties = array()) @@ -130,10 +129,10 @@ public function setProperties($properties = array()) if (is_array($properties)) { foreach (array_keys($properties) as $propkey) { if (!(array_key_exists($propkey, $this->fieldsArray[$this->type]['properties']))) { - throw new \InvalidArgumentException("Invalid property"); + throw new \InvalidArgumentException("Invalid property"); } } - $this->properties=array_merge($this->properties, $properties); + $this->properties = array_merge($this->properties, $properties); } return $this->properties; } @@ -151,7 +150,7 @@ public function getProperties() /** * Set Field options * - * @param array + * @param array $options * @return self */ public function setOptions($options = array()) @@ -162,11 +161,11 @@ public function setOptions($options = array()) throw new \InvalidArgumentException("Invalid option"); } } - $this->options=array_merge($this->options, $options); + $this->options = array_merge($this->options, $options); } return $this->options; } - + /** * Get Field properties * diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php index 24656537c6..68c4c40c2c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Field.php +++ b/src/PhpWord/Writer/Word2007/Element/Field.php @@ -20,7 +20,7 @@ /** * Field element writer * - * @since 0.10.0 + * @since 0.11.0 */ class Field extends Text { @@ -30,44 +30,43 @@ class Field extends Text public function write() { $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); + $element = $this->getElement(); if (!$element instanceof \PhpOffice\PhpWord\Element\Field) { return; } - $instruction=' '.$element->getType().' '; - $properties=$element->getProperties(); + $instruction = ' ' . $element->getType() . ' '; + $properties = $element->getProperties(); foreach ($properties as $propkey => $propval) { switch ($propkey) { case 'format': - $instruction.='\* '.$propval.' '; - break; case 'numformat': - $instruction.='\* '.$propval.' '; + $instruction .= '\* ' . $propval . ' '; break; case 'dateformat': - $instruction.='\@ "'.$propval.'" '; + $instruction .= '\@ "' . $propval . '" '; break; } } - - $options=$element->getOptions(); + + $options = $element->getOptions(); foreach ($options as $option) { switch ($option) { case 'PreserveFormat': - $instruction.='\* MERGEFORMAT '; + $instruction .= '\* MERGEFORMAT '; break; case 'LunarCalendar': - $instruction.='\h '; + $instruction .= '\h '; break; case 'SakaEraCalendar': - $instruction.='\s '; + $instruction .= '\s '; break; case 'LastUsedFormat': - $instruction.='\l '; + $instruction .= '\l '; break; } } + $this->writeOpeningWP(); $xmlWriter->startElement('w:fldSimple'); $xmlWriter->writeAttribute('w:instr', $instruction); @@ -76,7 +75,7 @@ public function write() $xmlWriter->startElement('w:noProof'); $xmlWriter->endElement(); // w:noProof $xmlWriter->endElement(); // w:rPr - + $xmlWriter->startElement('w:t'); $xmlWriter->writeRaw('1'); $xmlWriter->endElement(); // w:t diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 4d1d7ce217..ee8b88ae61 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -30,7 +30,7 @@ public function testUnmatchedElements() { $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', - 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC' + 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', 'Field' ); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 8ed1246f99..09f7d6a412 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -83,6 +83,10 @@ public function testElements() 'innerMargin' => 10, 'borderSize' => 1, 'borderColor' => '#FF0')); $section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center')); $section->addListItemRun()->addText('List item run 1'); + $section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar')); + $section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat', 'SakaEraCalendar')); + $section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat', 'LastUsedFormat')); + $section->addField('PAGE', array('format'=>'ArabicDash')); $doc = TestHelperDOCX::getDocument($phpWord); From 7a42802b4882cfe9ecda44b2b0131bb11059c641 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 29 May 2014 17:37:26 +0700 Subject: [PATCH 150/167] RTF reader: Unit tests and some improvements --- CHANGELOG.md | 3 +- docs/intro.rst | 2 +- docs/src/documentation.md | 2 +- ...e_27_ReadRTF.php => Sample_28_ReadRTF.php} | 0 ...e_27_ReadRTF.rtf => Sample_28_ReadRTF.rtf} | 0 src/PhpWord/Reader/RTF/Document.php | 70 +++++++++++-------- tests/PhpWord/Tests/Reader/ODTextTest.php | 4 +- tests/PhpWord/Tests/Reader/RTFTest.php | 51 ++++++++++++++ tests/PhpWord/Tests/Reader/Word2007Test.php | 33 ++------- .../PhpWord/Tests/_files/documents/reader.rtf | 21 ++++++ 10 files changed, 126 insertions(+), 60 deletions(-) rename samples/{Sample_27_ReadRTF.php => Sample_28_ReadRTF.php} (100%) rename samples/resources/{Sample_27_ReadRTF.rtf => Sample_28_ReadRTF.rtf} (100%) create mode 100644 tests/PhpWord/Tests/Reader/RTFTest.php create mode 100644 tests/PhpWord/Tests/_files/documents/reader.rtf diff --git a/CHANGELOG.md b/CHANGELOG.md index 4584c4a4db..0ccba8cca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. ### Features @@ -30,6 +30,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three - RTF Writer: Ability to write document properties - @ivanlanin - RTF Writer: Ability to write image - @ivanlanin - Element: New `Field` element - @basjan GH-251 +- RTF Reader: Basic RTF reader - @ivanlanin GH-72 ### Bugfixes diff --git a/docs/intro.rst b/docs/intro.rst index a64fb2add6..3da729e83b 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -124,7 +124,7 @@ Readers +---------------------------+----------------------+--------+-------+-------+ | | Custom | ✓ | | | +---------------------------+----------------------+--------+-------+-------+ -| **Element Type** | Text | ✓ | ✓ | | +| **Element Type** | Text | ✓ | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+ | | Text Run | ✓ | | | +---------------------------+----------------------+--------+-------+-------+ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 889842f9b9..0f4d085b5b 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -114,7 +114,7 @@ Below are the supported features for each file formats. |-------------------------|--------------------|------|-----|-----| | **Document Properties** | Standard | ✓ | | | | | Custom | ✓ | | | -| **Element Type** | Text | ✓ | ✓ | | +| **Element Type** | Text | ✓ | ✓ | ✓ | | | Text Run | ✓ | | | | | Title | ✓ | ✓ | | | | Link | ✓ | | | diff --git a/samples/Sample_27_ReadRTF.php b/samples/Sample_28_ReadRTF.php similarity index 100% rename from samples/Sample_27_ReadRTF.php rename to samples/Sample_28_ReadRTF.php diff --git a/samples/resources/Sample_27_ReadRTF.rtf b/samples/resources/Sample_28_ReadRTF.rtf similarity index 100% rename from samples/resources/Sample_27_ReadRTF.rtf rename to samples/resources/Sample_28_ReadRTF.rtf diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index 84e9c1ed72..cb082fdc63 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -245,8 +245,8 @@ private function flush($isControl = false) private function flushControl($isControl = false) { if (preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match) === 1) { - list(, $control) = $match; - $this->parseControl($control); + list(, $control, $parameter) = $match; + $this->parseControl($control, $parameter); } if ($isControl === true) { @@ -271,8 +271,7 @@ private function flushText() // Add text if it's not flagged as skipped if (!isset($this->flags['skipped'])) { - $textrun = $this->textrun->addText($this->text); - $this->flags['element'] = &$textrun; + $this->readText(); } $this->text = ''; @@ -312,30 +311,36 @@ private function pushText($char) * @param string $control * @param string $parameter */ - private function parseControl($control) + private function parseControl($control, $parameter) { $controls = array( - 'par' => array(self::PARA, 'paragraph', true), - 'b' => array(self::STYL, 'bold', true), - 'i' => array(self::STYL, 'italic', true), - 'u' => array(self::STYL, 'underline', true), - 'fonttbl' => array(self::SKIP, 'fonttbl', null), - 'colortbl' => array(self::SKIP, 'colortbl', null), - 'info' => array(self::SKIP, 'info', null), - 'generator' => array(self::SKIP, 'generator', null), - 'title' => array(self::SKIP, 'title', null), - 'subject' => array(self::SKIP, 'subject', null), - 'category' => array(self::SKIP, 'category', null), - 'keywords' => array(self::SKIP, 'keywords', null), - 'comment' => array(self::SKIP, 'comment', null), - 'shppict' => array(self::SKIP, 'pic', null), - 'fldinst' => array(self::SKIP, 'link', null), + 'par' => array(self::PARA, 'paragraph', true), + 'b' => array(self::STYL, 'font', 'bold', true), + 'i' => array(self::STYL, 'font', 'italic', true), + 'u' => array(self::STYL, 'font', 'underline', true), + 'strike' => array(self::STYL, 'font', 'strikethrough',true), + 'fs' => array(self::STYL, 'font', 'size', $parameter), + 'qc' => array(self::STYL, 'paragraph', 'align', 'center'), + 'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter), + 'fonttbl' => array(self::SKIP, 'fonttbl', null), + 'colortbl' => array(self::SKIP, 'colortbl', null), + 'info' => array(self::SKIP, 'info', null), + 'generator' => array(self::SKIP, 'generator', null), + 'title' => array(self::SKIP, 'title', null), + 'subject' => array(self::SKIP, 'subject', null), + 'category' => array(self::SKIP, 'category', null), + 'keywords' => array(self::SKIP, 'keywords', null), + 'comment' => array(self::SKIP, 'comment', null), + 'shppict' => array(self::SKIP, 'pic', null), + 'fldinst' => array(self::SKIP, 'link', null), ); if (array_key_exists($control, $controls)) { list($function) = $controls[$control]; if (method_exists($this, $function)) { - $this->$function($controls[$control]); + $directives = $controls[$control]; + array_shift($directives); // remove the function variable; we won't need it + $this->$function($directives); } } } @@ -347,7 +352,7 @@ private function parseControl($control) */ private function readParagraph($directives) { - list(, $property, $value) = $directives; + list($property, $value) = $directives; $this->textrun = $this->section->addTextRun(); $this->flags[$property] = $value; } @@ -359,12 +364,8 @@ private function readParagraph($directives) */ private function readStyle($directives) { - list(, $property, $value) = $directives; - $this->flags[$property] = $value; - if (isset($this->flags['element'])) { - $element = &$this->flags['element']; - $element->getFontStyle()->setStyleValue($property, $value); - } + list($style, $property, $value) = $directives; + $this->flags['styles'][$style][$property] = $value; } /** @@ -374,8 +375,19 @@ private function readStyle($directives) */ private function readSkip($directives) { - list(, $property) = $directives; + list($property) = $directives; $this->flags['property'] = $property; $this->flags['skipped'] = true; } + + /** + * Read text + */ + private function readText() + { + $text = $this->textrun->addText($this->text); + if (isset($this->flags['styles']['font'])) { + $text->getFontStyle()->setStyleByArray($this->flags['styles']['font']); + } + } } diff --git a/tests/PhpWord/Tests/Reader/ODTextTest.php b/tests/PhpWord/Tests/Reader/ODTextTest.php index 4120c11eb5..fc4d2e337e 100644 --- a/tests/PhpWord/Tests/Reader/ODTextTest.php +++ b/tests/PhpWord/Tests/Reader/ODTextTest.php @@ -33,7 +33,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase public function testLoad() { $filename = __DIR__ . '/../_files/documents/reader.odt'; - $object = IOFactory::load($filename, 'ODText'); - $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); + $phpWord = IOFactory::load($filename, 'ODText'); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); } } diff --git a/tests/PhpWord/Tests/Reader/RTFTest.php b/tests/PhpWord/Tests/Reader/RTFTest.php new file mode 100644 index 0000000000..c495db6884 --- /dev/null +++ b/tests/PhpWord/Tests/Reader/RTFTest.php @@ -0,0 +1,51 @@ +assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); + } + + /** + * Test load exception + * + * @expectedException \Exception + * @expectedExceptionMessage Cannot read + */ + public function testLoadException() + { + $filename = __DIR__ . '/../_files/documents/foo.rtf'; + IOFactory::load($filename, 'RTF'); + } +} diff --git a/tests/PhpWord/Tests/Reader/Word2007Test.php b/tests/PhpWord/Tests/Reader/Word2007Test.php index 58890c9a44..f2257012a5 100644 --- a/tests/PhpWord/Tests/Reader/Word2007Test.php +++ b/tests/PhpWord/Tests/Reader/Word2007Test.php @@ -28,40 +28,24 @@ */ class Word2007Test extends \PHPUnit_Framework_TestCase { - /** - * Init - */ - public function tearDown() - { - } - /** * Test canRead() method */ public function testCanRead() { $object = new Word2007(); - $fqFilename = join( - DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'documents', 'reader.docx') - ); - $this->assertTrue($object->canRead($fqFilename)); + $filename = __DIR__ . '/../_files/documents/reader.docx'; + $this->assertTrue($object->canRead($filename)); } /** * Can read exception - * - * @expectedException \PhpOffice\PhpWord\Exception\Exception */ public function testCanReadFailed() { $object = new Word2007(); - $fqFilename = join( - DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'documents', 'foo.docx') - ); - $this->assertFalse($object->canRead($fqFilename)); - $object = IOFactory::load($fqFilename); + $filename = __DIR__ . '/../_files/documents/foo.docx'; + $this->assertFalse($object->canRead($filename)); } /** @@ -69,11 +53,8 @@ public function testCanReadFailed() */ public function testLoad() { - $fqFilename = join( - DIRECTORY_SEPARATOR, - array(PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'documents', 'reader.docx') - ); - $object = IOFactory::load($fqFilename); - $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); + $filename = __DIR__ . '/../_files/documents/reader.docx'; + $phpWord = IOFactory::load($filename); + $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); } } diff --git a/tests/PhpWord/Tests/_files/documents/reader.rtf b/tests/PhpWord/Tests/_files/documents/reader.rtf new file mode 100644 index 0000000000..400f43a5d9 --- /dev/null +++ b/tests/PhpWord/Tests/_files/documents/reader.rtf @@ -0,0 +1,21 @@ +{\rtf1 +\ansi\ansicpg1252 +\deff0 +{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset0 Times New Roman;}} +{\colortbl;\red255\green0\blue0;\red14\green0\blue0} +{\*\generator PhpWord;} + +{\info{\title }{\subject }{\category }{\keywords }{\comment }{\author }{\operator }{\creatim \yr2014\mo05\dy27\hr23\min36\sec45}{\revtim \yr2014\mo05\dy27\hr23\min36\sec45}{\company }{\manager }} +\deftab720\viewkind1\uc1\pard\nowidctlpar\lang1036\kerning1\fs20 +{Welcome to PhpWord}\par +\pard\nowidctlpar{\cf0\f0 Hello World!}\par +\par +\par +\pard\nowidctlpar{\cf0\f0\fs32\b\i I am styled by a definition.}\par +\pard\nowidctlpar{\cf0\f0 I am styled by a paragraph style definition.}\par +\pard\nowidctlpar\qc\sa100{\cf0\f0\fs32\b\i I am styled by both font and paragraph style.}\par +\pard\nowidctlpar{\cf1\f1\fs40\b\i\ul\strike\super I am inline styled.}\par +\par +{\field {\*\fldinst {HYPERLINK "http://www.google.com"}}{\fldrslt {Google}}}\par +\par +} \ No newline at end of file From 4bb3ffe5bd6cf6752d630393011bb4a381d26520 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 29 May 2014 18:13:57 +0700 Subject: [PATCH 151/167] Apply #250 fix a minor typo in the text styles example --- docs/elements.rst | 2 +- docs/src/documentation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/elements.rst b/docs/elements.rst index 7e0c33f62d..901832ebae 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -88,7 +88,7 @@ Inline style examples: $textrun = $section->addTextRun(); $textrun->addText('I am bold', array('bold' => true)); $textrun->addText('I am italic', array('italic' => true)); - $textrun->addText('I am colored, array('color' => 'AACC00')); + $textrun->addText('I am colored', array('color' => 'AACC00')); Defined style examples: diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 0f4d085b5b..0259dd8b5e 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -495,7 +495,7 @@ $section->addText('I am simple paragraph', $fontStyle, $paragraphStyle); $textrun = $section->addTextRun(); $textrun->addText('I am bold', array('bold' => true)); $textrun->addText('I am italic', array('italic' => true)); -$textrun->addText('I am colored, array('color' => 'AACC00')); +$textrun->addText('I am colored', array('color' => 'AACC00')); ``` Defined style examples: From 1580113d7b885c6717f21cf8c6190eb3841e0a3a Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 29 May 2014 16:44:00 +0200 Subject: [PATCH 152/167] Added Line element --- CHANGELOG.md | 3 +- CHANGELOG.md~ | 268 +++++++++++++++++++ samples/Sample_28_Line.php | 64 +++++ src/PhpWord/Element/AbstractContainer.php | 14 + src/PhpWord/Element/Line.php | 54 ++++ src/PhpWord/Style/Line.php | 256 ++++++++++++++++++ src/PhpWord/Writer/Word2007/Element/Line.php | 84 ++++++ src/PhpWord/Writer/Word2007/Style/Line.php | 180 +++++++++++++ tests/PhpWord/Tests/Element/LineTest.php | 76 ++++++ tests/PhpWord/Tests/Style/LineTest.php | 153 +++++++++++ 10 files changed, 1151 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md~ create mode 100644 samples/Sample_28_Line.php create mode 100644 src/PhpWord/Element/Line.php create mode 100644 src/PhpWord/Style/Line.php create mode 100644 src/PhpWord/Writer/Word2007/Element/Line.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Line.php create mode 100644 tests/PhpWord/Tests/Element/LineTest.php create mode 100644 tests/PhpWord/Tests/Style/LineTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ccba8cca9..a322b2e89c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, Line and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. ### Features @@ -30,6 +30,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three - RTF Writer: Ability to write document properties - @ivanlanin - RTF Writer: Ability to write image - @ivanlanin - Element: New `Field` element - @basjan GH-251 +- Element: New `Line` element - @basjan - RTF Reader: Basic RTF reader - @ivanlanin GH-72 ### Bugfixes diff --git a/CHANGELOG.md~ b/CHANGELOG.md~ new file mode 100644 index 0000000000..0ccba8cca9 --- /dev/null +++ b/CHANGELOG.md~ @@ -0,0 +1,268 @@ +# Changelog + +This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub. + +## 0.11.0 - Not yet released + +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. + +### Features + +- Image: Ability to define relative and absolute positioning - @basjan GH-217 +- Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 +- Element: New `TextBox` element - @basjan @ivanlanin GH-228 GH-229 GH-231 +- HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 +- Element: New `ListItemRun` element that can add a list item with inline formatting like a textrun - @basjan GH-235 +- Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 +- RTF Writer: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 +- Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 +- RTF Writer: Ability to add links and page breaks in RTF - @ivanlanin GH-196 +- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin +- Config: Ability to use a config file to store various common settings - @ivanlanin GH-200 +- ODT Writer: Enable inline font style in TextRun - @ivanlanin +- ODT Writer: Enable underline, strike/doublestrike, smallcaps/allcaps, superscript/subscript font style - @ivanlanin +- ODT Writer: Enable section and column - @ivanlanin +- PDF Writer: Add TCPDF and mPDF as optional PDF renderer library - @ivanlanin +- ODT Writer: Enable title element and custom document properties - @ivanlanin +- ODT Reader: Ability to read standard and custom document properties - @ivanlanin +- Word2007 Writer: Enable the missing custom document properties writer - @ivanlanin +- Image: Enable "image float left" - @ivanlanin GH-244 +- RTF Writer: Ability to write document properties - @ivanlanin +- RTF Writer: Ability to write image - @ivanlanin +- Element: New `Field` element - @basjan GH-251 +- RTF Reader: Basic RTF reader - @ivanlanin GH-72 + +### Bugfixes + +- Header: All images added to the second header were assigned to the first header - @basjan GH-222 +- Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234 +- PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin GH-150 +- Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin GH-248 + +### Deprecated + +- Static classes `Footnotes`, `Endnotes`, and `TOC` +- `Writer\Word2007\Part`: `Numbering::writeNumbering()`, `Settings::writeSettings()`, `WebSettings::writeWebSettings()`, `ContentTypes::writeContentTypes()`, `Styles::writeStyles()`, `Document::writeDocument()` all changed into `write()` +- `Writer\Word2007\Part\DocProps`: Split into `Writer\Word2007\Part\DocPropsCore` and `Writer\Word2007\Part\DocPropsApp` +- `Element\Title::getBookmarkId()` replaced by `Element\Title::getRelationId()` +- `Writer\HTML::writeDocument`: Replaced by `Writer\HTML::getContent` + +### Miscellaneous + +- License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211 +- Word2007 Writer: New `Style\Image` class - @ivanlanin +- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 +- QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin +- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin +- Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 +- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 +- Writer: Refactor writer parts using composite pattern - @ivanlanin +- Docs: Show code quality and test code coverage badge on README +- Style: Change behaviour of `set...` function of boolean properties; when none is defined, assumed true - @ivanlanin +- Shared: Unify PHP ZipArchive and PCLZip features into PhpWord ZipArchive - @ivanlanin + +## 0.10.1 - 21 May 2014 + +This is a bugfix release for `php-zip` requirement in Composer. + +- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich GH-246 + +## 0.10.0 - 4 May 2014 + +This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled. Basic ODText reader is introduced. + +### Features + +- Image: Get image dimensions without EXIF extension - @andrew-kzoo GH-184 +- Table: Add `tblGrid` element for Libre/Open Office table sizing - @gianis6 GH-183 +- Footnote: Ability to insert textbreak in footnote `$footnote->addTextBreak()` - @ivanlanin +- Footnote: Ability to style footnote reference mark by using `FootnoteReference` style - @ivanlanin +- Font: Add `bgColor` to font style to define background using HEX color - @jcarignan GH-168 +- Table: Add `exactHeight` to row style to define whether row height should be exact or atLeast - @jcarignan GH-168 +- Element: New `CheckBox` element for sections and table cells - @ozilion GH-156 +- Settings: Ability to use PCLZip as alternative to ZipArchive - @bskrtich @ivanlanin GH-106 GH-140 GH-185 +- Template: Ability to find & replace variables in headers & footers - @dgudgeon GH-190 +- Template: Ability to clone & delete block of text using `cloneBlock` and `deleteBlock` - @diego-vieira GH-191 +- TOC: Ability to have two or more TOC in one document and to set min and max depth for TOC - @Pyreweb GH-189 +- Table: Ability to add footnote in table cell - @ivanlanin GH-187 +- Footnote: Ability to add image in footnote - @ivanlanin GH-187 +- ListItem: Ability to add list item in header/footer - @ivanlanin GH-187 +- CheckBox: Ability to add checkbox in header/footer - @ivanlanin GH-187 +- Link: Ability to add link in header/footer - @ivanlanin GH-187 +- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187 +- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19 +- General: Add `Style::resetStyles()` - @ivanlanin GH-187 +- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin +- Endnote: Ability to add endnotes - @ivanlanin +- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198 +- ODT Writer: Basic table writing support - @ivanlanin +- Image: Keep image aspect ratio if only 1 dimension styled - @japonicus GH-194 +- HTML Writer: Basic HTML writer: text, textrun, link, title, textbreak, table, image (as Base64), footnote, endnote - @ivanlanin GH-203 GH-67 GH-147 +- PDF Writer: Basic PDF writer using DomPDF: All HTML element except image - @ivanlanin GH-68 +- DOCX Writer: Change `docProps/app.xml` `Application` to `PHPWord` - @ivanlanin +- DOCX Writer: Create `word/settings.xml` and `word/webSettings.xml` dynamically - @ivanlanin +- ODT Writer: Basic image writing - @ivanlanin +- ODT Writer: Link writing - @ivanlanin +- ODT Reader: Basic ODText Reader - @ivanlanin GH-71 +- Section: Ability to define gutter and line numbering - @ivanlanin +- Font: Small caps, all caps, and double strikethrough - @ivanlanin GH-151 +- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin GH-199 +- Style: Remove `bgColor` from `Font`, `Table`, and `Cell` and put it into the new `Shading` style - @ivanlanin +- Style: New `Indentation` and `Spacing` style - @ivanlanin +- Paragraph: Ability to define first line and right indentation - @ivanlanin + +### Bugfixes + +- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin GH-170 +- Documentation: Error in a function - @theBeerNut GH-195 + +### Deprecated + +- `createTextRun` replaced by `addTextRun` +- `createFootnote` replaced by `addFootnote` +- `createHeader` replaced by `addHeader` +- `createFooter` replaced by `addFooter` +- `createSection` replaced by `addSection` +- `Element\Footnote::getReferenceId` replaced by `Element\AbstractElement::getRelationId` +- `Element\Footnote::setReferenceId` replaced by `Element\AbstractElement::setRelationId` +- `Footnote::addFootnoteLinkElement` replaced by `Media::addElement` +- `Footnote::getFootnoteLinkElements` replaced by `Media::getElements` +- All current methods on `Media` +- `Element\Link::getLinkSrc` replaced by `Element\Link::getTarget` +- `Element\Link::getLinkName` replaced by `Element\Link::getText` +- `Style\Cell::getDefaultBorderColor` + +### Miscellaneous + +- Documentation: Simplify page level docblock - @ivanlanin GH-179 +- Writer: Refactor writer classes and create a new `Write\AbstractWriter` abstract class - @ivanlanin GH-160 +- General: Refactor folders: `Element` and `Exception` - @ivanlanin GH-187 +- General: Remove legacy `HashTable` and `Shared\ZipStreamWrapper` and all related properties/methods - @ivanlanin GH-187 +- Element: New `AbstractElement` abstract class - @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 - @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 +- Style: New `Style\AbstractStyle` abstract class - @ivanlanin GH-187 +- Writer: New 'ODText\Base` class - @ivanlanin GH-187 +- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin +- General: Add some unit tests for Shared & Element (100%!) - @Progi1984 +- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59 +- Refactor: Remove Style\Tabs - @ivanlanin +- Refactor: Apply composite pattern for writers - @ivanlanin +- Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin +- Refactor: Apply composite pattern for Word2007 reader - @ivanlanin + +## 0.9.1 - 27 Mar 2014 + +This is a bugfix release for PSR-4 compatibility. + +- Fixed PSR-4 composer autoloader - @AntonTyutin + +## 0.9.0 - 26 Mar 2014 + +This release marked the transformation to namespaces (PHP 5.3+). + +### Features + +- Image: Ability to use remote or GD images using `addImage()` on sections, headers, footer, cells, and textruns - @ivanlanin +- Header: Ability to use remote or GD images using `addWatermark()` - @ivanlanin + +### Bugfixes + +- Preserve text doesn't render correctly when the text is not the first word, e.g. 'Page {PAGE}' - @ivanlanin + +### Miscellaneous + +- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82 +- Reorganize and redesign samples folder - @ivanlanin GH-137 +- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58 +- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull +- Compliance to phpDocumentor - @ivanlanin +- Merge Style\TableFull into Style\Table. Style\TableFull is deprecated - @ivanlanin GH-160 +- Merge Section\MemoryImage into Section\Image. Section\Image is deprecated - @ivanlanin GH-160 + +## 0.8.1 - 17 Mar 2014 + +This is a bugfix release for image detection functionality. + +- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull + +## 0.8.0 - 15 Mar 2014 + +This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage. + +### Features + +- Template: Permit to save a template generated as a file (PHPWord_Template::saveAs()) - @RomanSyroeshko GH-56 GH-57 +- Word2007: Support sections page numbering - @gabrielbull +- Word2007: Added line height methods to mirror the line height settings in Word in the paragraph styling - @gabrielbull +- Word2007: Added support for page header & page footer height - @JillElaine GH-5 +- General: Add ability to manage line breaks after image insertion - @bskrtich GH-6 GH-66 GH-84 +- Template: Ability to limit number of replacements performed by setValue() method of Template class - @RomanSyroeshko GH-52 GH-53 GH-85 +- Table row: Repeat as header row & allow row to break across pages - @ivanlanin GH-48 GH-86 +- Table: Table width in percentage - @ivanlanin GH-48 GH-86 +- Font: Superscript and subscript - @ivanlanin GH-48 GH-86 +- Paragraph: Hanging paragraph - @ivanlanin GH-48 GH-86 +- Section: Multicolumn and section break - @ivanlanin GH-48 GH-86 +- Template: Ability to apply XSL style sheet to Template - @RomanSyroeshko GH-46 GH-47 GH-83 +- General: PHPWord_Shared_Font::pointSizeToTwips() converter - @ivanlanin GH-87 +- Paragraph: Ability to define normal paragraph style with PHPWord::setNormalStyle() - @ivanlanin GH-87 +- Paragraph: Ability to define parent style (basedOn) and style for following paragraph (next) - @ivanlanin GH-87 +- Clone table rows on the fly when using a template document - @jeroenmoors GH-44 GH-88 +- Initial addition of basic footnote support - @deds GH-16 +- Paragraph: Ability to define paragraph pagination: widow control, keep next, keep lines, and page break before - @ivanlanin GH-92 +- General: PHPWord_Style_Font refactoring - @ivanlanin GH-93 +- Font: Use points instead of halfpoints internally. Conversion to halfpoints done during XML Writing. - @ivanlanin GH-93 +- Paragraph: setTabs() function - @ivanlanin GH-92 +- General: Basic support for TextRun on ODT and RTF - @ivanlanin GH-99 +- Reader: Basic Reader for Word2007 - @ivanlanin GH-104 +- TextRun: Allow Text Break in Text Run - @bskrtich GH-109 +- General: Support for East Asian fontstyle - @jhfangying GH-111 GH-118 +- Image: Use exif_imagetype to check image format instead of extension name - @gabrielbull GH-114 +- General: Setting for XMLWriter Compatibility option - @bskrtich GH-103 +- MemoryImage: Allow remote image when allow_url_open = on - @ivanlanin GH-122 +- TextBreak: Allow font and paragraph style for text break - @ivanlanin GH-18 + +### Bugfixes + +- Fixed bug with cell styling - @gabrielbull +- Fixed bug list items inside of cells - @gabrielbull +- Adding a value that contains "&" in a template breaks it - @SiebelsTim GH-51 +- Example in README.md is broken - @Progi1984 GH-89 +- General: PHPWord_Shared_Drawing::centimetersToPixels() conversion - @ivanlanin GH-94 +- Footnote: Corrupt DOCX reported by MS Word when sections > 1 and not every sections have footnote - @ivanlanin GH-125 + +### Miscellaneous + +- UnitTests - @Progi1984 + +## 0.7.0 - 28 Jan 2014 + +This is the first release after a long development hiatus in [CodePlex](https://phpword.codeplex.com/). This release initialized ODT and RTF Writer, along with some other new features for the existing Word2007 Writer, e.g. tab, multiple header, rowspan and colspan. [Composer](https://packagist.org/packages/phpoffice/phpword) and [Travis](https://travis-ci.org/PHPOffice/PHPWord) were added. + +### Features + +- Implement RTF Writer - @Progi1984 GH-1 +- Implement ODT Writer - @Progi1984 GH-2 +- Word2007: Add rowspan and colspan to cells - @kaystrobach +- Word2007: Support for tab stops - @RLovelett +- Word2007: Support Multiple headers - @RLovelett +- Word2007: Wrapping Styles to Images - @gabrielbull +- Added support for image wrapping style - @gabrielbull + +### Bugfixes + +- "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found - @RomanSyroeshko GH-32 +- PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input - @RomanSyroeshko GH-34 +- Temporary files naming logic in PHPWord_Template can lead to a collision - @RomanSyroeshko GH-38 + +### Miscellaneous + +- Add superscript/subscript styling in Excel2007 Writer - @MarkBaker +- add indentation support to paragraphs - @deds +- Support for Composer - @Progi1984 GH-27 +- Basic CI with Travis - @Progi1984 +- Added PHPWord_Exception and exception when could not copy the template - @Progi1984 +- IMPROVED: Moved examples out of Classes directory - @Progi1984 +- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo CP-49 diff --git a/samples/Sample_28_Line.php b/samples/Sample_28_Line.php new file mode 100644 index 0000000000..5a955702b7 --- /dev/null +++ b/samples/Sample_28_Line.php @@ -0,0 +1,64 @@ +addSection(); + +// Add Line elements +// See Element/Line.php for all options +$section->addText('Horizontal Line (Inline style):'); +$section->addLine( + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(0), + 'positioning' => 'absolute' + ) +); +$section->addText('Vertical Line (Inline style):'); +$section->addLine( + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(0), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1), + 'positioning' => 'absolute' + ) +); +// Two text break +$section->addTextBreak(1); + +$section->addText('Positioned Line (red):'); +$section->addLine( + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1), + 'positioning' => 'absolute', + 'posHorizontalRel' => 'page', + 'posVerticalRel' => 'page', + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(10), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(8), + 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, + 'color' => 'red' + ) +); + +$section->addText('Horizontal Formatted Line'); +$section->addLine( + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(0), + 'positioning' => 'absolute', + 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, + 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, + 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT, + 'weight' => 10 + ) +); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 71c5ae2a5e..6032f33fa9 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -156,6 +156,19 @@ public function addField($type = null, $properties = array(), $options = array() } + /** + * Add line element + * + * @param mixed $lineStyle + * @return \PhpOffice\PhpWord\Element\Line + */ + public function addLine($lineStyle = null) + { + return $this->addElement('Line', $lineStyle); + + } + + /** * Add link element * @@ -331,6 +344,7 @@ private function checkValidity($method) 'Image' => $allContainers, 'Object' => $allContainers, 'Field' => $allContainers, + 'Line' => $allContainers, 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), diff --git a/src/PhpWord/Element/Line.php b/src/PhpWord/Element/Line.php new file mode 100644 index 0000000000..eef3891435 --- /dev/null +++ b/src/PhpWord/Element/Line.php @@ -0,0 +1,54 @@ +style = $this->setStyle(new LineStyle(), $style); + } + + /** + * Get Image style + * + * @return ImageStyle + */ + public function getStyle() + { + return $this->style; + } +} diff --git a/src/PhpWord/Style/Line.php b/src/PhpWord/Style/Line.php new file mode 100644 index 0000000000..67a4328cde --- /dev/null +++ b/src/PhpWord/Style/Line.php @@ -0,0 +1,256 @@ +flip = $value; + } + + /** + * Get flip + * + * @return boolean + */ + public function getFlip() + { + return $this->flip; + } + + /** + * Set connectorType + * + * @param string $value + */ + public function setConnectorType($value = null) + { + $enum = array( + self::CONNECTOR_TYPE_STRAIGHT + ); + $this->connectorType = $this->setEnumVal($value, $enum, $this->connectorType); + } + + /** + * Get connectorType + * + * @return string + */ + public function getConnectorType() + { + return $this->connectorType; + } + + /** + * Set weight + * + * @param int $value Weight in points + */ + public function setWeight($value = null) + { + $this->weight = $value; + } + + /** + * Get weight + * + * @return int + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set color + * + * @param string $value + */ + public function setColor($value = null) + { + $this->color = $value; + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set beginArrow + * + * @param string $value + */ + public function setBeginArrow($value = null) + { + $enum = array( + self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND, + self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL + ); + $this->beginArrow = $this->setEnumVal($value, $enum, $this->beginArrow); + } + + /** + * Get beginArrow + * + * @return string + */ + public function getBeginArrow() + { + return $this->beginArrow; + } + /** + * Set endArrow + * + * @param string $value + */ + public function setEndArrow($value = null) + { + $enum = array( + self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND, + self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL + ); + $this->endArrow = $this->setEnumVal($value, $enum, $this->endArrow); + } + /** + * Get endArrow + * + * @return string + */ + public function getEndArrow() + { + return $this->endArrow; + } + /** + * Set Dash + * + * @param string $value + */ + public function setDash($value = null) + { + $enum = array( + self::DASH_STYLE_DASH, self::DASH_STYLE_DASH_DOT, self::DASH_STYLE_LONG_DASH, + self::DASH_STYLE_LONG_DASH_DOT, self::DASH_STYLE_LONG_DASH_DOT_DOT, self::DASH_STYLE_ROUND_DOT, + self::DASH_STYLE_SQUARE_DOT + ); + $this->dash = $this->setEnumVal($value, $enum, $this->dash); + } + /** + * Get Dash + * + * @return string + */ + public function getDash() + { + return $this->dash; + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php new file mode 100644 index 0000000000..411712053d --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -0,0 +1,84 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof LineElement) { + return; + } + + $style = $element->getStyle(); + $styleWriter = new LineStyleWriter($xmlWriter, $style); + + $id=$element->getElementIndex(); + if (!$this->withoutP) { + $xmlWriter->startElement('w:p'); + $styleWriter->writeAlignment(); + } + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:pict'); + if ($id==1) { //shapetype could be defined for each line separately, but then a unique id would be necessary + $xmlWriter->startElement('v:shapetype'); + $xmlWriter->writeAttribute('id', '_x0000_t32'); + $xmlWriter->writeAttribute('coordsize', '21600,21600'); + $xmlWriter->writeAttribute('o:spt', '32'); + $xmlWriter->writeAttribute('o:oned', 't'); + $xmlWriter->writeAttribute('path', 'm,l21600,21600e'); + $xmlWriter->writeAttribute('filled', 'f'); + $xmlWriter->startElement('v:path'); + $xmlWriter->writeAttribute('arrowok', 't'); + $xmlWriter->writeAttribute('fillok', 'f'); + $xmlWriter->writeAttribute('o:connecttype', 'none'); + $xmlWriter->endElement(); // v:path + $xmlWriter->startElement('o:lock'); + $xmlWriter->writeAttribute('v:ext', 'edit'); + $xmlWriter->writeAttribute('shapetype', 't'); + $xmlWriter->endElement(); // o:lock + $xmlWriter->endElement(); // v:shapetype + } + $xmlWriter->startElement('v:shape'); + $xmlWriter->writeAttribute('id', sprintf('_x0000_s1%1$03d', $id)); + $xmlWriter->writeAttribute('type', '#_x0000_t32'); //type should correspond to shapetype id + $styleWriter->write(); + $styleWriter->writeStroke(); + $styleWriter->writeW10Wrap(); + $xmlWriter->endElement(); // v:shape + $xmlWriter->endElement(); // w:pict + $xmlWriter->endElement(); // w:r + + if (!$this->withoutP) { + $xmlWriter->endElement(); // w:p + } + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php new file mode 100644 index 0000000000..dbf7773fef --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -0,0 +1,180 @@ +getStyle(); + if (!$style instanceof LineStyle) { + return; + } + $this->writeStyle($style); + } + + /** + * Write style attribute + * + * Copied function from Image/writeStyle in order to override getElementStyle + */ + protected function writeStyle(ImageStyle $style) + { + $xmlWriter = $this->getXmlWriter(); + + // Default style array + $styleArray = array( + 'mso-width-percent' => '0', + 'mso-height-percent' => '0', + 'mso-width-relative' => 'margin', + 'mso-height-relative' => 'margin', + ); + $styleArray = array_merge($styleArray, $this->getElementStyle($style)); + + // Absolute/relative positioning + $positioning = $style->getPositioning(); + $styleArray['position'] = $positioning; + if ($positioning !== null) { + $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); + $styleArray['mso-position-vertical'] = $style->getPosVertical(); + $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); + $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); + } + + // Wrapping style + $wrapping = $style->getWrappingStyle(); + if ($wrapping == LineStyle::WRAPPING_STYLE_INLINE) { + // Nothing to do when inline + } elseif ($wrapping == LineStyle::WRAPPING_STYLE_BEHIND) { + $styleArray['z-index'] = -251658752; + } else { + $styleArray['z-index'] = 251659264; + $styleArray['mso-position-horizontal'] = 'absolute'; + $styleArray['mso-position-vertical'] = 'absolute'; + } + + // w10 wrapping + if ($wrapping == LineStyle::WRAPPING_STYLE_SQUARE) { + $this->w10wrap = 'square'; + } elseif ($wrapping == LineStyle::WRAPPING_STYLE_TIGHT) { + $this->w10wrap = 'tight'; + } + + $imageStyle = $this->assembleStyle($styleArray); + + $xmlWriter->writeAttribute('style', $imageStyle); + $xmlWriter->writeAttribute('o:connectortype', $style->getConnectorType()); + + // Weight + $weight = $style->getWeight(); + if ($weight !== null) { + $xmlWriter->writeAttribute('strokeweight', $weight . 'pt'); + } + + // Color + $color = $style->getColor(); + if ($color !== null) { + $xmlWriter->writeAttribute('strokecolor', $color); + } + } + + /** + * Get element style + * + * @param \PhpOffice\PhpWord\Style\Image $style + * @return array + */ + private function getElementStyle(LineStyle $style) + { + $styles = array(); + $styleValues = array( + 'width' => $style->getWidth(), + 'height' => $style->getHeight(), + 'margin-top' => $style->getMarginTop(), + 'margin-left' => $style->getMarginLeft() + ); + foreach ($styleValues as $key => $value) { + if (!is_null($value)) { + $styles[$key] = $value . 'px'; + } + } + if ($style->getFlip()) { + $styles['flip']='y'; + } + + return $styles; + } + + public function writeStroke() + { + $style = $this->getStyle(); + $xmlWriter = $this->getXmlWriter(); + + $dash = $style->getDash(); + $beginArrow = $style->getBeginArrow(); + $endArrow = $style->getEndArrow(); + + if (($dash !== null) || ($beginArrow !== null) || ($endArrow !== null)) { + $xmlWriter->startElement('v:stroke'); + if ($beginArrow !== null) { + $xmlWriter->writeAttribute('startarrow', $beginArrow); + } + if ($endArrow !== null) { + $xmlWriter->writeAttribute('endarrow', $endArrow); + } + if ($dash !==null) { + switch ($dash) { + case LineStyle::DASH_STYLE_DASH: + $xmlWriter->writeAttribute('dashstyle', 'dash'); + break; + case LineStyle::DASH_STYLE_ROUND_DOT: + $xmlWriter->writeAttribute('dashstyle', '1 1'); + $xmlWriter->writeAttribute('endcap', 'round'); + break; + case LineStyle::DASH_STYLE_SQUARE_DOT: + $xmlWriter->writeAttribute('dashstyle', '1 1'); + break; + case LineStyle::DASH_STYLE_DASH_DOT: + $xmlWriter->writeAttribute('dashstyle', 'dashDot'); + break; + case LineStyle::DASH_STYLE_LONG_DASH: + $xmlWriter->writeAttribute('dashstyle', 'longDash'); + break; + case LineStyle::DASH_STYLE_LONG_DASH_DOT: + $xmlWriter->writeAttribute('dashstyle', 'longDashDot'); + break; + case LineStyle::DASH_STYLE_LONG_DASH_DOT_DOT: + $xmlWriter->writeAttribute('dashstyle', 'longDashDotDot'); + break; + } + } + $xmlWriter->endElement(); //v:stroke + } + } +} diff --git a/tests/PhpWord/Tests/Element/LineTest.php b/tests/PhpWord/Tests/Element/LineTest.php new file mode 100644 index 0000000000..429f9df69c --- /dev/null +++ b/tests/PhpWord/Tests/Element/LineTest.php @@ -0,0 +1,76 @@ +assertInstanceOf('PhpOffice\\PhpWord\\Element\\Line', $oLine); + $this->assertEquals($oLine->getStyle(), null); + } + + /** + * Get style name + */ + public function testStyleText() + { + $oLine = new Line('lineStyle'); + + $this->assertEquals($oLine->getStyle(), 'lineStyle'); + } + + /** + * Get style array + */ + public function testStyleArray() + { + $oLine = new Line( + array( + 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(14), + 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), + 'positioning' => 'absolute', + 'posHorizontalRel' => 'page', + 'posVerticalRel' => 'page', + 'flip' => true, + 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, + 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, + 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, + 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT, + 'weight' => 10 + ) + ); + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Line', $oLine->getStyle()); + } +} diff --git a/tests/PhpWord/Tests/Style/LineTest.php b/tests/PhpWord/Tests/Style/LineTest.php new file mode 100644 index 0000000000..92756e2443 --- /dev/null +++ b/tests/PhpWord/Tests/Style/LineTest.php @@ -0,0 +1,153 @@ + true, + 'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT, + 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, + 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, + 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT, + 'weight' => 10, + 'color' => 'red' + ); + foreach ($properties as $key => $value) { + $set = "set{$key}"; + $get = "get{$key}"; + $object->$set($value); + $this->assertEquals($value, $object->$get()); + } + } + + /** + * Test setStyleValue method + */ + public function testSetStyleValue() + { + $object = new Line(); + + $properties = array( + 'flip' => true, + 'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT, + 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, + 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, + 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT, + 'weight' => 10, + 'color' => 'red' + ); + foreach ($properties as $key => $value) { + $get = "get{$key}"; + $object->setStyleValue("{$key}", $value); + $this->assertEquals($value, $object->$get()); + } + } + + /** + * Test set/get flip + */ + public function testSetGetFlip() + { + $expected=true; + $object = new Line(); + $object->setFlip($expected); + $this->assertEquals($expected, $object->getFlip()); + } + + /** + * Test set/get connectorType + */ + public function testSetGetConnectorType() + { + $expected=\PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT; + $object = new Line(); + $object->setConnectorType($expected); + $this->assertEquals($expected, $object->getConnectorType()); + } + + /** + * Test set/get weight + */ + public function testSetGetWeight() + { + $expected=10; + $object = new Line(); + $object->setWeight($expected); + $this->assertEquals($expected, $object->getWeight()); + } + + /** + * Test set/get color + */ + public function testSetGetColor() + { + $expected='red'; + $object = new Line(); + $object->setColor($expected); + $this->assertEquals($expected, $object->getColor()); + } + + /** + * Test set/get dash + */ + public function testSetGetDash() + { + $expected=\PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT; + $object = new Line(); + $object->setDash($expected); + $this->assertEquals($expected, $object->getDash()); + } + + /** + * Test set/get beginArrow + */ + public function testSetGetBeginArrow() + { + $expected=\PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK; + $object = new Line(); + $object->setBeginArrow($expected); + $this->assertEquals($expected, $object->getBeginArrow()); + } + + /** + * Test set/get endArrow + */ + public function testSetGetEndArrow() + { + $expected=\PhpOffice\PhpWord\Style\Line::ARROW_STYLE_CLASSIC; + $object = new Line(); + $object->setEndArrow($expected); + $this->assertEquals($expected, $object->getEndArrow()); + } +} From 54af93a20ae43787d3491730686ab2e411172dc8 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 29 May 2014 17:11:54 +0200 Subject: [PATCH 153/167] Fixed some Travis build errors --- src/PhpWord/Style/Line.php | 2 +- src/PhpWord/Writer/Word2007/Style/Line.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/Line.php b/src/PhpWord/Style/Line.php index 67a4328cde..94bc2ea8cc 100644 --- a/src/PhpWord/Style/Line.php +++ b/src/PhpWord/Style/Line.php @@ -117,7 +117,7 @@ public function setFlip($value = null) * * @return boolean */ - public function getFlip() + public function isFlip() { return $this->flip; } diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php index dbf7773fef..a6638d96b3 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -124,13 +124,17 @@ private function getElementStyle(LineStyle $style) $styles[$key] = $value . 'px'; } } - if ($style->getFlip()) { + if ($style->isFlip()) { $styles['flip']='y'; } return $styles; } + /** + * Write Line stroke + * + */ public function writeStroke() { $style = $this->getStyle(); From 010378787306c7abdf93819b47d585f0826c5f64 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 29 May 2014 17:44:14 +0200 Subject: [PATCH 154/167] Second attempt to resolve Travis build errors --- src/PhpWord/Writer/Word2007/Style/Line.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php index a6638d96b3..1e4448a867 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -36,7 +36,7 @@ public function write() if (!$style instanceof LineStyle) { return; } - $this->writeStyle($style); + $this->writeLineStyle($style); } /** @@ -44,7 +44,7 @@ public function write() * * Copied function from Image/writeStyle in order to override getElementStyle */ - protected function writeStyle(ImageStyle $style) + protected function writeLineStyle(LineStyle $style) { $xmlWriter = $this->getXmlWriter(); From 748e16473d09797f7ca0248d9b80a41eda66c5f7 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Thu, 29 May 2014 18:07:01 +0200 Subject: [PATCH 155/167] Final try to resolve Travis build errors --- src/PhpWord/Writer/Word2007/Element/Line.php | 6 +++--- tests/PhpWord/Tests/Style/LineTest.php | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php index 411712053d..ea20263352 100644 --- a/src/PhpWord/Writer/Word2007/Element/Line.php +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -41,14 +41,14 @@ public function write() $style = $element->getStyle(); $styleWriter = new LineStyleWriter($xmlWriter, $style); - $id=$element->getElementIndex(); + $elementId=$element->getElementIndex(); if (!$this->withoutP) { $xmlWriter->startElement('w:p'); $styleWriter->writeAlignment(); } $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); - if ($id==1) { //shapetype could be defined for each line separately, but then a unique id would be necessary + if ($elementId==1) { //shapetype could be defined for each line separately, but then a unique id would be necessary $xmlWriter->startElement('v:shapetype'); $xmlWriter->writeAttribute('id', '_x0000_t32'); $xmlWriter->writeAttribute('coordsize', '21600,21600'); @@ -68,7 +68,7 @@ public function write() $xmlWriter->endElement(); // v:shapetype } $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('id', sprintf('_x0000_s1%1$03d', $id)); + $xmlWriter->writeAttribute('id', sprintf('_x0000_s1%1$03d', $elementId)); $xmlWriter->writeAttribute('type', '#_x0000_t32'); //type should correspond to shapetype id $styleWriter->write(); $styleWriter->writeStroke(); diff --git a/tests/PhpWord/Tests/Style/LineTest.php b/tests/PhpWord/Tests/Style/LineTest.php index 92756e2443..02d5ba16a2 100644 --- a/tests/PhpWord/Tests/Style/LineTest.php +++ b/tests/PhpWord/Tests/Style/LineTest.php @@ -35,7 +35,6 @@ public function testSetGetNormal() $object = new Line(); $properties = array( - 'flip' => true, 'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT, 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, @@ -59,7 +58,6 @@ public function testSetStyleValue() $object = new Line(); $properties = array( - 'flip' => true, 'connectorType' => \PhpOffice\PhpWord\Style\Line::CONNECTOR_TYPE_STRAIGHT, 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, @@ -82,7 +80,7 @@ public function testSetGetFlip() $expected=true; $object = new Line(); $object->setFlip($expected); - $this->assertEquals($expected, $object->getFlip()); + $this->assertEquals($expected, $object->isFlip()); } /** From a57b28de8f5edb1a4b79581d54d2a359b05fa704 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 30 May 2014 01:05:55 +0700 Subject: [PATCH 156/167] Some adjustments for the new `Line` element #253 --- CHANGELOG.md | 6 +- CHANGELOG.md~ | 268 ------------------ docs/elements.rst | 7 + docs/src/documentation.md | 6 + ...{Sample_28_Line.php => Sample_29_Line.php} | 0 src/PhpWord/Element/AbstractContainer.php | 2 +- src/PhpWord/Element/Field.php | 3 + src/PhpWord/Element/Line.php | 11 +- src/PhpWord/Style/Line.php | 128 +++++---- src/PhpWord/Writer/Word2007/Element/Line.php | 14 +- src/PhpWord/Writer/Word2007/Style/Image.php | 91 +++--- src/PhpWord/Writer/Word2007/Style/Line.php | 160 +++-------- .../Tests/Writer/Word2007/ElementTest.php | 3 +- .../Writer/Word2007/Part/DocumentTest.php | 11 + .../Tests/Writer/Word2007/StyleTest.php | 3 +- 15 files changed, 212 insertions(+), 501 deletions(-) delete mode 100644 CHANGELOG.md~ rename samples/{Sample_28_Line.php => Sample_29_Line.php} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a322b2e89c..2325b587e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, Line and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. ### Features @@ -30,8 +30,8 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three - RTF Writer: Ability to write document properties - @ivanlanin - RTF Writer: Ability to write image - @ivanlanin - Element: New `Field` element - @basjan GH-251 -- Element: New `Line` element - @basjan -- RTF Reader: Basic RTF reader - @ivanlanin GH-72 +- RTF Reader: Basic RTF reader - @ivanlanin GH-72 GH-252 +- Element: New `Line` element - @basjan GH-253 ### Bugfixes diff --git a/CHANGELOG.md~ b/CHANGELOG.md~ deleted file mode 100644 index 0ccba8cca9..0000000000 --- a/CHANGELOG.md~ +++ /dev/null @@ -1,268 +0,0 @@ -# Changelog - -This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub. - -## 0.11.0 - Not yet released - -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Three new elements were added: TextBox, ListItemRun, and Field. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. - -### Features - -- Image: Ability to define relative and absolute positioning - @basjan GH-217 -- Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin GH-219 -- Element: New `TextBox` element - @basjan @ivanlanin GH-228 GH-229 GH-231 -- HTML: Ability to add elements to PHPWord object via html - @basjan GH-231 -- Element: New `ListItemRun` element that can add a list item with inline formatting like a textrun - @basjan GH-235 -- Table: Ability to add table inside a cell (nested table) - @ivanlanin GH-149 -- RTF Writer: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin GH-158 -- Table: Ability to define table width (in percent and twip) and position - @ivanlanin GH-237 -- RTF Writer: Ability to add links and page breaks in RTF - @ivanlanin GH-196 -- ListItemRun: Remove fontStyle parameter because ListItemRun is inherited from TextRun and TextRun doesn't have fontStyle - @ivanlanin -- Config: Ability to use a config file to store various common settings - @ivanlanin GH-200 -- ODT Writer: Enable inline font style in TextRun - @ivanlanin -- ODT Writer: Enable underline, strike/doublestrike, smallcaps/allcaps, superscript/subscript font style - @ivanlanin -- ODT Writer: Enable section and column - @ivanlanin -- PDF Writer: Add TCPDF and mPDF as optional PDF renderer library - @ivanlanin -- ODT Writer: Enable title element and custom document properties - @ivanlanin -- ODT Reader: Ability to read standard and custom document properties - @ivanlanin -- Word2007 Writer: Enable the missing custom document properties writer - @ivanlanin -- Image: Enable "image float left" - @ivanlanin GH-244 -- RTF Writer: Ability to write document properties - @ivanlanin -- RTF Writer: Ability to write image - @ivanlanin -- Element: New `Field` element - @basjan GH-251 -- RTF Reader: Basic RTF reader - @ivanlanin GH-72 - -### Bugfixes - -- Header: All images added to the second header were assigned to the first header - @basjan GH-222 -- Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234 -- PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin GH-150 -- Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin GH-248 - -### Deprecated - -- Static classes `Footnotes`, `Endnotes`, and `TOC` -- `Writer\Word2007\Part`: `Numbering::writeNumbering()`, `Settings::writeSettings()`, `WebSettings::writeWebSettings()`, `ContentTypes::writeContentTypes()`, `Styles::writeStyles()`, `Document::writeDocument()` all changed into `write()` -- `Writer\Word2007\Part\DocProps`: Split into `Writer\Word2007\Part\DocPropsCore` and `Writer\Word2007\Part\DocPropsApp` -- `Element\Title::getBookmarkId()` replaced by `Element\Title::getRelationId()` -- `Writer\HTML::writeDocument`: Replaced by `Writer\HTML::getContent` - -### Miscellaneous - -- License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211 -- Word2007 Writer: New `Style\Image` class - @ivanlanin -- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 -- QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin -- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin -- Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 -- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 -- Writer: Refactor writer parts using composite pattern - @ivanlanin -- Docs: Show code quality and test code coverage badge on README -- Style: Change behaviour of `set...` function of boolean properties; when none is defined, assumed true - @ivanlanin -- Shared: Unify PHP ZipArchive and PCLZip features into PhpWord ZipArchive - @ivanlanin - -## 0.10.1 - 21 May 2014 - -This is a bugfix release for `php-zip` requirement in Composer. - -- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich GH-246 - -## 0.10.0 - 4 May 2014 - -This release marked heavy refactorings on internal code structure with the creation of some abstract classes to reduce code duplication. `Element` subnamespace is introduced in this release to replace `Section`. Word2007 reader capability is greatly enhanced. Endnote is introduced. List numbering is now customizable. Basic HTML and PDF writing support is enabled. Basic ODText reader is introduced. - -### Features - -- Image: Get image dimensions without EXIF extension - @andrew-kzoo GH-184 -- Table: Add `tblGrid` element for Libre/Open Office table sizing - @gianis6 GH-183 -- Footnote: Ability to insert textbreak in footnote `$footnote->addTextBreak()` - @ivanlanin -- Footnote: Ability to style footnote reference mark by using `FootnoteReference` style - @ivanlanin -- Font: Add `bgColor` to font style to define background using HEX color - @jcarignan GH-168 -- Table: Add `exactHeight` to row style to define whether row height should be exact or atLeast - @jcarignan GH-168 -- Element: New `CheckBox` element for sections and table cells - @ozilion GH-156 -- Settings: Ability to use PCLZip as alternative to ZipArchive - @bskrtich @ivanlanin GH-106 GH-140 GH-185 -- Template: Ability to find & replace variables in headers & footers - @dgudgeon GH-190 -- Template: Ability to clone & delete block of text using `cloneBlock` and `deleteBlock` - @diego-vieira GH-191 -- TOC: Ability to have two or more TOC in one document and to set min and max depth for TOC - @Pyreweb GH-189 -- Table: Ability to add footnote in table cell - @ivanlanin GH-187 -- Footnote: Ability to add image in footnote - @ivanlanin GH-187 -- ListItem: Ability to add list item in header/footer - @ivanlanin GH-187 -- CheckBox: Ability to add checkbox in header/footer - @ivanlanin GH-187 -- Link: Ability to add link in header/footer - @ivanlanin GH-187 -- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187 -- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19 -- General: Add `Style::resetStyles()` - @ivanlanin GH-187 -- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image, and title - @ivanlanin -- Endnote: Ability to add endnotes - @ivanlanin -- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198 -- ODT Writer: Basic table writing support - @ivanlanin -- Image: Keep image aspect ratio if only 1 dimension styled - @japonicus GH-194 -- HTML Writer: Basic HTML writer: text, textrun, link, title, textbreak, table, image (as Base64), footnote, endnote - @ivanlanin GH-203 GH-67 GH-147 -- PDF Writer: Basic PDF writer using DomPDF: All HTML element except image - @ivanlanin GH-68 -- DOCX Writer: Change `docProps/app.xml` `Application` to `PHPWord` - @ivanlanin -- DOCX Writer: Create `word/settings.xml` and `word/webSettings.xml` dynamically - @ivanlanin -- ODT Writer: Basic image writing - @ivanlanin -- ODT Writer: Link writing - @ivanlanin -- ODT Reader: Basic ODText Reader - @ivanlanin GH-71 -- Section: Ability to define gutter and line numbering - @ivanlanin -- Font: Small caps, all caps, and double strikethrough - @ivanlanin GH-151 -- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin GH-199 -- Style: Remove `bgColor` from `Font`, `Table`, and `Cell` and put it into the new `Shading` style - @ivanlanin -- Style: New `Indentation` and `Spacing` style - @ivanlanin -- Paragraph: Ability to define first line and right indentation - @ivanlanin - -### Bugfixes - -- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin GH-170 -- Documentation: Error in a function - @theBeerNut GH-195 - -### Deprecated - -- `createTextRun` replaced by `addTextRun` -- `createFootnote` replaced by `addFootnote` -- `createHeader` replaced by `addHeader` -- `createFooter` replaced by `addFooter` -- `createSection` replaced by `addSection` -- `Element\Footnote::getReferenceId` replaced by `Element\AbstractElement::getRelationId` -- `Element\Footnote::setReferenceId` replaced by `Element\AbstractElement::setRelationId` -- `Footnote::addFootnoteLinkElement` replaced by `Media::addElement` -- `Footnote::getFootnoteLinkElements` replaced by `Media::getElements` -- All current methods on `Media` -- `Element\Link::getLinkSrc` replaced by `Element\Link::getTarget` -- `Element\Link::getLinkName` replaced by `Element\Link::getText` -- `Style\Cell::getDefaultBorderColor` - -### Miscellaneous - -- Documentation: Simplify page level docblock - @ivanlanin GH-179 -- Writer: Refactor writer classes and create a new `Write\AbstractWriter` abstract class - @ivanlanin GH-160 -- General: Refactor folders: `Element` and `Exception` - @ivanlanin GH-187 -- General: Remove legacy `HashTable` and `Shared\ZipStreamWrapper` and all related properties/methods - @ivanlanin GH-187 -- Element: New `AbstractElement` abstract class - @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 - @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 -- Style: New `Style\AbstractStyle` abstract class - @ivanlanin GH-187 -- Writer: New 'ODText\Base` class - @ivanlanin GH-187 -- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin -- General: Add some unit tests for Shared & Element (100%!) - @Progi1984 -- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59 -- Refactor: Remove Style\Tabs - @ivanlanin -- Refactor: Apply composite pattern for writers - @ivanlanin -- Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin -- Refactor: Apply composite pattern for Word2007 reader - @ivanlanin - -## 0.9.1 - 27 Mar 2014 - -This is a bugfix release for PSR-4 compatibility. - -- Fixed PSR-4 composer autoloader - @AntonTyutin - -## 0.9.0 - 26 Mar 2014 - -This release marked the transformation to namespaces (PHP 5.3+). - -### Features - -- Image: Ability to use remote or GD images using `addImage()` on sections, headers, footer, cells, and textruns - @ivanlanin -- Header: Ability to use remote or GD images using `addWatermark()` - @ivanlanin - -### Bugfixes - -- Preserve text doesn't render correctly when the text is not the first word, e.g. 'Page {PAGE}' - @ivanlanin - -### Miscellaneous - -- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82 -- Reorganize and redesign samples folder - @ivanlanin GH-137 -- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58 -- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull -- Compliance to phpDocumentor - @ivanlanin -- Merge Style\TableFull into Style\Table. Style\TableFull is deprecated - @ivanlanin GH-160 -- Merge Section\MemoryImage into Section\Image. Section\Image is deprecated - @ivanlanin GH-160 - -## 0.8.1 - 17 Mar 2014 - -This is a bugfix release for image detection functionality. - -- Added fallback for computers that do not have exif_imagetype - @bskrtich, @gabrielbull - -## 0.8.0 - 15 Mar 2014 - -This release merged a lot of improvements from the community. Unit tests introduced in this release and has reached 90% code coverage. - -### Features - -- Template: Permit to save a template generated as a file (PHPWord_Template::saveAs()) - @RomanSyroeshko GH-56 GH-57 -- Word2007: Support sections page numbering - @gabrielbull -- Word2007: Added line height methods to mirror the line height settings in Word in the paragraph styling - @gabrielbull -- Word2007: Added support for page header & page footer height - @JillElaine GH-5 -- General: Add ability to manage line breaks after image insertion - @bskrtich GH-6 GH-66 GH-84 -- Template: Ability to limit number of replacements performed by setValue() method of Template class - @RomanSyroeshko GH-52 GH-53 GH-85 -- Table row: Repeat as header row & allow row to break across pages - @ivanlanin GH-48 GH-86 -- Table: Table width in percentage - @ivanlanin GH-48 GH-86 -- Font: Superscript and subscript - @ivanlanin GH-48 GH-86 -- Paragraph: Hanging paragraph - @ivanlanin GH-48 GH-86 -- Section: Multicolumn and section break - @ivanlanin GH-48 GH-86 -- Template: Ability to apply XSL style sheet to Template - @RomanSyroeshko GH-46 GH-47 GH-83 -- General: PHPWord_Shared_Font::pointSizeToTwips() converter - @ivanlanin GH-87 -- Paragraph: Ability to define normal paragraph style with PHPWord::setNormalStyle() - @ivanlanin GH-87 -- Paragraph: Ability to define parent style (basedOn) and style for following paragraph (next) - @ivanlanin GH-87 -- Clone table rows on the fly when using a template document - @jeroenmoors GH-44 GH-88 -- Initial addition of basic footnote support - @deds GH-16 -- Paragraph: Ability to define paragraph pagination: widow control, keep next, keep lines, and page break before - @ivanlanin GH-92 -- General: PHPWord_Style_Font refactoring - @ivanlanin GH-93 -- Font: Use points instead of halfpoints internally. Conversion to halfpoints done during XML Writing. - @ivanlanin GH-93 -- Paragraph: setTabs() function - @ivanlanin GH-92 -- General: Basic support for TextRun on ODT and RTF - @ivanlanin GH-99 -- Reader: Basic Reader for Word2007 - @ivanlanin GH-104 -- TextRun: Allow Text Break in Text Run - @bskrtich GH-109 -- General: Support for East Asian fontstyle - @jhfangying GH-111 GH-118 -- Image: Use exif_imagetype to check image format instead of extension name - @gabrielbull GH-114 -- General: Setting for XMLWriter Compatibility option - @bskrtich GH-103 -- MemoryImage: Allow remote image when allow_url_open = on - @ivanlanin GH-122 -- TextBreak: Allow font and paragraph style for text break - @ivanlanin GH-18 - -### Bugfixes - -- Fixed bug with cell styling - @gabrielbull -- Fixed bug list items inside of cells - @gabrielbull -- Adding a value that contains "&" in a template breaks it - @SiebelsTim GH-51 -- Example in README.md is broken - @Progi1984 GH-89 -- General: PHPWord_Shared_Drawing::centimetersToPixels() conversion - @ivanlanin GH-94 -- Footnote: Corrupt DOCX reported by MS Word when sections > 1 and not every sections have footnote - @ivanlanin GH-125 - -### Miscellaneous - -- UnitTests - @Progi1984 - -## 0.7.0 - 28 Jan 2014 - -This is the first release after a long development hiatus in [CodePlex](https://phpword.codeplex.com/). This release initialized ODT and RTF Writer, along with some other new features for the existing Word2007 Writer, e.g. tab, multiple header, rowspan and colspan. [Composer](https://packagist.org/packages/phpoffice/phpword) and [Travis](https://travis-ci.org/PHPOffice/PHPWord) were added. - -### Features - -- Implement RTF Writer - @Progi1984 GH-1 -- Implement ODT Writer - @Progi1984 GH-2 -- Word2007: Add rowspan and colspan to cells - @kaystrobach -- Word2007: Support for tab stops - @RLovelett -- Word2007: Support Multiple headers - @RLovelett -- Word2007: Wrapping Styles to Images - @gabrielbull -- Added support for image wrapping style - @gabrielbull - -### Bugfixes - -- "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found - @RomanSyroeshko GH-32 -- PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input - @RomanSyroeshko GH-34 -- Temporary files naming logic in PHPWord_Template can lead to a collision - @RomanSyroeshko GH-38 - -### Miscellaneous - -- Add superscript/subscript styling in Excel2007 Writer - @MarkBaker -- add indentation support to paragraphs - @deds -- Support for Composer - @Progi1984 GH-27 -- Basic CI with Travis - @Progi1984 -- Added PHPWord_Exception and exception when could not copy the template - @Progi1984 -- IMPROVED: Moved examples out of Classes directory - @Progi1984 -- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo CP-49 diff --git a/docs/elements.rst b/docs/elements.rst index 901832ebae..98ab042fde 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -45,6 +45,8 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 18 | Field | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 19 | Line | v | v | v | v | v | v | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -487,3 +489,8 @@ Fields ------ To be completed + +Line +------ + +To be completed diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 0259dd8b5e..0f96ff00f7 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -35,6 +35,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Checkboxes](#checkboxes) - [Textboxes](#textboxes) - [Fields](#fields) + - [Lines](#lines) - [Templates](#templates) - [Writers & readers](#writers-readers) - [OOXML](#ooxml) @@ -463,6 +464,7 @@ Below are the matrix of element availability in each container. The column shows | 16 | CheckBox | v | v | v | v | - | - | | 17 | TextBox | v | v | v | v | - | - | | 18 | Field | v | v | v | v | v | v | +| 19 | Line | v | v | v | v | v | v | Legend: @@ -844,6 +846,10 @@ To be completed. To be completed. +## Lines + +To be completed. + # Templates You can create a docx template with included search-patterns that can be replaced by any value you wish. Only single-line values can be replaced. To load a template file, use the `loadTemplate` method. After loading the docx template, you can use the `setValue` method to change the value of a search pattern. The search-pattern model is: `${search-pattern}`. It is not possible to add new PHPWord elements to a loaded template file. diff --git a/samples/Sample_28_Line.php b/samples/Sample_29_Line.php similarity index 100% rename from samples/Sample_28_Line.php rename to samples/Sample_29_Line.php diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 6032f33fa9..0f065b419b 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -149,11 +149,11 @@ public function addTextRun($paragraphStyle = null) * @param string $type * @param array $properties * @param array $options + * @return \PhpOffice\PhpWord\Element\Field */ public function addField($type = null, $properties = array(), $options = array()) { return $this->addElement('Field', $type, $properties, $options); - } /** diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index 7503dc9ba8..50f0522fb1 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -95,6 +95,7 @@ public function __construct($type = null, $properties = array(), $options = arra * * @param string $type * @return string + * @throws \InvalidArgumentException */ public function setType($type = null) { @@ -123,6 +124,7 @@ public function getType() * * @param array $properties * @return self + * @throws \InvalidArgumentException */ public function setProperties($properties = array()) { @@ -152,6 +154,7 @@ public function getProperties() * * @param array $options * @return self + * @throws \InvalidArgumentException */ public function setOptions($options = array()) { diff --git a/src/PhpWord/Element/Line.php b/src/PhpWord/Element/Line.php index eef3891435..4acca8eda3 100644 --- a/src/PhpWord/Element/Line.php +++ b/src/PhpWord/Element/Line.php @@ -27,25 +27,24 @@ class Line extends AbstractElement /** * Line style * - * @var LineStyle + * @var \PhpOffice\PhpWord\Style\Line */ private $style; - + /** * Create new line element * - * @param string $source * @param mixed $style */ public function __construct($style = null) { $this->style = $this->setStyle(new LineStyle(), $style); } - + /** - * Get Image style + * Get line style * - * @return ImageStyle + * @return \PhpOffice\PhpWord\Style\Line */ public function getStyle() { diff --git a/src/PhpWord/Style/Line.php b/src/PhpWord/Style/Line.php index 94bc2ea8cc..44f5422991 100644 --- a/src/PhpWord/Style/Line.php +++ b/src/PhpWord/Style/Line.php @@ -51,28 +51,28 @@ class Line extends Image const DASH_STYLE_LONG_DASH = 'longdash'; const DASH_STYLE_LONG_DASH_DOT = 'longdashdot'; const DASH_STYLE_LONG_DASH_DOT_DOT = 'longdashdotdot'; - + /** * flip Line * * @var boolean */ private $flip = false; - + /** * connectorType * * @var string */ private $connectorType = self::CONNECTOR_TYPE_STRAIGHT; - + /** * Line Weight * * @var int */ - private $weight = null; - + private $weight; + /** * Line color * @@ -85,47 +85,60 @@ class Line extends Image * * @var string */ - private $dash = null; - + private $dash; + /** * Begin arrow * * @var string */ - private $beginArrow = null; - + private $beginArrow; + /** * End arrow * * @var string */ - private $endArrow = null; - - + private $endArrow; + + /** + * Get flip + * + * @return boolean + */ + public function isFlip() + { + return $this->flip; + } + /** * Set flip * * @param boolean $value + * @return self */ - public function setFlip($value = null) + public function setFlip($value = false) { - $this->flip = $value; + $this->flip = $this->setBoolVal($value, $this->flip); + + return $this; } - + /** - * Get flip + * Get connectorType * - * @return boolean + * @return string */ - public function isFlip() + public function getConnectorType() { - return $this->flip; + return $this->connectorType; } - + /** * Set connectorType * * @param string $value + * @return self */ public function setConnectorType($value = null) { @@ -133,62 +146,71 @@ public function setConnectorType($value = null) self::CONNECTOR_TYPE_STRAIGHT ); $this->connectorType = $this->setEnumVal($value, $enum, $this->connectorType); + + return $this; } - + /** - * Get connectorType + * Get weight * - * @return string + * @return int */ - public function getConnectorType() + public function getWeight() { - return $this->connectorType; + return $this->weight; } /** * Set weight * * @param int $value Weight in points + * @return self */ public function setWeight($value = null) { - $this->weight = $value; + $this->weight = $this->setNumericVal($value, $this->weight); + + return $this; } - + /** - * Get weight + * Get color * - * @return int + * @return string */ - public function getWeight() + public function getColor() { - return $this->weight; + return $this->color; } - + /** * Set color * * @param string $value + * @return self */ public function setColor($value = null) { $this->color = $value; + + return $this; } - + /** - * Get color + * Get beginArrow * * @return string */ - public function getColor() + public function getBeginArrow() { - return $this->color; + return $this->beginArrow; } - + /** * Set beginArrow * * @param string $value + * @return self */ public function setBeginArrow($value = null) { @@ -197,21 +219,25 @@ public function setBeginArrow($value = null) self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL ); $this->beginArrow = $this->setEnumVal($value, $enum, $this->beginArrow); + + return $this; } /** - * Get beginArrow + * Get endArrow * * @return string */ - public function getBeginArrow() + public function getEndArrow() { - return $this->beginArrow; + return $this->endArrow; } + /** * Set endArrow * * @param string $value + * @return self */ public function setEndArrow($value = null) { @@ -220,20 +246,25 @@ public function setEndArrow($value = null) self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL ); $this->endArrow = $this->setEnumVal($value, $enum, $this->endArrow); + + return $this; } + /** - * Get endArrow + * Get Dash * * @return string */ - public function getEndArrow() + public function getDash() { - return $this->endArrow; + return $this->dash; } + /** * Set Dash * * @param string $value + * @return self */ public function setDash($value = null) { @@ -243,14 +274,7 @@ public function setDash($value = null) self::DASH_STYLE_SQUARE_DOT ); $this->dash = $this->setEnumVal($value, $enum, $this->dash); - } - /** - * Get Dash - * - * @return string - */ - public function getDash() - { - return $this->dash; + + return $this; } } diff --git a/src/PhpWord/Writer/Word2007/Element/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php index ea20263352..1ae1069495 100644 --- a/src/PhpWord/Writer/Word2007/Element/Line.php +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Element\Line as LineElement; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Line as LineStyleWriter; /** @@ -33,22 +32,23 @@ class Line extends AbstractElement public function write() { $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); + $element = $this->getElement(); if (!$element instanceof LineElement) { return; } - $style = $element->getStyle(); + $style = $element->getStyle(); $styleWriter = new LineStyleWriter($xmlWriter, $style); - - $elementId=$element->getElementIndex(); + + $elementId = $element->getElementIndex(); if (!$this->withoutP) { $xmlWriter->startElement('w:p'); $styleWriter->writeAlignment(); } $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); - if ($elementId==1) { //shapetype could be defined for each line separately, but then a unique id would be necessary + // Shapetype could be defined for each line separately, but then a unique id would be necessary + if ($elementId == 1) { $xmlWriter->startElement('v:shapetype'); $xmlWriter->writeAttribute('id', '_x0000_t32'); $xmlWriter->writeAttribute('coordsize', '21600,21600'); @@ -76,7 +76,7 @@ public function write() $xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - + if (!$this->withoutP) { $xmlWriter->endElement(); // w:p } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index b6b46535c2..280b569a4a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -48,50 +48,15 @@ public function write() /** * Write style attribute + * + * @param \PhpOffice\PhpWord\Style\Image $style */ - protected function writeStyle(ImageStyle $style) + protected function writeStyle($style) { $xmlWriter = $this->getXmlWriter(); - // Default style array - $styleArray = array( - 'mso-width-percent' => '0', - 'mso-height-percent' => '0', - 'mso-width-relative' => 'margin', - 'mso-height-relative' => 'margin', - ); - $styleArray = array_merge($styleArray, $this->getElementStyle($style)); - - // Absolute/relative positioning - $positioning = $style->getPositioning(); - $styleArray['position'] = $positioning; - if ($positioning !== null) { - $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); - $styleArray['mso-position-vertical'] = $style->getPosVertical(); - $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); - $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); - } - - // Wrapping style - $wrapping = $style->getWrappingStyle(); - if ($wrapping == ImageStyle::WRAPPING_STYLE_INLINE) { - // Nothing to do when inline - } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_BEHIND) { - $styleArray['z-index'] = -251658752; - } else { - $styleArray['z-index'] = 251659264; - $styleArray['mso-position-horizontal'] = 'absolute'; - $styleArray['mso-position-vertical'] = 'absolute'; - } - - // w10 wrapping - if ($wrapping == ImageStyle::WRAPPING_STYLE_SQUARE) { - $this->w10wrap = 'square'; - } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_TIGHT) { - $this->w10wrap = 'tight'; - } - - $imageStyle = $this->assembleStyle($styleArray); + $styles = $this->getElementStyle($style); + $imageStyle = $this->assembleStyle($styles); $xmlWriter->writeAttribute('style', $imageStyle); } @@ -134,21 +99,57 @@ public function writeW10Wrap() * @param \PhpOffice\PhpWord\Style\Image $style * @return array */ - private function getElementStyle(ImageStyle $style) + protected function getElementStyle(ImageStyle $style) { - $styles = array(); - $styleValues = array( + $styles = array( + 'mso-width-percent' => '0', + 'mso-height-percent' => '0', + 'mso-width-relative' => 'margin', + 'mso-height-relative' => 'margin', + ); + + // Dimension + $dimensions = array( 'width' => $style->getWidth(), 'height' => $style->getHeight(), 'margin-top' => $style->getMarginTop(), 'margin-left' => $style->getMarginLeft() ); - foreach ($styleValues as $key => $value) { - if (!is_null($value) && $value != '') { + foreach ($dimensions as $key => $value) { + if ($value !== null) { $styles[$key] = $value . 'px'; } } + // Absolute/relative positioning + $positioning = $style->getPositioning(); + $styles['position'] = $positioning; + if ($positioning !== null) { + $styles['mso-position-horizontal'] = $style->getPosHorizontal(); + $styles['mso-position-vertical'] = $style->getPosVertical(); + $styles['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); + $styles['mso-position-vertical-relative'] = $style->getPosVerticalRel(); + } + + // Wrapping style + $wrapping = $style->getWrappingStyle(); + if ($wrapping == ImageStyle::WRAPPING_STYLE_INLINE) { + // Nothing to do when inline + } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_BEHIND) { + $styles['z-index'] = -251658752; + } else { + $styles['z-index'] = 251659264; + $styles['mso-position-horizontal'] = 'absolute'; + $styles['mso-position-vertical'] = 'absolute'; + } + + // w10 wrapping + if ($wrapping == ImageStyle::WRAPPING_STYLE_SQUARE) { + $this->w10wrap = 'square'; + } elseif ($wrapping == ImageStyle::WRAPPING_STYLE_TIGHT) { + $this->w10wrap = 'tight'; + } + return $styles; } diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php index 1e4448a867..dfecb4b0e8 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -17,9 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; use PhpOffice\PhpWord\Style\Line as LineStyle; -use PhpOffice\PhpWord\Style\Image as ImageStyle; /** * Line style writer @@ -36,148 +34,76 @@ public function write() if (!$style instanceof LineStyle) { return; } - $this->writeLineStyle($style); + $this->writeStyle($style); } - + /** * Write style attribute - * - * Copied function from Image/writeStyle in order to override getElementStyle + * + * @param \PhpOffice\PhpWord\Style\Line $style */ - protected function writeLineStyle(LineStyle $style) + protected function writeStyle($style) { $xmlWriter = $this->getXmlWriter(); - - // Default style array - $styleArray = array( - 'mso-width-percent' => '0', - 'mso-height-percent' => '0', - 'mso-width-relative' => 'margin', - 'mso-height-relative' => 'margin', - ); - $styleArray = array_merge($styleArray, $this->getElementStyle($style)); - - // Absolute/relative positioning - $positioning = $style->getPositioning(); - $styleArray['position'] = $positioning; - if ($positioning !== null) { - $styleArray['mso-position-horizontal'] = $style->getPosHorizontal(); - $styleArray['mso-position-vertical'] = $style->getPosVertical(); - $styleArray['mso-position-horizontal-relative'] = $style->getPosHorizontalRel(); - $styleArray['mso-position-vertical-relative'] = $style->getPosVerticalRel(); - } - - // Wrapping style - $wrapping = $style->getWrappingStyle(); - if ($wrapping == LineStyle::WRAPPING_STYLE_INLINE) { - // Nothing to do when inline - } elseif ($wrapping == LineStyle::WRAPPING_STYLE_BEHIND) { - $styleArray['z-index'] = -251658752; - } else { - $styleArray['z-index'] = 251659264; - $styleArray['mso-position-horizontal'] = 'absolute'; - $styleArray['mso-position-vertical'] = 'absolute'; - } - - // w10 wrapping - if ($wrapping == LineStyle::WRAPPING_STYLE_SQUARE) { - $this->w10wrap = 'square'; - } elseif ($wrapping == LineStyle::WRAPPING_STYLE_TIGHT) { - $this->w10wrap = 'tight'; + + $styles = $this->getElementStyle($style); + if ($style->isFlip()) { + $styles['flip'] = 'y'; } - - $imageStyle = $this->assembleStyle($styleArray); - + $imageStyle = $this->assembleStyle($styles); $xmlWriter->writeAttribute('style', $imageStyle); + + // Connector type $xmlWriter->writeAttribute('o:connectortype', $style->getConnectorType()); - + // Weight $weight = $style->getWeight(); - if ($weight !== null) { - $xmlWriter->writeAttribute('strokeweight', $weight . 'pt'); - } - + $xmlWriter->writeAttributeIf($weight !== null, 'strokeweight', $weight . 'pt'); + // Color $color = $style->getColor(); - if ($color !== null) { - $xmlWriter->writeAttribute('strokecolor', $color); - } - } - - /** - * Get element style - * - * @param \PhpOffice\PhpWord\Style\Image $style - * @return array - */ - private function getElementStyle(LineStyle $style) - { - $styles = array(); - $styleValues = array( - 'width' => $style->getWidth(), - 'height' => $style->getHeight(), - 'margin-top' => $style->getMarginTop(), - 'margin-left' => $style->getMarginLeft() - ); - foreach ($styleValues as $key => $value) { - if (!is_null($value)) { - $styles[$key] = $value . 'px'; - } - } - if ($style->isFlip()) { - $styles['flip']='y'; - } - - return $styles; + $xmlWriter->writeAttributeIf($color !== null, 'strokecolor', $color); } - + /** * Write Line stroke - * */ public function writeStroke() { - $style = $this->getStyle(); $xmlWriter = $this->getXmlWriter(); - + $style = $this->getStyle(); + if (!$style instanceof LineStyle) { + return; + } + $dash = $style->getDash(); $beginArrow = $style->getBeginArrow(); $endArrow = $style->getEndArrow(); - + $dashStyles = array( + LineStyle::DASH_STYLE_DASH => 'dash', + LineStyle::DASH_STYLE_ROUND_DOT => '1 1', + LineStyle::DASH_STYLE_SQUARE_DOT => '1 1', + LineStyle::DASH_STYLE_DASH_DOT => 'dashDot', + LineStyle::DASH_STYLE_LONG_DASH => 'longDash', + LineStyle::DASH_STYLE_LONG_DASH_DOT => 'longDashDot', + LineStyle::DASH_STYLE_LONG_DASH_DOT_DOT => 'longDashDotDot', + ); + if (($dash !== null) || ($beginArrow !== null) || ($endArrow !== null)) { $xmlWriter->startElement('v:stroke'); - if ($beginArrow !== null) { - $xmlWriter->writeAttribute('startarrow', $beginArrow); - } - if ($endArrow !== null) { - $xmlWriter->writeAttribute('endarrow', $endArrow); - } - if ($dash !==null) { - switch ($dash) { - case LineStyle::DASH_STYLE_DASH: - $xmlWriter->writeAttribute('dashstyle', 'dash'); - break; - case LineStyle::DASH_STYLE_ROUND_DOT: - $xmlWriter->writeAttribute('dashstyle', '1 1'); - $xmlWriter->writeAttribute('endcap', 'round'); - break; - case LineStyle::DASH_STYLE_SQUARE_DOT: - $xmlWriter->writeAttribute('dashstyle', '1 1'); - break; - case LineStyle::DASH_STYLE_DASH_DOT: - $xmlWriter->writeAttribute('dashstyle', 'dashDot'); - break; - case LineStyle::DASH_STYLE_LONG_DASH: - $xmlWriter->writeAttribute('dashstyle', 'longDash'); - break; - case LineStyle::DASH_STYLE_LONG_DASH_DOT: - $xmlWriter->writeAttribute('dashstyle', 'longDashDot'); - break; - case LineStyle::DASH_STYLE_LONG_DASH_DOT_DOT: - $xmlWriter->writeAttribute('dashstyle', 'longDashDotDot'); - break; + + $xmlWriter->writeAttributeIf($beginArrow !== null, 'startarrow', $beginArrow); + $xmlWriter->writeAttributeIf($endArrow !== null, 'endarrow', $endArrow); + + if ($dash !== null) { + if (array_key_exists($dash, $dashStyles)) { + $xmlWriter->writeAttribute('dashstyle', $dashStyles[$dash]); + } + if ($dash == LineStyle::DASH_STYLE_ROUND_DOT) { + $xmlWriter->writeAttribute('endcap', 'round'); } } + $xmlWriter->endElement(); //v:stroke } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index ee8b88ae61..23ba575bf9 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -30,7 +30,8 @@ public function testUnmatchedElements() { $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', - 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', 'Field' + 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', + 'Field', 'Line' ); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 09f7d6a412..9223470e69 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -87,6 +87,17 @@ public function testElements() $section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat', 'SakaEraCalendar')); $section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat', 'LastUsedFormat')); $section->addField('PAGE', array('format'=>'ArabicDash')); + $section->addLine( + array( + 'width' => 10, + 'height' => 10, + 'positioning' => 'absolute', + 'beginArrow' => 'block', + 'endArrow' => 'open', + 'dash' => 'rounddot', + 'weight' => 10 + ) + ); $doc = TestHelperDOCX::getDocument($phpWord); diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index cc722efbf4..8303e92b8c 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -30,7 +30,8 @@ public function testEmptyStyles() { $styles = array( 'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', - 'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', 'TextBox' + 'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', + 'TextBox', 'Line' ); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style; From 5c2c687efdd0548a6b6dd0a91dffae51c094578c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 29 May 2014 22:37:10 +0700 Subject: [PATCH 157/167] #193: Heading numbering --- docs/recipes.rst | 24 ++++++++ docs/src/documentation.md | 23 +++++++ samples/Sample_14_ListItem.php | 21 ++++++- src/PhpWord/Style/NumberingLevel.php | 30 ++++++++++ src/PhpWord/Style/Paragraph.php | 60 +++++++++++++++++++ .../Writer/Word2007/Part/Numbering.php | 7 ++- .../Writer/Word2007/Style/Paragraph.php | 19 ++++++ 7 files changed, 180 insertions(+), 4 deletions(-) diff --git a/docs/recipes.rst b/docs/recipes.rst index eef3152775..d5678a520e 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -41,3 +41,27 @@ Use ``php://output`` as the filename. header('Expires: 0'); $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save("php://output"); + +Create numbered headings +------------------------ + +Define a numbering style and title styles, and match the two styles (with ``pStyle`` and ``numStyle``) like below. + +.. code-block:: php + + $phpWord->addNumberingStyle( + 'hNum', + array('type' => 'multilevel', 'levels' => array( + array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'), + array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'), + array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'), + ) + ) + ); + $phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'hNum', 'numLevel' => 0)); + $phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'hNum', 'numLevel' => 1)); + $phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'hNum', 'numLevel' => 2)); + + $section->addTitle('Heading 1', 1); + $section->addTitle('Heading 2', 2); + $section->addTitle('Heading 3', 3); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 0259dd8b5e..3d2b4b16d2 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -980,6 +980,29 @@ $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $xmlWriter->save("php://output"); ``` +## Create numbered headings + +Define a numbering style and title styles, and match the two styles (with `pStyle` and `numStyle`) like below. + +```php +$phpWord->addNumberingStyle( + 'hNum', + array('type' => 'multilevel', 'levels' => array( + array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'), + array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'), + array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'), + ) + ) +); +$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'hNum', 'numLevel' => 0)); +$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'hNum', 'numLevel' => 1)); +$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'hNum', 'numLevel' => 2)); + +$section->addTitle('Heading 1', 1); +$section->addTitle('Heading 2', 2); +$section->addTitle('Heading 3', 3); +``` + # Frequently asked questions ## Is this the same with PHPWord that I found in CodePlex? diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index 892771bc62..3a3d34abc5 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -18,7 +18,7 @@ array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360), array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720), ) - ) + ) ); $predefinedMultilevel = array('listType' => \PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED); @@ -66,6 +66,25 @@ $listItemRun->addText(' underlined', array('underline'=>'dash')); $section->addTextBreak(2); +// Numbered heading + +$phpWord->addNumberingStyle( + 'headingNumbering', + array('type' => 'multilevel', 'levels' => array( + array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'), + array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'), + array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'), + ) + ) +); +$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'headingNumbering', 'numLevel' => 0)); +$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'headingNumbering', 'numLevel' => 1)); +$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'headingNumbering', 'numLevel' => 2)); + +$section->addTitle('Heading 1', 1); +$section->addTitle('Heading 2', 2); +$section->addTitle('Heading 3', 3); + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index 465231a75c..32e61c8962 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -56,6 +56,14 @@ class NumberingLevel extends AbstractStyle */ private $restart; + /** + * Related paragraph style + * + * @var string + * @link http://www.schemacentral.com/sc/ooxml/e-w_pStyle-2.html + */ + private $pStyle; + /** * Content between numbering symbol and paragraph text * @@ -205,6 +213,28 @@ public function setRestart($value) return $this; } + /** + * Get related paragraph style + * + * @return string + */ + public function getPStyle() + { + return $this->pStyle; + } + + /** + * Set related paragraph style + * + * @param string $value + * @return self + */ + public function setPStyle($value) + { + $this->pStyle = $value; + return $this; + } + /** * Get suffix * diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index e70833cabf..c504e65309 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -114,6 +114,20 @@ class Paragraph extends AbstractStyle */ private $alignment; + /** + * Numbering style name + * + * @var string + */ + private $numStyle; + + /** + * Numbering level + * + * @var int + */ + private $numLevel = 0; + /** * Create new instance */ @@ -532,6 +546,52 @@ public function setSpace($value = null) return $this; } + /** + * Get numbering style name + * + * @return string + */ + public function getNumStyle() + { + return $this->numStyle; + } + + /** + * Set numbering style name + * + * @param string $value + * @return self + */ + public function setNumStyle($value) + { + $this->numStyle = $value; + + return $this; + } + + /** + * Get numbering level + * + * @return int + */ + public function getNumLevel() + { + return $this->numLevel; + } + + /** + * Set numbering level + * + * @param int $value + * @return self + */ + public function setNumLevel($value = 0) + { + $this->numLevel = $this->setIntVal($value, $this->numLevel); + + return $this; + } + /** * Get allow first/last line to display on a separate page setting * diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 05cbf7b91b..8f735dd324 100644 --- a/src/PhpWord/Writer/Word2007/Part/Numbering.php +++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php @@ -58,7 +58,7 @@ public function write() $levels = $style->getLevels(); $xmlWriter->startElement('w:abstractNum'); - $xmlWriter->writeAttribute('w:abstractNumId', $style->getNumId()); + $xmlWriter->writeAttribute('w:abstractNumId', $style->getIndex()); $xmlWriter->startElement('w:nsid'); $xmlWriter->writeAttribute('w:val', $this->getRandomHexNumber()); @@ -81,9 +81,9 @@ public function write() foreach ($styles as $style) { if ($style instanceof NumberingStyle) { $xmlWriter->startElement('w:num'); - $xmlWriter->writeAttribute('w:numId', $style->getNumId()); + $xmlWriter->writeAttribute('w:numId', $style->getIndex()); $xmlWriter->startElement('w:abstractNumId'); - $xmlWriter->writeAttribute('w:val', $style->getNumId()); + $xmlWriter->writeAttribute('w:val', $style->getIndex()); $xmlWriter->endElement(); // w:abstractNumId $xmlWriter->endElement(); // w:num } @@ -107,6 +107,7 @@ private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) 'start' => 'start', 'format' => 'numFmt', 'restart' => 'lvlRestart', + 'pStyle' => 'pStyle', 'suffix' => 'suff', 'text' => 'lvlText', 'align' => 'lvlJc' diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 7322fd9142..8741c1774c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; /** @@ -117,6 +118,24 @@ private function writeStyle() $xmlWriter->endElement(); } + // Numbering + $numStyleName = $style->getNumStyle(); + $numStyleObject = Style::getStyle($numStyleName); + if ($numStyleName !== null && $numStyleObject !== null) { + $xmlWriter->startElement('w:numPr'); + $xmlWriter->startElement('w:numId'); + $xmlWriter->writeAttribute('w:val', $numStyleObject->getIndex()); + $xmlWriter->endElement(); // w:numId + $xmlWriter->startElement('w:ilvl'); + $xmlWriter->writeAttribute('w:val', $style->getNumLevel()); + $xmlWriter->endElement(); // w:ilvl + $xmlWriter->endElement(); // w:numPr + + $xmlWriter->startElement('w:outlineLvl'); + $xmlWriter->writeAttribute('w:val', $style->getNumLevel()); + $xmlWriter->endElement(); // w:outlineLvl + } + if (!$this->withoutPPR) { $xmlWriter->endElement(); // w:pPr } From 900a96addf574a4762d31f8ae87be4664b6859fa Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 30 May 2014 19:59:57 +0700 Subject: [PATCH 158/167] Bugfix for #236 (OpenOffice crash when opening DOCX) and paragraph style refactoring --- CHANGELOG.md | 5 + src/PhpWord/Style/Paragraph.php | 402 ++++++++++-------- src/PhpWord/Writer/Word2007/Element/TOC.php | 6 +- src/PhpWord/Writer/Word2007/Element/Title.php | 13 +- .../Writer/Word2007/Style/Paragraph.php | 95 +++-- .../Writer/Word2007/Part/DocumentTest.php | 2 - 6 files changed, 306 insertions(+), 217 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2325b587e8..7f4e6cf021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - Element: New `Field` element - @basjan GH-251 - RTF Reader: Basic RTF reader - @ivanlanin GH-72 GH-252 - Element: New `Line` element - @basjan GH-253 +- Title: Ability to apply numbering in heading - @ivanlanin GH-193 ### Bugfixes @@ -39,6 +40,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan GH-233 GH-234 - PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin GH-150 - Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin GH-248 +- Title: Orphan `w:fldChar` caused OpenOffice to crash when opening DOCX - @ivanlanin GH-236 ### Deprecated @@ -61,6 +63,9 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - Docs: Show code quality and test code coverage badge on README - Style: Change behaviour of `set...` function of boolean properties; when none is defined, assumed true - @ivanlanin - Shared: Unify PHP ZipArchive and PCLZip features into PhpWord ZipArchive - @ivanlanin +- Docs: Create VERSION file - @ivanlanin +- QA: Improve dan update requirement check in `samples` folder - @ivanlanin + ## 0.10.1 - 21 May 2014 diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index c504e65309..1aacd44f5c 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -22,6 +22,30 @@ /** * Paragraph style + * + * OOXML: + * - General: alignment, outline level + * - Indentation: left, right, firstline, hanging + * - Spacing: before, after, line spacing + * - Pagination: widow control, keep next, keep line, page break before + * - Formatting exception: suppress line numbers, don't hyphenate + * - Textbox options + * - Tabs + * - Shading + * - Borders + * + * OpenOffice: + * - Indents & spacing + * - Alignment + * - Text flow + * - Outline & numbering + * - Tabs + * - Dropcaps + * - Tabs + * - Borders + * - Background + * + * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_PPr.html */ class Paragraph extends AbstractStyle { @@ -38,32 +62,46 @@ class Paragraph extends AbstractStyle protected $aliases = array('line-height' => 'lineHeight'); /** - * Text line height + * Parent style * - * @var int + * @var string */ - private $lineHeight; + private $basedOn = 'Normal'; /** - * Set of Custom Tab Stops + * Style for next paragraph * - * @var \PhpOffice\PhpWord\Style\Tab[] + * @var string */ - private $tabs = array(); + private $next; /** - * Parent style + * Alignment * - * @var string + * @var \PhpOffice\PhpWord\Style\Alignment */ - private $basedOn = 'Normal'; + private $alignment; /** - * Style for next paragraph + * Indentation * - * @var string + * @var \PhpOffice\PhpWord\Style\Indentation */ - private $next; + private $indentation; + + /** + * Spacing + * + * @var \PhpOffice\PhpWord\Style\Spacing + */ + private $spacing; + + /** + * Text line height + * + * @var int + */ + private $lineHeight; /** * Allow first/last line to display on a separate page @@ -93,27 +131,6 @@ class Paragraph extends AbstractStyle */ private $pageBreakBefore = false; - /** - * Indentation - * - * @var \PhpOffice\PhpWord\Style\Indentation - */ - private $indentation; - - /** - * Spacing - * - * @var \PhpOffice\PhpWord\Style\Spacing - */ - private $spacing; - - /** - * Alignment - * - * @var \PhpOffice\PhpWord\Style\Alignment - */ - private $alignment; - /** * Numbering style name * @@ -128,6 +145,13 @@ class Paragraph extends AbstractStyle */ private $numLevel = 0; + /** + * Set of Custom Tab Stops + * + * @var \PhpOffice\PhpWord\Style\Tab[] + */ + private $tabs = array(); + /** * Create new instance */ @@ -155,6 +179,38 @@ public function setStyleValue($key, $value) return parent::setStyleValue($key, $value); } + /** + * Get style values + * + * An experiment to retrieve all style values in one function. This will + * reduce function call and increase cohesion between functions. Should be + * implemented in all styles. + * + * @return array + */ + public function getStyleValues() + { + return array( + 'name' => $this->getStyleName(), + 'basedOn' => $this->getBasedOn(), + 'next' => $this->getNext(), + 'alignment' => $this->getAlign(), + 'indentation' => $this->getIndentation(), + 'spacing' => $this->getSpace(), + 'pagination' => array( + 'widowControl' => $this->hasWidowControl(), + 'keepNext' => $this->isKeepNext(), + 'keepLines' => $this->isKeepLines(), + 'pageBreak' => $this->hasPageBreakBefore(), + ), + 'numbering' => array( + 'style' => $this->getNumStyle(), + 'level' => $this->getNumLevel(), + ), + 'tabs' => $this->getTabs(), + ); + } + /** * Get alignment * @@ -179,109 +235,71 @@ public function setAlign($value = null) } /** - * Get space before paragraph + * Get parent style ID * - * @return integer + * @return string */ - public function getSpaceBefore() + public function getBasedOn() { - if ($this->spacing !== null) { - return $this->spacing->getBefore(); - } else { - return null; - } + return $this->basedOn; } /** - * Set space before paragraph + * Set parent style ID * - * @param int $value + * @param string $value * @return self */ - public function setSpaceBefore($value = null) - { - return $this->setSpace(array('before' => $value)); - } - - /** - * Get space after paragraph - * - * @return integer - */ - public function getSpaceAfter() + public function setBasedOn($value = 'Normal') { - if ($this->spacing !== null) { - return $this->spacing->getAfter(); - } else { - return null; - } - } + $this->basedOn = $value; - /** - * Set space after paragraph - * - * @param int $value - * @return self - */ - public function setSpaceAfter($value = null) - { - return $this->setSpace(array('after' => $value)); + return $this; } /** - * Get spacing between lines + * Get style for next paragraph * - * @return int + * @return string */ - public function getSpacing() + public function getNext() { - if ($this->spacing !== null) { - return $this->spacing->getLine(); - } else { - return null; - } + return $this->next; } /** - * Set spacing between lines + * Set style for next paragraph * - * @param int $value + * @param string $value * @return self */ - public function setSpacing($value = null) + public function setNext($value = null) { - return $this->setSpace(array('line' => $value)); + $this->next = $value; + + return $this; } /** - * Get line height + * Get shading * - * @return int|float + * @return \PhpOffice\PhpWord\Style\Indentation */ - public function getLineHeight() + public function getIndentation() { - return $this->lineHeight; + return $this->indentation; } /** - * Set the line height + * Set shading * - * @param int|float|string $lineHeight + * @param mixed $value * @return self - * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException */ - public function setLineHeight($lineHeight) + public function setIndentation($value = null) { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } + $this->setObjectVal($value, 'Indentation', $this->indentation); - $this->lineHeight = $lineHeight; - $this->setSpacing($lineHeight * self::LINE_HEIGHT); return $this; } @@ -336,73 +354,134 @@ public function setHanging($value = null) } /** - * Get tabs + * Get spacing * - * @return \PhpOffice\PhpWord\Style\Tab[] + * @return \PhpOffice\PhpWord\Style\Spacing + * @todo Rename to getSpacing in 1.0 */ - public function getTabs() + public function getSpace() { - return $this->tabs; + return $this->spacing; } /** - * Set tabs + * Set spacing * - * @param array $value + * @param mixed $value * @return self + * @todo Rename to setSpacing in 1.0 */ - public function setTabs($value = null) + public function setSpace($value = null) { - if (is_array($value)) { - $this->tabs = $value; - } + $this->setObjectVal($value, 'Spacing', $this->spacing); return $this; } /** - * Get parent style ID + * Get space before paragraph * - * @return string + * @return integer */ - public function getBasedOn() + public function getSpaceBefore() { - return $this->basedOn; + if ($this->spacing !== null) { + return $this->spacing->getBefore(); + } else { + return null; + } } /** - * Set parent style ID + * Set space before paragraph * - * @param string $value + * @param int $value * @return self */ - public function setBasedOn($value = 'Normal') + public function setSpaceBefore($value = null) { - $this->basedOn = $value; + return $this->setSpace(array('before' => $value)); + } - return $this; + /** + * Get space after paragraph + * + * @return integer + */ + public function getSpaceAfter() + { + if ($this->spacing !== null) { + return $this->spacing->getAfter(); + } else { + return null; + } } /** - * Get style for next paragraph + * Set space after paragraph * - * @return string + * @param int $value + * @return self */ - public function getNext() + public function setSpaceAfter($value = null) { - return $this->next; + return $this->setSpace(array('after' => $value)); } /** - * Set style for next paragraph + * Get spacing between lines * - * @param string $value + * @return int + */ + public function getSpacing() + { + if ($this->spacing !== null) { + return $this->spacing->getLine(); + } else { + return null; + } + } + + /** + * Set spacing between lines + * + * @param int $value * @return self */ - public function setNext($value = null) + public function setSpacing($value = null) { - $this->next = $value; + return $this->setSpace(array('line' => $value)); + } + + /** + * Get line height + * + * @return int|float + */ + public function getLineHeight() + { + return $this->lineHeight; + } + /** + * Set the line height + * + * @param int|float|string $lineHeight + * @return self + * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException + */ + public function setLineHeight($lineHeight) + { + if (is_string($lineHeight)) { + $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); + } + + if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { + throw new InvalidStyleException('Line height must be a valid number'); + } + + $this->lineHeight = $lineHeight; + $this->setSpacing($lineHeight * self::LINE_HEIGHT); return $this; } @@ -498,54 +577,6 @@ public function setPageBreakBefore($value = true) return $this; } - /** - * Get shading - * - * @return \PhpOffice\PhpWord\Style\Indentation - */ - public function getIndentation() - { - return $this->indentation; - } - - /** - * Set shading - * - * @param mixed $value - * @return self - */ - public function setIndentation($value = null) - { - $this->setObjectVal($value, 'Indentation', $this->indentation); - - return $this; - } - - /** - * Get shading - * - * @return \PhpOffice\PhpWord\Style\Spacing - * @todo Rename to getSpacing in 1.0 - */ - public function getSpace() - { - return $this->spacing; - } - - /** - * Set shading - * - * @param mixed $value - * @return self - * @todo Rename to setSpacing in 1.0 - */ - public function setSpace($value = null) - { - $this->setObjectVal($value, 'Spacing', $this->spacing); - - return $this; - } - /** * Get numbering style name * @@ -592,6 +623,31 @@ public function setNumLevel($value = 0) return $this; } + /** + * Get tabs + * + * @return \PhpOffice\PhpWord\Style\Tab[] + */ + public function getTabs() + { + return $this->tabs; + } + + /** + * Set tabs + * + * @param array $value + * @return self + */ + public function setTabs($value = null) + { + if (is_array($value)) { + $this->tabs = $value; + } + + return $this; + } + /** * Get allow first/last line to display on a separate page setting * diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 36ef4866ec..1db2efddbd 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -74,7 +74,7 @@ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $ $tocStyle = $element->getStyleTOC(); $fontStyle = $element->getStyleFont(); $isObject = ($fontStyle instanceof Font) ? true : false; - $anchor = '_Toc' . ($title->getRelationId() + 252634154); + $rId = $title->getRelationId(); $indent = ($title->getDepth() - 1) * $tocStyle->getIndent(); $xmlWriter->startElement('w:p'); @@ -87,7 +87,7 @@ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $ // Hyperlink $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('w:anchor', $anchor); + $xmlWriter->writeAttribute('w:anchor', "_Toc{$rId}"); $xmlWriter->writeAttribute('w:history', '1'); // Title text @@ -114,7 +114,7 @@ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $ $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:instrText'); $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw('PAGEREF ' . $anchor . ' \h'); + $xmlWriter->writeRaw("PAGEREF _Toc{$rId} \h"); $xmlWriter->endElement(); $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 298bd9b103..144e67abe8 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -35,8 +35,6 @@ public function write() return; } - $rId = $element->getRelationId(); - $anchor = '_Toc' . ($rId + 252634154); $style = $element->getStyle(); $xmlWriter->startElement('w:p'); @@ -49,23 +47,22 @@ public function write() $xmlWriter->endElement(); } - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); + $rId = $element->getRelationId(); + // Bookmark start for TOC $xmlWriter->startElement('w:bookmarkStart'); $xmlWriter->writeAttribute('w:id', $rId); - $xmlWriter->writeAttribute('w:name', $anchor); + $xmlWriter->writeAttribute('w:name', "_Toc{$rId}"); $xmlWriter->endElement(); + // Actual text $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:t'); $xmlWriter->writeRaw($this->getText($element->getText())); $xmlWriter->endElement(); $xmlWriter->endElement(); + // Bookmark end $xmlWriter->startElement('w:bookmarkEnd'); $xmlWriter->writeAttribute('w:id', $rId); $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 8741c1774c..4487aa71b3 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; @@ -74,41 +75,66 @@ private function writeStyle() return; } $xmlWriter = $this->getXmlWriter(); + $styles = $style->getStyleValues(); if (!$this->withoutPPR) { $xmlWriter->startElement('w:pPr'); } // Style name - $styleName = $style->getStyleName(); - $xmlWriter->writeElementIf(!is_null($styleName), 'w:pStyle', 'w:val', $styleName); + $xmlWriter->writeElementIf($styles['name'] !== null, 'w:pStyle', 'w:val', $styles['name']); // Alignment - $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $style->getAlign()))); + $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $styles['alignment']))); $styleWriter->write(); // Pagination - $xmlWriter->writeElementIf(!$style->hasWidowControl(), 'w:widowControl', 'w:val', '0'); - $xmlWriter->writeElementIf($style->isKeepNext(), 'w:keepNext', 'w:val', '1'); - $xmlWriter->writeElementIf($style->isKeepLines(), 'w:keepLines', 'w:val', '1'); - $xmlWriter->writeElementIf($style->hasPageBreakBefore(), 'w:pageBreakBefore', 'w:val', '1'); - - // Indentation - $indentation = $style->getIndentation(); - if (!is_null($indentation)) { - $styleWriter = new Indentation($xmlWriter, $indentation); - $styleWriter->write(); + $xmlWriter->writeElementIf($styles['pagination']['widowControl'] === false, 'w:widowControl', 'w:val', '0'); + $xmlWriter->writeElementIf($styles['pagination']['keepNext'] === true, 'w:keepNext', 'w:val', '1'); + $xmlWriter->writeElementIf($styles['pagination']['keepLines'] === true, 'w:keepLines', 'w:val', '1'); + $xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', 'w:val', '1'); + + // Indentation & spacing + $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']); + $this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']); + + // Tabs + $this->writeTabs($xmlWriter, $styles['tabs']); + + // Numbering + $this->writeNumbering($xmlWriter, $styles['numbering']); + + if (!$this->withoutPPR) { + $xmlWriter->endElement(); // w:pPr } + } + + /** + * Write child style + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $name + * @param string $value + */ + private function writeChildStyle(XMLWriter $xmlWriter, $name, $value) + { + if ($value !== null) { + $class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\" . $name; - // Spacing - $spacing = $style->getSpace(); - if (!is_null($spacing)) { - $styleWriter = new Spacing($xmlWriter, $spacing); - $styleWriter->write(); + /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $writer */ + $writer = new $class($xmlWriter, $value); + $writer->write(); } + } - // Tabs - $tabs = $style->getTabs(); + /** + * Write tabs + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param array $tabs + */ + private function writeTabs(XMLWriter $xmlWriter, $tabs) + { if (!empty($tabs)) { $xmlWriter->startElement("w:tabs"); foreach ($tabs as $tab) { @@ -117,28 +143,35 @@ private function writeStyle() } $xmlWriter->endElement(); } + } - // Numbering - $numStyleName = $style->getNumStyle(); - $numStyleObject = Style::getStyle($numStyleName); - if ($numStyleName !== null && $numStyleObject !== null) { + /** + * Write numbering + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param array $numbering + */ + private function writeNumbering(XMLWriter $xmlWriter, $numbering) + { + $numStyle = $numbering['style']; + $numLevel = $numbering['level']; + + /** @var \PhpOffice\PhpWord\Style\Numbering $numbering */ + $numbering = Style::getStyle($numStyle); + if ($numStyle !== null && $numbering !== null) { $xmlWriter->startElement('w:numPr'); $xmlWriter->startElement('w:numId'); - $xmlWriter->writeAttribute('w:val', $numStyleObject->getIndex()); + $xmlWriter->writeAttribute('w:val', $numbering->getIndex()); $xmlWriter->endElement(); // w:numId $xmlWriter->startElement('w:ilvl'); - $xmlWriter->writeAttribute('w:val', $style->getNumLevel()); + $xmlWriter->writeAttribute('w:val', $numLevel); $xmlWriter->endElement(); // w:ilvl $xmlWriter->endElement(); // w:numPr $xmlWriter->startElement('w:outlineLvl'); - $xmlWriter->writeAttribute('w:val', $style->getNumLevel()); + $xmlWriter->writeAttribute('w:val', $numLevel); $xmlWriter->endElement(); // w:outlineLvl } - - if (!$this->withoutPPR) { - $xmlWriter->endElement(); // w:pPr - } } /** diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 9223470e69..e393355716 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -342,8 +342,6 @@ public function testWriteTitle() $element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; $this->assertEquals('Heading1', $doc->getElementAttribute($element, 'w:val')); - $element = "/w:document/w:body/w:p/w:r/w:fldChar"; - $this->assertEquals('end', $doc->getElementAttribute($element, 'w:fldCharType')); } /** From 4f9399899a2281cc1120782911bc88e16f8d93bc Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 30 May 2014 20:44:06 +0700 Subject: [PATCH 159/167] QA: Docblock improvements and -q parameter for phpdoc --- .travis.yml | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 2 ++ src/PhpWord/Reader/Word2007/Document.php | 1 + src/PhpWord/Shared/Html.php | 4 +++- src/PhpWord/Style/Image.php | 2 ++ src/PhpWord/Style/Paragraph.php | 4 +++- src/PhpWord/Writer/Word2007/Style/Paragraph.php | 7 ++++--- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 63165dbd95..73dd68ec83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ script: ## PHPUnit - phpunit -c ./ --coverage-text --coverage-html ./build/coverage ## PHPDocumentor - - vendor/bin/phpdoc.php -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" + - vendor/bin/phpdoc.php -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" after_script: ## PHPDocumentor diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 8f14daed1c..a7261d6d9d 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -437,6 +437,7 @@ private function readCellStyle(XMLReader $xmlReader, \DOMElement $domNode) * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $parentNode * @param array $styleDefs + * @ignoreScrutinizerPatch * @return array */ protected function readStyleDefs(XMLReader $xmlReader, \DOMElement $parentNode = null, $styleDefs = array()) @@ -467,6 +468,7 @@ protected function readStyleDefs(XMLReader $xmlReader, \DOMElement $parentNode = * Return style definition based on conversion method * * @param string $method + * @ignoreScrutinizerPatch * @param mixed $attributeValue * @param mixed $expected * @return mixed diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 80d2dde234..be804531d3 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -99,6 +99,7 @@ private function readHeaderFooter($settings, Section &$section) * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode + * @ignoreScrutinizerPatch * @return array */ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 501d24046a..171cfa21d0 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -242,7 +242,9 @@ protected static function parseNode( $cNodes = $node->childNodes; if (count($cNodes) > 0) { foreach ($cNodes as $cNode) { - self::parseNode($cNode, $newobject, $styles, $data); + if ($newobject instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { + self::parseNode($cNode, $newobject, $styles, $data); + } } } } diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 1de518700f..3798c1a22f 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -245,6 +245,7 @@ public function getMarginTop() /** * Set margin top * + * @ignoreScrutinizerPatch * @param int|float $value * @return self */ @@ -268,6 +269,7 @@ public function getMarginLeft() /** * Set margin left * + * @ignoreScrutinizerPatch * @param int|float $value * @return self */ diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 1aacd44f5c..32c7f0f886 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -190,7 +190,7 @@ public function setStyleValue($key, $value) */ public function getStyleValues() { - return array( + $styles = array( 'name' => $this->getStyleName(), 'basedOn' => $this->getBasedOn(), 'next' => $this->getNext(), @@ -209,6 +209,8 @@ public function getStyleValues() ), 'tabs' => $this->getTabs(), ); + + return $styles; } /** diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 4487aa71b3..f328770083 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -20,6 +20,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; +use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; /** * Paragraph style writer @@ -71,7 +72,7 @@ public function write() private function writeStyle() { $style = $this->getStyle(); - if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) { + if (!$style instanceof ParagraphStyle) { return; } $xmlWriter = $this->getXmlWriter(); @@ -114,7 +115,7 @@ private function writeStyle() * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $name - * @param string $value + * @param mixed $value */ private function writeChildStyle(XMLWriter $xmlWriter, $name, $value) { @@ -131,7 +132,7 @@ private function writeChildStyle(XMLWriter $xmlWriter, $name, $value) * Write tabs * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param array $tabs + * @param \PhpOffice\PhpWord\Style\Tab[] $tabs */ private function writeTabs(XMLWriter $xmlWriter, $tabs) { From 0164e37873bf45f1cac86b6e995c32bf9e9b9b6e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 01:30:59 +0700 Subject: [PATCH 160/167] Decompose Shared\Html --- samples/Sample_26_Html.php | 6 +- src/PhpWord/Shared/Html.php | 436 ++++++++++++++++++++------------ src/PhpWord/Style/Paragraph.php | 1 + 3 files changed, 278 insertions(+), 165 deletions(-) diff --git a/samples/Sample_26_Html.php b/samples/Sample_26_Html.php index 5843691561..92b3aa498c 100644 --- a/samples/Sample_26_Html.php +++ b/samples/Sample_26_Html.php @@ -8,7 +8,11 @@ $section = $phpWord->addSection(); $html = '

Adding element via HTML

'; $html .= '

Some well formed HTML snippet needs to be used

'; -$html .= '

With for example some inline formatting

'; +$html .= '

With for example some1 inline formatting1

'; +$html .= '

Unordered (bulleted) list:

'; +$html .= '
  • Item 1
  • Item 2
    • Item 2.1
    • Item 2.1
'; +$html .= '

Ordered (numbered) list:

'; +$html .= '
  1. Item 1
  2. Item 2
'; \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html); diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 171cfa21d0..bfe64a2596 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -17,8 +17,12 @@ namespace PhpOffice\PhpWord\Shared; +use PhpOffice\PhpWord\Element\AbstractContainer; + /** * Common Html functions + * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) For readWPNode */ class Html { @@ -27,10 +31,10 @@ class Html * * Note: $stylesheet parameter is removed to avoid PHPMD error for unused parameter * - * @param \PhpOffice\PhpWord\Element\AbstractContainer $object Where the parts need to be added + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element Where the parts need to be added * @param string $html the code to parse */ - public static function addHtml($object, $html) + public static function addHtml($element, $html) { /* * @todo parse $stylesheet for default styles. Should result in an array based on id, class and element, @@ -44,17 +48,17 @@ public static function addHtml($object, $html) $node = $dom->getElementsByTagName('body'); - self::parseNode($node->item(0), $object); + self::parseNode($node->item(0), $element); } /** * parse Inline style of a node * * @param \DOMNode $node Node to check on attributes and to compile a style array - * @param array $style is supplied, the inline style attributes are added to the already existing style + * @param array $styles is supplied, the inline style attributes are added to the already existing style * @return array */ - protected static function parseInlineStyle($node, $style = array()) + protected static function parseInlineStyle($node, $styles = array()) { if ($node->nodeType == XML_ELEMENT_NODE) { $attributes = $node->attributes; // get all the attributes(eg: id, class) @@ -62,191 +66,295 @@ protected static function parseInlineStyle($node, $style = array()) foreach ($attributes as $attribute) { switch ($attribute->name) { case 'style': - $properties = explode(';', trim($attribute->value, " \t\n\r\0\x0B;")); - foreach ($properties as $property) { - list ($cKey, $cValue) = explode(':', $property, 2); - $cValue = trim($cValue); - switch (trim($cKey)) { - case 'text-decoration': - switch ($cValue) { - case 'underline': - $style['underline'] = 'single'; - break; - case 'line-through': - $style['strikethrough'] = true; - break; - } - break; - case 'text-align': - $style['align'] = $cValue; - break; - case 'color': - $style['color'] = trim($cValue, "#"); - break; - case 'background-color': - $style['bgColor'] = trim($cValue, "#"); - break; - } - } + $styles = self::parseStyle($attribute, $styles); break; } } } - return $style; + return $styles; } /** - * parse a node and add a corresponding element to the object + * Parse a node and add a corresponding element to the parent element * * @param \DOMNode $node node to parse - * @param \PhpOffice\PhpWord\Element\AbstractContainer $object object to add an element corresponding with the node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element object to add an element corresponding with the node * @param array $styles Array with all styles * @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems */ - protected static function parseNode( - $node, - $object, - $styles = array('fontStyle' => array(), 'paragraphStyle' => array(), 'listStyle' => array()), - $data = array() - ) { - $newobject = null; - switch ($node->nodeName) { - case 'p': - $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - - /** - * @todo Think of a clever way of defining header styles, now it is only based on the assumption, that - * Heading1 - Heading6 are already defined somewhere - */ - case 'h1': - $styles['paragraphStyle'] = 'Heading1'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case 'h2': - $styles['paragraphStyle'] = 'Heading2'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case 'h3': - $styles['paragraphStyle'] = 'Heading3'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case 'h4': - $styles['paragraphStyle'] = 'Heading4'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case 'h5': - $styles['paragraphStyle'] = 'Heading5'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case 'h6': - $styles['paragraphStyle'] = 'Heading6'; - $newobject = $object->addTextRun($styles['paragraphStyle']); - break; - case '#text': - $styles['fontStyle'] = self::parseInlineStyle($node, $styles['fontStyle']); - if (method_exists($object, 'addText')) { - $object->addText($node->nodeValue, $styles['fontStyle'], $styles['paragraphStyle']); - } - break; - case 'strong': - $styles['fontStyle']['bold'] = true; - break; - case 'em': - $styles['fontStyle']['italic'] = true; - break; - case 'sup': - $styles['fontStyle']['superScript'] = true; - break; - case 'sub': - $styles['fontStyle']['subScript'] = true; - break; - - /** - * @todo As soon as TableItem, RowItem and CellItem support relative width and height - */ - case 'table': - $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); - $newobject = $object->addTable(); - // if ($attributes->getNamedItem('width') !== null) { - // $newobject->setWidth($attributes->getNamedItem('width')->value); - // } - break; - case 'tr': - /** @var \PhpOffice\PhpWord\Element\Table $object Type hint */ - $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); - $newobject = $object->addRow(); - // if ($attributes->getNamedItem('height') !== null) { - // $newobject->setHeight($attributes->getNamedItem('height')->value); - // } - break; - case 'td': - /** @var \PhpOffice\PhpWord\Element\Row $object Type hint */ - $styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']); - // if ($attributes->getNamedItem('width') !== null) { - // $newobject=$object->addCell($width=$attributes->getNamedItem('width')->value); - // } else { - // $newobject=$object->addCell(); - // } - $newobject = $object->addCell(); - break; - case 'ul': - if (isset($data['listdepth'])) { - $data['listdepth'] ++; - } else { - $data['listdepth'] = 0; - } - $styles['listStyle']['listType'] = 3; // TYPE_BULLET_FILLED = 3; - break; - case 'ol': - if (isset($data['listdepth'])) { - $data['listdepth'] ++; - } else { - $data['listdepth'] = 0; + protected static function parseNode($node, $element, $styles = array(), $data = array()) + { + // Populate styles array + $styleTypes = array('font', 'paragraph', 'list'); + foreach ($styleTypes as $styleType) { + if (!isset($styles[$styleType])) { + $styles[$styleType] = array(); + } + } + + // Node mapping table + $nodes = array( + // $method $node $element $styles $data $argument1 $argument2 + 'p' => array('Paragraph', $node, $element, $styles, null, null, null), + 'h1' => array('Heading', null, $element, $styles, null, 'Heading1', null), + 'h2' => array('Heading', null, $element, $styles, null, 'Heading2', null), + 'h3' => array('Heading', null, $element, $styles, null, 'Heading3', null), + 'h4' => array('Heading', null, $element, $styles, null, 'Heading4', null), + 'h5' => array('Heading', null, $element, $styles, null, 'Heading5', null), + 'h6' => array('Heading', null, $element, $styles, null, 'Heading6', null), + '#text' => array('Text', $node, $element, $styles, null, null, null), + 'strong' => array('Property', null, null, $styles, null, 'bold', true), + 'em' => array('Property', null, null, $styles, null, 'italic', true), + 'sup' => array('Property', null, null, $styles, null, 'superScript', true), + 'sub' => array('Property', null, null, $styles, null, 'subScript', true), + 'table' => array('Table', $node, $element, $styles, null, 'addTable', true), + 'tr' => array('Table', $node, $element, $styles, null, 'addRow', true), + 'td' => array('Table', $node, $element, $styles, null, 'addCell', true), + 'ul' => array('List', null, null, $styles, $data, 3, null), + 'ol' => array('List', null, null, $styles, $data, 7, null), + 'li' => array('ListItem', $node, $element, $styles, $data, null, null), + ); + + $newElement = null; + $keys = array('node', 'element', 'styles', 'data', 'argument1', 'argument2'); + + if (array_key_exists($node->nodeName, $nodes)) { + + // Execute method based on node mapping table and return $newElement or null + // Arguments are passed by reference + $arguments = array(); + $args = array(); + list($method, $args[0], $args[1], $args[2], $args[3], $args[4], $args[5]) = $nodes[$node->nodeName]; + for ($i = 0; $i <= 5; $i++) { + if ($args[$i] !== null) { + $arguments[$keys[$i]] = &$args[$i]; } - $styles['listStyle']['listType'] = 7; // TYPE_NUMBER = 7; - break; - - /** - * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes - */ - case 'li': - $cNodes = $node->childNodes; - if (count($cNodes) > 0) { - $text = ''; - foreach ($cNodes as $cNode) { - if ($cNode->nodeName == '#text') { - $text = $cNode->nodeValue; - } - } - $object->addListItem( - $text, - $data['listdepth'], - $styles['fontStyle'], - $styles['listStyle'], - $styles['paragraphStyle'] - ); + } + $method = "parse{$method}"; + $newElement = call_user_func_array(array('PhpOffice\PhpWord\Shared\Html', $method), $arguments); + + // Retrieve back variables from arguments + foreach ($keys as $key) { + if (array_key_exists($key, $arguments)) { + $$key = $arguments[$key]; } + } } - if ($newobject === null) { - $newobject = $object; + if ($newElement === null) { + $newElement = $element; } - /** - * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete condition - */ + self::parseChildNodes($node, $newElement, $styles, $data); + } + + /** + * Parse child nodes + * + * @param \DOMNode $node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @param array $data + */ + private static function parseChildNodes($node, $element, $styles, $data) + { if ($node->nodeName != 'li') { $cNodes = $node->childNodes; if (count($cNodes) > 0) { foreach ($cNodes as $cNode) { - if ($newobject instanceof \PhpOffice\PhpWord\Element\AbstractContainer) { - self::parseNode($cNode, $newobject, $styles, $data); + if ($element instanceof AbstractContainer) { + self::parseNode($cNode, $element, $styles, $data); } } } } } + + /** + * Parse paragraph node + * + * @param \DOMNode $node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @return \PhpOffice\PhpWord\Element\TextRun + */ + private static function parseParagraph($node, $element, &$styles) + { + $styles['paragraph'] = self::parseInlineStyle($node, $styles['paragraph']); + $newElement = $element->addTextRun($styles['paragraph']); + + return $newElement; + } + + /** + * Parse heading node + * + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @param string $argument1 Name of heading style + * @return \PhpOffice\PhpWord\Element\TextRun + * + * @todo Think of a clever way of defining header styles, now it is only based on the assumption, that + * Heading1 - Heading6 are already defined somewhere + */ + private static function parseHeading($element, &$styles, $argument1) + { + $styles['paragraph'] = $argument1; + $newElement = $element->addTextRun($styles['paragraph']); + + return $newElement; + } + + /** + * Parse text node + * + * @param \DOMNode $node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @return null + */ + private static function parseText($node, $element, &$styles) + { + $styles['font'] = self::parseInlineStyle($node, $styles['font']); + if (method_exists($element, 'addText')) { + $element->addText($node->nodeValue, $styles['font'], $styles['paragraph']); + } + + return null; + } + + /** + * Parse property node + * + * @param array $styles + * @param string $argument1 Style name + * @param string $argument2 Style value + * @return null + */ + private static function parseProperty(&$styles, $argument1, $argument2) + { + $styles['font'][$argument1] = $argument2; + + return null; + } + + /** + * Parse table node + * + * @param \DOMNode $node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @param string $argument1 Method name + * @return \PhpOffice\PhpWord\Element\AbstractContainer $element + * + * @todo As soon as TableItem, RowItem and CellItem support relative width and height + */ + private static function parseTable($node, $element, &$styles, $argument1) + { + $styles['paragraph'] = self::parseInlineStyle($node, $styles['paragraph']); + + $newElement = $element->$argument1(); + + // $attributes = $node->attributes; + // if ($attributes->getNamedItem('width') !== null) { + // $newElement->setWidth($attributes->getNamedItem('width')->value); + // } + + // if ($attributes->getNamedItem('height') !== null) { + // $newElement->setHeight($attributes->getNamedItem('height')->value); + // } + // if ($attributes->getNamedItem('width') !== null) { + // $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value); + // } + + return $newElement; + } + + /** + * Parse list node + * + * @param array $styles + * @param array $data + * @param string $argument1 List type + * @return null + */ + private static function parseList(&$styles, &$data, $argument1) + { + if (isset($data['listdepth'])) { + $data['listdepth']++; + } else { + $data['listdepth'] = 0; + } + $styles['list']['listType'] = $argument1; + + return null; + } + + /** + * Parse list item node + * + * @param \DOMNode $node + * @param \PhpOffice\PhpWord\Element\AbstractContainer $element + * @param array $styles + * @param array $data + * @return null + * + * @todo This function is almost the same like `parseChildNodes`. Merged? + * @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes + */ + private static function parseListItem($node, $element, &$styles, $data) + { + $cNodes = $node->childNodes; + if (count($cNodes) > 0) { + $text = ''; + foreach ($cNodes as $cNode) { + if ($cNode->nodeName == '#text') { + $text = $cNode->nodeValue; + } + } + $element->addListItem($text, $data['listdepth'], $styles['font'], $styles['list'], $styles['paragraph']); + } + + return null; + } + + /** + * Parse style + * + * @param \DOMAttr $attribute + * @param array $styles + * @return array + */ + private static function parseStyle($attribute, $styles) + { + $properties = explode(';', trim($attribute->value, " \t\n\r\0\x0B;")); + foreach ($properties as $property) { + list($cKey, $cValue) = explode(':', $property, 2); + $cValue = trim($cValue); + switch (trim($cKey)) { + case 'text-decoration': + switch ($cValue) { + case 'underline': + $styles['underline'] = 'single'; + break; + case 'line-through': + $styles['strikethrough'] = true; + break; + } + break; + case 'text-align': + $styles['align'] = $cValue; + break; + case 'color': + $styles['color'] = trim($cValue, "#"); + break; + case 'background-color': + $styles['bgColor'] = trim($cValue, "#"); + break; + } + } + + return $styles; + } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 32c7f0f886..8167358663 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -186,6 +186,7 @@ public function setStyleValue($key, $value) * reduce function call and increase cohesion between functions. Should be * implemented in all styles. * + * @ignoreScrutinizerPatch * @return array */ public function getStyleValues() From ec85d7d641dc7f6a2f75f0ae81279b0c1c5d23a7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 03:06:11 +0700 Subject: [PATCH 161/167] #80: Basic HTML reader --- CHANGELOG.md | 3 +- samples/Sample_30_ReadHTML.php | 15 ++++++ samples/resources/Sample_30_ReadHTML.html | 15 ++++++ src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Reader/HTML.php | 50 ++++++++++++++++++ src/PhpWord/Shared/Html.php | 15 ++++-- tests/PhpWord/Tests/Reader/HTMLTest.php | 51 +++++++++++++++++++ .../Tests/_files/documents/reader.html | 15 ++++++ 8 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 samples/Sample_30_ReadHTML.php create mode 100644 samples/resources/Sample_30_ReadHTML.html create mode 100644 src/PhpWord/Reader/HTML.php create mode 100644 tests/PhpWord/Tests/Reader/HTMLTest.php create mode 100644 tests/PhpWord/Tests/_files/documents/reader.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4e6cf021..8b36f34a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.11.0 - Not yet released -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF reader were initiated. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF and HTML reader were initiated. ### Features @@ -33,6 +33,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - RTF Reader: Basic RTF reader - @ivanlanin GH-72 GH-252 - Element: New `Line` element - @basjan GH-253 - Title: Ability to apply numbering in heading - @ivanlanin GH-193 +- HTML Reader: Basic HTML reader - @ivanlanin GH-80 ### Bugfixes diff --git a/samples/Sample_30_ReadHTML.php b/samples/Sample_30_ReadHTML.php new file mode 100644 index 0000000000..029f8c8cfd --- /dev/null +++ b/samples/Sample_30_ReadHTML.php @@ -0,0 +1,15 @@ + + + +PHPWord + + +

Adding element via HTML

+

Some well formed HTML snippet needs to be used

+

With for example some1 inline formatting1

+

Unordered (bulleted) list:

+
  • Item 1
  • Item 2
    • Item 2.1
    • Item 2.1
+

Ordered (numbered) list:

+
  1. Item 1
  2. Item 2
+ + diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 0d5fe68949..1d78496234 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -51,7 +51,7 @@ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') */ public static function createReader($name = 'Word2007') { - if (!in_array($name, array('ReaderInterface', 'Word2007', 'ODText', 'RTF'))) { + if (!in_array($name, array('ReaderInterface', 'Word2007', 'ODText', 'RTF', 'HTML'))) { throw new Exception("\"{$name}\" is not a valid reader."); } diff --git a/src/PhpWord/Reader/HTML.php b/src/PhpWord/Reader/HTML.php new file mode 100644 index 0000000000..a6582a3f26 --- /dev/null +++ b/src/PhpWord/Reader/HTML.php @@ -0,0 +1,50 @@ +canRead($docFile)) { + $section = $phpWord->addSection(); + HTMLParser::addHtml($section, file_get_contents($docFile), true); + } else { + throw new \Exception("Cannot read {$docFile}."); + } + + return $phpWord; + } +} diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index bfe64a2596..83292a3a5e 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -32,20 +32,27 @@ class Html * Note: $stylesheet parameter is removed to avoid PHPMD error for unused parameter * * @param \PhpOffice\PhpWord\Element\AbstractContainer $element Where the parts need to be added - * @param string $html the code to parse + * @param string $html The code to parse + * @param bool $fullHTML If it's a full HTML, no need to add 'body' tag */ - public static function addHtml($element, $html) + public static function addHtml($element, $html, $fullHTML = false) { /* * @todo parse $stylesheet for default styles. Should result in an array based on id, class and element, * which could be applied when such an element occurs in the parseNode function. */ + + // Preprocess: remove all line ends, decode HTML entity, and add body tag for HTML fragments $html = str_replace(array("\n", "\r"), '', $html); + $html = html_entity_decode($html); + if ($fullHTML === false) { + $html = '' . $html . ''; + } + // Load DOM $dom = new \DOMDocument(); $dom->preserveWhiteSpace = true; - $dom->loadXML('' . html_entity_decode($html) . ''); - + $dom->loadXML($html); $node = $dom->getElementsByTagName('body'); self::parseNode($node->item(0), $element); diff --git a/tests/PhpWord/Tests/Reader/HTMLTest.php b/tests/PhpWord/Tests/Reader/HTMLTest.php new file mode 100644 index 0000000000..cb3dc55c29 --- /dev/null +++ b/tests/PhpWord/Tests/Reader/HTMLTest.php @@ -0,0 +1,51 @@ +assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord); + } + + /** + * Test load exception + * + * @expectedException \Exception + * @expectedExceptionMessage Cannot read + */ + public function testLoadException() + { + $filename = __DIR__ . '/../_files/documents/foo.html'; + IOFactory::load($filename, 'HTML'); + } +} diff --git a/tests/PhpWord/Tests/_files/documents/reader.html b/tests/PhpWord/Tests/_files/documents/reader.html new file mode 100644 index 0000000000..5593298bfb --- /dev/null +++ b/tests/PhpWord/Tests/_files/documents/reader.html @@ -0,0 +1,15 @@ + + + +PHPWord + + +

Adding element via HTML

+

Some well formed HTML snippet needs to be used

+

With for example some1 inline formatting1

+

Unordered (bulleted) list:

+
  • Item 1
  • Item 2
    • Item 2.1
    • Item 2.1
+

Ordered (numbered) list:

+
  1. Item 1
  2. Item 2
+ + From 022cdeb570519e238247afb0a75ff9b5949d3ef7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 03:28:58 +0700 Subject: [PATCH 162/167] Documentation updates and test fix for #254 --- CHANGELOG.md | 2 +- docs/intro.rst | 110 ++++++++++++------------ docs/src/documentation.md | 56 ++++++------ tests/PhpWord/Tests/Shared/HtmlTest.php | 4 +- 4 files changed, 86 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b36f34a7c..43b5373dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - RTF Reader: Basic RTF reader - @ivanlanin GH-72 GH-252 - Element: New `Line` element - @basjan GH-253 - Title: Ability to apply numbering in heading - @ivanlanin GH-193 -- HTML Reader: Basic HTML reader - @ivanlanin GH-80 +- HTML Reader: Basic HTML reader - @ivanlanin GH-80 GH-254 ### Bugfixes diff --git a/docs/intro.rst b/docs/intro.rst index 3da729e83b..9400123742 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -117,61 +117,61 @@ Writers Readers ~~~~~~~ -+---------------------------+----------------------+--------+-------+-------+ -| Features | | DOCX | ODT | RTF | -+===========================+======================+========+=======+=======+ -| **Document Properties** | Standard | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Custom | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| **Element Type** | Text | ✓ | ✓ | ✓ | -+---------------------------+----------------------+--------+-------+-------+ -| | Text Run | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Title | ✓ | ✓ | | -+---------------------------+----------------------+--------+-------+-------+ -| | Link | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Preserve Text | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Text Break | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Page Break | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | List | ✓ | ✓ | | -+---------------------------+----------------------+--------+-------+-------+ -| | Table | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Image | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Object | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Watermark | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Table of Contents | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Header | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Footer | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Footnote | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Endnote | ✓ | | | -+---------------------------+----------------------+--------+-------+-------+ -| **Graphs** | 2D basic graphs | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | 2D advanced graphs | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | 3D graphs | | | | -+---------------------------+----------------------+--------+-------+-------+ -| **Math** | OMML support | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | MathML support | | | | -+---------------------------+----------------------+--------+-------+-------+ -| **Bonus** | Encryption | | | | -+---------------------------+----------------------+--------+-------+-------+ -| | Protection | | | | -+---------------------------+----------------------+--------+-------+-------+ ++---------------------------+----------------------+--------+-------+-------+-------+ +| Features | | DOCX | ODT | RTF | HTML | ++===========================+======================+========+=======+=======+=======+ +| **Document Properties** | Standard | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Custom | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| **Element Type** | Text | ✓ | ✓ | ✓ | ✓ | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Text Run | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Title | ✓ | ✓ | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Link | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Preserve Text | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Text Break | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Page Break | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | List | ✓ | ✓ | | ✓ | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Table | ✓ | | | ✓ | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Image | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Object | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Watermark | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Table of Contents | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Header | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Footer | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Footnote | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Endnote | ✓ | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| **Graphs** | 2D basic graphs | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | 2D advanced graphs | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | 3D graphs | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| **Math** | OMML support | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | MathML support | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| **Bonus** | Encryption | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ +| | Protection | | | | | ++---------------------------+----------------------+--------+-------+-------+-------+ Contributing ------------ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 9db32c9fad..773269a935 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -111,34 +111,34 @@ Below are the supported features for each file formats. ### Readers -| Features | | DOCX | ODT | RTF | -|-------------------------|--------------------|------|-----|-----| -| **Document Properties** | Standard | ✓ | | | -| | Custom | ✓ | | | -| **Element Type** | Text | ✓ | ✓ | ✓ | -| | Text Run | ✓ | | | -| | Title | ✓ | ✓ | | -| | Link | ✓ | | | -| | Preserve Text | ✓ | | | -| | Text Break | ✓ | | | -| | Page Break | ✓ | | | -| | List | ✓ | ✓ | | -| | Table | ✓ | | | -| | Image | ✓ | | | -| | Object | | | | -| | Watermark | | | | -| | Table of Contents | | | | -| | Header | ✓ | | | -| | Footer | ✓ | | | -| | Footnote | ✓ | | | -| | Endnote | ✓ | | | -| **Graphs** | 2D basic graphs | | | | -| | 2D advanced graphs | | | | -| | 3D graphs | | | | -| **Math** | OMML support | | | | -| | MathML support | | | | -| **Bonus** | Encryption | | | | -| | Protection | | | | +| Features | | DOCX | ODT | RTF | HTML| +|-------------------------|--------------------|------|-----|-----|-----| +| **Document Properties** | Standard | ✓ | | | | +| | Custom | ✓ | | | | +| **Element Type** | Text | ✓ | ✓ | ✓ | ✓ | +| | Text Run | ✓ | | | | +| | Title | ✓ | ✓ | | | +| | Link | ✓ | | | | +| | Preserve Text | ✓ | | | | +| | Text Break | ✓ | | | | +| | Page Break | ✓ | | | | +| | List | ✓ | ✓ | | ✓ | +| | Table | ✓ | | | ✓ | +| | Image | ✓ | | | | +| | Object | | | | | +| | Watermark | | | | | +| | Table of Contents | | | | | +| | Header | ✓ | | | | +| | Footer | ✓ | | | | +| | Footnote | ✓ | | | | +| | Endnote | ✓ | | | | +| **Graphs** | 2D basic graphs | | | | | +| | 2D advanced graphs | | | | | +| | 3D graphs | | | | | +| **Math** | OMML support | | | | | +| | MathML support | | | | | +| **Bonus** | Encryption | | | | | +| | Protection | | | | | ## Contributing diff --git a/tests/PhpWord/Tests/Shared/HtmlTest.php b/tests/PhpWord/Tests/Shared/HtmlTest.php index 81714432b9..730600d743 100644 --- a/tests/PhpWord/Tests/Shared/HtmlTest.php +++ b/tests/PhpWord/Tests/Shared/HtmlTest.php @@ -58,8 +58,8 @@ public function testAddHtml() $section = new Section(1); $content = ''; $content .= '
HeaderContent
'; - $content .= '
  • Bullet
'; + $content .= '
  • Bullet
    • Bullet
'; $content .= '
  1. Bullet
'; - Html::addHtml($section, $content, null, array('listdepth' => 2)); + Html::addHtml($section, $content); } } From e7540c079ec8e574cded63447f75a71793e51a83 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 09:29:09 +0700 Subject: [PATCH 163/167] Add $nestedLevel to elements --- src/PhpWord/Element/AbstractContainer.php | 60 +++++++++++++---------- src/PhpWord/Element/AbstractElement.php | 35 +++++++++++-- src/PhpWord/Element/Row.php | 1 + src/PhpWord/Element/Table.php | 18 +++---- 4 files changed, 76 insertions(+), 38 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 0f065b419b..95186749e3 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -65,9 +65,18 @@ protected function addElement($elementName) $reflection = new \ReflectionClass($elementClass); $elementArgs = $args; array_shift($elementArgs); // Shift an element off the beginning of array: the $elementName + /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */ $element = $reflection->newInstanceArgs($elementArgs); + // Set nested level + if ($this->container == 'Cell') { + $element->setNestedLevel($this->getNestedLevel() + 1); + } else { + $element->setNestedLevel($this->getNestedLevel()); + } + + // Set relation Id for media collection $mediaContainer = $this->getMediaContainer(); if (in_array($elementName, array('Link', 'Image', 'Object'))) { @@ -143,32 +152,6 @@ public function addTextRun($paragraphStyle = null) return $this->addElement('TextRun', $paragraphStyle); } - /** - * Add field element - * - * @param string $type - * @param array $properties - * @param array $options - * @return \PhpOffice\PhpWord\Element\Field - */ - public function addField($type = null, $properties = array(), $options = array()) - { - return $this->addElement('Field', $type, $properties, $options); - } - - /** - * Add line element - * - * @param mixed $lineStyle - * @return \PhpOffice\PhpWord\Element\Line - */ - public function addLine($lineStyle = null) - { - return $this->addElement('Line', $lineStyle); - - } - - /** * Add link element * @@ -323,6 +306,31 @@ public function addTextBox($style = null) return $this->addElement('TextBox', $style); } + /** + * Add field element + * + * @param string $type + * @param array $properties + * @param array $options + * @return \PhpOffice\PhpWord\Element\Field + */ + public function addField($type = null, $properties = array(), $options = array()) + { + return $this->addElement('Field', $type, $properties, $options); + } + + /** + * Add line element + * + * @param mixed $lineStyle + * @return \PhpOffice\PhpWord\Element\Line + */ + public function addLine($lineStyle = null) + { + return $this->addElement('Line', $lineStyle); + + } + /** * Check if a method is allowed for the current container * diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 4531136479..ca45ef23f9 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -84,6 +84,15 @@ abstract class AbstractElement */ protected $relationId; + /** + * Depth of table container nested level; Primarily used for RTF writer/reader + * + * 0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc. + * + * @var int + */ + private $nestedLevel = 0; + /** * Get PhpWord * @@ -197,11 +206,31 @@ public function getRelationId() /** * Set relation Id * - * @param int $rId + * @param int $value + */ + public function setRelationId($value) + { + $this->relationId = $value; + } + + /** + * Get nested level + * + * @return int + */ + public function getNestedLevel() + { + return $this->nestedLevel; + } + + /** + * Set nested level + * + * @param int $value */ - public function setRelationId($rId) + public function setNestedLevel($value) { - $this->relationId = $rId; + $this->nestedLevel = $value; } /** diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index 07957ac115..d7dcea3443 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -71,6 +71,7 @@ public function addCell($width = null, $style = null) $cell = new Cell($width, $style); $cell->setDocPart($this->getDocPart(), $this->getDocPartId()); $cell->setPhpWord($this->phpWord); + $cell->setNestedLevel($this->getNestedLevel()); $this->cells[] = $cell; return $cell; diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 01d3d7c8e4..ace634607d 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -45,7 +45,6 @@ class Table extends AbstractElement */ private $width = null; - /** * Create a new table * @@ -68,6 +67,7 @@ public function addRow($height = null, $style = null) $row = new Row($height, $style); $row->setDocPart($this->getDocPart(), $this->getDocPartId()); $row->setPhpWord($this->phpWord); + $row->setNestedLevel($this->getNestedLevel()); $this->rows[] = $row; return $row; @@ -110,23 +110,23 @@ public function getStyle() } /** - * Set table width + * Get table width * - * @param int $width + * @return int */ - public function setWidth($width) + public function getWidth() { - $this->width = $width; + return $this->width; } /** - * Get table width + * Set table width * - * @return int + * @param int $width */ - public function getWidth() + public function setWidth($width) { - return $this->width; + $this->width = $width; } /** From 2205377259731309383ccfa227bf2468730c25c4 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 12:37:38 +0700 Subject: [PATCH 164/167] #245: Basic table support in RTF writer --- CHANGELOG.md | 1 + docs/elements.rst | 2 +- docs/intro.rst | 2 +- docs/src/documentation.md | 6 +- .../Writer/RTF/Element/AbstractElement.php | 1 + src/PhpWord/Writer/RTF/Element/Table.php | 142 ++++++++++++++++++ src/PhpWord/Writer/RTF/Element/TextBreak.php | 2 +- src/PhpWord/Writer/RTF/Style/Paragraph.php | 25 ++- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- .../PhpWord/Tests/Writer/RTF/ElementTest.php | 2 +- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- 11 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 src/PhpWord/Writer/RTF/Element/Table.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 43b5373dac..30d6f0a386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - Element: New `Line` element - @basjan GH-253 - Title: Ability to apply numbering in heading - @ivanlanin GH-193 - HTML Reader: Basic HTML reader - @ivanlanin GH-80 GH-254 +- RTF Writer: Basic table writing - @ivanlanin GH-245 ### Bugfixes diff --git a/docs/elements.rst b/docs/elements.rst index 98ab042fde..7d07674206 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -25,7 +25,7 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 8 | List | v | v | v | v | - | - | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 9 | Table | v | v | v | ? | - | - | +| 9 | Table | v | v | v | v | - | - | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 10 | Image | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ diff --git a/docs/intro.rst b/docs/intro.rst index 9400123742..aca5b24153 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -81,7 +81,7 @@ Writers +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | List | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| | Table | ✓ | ✓ | | ✓ | ✓ | +| | Table | ✓ | ✓ | ✓ | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Image | ✓ | ✓ | ✓ | ✓ | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 773269a935..84522c1b5f 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -90,9 +90,9 @@ Below are the supported features for each file formats. | | Link | ✓ | ✓ | ✓ | ✓ | ✓ | | | Preserve Text | ✓ | | | | | | | Text Break | ✓ | ✓ | ✓ | ✓ | ✓ | -| | Page Break | ✓ | | ✓ | | | +| | Page Break | ✓ | | ✓ | | | | | List | ✓ | | | | | -| | Table | ✓ | ✓ | | ✓ | ✓ | +| | Table | ✓ | ✓ | ✓ | ✓ | ✓ | | | Image | ✓ | ✓ | ✓ | ✓ | | | | Object | ✓ | | | | | | | Watermark | ✓ | | | | | @@ -454,7 +454,7 @@ Below are the matrix of element availability in each container. The column shows | 6 | Text Break | v | v | v | v | v | v | | 7 | Page Break | v | - | - | - | - | - | | 8 | List | v | v | v | v | - | - | -| 9 | Table | v | v | v | ? | - | - | +| 9 | Table | v | v | v | v | - | - | | 10 | Image | v | v | v | v | v | v | | 11 | Watermark | - | v | - | - | - | - | | 12 | Object | v | v | v | v | v | v | diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index 7af9318071..79e139471b 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -98,6 +98,7 @@ protected function writeOpening() } $styleWriter = new ParagraphStyleWriter($this->paragraphStyle); + $styleWriter->setNestedLevel($this->element->getNestedLevel()); return $styleWriter->write(); } diff --git a/src/PhpWord/Writer/RTF/Element/Table.php b/src/PhpWord/Writer/RTF/Element/Table.php new file mode 100644 index 0000000000..b48e084f46 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Element/Table.php @@ -0,0 +1,142 @@ +element instanceof TableElement) { + return ''; + } + $element = $this->element; + // No nesting table for now + if ($element->getNestedLevel() >= 1) { + return ''; + } + + $content = ''; + $rows = $element->getRows(); + $rowCount = count($rows); + + if ($rowCount > 0) { + $content .= '\pard' . PHP_EOL; + + for ($i = 0; $i < $rowCount; $i++) { + $content .= '\trowd '; + $content .= $this->writeRowDef($rows[$i]); + $content .= PHP_EOL; + $content .= $this->writeRow($rows[$i]); + $content .= '\row' . PHP_EOL; + } + } + + return $content; + } + + /** + * Write column + * + * @return string + */ + private function writeRowDef(RowElement $row) + { + $content = ''; + + $rightMargin = 0; + foreach ($row->getCells() as $cell) { + $width = $cell->getWidth(); + $vMerge = $this->getVMerge($cell->getStyle()->getVMerge()); + if ($width === null) { + $width = 720; // Arbitrary default width + } + $rightMargin += $width; + $content .= "{$vMerge}\cellx{$rightMargin} "; + } + + return $content; + } + + /** + * Write row + * + * @return string + */ + private function writeRow(RowElement $row) + { + $content = ''; + + // Write cells + foreach ($row->getCells() as $cell) { + $content .= $this->writeCell($cell); + } + + return $content; + } + + /** + * Write cell + * + * @return string + */ + private function writeCell(CellElement $cell) + { + $content = '\intbl' . PHP_EOL; + + // Write content + $writer = new Container($this->parentWriter, $cell); + $content .= $writer->write(); + + $content .= '\cell' . PHP_EOL; + + return $content; + } + + /** + * Get vertical merge style + * + * @param string $value + * @return string + * @todo Move to style + */ + private function getVMerge($value) + { + $style = ''; + if ($value == 'restart') { + $style = '\clvmgf'; + } elseif ($value == 'continue') { + $style = '\clvmrg'; + } + + return $style; + } +} diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php index 4449be6515..57dc634994 100644 --- a/src/PhpWord/Writer/RTF/Element/TextBreak.php +++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php @@ -35,6 +35,6 @@ public function write() $parentWriter = $this->parentWriter; $parentWriter->setLastParagraphStyle(); - return '\par' . PHP_EOL; + return '\pard\par' . PHP_EOL; } } diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index e5f5d85e5e..b166cc2790 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -26,6 +26,16 @@ */ class Paragraph extends AbstractStyle { + + /** + * Depth of table container nested level; Primarily used for RTF writer/reader + * + * 0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc. + * + * @var int + */ + private $nestedLevel = 0; + /** * Write style * @@ -49,7 +59,10 @@ public function write() $spaceAfter = $style->getSpaceAfter(); $spaceBefore = $style->getSpaceBefore(); - $content = '\pard\nowidctlpar'; + $content = ''; + if ($this->nestedLevel == 0) { + $content .= '\pard\nowidctlpar '; + } if (isset($alignments[$align])) { $content .= $alignments[$align]; } @@ -58,4 +71,14 @@ public function write() return $content; } + + /** + * Set nested level + * + * @param int $value + */ + public function setNestedLevel($value) + { + $this->nestedLevel = $value; + } } diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index 88e673fbb4..25b8095b10 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -79,7 +79,7 @@ public function testSave() $section->addLink('http://test.com'); $section->addTitle('Test', 1); $section->addPageBreak(); - $section->addTable(); + $section->addTable()->addRow()->addCell()->addText('Test'); $section->addListItem('Test'); $section->addImage($imageSrc); $section->addObject($objectSrc); diff --git a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php index a31117e6b8..e1e0e4a782 100644 --- a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php @@ -28,7 +28,7 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $elements = array('Container', 'Text', 'Title', 'Link'); + $elements = array('Container', 'Text', 'Title', 'Link', 'Table'); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element; $parentWriter = new RTF(); diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index 51a66a7d15..cc88a91ad9 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -68,7 +68,7 @@ public function testSave() $section->addLink('http://test.com'); $section->addTitle('Test', 1); $section->addPageBreak(); - $section->addTable(); + $section->addTable()->addRow()->addCell()->addText('Test'); $section->addListItem('Test'); $section->addImage($imageSrc); $section->addObject($objectSrc); From 9839222492ba1f2e17935ab78913fa33e0b0722b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 31 May 2014 17:39:54 +0700 Subject: [PATCH 165/167] QA: Additional unit tests --- src/PhpWord/Element/AbstractContainer.php | 86 ++++++++++++------- src/PhpWord/Reader/ODText/AbstractPart.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 3 + src/PhpWord/Shared/ZipArchive.php | 1 + src/PhpWord/Writer/AbstractWriter.php | 13 +++ src/PhpWord/Writer/HTML/Element/Text.php | 2 +- src/PhpWord/Writer/HTML/Style/Font.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 11 ++- src/PhpWord/Writer/PDF/AbstractRenderer.php | 6 ++ tests/PhpWord/Tests/Element/FieldTest.php | 42 ++++++++- tests/PhpWord/Tests/Shared/XMLReaderTest.php | 13 +++ .../Tests/Style/NumberingLevelTest.php | 1 + tests/PhpWord/Tests/Style/ParagraphTest.php | 2 + .../PhpWord/Tests/Writer/HTML/ElementTest.php | 15 ++++ tests/PhpWord/Tests/Writer/HTML/PartTest.php | 36 ++++++++ tests/PhpWord/Tests/Writer/HTMLTest.php | 2 +- .../Tests/Writer/ODText/Part/ContentTest.php | 3 + .../PhpWord/Tests/Writer/RTF/ElementTest.php | 2 +- tests/PhpWord/Tests/Writer/RTFTest.php | 11 ++- .../Tests/Writer/Word2007/ElementTest.php | 24 ++++++ .../Writer/Word2007/Part/DocumentTest.php | 2 + .../Tests/Writer/Word2007/StyleTest.php | 19 ++++ 22 files changed, 254 insertions(+), 44 deletions(-) create mode 100644 tests/PhpWord/Tests/Writer/HTML/PartTest.php diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 95186749e3..99927c686a 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -60,49 +60,29 @@ protected function addElement($elementName) if ($withoutP && ($elementName == 'Text' || $elementName == 'PreserveText')) { $args[3] = null; // Remove paragraph style for texts in textrun } + $source = ''; + if (count($args) > 1) { + $source = $args[1]; + } // Create element using reflection $reflection = new \ReflectionClass($elementClass); $elementArgs = $args; - array_shift($elementArgs); // Shift an element off the beginning of array: the $elementName + array_shift($elementArgs); // Shift the $elementName off the beginning of array /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */ $element = $reflection->newInstanceArgs($elementArgs); - // Set nested level - if ($this->container == 'Cell') { - $element->setNestedLevel($this->getNestedLevel() + 1); - } else { - $element->setNestedLevel($this->getNestedLevel()); - } - - - // Set relation Id for media collection - $mediaContainer = $this->getMediaContainer(); - if (in_array($elementName, array('Link', 'Image', 'Object'))) { - /** @var \PhpOffice\PhpWord\Element\Image $element Type hint */ - $image = ($elementName == 'Image') ? $element : null; - $rId = Media::addElement($mediaContainer, strtolower($elementName), $args[1], $image); - $element->setRelationId($rId); - } - if ($elementName == 'Object') { - /** @var \PhpOffice\PhpWord\Element\Object $element Type hint */ - $rIdIcon = Media::addElement($mediaContainer, 'image', $element->getIcon(), new Image($element->getIcon())); - $element->setImageRelationId($rIdIcon); - } - - // Set relation Id for other collection - if (in_array($elementName, array('Footnote', 'Endnote', 'Title')) && $this->phpWord instanceof PhpWord) { - $addMethod = "add{$elementName}"; - $rId = $this->phpWord->$addMethod($element); - $element->setRelationId($rId); - } + // Set nested level and relation Id + $this->setElementNestedLevel($element); + $this->setElementRelationId($element, $elementName, $source); // Set other properties and add element into collection $element->setDocPart($this->getDocPart(), $this->getDocPartId()); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); $element->setPhpWord($this->phpWord); + $this->elements[] = $element; return $element; @@ -128,6 +108,54 @@ public function countElements() return count($this->elements); } + /** + * Set element nested level based on container; add one when it's inside a cell + */ + private function setElementNestedLevel(AbstractElement $element) + { + if ($this->container == 'Cell') { + $element->setNestedLevel($this->getNestedLevel() + 1); + } else { + $element->setNestedLevel($this->getNestedLevel()); + } + } + + /** + * Set relation Id + * + * @param string $elementName + * @param string $source + */ + private function setElementRelationId(AbstractElement $element, $elementName, $source) + { + $mediaContainer = $this->getMediaContainer(); + $hasMediaRelation = in_array($elementName, array('Link', 'Image', 'Object')); + $hasOtherRelation = in_array($elementName, array('Footnote', 'Endnote', 'Title')); + + // Set relation Id for media elements (link, image, object; legacy of OOXML) + // Only Image that needs to be passed to Media class + if ($hasMediaRelation) { + /** @var \PhpOffice\PhpWord\Element\Image $element Type hint */ + $image = ($elementName == 'Image') ? $element : null; + $rId = Media::addElement($mediaContainer, strtolower($elementName), $source, $image); + $element->setRelationId($rId); + } + + // Set relation Id for icon of object element + if ($elementName == 'Object') { + /** @var \PhpOffice\PhpWord\Element\Object $element Type hint */ + $rIdIcon = Media::addElement($mediaContainer, 'image', $element->getIcon(), new Image($element->getIcon())); + $element->setImageRelationId($rIdIcon); + } + + // Set relation Id for elements that will be registered in the Collection subnamespaces + if ($hasOtherRelation && $this->phpWord instanceof PhpWord) { + $addMethod = "add{$elementName}"; + $rId = $this->phpWord->$addMethod($element); + $element->setRelationId($rId); + } + } + /** * Add text/preservetext element * diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php index 2097df9c0f..95f700847e 100644 --- a/src/PhpWord/Reader/ODText/AbstractPart.php +++ b/src/PhpWord/Reader/ODText/AbstractPart.php @@ -23,7 +23,7 @@ * Abstract part reader * * @since 0.10.0 - * @codeCoverageIgnore Nothing in here yet + * @codeCoverageIgnore */ abstract class AbstractPart extends Word2007AbstractPart { diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 81e8e286a0..cb00c70b74 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -69,9 +69,12 @@ public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = $this->tempFile = @tempnam($tempFolder, 'xml'); // Fallback to memory when temporary file cannot be used + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if ($this->xmlWriter->openUri($this->tempFile) === false) { $this->xmlWriter->openMemory(); } + // @codeCoverageIgnoreEnd } // Set xml Compatibility diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index a5a37ec066..cbfcb07127 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -152,6 +152,7 @@ public function open($filename, $flags = null) * * @return bool * @throws \PhpOffice\PhpWord\Exception\Exception + * @codeCoverageIgnore Can't find any test case. Uncomment when found. */ public function close() { diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 367b7729a2..346e9b66ba 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -219,9 +219,12 @@ protected function getTempFile($filename) $this->originalFilename = $filename; if (strtolower($filename) == 'php://output' || strtolower($filename) == 'php://stdout') { $filename = @tempnam(sys_get_temp_dir(), 'phpword_'); + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if ($filename == '') { $filename = $this->originalFilename; } + // @codeCoverageIgnoreEnd } $this->tempFilename = $filename; @@ -234,9 +237,12 @@ protected function getTempFile($filename) protected function cleanupTempFile() { if ($this->originalFilename != $this->tempFilename) { + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if (copy($this->tempFilename, $this->originalFilename) === false) { throw new Exception("Could not copy temporary zip file."); } + // @codeCoverageIgnoreEnd @unlink($this->tempFilename); } @@ -269,11 +275,15 @@ protected function getZipArchive($filename) // Try opening the ZIP file $zip = new ZipArchive(); + + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) { if ($zip->open($filename, ZipArchive::CREATE) !== true) { throw new \Exception("Could not open '{$filename}' for writing."); } } + // @codeCoverageIgnoreEnd return $zip; } @@ -290,9 +300,12 @@ protected function openFile($filename) { $filename = $this->getTempFile($filename); $fileHandle = fopen($filename, 'w'); + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if ($fileHandle === false) { throw new \Exception("Could not open '{$filename}' for writing."); } + // @codeCoverageIgnoreEnd return $fileHandle; } diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index cbabc645e5..52e7a6b5a5 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -70,6 +70,7 @@ public function write() $content = ''; $content .= $this->writeOpening(); + $content .= $this->openingText; $content .= $this->openingTags; $content .= htmlspecialchars($element->getText()); $content .= $this->closingTags; @@ -113,7 +114,6 @@ protected function writeOpening() $style = $this->getParagraphStyle(); } $content .= ""; - $content .= $this->openingText; } return $content; diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index aec36bbb2e..18f2828751 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -49,7 +49,7 @@ public function write() $css['font-family'] = $this->getValueIf($font !== null, "'{$font}'"); $css['font-size'] = $this->getValueIf($size !== null, "{$size}pt"); - $css['color'] = $this->getValueIf($color != Settings::DEFAULT_FONT_COLOR, "#{$color}"); + $css['color'] = $this->getValueIf($color !== null, "#{$color}"); $css['background'] = $this->getValueIf($fgColor != '', $fgColor); $css['font-weight'] = $this->getValueIf($style->isBold(), 'bold'); $css['font-style'] = $this->getValueIf($style->isItalic(), 'italic'); diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index 0d240a68ff..c9e729add5 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -89,17 +89,16 @@ public function write() * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $property * @param string $value - * @param string $type string (default/null) * - * @todo Handle other `$type`: double|date|dateTime|duration|boolean + * @todo Handle other `$type`: double|date|dateTime|duration|boolean (4th arguments) */ - private function writeCustomProperty(XMLWriter $xmlWriter, $property, $value, $type = null) + private function writeCustomProperty(XMLWriter $xmlWriter, $property, $value) { $xmlWriter->startElement('meta:user-defined'); $xmlWriter->writeAttribute('meta:name', $property); - if ($type !== null) { - $xmlWriter->writeAttribute('meta:value-type', $type); - } + // if ($type !== null) { + // $xmlWriter->writeAttribute('meta:value-type', $type); + // } $xmlWriter->writeRaw($value); $xmlWriter->endElement(); // meta:user-defined } diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index 83b02251cb..d4288c8a3f 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -87,7 +87,10 @@ public function __construct(PhpWord $phpWord) /** @noinspection PhpIncludeInspection Dynamic includes */ require_once $includeFile; } else { + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. throw new Exception('Unable to load PDF Rendering library'); + // @codeCoverageIgnoreEnd } } @@ -172,9 +175,12 @@ public function setOrientation($value = 'default') protected function prepareForSave($filename = null) { $fileHandle = fopen($filename, 'w'); + // @codeCoverageIgnoreStart + // Can't find any test case. Uncomment when found. if ($fileHandle === false) { throw new Exception("Could not open file $filename for writing."); } + // @codeCoverageIgnoreEnd $this->isPdf = true; return $fileHandle; diff --git a/tests/PhpWord/Tests/Element/FieldTest.php b/tests/PhpWord/Tests/Element/FieldTest.php index 68fd8a8479..2f9193d461 100644 --- a/tests/PhpWord/Tests/Element/FieldTest.php +++ b/tests/PhpWord/Tests/Element/FieldTest.php @@ -43,7 +43,7 @@ public function testConstructNull() public function testConstructWithType() { $oField = new Field('DATE'); - + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); $this->assertEquals($oField->getType(), 'DATE'); } @@ -54,7 +54,7 @@ public function testConstructWithType() public function testConstructWithTypeProperties() { $oField = new Field('DATE', array('dateformat'=>'d-M-yyyy')); - + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); $this->assertEquals($oField->getType(), 'DATE'); $this->assertEquals($oField->getProperties(), array('dateformat'=>'d-M-yyyy')); @@ -66,10 +66,46 @@ public function testConstructWithTypeProperties() public function testConstructWithTypePropertiesOptions() { $oField = new Field('DATE', array('dateformat'=>'d-M-yyyy'), array('SakaEraCalendar', 'PreserveFormat')); - + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Field', $oField); $this->assertEquals($oField->getType(), 'DATE'); $this->assertEquals($oField->getProperties(), array('dateformat'=>'d-M-yyyy')); $this->assertEquals($oField->getOptions(), array('SakaEraCalendar', 'PreserveFormat')); } + + /** + * Test setType exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid type + */ + public function testSetTypeException() + { + $object = new Field(); + $object->setType('foo'); + } + + /** + * Test setProperties exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid property + */ + public function testSetPropertiesException() + { + $object = new Field('PAGE'); + $object->setProperties(array('foo' => 'bar')); + } + + /** + * Test setOptions exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid option + */ + public function testSetOptionsException() + { + $object = new Field('PAGE'); + $object->setOptions(array('foo' => 'bar')); + } } diff --git a/tests/PhpWord/Tests/Shared/XMLReaderTest.php b/tests/PhpWord/Tests/Shared/XMLReaderTest.php index 5c5da6829e..2bb6ef658d 100644 --- a/tests/PhpWord/Tests/Shared/XMLReaderTest.php +++ b/tests/PhpWord/Tests/Shared/XMLReaderTest.php @@ -27,6 +27,19 @@ */ class XMLReaderTest extends \PHPUnit_Framework_TestCase { + /** + * Test get DOMDocument from ZipArchive exception + * + * @expectedException \PhpOffice\PhpWord\Exception\Exception + * @expectedExceptionMessage Cannot find archive file. + */ + public function testGetDomFromZipException() + { + $filename = __DIR__ . "/../_files/documents/foo.zip"; + $object = new XMLReader(); + $object->getDomFromZip($filename, 'yadayadaya'); + } + /** * Test get DOMDocument from ZipArchive returns false */ diff --git a/tests/PhpWord/Tests/Style/NumberingLevelTest.php b/tests/PhpWord/Tests/Style/NumberingLevelTest.php index c0cfa29718..8959a98317 100644 --- a/tests/PhpWord/Tests/Style/NumberingLevelTest.php +++ b/tests/PhpWord/Tests/Style/NumberingLevelTest.php @@ -38,6 +38,7 @@ public function testSetGetNormal() 'start' => 1, 'format' => 'decimal', 'restart' => 1, + 'pStyle' => 'pStyle', 'suffix' => 'space', 'text' => '%1.', 'align' => 'left', diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 32e4698505..12aa51ceb6 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -75,6 +75,8 @@ public function testSetStyleValueNormal() 'spacing' => 120, 'basedOn' => 'Normal', 'next' => 'Normal', + 'numStyle' => 'numStyle', + 'numLevel' => 1, 'widowControl' => false, 'keepNext' => true, 'keepLines' => true, diff --git a/tests/PhpWord/Tests/Writer/HTML/ElementTest.php b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php index e12193e87f..ae136d34d7 100644 --- a/tests/PhpWord/Tests/Writer/HTML/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/HTML/ElementTest.php @@ -16,7 +16,9 @@ */ namespace PhpOffice\PhpWord\Tests\Writer\HTML; +use PhpOffice\PhpWord\Element\Text as TextElement; use PhpOffice\PhpWord\Writer\HTML; +use PhpOffice\PhpWord\Writer\HTML\Element\Text; /** * Test class for PhpOffice\PhpWord\Writer\HTML\Element subnamespace @@ -38,4 +40,17 @@ public function testUnmatchedElements() $this->assertEquals('', $object->write()); } } + + /** + * Test write element text + */ + public function testWriteTextElement() + { + $object = new Text(new HTML(), new TextElement('A')); + $object->setOpeningText('-'); + $object->setClosingText('-'); + $object->setWithoutP(true); + + $this->assertEquals('-A-', $object->write()); + } } diff --git a/tests/PhpWord/Tests/Writer/HTML/PartTest.php b/tests/PhpWord/Tests/Writer/HTML/PartTest.php new file mode 100644 index 0000000000..93e9a98ef8 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/HTML/PartTest.php @@ -0,0 +1,36 @@ +getParentWriter(); + } +} diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index 0a59b3df94..f9b8e6ba91 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -67,7 +67,7 @@ public function testSave() $phpWord->addTitleStyle(1, array('bold' => true)); $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); - $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); + $phpWord->addParagraphStyle('Paragraph', array('align' => 'center', 'spaceAfter' => 20, 'spaceBefore' => 20)); $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); $section->addTextBreak(); diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index f75946ccab..27b2427f9b 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -47,6 +47,9 @@ public function testWriteContent() $phpWord = new PhpWord(); + $docProps = $phpWord->getDocumentProperties(); + $docProps->setCustomProperty('Company', 'PHPWord'); + $phpWord->setDefaultFontName('Verdana'); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); diff --git a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php index e1e0e4a782..e090b34921 100644 --- a/tests/PhpWord/Tests/Writer/RTF/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/RTF/ElementTest.php @@ -28,7 +28,7 @@ class ElementTest extends \PHPUnit_Framework_TestCase */ public function testUnmatchedElements() { - $elements = array('Container', 'Text', 'Title', 'Link', 'Table'); + $elements = array('Container', 'Text', 'Title', 'Link', 'Image', 'Table'); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element; $parentWriter = new RTF(); diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index cc88a91ad9..c144810674 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -68,7 +68,16 @@ public function testSave() $section->addLink('http://test.com'); $section->addTitle('Test', 1); $section->addPageBreak(); - $section->addTable()->addRow()->addCell()->addText('Test'); + + // Rowspan + $table = $section->addTable(); + $table->addRow()->addCell(null, array('vMerge' => 'restart'))->addText('Test'); + $table->addRow()->addCell(null, array('vMerge' => 'continue'))->addText('Test'); + + // Nested table + $cell = $section->addTable()->addRow()->addCell(); + $cell->addTable()->addRow()->addCell(); + $section->addListItem('Test'); $section->addImage($imageSrc); $section->addObject($objectSrc); diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 23ba575bf9..da7504b5c1 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -16,13 +16,23 @@ */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * Test class for PhpOffice\PhpWord\Writer\Word2007\Element subnamespace */ class ElementTest extends \PHPUnit_Framework_TestCase { + /** + * Executed before each method of the class + */ + public function tearDown() + { + TestHelperDOCX::clear(); + } + /** * Test unmatched element */ @@ -43,4 +53,18 @@ public function testUnmatchedElements() $this->assertEquals('', $xmlWriter->getData()); } } + + /** + * Test line element + */ + public function testLineElement() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + $section->addLine(array('width' => 1000, 'height' => 1000, 'positioning' => 'absolute', 'flip' => true)); + $doc = TestHelperDOCX::getDocument($phpWord); + + $element = "/w:document/w:body/w:p/w:r/w:pict/v:shapetype"; + $this->assertTrue($doc->elementExists($element)); + } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index e393355716..7ff4cb7c39 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -43,6 +43,8 @@ public function testWriteEndSectionPageNumbering() { $phpWord = new PhpWord(); $section = $phpWord->addSection(); + $section->addHeader(); + $section->addHeader('first'); $settings = $section->getSettings(); $settings->setLandscape(); $settings->setPageNumberingStart(2); diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index 8303e92b8c..71cbc30068 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -42,4 +42,23 @@ public function testEmptyStyles() $this->assertEquals('', $xmlWriter->getData()); } } + + /** + * Test method exceptions + */ + public function testMethodExceptions() + { + $styles = array( + 'Image' => 'writeAlignment', + 'Line' => 'writeStroke', + ); + foreach ($styles as $style => $method) { + $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style; + $xmlWriter = new XMLWriter(); + $object = new $objectClass($xmlWriter); + $object->$method(); + + $this->assertEquals('', $xmlWriter->getData()); + } + } } From e0d2c6584c55913f5f18d972025883db94f350ee Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 1 Jun 2014 00:12:35 +0700 Subject: [PATCH 166/167] Refactor IOFactory and AbstractContainer to allow more dynamic inclusion. --- src/PhpWord/Element/AbstractContainer.php | 267 +++++------------- src/PhpWord/IOFactory.php | 32 ++- .../Writer/Word2007/Part/DocumentTest.php | 6 +- 3 files changed, 90 insertions(+), 215 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 99927c686a..4bbe5ddff5 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -23,6 +23,23 @@ /** * Container abstract class * + * @method Text addText($text, $fStyle = null, $pStyle = null) + * @method TextRun addTextRun($pStyle = null) + * @method Link addLink($target, $text = null, $fStyle = null, $pStyle = null) + * @method PreserveText addPreserveText($text, $fStyle = null, $pStyle = null) + * @method void addTextBreak($count = 1, $fStyle = null, $pStyle = null) + * @method ListItem addListItem($text, $depth = 0, $fStyle = null, $listStyle = null, $pStyle = null) + * @method ListItemRun addListItemRun($depth = 0, $listStyle = null, $pStyle = null) + * @method Table addTable($style = null) + * @method Image addImage($source, $style = null, $isWatermark = false) + * @method Object addObject($source, $style = null) + * @method Footnote addFootnote($pStyle = null) + * @method Endnote addEndnote($pStyle = null) + * @method CheckBox addCheckBox($name, $text, $fStyle = null, $pStyle = null) + * @method TextBox addTextBox($style = null) + * @method Field addField($type = null, $properties = array(), $options = array()) + * @method Line addLine($lineStyle = null) + * * @since 0.10.0 */ abstract class AbstractContainer extends AbstractElement @@ -41,6 +58,53 @@ abstract class AbstractContainer extends AbstractElement */ protected $container; + /** + * Magic method to catch all 'addElement' variation + * + * This removes addText, addTextRun, etc. When adding new element, we have to + * add the model in the class docblock with `@method`. + * + * Warning: This makes capitalization matters, e.g. addCheckbox or addcheckbox won't work. + * + * @param mixed $function + * @param mixed $args + * @return \PhpOffice\PhpWord\Element\AbstractElement + */ + public function __call($function, $args) + { + $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', + 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', + 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line'); + $functions = array(); + for ($i = 0; $i < count($elements); $i++) { + $functions[$i] = 'add' . $elements[$i]; + } + + // Run valid `add` command + if (in_array($function, $functions)) { + $element = str_replace('add', '', $function); + + // Special case for TextBreak + // @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements? + if ($element == 'TextBreak') { + @list($count, $fontStyle, $paragraphStyle) = $args; // Suppress error + if ($count === null) { + $count = 1; + } + for ($i = 1; $i <= $count; $i++) { + $this->addElement($element, $fontStyle, $paragraphStyle); + } + + // All other elements + } else { + array_unshift($args, $element); // Prepend element name to the beginning of args array + return call_user_func_array(array($this, 'addElement'), $args); + } + } + + return null; + } + /** * Add element * @@ -156,209 +220,6 @@ private function setElementRelationId(AbstractElement $element, $elementName, $s } } - /** - * Add text/preservetext element - * - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Text|\PhpOffice\PhpWord\Element\PreserveText - */ - public function addText($text, $fontStyle = null, $paragraphStyle = null) - { - return $this->addElement('Text', $text, $fontStyle, $paragraphStyle); - } - - /** - * Add textrun element - * - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\TextRun - */ - public function addTextRun($paragraphStyle = null) - { - return $this->addElement('TextRun', $paragraphStyle); - } - - /** - * Add link element - * - * @param string $target - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Link - */ - public function addLink($target, $text = null, $fontStyle = null, $paragraphStyle = null) - { - return $this->addElement('Link', $target, $text, $fontStyle, $paragraphStyle); - } - - /** - * Add preserve text element - * - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\PreserveText - */ - public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) - { - return $this->addElement('PreserveText', $text, $fontStyle, $paragraphStyle); - } - - /** - * Add text break element - * - * @param int $count - * @param mixed $fontStyle - * @param mixed $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->addElement('TextBreak', $fontStyle, $paragraphStyle); - } - } - - /** - * Add listitem element - * - * @param string $text - * @param int $depth - * @param mixed $fontStyle - * @param mixed $listStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\ListItem - */ - public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) - { - return $this->addElement('ListItem', $text, $depth, $fontStyle, $listStyle, $paragraphStyle); - } - - /** - * Add listitemrun element - * - * @param int $depth - * @param mixed $listStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\ListItemRun - */ - public function addListItemRun($depth = 0, $listStyle = null, $paragraphStyle = null) - { - return $this->addElement('ListItemRun', $depth, $listStyle, $paragraphStyle); - } - - /** - * Add table element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\Table - */ - public function addTable($style = null) - { - return $this->addElement('Table', $style); - } - - /** - * Add image element - * - * @param string $source - * @param mixed $style Image style - * @param bool $isWatermark - * @return \PhpOffice\PhpWord\Element\Image - */ - public function addImage($source, $style = null, $isWatermark = false) - { - return $this->addElement('Image', $source, $style, $isWatermark); - } - - /** - * Add OLE-object element - * - * All exceptions should be handled by \PhpOffice\PhpWord\Element\Object - * - * @param string $source - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\Object - */ - public function addObject($source, $style = null) - { - return $this->addElement('Object', $source, $style); - } - - /** - * Add footnote element - * - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Footnote - */ - public function addFootnote($paragraphStyle = null) - { - return $this->addElement('Footnote', $paragraphStyle); - } - - /** - * Add endnote element - * - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Endnote - */ - public function addEndnote($paragraphStyle = null) - { - return $this->addElement('Endnote', $paragraphStyle); - } - - /** - * Add a CheckBox Element - * - * @param string $name - * @param string $text - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\CheckBox - */ - public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = null) - { - return $this->addElement('CheckBox', $name, $text, $fontStyle, $paragraphStyle); - } - - /** - * Add textbox element - * - * @param mixed $style - * @return \PhpOffice\PhpWord\Element\TextBox - */ - public function addTextBox($style = null) - { - return $this->addElement('TextBox', $style); - } - - /** - * Add field element - * - * @param string $type - * @param array $properties - * @param array $options - * @return \PhpOffice\PhpWord\Element\Field - */ - public function addField($type = null, $properties = array(), $options = array()) - { - return $this->addElement('Field', $type, $properties, $options); - } - - /** - * Add line element - * - * @param mixed $lineStyle - * @return \PhpOffice\PhpWord\Element\Line - */ - public function addLine($lineStyle = null) - { - return $this->addElement('Line', $lineStyle); - - } - /** * Check if a method is allowed for the current container * diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 1d78496234..166ea1525c 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -20,7 +20,7 @@ use PhpOffice\PhpWord\Exception\Exception; /** - * IO factory + * IO Factory */ abstract class IOFactory { @@ -34,12 +34,12 @@ abstract class IOFactory */ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') { - if (!in_array($name, array('WriterInterface', 'Word2007', 'ODText', 'RTF', 'HTML', 'PDF'))) { + $class = 'PhpOffice\\PhpWord\\Writer\\' . $name; + if (class_exists($class) && self::isConcreteClass($class)) { + return new $class($phpWord); + } else { throw new Exception("\"{$name}\" is not a valid writer."); } - - $fqName = "PhpOffice\\PhpWord\\Writer\\{$name}"; - return new $fqName($phpWord); } /** @@ -51,12 +51,12 @@ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') */ public static function createReader($name = 'Word2007') { - if (!in_array($name, array('ReaderInterface', 'Word2007', 'ODText', 'RTF', 'HTML'))) { + $class = 'PhpOffice\\PhpWord\\Reader\\' . $name; + if (class_exists($class) && self::isConcreteClass($class)) { + return new $class(); + } else { throw new Exception("\"{$name}\" is not a valid reader."); } - - $fqName = "PhpOffice\\PhpWord\\Reader\\{$name}"; - return new $fqName(); } /** @@ -69,6 +69,20 @@ public static function createReader($name = 'Word2007') public static function load($filename, $readerName = 'Word2007') { $reader = self::createReader($readerName); + return $reader->load($filename); } + + /** + * Check if it's a concrete class (not abstract nor interface) + * + * @param string $class + * @return bool + */ + private static function isConcreteClass($class) + { + $reflection = new \ReflectionClass($class); + + return !$reflection->isAbstract() && !$reflection->isInterface(); + } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 7ff4cb7c39..e27d072a37 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -355,10 +355,10 @@ public function testWriteCheckbox() $pStyle = 'pStyle'; $phpWord = new PhpWord(); - $phpWord->addFontStyle($rStyle, array('bold' => true)); - $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); + // $phpWord->addFontStyle($rStyle, array('bold' => true)); + // $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); $section = $phpWord->addSection(); - $section->addCheckbox('Check1', 'Test', $rStyle, $pStyle); + $section->addCheckBox('Check1', 'Test', $rStyle, $pStyle); $doc = TestHelperDOCX::getDocument($phpWord); $element = '/w:document/w:body/w:p/w:r/w:fldChar/w:ffData/w:name'; From ce21e8d9e8013389f0abb6b9bf78879c058b6319 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 1 Jun 2014 21:00:02 +0700 Subject: [PATCH 167/167] PR 0.11.0 #225 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30d6f0a386..cd4d6f342b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ This is the changelog between releases of PHPWord. Releases are listed in reverse chronological order with the latest version listed on top, while additions/changes in each release are listed in chronological order. Changes in each release are divided into three parts: added or change features, bugfixes, and miscellaneous improvements. Each line contains short information about the change made, the person who made it, and the related issue number(s) in GitHub. -## 0.11.0 - Not yet released +## 0.11.0 - 1 June 2014 -This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemeted. RTF and HTML reader were initiated. +This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four new elements were added: TextBox, ListItemRun, Field, and Line. Relative and absolute positioning for images and textboxes were added. Writer classes were refactored into parts, elements, and styles. ODT and RTF features were enhanced. Ability to add elements to PHPWord object via HTML were implemented. RTF and HTML reader were initiated. ### Features