From 4dd85e28c66fe218f585b8e8af75ab5a6cdea96d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 1 Jun 2014 22:32:20 +0700 Subject: [PATCH 001/174] Version and changelog for 0.12.0 --- CHANGELOG.md | 18 ++++++++++++++++++ VERSION | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd4d6f342b..c6f0e3b88c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ 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.12.0 - Not yet released + +### Features + +None yet. + +### Bugfixes + +None yet. + +### Deprecated + +None yet. + +### Miscellaneous + +None yet. + ## 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 implemented. RTF and HTML reader were initiated. diff --git a/VERSION b/VERSION index 142464bf22..d33c3a2128 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.11.0 \ No newline at end of file +0.12.0 \ No newline at end of file From a66f93ccdc78275928d36a412426eee2c48de865 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 2 Jun 2014 21:21:34 +0700 Subject: [PATCH 002/174] #123: New drawing shapes (arc, curve, line, polyline, rect, oval) --- CHANGELOG.md | 2 +- docs/elements.rst | 9 +- docs/intro.rst | 4 +- docs/src/documentation.md | 10 +- phpmd.xml.dist | 2 +- samples/Sample_31_Shape.php | 82 ++++++ src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/AbstractElement.php | 21 ++ src/PhpWord/Element/Shape.php | 88 ++++++ src/PhpWord/Style/AbstractStyle.php | 2 +- src/PhpWord/Style/Extrusion.php | 106 ++++++++ src/PhpWord/Style/Fill.php | 69 +++++ src/PhpWord/Style/Frame.php | 159 +++++++++++ src/PhpWord/Style/Outline.php | 248 +++++++++++++++++ src/PhpWord/Style/Shadow.php | 97 +++++++ src/PhpWord/Style/Shape.php | 255 ++++++++++++++++++ src/PhpWord/Writer/Word2007/Element/Shape.php | 169 ++++++++++++ .../Writer/Word2007/Style/AbstractStyle.php | 36 +++ .../Writer/Word2007/Style/Extrusion.php | 44 +++ src/PhpWord/Writer/Word2007/Style/Fill.php | 41 +++ src/PhpWord/Writer/Word2007/Style/Frame.php | 56 ++++ src/PhpWord/Writer/Word2007/Style/Image.php | 18 -- src/PhpWord/Writer/Word2007/Style/Outline.php | 48 ++++ .../Writer/Word2007/Style/Paragraph.php | 18 -- src/PhpWord/Writer/Word2007/Style/Shadow.php | 44 +++ src/PhpWord/Writer/Word2007/Style/Shape.php | 45 ++++ .../Tests/Writer/Word2007/ElementTest.php | 83 +++++- .../Tests/Writer/Word2007/StyleTest.php | 2 +- 28 files changed, 1715 insertions(+), 47 deletions(-) create mode 100644 samples/Sample_31_Shape.php create mode 100644 src/PhpWord/Element/Shape.php create mode 100644 src/PhpWord/Style/Extrusion.php create mode 100644 src/PhpWord/Style/Fill.php create mode 100644 src/PhpWord/Style/Frame.php create mode 100644 src/PhpWord/Style/Outline.php create mode 100644 src/PhpWord/Style/Shadow.php create mode 100644 src/PhpWord/Style/Shape.php create mode 100644 src/PhpWord/Writer/Word2007/Element/Shape.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Extrusion.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Fill.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Frame.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Outline.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Shadow.php create mode 100644 src/PhpWord/Writer/Word2007/Style/Shape.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d6df064a06..36c27c26e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Features -None yet. +- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 ### Bugfixes diff --git a/docs/elements.rst b/docs/elements.rst index 7d07674206..a3a8171721 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -47,6 +47,8 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 19 | Line | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 20 | Shapes | v | v | v | v | v | v | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -490,7 +492,12 @@ Fields To be completed -Line +Lines +----- + +To be completed + +Shapes ------ To be completed diff --git a/docs/intro.rst b/docs/intro.rst index aca5b24153..5045d4dc1d 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -99,11 +99,11 @@ Writers +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | Endnote | ✓ | | | ✓ | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| **Graphs** | 2D basic graphs | | | | | | +| **Graphs** | 2D basic graphs | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | | 2D advanced graphs | | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ -| | 3D graphs | | | | | | +| | 3D graphs | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ | **Math** | OMML support | | | | | | +---------------------------+----------------------+--------+-------+-------+--------+-------+ diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 84522c1b5f..e971640144 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -36,6 +36,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Textboxes](#textboxes) - [Fields](#fields) - [Lines](#lines) + - [Shapes](#shapes) - [Templates](#templates) - [Writers & readers](#writers-readers) - [OOXML](#ooxml) @@ -101,9 +102,9 @@ Below are the supported features for each file formats. | | Footer | ✓ | | | | | | | Footnote | ✓ | | | ✓ | | | | Endnote | ✓ | | | ✓ | | -| **Graphs** | 2D basic graphs | | | | | | +| **Graphs** | 2D basic graphs | ✓ | | | | | | | 2D advanced graphs | | | | | | -| | 3D graphs | | | | | | +| | 3D graphs | ✓ | | | | | | **Math** | OMML support | | | | | | | | MathML support | | | | | | | **Bonus** | Encryption | | | | | | @@ -465,6 +466,7 @@ Below are the matrix of element availability in each container. The column shows | 17 | TextBox | v | v | v | v | - | - | | 18 | Field | v | v | v | v | v | v | | 19 | Line | v | v | v | v | v | v | +| 20 | Shape | v | v | v | v | v | v | Legend: @@ -850,6 +852,10 @@ To be completed. To be completed. +## Shapes + +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/phpmd.xml.dist b/phpmd.xml.dist index f0b62b2d6e..5eb348ecfe 100644 --- a/phpmd.xml.dist +++ b/phpmd.xml.dist @@ -18,7 +18,7 @@ - + diff --git a/samples/Sample_31_Shape.php b/samples/Sample_31_Shape.php new file mode 100644 index 0000000000..02399992e7 --- /dev/null +++ b/samples/Sample_31_Shape.php @@ -0,0 +1,82 @@ +addTitleStyle(1, array('size' => 14, 'bold' => true)); + +$section = $phpWord->addSection(); + +// Arc +$section->addTitle('Arc', 1); +$section->addShape( + 'arc', + array( + 'points' => '-90 20', + 'frame' => array('width' => 120, 'height' => 120), + 'outline' => array('color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'), + ) +); + +// Curve +$section->addTitle('Curve', 1); +$section->addShape( + 'curve', + array( + 'points' => '1,100 200,1 1,50 200,50', 'connector' => 'elbow', + 'outline' => array('color' => '#66cc00', 'weight' => 2, 'dash' => 'dash', 'startArrow' => 'diamond', 'endArrow' => 'block'), + ) +); + +// Line +$section->addTitle('Line', 1); +$section->addShape( + 'line', + array( + 'points' => '1,1 150,30', + 'outline' => array('color' => '#cc00ff', 'line' => 'thickThin', 'weight' => 3, 'startArrow' => 'oval', 'endArrow' => 'classic'), + ) +); + +// Polyline +$section->addTitle('Polyline', 1); +$section->addShape( + 'polyline', + array( + 'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50', + 'outline' => array('color' => '#cc6666', 'weight' => 2, 'startArrow' => 'none', 'endArrow' => 'classic'), + ) +); + +// Rectangle +$section->addTitle('Rectangle', 1); +$section->addShape( + 'rect', + array( + 'roundness' => 0.2, + 'frame' => array('width' => 100, 'height' => 100, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#FFCC33'), + 'outline' => array('color' => '#990000', 'weight' => 1), + 'shadow' => array(), + ) +); + +// Oval +$section->addTitle('Oval', 1); +$section->addShape( + 'oval', + array( + 'frame' => array('width' => 100, 'height' => 70, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#33CC99'), + 'outline' => array('color' => '#333333', 'weight' => 2), + 'extrusion' => array(), + ) +); + +// 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 4bbe5ddff5..ae750de995 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -39,6 +39,7 @@ * @method TextBox addTextBox($style = null) * @method Field addField($type = null, $properties = array(), $options = array()) * @method Line addLine($lineStyle = null) + * @method Shape addObject($type, $style = null) * * @since 0.10.0 */ @@ -74,7 +75,7 @@ public function __call($function, $args) { $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', - 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line'); + 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape'); $functions = array(); for ($i = 0; $i < count($elements); $i++) { $functions[$i] = 'add' . $elements[$i]; @@ -242,6 +243,7 @@ private function checkValidity($method) 'Object' => $allContainers, 'Field' => $allContainers, 'Line' => $allContainers, + 'Shape' => $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/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index ca45ef23f9..c8e574b7e5 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -262,4 +262,25 @@ protected function setStyle($styleObject, $styleValue = null, $returnObject = fa return $style; } + + /** + * Set enum value + * + * @param mixed $value + * @param array $enum + * @param mixed $default + * @return mixed + * @throws \InvalidArgumentException + * @todo Merge with the same method in AbstractStyle + */ + 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: {$value}"); + } elseif ($value === null || trim($value) == '') { + $value = $default; + } + + return $value; + } } diff --git a/src/PhpWord/Element/Shape.php b/src/PhpWord/Element/Shape.php new file mode 100644 index 0000000000..9b3aae4ffe --- /dev/null +++ b/src/PhpWord/Element/Shape.php @@ -0,0 +1,88 @@ +setType($type); + $this->style = $this->setStyle(new ShapeStyle(), $style); + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set pattern + * + * @param string $value + * @return self + */ + public function setType($value = null) + { + $enum = array('arc', 'curve', 'line', 'polyline', 'rect', 'oval'); + $this->type = $this->setEnumVal($value, $enum, null); + + return $this; + } + + /** + * Get shape style + * + * @return \PhpOffice\PhpWord\Style\Shape + */ + public function getStyle() + { + return $this->style; + } +} diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 13ef8f9b26..4d3758889d 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -264,7 +264,7 @@ protected function setFloatVal($value, $default = null) 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.'); + throw new \InvalidArgumentException("Invalid style value: {$value}"); } elseif ($value === null || trim($value) == '') { $value = $default; } diff --git a/src/PhpWord/Style/Extrusion.php b/src/PhpWord/Style/Extrusion.php new file mode 100644 index 0000000000..ccbb26505b --- /dev/null +++ b/src/PhpWord/Style/Extrusion.php @@ -0,0 +1,106 @@ +setStyleByArray($style); + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set pattern + * + * @param string $value + * @return self + */ + public function setType($value = null) + { + $enum = array(self::EXTRUSION_PARALLEL, self::EXTRUSION_PERSPECTIVE); + $this->type = $this->setEnumVal($value, $enum, null); + + return $this; + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set color + * + * @param string $value + * @return self + */ + public function setColor($value = null) + { + $this->color = $value; + + return $this; + } +} diff --git a/src/PhpWord/Style/Fill.php b/src/PhpWord/Style/Fill.php new file mode 100644 index 0000000000..08c7a85739 --- /dev/null +++ b/src/PhpWord/Style/Fill.php @@ -0,0 +1,69 @@ +setStyleByArray($style); + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set color + * + * @param string $value + * @return self + */ + public function setColor($value = null) + { + $this->color = $value; + + return $this; + } +} diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php new file mode 100644 index 0000000000..fce3f4a997 --- /dev/null +++ b/src/PhpWord/Style/Frame.php @@ -0,0 +1,159 @@ +setStyleByArray($style); + } + + /** + * 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, null); + + return $this; + } + + /** + * Get height + * + * @return int|float + */ + public function getHeight() + { + return $this->height; + } + + /** + * Set height + * + * @param int|float $value + * @return self + */ + public function setHeight($value = null) + { + $this->height = $this->setNumericVal($value, null); + + return $this; + } + + /** + * Get left + * + * @return int|float + */ + public function getLeft() + { + return $this->left; + } + + /** + * Set left + * + * @param int|float $value + * @return self + */ + public function setLeft($value = 0) + { + $this->left = $this->setNumericVal($value, 0); + + return $this; + } + + /** + * Get topmost position + * + * @return int|float + */ + public function getTop() + { + return $this->top; + } + + /** + * Set topmost position + * + * @param int|float $value + * @return self + */ + public function setTop($value = 0) + { + $this->top = $this->setNumericVal($value, 0); + + return $this; + } +} diff --git a/src/PhpWord/Style/Outline.php b/src/PhpWord/Style/Outline.php new file mode 100644 index 0000000000..7e6b19cf90 --- /dev/null +++ b/src/PhpWord/Style/Outline.php @@ -0,0 +1,248 @@ +setStyleByArray($style); + } + + /** + * Get weight + * + * @return int|float + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Set weight + * + * @param int|float $value + * @return self + */ + public function setWeight($value = null) + { + $this->weight = $this->setNumericVal($value, null); + + return $this; + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set color + * + * @param string $value + * @return self + */ + public function setColor($value = null) + { + $this->color = $value; + + return $this; + } + + /** + * Get dash type + * + * @return string + */ + public function getDash() + { + return $this->dash; + } + + /** + * Set dash type + * + * @param string $value + * @return self + */ + public function setDash($value = null) + { + $this->dash = $value; + + return $this; + } + + /** + * Get line style + * + * @return string + */ + public function getLine() + { + return $this->line; + } + + /** + * Set line style + * + * @param string $value + * @return self + */ + public function setLine($value = null) + { + $enum = array(self::LINE_SINGLE, self::LINE_THIN_THIN, self::LINE_THIN_THICK, + self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN); + $this->line = $this->setEnumVal($value, $enum, null); + + return $this; + } + + /** + * Get startArrow + * + * @return string + */ + public function getStartArrow() + { + return $this->startArrow; + } + + /** + * Set pattern + * + * @param string $value + * @return self + */ + public function setStartArrow($value = null) + { + $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC, + self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN); + $this->startArrow = $this->setEnumVal($value, $enum, null); + + return $this; + } + + /** + * Get endArrow + * + * @return string + */ + public function getEndArrow() + { + return $this->endArrow; + } + + /** + * Set pattern + * + * @param string $value + * @return self + */ + public function setEndArrow($value = null) + { + $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC, + self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN); + $this->endArrow = $this->setEnumVal($value, $enum, null); + + return $this; + } +} diff --git a/src/PhpWord/Style/Shadow.php b/src/PhpWord/Style/Shadow.php new file mode 100644 index 0000000000..deafbff0f8 --- /dev/null +++ b/src/PhpWord/Style/Shadow.php @@ -0,0 +1,97 @@ +setStyleByArray($style); + } + + /** + * Get color + * + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * Set color + * + * @param string $value + * @return self + */ + public function setColor($value = null) + { + $this->color = $value; + + return $this; + } + + /** + * Get offset + * + * @return string + */ + public function getOffset() + { + return $this->offset; + } + + /** + * Set offset + * + * @param string $value + * @return self + */ + public function setOffset($value = null) + { + $this->offset = $value; + + return $this; + } +} diff --git a/src/PhpWord/Style/Shape.php b/src/PhpWord/Style/Shape.php new file mode 100644 index 0000000000..c9809920bb --- /dev/null +++ b/src/PhpWord/Style/Shape.php @@ -0,0 +1,255 @@ +setStyleByArray($style); + } + + /** + * Get points + * + * @return string + */ + public function getPoints() + { + return $this->points; + } + + /** + * Set points + * + * @param string $value + * @return self + */ + public function setPoints($value = null) + { + $this->points = $value; + + return $this; + } + + /** + * Get roundness + * + * @return int|float + */ + public function getRoundness() + { + return $this->roundness; + } + + /** + * Set roundness + * + * @param int|float $value + * @return self + */ + public function setRoundness($value = null) + { + $this->roundness = $this->setNumericVal($value, null); + + return $this; + } + + /** + * Get frame + * + * @return \PhpOffice\PhpWord\Style\Frame + */ + public function getFrame() + { + return $this->frame; + } + + /** + * Set frame + * + * @param mixed $value + * @return self + */ + public function setFrame($value = null) + { + $this->setObjectVal($value, 'Frame', $this->frame); + + return $this; + } + + /** + * Get fill + * + * @return \PhpOffice\PhpWord\Style\Fill + */ + public function getFill() + { + return $this->fill; + } + + /** + * Set fill + * + * @param mixed $value + * @return self + */ + public function setFill($value = null) + { + $this->setObjectVal($value, 'Fill', $this->fill); + + return $this; + } + + /** + * Get outline + * + * @return \PhpOffice\PhpWord\Style\Outline + */ + public function getOutline() + { + return $this->outline; + } + + /** + * Set outline + * + * @param mixed $value + * @return self + */ + public function setOutline($value = null) + { + $this->setObjectVal($value, 'Outline', $this->outline); + + return $this; + } + + /** + * Get shadow + * + * @return \PhpOffice\PhpWord\Style\Shadow + */ + public function getShadow() + { + return $this->shadow; + } + + /** + * Set shadow + * + * @param mixed $value + * @return self + */ + public function setShadow($value = null) + { + $this->setObjectVal($value, 'Shadow', $this->shadow); + + return $this; + } + + /** + * Get 3D extrusion + * + * @return \PhpOffice\PhpWord\Style\Extrusion + */ + public function getExtrusion() + { + return $this->extrusion; + } + + /** + * Set 3D extrusion + * + * @param mixed $value + * @return self + */ + public function setExtrusion($value = null) + { + $this->setObjectVal($value, 'Extrusion', $this->extrusion); + + return $this; + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php new file mode 100644 index 0000000000..f4ac2efb08 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Shape.php @@ -0,0 +1,169 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof ShapeElement) { + return; + } + + $style = $element->getStyle(); + $type = $element->getType(); + if ($type == 'rect' && $style->getRoundness() !== null) { + $type = 'roundrect'; + } + $method = "write{$type}"; + + if (!$this->withoutP) { + $xmlWriter->startElement('w:p'); + } + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:pict'); + $xmlWriter->startElement("v:{$type}"); + + // Element style + if (method_exists($this, $method)) { + $this->$method($xmlWriter, $style); + } + + // Child style + $styleWriter = new ShapeStyleWriter($xmlWriter, $style); + $styleWriter->write(); + + $xmlWriter->endElement(); // v:$type + $xmlWriter->endElement(); // w:pict + $xmlWriter->endElement(); // w:r + + if (!$this->withoutP) { + $xmlWriter->endElement(); // w:p + } + } + + /** + * Write arc + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Shape $style + */ + private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style) + { + $points = $this->getPoints('arc', $style->getPoints()); + + $xmlWriter->writeAttributeIf($points['start'] !== null, 'startAngle', $points['start']); + $xmlWriter->writeAttributeIf($points['end'] !== null, 'endAngle', $points['end']); + } + + /** + * Write curve + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Shape $style + */ + private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style) + { + $points = $this->getPoints('curve', $style->getPoints()); + + $this->writeLine($xmlWriter, $style); + $xmlWriter->writeAttributeIf($points['point1'] !== null, 'control1', $points['point1']); + $xmlWriter->writeAttributeIf($points['point2'] !== null, 'control2', $points['point2']); + } + + /** + * Write line + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Shape $style + */ + private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style) + { + $points = $this->getPoints('line', $style->getPoints()); + + $xmlWriter->writeAttributeIf($points['start'] !== null, 'from', $points['start']); + $xmlWriter->writeAttributeIf($points['end'] !== null, 'to', $points['end']); + } + + /** + * Write polyline + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Shape $style + */ + private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style) + { + $xmlWriter->writeAttributeIf($style->getPoints() !== null, 'points', $style->getPoints()); + } + + /** + * Write rectangle + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Shape $style + */ + private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style) + { + $xmlWriter->writeAttribute('arcsize', $style->getRoundness()); + } + + /** + * Set points + * + * @param string $type + * @param array $value + * @return array + */ + private function getPoints($type, $value) + { + $points = array(); + + switch ($type) { + case 'arc': + case 'line': + $points = explode(' ', $value); + @list($start, $end) = $points; + $points = array('start' => $start, 'end' => $end); + break; + case 'curve': + $points = explode(' ', $value); + @list($start, $end, $point1, $point2) = $points; + $points = array('start' => $start, 'end' => $end, 'point1' => $point1, 'point2' => $point2); + break; + } + + return $points; + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 61c8bae808..d91e37b8d2 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -102,4 +102,40 @@ protected function convertTwip($value, $default = 0) return $value * $factor; } + + /** + * Write child style + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $name + * @param mixed $value + */ + protected function writeChildStyle(XMLWriter $xmlWriter, $name, $value) + { + if ($value !== null) { + $class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\" . $name; + + /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $writer */ + $writer = new $class($xmlWriter, $value); + $writer->write(); + } + } + + /** + * Assemble style array into style string + * + * @param array $styles + * @return string + */ + protected 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/Word2007/Style/Extrusion.php b/src/PhpWord/Writer/Word2007/Style/Extrusion.php new file mode 100644 index 0000000000..aa8ba1eadf --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Extrusion.php @@ -0,0 +1,44 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Extrusion) { + return; + } + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement("o:extrusion"); + $xmlWriter->writeAttribute('on', 't'); + $xmlWriter->writeAttributeIf($style->getType() !== null, 'type', $style->getType()); + $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); + $xmlWriter->endElement(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Fill.php b/src/PhpWord/Writer/Word2007/Style/Fill.php new file mode 100644 index 0000000000..0695f8eff0 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Fill.php @@ -0,0 +1,41 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Fill) { + return; + } + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->writeAttribute('on', 't'); + $xmlWriter->writeAttributeIf($style->getColor() !== null, 'fillcolor', $style->getColor()); + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php new file mode 100644 index 0000000000..dd2337eec8 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -0,0 +1,56 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Frame) { + return; + } + $xmlWriter = $this->getXmlWriter(); + + $styles = array(); + $properties = array( + 'left' => 'margin-left', + 'top' => 'margin-top', + 'width' => 'width', + 'height' => 'height', + ); + + foreach ($properties as $key => $property) { + $method = "get{$key}"; + $value = $style->$method(); + if ($value !== null) { + $styles[$property] = $style->$method() . 'pt'; + } + } + + $xmlWriter->writeAttribute('style', $this->assembleStyle($styles)); + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index 280b569a4a..aebc93c114 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -152,22 +152,4 @@ protected function getElementStyle(ImageStyle $style) return $styles; } - - /** - * Assemble style array into style string - * - * @param array $styles - * @return string - */ - protected 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/Word2007/Style/Outline.php b/src/PhpWord/Writer/Word2007/Style/Outline.php new file mode 100644 index 0000000000..5003d9fca6 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Outline.php @@ -0,0 +1,48 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Outline) { + return; + } + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement("v:stroke"); + $xmlWriter->writeAttribute('on', 't'); + $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); + $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . 'pt'); + $xmlWriter->writeAttributeIf($style->getDash() !== null, 'dashstyle', $style->getDash()); + $xmlWriter->writeAttributeIf($style->getLine() !== null, 'linestyle', $style->getLine()); + $xmlWriter->writeAttributeIf($style->getStartArrow() !== null, 'startarrow', $style->getStartArrow()); + $xmlWriter->writeAttributeIf($style->getEndArrow() !== null, 'endarrow', $style->getEndArrow()); + $xmlWriter->endElement(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index f328770083..0e97a7d7dc 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -110,24 +110,6 @@ private function writeStyle() } } - /** - * Write child style - * - * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $name - * @param mixed $value - */ - private function writeChildStyle(XMLWriter $xmlWriter, $name, $value) - { - if ($value !== null) { - $class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\" . $name; - - /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $writer */ - $writer = new $class($xmlWriter, $value); - $writer->write(); - } - } - /** * Write tabs * diff --git a/src/PhpWord/Writer/Word2007/Style/Shadow.php b/src/PhpWord/Writer/Word2007/Style/Shadow.php new file mode 100644 index 0000000000..dd7c769aca --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Shadow.php @@ -0,0 +1,44 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Shadow) { + return; + } + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startElement("v:shadow"); + $xmlWriter->writeAttribute('on', 't'); + $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); + $xmlWriter->writeAttributeIf($style->getOffset() !== null, 'offset', $style->getOffset()); + $xmlWriter->endElement(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Style/Shape.php b/src/PhpWord/Writer/Word2007/Style/Shape.php new file mode 100644 index 0000000000..7eafb18e1a --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Style/Shape.php @@ -0,0 +1,45 @@ +getStyle(); + if (!$style instanceof \PhpOffice\PhpWord\Style\Shape) { + return; + } + + $xmlWriter = $this->getXmlWriter(); + + $childStyles = array('Frame', 'Fill', 'Outline', 'Shadow', 'Extrusion'); + foreach ($childStyles as $childStyle) { + $method = "get{$childStyle}"; + $this->writeChildStyle($xmlWriter, $childStyle, $style->$method()); + } + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index da7504b5c1..6ba3477be0 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -41,7 +41,7 @@ public function testUnmatchedElements() $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', - 'Field', 'Line' + 'Field', 'Line', 'Shape' ); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; @@ -61,10 +61,91 @@ 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)); } + + /** + * Test shape elements + */ + public function testShapeElements() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + // Arc + $section->addShape( + 'arc', + array( + 'points' => '-90 20', + 'frame' => array('width' => 120, 'height' => 120), + 'outline' => array('color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'), + ) + ); + + // Curve + $section->addShape( + 'curve', + array( + 'points' => '1,100 200,1 1,50 200,50', 'connector' => 'elbow', + 'outline' => array('color' => '#66cc00', 'weight' => 2, 'dash' => 'dash', + 'startArrow' => 'diamond', 'endArrow' => 'block'), + ) + ); + + // Line + $section->addShape( + 'line', + array( + 'points' => '1,1 150,30', + 'outline' => array('color' => '#cc00ff', 'line' => 'thickThin', 'weight' => 3, + 'startArrow' => 'oval', 'endArrow' => 'classic'), + ) + ); + + // Polyline + $section->addShape( + 'polyline', + array( + 'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50', + 'outline' => array('color' => '#cc6666', 'weight' => 2, + 'startArrow' => 'none', 'endArrow' => 'classic'), + ) + ); + + // Rectangle + $section->addShape( + 'rect', + array( + 'roundness' => 0.2, + 'frame' => array('width' => 100, 'height' => 100, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#FFCC33'), + 'outline' => array('color' => '#990000', 'weight' => 1), + 'shadow' => array('color' => '#EEEEEE', 'offset' => '3pt,3pt'), + ) + ); + + // Oval + $section->addShape( + 'oval', + array( + 'frame' => array('width' => 100, 'height' => 70, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#33CC99'), + 'outline' => array('color' => '#333333', 'weight' => 2), + 'extrusion' => array('type' => 'perspective', 'color' => '#EEEEEE'), + ) + ); + + $doc = TestHelperDOCX::getDocument($phpWord); + + $elements = array('arc', 'curve', 'line', 'polyline', 'roundrect', 'oval'); + foreach ($elements as $element) { + $path = "/w:document/w:body/w:p/w:r/w:pict/v:{$element}"; + $this->assertTrue($doc->elementExists($path)); + } + } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index 71cbc30068..c840d2074f 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -31,7 +31,7 @@ public function testEmptyStyles() $styles = array( 'Alignment', 'Cell', 'Font', 'Image', 'Indentation', 'LineNumbering', 'Paragraph', 'Row', 'Section', 'Shading', 'Spacing', 'Tab', 'Table', - 'TextBox', 'Line' + 'TextBox', 'Line', 'Shape', 'Frame', 'Outline', 'Fill', 'Shadow', 'Extrusion', ); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style; From 61d8dbde49ffc6f7b643ec9da2fcd42d35afa1f0 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 2 Jun 2014 22:57:11 +0700 Subject: [PATCH 003/174] QA: Small fixes for #258 based on Scrutinizer https://scrutinizer-ci.com/g/PHPOffice/PHPWord/inspections/54c74458-884d-4299-aed1-a7d2eb6a5654 --- src/PhpWord/Writer/HTML/Style/Font.php | 1 - src/PhpWord/Writer/Word2007/Element/Shape.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 18f2828751..8645a1f402 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\HTML\Style; -use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Style\Font as FontStyle; /** diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php index f4ac2efb08..5590861c8a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Shape.php +++ b/src/PhpWord/Writer/Word2007/Element/Shape.php @@ -143,7 +143,7 @@ private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style) * Set points * * @param string $type - * @param array $value + * @param string $value * @return array */ private function getPoints($type, $value) From e3dd4494f3f0864bc7e21de5b208a70bb38911a4 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 2 Jun 2014 23:33:10 +0700 Subject: [PATCH 004/174] #238: Known issue about read/write permission on temp folder --- CHANGELOG.md | 2 +- README.md | 4 ++++ samples/index.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36c27c26e1..7c9d370a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ None yet. ### Miscellaneous -None yet. +- Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 ## 0.11.1 - 2 June 2014 diff --git a/README.md b/README.md index ecbe135440..fefde4eb75 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,10 @@ $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); $objWriter->save('helloWorld.rtf'); ``` +## Known issues + +- GH-238: PHPWord uses temporary folder with `sys_get_temp_dir()` extensively. The default setting on some systems (especially Windows) do not give appropriate read/write permission to this folder. Run `samples/index.php` either by CLI or by web browsers to check if you have this requirement fulfilled. + ## Contributing We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: diff --git a/samples/index.php b/samples/index.php index 420c542019..8e466d9700 100644 --- a/samples/index.php +++ b/samples/index.php @@ -3,6 +3,7 @@ $requirements = array( 'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), 'xml' => array('PHP extension XML', extension_loaded('xml')), + 'temp' => array('Temp folder "' . sys_get_temp_dir() . '" is writable', is_writable(sys_get_temp_dir())), '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')), @@ -34,6 +35,7 @@ echo 'Requirement check:' . PHP_EOL; foreach ($requirements as $key => $value) { list($label, $result) = $value; + $label = strip_tags($label); $status = $result ? '32m passed' : '31m failed'; echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL; } From 9c8620ecd79887d90b38c0003b966f6aebf17ab8 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 2 Jun 2014 23:47:44 +0700 Subject: [PATCH 005/174] Refactor `IOFactory` to remove duplication --- src/PhpWord/IOFactory.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 166ea1525c..70b525f8bc 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -27,19 +27,13 @@ abstract class IOFactory /** * Create new writer * - * @param PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $name * @return \PhpOffice\PhpWord\Writer\WriterInterface - * @throws \PhpOffice\PhpWord\Exception\Exception */ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') { - $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."); - } + return self::createObject('Writer', $name, $phpWord); } /** @@ -47,15 +41,28 @@ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') * * @param string $name * @return \PhpOffice\PhpWord\Reader\ReaderInterface - * @throws \PhpOffice\PhpWord\Exception\Exception */ public static function createReader($name = 'Word2007') { - $class = 'PhpOffice\\PhpWord\\Reader\\' . $name; + return self::createObject('Reader', $name); + } + + /** + * Create new object + * + * @param string $type + * @param string $name + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + private static function createObject($type, $name, $phpWord = null) + { + $class = "PhpOffice\\PhpWord\\{$type}\\{$name}"; if (class_exists($class) && self::isConcreteClass($class)) { - return new $class(); + return new $class($phpWord); } else { - throw new Exception("\"{$name}\" is not a valid reader."); + throw new Exception("\"{$name}\" is not a valid {$type}."); } } @@ -64,7 +71,7 @@ public static function createReader($name = 'Word2007') * * @param string $filename The name of the file * @param string $readerName - * @return PhpWord + * @return \PhpOffice\PhpWord\PhpWord $phpWord */ public static function load($filename, $readerName = 'Word2007') { From a2294b4b1ed13061eb9f140390216816ab92fb79 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 4 Jun 2014 22:57:59 +0700 Subject: [PATCH 006/174] Font: New `scale`, `spacing`, and `kerning` property of font style --- CHANGELOG.md | 1 + samples/Sample_01_SimpleText.php | 43 +++- src/PhpWord/IOFactory.php | 1 + src/PhpWord/Style/AbstractStyle.php | 36 ++++ src/PhpWord/Style/Font.php | 200 ++++++++++++++---- src/PhpWord/Style/Paragraph.php | 30 +-- src/PhpWord/Writer/Word2007/Style/Font.php | 11 +- tests/PhpWord/Tests/Style/FontTest.php | 6 + .../Writer/Word2007/Part/DocumentTest.php | 3 +- 9 files changed, 244 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c9d370a68..316f92bfec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Features - Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 +- Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin ### Bugfixes diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 311f33508f..8c93f9176f 100644 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -23,22 +23,43 @@ $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->addPageBreak(); +$section->addTextBreak(); // Inline font style $fontStyle['name'] = 'Times New Roman'; $fontStyle['size'] = 20; -$fontStyle['bold'] = true; -$fontStyle['italic'] = true; -$fontStyle['underline'] = 'dash'; -$fontStyle['strikethrough'] = true; -$fontStyle['superScript'] = true; -$fontStyle['color'] = 'FF0000'; -$fontStyle['fgColor'] = 'yellow'; -$fontStyle['smallCaps'] = true; -$section->addText('I am inline styled.', $fontStyle); -$section->addTextBreak(); +$textrun = $section->addTextRun(); +$textrun->addText('I am inline styled ', $fontStyle); +$textrun->addText('with '); +$textrun->addText('color', array('color' => '996699')); +$textrun->addText(', '); +$textrun->addText('bold', array('bold' => true)); +$textrun->addText(', '); +$textrun->addText('italic', array('italic' => true)); +$textrun->addText(', '); +$textrun->addText('underline', array('underline' => 'dash')); +$textrun->addText(', '); +$textrun->addText('strikethrough', array('strikethrough' => true)); +$textrun->addText(', '); +$textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true)); +$textrun->addText(', '); +$textrun->addText('superScript', array('superScript' => true)); +$textrun->addText(', '); +$textrun->addText('subScript', array('subScript' => true)); +$textrun->addText(', '); +$textrun->addText('smallCaps', array('smallCaps' => true)); +$textrun->addText(', '); +$textrun->addText('allCaps', array('allCaps' => true)); +$textrun->addText(', '); +$textrun->addText('fgColor', array('fgColor' => 'yellow')); +$textrun->addText(', '); +$textrun->addText('scale', array('scale' => 200)); +$textrun->addText(', '); +$textrun->addText('spacing', array('spacing' => 120)); +$textrun->addText(', '); +$textrun->addText('kerning', array('kerning' => 10)); +$textrun->addText('. '); // Link $section->addLink('http://www.google.com', 'Google'); diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 70b525f8bc..9b51af06f6 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -75,6 +75,7 @@ private static function createObject($type, $name, $phpWord = null) */ public static function load($filename, $readerName = 'Word2007') { + /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ $reader = self::createReader($readerName); return $reader->load($filename); diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 4d3758889d..cc275fc6a8 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -126,6 +126,24 @@ public function setAuto($value = true) return $this; } + /** + * Return style value of child style object, e.g. `left` from `Indentation` child style of `Paragraph` + * + * @param \PhpOffice\PhpWord\Style\AbstractStyle $substyleObject + * @param string $substyleProperty + * @return mixed + * @since 0.12.0 + */ + public function getChildStyleValue($substyleObject, $substyleProperty) + { + if ($substyleObject !== null) { + $method = "get{$substyleProperty}"; + return $substyleObject->$method(); + } else { + return null; + } + } + /** * Set style value template method * @@ -296,6 +314,24 @@ protected function setObjectVal($value, $styleName, &$style) return $style; } + /** + * Set $property value and set $pairProperty = false when $value = true + * + * @param bool $property + * @param bool $pairProperty + * @param bool $value + * @return self + */ + protected function setPairedVal(&$property, &$pairProperty, $value) + { + $property = $this->setBoolVal($value, $property); + if ($value == true) { + $pairProperty = false; + } + + return $this; + } + /** * Set style using associative array * diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 0775b8b33b..000e2bb688 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -182,10 +182,31 @@ class Font extends AbstractStyle private $fgColor; /** - * Text line height + * Expanded/compressed text: 0-600 (percent) * * @var int + * @since 0.12.0 + * @link http://www.schemacentral.com/sc/ooxml/e-w_w-1.html */ + private $scale; + + /** + * Character spacing adjustment: twip + * + * @var int|float + * @since 0.12.0 + * @link http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html + */ + private $spacing; + + /** + * Font kerning: halfpoint + * + * @var int|float + * @since 0.12.0 + * @link http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html + */ + private $kerning; /** * Paragraph style @@ -213,6 +234,46 @@ public function __construct($type = 'text', $paragraph = null) $this->setParagraph($paragraph); } + /** + * Get style values + * + * @return array + * @since 0.12.0 + */ + public function getStyleValues() + { + $styles = array( + 'name' => $this->getStyleName(), + 'basic' => array( + 'name' => $this->getName(), + 'size' => $this->getSize(), + 'color' => $this->getColor(), + 'hint' => $this->getHint(), + ), + 'style' => array( + 'bold' => $this->isBold(), + 'italic' => $this->isItalic(), + 'underline' => $this->getUnderline(), + 'strike' => $this->isStrikethrough(), + 'dStrike' => $this->isDoubleStrikethrough(), + 'super' => $this->isSuperScript(), + 'sub' => $this->isSubScript(), + 'smallCaps' => $this->isSmallCaps(), + 'allCaps' => $this->isAllCaps(), + 'fgColor' => $this->getFgColor(), + ), + 'spacing' => array( + 'scale' => $this->getScale(), + 'spacing' => $this->getSpacing(), + 'kerning' => $this->getKerning(), + ), + 'paragraph' => $this->getParagraph(), + 'shading' => $this->getShading(), + ); + + return $styles; + } + /** * Get style type * @@ -236,7 +297,7 @@ public function getName() /** * Set font name * - * @param string $value + * @param string $value * @return self */ public function setName($value = null) @@ -259,7 +320,7 @@ public function getHint() /** * Set Font Content Type * - * @param string $value + * @param string $value * @return self */ public function setHint($value = null) @@ -272,7 +333,7 @@ public function setHint($value = null) /** * Get font size * - * @return int|float + * @return int|float */ public function getSize() { @@ -282,7 +343,7 @@ public function getSize() /** * Set font size * - * @param int|float $value + * @param int|float $value * @return self */ public function setSize($value = null) @@ -305,7 +366,7 @@ public function getColor() /** * Set font color * - * @param string $value + * @param string $value * @return self */ public function setColor($value = null) @@ -328,7 +389,7 @@ public function isBold() /** * Set bold * - * @param bool $value + * @param bool $value * @return self */ public function setBold($value = true) @@ -351,7 +412,7 @@ public function isItalic() /** * Set italic * - * @param bool $value + * @param bool $value * @return self */ public function setItalic($value = true) @@ -374,7 +435,7 @@ public function getUnderline() /** * Set underline * - * @param string $value + * @param string $value * @return self */ public function setUnderline($value = self::UNDERLINE_NONE) @@ -397,12 +458,12 @@ public function isSuperScript() /** * Set superscript * - * @param bool $value + * @param bool $value * @return self */ public function setSuperScript($value = true) { - return $this->setPairedProperty($this->superScript, $this->subScript, $value); + return $this->setPairedVal($this->superScript, $this->subScript, $value); } /** @@ -418,12 +479,12 @@ public function isSubScript() /** * Set subscript * - * @param bool $value + * @param bool $value * @return self */ public function setSubScript($value = true) { - return $this->setPairedProperty($this->subScript, $this->superScript, $value); + return $this->setPairedVal($this->subScript, $this->superScript, $value); } /** @@ -439,12 +500,12 @@ public function isStrikethrough() /** * Set strikethrough * - * @param bool $value + * @param bool $value * @return self */ public function setStrikethrough($value = true) { - return $this->setPairedProperty($this->strikethrough, $this->doubleStrikethrough, $value); + return $this->setPairedVal($this->strikethrough, $this->doubleStrikethrough, $value); } /** @@ -460,12 +521,12 @@ public function isDoubleStrikethrough() /** * Set double strikethrough * - * @param bool $value + * @param bool $value * @return self */ public function setDoubleStrikethrough($value = true) { - return $this->setPairedProperty($this->doubleStrikethrough, $this->strikethrough, $value); + return $this->setPairedVal($this->doubleStrikethrough, $this->strikethrough, $value); } /** @@ -481,12 +542,12 @@ public function isSmallCaps() /** * Set small caps * - * @param bool $value + * @param bool $value * @return self */ public function setSmallCaps($value = true) { - return $this->setPairedProperty($this->smallCaps, $this->allCaps, $value); + return $this->setPairedVal($this->smallCaps, $this->allCaps, $value); } /** @@ -502,12 +563,12 @@ public function isAllCaps() /** * Set all caps * - * @param bool $value + * @param bool $value * @return self */ public function setAllCaps($value = true) { - return $this->setPairedProperty($this->allCaps, $this->smallCaps, $value); + return $this->setPairedVal($this->allCaps, $this->smallCaps, $value); } /** @@ -523,7 +584,7 @@ public function getFgColor() /** * Set foreground/highlight color * - * @param string $value + * @param string $value * @return self */ public function setFgColor($value = null) @@ -540,11 +601,7 @@ public function setFgColor($value = null) */ public function getBgColor() { - if ($this->shading !== null) { - return $this->shading->getFill(); - } else { - return null; - } + return $this->getChildStyleValue($this->shading, 'fill'); } /** @@ -558,6 +615,75 @@ public function setBgColor($value = null) $this->setShading(array('fill' => $value)); } + /** + * Get scale + * + * @return int + */ + public function getScale() + { + return $this->scale; + } + + /** + * Set scale + * + * @param int $value + * @return self + */ + public function setScale($value = null) + { + $this->scale = $this->setIntVal($value, null); + + return $this; + } + + /** + * Get font spacing + * + * @return int|float + */ + public function getSpacing() + { + return $this->spacing; + } + + /** + * Set font spacing + * + * @param int|float $value + * @return self + */ + public function setSpacing($value = null) + { + $this->spacing = $this->setNumericVal($value, null); + + return $this; + } + + /** + * Get font kerning + * + * @return int|float + */ + public function getKerning() + { + return $this->kerning; + } + + /** + * Set font kerning + * + * @param int|float $value + * @return self + */ + public function setKerning($value = null) + { + $this->kerning = $this->setNumericVal($value, null); + + return $this; + } + /** * Get line height * @@ -571,7 +697,7 @@ public function getLineHeight() /** * Set lineheight * - * @param int|float|string $value + * @param int|float|string $value * @return self */ public function setLineHeight($value) @@ -627,24 +753,6 @@ public function setShading($value = null) return $this; } - /** - * Set $property value and set $pairProperty = false when $value = true - * - * @param bool $property - * @param bool $pairProperty - * @param bool $value - * @return self - */ - private function setPairedProperty(&$property, &$pairProperty, $value) - { - $property = $this->setBoolVal($value, $property); - if ($value == true) { - $pairProperty = false; - } - - return $this; - } - /** * Get bold * diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 8167358663..a557606704 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -313,11 +313,7 @@ public function setIndentation($value = null) */ public function getIndent() { - if ($this->indentation !== null) { - return $this->indentation->getLeft(); - } else { - return null; - } + return $this->getChildStyleValue($this->indentation, 'left'); } /** @@ -338,11 +334,7 @@ public function setIndent($value = null) */ public function getHanging() { - if ($this->indentation !== null) { - return $this->indentation->getHanging(); - } else { - return null; - } + return $this->getChildStyleValue($this->indentation, 'hanging'); } /** @@ -388,11 +380,7 @@ public function setSpace($value = null) */ public function getSpaceBefore() { - if ($this->spacing !== null) { - return $this->spacing->getBefore(); - } else { - return null; - } + return $this->getChildStyleValue($this->spacing, 'before'); } /** @@ -413,11 +401,7 @@ public function setSpaceBefore($value = null) */ public function getSpaceAfter() { - if ($this->spacing !== null) { - return $this->spacing->getAfter(); - } else { - return null; - } + return $this->getChildStyleValue($this->spacing, 'after'); } /** @@ -438,11 +422,7 @@ public function setSpaceAfter($value = null) */ public function getSpacing() { - if ($this->spacing !== null) { - return $this->spacing->getLine(); - } else { - return null; - } + return $this->getChildStyleValue($this->spacing, 'line'); } /** diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 0ef22f08f9..73673f05ca 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -103,17 +103,20 @@ private function writeStyle() $xmlWriter->writeElementIf($style->isAllCaps(), 'w:caps'); // Underline - $underline = $style->getUnderline(); - $xmlWriter->writeElementIf($underline != 'none', 'w:u', 'w:val', $underline); + $xmlWriter->writeElementIf($style->getUnderline() != 'none', 'w:u', 'w:val', $style->getUnderline()); // Foreground-Color - $fgColor = $style->getFgColor(); - $xmlWriter->writeElementIf(!is_null($fgColor), 'w:highlight', 'w:val', $fgColor); + $xmlWriter->writeElementIf($style->getFgColor() !== null, 'w:highlight', 'w:val', $style->getFgColor()); // Superscript/subscript $xmlWriter->writeElementIf($style->isSuperScript(), 'w:vertAlign', 'w:val', 'superscript'); $xmlWriter->writeElementIf($style->isSubScript(), 'w:vertAlign', 'w:val', 'subscript'); + // Spacing + $xmlWriter->writeElementIf($style->getScale() !== null, 'w:w', 'w:val', $style->getScale()); + $xmlWriter->writeElementIf($style->getSpacing() !== null, 'w:spacing', 'w:val', $style->getSpacing()); + $xmlWriter->writeElementIf($style->getKerning() !== null, 'w:kern', 'w:val', $style->getKerning() * 2); + // Background-Color $shading = $style->getShading(); if (!is_null($shading)) { diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 432b29fb22..9e74af2fbe 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -71,6 +71,9 @@ public function testSetStyleValueWithNullOrEmpty() 'allCaps' => false, 'fgColor' => null, 'bgColor' => null, + 'scale' => null, + 'spacing' => null, + 'kerning' => null, ); foreach ($attributes as $key => $default) { $get = is_bool($default) ? "is{$key}" : "get{$key}"; @@ -106,6 +109,9 @@ public function testSetStyleValueNormal() 'fgColor' => Font::FGCOLOR_YELLOW, 'bgColor' => 'FFFF00', 'lineHeight' => 2, + 'scale' => 150, + 'spacing' => 240, + 'kerning' => 10, ); $object->setStyleByArray($attributes); foreach ($attributes as $key => $value) { diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index e27d072a37..5e0dc747d8 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -136,7 +136,8 @@ public function testElementStyles() $tabs = array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)); $phpWord = new PhpWord(); $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'tabs' => $tabs)); // Style #1 - $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true)); // Style #2 + $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true, + 'scale' => 200, 'spacing' => 240, 'kerning' => 10)); // 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')); From d57606082db85f52a30ac924b1972c58579e1aec Mon Sep 17 00:00:00 2001 From: Andrew Collins Date: Wed, 4 Jun 2014 13:27:18 -0400 Subject: [PATCH 007/174] Fix rare PclZip/realpath/PHP version problem In PHP 5.4.4 realpath() handles absolute paths correctly, but in PHP 5.3.8 returns false. --- src/PhpWord/Shared/ZipArchive.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index cbfcb07127..c5d56b01bb 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -218,7 +218,10 @@ public function pclzipAddFile($filename, $localname = null) { /** @var \PclZip $zip Type hint */ $zip = $this->zip; - $filename = realpath($filename); + $test_filename = realpath($filename); + if($test_filename !== false) { + $filename = $test_filename; + } $filenameParts = pathinfo($filename); $localnameParts = pathinfo($localname); From 2328e34e64d3d045d821f44212d3a4e2da5459c2 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 3 Jun 2014 14:13:35 +0700 Subject: [PATCH 008/174] Refactor Word2007/Element to identify the same properties --- .../Word2007/Element/AbstractElement.php | 10 ++++++++++ .../Writer/Word2007/Element/CheckBox.php | 2 +- src/PhpWord/Writer/Word2007/Element/Field.php | 2 +- .../Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Image.php | 19 ++++++++++++++----- src/PhpWord/Writer/Word2007/Element/Line.php | 15 ++++++++++----- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- .../Writer/Word2007/Element/Object.php | 14 +++++++++++--- .../Writer/Word2007/Element/PreserveText.php | 2 +- src/PhpWord/Writer/Word2007/Element/Shape.php | 7 +++---- src/PhpWord/Writer/Word2007/Element/Text.php | 14 +------------- .../Writer/Word2007/Element/TextBox.php | 7 ++++--- .../Writer/Word2007/Element/TextBreak.php | 4 +++- .../Writer/Word2007/Element/TextRun.php | 2 +- 14 files changed, 62 insertions(+), 40 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 52b4c62e9c..c1e721edcc 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -115,6 +115,16 @@ public function setPageBreakBefore($value = true) $this->pageBreakBefore = (bool)$value; } + /** + * Write ending + */ + protected function endElementP() + { + if (!$this->withoutP) { + $this->xmlWriter->endElement(); // w:p + } + } + /** * Convert text to valid format * diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index ea13b8f943..2d0fe6916d 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -85,6 +85,6 @@ public function write() $xmlWriter->endElement(); // w:t $xmlWriter->endElement(); // w:r - $this->writeClosingWP(); + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php index 68c4c40c2c..1e538e1ad8 100644 --- a/src/PhpWord/Writer/Word2007/Element/Field.php +++ b/src/PhpWord/Writer/Word2007/Element/Field.php @@ -82,6 +82,6 @@ public function write() $xmlWriter->endElement(); // w:r $xmlWriter->endElement(); // w:fldSimple - $this->writeClosingWP(); + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 240a8a00a8..05b96ae5b2 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->writeClosingWP(); + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index a882040eac..963e2da16f 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -52,6 +52,7 @@ 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); @@ -59,23 +60,25 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) $xmlWriter->startElement('w:p'); $styleWriter->writeAlignment(); } + $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('type', '#_x0000_t75'); + $styleWriter->write(); + $styleWriter->writeW10Wrap(); + $xmlWriter->startElement('v:imagedata'); $xmlWriter->writeAttribute('r:id', 'rId' . $rId); $xmlWriter->writeAttribute('o:title', ''); $xmlWriter->endElement(); // v:imagedata - $styleWriter->writeW10Wrap(); + $xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $xmlWriter->endElement(); // w:p - } + $this->endElementP(); // w:p } /** * Write watermark element @@ -83,23 +86,29 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) { $rId = $element->getRelationId(); + $style = $element->getStyle(); - $style->setPositioning('absolute'); $styleWriter = new ImageStyleWriter($xmlWriter, $style); $xmlWriter->startElement('w:p'); + $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('type', '#_x0000_t75'); + + $style->setPositioning('absolute'); $styleWriter->write(); + $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/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php index 1ae1069495..ce576030e6 100644 --- a/src/PhpWord/Writer/Word2007/Element/Line.php +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -37,16 +37,19 @@ public function write() return; } - $style = $element->getStyle(); + $style = $element->getStyle(); $styleWriter = new LineStyleWriter($xmlWriter, $style); $elementId = $element->getElementIndex(); + if (!$this->withoutP) { $xmlWriter->startElement('w:p'); $styleWriter->writeAlignment(); } + $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); + // Shapetype could be defined for each line separately, but then a unique id would be necessary if ($elementId == 1) { $xmlWriter->startElement('v:shapetype'); @@ -67,18 +70,20 @@ public function write() $xmlWriter->endElement(); // o:lock $xmlWriter->endElement(); // v:shapetype } + $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('id', sprintf('_x0000_s1%1$03d', $elementId)); $xmlWriter->writeAttribute('type', '#_x0000_t32'); //type should correspond to shapetype id + $styleWriter->write(); - $styleWriter->writeStroke(); $styleWriter->writeW10Wrap(); + $styleWriter->writeStroke(); + $xmlWriter->endElement(); // v:shape + $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $xmlWriter->endElement(); // w:p - } + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index ec531bacaa..68851ec4a0 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->writeClosingWP(); + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index ae03f04f5b..f172f81b66 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -41,6 +41,7 @@ public function write() $rIdImage = $element->getImageRelationId() + ($element->isInSection() ? 6 : 0); $shapeId = md5($rIdObject . '_' . $rIdImage); $objectId = $element->getRelationId() + 1325353440; + $style = $element->getStyle(); $styleWriter = new ImageStyleWriter($xmlWriter, $style); @@ -48,20 +49,27 @@ public function write() $xmlWriter->startElement('w:p'); $styleWriter->writeAlignment(); } + $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:object'); $xmlWriter->writeAttribute('w:dxaOrig', '249'); $xmlWriter->writeAttribute('w:dyaOrig', '160'); + + // Icon $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 + + // Object $xmlWriter->startElement('o:OLEObject'); $xmlWriter->writeAttribute('Type', 'Embed'); $xmlWriter->writeAttribute('ProgID', 'Package'); @@ -70,10 +78,10 @@ public function write() $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) { - $xmlWriter->endElement(); // w:p - } + + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index dd5d900874..c63d13a79c 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -86,6 +86,6 @@ public function write() } } - $this->writeClosingWP(); + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php index 5590861c8a..649e7384ca 100644 --- a/src/PhpWord/Writer/Word2007/Element/Shape.php +++ b/src/PhpWord/Writer/Word2007/Element/Shape.php @@ -42,6 +42,8 @@ public function write() } $style = $element->getStyle(); + $styleWriter = new ShapeStyleWriter($xmlWriter, $style); + $type = $element->getType(); if ($type == 'rect' && $style->getRoundness() !== null) { $type = 'roundrect'; @@ -62,16 +64,13 @@ public function write() } // Child style - $styleWriter = new ShapeStyleWriter($xmlWriter, $style); $styleWriter->write(); $xmlWriter->endElement(); // v:$type $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $xmlWriter->endElement(); // w:p - } + $this->endElementP(); // w:p } /** diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 64c4b766cb..5d92b3f998 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -51,7 +51,7 @@ public function write() $xmlWriter->endElement(); $xmlWriter->endElement(); // w:r - $this->writeClosingWP(); + $this->endElementP(); // w:p } /** @@ -78,18 +78,6 @@ protected function writeOpeningWP() } } - /** - * Write ending - */ - protected function writeClosingWP() - { - $xmlWriter = $this->getXmlWriter(); - - if (!$this->withoutP) { - $xmlWriter->endElement(); // w:p - } - } - /** * Write ending */ diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 4ee5e68e61..00fac58ec3 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -36,6 +36,7 @@ public function write() if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) { return; } + $style = $element->getStyle(); $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); @@ -48,7 +49,9 @@ public function write() $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('type', '#_x0000_t0202'); + $styleWriter->write(); + $xmlWriter->startElement('v:textbox'); $styleWriter->writeInnerMargin(); @@ -64,8 +67,6 @@ public function write() $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - if (!$this->withoutP) { - $xmlWriter->endElement(); // w:p - } + $this->endElementP(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 5f4bd3ce59..2995e8be74 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -38,12 +38,14 @@ public function write() if (!$this->withoutP) { $hasStyle = $element->hasStyle(); $this->writeOpeningWP(); + if ($hasStyle) { $xmlWriter->startElement('w:pPr'); $this->writeFontStyle(); $xmlWriter->endElement(); // w:pPr } - $this->writeClosingWP(); + + $this->endElementP(); // w:p } else { $xmlWriter->writeElement('w:br'); } diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index 330e297c13..ca3a6b0573 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->writeClosingWP(); + $this->endElementP(); // w:p } } From 1accec2ff0e0b1b97ce2759ede3cce5a4bcc8ea9 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 5 Jun 2014 12:52:39 +0700 Subject: [PATCH 009/174] Refactor styles: Inherit Image and Line from Frame --- src/PhpWord/Style/Frame.php | 316 ++++++++++++++++++ src/PhpWord/Style/Image.php | 298 +++-------------- src/PhpWord/Style/Outline.php | 60 ++++ src/PhpWord/Writer/Word2007/Element/Image.php | 10 +- src/PhpWord/Writer/Word2007/Element/Line.php | 1 - .../Writer/Word2007/Element/TextBox.php | 8 +- src/PhpWord/Writer/Word2007/Style/Frame.php | 115 ++++++- src/PhpWord/Writer/Word2007/Style/Image.php | 130 +------ src/PhpWord/Writer/Word2007/Style/Line.php | 72 +--- src/PhpWord/Writer/Word2007/Style/Outline.php | 3 +- src/PhpWord/Writer/Word2007/Style/TextBox.php | 86 +---- tests/PhpWord/Tests/Style/FontTest.php | 1 + .../Tests/Writer/Word2007/ElementTest.php | 2 +- .../Tests/Writer/Word2007/StyleTest.php | 5 +- 14 files changed, 579 insertions(+), 528 deletions(-) diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index fce3f4a997..21b2771602 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -27,6 +27,80 @@ */ class Frame extends AbstractStyle { + /** + * Length unit + * + * @const string + */ + const UNIT_PT = 'pt'; // Mostly for shapes + const UNIT_PX = 'px'; // Mostly for images + + /** + * Position type, relative/absolute + * + * @const string + */ + const POS_ABSOLUTE = 'absolute'; + const POS_RELATIVE = 'relative'; + + /** + * Horizontal/vertical value + * + * @const string + */ + const POS_CENTER = 'center'; + const POS_LEFT = 'left'; + const POS_RIGHT = 'right'; + const POS_TOP = 'top'; + const POS_BOTTOM = 'bottom'; + const POS_INSIDE = 'inside'; + const POS_OUTSIDE = 'outside'; + + /** + * Position relative to + * + * @const string + */ + const POS_RELTO_MARGIN = 'margin'; + const POS_RELTO_PAGE = 'page'; + const POS_RELTO_COLUMN = 'column'; // horizontal only + const POS_RELTO_CHAR = 'char'; // horizontal only + const POS_RELTO_TEXT = 'text'; // vertical only + const POS_RELTO_LINE = 'line'; // vertical only + const POS_RELTO_LMARGIN = 'left-margin-area'; // horizontal only + const POS_RELTO_RMARGIN = 'right-margin-area'; // horizontal only + const POS_RELTO_TMARGIN = 'top-margin-area'; // vertical only + const POS_RELTO_BMARGIN = 'bottom-margin-area'; // vertical only + const POS_RELTO_IMARGIN = 'inner-margin-area'; + const POS_RELTO_OMARGIN = 'outer-margin-area'; + + /** + * Wrap type + * + * @const string + */ + const WRAP_INLINE = 'inline'; + const WRAP_SQUARE = 'square'; + const WRAP_TIGHT = 'tight'; + const WRAP_THROUGH = 'through'; + const WRAP_TOPBOTTOM = 'topAndBottom'; + const WRAP_BEHIND = 'behind'; + const WRAP_INFRONT = 'infront'; + + /** + * Alignment + * + * @var \PhpOffice\PhpWord\Style\Alignment + */ + private $alignment; + + /** + * Unit + * + * @var string + */ + private $unit = 'pt'; + /** * Width * @@ -55,6 +129,48 @@ class Frame extends AbstractStyle */ private $top = 0; + /** + * Position type: absolute|relative + * + * @var string + */ + private $pos; + + /** + * Horizontal position + * + * @var string + */ + private $hPos; + + /** + * Horizontal position relative to + * + * @var string + */ + private $hPosRelTo; + + /** + * Vertical position + * + * @var string + */ + private $vPos; + + /** + * Vertical position relative to + * + * @var string + */ + private $vPosRelTo; + + /** + * Wrap type + * + * @var string + */ + private $wrap; + /** * Create a new instance * @@ -62,9 +178,56 @@ class Frame extends AbstractStyle */ public function __construct($style = array()) { + $this->alignment = new Alignment(); $this->setStyleByArray($style); } + /** + * Get alignment + * + * @return string + */ + public function getAlign() + { + return $this->alignment->getValue(); + } + + /** + * Set alignment + * + * @param string $value + * @return self + */ + public function setAlign($value = null) + { + $this->alignment->setValue($value); + + return $this; + } + + /** + * Get unit + * + * @return string + */ + public function getUnit() + { + return $this->unit; + } + + /** + * Set unit + * + * @param string $value + * @return self + */ + public function setUnit($value) + { + $this->unit = $value; + + return $this; + } + /** * Get width * @@ -156,4 +319,157 @@ public function setTop($value = 0) return $this; } + + /** + * Get position type + * + * @return string + */ + public function getPos() + { + return $this->pos; + } + + /** + * Set position type + * + * @param string $value + * @return self + */ + public function setPos($value) + { + $enum = array(self::POS_RELATIVE, self::POS_ABSOLUTE); + $this->pos = $this->setEnumVal($value, $enum, $this->pos); + + return $this; + } + + /** + * Get horizontal position + * + * @return string + */ + public function getHPos() + { + return $this->hPos; + } + + /** + * Set horizontal position + * + * @param string $value + * @return self + */ + public function setHPos($value) + { + $enum = array(self::POS_LEFT, self::POS_CENTER, self::POS_RIGHT, self::POS_INSIDE, self::POS_OUTSIDE); + $this->hPos = $this->setEnumVal($value, $enum, $this->hPos); + + return $this; + } + + /** + * Get vertical position + * + * @return string + */ + public function getVPos() + { + return $this->vPos; + } + + /** + * Set vertical position + * + * @param string $value + * @return self + */ + public function setVPos($value) + { + $enum = array(self::POS_TOP, self::POS_CENTER, self::POS_BOTTOM, self::POS_INSIDE, self::POS_OUTSIDE); + $this->vPos = $this->setEnumVal($value, $enum, $this->vPos); + + return $this; + } + + /** + * Get horizontal position relative to + * + * @return string + */ + public function getHPosRelTo() + { + return $this->hPosRelTo; + } + + /** + * Set horizontal position relative to + * + * @param string $value + * @return self + */ + public function setHPosRelTo($value) + { + $enum = array( + self::POS_RELTO_MARGIN, self::POS_RELTO_PAGE, self::POS_RELTO_COLUMN, self::POS_RELTO_CHAR, + self::POS_RELTO_LMARGIN, self::POS_RELTO_RMARGIN, self::POS_RELTO_IMARGIN, self::POS_RELTO_OMARGIN, + ); + $this->hPosRelTo = $this->setEnumVal($value, $enum, $this->hPosRelTo); + + return $this; + } + + /** + * Get vertical position relative to + * + * @return string + */ + public function getVPosRelTo() + { + return $this->vPosRelTo; + } + + /** + * Set vertical position relative to + * + * @param string $value + * @return self + */ + public function setVPosRelTo($value) + { + $enum = array( + self::POS_RELTO_MARGIN, self::POS_RELTO_PAGE, self::POS_RELTO_TEXT, self::POS_RELTO_LINE, + self::POS_RELTO_TMARGIN, self::POS_RELTO_BMARGIN, self::POS_RELTO_IMARGIN, self::POS_RELTO_OMARGIN, + ); + $this->vPosRelTo = $this->setEnumVal($value, $enum, $this->vPosRelTo); + + return $this; + } + + /** + * Get wrap type + * + * @return string + */ + public function getWrap() + { + return $this->wrap; + } + + /** + * Set wrap type + * + * @param string $value + * @return self + */ + public function setWrap($value) + { + $enum = array( + self::WRAP_INLINE, self::WRAP_SQUARE, self::WRAP_TIGHT, self::WRAP_THROUGH, + self::WRAP_TOPBOTTOM, self::WRAP_BEHIND, self::WRAP_INFRONT + ); + $this->wrap = $this->setEnumVal($value, $enum, $this->wrap); + + return $this; + } } diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 3798c1a22f..babfa6798e 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -19,217 +19,56 @@ /** * Image and memory image style */ -class Image extends AbstractStyle +class Image extends Frame { /** - * Wrapping styles + * Backward compatibility constants * * @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'; // horizontal only - const POSITION_RELATIVE_TO_CHAR = 'char'; // horizontal only - const POSITION_RELATIVE_TO_TEXT = 'text'; // vertical 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 - * - * @var int - */ - private $width; - - /** - * Image width - * - * @var int - */ - private $height; - - /** - * Alignment - * - * @var \PhpOffice\PhpWord\Style\Alignment - */ - private $alignment; - - /** - * Margin Top - * - * @var int|float - */ - private $marginTop = 0; - - /** - * Margin Left - * - * @var int|float - */ - private $marginLeft = 0; - - /** - * Wrapping style - * - * @var string - */ - private $wrappingStyle = self::WRAPPING_STYLE_INLINE; - - /** - * Positioning type (relative or absolute) - * - * @var string - */ - private $positioning; - - /** - * Horizontal alignment - * - * @var string - */ - private $posHorizontal = self::POSITION_HORIZONTAL_LEFT; - - /** - * Horizontal Relation - * - * @var string - */ - private $posHorizontalRel = self::POSITION_RELATIVE_TO_CHAR; - - /** - * Vertical alignment - * - * @var string - */ - private $posVertical = self::POSITION_VERTICAL_TOP; - - /** - * Vertical Relation - * - * @var string - */ - private $posVerticalRel = self::POSITION_RELATIVE_TO_LINE; + const WRAPPING_STYLE_INLINE = self::WRAP_INLINE; + const WRAPPING_STYLE_SQUARE = self::WRAP_SQUARE; + const WRAPPING_STYLE_TIGHT = self::WRAP_TIGHT; + const WRAPPING_STYLE_BEHIND = self::WRAP_BEHIND; + const WRAPPING_STYLE_INFRONT = self::WRAP_INFRONT; + const POSITION_HORIZONTAL_LEFT = self::POS_LEFT; + const POSITION_HORIZONTAL_CENTER = self::POS_CENTER; + const POSITION_HORIZONTAL_RIGHT = self::POS_RIGHT; + const POSITION_VERTICAL_TOP = self::POS_TOP; + const POSITION_VERTICAL_CENTER = self::POS_CENTER; + const POSITION_VERTICAL_BOTTOM = self::POS_BOTTOM; + const POSITION_VERTICAL_INSIDE = self::POS_INSIDE; + const POSITION_VERTICAL_OUTSIDE = self::POS_OUTSIDE; + const POSITION_RELATIVE_TO_MARGIN = self::POS_RELTO_MARGIN; + const POSITION_RELATIVE_TO_PAGE = self::POS_RELTO_PAGE; + const POSITION_RELATIVE_TO_COLUMN = self::POS_RELTO_COLUMN; + const POSITION_RELATIVE_TO_CHAR = self::POS_RELTO_CHAR; + const POSITION_RELATIVE_TO_TEXT = self::POS_RELTO_TEXT; + const POSITION_RELATIVE_TO_LINE = self::POS_RELTO_LINE; + const POSITION_RELATIVE_TO_LMARGIN = self::POS_RELTO_LMARGIN; + const POSITION_RELATIVE_TO_RMARGIN = self::POS_RELTO_RMARGIN; + const POSITION_RELATIVE_TO_TMARGIN = self::POS_RELTO_TMARGIN; + const POSITION_RELATIVE_TO_BMARGIN = self::POS_RELTO_BMARGIN; + const POSITION_RELATIVE_TO_IMARGIN = self::POS_RELTO_IMARGIN; + const POSITION_RELATIVE_TO_OMARGIN = self::POS_RELTO_OMARGIN; + const POSITION_ABSOLUTE = self::POS_ABSOLUTE; + const POSITION_RELATIVE = self::POS_RELATIVE; /** * Create new instance */ public function __construct() { - $this->alignment = new Alignment(); - } - - /** - * Get width - * - * @return int - */ - public function getWidth() - { - return $this->width; - } - - /** - * Set width - * - * @param int $value - * @return self - */ - public function setWidth($value = null) - { - $this->width = $value; - - return $this; - } - - /** - * Get height - * - * @return int - */ - public function getHeight() - { - return $this->height; - } - - /** - * 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->alignment->getValue(); - } - - /** - * Set alignment - * - * @param string $value - * @return self - */ - public function setAlign($value = null) - { - $this->alignment->setValue($value); - - return $this; + parent::__construct(); + $this->setUnit('px'); + + // Backward compatilibity setting + // @todo Remove on 1.0.0 + $this->setWrap(self::WRAPPING_STYLE_INLINE); + $this->setHPos(self::POSITION_HORIZONTAL_LEFT); + $this->setHPosRelTo(self::POSITION_RELATIVE_TO_CHAR); + $this->setVPos(self::POSITION_VERTICAL_TOP); + $this->setVPosRelTo(self::POSITION_RELATIVE_TO_LINE); } /** @@ -239,7 +78,7 @@ public function setAlign($value = null) */ public function getMarginTop() { - return $this->marginTop; + return $this->getTop(); } /** @@ -251,7 +90,7 @@ public function getMarginTop() */ public function setMarginTop($value = 0) { - $this->marginTop = $this->setNumericVal($value, 0); + $this->setTop($value); return $this; } @@ -263,7 +102,7 @@ public function setMarginTop($value = 0) */ public function getMarginLeft() { - return $this->marginLeft; + return $this->getLeft(); } /** @@ -275,7 +114,7 @@ public function getMarginLeft() */ public function setMarginLeft($value = 0) { - $this->marginLeft = $this->setNumericVal($value, 0); + $this->setLeft($value); return $this; } @@ -287,7 +126,7 @@ public function setMarginLeft($value = 0) */ public function getWrappingStyle() { - return $this->wrappingStyle; + return $this->getWrap(); } /** @@ -299,12 +138,7 @@ 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, - ); - $this->wrappingStyle = $this->setEnumVal($wrappingStyle, $enum, $this->wrappingStyle); + $this->setWrap($wrappingStyle); return $this; } @@ -316,7 +150,7 @@ public function setWrappingStyle($wrappingStyle) */ public function getPositioning() { - return $this->positioning; + return $this->getPos(); } /** @@ -328,8 +162,7 @@ public function getPositioning() */ public function setPositioning($positioning) { - $enum = array(self::POSITION_RELATIVE, self::POSITION_ABSOLUTE); - $this->positioning = $this->setEnumVal($positioning, $enum, $this->positioning); + $this->setPos($positioning); return $this; } @@ -341,7 +174,7 @@ public function setPositioning($positioning) */ public function getPosHorizontal() { - return $this->posHorizontal; + return $this->getHPos(); } /** @@ -353,11 +186,7 @@ public function getPosHorizontal() */ public function setPosHorizontal($alignment) { - $enum = array( - self::POSITION_HORIZONTAL_LEFT, self::POSITION_HORIZONTAL_CENTER, - self::POSITION_HORIZONTAL_RIGHT, self::POSITION_ABSOLUTE - ); - $this->posHorizontal = $this->setEnumVal($alignment, $enum, $this->posHorizontal); + $this->setHPos($alignment); return $this; } @@ -369,7 +198,7 @@ public function setPosHorizontal($alignment) */ public function getPosVertical() { - return $this->posVertical; + return $this->getVPos(); } /** @@ -381,12 +210,7 @@ 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, self::POSITION_ABSOLUTE - ); - $this->posVertical = $this->setEnumVal($alignment, $enum, $this->posVertical); + $this->setVPos($alignment); return $this; } @@ -398,7 +222,7 @@ public function setPosVertical($alignment) */ public function getPosHorizontalRel() { - return $this->posHorizontalRel; + return $this->getHPosRelTo(); } /** @@ -410,13 +234,7 @@ public function getPosHorizontalRel() */ 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, - ); - $this->posHorizontalRel = $this->setEnumVal($relto, $enum, $this->posHorizontalRel); + $this->setHPosRelTo($relto); return $this; } @@ -428,7 +246,7 @@ public function setPosHorizontalRel($relto) */ public function getPosVerticalRel() { - return $this->posVerticalRel; + return $this->getVPosRelTo(); } /** @@ -440,13 +258,7 @@ public function getPosVerticalRel() */ public function setPosVerticalRel($relto) { - $enum = array( - self::POSITION_RELATIVE_TO_MARGIN, self::POSITION_RELATIVE_TO_PAGE, - self::POSITION_RELATIVE_TO_TEXT, 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, - ); - $this->posVerticalRel = $this->setEnumVal($relto, $enum, $this->posVerticalRel); + $this->setVPosRelTo($relto); return $this; } diff --git a/src/PhpWord/Style/Outline.php b/src/PhpWord/Style/Outline.php index 7e6b19cf90..bfd14a1457 100644 --- a/src/PhpWord/Style/Outline.php +++ b/src/PhpWord/Style/Outline.php @@ -21,6 +21,7 @@ * Outline defines the line/border of the object * * @link http://www.schemacentral.com/sc/ooxml/t-v_CT_Stroke.html + * @link http://www.w3.org/TR/1998/NOTE-VML-19980513#_Toc416858395 * @since 0.12.0 */ class Outline extends AbstractStyle @@ -37,6 +38,16 @@ class Outline extends AbstractStyle const LINE_THICK_THIN = 'thickThin'; const LINE_THICK_BETWEEN_THIN = 'thickBetweenThin'; + /** + * Line style constants + * + * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html + * @const string + */ + const ENDCAP_FLAT = 'flat'; + const ENDCAP_SQUARE = 'square'; + const ENDCAP_ROUND = 'round'; + /** * Arrowhead type constants * @@ -50,6 +61,13 @@ class Outline extends AbstractStyle const ARROW_DIAMOND = 'diamond'; const ARROW_OPEN = 'open'; + /** + * Unit; No set method for now + * + * @var string + */ + private $unit = 'pt'; + /** * Outline weight * @@ -78,6 +96,14 @@ class Outline extends AbstractStyle */ private $line; + /** + * End cap + * + * @var string + * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html + */ + private $endCap; + /** * Start arrow type * @@ -102,6 +128,16 @@ public function __construct($style = array()) $this->setStyleByArray($style); } + /** + * Get unit + * + * @return string + */ + public function getUnit() + { + return $this->unit; + } + /** * Get weight * @@ -196,6 +232,30 @@ public function setLine($value = null) return $this; } + /** + * Get endCap style + * + * @return string + */ + public function getEndCap() + { + return $this->endCap; + } + + /** + * Set endCap style + * + * @param string $value + * @return self + */ + public function setEndCap($value = null) + { + $enum = array(self::ENDCAP_FLAT, self::ENDCAP_SQUARE, self::ENDCAP_ROUND); + $this->endCap = $this->setEnumVal($value, $enum, null); + + return $this; + } + /** * Get startArrow * diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 963e2da16f..02780ed1c1 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -52,7 +52,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); @@ -67,7 +66,6 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) $xmlWriter->writeAttribute('type', '#_x0000_t75'); $styleWriter->write(); - $styleWriter->writeW10Wrap(); $xmlWriter->startElement('v:imagedata'); $xmlWriter->writeAttribute('r:id', 'rId' . $rId); @@ -78,7 +76,7 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - $this->endElementP(); // w:p + $this->endElementP(); } /** * Write watermark element @@ -86,29 +84,25 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) { $rId = $element->getRelationId(); - $style = $element->getStyle(); + $style->setPositioning('absolute'); $styleWriter = new ImageStyleWriter($xmlWriter, $style); $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:pict'); $xmlWriter->startElement('v:shape'); $xmlWriter->writeAttribute('type', '#_x0000_t75'); - $style->setPositioning('absolute'); $styleWriter->write(); $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/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php index ce576030e6..ade5b8892a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Line.php +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -76,7 +76,6 @@ public function write() $xmlWriter->writeAttribute('type', '#_x0000_t32'); //type should correspond to shapetype id $styleWriter->write(); - $styleWriter->writeW10Wrap(); $styleWriter->writeStroke(); $xmlWriter->endElement(); // v:shape diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 00fac58ec3..71935d6e74 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -24,7 +24,7 @@ * * @since 0.11.0 */ -class TextBox extends AbstractElement +class TextBox extends Image { /** * Write element @@ -36,7 +36,6 @@ public function write() if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) { return; } - $style = $element->getStyle(); $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); @@ -51,6 +50,7 @@ public function write() $xmlWriter->writeAttribute('type', '#_x0000_t0202'); $styleWriter->write(); + $styleWriter->writeBorder(); $xmlWriter->startElement('v:textbox'); $styleWriter->writeInnerMargin(); @@ -62,11 +62,11 @@ public function write() $xmlWriter->endElement(); // w:txbxContent $xmlWriter->endElement(); // v: textbox - $styleWriter->writeW10Wrap(); + $xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:r - $this->endElementP(); // w:p + $this->endElementP(); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php index dd2337eec8..507c0c029d 100644 --- a/src/PhpWord/Writer/Word2007/Style/Frame.php +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -17,6 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; +use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; +use PhpOffice\PhpWord\Style\Frame as FrameStyle; + /** * Frame style writer * @@ -30,27 +34,122 @@ class Frame extends AbstractStyle public function write() { $style = $this->getStyle(); - if (!$style instanceof \PhpOffice\PhpWord\Style\Frame) { + if (!$style instanceof FrameStyle) { return; } $xmlWriter = $this->getXmlWriter(); - $styles = array(); + $zIndices = array(FrameStyle::WRAP_INFRONT => PHP_INT_MAX, FrameStyle::WRAP_BEHIND => -PHP_INT_MAX); + + $properties = array( + 'width' => 'width', + 'height' => 'height', + 'left' => 'margin-left', + 'top' => 'margin-top', + ); + $sizeStyles = $this->getStyles($style, $properties, $style->getUnit()); + $properties = array( - 'left' => 'margin-left', - 'top' => 'margin-top', - 'width' => 'width', - 'height' => 'height', + 'pos' => 'position', + 'hPos' => 'mso-position-horizontal', + 'vPos' => 'mso-position-vertical', + 'hPosRelTo' => 'mso-position-horizontal-relative', + 'vPosRelTo' => 'mso-position-vertical-relative', ); + $posStyles = $this->getStyles($style, $properties); + + $styles = array_merge($sizeStyles, $posStyles); + + // zIndex for infront & behind wrap + $wrap = $style->getWrap(); + if ($wrap !== null && array_key_exists($wrap, $zIndices)) { + $styles['z-index'] = $zIndices[$wrap]; + $wrap = null; + } + + // Style attribute + $xmlWriter->writeAttribute('style', $this->assembleStyle($styles)); + + $this->writeWrap($xmlWriter, $style, $wrap); + } + + /** + * Write alignment + */ + public function writeAlignment() + { + $style = $this->getStyle(); + if (!$style instanceof FrameStyle) { + 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 alignment + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Frame $style + * @param string $wrap + */ + private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap) + { + if ($wrap !== null) { + $xmlWriter->startElement('w10:wrap'); + $xmlWriter->writeAttribute('type', $wrap); + + $relativePositions = array( + FrameStyle::POS_RELTO_MARGIN => 'margin', + FrameStyle::POS_RELTO_PAGE => 'page', + FrameStyle::POS_RELTO_TMARGIN => 'margin', + FrameStyle::POS_RELTO_BMARGIN => 'page', + FrameStyle::POS_RELTO_LMARGIN => 'margin', + FrameStyle::POS_RELTO_RMARGIN => 'page', + ); + $pos = $style->getPos(); + $hPos = $style->getHPosRelTo(); + $vPos = $style->getVPosRelTo(); + + if ($pos == FrameStyle::POS_ABSOLUTE) { + $xmlWriter->writeAttribute('anchorx', "page"); + $xmlWriter->writeAttribute('anchory', "page"); + } elseif ($pos == FrameStyle::POS_RELATIVE) { + if (array_key_exists($hPos, $relativePositions)) { + $xmlWriter->writeAttribute('anchorx', $relativePositions[$hPos]); + } + if (array_key_exists($vPos, $relativePositions)) { + $xmlWriter->writeAttribute('anchory', $relativePositions[$vPos]); + } + } + + $xmlWriter->endElement(); // w10:wrap + } + } + + /** + * Get style values in associative array + * + * @param array $properties + * @param string $suffix + * @return array + */ + private function getStyles(FrameStyle $style, $properties, $suffix = '') + { + $styles = array(); foreach ($properties as $key => $property) { $method = "get{$key}"; $value = $style->$method(); if ($value !== null) { - $styles[$property] = $style->$method() . 'pt'; + $styles[$property] = $style->$method() . $suffix; } } - $xmlWriter->writeAttribute('style', $this->assembleStyle($styles)); + return $styles; } } diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php index aebc93c114..cabf37ce3b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Image.php +++ b/src/PhpWord/Writer/Word2007/Style/Image.php @@ -17,139 +17,11 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; -use PhpOffice\PhpWord\Style\Image as ImageStyle; - /** * Image style writer * * @since 0.10.0 */ -class Image extends AbstractStyle +class Image extends Frame { - /** - * w10 namespace wrapping type - * - * @var string - */ - protected $w10wrap; - - /** - * Write style - */ - public function write() - { - $style = $this->getStyle(); - if (!$style instanceof ImageStyle) { - return; - } - $this->writeStyle($style); - } - - /** - * Write style attribute - * - * @param \PhpOffice\PhpWord\Style\Image $style - */ - protected function writeStyle($style) - { - $xmlWriter = $this->getXmlWriter(); - - $styles = $this->getElementStyle($style); - $imageStyle = $this->assembleStyle($styles); - - $xmlWriter->writeAttribute('style', $imageStyle); - } - - /** - * Write alignment - */ - public function writeAlignment() - { - $style = $this->getStyle(); - if (!$style instanceof ImageStyle) { - 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 - * - * @param \PhpOffice\PhpWord\Style\Image $style - * @return array - */ - protected function getElementStyle(ImageStyle $style) - { - $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 ($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 dfecb4b0e8..8a56cb7bbe 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -23,50 +23,12 @@ * Line style writer * */ -class Line extends Image +class Line extends Frame { - /** - * Write style - */ - public function write() - { - $style = $this->getStyle(); - if (!$style instanceof LineStyle) { - return; - } - $this->writeStyle($style); - } - - /** - * Write style attribute - * - * @param \PhpOffice\PhpWord\Style\Line $style - */ - protected function writeStyle($style) - { - $xmlWriter = $this->getXmlWriter(); - - $styles = $this->getElementStyle($style); - if ($style->isFlip()) { - $styles['flip'] = 'y'; - } - $imageStyle = $this->assembleStyle($styles); - $xmlWriter->writeAttribute('style', $imageStyle); - - // Connector type - $xmlWriter->writeAttribute('o:connectortype', $style->getConnectorType()); - - // Weight - $weight = $style->getWeight(); - $xmlWriter->writeAttributeIf($weight !== null, 'strokeweight', $weight . 'pt'); - - // Color - $color = $style->getColor(); - $xmlWriter->writeAttributeIf($color !== null, 'strokecolor', $color); - } - /** * Write Line stroke + * + * @todo Merge with `Stroke` style */ public function writeStroke() { @@ -77,8 +39,6 @@ public function writeStroke() } $dash = $style->getDash(); - $beginArrow = $style->getBeginArrow(); - $endArrow = $style->getEndArrow(); $dashStyles = array( LineStyle::DASH_STYLE_DASH => 'dash', LineStyle::DASH_STYLE_ROUND_DOT => '1 1', @@ -89,22 +49,22 @@ public function writeStroke() LineStyle::DASH_STYLE_LONG_DASH_DOT_DOT => 'longDashDotDot', ); - if (($dash !== null) || ($beginArrow !== null) || ($endArrow !== null)) { - $xmlWriter->startElement('v:stroke'); + $xmlWriter->startElement('v:stroke'); - $xmlWriter->writeAttributeIf($beginArrow !== null, 'startarrow', $beginArrow); - $xmlWriter->writeAttributeIf($endArrow !== null, 'endarrow', $endArrow); + $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . 'pt'); + $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); + $xmlWriter->writeAttributeIf($style->getBeginArrow() !== null, 'startarrow', $style->getBeginArrow()); + $xmlWriter->writeAttributeIf($style->getEndArrow() !== null, 'endarrow', $style->getEndArrow()); - 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'); - } + 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 } + + $xmlWriter->endElement(); //v:stroke } } diff --git a/src/PhpWord/Writer/Word2007/Style/Outline.php b/src/PhpWord/Writer/Word2007/Style/Outline.php index 5003d9fca6..e53282a315 100644 --- a/src/PhpWord/Writer/Word2007/Style/Outline.php +++ b/src/PhpWord/Writer/Word2007/Style/Outline.php @@ -38,9 +38,10 @@ public function write() $xmlWriter->startElement("v:stroke"); $xmlWriter->writeAttribute('on', 't'); $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); - $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . 'pt'); + $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . $style->getUnit()); $xmlWriter->writeAttributeIf($style->getDash() !== null, 'dashstyle', $style->getDash()); $xmlWriter->writeAttributeIf($style->getLine() !== null, 'linestyle', $style->getLine()); + $xmlWriter->writeAttributeIf($style->getEndCap() !== null, 'endcap', $style->getEndCap()); $xmlWriter->writeAttributeIf($style->getStartArrow() !== null, 'startarrow', $style->getStartArrow()); $xmlWriter->writeAttributeIf($style->getEndArrow() !== null, 'endarrow', $style->getEndArrow()); $xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index 13f40256f1..a5f82e53db 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -24,67 +24,8 @@ * * @since 0.11.0 */ -class TextBox extends Image +class TextBox extends Frame { - /** - * Write style - */ - public function write() - { - $style = $this->getStyle(); - if (!$style instanceof TextBoxStyle) { - return; - } - $this->writeStyle($style); - $this->writeBorder($style); - } - - /** - * Write w10 wrapping - * - * @return array - */ - public function writeW10Wrap() - { - if (is_null($this->w10wrap)) { - return; - } - $style = $this->getStyle(); - if (!$style instanceof TextBoxStyle) { - return; - } - - $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(); - - $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]); - } - } - - $xmlWriter->endElement(); // w10:wrap - } - /** * Writer inner margin */ @@ -97,29 +38,24 @@ public function writeInnerMargin() $xmlWriter = $this->getXmlWriter(); $margins = implode(', ', $style->getInnerMargin()); + $xmlWriter->writeAttribute('inset', $margins); } /** * Writer border */ - private function writeBorder(TextBoxStyle $style) + public function writeBorder() { - $xmlWriter = $this->getXmlWriter(); - - // Border size - $borderSize = $style->getBorderSize(); - if ($borderSize !== null) { - $xmlWriter->writeAttribute('strokeweight', $borderSize . 'pt'); + $style = $this->getStyle(); + if (!$style instanceof TextBoxStyle) { + return; } + $xmlWriter = $this->getXmlWriter(); - // Border color - $borderColor = $style->getBorderColor(); - if (empty($borderColor)) { - $xmlWriter->writeAttribute('stroked', 'f'); - } else { - $xmlWriter->writeAttribute('strokecolor', $borderColor); - } - //@todo + $xmlWriter->startElement('v:stroke'); + $xmlWriter->writeAttributeIf($style->getBorderSize() !== null, 'weight', $style->getBorderSize() . 'pt'); + $xmlWriter->writeAttributeIf($style->getBorderColor() !== null, 'color', $style->getBorderColor()); + $xmlWriter->endElement(); // v:stroke } } diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 9e74af2fbe..c21ea4ce3e 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -46,6 +46,7 @@ public function testInitiation() $this->assertEquals('text', $object->getStyleType()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle()); + $this->assertTrue(is_array($object->getStyleValues())); } /** diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 6ba3477be0..c774e9f352 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -103,7 +103,7 @@ public function testShapeElements() array( 'points' => '1,1 150,30', 'outline' => array('color' => '#cc00ff', 'line' => 'thickThin', 'weight' => 3, - 'startArrow' => 'oval', 'endArrow' => 'classic'), + 'startArrow' => 'oval', 'endArrow' => 'classic', 'endCap' => 'round'), ) ); diff --git a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php index c840d2074f..8dd229c311 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/StyleTest.php @@ -49,8 +49,9 @@ public function testEmptyStyles() public function testMethodExceptions() { $styles = array( - 'Image' => 'writeAlignment', - 'Line' => 'writeStroke', + 'Frame' => 'writeAlignment', + 'Line' => 'writeStroke', + 'TextBox' => 'writeBorder', ); foreach ($styles as $style => $method) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style; From f44ff4b7a6b6e618f9a21a0b893e95532562a0cd Mon Sep 17 00:00:00 2001 From: lrobert Date: Thu, 5 Jun 2014 10:47:53 -0400 Subject: [PATCH 010/174] Added shading to the paragraph style for full width shading --- src/PhpWord/Style/Paragraph.php | 31 +++++++++++++++++++ .../Writer/Word2007/Style/Paragraph.php | 7 +++++ 2 files changed, 38 insertions(+) diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 8167358663..ef966635ea 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -152,6 +152,13 @@ class Paragraph extends AbstractStyle */ private $tabs = array(); + /** + * Shading + * + * @var \PhpOffice\PhpWord\Style\Shading + */ + private $shading; + /** * Create new instance */ @@ -209,6 +216,7 @@ public function getStyleValues() 'level' => $this->getNumLevel(), ), 'tabs' => $this->getTabs(), + 'shading' => $this->getShading(), ); return $styles; @@ -694,4 +702,27 @@ public function getPageBreakBefore() { return $this->hasPageBreakBefore(); } + + /** + * Get shading + * + * @return \PhpOffice\PhpWord\Style\Shading + */ + public function getShading() + { + return $this->shading; + } + + /** + * Set shading + * + * @param mixed $value + * @return self + */ + public function setShading($value = null) + { + $this->setObjectVal($value, 'Shading', $this->shading); + + return $this; + } } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index f328770083..71bb6e48b5 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -99,6 +99,13 @@ private function writeStyle() $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']); $this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']); + // Background-Color + $shading = $style->getShading(); + if (!is_null($shading)) { + $styleWriter = new Shading($xmlWriter, $shading); + $styleWriter->write(); + } + // Tabs $this->writeTabs($xmlWriter, $styles['tabs']); From 479713da5593f8e23071007195680a9f19cf6068 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 5 Jun 2014 22:41:58 +0700 Subject: [PATCH 011/174] Update changelog and unit test for #264 --- CHANGELOG.md | 1 + src/PhpWord/Writer/Word2007/Style/Paragraph.php | 10 ++-------- .../Tests/Writer/Word2007/Part/DocumentTest.php | 6 +++++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 316f92bfec..19d22c8f97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers - Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 - Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin +- Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 ### Bugfixes diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 7be537cd5a..4ccba00f3a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -95,16 +95,10 @@ private function writeStyle() $xmlWriter->writeElementIf($styles['pagination']['keepLines'] === true, 'w:keepLines', 'w:val', '1'); $xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', 'w:val', '1'); - // Indentation & spacing + // Child style: indentation, spacing, and shading $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']); $this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']); - - // Background-Color - $shading = $style->getShading(); - if (!is_null($shading)) { - $styleWriter = new Shading($xmlWriter, $shading); - $styleWriter->write(); - } + $this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']); // Tabs $this->writeTabs($xmlWriter, $styles['tabs']); diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index 5e0dc747d8..fd36db25a0 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -135,7 +135,11 @@ public function testElementStyles() $tabs = array(new \PhpOffice\PhpWord\Style\Tab('right', 9090)); $phpWord = new PhpWord(); - $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'tabs' => $tabs)); // Style #1 + $phpWord->addParagraphStyle('pStyle', array( + 'align' => 'center', + 'tabs' => $tabs, + 'shading' => array('fill' => 'FFFF99'), + )); // Style #1 $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true, 'scale' => 200, 'spacing' => 240, 'kerning' => 10)); // Style #2 $phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3 From d97602fa98cd6ab0bc1bfb88c25a5b6d19aa6213 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 5 Jun 2014 23:47:39 +0700 Subject: [PATCH 012/174] Reduce duplications and fix some docblocks --- src/PhpWord/Element/AbstractContainer.php | 1 + src/PhpWord/Writer/RTF/Element/Table.php | 3 + .../Word2007/Element/AbstractElement.php | 61 ++++++++++++++++++- .../Writer/Word2007/Element/CheckBox.php | 2 +- src/PhpWord/Writer/Word2007/Element/Field.php | 3 +- .../Writer/Word2007/Element/Footnote.php | 2 +- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- .../Writer/Word2007/Element/PageBreak.php | 2 +- .../Writer/Word2007/Element/PreserveText.php | 2 +- src/PhpWord/Writer/Word2007/Element/Text.php | 60 +----------------- .../Writer/Word2007/Element/TextBreak.php | 2 +- .../Writer/Word2007/Element/TextRun.php | 2 +- src/PhpWord/Writer/Word2007/Style/Frame.php | 1 + 13 files changed, 75 insertions(+), 68 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index ae750de995..7afdbb4728 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -188,6 +188,7 @@ private function setElementNestedLevel(AbstractElement $element) /** * Set relation Id * + * @param \PhpOffice\PhpWord\Element\AbstractElement $element * @param string $elementName * @param string $source */ diff --git a/src/PhpWord/Writer/RTF/Element/Table.php b/src/PhpWord/Writer/RTF/Element/Table.php index b48e084f46..7c4329f719 100644 --- a/src/PhpWord/Writer/RTF/Element/Table.php +++ b/src/PhpWord/Writer/RTF/Element/Table.php @@ -66,6 +66,7 @@ public function write() /** * Write column * + * @param \PhpOffice\PhpWord\Element\Row $row * @return string */ private function writeRowDef(RowElement $row) @@ -89,6 +90,7 @@ private function writeRowDef(RowElement $row) /** * Write row * + * @param \PhpOffice\PhpWord\Element\Row $row * @return string */ private function writeRow(RowElement $row) @@ -106,6 +108,7 @@ private function writeRow(RowElement $row) /** * Write cell * + * @param \PhpOffice\PhpWord\Element\Cell $cell * @return string */ private function writeCell(CellElement $cell) diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index c1e721edcc..e17640c864 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -18,6 +18,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Element\AbstractElement as Element; +use PhpOffice\PhpWord\Element\PageBreak as PageBreakElement; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -116,7 +117,28 @@ public function setPageBreakBefore($value = true) } /** - * Write ending + * Start w:p DOM element + * + * @uses \PhpOffice\PhpWord\Writer\Word2007\Element\PageBreak::write() + */ + protected function startElementP() + { + if (!$this->withoutP) { + $this->xmlWriter->startElement('w:p'); + // Paragraph style + if (method_exists($this->element, 'getParagraphStyle')) { + $this->writeParagraphStyle(); + } + // PageBreak + if ($this->pageBreakBefore) { + $elementWriter = new PageBreak($this->xmlWriter, new PageBreakElement()); + $elementWriter->write(); + } + } + } + + /** + * End w:p DOM element */ protected function endElementP() { @@ -125,6 +147,43 @@ protected function endElementP() } } + /** + * Write ending + */ + protected function writeParagraphStyle() + { + $this->writeTextStyle('Paragraph'); + } + + /** + * Write ending + */ + protected function writeFontStyle() + { + $this->writeTextStyle('Font'); + } + + + /** + * Write text style + * + * @param string $styleType Font|Paragraph + */ + private function writeTextStyle($styleType) + { + $method = "get{$styleType}Style"; + $class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\{$styleType}"; + $styleObject = $this->element->$method(); + + $styleWriter = new $class($this->xmlWriter, $styleObject); + if (method_exists($styleWriter, 'setIsInline')) { + $styleWriter->setIsInline(true); + } + + /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $styleWriter */ + $styleWriter->write(); + } + /** * Convert text to valid format * diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 2d0fe6916d..d5f6a64e12 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -35,7 +35,7 @@ public function write() return; } - $this->writeOpeningWP(); + $this->startElementP(); $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:fldChar'); diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php index 1e538e1ad8..7133e83fe4 100644 --- a/src/PhpWord/Writer/Word2007/Element/Field.php +++ b/src/PhpWord/Writer/Word2007/Element/Field.php @@ -67,7 +67,8 @@ public function write() } } - $this->writeOpeningWP(); + $this->startElementP(); + $xmlWriter->startElement('w:fldSimple'); $xmlWriter->writeAttribute('w:instr', $instruction); $xmlWriter->startElement('w:r'); diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index 05b96ae5b2..be5a21f13c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -42,7 +42,7 @@ public function write() return; } - $this->writeOpeningWP(); + $this->startElementP(); $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:rPr'); diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 68851ec4a0..d7e68ac15c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -37,7 +37,7 @@ public function write() $rId = $element->getRelationId() + ($element->isInSection() ? 6 : 0); - $this->writeOpeningWP(); + $this->startElementP(); $xmlWriter->startElement('w:hyperlink'); $xmlWriter->writeAttribute('r:id', 'rId' . $rId); diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index 6974777a45..47f3feb5bf 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -30,7 +30,7 @@ class PageBreak extends AbstractElement /** * Write element * - * @usedby \PhpOffice\PhpWord\Writer\Word2007\Element\Text::writeOpeningWP() + * @usedby \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement::startElementP() */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index c63d13a79c..ef5b93cdb9 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -40,7 +40,7 @@ public function write() $texts = array($texts); } - $this->writeOpeningWP(); + $this->startElementP(); foreach ($texts as $text) { if (substr($text, 0, 1) == '{') { diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 5d92b3f998..1fa4861f22 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -17,10 +17,6 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Element\PageBreak as PageBreakElement; -use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; -use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; - /** * Text element writer * @@ -39,7 +35,7 @@ public function write() return; } - $this->writeOpeningWP(); + $this->startElementP(); $xmlWriter->startElement('w:r'); @@ -53,58 +49,4 @@ public function write() $this->endElementP(); // w:p } - - /** - * Write opening - * - * @uses \PhpOffice\PhpWord\Writer\Word2007\Element\PageBreak::write() - */ - protected function writeOpeningWP() - { - $xmlWriter = $this->getXmlWriter(); - $element = $this->getElement(); - - if (!$this->withoutP) { - $xmlWriter->startElement('w:p'); - // Paragraph style - if (method_exists($element, 'getParagraphStyle')) { - $this->writeParagraphStyle(); - } - // PageBreak - if ($this->hasPageBreakBefore()) { - $elementWriter = new PageBreak($xmlWriter, new PageBreakElement()); - $elementWriter->write(); - } - } - } - - /** - * Write ending - */ - protected function writeParagraphStyle() - { - $xmlWriter = $this->getXmlWriter(); - - /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ - $element = $this->getElement(); - $paragraphStyle = $element->getParagraphStyle(); - $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); - $styleWriter->setIsInline(true); - $styleWriter->write(); - } - - /** - * Write ending - */ - protected function writeFontStyle() - { - $xmlWriter = $this->getXmlWriter(); - - /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */ - $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 2995e8be74..83ec22218b 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -37,7 +37,7 @@ public function write() if (!$this->withoutP) { $hasStyle = $element->hasStyle(); - $this->writeOpeningWP(); + $this->startElementP(); if ($hasStyle) { $xmlWriter->startElement('w:pPr'); diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index ca3a6b0573..9ff348cf05 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -32,7 +32,7 @@ public function write() $xmlWriter = $this->getXmlWriter(); $element = $this->getElement(); - $this->writeOpeningWP(); + $this->startElementP(); $containerWriter = new Container($xmlWriter, $element); $containerWriter->write(); diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php index 507c0c029d..6926081f4c 100644 --- a/src/PhpWord/Writer/Word2007/Style/Frame.php +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -134,6 +134,7 @@ private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap) /** * Get style values in associative array * + * @param \PhpOffice\PhpWord\Style\Frame $style * @param array $properties * @param string $suffix * @return array From 3d2cd163d385be827b61daabf1c85f8e23af5ad3 Mon Sep 17 00:00:00 2001 From: Andrew Collins Date: Thu, 5 Jun 2014 13:45:18 -0400 Subject: [PATCH 013/174] Ensure temp file in pclzipAddFile() removed Make pclzipAddFile() similar to pclzipAddFromString() in removing temporary files. --- src/PhpWord/Shared/ZipArchive.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index cbfcb07127..8bbfd4c367 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -224,7 +224,9 @@ public function pclzipAddFile($filename, $localname = null) // To Rename the file while adding it to the zip we // need to create a temp file with the correct name + $temp_file = false; if ($filenameParts['basename'] != $localnameParts['basename']) { + $temp_file = true; // temp file created $temppath = $this->tempDir . '/' . $localnameParts['basename']; copy($filename, $temppath); $filename = $temppath; @@ -236,6 +238,11 @@ public function pclzipAddFile($filename, $localname = null) $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); + if($temp_file) { + // Remove temp file, if created + @unlink($this->tempDir . '/' . $localnameParts["basename"]); + } + return ($res == 0) ? false : true; } From 49f4e6ba64601a80dcdd3af5e2a451a98ef79033 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 6 Jun 2014 12:53:01 +0700 Subject: [PATCH 014/174] RTF Writer: Support for sections, margins, and borders #249 --- CHANGELOG.md | 1 + .../Writer/HTML/Style/AbstractStyle.php | 27 ++++ src/PhpWord/Writer/RTF/Part/Document.php | 13 +- src/PhpWord/Writer/RTF/Part/Header.php | 36 ++++- src/PhpWord/Writer/RTF/Style/Border.php | 124 ++++++++++++++++++ src/PhpWord/Writer/RTF/Style/Section.php | 69 ++++++++++ tests/PhpWord/Tests/Writer/RTF/StyleTest.php | 2 +- 7 files changed, 263 insertions(+), 9 deletions(-) create mode 100644 src/PhpWord/Writer/RTF/Style/Border.php create mode 100644 src/PhpWord/Writer/RTF/Style/Section.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 19d22c8f97..f176fa4430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers - Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 - Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin - Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 +- RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 ### Bugfixes diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index cd37174aed..c729ec552b 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -26,6 +26,13 @@ */ abstract class AbstractStyle { + /** + * Parent writer + * + * @var \PhpOffice\PhpWord\Writer\AbstractWriter + */ + private $parentWriter; + /** * Style * @@ -48,6 +55,26 @@ public function __construct($style = null) $this->style = $style; } + /** + * Set parent writer + * + * @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer + */ + public function setParentWriter($writer) + { + $this->parentWriter = $writer; + } + + /** + * Get parent writer + * + * @return \PhpOffice\PhpWord\Writer\AbstractWriter + */ + public function getParentWriter() + { + return $this->parentWriter; + } + /** * Get style * diff --git a/src/PhpWord/Writer/RTF/Part/Document.php b/src/PhpWord/Writer/RTF/Part/Document.php index 71565044b2..2f5c2f8e09 100644 --- a/src/PhpWord/Writer/RTF/Part/Document.php +++ b/src/PhpWord/Writer/RTF/Part/Document.php @@ -19,11 +19,13 @@ use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Writer\RTF\Element\Container; +use PhpOffice\PhpWord\Writer\RTF\Style\Section as SectionStyleWriter; /** * RTF document part writer * * @since 0.11.0 + * @link http://www.biblioscape.com/rtf15_spec.htm#Heading24 */ class Document extends AbstractPart { @@ -103,12 +105,19 @@ private function writeFormatting() */ private function writeSections() { + $content = ''; $sections = $this->getParentWriter()->getPhpWord()->getSections(); foreach ($sections as $section) { - $writer = new Container($this->getParentWriter(), $section); - $content .= $writer->write(); + $styleWriter = new SectionStyleWriter($section->getSettings()); + $styleWriter->setParentWriter($this->getParentWriter()); + $content .= $styleWriter->write(); + + $elementWriter = new Container($this->getParentWriter(), $section); + $content .= $elementWriter->write(); + + $content .= '\sect' . PHP_EOL; } return $content; diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index 15a0c303e8..32debb06b4 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -25,7 +25,15 @@ /** * RTF header part writer * + * - Character set + * - Font table + * - File table (not supported yet) + * - Color table + * - Style sheet (not supported yet) + * - List table (not supported yet) + * * @since 0.11.0 + * @link http://www.biblioscape.com/rtf15_spec.htm#Heading6 */ class Header extends AbstractPart { @@ -141,10 +149,10 @@ private function writeColorTable() $content = ''; $content .= '{'; - $content .= '\colortbl'; + $content .= '\colortbl;'; foreach ($this->colorTable as $color) { list($red, $green, $blue) = Drawing::htmlToRGB($color); - $content .= ";\\red{$red}\\green{$green}\\blue{$blue}"; + $content .= "\\red{$red}\\green{$green}\\blue{$blue};"; } $content .= '}'; $content .= PHP_EOL; @@ -185,6 +193,7 @@ private function registerFont() $sections = $phpWord->getSections(); foreach ($sections as $section) { $elements = $section->getElements(); + $this->registerBorderColor($section->getSettings()); foreach ($elements as $element) { if (method_exists($element, 'getFontStyle')) { $style = $element->getFontStyle(); @@ -194,6 +203,21 @@ private function registerFont() } } + /** + * Register border colors + * + * @param \PhpOffice\PhpWord\Style\Border $style + */ + private function registerBorderColor($style) + { + $colors = $style->getBorderColor(); + foreach ($colors as $color) { + if ($color !== null) { + $this->registerTableItem($this->colorTable, $color); + } + } + } + /** * Register fonts and colors * @@ -205,9 +229,9 @@ private function registerFontItems($style) $defaultColor = Settings::DEFAULT_FONT_COLOR; if ($style instanceof Font) { - $this->registerFontItem($this->fontTable, $style->getName(), $defaultFont); - $this->registerFontItem($this->colorTable, $style->getColor(), $defaultColor); - $this->registerFontItem($this->colorTable, $style->getFgColor(), $defaultColor); + $this->registerTableItem($this->fontTable, $style->getName(), $defaultFont); + $this->registerTableItem($this->colorTable, $style->getColor(), $defaultColor); + $this->registerTableItem($this->colorTable, $style->getFgColor(), $defaultColor); } } @@ -218,7 +242,7 @@ private function registerFontItems($style) * @param string $value * @param string $default */ - private function registerFontItem(&$table, $value, $default) + private function registerTableItem(&$table, $value, $default = null) { if (in_array($value, $table) === false && $value !== null && $value != $default) { $table[] = $value; diff --git a/src/PhpWord/Writer/RTF/Style/Border.php b/src/PhpWord/Writer/RTF/Style/Border.php new file mode 100644 index 0000000000..8df6d165e4 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Style/Border.php @@ -0,0 +1,124 @@ +sizes) - 1; + + // Page border measure + // 8 = from text, infront off; 32 = from edge, infront on; 40 = from edge, infront off + $content .= '\pgbrdropt32'; + + for ($i = 0; $i < $sizeCount; $i++) { + if ($this->sizes[$i] !== null) { + $color = null; + if (isset($this->colors[$i])) { + $color = $this->colors[$i]; + } + $content .= $this->writeSide($sides[$i], $this->sizes[$i], $color); + } + } + + return $content; + } + + /** + * Write side + * + * @param string $side + * @param int $width + * @param string $color + * @return string + */ + private function writeSide($side, $width, $color = '') + { + /** @var \PhpOffice\PhpWord\Writer\RTF $rtfWriter */ + $rtfWriter = $this->getParentWriter(); + $colorIndex = 0; + if ($rtfWriter !== null) { + $colorTable = $rtfWriter->getColorTable(); + $index = array_search($color, $colorTable); + if ($index !== false && $colorIndex !== null) { + $colorIndex = $index + 1; + } + } + + $content = ''; + + $content .= '\pgbrdr' . substr($side, 0, 1); + $content .= '\brdrs'; // Single-thickness border; @todo Get other type of border + $content .= '\brdrw' . $width; // Width + $content .= '\brdrcf' . $colorIndex; // Color + $content .= '\brsp480'; // Space in twips between borders and the paragraph (24pt, following OOXML) + $content .= ' '; + + return $content; + } + + /** + * Set sizes + * + * @param integer[] $value + */ + public function setSizes($value) + { + $this->sizes = $value; + } + + /** + * Set colors + * + * @param string[] $value + */ + public function setColors($value) + { + $this->colors = $value; + } +} diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php new file mode 100644 index 0000000000..b556e299e9 --- /dev/null +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -0,0 +1,69 @@ +getStyle(); + if (!$style instanceof SectionStyle) { + return ''; + } + + $content = ''; + + $content .= '\sectd '; + + // Size & margin + $content .= $this->getValueIf($style->getPageSizeW(), '\pgwsxn' . $style->getPageSizeW()); + $content .= $this->getValueIf($style->getPageSizeH(), '\pghsxn' . $style->getPageSizeH()); + $content .= ' '; + $content .= $this->getValueIf($style->getMarginTop(), '\margtsxn' . $style->getMarginTop()); + $content .= $this->getValueIf($style->getMarginRight(), '\margrsxn' . $style->getMarginRight()); + $content .= $this->getValueIf($style->getMarginBottom(), '\margbsxn' . $style->getMarginBottom()); + $content .= $this->getValueIf($style->getMarginLeft(), '\marglsxn' . $style->getMarginLeft()); + $content .= $this->getValueIf($style->getHeaderHeight(), '\headery' . $style->getHeaderHeight()); + $content .= $this->getValueIf($style->getFooterHeight(), '\footery' . $style->getFooterHeight()); + $content .= $this->getValueIf($style->getGutter(), '\guttersxn' . $style->getGutter()); + $content .= ' '; + + // Borders + if ($style->hasBorder()) { + $styleWriter = new Border($style); + $styleWriter->setParentWriter($this->getParentWriter()); + $styleWriter->setSizes($style->getBorderSize()); + $styleWriter->setColors($style->getBorderColor()); + $content .= $styleWriter->write(); + } + + return $content . PHP_EOL; + } +} diff --git a/tests/PhpWord/Tests/Writer/RTF/StyleTest.php b/tests/PhpWord/Tests/Writer/RTF/StyleTest.php index 8b4a4441ba..542e34fe7c 100644 --- a/tests/PhpWord/Tests/Writer/RTF/StyleTest.php +++ b/tests/PhpWord/Tests/Writer/RTF/StyleTest.php @@ -28,7 +28,7 @@ class StyleTest extends \PHPUnit_Framework_TestCase */ public function testEmptyStyles() { - $styles = array('Font', 'Paragraph'); + $styles = array('Font', 'Paragraph', 'Section'); foreach ($styles as $style) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Style\\' . $style; $object = new $objectClass(); From a2ec62a79fb2e9ef51aa021ac84c174231d65e5a Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 6 Jun 2014 15:23:19 +0700 Subject: [PATCH 015/174] Section: Ability to set paper size, e.g. A4, A3, and Legal --- CHANGELOG.md | 1 + composer.lock | 219 +++++++++------------- samples/Sample_03_Sections.php | 4 +- src/PhpWord/Style/Paper.php | 188 +++++++++++++++++++ src/PhpWord/Style/Section.php | 47 ++++- src/PhpWord/Writer/RTF/Style/Border.php | 2 - tests/PhpWord/Tests/Style/SectionTest.php | 16 +- 7 files changed, 328 insertions(+), 149 deletions(-) create mode 100644 src/PhpWord/Style/Paper.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f176fa4430..eb0a6c20a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers - Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin - Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 - RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 +- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 ### Bugfixes diff --git a/composer.lock b/composer.lock index 172e564ef9..11a38043ab 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": "91993ff980d11a416fcf3a7309a4044f", + "hash": "7d0a883164ca8e64ca34f4910aa64b96", "packages": [ ], @@ -553,16 +553,16 @@ }, { "name": "monolog/monolog", - "version": "1.9.1", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "65026b610f8c19e61d7242f600530677b0466aac" + "reference": "25b16e801979098cb2f120e697bfce454b18bf23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/65026b610f8c19e61d7242f600530677b0466aac", - "reference": "65026b610f8c19e61d7242f600530677b0466aac", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/25b16e801979098cb2f120e697bfce454b18bf23", + "reference": "25b16e801979098cb2f120e697bfce454b18bf23", "shasum": "" }, "require": { @@ -590,7 +590,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -617,7 +617,7 @@ "logging", "psr-3" ], - "time": "2014-04-24 13:29:03" + "time": "2014-06-04 16:30:04" }, { "name": "mpdf/mpdf", @@ -1984,17 +1984,17 @@ }, { "name": "symfony/config", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "2effc67af6f21a0d267210b72d0b0b691d113528" + "reference": "9c8caadb38ecc69ac35ab31af4d1996944b5a09f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/2effc67af6f21a0d267210b72d0b0b691d113528", - "reference": "2effc67af6f21a0d267210b72d0b0b691d113528", + "url": "https://api.github.com/repos/symfony/Config/zipball/9c8caadb38ecc69ac35ab31af4d1996944b5a09f", + "reference": "9c8caadb38ecc69ac35ab31af4d1996944b5a09f", "shasum": "" }, "require": { @@ -2004,7 +2004,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2030,36 +2030,38 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-04-22 08:11:06" + "time": "2014-04-22 08:11:23" }, { "name": "symfony/console", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "2e452005b1e1d003d23702d227e23614679eb5ca" + "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/2e452005b1e1d003d23702d227e23614679eb5ca", - "reference": "2e452005b1e1d003d23702d227e23614679eb5ca", + "url": "https://api.github.com/repos/symfony/Console/zipball/ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", + "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { + "psr/log": "~1.0", "symfony/event-dispatcher": "~2.1" }, "suggest": { + "psr/log": "For using the console logger", "symfony/event-dispatcher": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2085,28 +2087,31 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-04-27 13:34:57" + "time": "2014-05-22 08:54:24" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e539602e5455aa086c0e81e604745af7789e4d8a" + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e539602e5455aa086c0e81e604745af7789e4d8a", - "reference": "e539602e5455aa086c0e81e604745af7789e4d8a", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "~2.0" + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0", + "symfony/stopwatch": "~2.2" }, "suggest": { "symfony/dependency-injection": "", @@ -2115,7 +2120,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2141,21 +2146,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-04-16 10:34:31" + "time": "2014-04-29 10:13:57" }, { "name": "symfony/filesystem", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4" + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a3af8294bcce4a7c1b2892363b0c9d8109affad4", - "reference": "a3af8294bcce4a7c1b2892363b0c9d8109affad4", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/98e831eac836a0a5911626ce82684155f21d0e4d", + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d", "shasum": "" }, "require": { @@ -2164,7 +2169,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2190,21 +2195,21 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2014-04-16 10:34:31" + "time": "2014-04-16 10:36:21" }, { "name": "symfony/finder", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730" + "reference": "307aad2c541bbdf43183043645e186ef2cd6b973" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/25e1e7d5e7376f8a92ae3b1d714d956edf33a730", - "reference": "25e1e7d5e7376f8a92ae3b1d714d956edf33a730", + "url": "https://api.github.com/repos/symfony/Finder/zipball/307aad2c541bbdf43183043645e186ef2cd6b973", + "reference": "307aad2c541bbdf43183043645e186ef2cd6b973", "shasum": "" }, "require": { @@ -2213,7 +2218,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2239,21 +2244,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-04-27 13:34:57" + "time": "2014-05-22 13:47:45" }, { "name": "symfony/process", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7" + "reference": "5d7d78e23894544740219e006320678cfa4cd45b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", - "reference": "8721f1476d5d38a43c7d6ccb6435b351cf8f3bb7", + "url": "https://api.github.com/repos/symfony/Process/zipball/5d7d78e23894544740219e006320678cfa4cd45b", + "reference": "5d7d78e23894544740219e006320678cfa4cd45b", "shasum": "" }, "require": { @@ -2262,7 +2267,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2288,81 +2293,21 @@ ], "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" + "time": "2014-05-23 09:02:52" }, { "name": "symfony/stopwatch", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a" + "reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/343bcc0360f2c22f371884b8f6a9fee8d1aa431a", - "reference": "343bcc0360f2c22f371884b8f6a9fee8d1aa431a", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/724d73604ebe6c1c9bdf36533b556123bd9075a1", + "reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1", "shasum": "" }, "require": { @@ -2371,7 +2316,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2397,21 +2342,21 @@ ], "description": "Symfony Stopwatch Component", "homepage": "http://symfony.com", - "time": "2014-04-18 20:37:09" + "time": "2014-04-18 20:40:13" }, { "name": "symfony/translation", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5" + "reference": "5f23265dcf8927a84be832608069c9edca3cf5f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", - "reference": "d2c73ffa4a5ba1fa0c5d93f43b68331dffe898c5", + "url": "https://api.github.com/repos/symfony/Translation/zipball/5f23265dcf8927a84be832608069c9edca3cf5f4", + "reference": "5f23265dcf8927a84be832608069c9edca3cf5f4", "shasum": "" }, "require": { @@ -2428,7 +2373,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2454,48 +2399,53 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2014-04-18 21:02:05" + "time": "2014-05-22 13:47:45" }, { "name": "symfony/validator", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7" + "reference": "62f6f7735fbd3897b9347ae60fda4a40d0122640" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/5bbcdcc520bc7fb3826abb44020880f14c9c03a7", - "reference": "5bbcdcc520bc7fb3826abb44020880f14c9c03a7", + "url": "https://api.github.com/repos/symfony/Validator/zipball/62f6f7735fbd3897b9347ae60fda4a40d0122640", + "reference": "62f6f7735fbd3897b9347ae60fda4a40d0122640", "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", + "egulias/email-validator": "~1.0", "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", "symfony/http-foundation": "~2.1", "symfony/intl": "~2.3", + "symfony/property-access": "~2.2", "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", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", + "egulias/email-validator": "Strict (RFC compliant) email validation", "symfony/config": "", + "symfony/expression-language": "For using the 2.4 Expression validator", "symfony/http-foundation": "", "symfony/intl": "", + "symfony/property-access": "For using the 2.4 Validator API", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2521,21 +2471,21 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2014-04-27 13:34:57" + "time": "2014-05-31 02:02:56" }, { "name": "symfony/yaml", - "version": "v2.4.4", + "version": "v2.5.0", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff" + "reference": "b4b09c68ec2f2727574544ef0173684281a5033c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/65539ecde838f9c0d18b006b2101e3deb4b5c9ff", - "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b4b09c68ec2f2727574544ef0173684281a5033c", + "reference": "b4b09c68ec2f2727574544ef0173684281a5033c", "shasum": "" }, "require": { @@ -2544,7 +2494,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -2570,15 +2520,15 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-04-18 20:37:09" + "time": "2014-05-16 14:25:18" }, { "name": "tecnick.com/tcpdf", - "version": "6.0.078", + "version": "6.0.083", "source": { "type": "git", "url": "git://git.code.sf.net/p/tcpdf/code", - "reference": "e1cbda79b99f3cdc8fdf26b39eb4870d2cd9fbac" + "reference": "d6a2206ab366f493680a22151429f17fd045fe04" }, "require": { "php": ">=5.3.0" @@ -2627,7 +2577,7 @@ "pdf417", "qrcode" ], - "time": "2014-05-12 19:50:13" + "time": "2014-05-29 18:28:56" }, { "name": "twig/twig", @@ -3274,8 +3224,7 @@ ], "platform": { "php": ">=5.3.3", - "ext-xml": "*", - "ext-zip": "*" + "ext-xml": "*" }, "platform-dev": [ diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index bfbc84afda..9ed75c731a 100644 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -16,8 +16,8 @@ $section->addPageBreak(); // New portrait section -$section = $phpWord->addSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); -$section->addText('This section uses other margins.'); +$section = $phpWord->addSection(array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); +$section->addText('This section uses other margins with folio papersize.'); // New portrait section with Header & Footer $section = $phpWord->addSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); diff --git a/src/PhpWord/Style/Paper.php b/src/PhpWord/Style/Paper.php new file mode 100644 index 0000000000..642666b5f1 --- /dev/null +++ b/src/PhpWord/Style/Paper.php @@ -0,0 +1,188 @@ + array(297, 420, 'mm'), + 'A4' => array(210, 297, 'mm'), + 'A5' => array(148, 210, 'mm'), + 'Folio' => array(8.5, 13, 'in'), + 'Legal' => array(8.5, 14, 'in'), + 'Letter' => array(8.5, 11, 'in'), + ); + + /** + * Paper size + * + * @var string + */ + private $size = 'A4'; + + /** + * Width + * + * @var int (twip) + */ + private $width; + + /** + * Height + * + * @var int (twip) + */ + private $height; + + /** + * Create a new instance + * + * @param string $size + */ + public function __construct($size = 'A4') + { + $this->setSize($size); + } + + /** + * Get size + * + * @return string + */ + public function getSize() + { + return $this->size; + } + + /** + * Set size + * + * @param string $size + * @return self + */ + public function setSize($size) + { + $this->size = $this->setEnumVal($size, array_keys($this->sizes), $this->size); + + list($width, $height, $unit) = $this->sizes[$this->size]; + $multipliers = array('mm' => 56.5217, 'in' => 1440); + $multiplier = $multipliers[$unit]; + + $this->width = (int)round($width * $multiplier); + $this->height = (int)round($height * $multiplier); + + return $this; + } + + /** + * Get width + * + * @return int + */ + public function getWidth() + { + return $this->width; + } + + /** + * Get height + * + * @return int + */ + public function getHeight() + { + return $this->height; + } +} diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index fd59f1b419..c56b0a1950 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -35,8 +35,8 @@ class Section extends Border * * @const int|float */ - const DEFAULT_WIDTH = 11906; // In twip - const DEFAULT_HEIGHT = 16838; // In twip + const DEFAULT_WIDTH = 11870; // In twip + const DEFAULT_HEIGHT = 16787; // In twip const DEFAULT_MARGIN = 1440; // In twip const DEFAULT_GUTTER = 0; // In twip const DEFAULT_HEADER_HEIGHT = 720; // In twip @@ -52,6 +52,13 @@ class Section extends Border */ private $orientation = self::ORIENTATION_PORTRAIT; + /** + * Paper size + * + * @var \PhpOffice\PhpWord\Style\Paper + */ + private $paper; + /** * Page Size Width * @@ -159,6 +166,42 @@ class Section extends Border */ private $lineNumbering; + /** + * Create new instance + */ + public function __construct() + { + $this->setPaperSize(); + } + + /** + * Get paper size + * + * @return string + */ + public function getPaperSize() + { + return $this->paper->getSize(); + } + + /** + * Set paper size + * + * @param string $value + * @return self + */ + public function setPaperSize($value = 'A4') + { + if ($this->paper === null) { + $this->paper = new Paper(); + } + $this->paper->setSize($value); + $this->pageSizeW = $this->paper->getWidth(); + $this->pageSizeH = $this->paper->getHeight(); + + return $this; + } + /** * Set Setting Value * diff --git a/src/PhpWord/Writer/RTF/Style/Border.php b/src/PhpWord/Writer/RTF/Style/Border.php index 8df6d165e4..8bb9703f43 100644 --- a/src/PhpWord/Writer/RTF/Style/Border.php +++ b/src/PhpWord/Writer/RTF/Style/Border.php @@ -17,8 +17,6 @@ namespace PhpOffice\PhpWord\Writer\RTF\Style; -use PhpOffice\PhpWord\Shared\XMLWriter; - /** * Border style writer * diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index dd7273cb0f..de58294853 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -35,13 +35,13 @@ public function testSettingValue() $oSettings = new Section(); $this->assertEquals('portrait', $oSettings->getOrientation()); - $this->assertEquals(11906, $oSettings->getPageSizeW()); - $this->assertEquals(16838, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeH()); $oSettings->setSettingValue('orientation', 'landscape'); $this->assertEquals('landscape', $oSettings->getOrientation()); - $this->assertEquals(16838, $oSettings->getPageSizeW()); - $this->assertEquals(11906, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeH()); $iVal = rand(1, 1000); $oSettings->setSettingValue('borderSize', $iVal); @@ -106,8 +106,8 @@ public function testOrientationLandscape() $oSettings->setLandscape(); $this->assertEquals('landscape', $oSettings->getOrientation()); - $this->assertEquals(16838, $oSettings->getPageSizeW()); - $this->assertEquals(11906, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeH()); } /** @@ -120,8 +120,8 @@ public function testOrientationPortrait() $oSettings->setPortrait(); $this->assertEquals('portrait', $oSettings->getOrientation()); - $this->assertEquals(11906, $oSettings->getPageSizeW()); - $this->assertEquals(16838, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeH()); } /** From 09a143fe71334bb599db1833b929b87972bf227d Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 6 Jun 2014 18:56:09 +0700 Subject: [PATCH 016/174] QA: Type check fix for RTF section style and docblock comment fix for AbstractContainer --- src/PhpWord/Element/AbstractContainer.php | 34 +++++++++++------------ src/PhpWord/Writer/RTF/Style/Section.php | 18 ++++++------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 7afdbb4728..701b888ce6 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -23,23 +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) - * @method Shape addObject($type, $style = null) + * @method Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null) + * @method TextRun addTextRun(mixed $pStyle = null) + * @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null) + * @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null) + * @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null) + * @method ListItem addListItem(string $text, int $depth = 0, mixed $fStyle = null, mixed $listStyle = null, mixed $pStyle = null) + * @method ListItemRun addListItemRun(int $depth = 0, mixed $listStyle = null, mixed $pStyle = null) + * @method Footnote addFootnote(mixed $pStyle = null) + * @method Endnote addEndnote(mixed $pStyle = null) + * @method CheckBox addCheckBox(string $name, $text, mixed $fStyle = null, mixed $pStyle = null) + * @method Table addTable(mixed $style = null) + * @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false) + * @method Object addObject(string $source, mixed $style = null) + * @method TextBox addTextBox(mixed $style = null) + * @method Field addField(string $type = null, array $properties = array(), array $options = array()) + * @method Line addLine(mixed $lineStyle = null) + * @method Shape addObject(string $type, mixed $style = null) * * @since 0.10.0 */ diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index b556e299e9..4169b630cc 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -43,16 +43,16 @@ public function write() $content .= '\sectd '; // Size & margin - $content .= $this->getValueIf($style->getPageSizeW(), '\pgwsxn' . $style->getPageSizeW()); - $content .= $this->getValueIf($style->getPageSizeH(), '\pghsxn' . $style->getPageSizeH()); + $content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . $style->getPageSizeW()); + $content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . $style->getPageSizeH()); $content .= ' '; - $content .= $this->getValueIf($style->getMarginTop(), '\margtsxn' . $style->getMarginTop()); - $content .= $this->getValueIf($style->getMarginRight(), '\margrsxn' . $style->getMarginRight()); - $content .= $this->getValueIf($style->getMarginBottom(), '\margbsxn' . $style->getMarginBottom()); - $content .= $this->getValueIf($style->getMarginLeft(), '\marglsxn' . $style->getMarginLeft()); - $content .= $this->getValueIf($style->getHeaderHeight(), '\headery' . $style->getHeaderHeight()); - $content .= $this->getValueIf($style->getFooterHeight(), '\footery' . $style->getFooterHeight()); - $content .= $this->getValueIf($style->getGutter(), '\guttersxn' . $style->getGutter()); + $content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop()); + $content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight()); + $content .= $this->getValueIf($style->getMarginBottom() !== null, '\margbsxn' . $style->getMarginBottom()); + $content .= $this->getValueIf($style->getMarginLeft() !== null, '\marglsxn' . $style->getMarginLeft()); + $content .= $this->getValueIf($style->getHeaderHeight() !== null, '\headery' . $style->getHeaderHeight()); + $content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . $style->getFooterHeight()); + $content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . $style->getGutter()); $content .= ' '; // Borders From 8b0472dd528f5ab236a5a5b1b3e0cab55920cdec Mon Sep 17 00:00:00 2001 From: Brandon Skrtich Date: Fri, 6 Jun 2014 13:34:01 -0600 Subject: [PATCH 017/174] Autoloader Options Add the ability to set the autoloader options. --- src/PhpWord/Autoloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index c467f836c3..d7e154bb85 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -30,9 +30,9 @@ class Autoloader * * @return void */ - public static function register() + public static function register($throw = true, $prepend = false) { - spl_autoload_register(array(new self, 'autoload')); + spl_autoload_register(array(new self, 'autoload'), $throw, $prepend); } /** From 01853f7aacde43a071be45d8410b1667905bc878 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 7 Jun 2014 17:48:45 +0700 Subject: [PATCH 018/174] Update change log and adjust some coding standards for #261, #265, and #267 --- CHANGELOG.md | 4 +++- src/PhpWord/Autoloader.php | 2 ++ src/PhpWord/Shared/ZipArchive.php | 15 +++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb0a6c20a5..a2f52bded4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Bugfixes -None yet. +- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 ### Deprecated @@ -23,6 +23,8 @@ None yet. ### Miscellaneous - Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 +- PclZip: Remove temporary file after used - @andrew-kzoo GH-265 +- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 ## 0.11.1 - 2 June 2014 diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index d7e154bb85..dbc4218705 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -28,6 +28,8 @@ class Autoloader /** * Register * + * @param bool $throw + * @param bool $prepend * @return void */ public static function register($throw = true, $prepend = false) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 2e6daa1320..7515c5b50a 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -218,18 +218,21 @@ public function pclzipAddFile($filename, $localname = null) { /** @var \PclZip $zip Type hint */ $zip = $this->zip; - $test_filename = realpath($filename); - if($test_filename !== false) { - $filename = $test_filename; + + // Bugfix GH-261 https://github.com/PHPOffice/PHPWord/pull/261 + $realpathFilename = realpath($filename); + if ($realpathFilename !== false) { + $filename = $realpathFilename; } + $filenameParts = pathinfo($filename); $localnameParts = pathinfo($localname); // To Rename the file while adding it to the zip we // need to create a temp file with the correct name - $temp_file = false; + $tempFile = false; if ($filenameParts['basename'] != $localnameParts['basename']) { - $temp_file = true; // temp file created + $tempFile = true; // temp file created $temppath = $this->tempDir . '/' . $localnameParts['basename']; copy($filename, $temppath); $filename = $temppath; @@ -241,7 +244,7 @@ public function pclzipAddFile($filename, $localname = null) $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); - if($temp_file) { + if ($tempFile) { // Remove temp file, if created @unlink($this->tempDir . '/' . $localnameParts["basename"]); } From 893843969f3906824484a75ee98885d3c1c77e5a Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 02:31:44 +0700 Subject: [PATCH 019/174] Refactor elements to move set relation Id from container to element --- CHANGELOG.md | 5 +- src/PhpWord/Element/AbstractContainer.php | 90 ++------------- src/PhpWord/Element/AbstractElement.php | 108 +++++++++++++++++- src/PhpWord/Element/Footnote.php | 8 ++ src/PhpWord/Element/Image.php | 7 ++ src/PhpWord/Element/Link.php | 38 ++++-- src/PhpWord/Element/Object.php | 7 ++ src/PhpWord/Element/Row.php | 4 +- src/PhpWord/Element/Section.php | 34 ------ src/PhpWord/Element/Table.php | 4 +- src/PhpWord/Element/Title.php | 7 ++ src/PhpWord/Reader/Word2007/AbstractPart.php | 4 +- src/PhpWord/Writer/HTML/Element/Link.php | 2 +- src/PhpWord/Writer/ODText/Element/Link.php | 2 +- src/PhpWord/Writer/RTF/Element/Link.php | 2 +- src/PhpWord/Writer/Word2007/Style/Font.php | 6 +- .../Writer/Word2007/Style/Paragraph.php | 4 +- tests/PhpWord/Tests/Element/LinkTest.php | 6 +- .../PhpWord/Tests/Element/ListItemRunTest.php | 4 +- tests/PhpWord/Tests/Element/TextRunTest.php | 4 +- tests/PhpWord/Tests/Style/SectionTest.php | 1 + 21 files changed, 195 insertions(+), 152 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f52bded4..7acfeceeba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ## 0.12.0 - Not yet released +This release added drawing shapes (arc, curve, line, polyline, rect, oval) element and some new styles. + ### Features - Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 @@ -18,13 +20,14 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Deprecated -None yet. +- `Element\Link::getTarget()` replaced by `Element\Link::getSource()` ### Miscellaneous - Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 - PclZip: Remove temporary file after used - @andrew-kzoo GH-265 - Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 +- Element: Refactor elements to move set relation Id from container to element - @ivanlanin ## 0.11.1 - 2 June 2014 diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 701b888ce6..64c4b768da 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -17,9 +17,6 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Media; -use PhpOffice\PhpWord\PhpWord; - /** * Container abstract class * @@ -33,6 +30,10 @@ * @method Footnote addFootnote(mixed $pStyle = null) * @method Endnote addEndnote(mixed $pStyle = null) * @method CheckBox addCheckBox(string $name, $text, mixed $fStyle = null, mixed $pStyle = null) + * @method Title addTitle(string $text, int $depth = 1) + * @method TOC addTOC(mixed $fontStyle = null, mixed $tocStyle = null, int $minDepth = 1, int $maxDepth = 9) + * + * @method PageBreak addPageBreak() * @method Table addTable(mixed $style = null) * @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false) * @method Object addObject(string $source, mixed $style = null) @@ -125,10 +126,6 @@ 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); @@ -138,15 +135,10 @@ protected function addElement($elementName) /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */ $element = $reflection->newInstanceArgs($elementArgs); - // 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()); + // Set parent container + $element->setParentContainer($this); $element->setElementIndex($this->countElements() + 1); $element->setElementId(); - $element->setPhpWord($this->phpWord); $this->elements[] = $element; @@ -173,55 +165,6 @@ 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 \PhpOffice\PhpWord\Element\AbstractElement $element - * @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); - } - } - /** * Check if a method is allowed for the current container * @@ -254,6 +197,9 @@ private function checkValidity($method) 'Footnote' => array('Section', 'TextRun', 'Cell'), 'Endnote' => array('Section', 'TextRun', 'Cell'), 'PreserveText' => array('Header', 'Footer', 'Cell'), + 'Title' => array('Section'), + 'TOC' => array('Section'), + 'PageBreak' => array('Section'), ); // Special condition, e.g. preservetext can only exists in cell when // the cell is located in header or footer @@ -284,24 +230,6 @@ private function checkValidity($method) return true; } - /** - * Return media element (image, object, link) container name - * - * @return string section|headerx|footerx|footnote|endnote - */ - private function getMediaContainer() - { - $partName = $this->container; - if (in_array($partName, array('Cell', 'TextRun', 'TextBox', 'ListItemRun'))) { - $partName = $this->getDocPart(); - } - if ($partName == 'Header' || $partName == 'Footer') { - $partName .= $this->getDocPartId(); - } - - return strtolower($partName); - } - /** * Add memory image element * diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index c8e574b7e5..623f6bfb25 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style; @@ -42,7 +43,7 @@ abstract class AbstractElement protected $sectionId; /** - * Document part type: section|header|footer + * Document part type: Section|Header|Footer|Footnote|Endnote * * Used by textrun and cell container to determine where the element is * located because it will affect the availability of other element, @@ -93,6 +94,27 @@ abstract class AbstractElement */ private $nestedLevel = 0; + /** + * Parent container type + * + * @var string + */ + private $parentContainer; + + /** + * Has media relation flag; true for Link, Image, and Object + * + * @var bool + */ + protected $mediaRelation = false; + + /** + * Is part of collection; true for Title, Footnote, and Endnote + * + * @var bool + */ + protected $collectionRelation = false; + /** * Get PhpWord * @@ -155,6 +177,21 @@ public function getDocPartId() return $this->docPartId; } + /** + * Return media element (image, object, link) container name + * + * @return string section|headerx|footerx|footnote|endnote + */ + private function getMediaPart() + { + $mediaPart = $this->docPart; + if ($mediaPart == 'Header' || $mediaPart == 'Footer') { + $mediaPart .= $this->docPartId; + } + + return strtolower($mediaPart); + } + /** * Get element index * @@ -224,13 +261,74 @@ public function getNestedLevel() } /** - * Set nested level + * Set parent container * - * @param int $value + * Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell) + * + * @param \PhpOffice\PhpWord\Element\AbstractElement $container */ - public function setNestedLevel($value) + public function setParentContainer(AbstractElement $container) { - $this->nestedLevel = $value; + $this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1); + + // Set nested level + $this->nestedLevel = $container->getNestedLevel(); + if ($this->parentContainer == 'Cell') { + $this->nestedLevel++; + } + + // Set phpword + $phpWord = $container->getPhpWord(); + $this->setPhpWord($phpWord); + + // Set doc part + if (!$this instanceof Footnote) { + $this->setDocPart($container->getDocPart(), $container->getDocPartId()); + } + + $this->setMediaRelation(); + $this->setCollectionRelation(); + } + + /** + * Set relation Id for media elements (link, image, object; legacy of OOXML) + * + * - Image element needs to be passed to Media object + * - Icon needs to be set for Object element + */ + private function setMediaRelation() + { + if ($this->mediaRelation === false) { + return; + } + + $mediaPart = $this->getMediaPart(); + $elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1); + + /** @var \PhpOffice\PhpWord\Element\Image $this Type hint */ + $source = $this->getSource(); + $image = ($elementName == 'Image') ? $this : null; + $rId = Media::addElement($mediaPart, strtolower($elementName), $source, $image); + $this->setRelationId($rId); + + if ($elementName == 'Object') { + /** @var \PhpOffice\PhpWord\Element\Object $this Type hint */ + $rId = Media::addElement($mediaPart, 'image', $this->getIcon(), new Image($this->getIcon())); + $this->setImageRelationId($rId); + } + } + + /** + * Set relation Id for elements that will be registered in the Collection subnamespaces + */ + private function setCollectionRelation() + { + if ($this->collectionRelation === true && $this->phpWord instanceof PhpWord) { + $elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1); + $addMethod = "add{$elementName}"; + $rId = $this->phpWord->$addMethod($this); + $this->setRelationId($rId); + } } /** diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index 76311c6bbd..82bcd88f4c 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -36,6 +36,13 @@ class Footnote extends AbstractContainer */ protected $paragraphStyle; + /** + * Is part of collection; true for Title, Footnote, and Endnote + * + * @var bool + */ + protected $collectionRelation = true; + /** * Create new instance * @@ -44,6 +51,7 @@ class Footnote extends AbstractContainer public function __construct($paragraphStyle = null) { $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->setDocPart($this->container); } /** diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index a1cb8250f7..3d6a554573 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -111,6 +111,13 @@ class Image extends AbstractElement */ private $mediaIndex; + /** + * Has media relation flag; true for Link, Image, and Object + * + * @var bool + */ + protected $mediaRelation = true; + /** * Create new image element * diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 3ffe58d4a4..d962a3b510 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -27,11 +27,11 @@ class Link extends AbstractElement { /** - * Link target + * Link source * * @var string */ - private $target; + private $source; /** * Link text @@ -54,19 +54,25 @@ class Link extends AbstractElement */ private $paragraphStyle; + /** + * Has media relation flag; true for Link, Image, and Object + * + * @var bool + */ + protected $mediaRelation = true; /** * Create a new Link Element * - * @param string $target + * @param string $source * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle */ - public function __construct($target, $text = null, $fontStyle = null, $paragraphStyle = null) + public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null) { - $this->target = String::toUTF8($target); - $this->text = is_null($text) ? $this->target : String::toUTF8($text); + $this->source = String::toUTF8($source); + $this->text = is_null($text) ? $this->source : String::toUTF8($text); $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); @@ -74,13 +80,13 @@ public function __construct($target, $text = null, $fontStyle = null, $paragraph } /** - * Get link target + * Get link source * * @return string */ - public function getTarget() + public function getSource() { - return $this->target; + return $this->source; } /** @@ -113,6 +119,18 @@ public function getParagraphStyle() return $this->paragraphStyle; } + /** + * Get link target + * + * @return string + * @deprecated 0.12.0 + * @codeCoverageIgnore + */ + public function getTarget() + { + return $this->source; + } + /** * Get Link source * @@ -122,7 +140,7 @@ public function getParagraphStyle() */ public function getLinkSrc() { - return $this->getTarget(); + return $this->getSource(); } /** diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index a63c186936..ca3ecdf187 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -53,6 +53,13 @@ class Object extends AbstractElement */ private $imageRelationId; + /** + * Has media relation flag; true for Link, Image, and Object + * + * @var bool + */ + protected $mediaRelation = true; + /** * Create a new Ole-Object Element * diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index d7dcea3443..acbb75dc8c 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -69,9 +69,7 @@ public function __construct($height = null, $style = null) 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()); + $cell->setParentContainer($this); $this->cells[] = $cell; return $cell; diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index b7cee6a2df..6fc6333270 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -92,40 +92,6 @@ 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) - { - return $this->addElement('Title', $text, $depth); - } - - /** - * Add a PageBreak Element - */ - public function addPageBreak() - { - return $this->addElement('PageBreak'); - } - - /** - * Add a Table-of-Contents Element - * - * @param mixed $fontStyle - * @param mixed $tocStyle - * @param integer $minDepth - * @param integer $maxDepth - * @return \PhpOffice\PhpWord\Element\TOC - */ - public function addTOC($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9) - { - return $this->addElement('TOC', $fontStyle, $tocStyle, $minDepth, $maxDepth); - } - /** * Add header * diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index ace634607d..2d59073e54 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -65,9 +65,7 @@ public function __construct($style = null) 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()); + $row->setParentContainer($this); $this->rows[] = $row; return $row; diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index d5206879dc..a4faeb70a1 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -46,6 +46,13 @@ class Title extends AbstractElement */ private $style; + /** + * Is part of collection; true for Title, Footnote, and Endnote + * + * @var bool + */ + protected $collectionRelation = true; + /** * Create a new Title Element * diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index a7261d6d9d..ac26dee58e 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -483,8 +483,8 @@ private function readStyleDef($method, $attributeValue, $expected) $style = true; } elseif ($method == self::READ_FALSE) { $style = false; - } elseif ($method == self::READ_EQUAL && $attributeValue == $expected) { - $style = true; + } elseif ($method == self::READ_EQUAL) { + $style = $attributeValue == $expected; } return $style; diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php index d1256eb066..4e99810c7b 100644 --- a/src/PhpWord/Writer/HTML/Element/Link.php +++ b/src/PhpWord/Writer/HTML/Element/Link.php @@ -37,7 +37,7 @@ public function write() $content = ''; $content .= $this->writeOpening(); - $content .= "element->getTarget()}\">{$this->element->getText()}"; + $content .= "element->getSource()}\">{$this->element->getText()}"; $content .= $this->writeClosing(); return $content; diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php index 79d3aa246f..adb64f8599 100644 --- a/src/PhpWord/Writer/ODText/Element/Link.php +++ b/src/PhpWord/Writer/ODText/Element/Link.php @@ -41,7 +41,7 @@ public function write() $xmlWriter->startElement('text:a'); $xmlWriter->writeAttribute('xlink:type', 'simple'); - $xmlWriter->writeAttribute('xlink:href', $element->getTarget()); + $xmlWriter->writeAttribute('xlink:href', $element->getSource()); $xmlWriter->writeRaw($element->getText()); $xmlWriter->endElement(); // text:a diff --git a/src/PhpWord/Writer/RTF/Element/Link.php b/src/PhpWord/Writer/RTF/Element/Link.php index 22b085886c..adbc7976ce 100644 --- a/src/PhpWord/Writer/RTF/Element/Link.php +++ b/src/PhpWord/Writer/RTF/Element/Link.php @@ -39,7 +39,7 @@ public function write() $content = ''; $content .= $this->writeOpening(); - $content .= '{\field {\*\fldinst {HYPERLINK "' . $this->element->getTarget() . '"}}{\\fldrslt {'; + $content .= '{\field {\*\fldinst {HYPERLINK "' . $this->element->getSource() . '"}}{\\fldrslt {'; $content .= $this->writeFontStyle(); $content .= $this->writeText($this->element->getText()); $content .= '}}}'; diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 73673f05ca..6eb38dc26b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -64,8 +64,10 @@ private function writeStyle() $xmlWriter->startElement('w:rPr'); // Style name - $styleName = $style->getStyleName(); - $xmlWriter->writeElementIf(!is_null($styleName), 'w:rStyle', 'w:val', $styleName); + if ($this->isInline === true) { + $styleName = $style->getStyleName(); + $xmlWriter->writeElementIf($styleName !== null, 'w:rStyle', 'w:val', $styleName); + } // Font name/family $font = $style->getName(); diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 4ccba00f3a..f8d6cf1e58 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -83,7 +83,9 @@ private function writeStyle() } // Style name - $xmlWriter->writeElementIf($styles['name'] !== null, 'w:pStyle', 'w:val', $styles['name']); + if ($this->isInline === true) { + $xmlWriter->writeElementIf($styles['name'] !== null, 'w:pStyle', 'w:val', $styles['name']); + } // Alignment $styleWriter = new Alignment($xmlWriter, new AlignmentStyle(array('value' => $styles['alignment']))); diff --git a/tests/PhpWord/Tests/Element/LinkTest.php b/tests/PhpWord/Tests/Element/LinkTest.php index 0e582b13ca..ada6a36a9f 100644 --- a/tests/PhpWord/Tests/Element/LinkTest.php +++ b/tests/PhpWord/Tests/Element/LinkTest.php @@ -36,8 +36,8 @@ public function testConstructDefault() $oLink = new Link('http://www.google.com'); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $oLink); - $this->assertEquals($oLink->getTarget(), 'http://www.google.com'); - $this->assertEquals($oLink->getText(), $oLink->getTarget()); + $this->assertEquals($oLink->getSource(), 'http://www.google.com'); + $this->assertEquals($oLink->getText(), $oLink->getSource()); $this->assertEquals($oLink->getFontStyle(), null); $this->assertEquals($oLink->getParagraphStyle(), null); } @@ -55,7 +55,7 @@ public function testConstructWithParamsArray() ); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $oLink); - $this->assertEquals($oLink->getTarget(), 'http://www.google.com'); + $this->assertEquals($oLink->getSource(), 'http://www.google.com'); $this->assertEquals($oLink->getText(), 'Search Engine'); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oLink->getFontStyle()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle()); diff --git a/tests/PhpWord/Tests/Element/ListItemRunTest.php b/tests/PhpWord/Tests/Element/ListItemRunTest.php index 37d679f93b..7bb0c25d71 100644 --- a/tests/PhpWord/Tests/Element/ListItemRunTest.php +++ b/tests/PhpWord/Tests/Element/ListItemRunTest.php @@ -131,7 +131,7 @@ public function testAddLink() $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); $this->assertCount(1, $oListItemRun->getElements()); - $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + $this->assertEquals($element->getSource(), 'http://www.google.fr'); } /** @@ -144,7 +144,7 @@ public function testAddLinkWithName() $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); $this->assertCount(1, $oListItemRun->getElements()); - $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + $this->assertEquals($element->getSource(), 'http://www.google.fr'); $this->assertEquals($element->getText(), 'ééé'); } diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index 870214dde1..de62a920da 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -99,7 +99,7 @@ public function testAddLink() $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + $this->assertEquals($element->getSource(), 'http://www.google.fr'); } /** @@ -112,7 +112,7 @@ public function testAddLinkWithName() $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element); $this->assertCount(1, $oTextRun->getElements()); - $this->assertEquals($element->getTarget(), 'http://www.google.fr'); + $this->assertEquals($element->getSource(), 'http://www.google.fr'); $this->assertEquals($element->getText(), 'ééé'); } diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index de58294853..8e8c1e8794 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -37,6 +37,7 @@ public function testSettingValue() $this->assertEquals('portrait', $oSettings->getOrientation()); $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeW()); $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeH()); + $this->assertEquals('A4', $oSettings->getPaperSize()); $oSettings->setSettingValue('orientation', 'landscape'); $this->assertEquals('landscape', $oSettings->getOrientation()); From a9c9c21d3bf0b4b7590fbae2ab98b9fd6e3b9b44 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 03:38:53 +0700 Subject: [PATCH 020/174] Fix Travis test error --- src/PhpWord/Element/AbstractContainer.php | 3 ++- src/PhpWord/Element/AbstractElement.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 64c4b768da..5093d3f4d3 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -76,7 +76,8 @@ public function __call($function, $args) { $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', - 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape'); + 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape', + 'Title', 'TOC', 'PageBreak'); $functions = array(); for ($i = 0; $i < count($elements); $i++) { $functions[$i] = 'add' . $elements[$i]; diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 623f6bfb25..4110351d30 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -298,22 +298,23 @@ public function setParentContainer(AbstractElement $container) */ private function setMediaRelation() { - if ($this->mediaRelation === false) { + if (!$this instanceof Link && !$this instanceof Image && !$this instanceof Object) { return; } - $mediaPart = $this->getMediaPart(); $elementName = substr(get_class($this), strrpos(get_class($this), '\\') + 1); - - /** @var \PhpOffice\PhpWord\Element\Image $this Type hint */ + $mediaPart = $this->getMediaPart(); $source = $this->getSource(); - $image = ($elementName == 'Image') ? $this : null; + $image = null; + if ($this instanceof Image) { + $image = $this; + } $rId = Media::addElement($mediaPart, strtolower($elementName), $source, $image); $this->setRelationId($rId); - if ($elementName == 'Object') { - /** @var \PhpOffice\PhpWord\Element\Object $this Type hint */ - $rId = Media::addElement($mediaPart, 'image', $this->getIcon(), new Image($this->getIcon())); + if ($this instanceof Object) { + $icon = $this->getIcon(); + $rId = Media::addElement($mediaPart, 'image', $icon, new Image($icon)); $this->setImageRelationId($rId); } } From 63d53ac910bb599a77e2fb699da4ea3f23df2978 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 16:44:46 +0700 Subject: [PATCH 021/174] Use section "style" instead of "settings" for consistency --- CHANGELOG.md | 1 + docs/containers.rst | 20 +++---- docs/general.rst | 2 +- docs/src/documentation.md | 22 +++---- src/PhpWord/Element/AbstractElement.php | 4 +- src/PhpWord/Element/Cell.php | 2 +- src/PhpWord/Element/Endnote.php | 2 +- src/PhpWord/Element/Footnote.php | 2 +- src/PhpWord/Element/Image.php | 2 +- src/PhpWord/Element/Line.php | 2 +- src/PhpWord/Element/Link.php | 4 +- src/PhpWord/Element/ListItem.php | 2 +- src/PhpWord/Element/ListItemRun.php | 4 +- src/PhpWord/Element/Object.php | 2 +- src/PhpWord/Element/PreserveText.php | 4 +- src/PhpWord/Element/Row.php | 2 +- src/PhpWord/Element/Section.php | 59 ++++++++++++------- src/PhpWord/Element/Shape.php | 2 +- src/PhpWord/Element/Table.php | 2 +- src/PhpWord/Element/TextBox.php | 2 +- src/PhpWord/Element/TextRun.php | 2 +- src/PhpWord/PhpWord.php | 6 +- src/PhpWord/Reader/Word2007/Document.php | 6 +- src/PhpWord/Writer/ODText/Part/Content.php | 2 +- src/PhpWord/Writer/RTF/Part/Document.php | 2 +- src/PhpWord/Writer/RTF/Part/Header.php | 2 +- src/PhpWord/Writer/Word2007/Part/Document.php | 2 +- tests/PhpWord/Tests/Element/SectionTest.php | 12 ++-- .../Writer/Word2007/Part/DocumentTest.php | 10 ++-- 29 files changed, 103 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acfeceeba..19d9934806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme ### Deprecated - `Element\Link::getTarget()` replaced by `Element\Link::getSource()` +- `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` ### Miscellaneous diff --git a/docs/containers.rst b/docs/containers.rst index 30566df647..df04e65849 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -32,7 +32,7 @@ section. Example: Section settings ~~~~~~~~~~~~~~~~ -Below are the available settings for section: +Below are the available styles for section: - ``orientation`` Page orientation, i.e. 'portrait' (default) or 'landscape' @@ -56,8 +56,8 @@ Below are the available settings for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two settings are automatically set by the use of the -``orientation`` setting. You can alter them but that's not recommended. +The following two styles are automatically set by the use of the +``orientation`` style. You can alter them but that's not recommended. - ``pageSizeW`` Page width in twips - ``pageSizeH`` Page height in twips @@ -66,7 +66,7 @@ Page number ~~~~~~~~~~~ You can change a section page number by using the ``pageNumberingStart`` -property of the section. +style of the section. .. code-block:: php @@ -75,13 +75,13 @@ property of the section. // Method 2 $section = $phpWord->addSection(); - $section->getSettings()->setPageNumberingStart(1); + $section->getStyle()->setPageNumberingStart(1); Multicolumn ~~~~~~~~~~~ You can change a section layout to multicolumn (like in a newspaper) by -using the ``breakType`` and ``colsNum`` property of the section. +using the ``breakType`` and ``colsNum`` style of the section. .. code-block:: php @@ -90,14 +90,14 @@ using the ``breakType`` and ``colsNum`` property of the section. // Method 2 $section = $phpWord->addSection(); - $section->getSettings()->setBreakType('continuous'); - $section->getSettings()->setColsNum(2); + $section->getStyle()->setBreakType('continuous'); + $section->getStyle()->setColsNum(2); ### Line numbering You can apply line numbering to a section by using the ``lineNumbering`` -property of the section. +style of the section. .. code-block:: php @@ -106,7 +106,7 @@ property of the section. // Method 2 $section = $phpWord->addSection(); - $section->getSettings()->setLineNumbering(array()); + $section->getStyle()->setLineNumbering(array()); Below are the properties of the line numbering style. diff --git a/docs/general.rst b/docs/general.rst index f08e29badd..270608f7ed 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -138,7 +138,7 @@ points to twips. ); $section = $phpWord->addSection(); - $sectionStyle = $section->getSettings(); + $sectionStyle = $section->getStyle(); // half inch left margin $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); // 2 cm right margin diff --git a/docs/src/documentation.md b/docs/src/documentation.md index e971640144..e0f00dac88 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -304,7 +304,7 @@ $phpWord->addParagraphStyle('My Style', array( ); $section = $phpWord->addSection(); -$sectionStyle = $section->getSettings(); +$sectionStyle = $section->getStyle(); // half inch left margin $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); // 2 cm right margin @@ -333,9 +333,9 @@ $sectionSettings = array( ); ``` -### Section settings +### Section style -Below are the available settings for section: +Below are the available styles for section: - `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape' - `marginTop` Page margin top in twips @@ -357,14 +357,14 @@ Below are the available settings for section: - `colsSpace` Spacing between columns - `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two settings are automatically set by the use of the `orientation` setting. You can alter them but that's not recommended. +The following two styles are automatically set by the use of the `orientation` style. You can alter them but that's not recommended. - `pageSizeW` Page width in twips - `pageSizeH` Page height in twips ### Page number -You can change a section page number by using the `pageNumberingStart` property of the section. +You can change a section page number by using the `pageNumberingStart` style of the section. ```php // Method 1 @@ -372,12 +372,12 @@ $section = $phpWord->addSection(array('pageNumberingStart' => 1)); // Method 2 $section = $phpWord->addSection(); -$section->getSettings()->setPageNumberingStart(1); +$section->getStyle()->setPageNumberingStart(1); ``` ### Multicolumn -You can change a section layout to multicolumn (like in a newspaper) by using the `breakType` and `colsNum` property of the section. +You can change a section layout to multicolumn (like in a newspaper) by using the `breakType` and `colsNum` style of the section. ```php // Method 1 @@ -385,13 +385,13 @@ $section = $phpWord->addSection(array('breakType' => 'continuous', 'colsNum' => // Method 2 $section = $phpWord->addSection(); -$section->getSettings()->setBreakType('continuous'); -$section->getSettings()->setColsNum(2); +$section->getStyle()->setBreakType('continuous'); +$section->getStyle()->setColsNum(2); ``` ### Line numbering -You can apply line numbering to a section by using the `lineNumbering` property of the section. +You can apply line numbering to a section by using the `lineNumbering` style of the section. ```php // Method 1 @@ -399,7 +399,7 @@ $section = $phpWord->addSection(array('lineNumbering' => array())); // Method 2 $section = $phpWord->addSection(); -$section->getSettings()->setLineNumbering(array()); +$section->getStyle()->setLineNumbering(array()); ``` Below are the properties of the line numbering style. diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 4110351d30..fe133fddf5 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -343,14 +343,14 @@ public function isInSection() } /** - * Set style value + * Set new style value * * @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) + protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false) { if (!is_null($styleValue) && is_array($styleValue)) { $styleObject->setStyleByArray($styleValue); diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index ea49bc7bc8..cac37a7804 100644 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -52,7 +52,7 @@ class Cell extends AbstractContainer public function __construct($width = null, $style = null) { $this->width = $width; - $this->style = $this->setStyle(new CellStyle(), $style, true); + $this->style = $this->setNewStyle(new CellStyle(), $style, true); } /** diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php index 20278898f8..1000055520 100644 --- a/src/PhpWord/Element/Endnote.php +++ b/src/PhpWord/Element/Endnote.php @@ -38,6 +38,6 @@ class Endnote extends Footnote */ public function __construct($paragraphStyle = null) { - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); } } diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index 82bcd88f4c..e263933cf7 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -50,7 +50,7 @@ class Footnote extends AbstractContainer */ public function __construct($paragraphStyle = null) { - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->setDocPart($this->container); } diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 3d6a554573..532905f428 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -131,7 +131,7 @@ public function __construct($source, $style = null, $watermark = false) { $this->source = $source; $this->setIsWatermark($watermark); - $this->style = $this->setStyle(new ImageStyle(), $style, true); + $this->style = $this->setNewStyle(new ImageStyle(), $style, true); $this->checkImage($source); } diff --git a/src/PhpWord/Element/Line.php b/src/PhpWord/Element/Line.php index 4acca8eda3..b76ac4fb32 100644 --- a/src/PhpWord/Element/Line.php +++ b/src/PhpWord/Element/Line.php @@ -38,7 +38,7 @@ class Line extends AbstractElement */ public function __construct($style = null) { - $this->style = $this->setStyle(new LineStyle(), $style); + $this->style = $this->setNewStyle(new LineStyle(), $style); } /** diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index d962a3b510..4b00dc9047 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -73,8 +73,8 @@ public function __construct($source, $text = null, $fontStyle = null, $paragraph { $this->source = String::toUTF8($source); $this->text = is_null($text) ? $this->source : String::toUTF8($text); - $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle); - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); return $this; } diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 59bd83917c..4cb8d33952 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -64,7 +64,7 @@ public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = n if (!is_null($listStyle) && is_string($listStyle)) { $this->style = new ListItemStyle($listStyle); } else { - $this->style = $this->setStyle(new ListItemStyle(), $listStyle, true); + $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true); } } diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php index fb219f91fb..82c6f1ab8c 100644 --- a/src/PhpWord/Element/ListItemRun.php +++ b/src/PhpWord/Element/ListItemRun.php @@ -59,9 +59,9 @@ public function __construct($depth = 0, $listStyle = null, $paragraphStyle = nul if (!is_null($listStyle) && is_string($listStyle)) { $this->style = new ListItemStyle($listStyle); } else { - $this->style = $this->setStyle(new ListItemStyle(), $listStyle, true); + $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true); } - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); } /** diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index ca3ecdf187..ae279ab020 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -79,7 +79,7 @@ public function __construct($source, $style = null) } $this->source = $source; - $this->style = $this->setStyle(new ImageStyle(), $style, true); + $this->style = $this->setNewStyle(new ImageStyle(), $style, true); $this->icon = realpath(__DIR__ . "/../resources/{$ext}.png"); return $this; diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 100385c93e..44aef3b40e 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -58,8 +58,8 @@ class PreserveText extends AbstractElement */ public function __construct($text = null, $fontStyle = null, $paragraphStyle = null) { - $this->fontStyle = $this->setStyle(new Font('text'), $fontStyle); - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->text = String::toUTF8($text); $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index acbb75dc8c..e2df632551 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -56,7 +56,7 @@ class Row extends AbstractElement public function __construct($height = null, $style = null) { $this->height = $height; - $this->style = $this->setStyle(new RowStyle(), $style, true); + $this->style = $this->setNewStyle(new RowStyle(), $style, true); } /** diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 6fc6333270..33c6979597 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Style\Section as SectionSettings; +use PhpOffice\PhpWord\Style\Section as SectionStyle; /** * Section @@ -31,11 +31,11 @@ class Section extends AbstractContainer protected $container = 'Section'; /** - * Section settings + * Section style * * @var \PhpOffice\PhpWord\Style\Section */ - private $settings; + private $style; /** * Section headers, indexed from 1, not zero @@ -55,41 +55,36 @@ class Section extends AbstractContainer * Create new instance * * @param int $sectionCount - * @param array $settings + * @param array $style */ - public function __construct($sectionCount, $settings = null) + public function __construct($sectionCount, $style = null) { $this->sectionId = $sectionCount; $this->setDocPart($this->container, $this->sectionId); - $this->settings = new SectionSettings(); - $this->setSettings($settings); + $this->style = new SectionStyle(); + $this->setStyle($style); } /** - * Set section settings + * Set section style * - * @param array $settings + * @param array $style */ - public function setSettings($settings = null) + public function setStyle($style = null) { - if (!is_null($settings) && is_array($settings)) { - foreach ($settings as $key => $value) { - if (is_null($value)) { - continue; - } - $this->settings->setSettingValue($key, $value); - } + if (!is_null($style) && is_array($style)) { + $this->style->setStyleByArray($style); } } /** - * Get Section Settings + * Get section style * * @return \PhpOffice\PhpWord\Style\Section */ - public function getSettings() + public function getStyle() { - return $this->settings; + return $this->style; } /** @@ -184,6 +179,30 @@ private function addHeaderFooter($type = Header::AUTO, $header = true) } + /** + * Set section style + * + * @param array $settings + * @deprecated 0.12.0 + * @codeCoverageIgnore + */ + public function setSettings($settings = null) + { + $this->setStyle($settings); + } + + /** + * Get section style + * + * @return \PhpOffice\PhpWord\Style\Section + * @deprecated 0.12.0 + * @codeCoverageIgnore + */ + public function getSettings() + { + return $this->getStyle(); + } + /** * Create header * diff --git a/src/PhpWord/Element/Shape.php b/src/PhpWord/Element/Shape.php index 9b3aae4ffe..a7a96d1884 100644 --- a/src/PhpWord/Element/Shape.php +++ b/src/PhpWord/Element/Shape.php @@ -49,7 +49,7 @@ class Shape extends AbstractElement public function __construct($type, $style = null) { $this->setType($type); - $this->style = $this->setStyle(new ShapeStyle(), $style); + $this->style = $this->setNewStyle(new ShapeStyle(), $style); } /** diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 2d59073e54..5e14d6bc4b 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -52,7 +52,7 @@ class Table extends AbstractElement */ public function __construct($style = null) { - $this->style = $this->setStyle(new TableStyle(), $style); + $this->style = $this->setNewStyle(new TableStyle(), $style); } /** diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php index 06c9518167..d929bf35db 100644 --- a/src/PhpWord/Element/TextBox.php +++ b/src/PhpWord/Element/TextBox.php @@ -45,7 +45,7 @@ class TextBox extends AbstractContainer */ public function __construct($style = null) { - $this->style = $this->setStyle(new TextBoxStyle(), $style); + $this->style = $this->setNewStyle(new TextBoxStyle(), $style); } /** diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index 7583710404..c356cfa8e1 100644 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -43,7 +43,7 @@ class TextRun extends AbstractContainer */ public function __construct($paragraphStyle = null) { - $this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); + $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); } /** diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index c54faa3615..e06080c16d 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -121,12 +121,12 @@ public function getSections() /** * Create new section * - * @param array $settings + * @param array $style * @return \PhpOffice\PhpWord\Element\Section */ - public function addSection($settings = null) + public function addSection($style = null) { - $section = new Section(count($this->sections) + 1, $settings); + $section = new Section(count($this->sections) + 1, $style); $section->setPhpWord($this); $this->sections[] = $section; diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index be804531d3..0208418924 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -175,8 +175,8 @@ private function readWPNode(XMLReader $xmlReader, \DOMElement $node, Section &$s */ private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section) { - $settings = $this->readSectionStyle($xmlReader, $node); - $section->setSettings($settings); - $this->readHeaderFooter($settings, $section); + $style = $this->readSectionStyle($xmlReader, $node); + $section->setStyle($style); + $this->readHeaderFooter($style, $section); } } diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index f16937a0e2..51326210ea 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -168,7 +168,7 @@ private function getAutoStyles(PhpWord $phpWord) $paragraphStyleCount = 0; $fontStyleCount = 0; foreach ($sections as $section) { - $style = $section->getSettings(); + $style = $section->getStyle(); $style->setStyleName("Section{$section->getSectionId()}"); $this->autoStyles['Section'][] = $style; $this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount); diff --git a/src/PhpWord/Writer/RTF/Part/Document.php b/src/PhpWord/Writer/RTF/Part/Document.php index 2f5c2f8e09..f0a9b8f20a 100644 --- a/src/PhpWord/Writer/RTF/Part/Document.php +++ b/src/PhpWord/Writer/RTF/Part/Document.php @@ -110,7 +110,7 @@ private function writeSections() $sections = $this->getParentWriter()->getPhpWord()->getSections(); foreach ($sections as $section) { - $styleWriter = new SectionStyleWriter($section->getSettings()); + $styleWriter = new SectionStyleWriter($section->getStyle()); $styleWriter->setParentWriter($this->getParentWriter()); $content .= $styleWriter->write(); diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index 32debb06b4..4d8d3a2726 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -193,7 +193,7 @@ private function registerFont() $sections = $phpWord->getSections(); foreach ($sections as $section) { $elements = $section->getElements(); - $this->registerBorderColor($section->getSettings()); + $this->registerBorderColor($section->getStyle()); foreach ($elements as $element) { if (method_exists($element, 'getFontStyle')) { $style = $element->getFontStyle(); diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 9957033859..e6639511af 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -128,7 +128,7 @@ private function writeSectionSettings(XMLWriter $xmlWriter, Section $section) } // Section settings - $styleWriter = new SectionStyleWriter($xmlWriter, $section->getSettings()); + $styleWriter = new SectionStyleWriter($xmlWriter, $section->getStyle()); $styleWriter->write(); $xmlWriter->endElement(); // w:sectPr diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index af7595e208..853ebc5d3f 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -31,12 +31,12 @@ class SectionTest extends \PHPUnit_Framework_TestCase { /** - * Get settings + * Get style */ - public function testGetSettings() + public function testGetStyle() { $oSection = new Section(0); - $this->assertAttributeEquals($oSection->getSettings(), 'settings', new Section(0)); + $this->assertAttributeEquals($oSection->getStyle(), 'style', new Section(0)); } /** @@ -69,12 +69,12 @@ public function testGetHeaders() /** * Set settings */ - public function testSetSettings() + public function testSetStyle() { $expected = 'landscape'; $object = new Section(0); - $object->setSettings(array('orientation' => $expected, 'foo' => null)); - $this->assertEquals($expected, $object->getSettings()->getOrientation()); + $object->setStyle(array('orientation' => $expected, 'foo' => null)); + $this->assertEquals($expected, $object->getStyle()->getOrientation()); } /** diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index fd36db25a0..de5d63e88b 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -45,11 +45,11 @@ public function testWriteEndSectionPageNumbering() $section = $phpWord->addSection(); $section->addHeader(); $section->addHeader('first'); - $settings = $section->getSettings(); - $settings->setLandscape(); - $settings->setPageNumberingStart(2); - $settings->setBorderSize(240); - $settings->setBreakType('nextPage'); + $style = $section->getStyle(); + $style->setLandscape(); + $style->setPageNumberingStart(2); + $style->setBorderSize(240); + $style->setBreakType('nextPage'); $doc = TestHelperDOCX::getDocument($phpWord); $element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType'); From 3197524343c3a60d24a268511f2c732b9dc4343b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 17:10:02 +0700 Subject: [PATCH 022/174] Docs: Restructure documentation --- docs/conf.py | 4 +- docs/containers.rst | 46 +---- docs/elements.rst | 116 +------------ docs/index.rst | 3 +- docs/{setup.rst => installing.rst} | 0 docs/src/documentation.md | 258 +++++++++++++++-------------- docs/styles.rst | 137 +++++++++++++++ 7 files changed, 287 insertions(+), 277 deletions(-) rename docs/{setup.rst => installing.rst} (100%) create mode 100644 docs/styles.rst diff --git a/docs/conf.py b/docs/conf.py index f5c38581f1..de645350d0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,14 +41,14 @@ # General information about the project. project = u'PhpWord' -copyright = u'2014, Progi1984' +copyright = u'2014, PHPWord Contributors' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.9.0' +version = '0.12.0' # The full version, including alpha/beta/rc tags. release = version diff --git a/docs/containers.rst b/docs/containers.rst index df04e65849..f165a58981 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -16,52 +16,19 @@ section, use the following code: .. code-block:: php - $section = $phpWord->addSection($sectionSettings); + $section = $phpWord->addSection($sectionStyle); -The ``$sectionSettings`` is an optional associative array that sets the +The ``$sectionStyle`` is an optional associative array that sets the section. Example: .. code-block:: php - $sectionSettings = array( + $sectionStyle = array( 'orientation' => 'landscape', 'marginTop' => 600, 'colsNum' => 2, ); -Section settings -~~~~~~~~~~~~~~~~ - -Below are the available styles for section: - -- ``orientation`` Page orientation, i.e. 'portrait' (default) or - 'landscape' -- ``marginTop`` Page margin top in twips -- ``marginLeft`` Page margin left in twips -- ``marginRight`` Page margin right in twips -- ``marginBottom`` Page margin bottom in twips -- ``borderTopSize`` Border top size in twips -- ``borderTopColor`` Border top color -- ``borderLeftSize`` Border left size in twips -- ``borderLeftColor`` Border left color -- ``borderRightSize`` Border right size in twips -- ``borderRightColor`` Border right color -- ``borderBottomSize`` Border bottom size in twips -- ``borderBottomColor`` Border bottom color -- ``headerHeight`` Spacing to top of header -- ``footerHeight`` Spacing to bottom of footer -- ``gutter`` Page gutter spacing -- ``colsNum`` Number of columns -- ``colsSpace`` Spacing between columns -- ``breakType`` Section break type (nextPage, nextColumn, continuous, - evenPage, oddPage) - -The following two styles are automatically set by the use of the -``orientation`` style. You can alter them but that's not recommended. - -- ``pageSizeW`` Page width in twips -- ``pageSizeH`` Page height in twips - Page number ~~~~~~~~~~~ @@ -93,8 +60,8 @@ using the ``breakType`` and ``colsNum`` style of the section. $section->getStyle()->setBreakType('continuous'); $section->getStyle()->setColsNum(2); - -### Line numbering +Line numbering +~~~~~~~~~~~~~~ You can apply line numbering to a section by using the ``lineNumbering`` style of the section. @@ -113,7 +80,8 @@ Below are the properties of the line numbering style. - ``start`` Line numbering starting value - ``increment`` Line number increments - ``distance`` Distance between text and line numbering in twip -- ``restart`` Line numbering restart setting continuous|newPage|newSection +- ``restart`` Line numbering restart setting + continuous\|newPage\|newSection Headers ------- diff --git a/docs/elements.rst b/docs/elements.rst index a3a8171721..a01c9fd421 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -47,7 +47,7 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 19 | Line | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ -| 20 | Shapes | v | v | v | v | v | v | +| 20 | Shape | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -73,9 +73,6 @@ as follow: $section->addText($text, [$fontStyle], [$paragraphStyle]); $textrun = $section->addTextRun([$paragraphStyle]); -Text styles -~~~~~~~~~~~ - You can use the ``$fontStyle`` and ``$paragraphStyle`` variable to define text formatting. There are 2 options to style the inserted text elements, i.e. inline style by using array or defined style by adding @@ -106,47 +103,6 @@ Defined style examples: $phpWord->addParagraphStyle('pStyle', $paragraphStyle); $text = $section->addText('Hello world!', 'pStyle'); -Font style -^^^^^^^^^^ - -Available font styles: - -- ``name`` Font name, e.g. *Arial* -- ``size`` Font size, e.g. *20*, *22*, -- ``hint`` Font content type, *default*, *eastAsia*, or *cs* -- ``bold`` Bold, *true* or *false* -- ``italic`` Italic, *true* or *false* -- ``superScript`` Superscript, *true* or *false* -- ``subScript`` Subscript, *true* or *false* -- ``underline`` Underline, *dash*, *dotted*, etc. -- ``strikethrough`` Strikethrough, *true* or *false* -- ``doubleStrikethrough`` Double strikethrough, *true* or *false* -- ``color`` Font color, e.g. *FF0000* -- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue* -- ``bgColor`` Font background color, e.g. *FF0000* -- ``smallCaps`` Small caps, *true* or *false* -- ``allCaps`` All caps, *true* or *false* - -Paragraph style -^^^^^^^^^^^^^^^ - -Available paragraph styles: - -- ``align`` Paragraph alignment, *left*, *right* or *center* -- ``spaceBefore`` Space before paragraph -- ``spaceAfter`` Space after paragraph -- ``indent`` Indent by how much -- ``hanging`` Hanging by how much -- ``basedOn`` Parent style -- ``next`` Style for next paragraph -- ``widowControl`` Allow first/last line to display on a separate page, - *true* or *false* -- ``keepNext`` Keep paragraph with next paragraph, *true* or *false* -- ``keepLines`` Keep all lines on one page, *true* or *false* -- ``pageBreakBefore`` Start paragraph on next page, *true* or *false* -- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect... -- ``tabs`` Set of custom tab stops - Titles ~~~~~~ @@ -209,9 +165,9 @@ Page breaks There are two ways to insert a page breaks, using the ``addPageBreak`` method or using the ``pageBreakBefore`` style of paragraph. -:: code-block:: php +.. code-block:: php - \\$section->addPageBreak(); + $section->addPageBreak(); Lists ----- @@ -254,23 +210,6 @@ You can also create your own numbering style by changing the $section->addListItem('List Item I.b', 1, null, 'multilevel'); $section->addListItem('List Item II', 0, null, 'multilevel'); -Level styles: - -- ``start`` Starting value -- ``format`` Numbering format - bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter -- ``restart`` Restart numbering level symbol -- ``suffix`` Content between numbering symbol and paragraph text - tab\|space\|nothing -- ``text`` Numbering level text e.g. %1 for nonbullet or bullet - character -- ``align`` Numbering symbol align left\|center\|right\|both -- ``left`` See paragraph style -- ``hanging`` See paragraph style -- ``tabPos`` See paragraph style -- ``font`` Font name -- ``hint`` See font style - Tables ------ @@ -296,34 +235,6 @@ Table style can be defined with ``addTableStyle``: $phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle); $table = $section->addTable('myTable'); -Table, row, and cell styles -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Table styles: - -- ``width`` Table width in percent -- ``bgColor`` Background color, e.g. '9966CC' -- ``border(Top|Right|Bottom|Left)Size`` Border size in twips -- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' -- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips - -Row styles: - -- ``tblHeader`` Repeat table row on every new page, *true* or *false* -- ``cantSplit`` Table row cannot break across pages, *true* or *false* -- ``exactHeight`` Row height is exact or at least - -Cell styles: - -- ``width`` Cell width in twips -- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom* -- ``textDirection`` Direction of text -- ``bgColor`` Background color, e.g. '9966CC' -- ``border(Top|Right|Bottom|Left)Size`` Border size in twips -- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' -- ``gridSpan`` Number of columns spanned -- ``vMerge`` *restart* or *continue* - Cell span ~~~~~~~~~ @@ -370,19 +281,6 @@ Examples: $textrun = $section->addTextRun(); $textrun->addImage('http://php.net/logo.jpg'); -Image styles -~~~~~~~~~~~~ - -Available image styles: - -- ``width`` Width in pixels -- ``height`` Height in pixels -- ``align`` Image alignment, *left*, *right*, or *center* -- ``marginTop`` Top margin in inches, can be negative -- ``marginLeft`` Left margin in inches, can be negative -- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*, - *behind*, or *infront* - Watermarks ~~~~~~~~~~ @@ -485,19 +383,19 @@ Checkbox elements can be added to sections or table cells by using Textboxes --------- -To be completed +To be completed. Fields ------ -To be completed +To be completed. Lines ----- -To be completed +To be completed. Shapes ------ -To be completed +To be completed. diff --git a/docs/index.rst b/docs/index.rst index fd3a3fa910..4f200cca79 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,10 +18,11 @@ Format (RTF). :maxdepth: 2 intro - setup + installing general containers elements + styles templates writersreaders recipes diff --git a/docs/setup.rst b/docs/installing.rst similarity index 100% rename from docs/setup.rst rename to docs/installing.rst diff --git a/docs/src/documentation.md b/docs/src/documentation.md index e0f00dac88..c76ec1f234 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -37,6 +37,11 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Fields](#fields) - [Lines](#lines) - [Shapes](#shapes) +- [Styles](#styles) + - [Section](#section) + - [Font](#font) + - [Paragraph](#paragraph) + - [Table](#table) - [Templates](#templates) - [Writers & readers](#writers-readers) - [OOXML](#ooxml) @@ -320,47 +325,19 @@ Containers are objects where you can put elements (texts, lists, tables, etc). T Every visible element in word is placed inside of a section. To create a section, use the following code: ```php -$section = $phpWord->addSection($sectionSettings); +$section = $phpWord->addSection($sectionStyle); ``` -The `$sectionSettings` is an optional associative array that sets the section. Example: +The `$sectionStyle` is an optional associative array that sets the section. Example: ```php -$sectionSettings = array( +$sectionStyle = array( 'orientation' => 'landscape', 'marginTop' => 600, 'colsNum' => 2, ); ``` -### Section style - -Below are the available styles for section: - -- `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape' -- `marginTop` Page margin top in twips -- `marginLeft` Page margin left in twips -- `marginRight` Page margin right in twips -- `marginBottom` Page margin bottom in twips -- `borderTopSize` Border top size in twips -- `borderTopColor` Border top color -- `borderLeftSize` Border left size in twips -- `borderLeftColor` Border left color -- `borderRightSize` Border right size in twips -- `borderRightColor` Border right color -- `borderBottomSize` Border bottom size in twips -- `borderBottomColor` Border bottom color -- `headerHeight` Spacing to top of header -- `footerHeight` Spacing to bottom of footer -- `gutter` Page gutter spacing -- `colsNum` Number of columns -- `colsSpace` Spacing between columns -- `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) - -The following two styles are automatically set by the use of the `orientation` style. You can alter them but that's not recommended. - -- `pageSizeW` Page width in twips -- `pageSizeH` Page height in twips ### Page number @@ -485,8 +462,6 @@ $section->addText($text, [$fontStyle], [$paragraphStyle]); $textrun = $section->addTextRun([$paragraphStyle]); ``` -### Text styles - You can use the `$fontStyle` and `$paragraphStyle` variable to define text formatting. There are 2 options to style the inserted text elements, i.e. inline style by using array or defined style by adding style definition. Inline style examples: @@ -514,44 +489,6 @@ $phpWord->addParagraphStyle('pStyle', $paragraphStyle); $text = $section->addText('Hello world!', 'pStyle'); ``` -#### Font style - -Available font styles: - -- `name` Font name, e.g. *Arial* -- `size` Font size, e.g. *20*, *22*, -- `hint` Font content type, *default*, *eastAsia*, or *cs* -- `bold` Bold, *true* or *false* -- `italic` Italic, *true* or *false* -- `superScript` Superscript, *true* or *false* -- `subScript` Subscript, *true* or *false* -- `underline` Underline, *dash*, *dotted*, etc. -- `strikethrough` Strikethrough, *true* or *false* -- `doubleStrikethrough` Double strikethrough, *true* or *false* -- `color` Font color, e.g. *FF0000* -- `fgColor` Font highlight color, e.g. *yellow*, *green*, *blue* -- `bgColor` Font background color, e.g. *FF0000* -- `smallCaps` Small caps, *true* or *false* -- `allCaps` All caps, *true* or *false* - -#### Paragraph style - -Available paragraph styles: - -- `align` Paragraph alignment, *left*, *right* or *center* -- `spaceBefore` Space before paragraph -- `spaceAfter` Space after paragraph -- `indent` Indent by how much -- `hanging` Hanging by how much -- `basedOn` Parent style -- `next` Style for next paragraph -- `widowControl` Allow first/last line to display on a separate page, *true* or *false* -- `keepNext` Keep paragraph with next paragraph, *true* or *false* -- `keepLines` Keep all lines on one page, *true* or *false* -- `pageBreakBefore` Start paragraph on next page, *true* or *false* -- `lineHeight` text line height, e.g. *1.0*, *1.5*, ect... -- `tabs` Set of custom tab stops - ### Titles If you want to structure your document or build table of contents, you need titles or headings. To add a title to the document, use the `addTitleStyle` and `addTitle` method. @@ -602,9 +539,9 @@ $section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]); There are two ways to insert a page breaks, using the `addPageBreak` method or using the `pageBreakBefore` style of paragraph. -:: code-block:: php - -> \$section-\>addPageBreak(); +```php +$section->addPageBreak(); +``` ## Lists @@ -643,20 +580,6 @@ $section->addListItem('List Item I.b', 1, null, 'multilevel'); $section->addListItem('List Item II', 0, null, 'multilevel'); ``` -Level styles: - -- `start` Starting value -- `format` Numbering format bullet|decimal|upperRoman|lowerRoman|upperLetter|lowerLetter -- `restart` Restart numbering level symbol -- `suffix` Content between numbering symbol and paragraph text tab|space|nothing -- `text` Numbering level text e.g. %1 for nonbullet or bullet character -- `align` Numbering symbol align left|center|right|both -- `left` See paragraph style -- `hanging` See paragraph style -- `tabPos` See paragraph style -- `font` Font name -- `hint` See font style - ## Tables To add tables, rows, and cells, use the `addTable`, `addRow`, and `addCell` methods: @@ -680,33 +603,6 @@ $phpWord->addTableStyle('myTable', $tableStyle, $firstRowStyle); $table = $section->addTable('myTable'); ``` -### Table, row, and cell styles - -Table styles: - -- `width` Table width in percent -- `bgColor` Background color, e.g. '9966CC' -- `border(Top|Right|Bottom|Left)Size` Border size in twips -- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC' -- `cellMargin(Top|Right|Bottom|Left)` Cell margin in twips - -Row styles: - -- `tblHeader` Repeat table row on every new page, *true* or *false* -- `cantSplit` Table row cannot break across pages, *true* or *false* -- `exactHeight` Row height is exact or at least - -Cell styles: - -- `width` Cell width in twips -- `valign` Vertical alignment, *top*, *center*, *both*, *bottom* -- `textDirection` Direction of text -- `bgColor` Background color, e.g. '9966CC' -- `border(Top|Right|Bottom|Left)Size` Border size in twips -- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC' -- `gridSpan` Number of columns spanned -- `vMerge` *restart* or *continue* - ### Cell span You can span a cell on multiple columns by using `gridSpan` or multiple rows by using `vMerge`. @@ -749,17 +645,6 @@ $textrun = $section->addTextRun(); $textrun->addImage('http://php.net/logo.jpg'); ``` -### Image styles - -Available image styles: - -- `width` Width in pixels -- `height` Height in pixels -- `align` Image alignment, *left*, *right*, or *center* -- `marginTop` Top margin in inches, can be negative -- `marginLeft` Left margin in inches, can be negative -- `wrappingStyle` Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront* - ### Watermarks To add a watermark (or page background image), your section needs a header reference. After creating a header, you can use the `addWatermark` method to add a watermark. @@ -856,6 +741,127 @@ To be completed. To be completed. +# Styles + +## Section + +Below are the available styles for section: + +- `orientation` Page orientation, i.e. 'portrait' (default) or 'landscape' +- `marginTop` Page margin top in twips +- `marginLeft` Page margin left in twips +- `marginRight` Page margin right in twips +- `marginBottom` Page margin bottom in twips +- `borderTopSize` Border top size in twips +- `borderTopColor` Border top color +- `borderLeftSize` Border left size in twips +- `borderLeftColor` Border left color +- `borderRightSize` Border right size in twips +- `borderRightColor` Border right color +- `borderBottomSize` Border bottom size in twips +- `borderBottomColor` Border bottom color +- `headerHeight` Spacing to top of header +- `footerHeight` Spacing to bottom of footer +- `gutter` Page gutter spacing +- `colsNum` Number of columns +- `colsSpace` Spacing between columns +- `breakType` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) + +The following two styles are automatically set by the use of the `orientation` style. You can alter them but that's not recommended. + +- `pageSizeW` Page width in twips +- `pageSizeH` Page height in twips + +## Font + +Available font styles: + +- `name` Font name, e.g. *Arial* +- `size` Font size, e.g. *20*, *22*, +- `hint` Font content type, *default*, *eastAsia*, or *cs* +- `bold` Bold, *true* or *false* +- `italic` Italic, *true* or *false* +- `superScript` Superscript, *true* or *false* +- `subScript` Subscript, *true* or *false* +- `underline` Underline, *dash*, *dotted*, etc. +- `strikethrough` Strikethrough, *true* or *false* +- `doubleStrikethrough` Double strikethrough, *true* or *false* +- `color` Font color, e.g. *FF0000* +- `fgColor` Font highlight color, e.g. *yellow*, *green*, *blue* +- `bgColor` Font background color, e.g. *FF0000* +- `smallCaps` Small caps, *true* or *false* +- `allCaps` All caps, *true* or *false* + +## Paragraph + +Available paragraph styles: + +- `align` Paragraph alignment, *left*, *right* or *center* +- `spaceBefore` Space before paragraph +- `spaceAfter` Space after paragraph +- `indent` Indent by how much +- `hanging` Hanging by how much +- `basedOn` Parent style +- `next` Style for next paragraph +- `widowControl` Allow first/last line to display on a separate page, *true* or *false* +- `keepNext` Keep paragraph with next paragraph, *true* or *false* +- `keepLines` Keep all lines on one page, *true* or *false* +- `pageBreakBefore` Start paragraph on next page, *true* or *false* +- `lineHeight` text line height, e.g. *1.0*, *1.5*, ect... +- `tabs` Set of custom tab stops + +## Table + +Table styles: + +- `width` Table width in percent +- `bgColor` Background color, e.g. '9966CC' +- `border(Top|Right|Bottom|Left)Size` Border size in twips +- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC' +- `cellMargin(Top|Right|Bottom|Left)` Cell margin in twips + +Row styles: + +- `tblHeader` Repeat table row on every new page, *true* or *false* +- `cantSplit` Table row cannot break across pages, *true* or *false* +- `exactHeight` Row height is exact or at least + +Cell styles: + +- `width` Cell width in twips +- `valign` Vertical alignment, *top*, *center*, *both*, *bottom* +- `textDirection` Direction of text +- `bgColor` Background color, e.g. '9966CC' +- `border(Top|Right|Bottom|Left)Size` Border size in twips +- `border(Top|Right|Bottom|Left)Color` Border color, e.g. '9966CC' +- `gridSpan` Number of columns spanned +- `vMerge` *restart* or *continue* + +## Image + +Available image styles: + +- `width` Width in pixels +- `height` Height in pixels +- `align` Image alignment, *left*, *right*, or *center* +- `marginTop` Top margin in inches, can be negative +- `marginLeft` Left margin in inches, can be negative +- `wrappingStyle` Wrapping style, *inline*, *square*, *tight*, *behind*, or *infront* + +## Numbering level + +- `start` Starting value +- `format` Numbering format bullet|decimal|upperRoman|lowerRoman|upperLetter|lowerLetter +- `restart` Restart numbering level symbol +- `suffix` Content between numbering symbol and paragraph text tab|space|nothing +- `text` Numbering level text e.g. %1 for nonbullet or bullet character +- `align` Numbering symbol align left|center|right|both +- `left` See paragraph style +- `hanging` See paragraph style +- `tabPos` See paragraph style +- `font` Font name +- `hint` See font style + # 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/docs/styles.rst b/docs/styles.rst new file mode 100644 index 0000000000..cd07a9f7e0 --- /dev/null +++ b/docs/styles.rst @@ -0,0 +1,137 @@ +.. _styles: + +Styles +====== + +Section +------- + +Below are the available styles for section: + +- ``orientation`` Page orientation, i.e. 'portrait' (default) or + 'landscape' +- ``marginTop`` Page margin top in twips +- ``marginLeft`` Page margin left in twips +- ``marginRight`` Page margin right in twips +- ``marginBottom`` Page margin bottom in twips +- ``borderTopSize`` Border top size in twips +- ``borderTopColor`` Border top color +- ``borderLeftSize`` Border left size in twips +- ``borderLeftColor`` Border left color +- ``borderRightSize`` Border right size in twips +- ``borderRightColor`` Border right color +- ``borderBottomSize`` Border bottom size in twips +- ``borderBottomColor`` Border bottom color +- ``headerHeight`` Spacing to top of header +- ``footerHeight`` Spacing to bottom of footer +- ``gutter`` Page gutter spacing +- ``colsNum`` Number of columns +- ``colsSpace`` Spacing between columns +- ``breakType`` Section break type (nextPage, nextColumn, continuous, + evenPage, oddPage) + +The following two styles are automatically set by the use of the +``orientation`` style. You can alter them but that's not recommended. + +- ``pageSizeW`` Page width in twips +- ``pageSizeH`` Page height in twips + +Font +---- + +Available font styles: + +- ``name`` Font name, e.g. *Arial* +- ``size`` Font size, e.g. *20*, *22*, +- ``hint`` Font content type, *default*, *eastAsia*, or *cs* +- ``bold`` Bold, *true* or *false* +- ``italic`` Italic, *true* or *false* +- ``superScript`` Superscript, *true* or *false* +- ``subScript`` Subscript, *true* or *false* +- ``underline`` Underline, *dash*, *dotted*, etc. +- ``strikethrough`` Strikethrough, *true* or *false* +- ``doubleStrikethrough`` Double strikethrough, *true* or *false* +- ``color`` Font color, e.g. *FF0000* +- ``fgColor`` Font highlight color, e.g. *yellow*, *green*, *blue* +- ``bgColor`` Font background color, e.g. *FF0000* +- ``smallCaps`` Small caps, *true* or *false* +- ``allCaps`` All caps, *true* or *false* + +Paragraph +--------- + +Available paragraph styles: + +- ``align`` Paragraph alignment, *left*, *right* or *center* +- ``spaceBefore`` Space before paragraph +- ``spaceAfter`` Space after paragraph +- ``indent`` Indent by how much +- ``hanging`` Hanging by how much +- ``basedOn`` Parent style +- ``next`` Style for next paragraph +- ``widowControl`` Allow first/last line to display on a separate page, + *true* or *false* +- ``keepNext`` Keep paragraph with next paragraph, *true* or *false* +- ``keepLines`` Keep all lines on one page, *true* or *false* +- ``pageBreakBefore`` Start paragraph on next page, *true* or *false* +- ``lineHeight`` text line height, e.g. *1.0*, *1.5*, ect... +- ``tabs`` Set of custom tab stops + +Table +----- + +Table styles: + +- ``width`` Table width in percent +- ``bgColor`` Background color, e.g. '9966CC' +- ``border(Top|Right|Bottom|Left)Size`` Border size in twips +- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' +- ``cellMargin(Top|Right|Bottom|Left)`` Cell margin in twips + +Row styles: + +- ``tblHeader`` Repeat table row on every new page, *true* or *false* +- ``cantSplit`` Table row cannot break across pages, *true* or *false* +- ``exactHeight`` Row height is exact or at least + +Cell styles: + +- ``width`` Cell width in twips +- ``valign`` Vertical alignment, *top*, *center*, *both*, *bottom* +- ``textDirection`` Direction of text +- ``bgColor`` Background color, e.g. '9966CC' +- ``border(Top|Right|Bottom|Left)Size`` Border size in twips +- ``border(Top|Right|Bottom|Left)Color`` Border color, e.g. '9966CC' +- ``gridSpan`` Number of columns spanned +- ``vMerge`` *restart* or *continue* + +Image +----- + +Available image styles: + +- ``width`` Width in pixels +- ``height`` Height in pixels +- ``align`` Image alignment, *left*, *right*, or *center* +- ``marginTop`` Top margin in inches, can be negative +- ``marginLeft`` Left margin in inches, can be negative +- ``wrappingStyle`` Wrapping style, *inline*, *square*, *tight*, + *behind*, or *infront* + +Numbering level +--------------- + +- ``start`` Starting value +- ``format`` Numbering format + bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter +- ``restart`` Restart numbering level symbol +- ``suffix`` Content between numbering symbol and paragraph text + tab\|space\|nothing +- ``text`` Numbering level text e.g. %1 for nonbullet or bullet + character +- ``align`` Numbering symbol align left\|center\|right\|both +- ``left`` See paragraph style +- ``hanging`` See paragraph style +- ``tabPos`` See paragraph style +- ``font`` Font name +- ``hint`` See font style From e952fdefb5730f59087f77404d4d7884128407c7 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 18:29:24 +0700 Subject: [PATCH 023/174] Refactor PhpWord to reduce dependencies --- src/PhpWord/Element/AbstractContainer.php | 2 +- src/PhpWord/PhpWord.php | 240 ++++++++-------------- src/PhpWord/Reader/ODText/Content.php | 2 +- 3 files changed, 83 insertions(+), 161 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 5093d3f4d3..4398ef1635 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -25,7 +25,7 @@ * @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null) * @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null) * @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null) - * @method ListItem addListItem(string $text, int $depth = 0, mixed $fStyle = null, mixed $listStyle = null, mixed $pStyle = null) + * @method ListItem addListItem(string $txt, int $depth = 0, mixed $font = null, mixed $list = null, mixed $para = null) * @method ListItemRun addListItemRun(int $depth = 0, mixed $listStyle = null, mixed $pStyle = null) * @method Footnote addFootnote(mixed $pStyle = null) * @method Endnote addEndnote(mixed $pStyle = null) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index e06080c16d..9c8d5a90dd 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -17,14 +17,25 @@ namespace PhpOffice\PhpWord; -use PhpOffice\PhpWord\Collection\Endnotes; -use PhpOffice\PhpWord\Collection\Footnotes; -use PhpOffice\PhpWord\Collection\Titles; use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Exception\Exception; /** * PHPWord main class + * + * @method Collection\Titles getTitles() + * @method Collection\Footnotes getFootnotes() + * @method Collection\Endnotes getEndnotes() + * @method int addTitle(Element\Title $title) + * @method int addFootnote(Element\Footnote $footnote) + * @method int addEndnote(Element\Endnote $endnote) + * + * @method Style\Paragraph addParagraphStyle(string $styleName, array $styles) + * @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null) + * @method Style\Font addLinkStyle(string $styleName, mixed $styles) + * @method Style\Font addTitleStyle(int $depth, mixed $fontStyle, mixed $paragraphStyle = null) + * @method Style\Table addTableStyle(string $styleName, mixed $styleTable, mixed $styleFirstRow = null) + * @method Style\Numbering addNumberingStyle(string $styleName, mixed $styles) */ class PhpWord { @@ -54,35 +65,84 @@ class PhpWord private $sections = array(); /** - * Collection of titles + * Collections * - * @var \PhpOffice\PhpWord\Collection\Titles + * @var array */ - private $titles; + private $collections = array(); /** - * Collection of footnotes + * Create new instance * - * @var \PhpOffice\PhpWord\Collection\Footnotes + * Collections are created dynamically */ - private $footnotes; + public function __construct() + { + $this->documentProperties = new DocumentProperties(); - /** - * Collection of endnotes - * - * @var \PhpOffice\PhpWord\Collection\Endnotes - */ - private $endnotes; + $collections = array('Titles', 'Footnotes', 'Endnotes'); + foreach ($collections as $collection) { + $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection; + $this->collections[$collection] = new $class(); + } + } /** - * Create new + * Dynamic function call to reduce static dependency + * + * Usage: + * - Getting and adding collections (Titles, Footnotes, and Endnotes) + * - Adding style + * + * @param mixed $function + * @param mixed $args + * @return mixed + * + * @since 0.12.0 */ - public function __construct() + public function __call($function, $args) { - $this->documentProperties = new DocumentProperties(); - $this->titles = new Titles(); - $this->footnotes = new Footnotes(); - $this->endnotes = new Endnotes(); + $function = strtolower($function); + + $getCollection = array(); + $addCollection = array(); + $addStyle = array(); + + $collections = array('Title', 'Footnote', 'Endnote'); + foreach ($collections as $collection) { + $getCollection[] = strtolower("get{$collection}s"); + $addCollection[] = strtolower("add{$collection}"); + } + + $styles = array('Paragraph', 'Font', 'Table', 'Numbering', 'Link', 'Title'); + foreach ($styles as $style) { + $addStyle[] = strtolower("add{$style}style"); + } + + // Run get collection method + if (in_array($function, $getCollection)) { + $key = ucfirst(str_replace('get', '', $function)); + + return $this->collections[$key]; + } + + // Run add collection item method + if (in_array($function, $addCollection)) { + $key = ucfirst(str_replace('add', '', $function) . 's'); + + /** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */ + $collectionObject = $this->collections[$key]; + + return $collectionObject->addItem($args[0]); + } + + // Run add style method + if (in_array($function, $addStyle)) { + return forward_static_call_array(array('PhpOffice\\PhpWord\\Style', $function), $args); + } + + // All other methods + return null; } /** @@ -133,69 +193,6 @@ public function addSection($style = null) 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 * @@ -247,81 +244,6 @@ public function setDefaultParagraphStyle($styles) return Style::setDefaultParagraphStyle($styles); } - /** - * Adds a paragraph style definition to styles.xml - * - * @param string $styleName - * @param array $styles - * @return \PhpOffice\PhpWord\Style\Paragraph - */ - public function addParagraphStyle($styleName, $styles) - { - return Style::addParagraphStyle($styleName, $styles); - } - - /** - * Adds a font style definition to styles.xml - * - * @param string $styleName - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Style\Font - */ - public function addFontStyle($styleName, $fontStyle, $paragraphStyle = null) - { - return Style::addFontStyle($styleName, $fontStyle, $paragraphStyle); - } - - /** - * Adds a table style definition to styles.xml - * - * @param string $styleName - * @param mixed $styleTable - * @param mixed $styleFirstRow - * @return \PhpOffice\PhpWord\Style\Table - */ - public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) - { - return Style::addTableStyle($styleName, $styleTable, $styleFirstRow); - } - - /** - * Adds a numbering style - * - * @param string $styleName - * @param mixed $styles - * @return \PhpOffice\PhpWord\Style\Numbering - */ - public function addNumberingStyle($styleName, $styles) - { - return Style::addNumberingStyle($styleName, $styles); - } - - /** - * Adds a hyperlink style to styles.xml - * - * @param string $styleName - * @param mixed $styles - * @return \PhpOffice\PhpWord\Style\Font - */ - public function addLinkStyle($styleName, $styles) - { - return Style::addLinkStyle($styleName, $styles); - } - - /** - * Adds a heading style definition to styles.xml - * - * @param int $depth - * @param mixed $fontStyle - * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Style\Font - */ - public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null) - { - return Style::addTitleStyle($depth, $fontStyle, $paragraphStyle); - } - /** * Load template by filename * diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index 12b39f74d3..034789ff6a 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -57,7 +57,7 @@ public function read(PhpWord &$phpWord) $listItems = $xmlReader->getElements('text:list-item/text:p', $node); foreach ($listItems as $listItem) { // $listStyleName = $xmlReader->getAttribute('text:style-name', $listItem); - $section->addListItem($listItem->nodeValue); + $section->addListItem($listItem->nodeValue, 0); } break; } From 6839ee41dd0d0fe0d7d3286592c24e2e8446db18 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 20:11:44 +0700 Subject: [PATCH 024/174] New `PhpWord::save()` method to encapsulate `IOFactory` --- CHANGELOG.md | 1 + README.md | 13 ++++------ docs/general.rst | 13 ++++------ docs/src/documentation.md | 13 ++++------ samples/Sample_Header.php | 12 ++++------ src/PhpWord/PhpWord.php | 37 +++++++++++++++++++++++++++++ tests/PhpWord/Tests/PhpWordTest.php | 12 ++++++++++ 7 files changed, 67 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19d9934806..7d4010ecf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme - Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 - RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 - Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 +- General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin ### Bugfixes diff --git a/README.md b/README.md index fefde4eb75..a9006f2c44 100644 --- a/README.md +++ b/README.md @@ -100,15 +100,10 @@ $fontStyle->setSize(22); $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); -// Finally, write the document: -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); -$objWriter->save('helloWorld.docx'); - -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); -$objWriter->save('helloWorld.odt'); - -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); -$objWriter->save('helloWorld.rtf'); +// Finally, save the document: +$phpWord->save('helloWorld.docx'); +$phpWord->save('helloWorld.odt', 'ODText'); +$phpWord->save('helloWorld.rtf', 'RTF'); ``` ## Known issues diff --git a/docs/general.rst b/docs/general.rst index 270608f7ed..0bbeb2ec71 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -43,15 +43,10 @@ folder `__. $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); - // Finally, write the document: - $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); - $objWriter->save('helloWorld.docx'); - - $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); - $objWriter->save('helloWorld.odt'); - - $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); - $objWriter->save('helloWorld.rtf'); + // Finally, save the document: + $phpWord->save('helloWorld.docx'); + $phpWord->save('helloWorld.odt', 'ODText'); + $phpWord->save('helloWorld.rtf', 'RTF'); Settings -------- diff --git a/docs/src/documentation.md b/docs/src/documentation.md index c76ec1f234..c2fc5e7729 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -238,15 +238,10 @@ $fontStyle->setSize(22); $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); -// Finally, write the document: -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); -$objWriter->save('helloWorld.docx'); - -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); -$objWriter->save('helloWorld.odt'); - -$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); -$objWriter->save('helloWorld.rtf'); +// Finally, save the document: +$phpWord->save('helloWorld.docx'); +$phpWord->save('helloWorld.odt', 'ODText'); +$phpWord->save('helloWorld.rtf', 'RTF'); ``` ## Settings diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 7af23c94d2..d915c039d7 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -4,7 +4,6 @@ */ use PhpOffice\PhpWord\Autoloader; use PhpOffice\PhpWord\Settings; -use PhpOffice\PhpWord\IOFactory; error_reporting(E_ALL); define('CLI', (PHP_SAPI == 'cli') ? true : false); @@ -59,12 +58,11 @@ function write($phpWord, $filename, $writers) $result = ''; // Write documents - foreach ($writers as $writer => $extension) { - $result .= date('H:i:s') . " Write to {$writer} format"; - if (!is_null($extension)) { - $xmlWriter = IOFactory::createWriter($phpWord, $writer); - $xmlWriter->save(__DIR__ . "/{$filename}.{$extension}"); - rename(__DIR__ . "/{$filename}.{$extension}", __DIR__ . "/results/{$filename}.{$extension}"); + foreach ($writers as $format => $extension) { + $result .= date('H:i:s') . " Write to {$format} format"; + if ($extension !== null) { + $targetFile = __DIR__ . "/results/{$filename}.{$extension}"; + $phpWord->save($targetFile, $format); } else { $result .= ' ... NOT DONE!'; } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 9c8d5a90dd..8e889cce60 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -260,6 +260,43 @@ public function loadTemplate($filename) } } + /** + * Save to file or download + * + * All exceptions should already been handled by the writers + * + * @param string $filename + * @param string $format + * @param bool $download + * @return bool + */ + public function save($filename, $format = 'Word2007', $download = false) + { + $mime = array( + 'Word2007' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'ODT' => 'application/vnd.oasis.opendocument.text', + 'RTF' => 'application/rtf', + 'HTML' => 'text/html', + 'PDF' => 'application/pdf', + ); + + $writer = IOFactory::createWriter($this, $format); + + if ($download === true) { + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Content-Type: ' . $mime[$format]); + header('Content-Transfer-Encoding: binary'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Expires: 0'); + $filename = 'php://output'; // Change filename to force download + } + + $writer->save($filename); + + return true; + } + /** * Create new section * diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 6a9e6b2649..ca49bf28b2 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -158,4 +158,16 @@ public function testLoadTemplateException() $phpWord = new PhpWord(); $phpWord->loadTemplate($templateFqfn); } + + /** + * Test save + */ + public function testSave() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + $section->addText('Hello world!'); + + $this->assertTrue($phpWord->save('test.docx', 'Word2007', true)); + } } From 1ec0589c557406725bf03eb0f791b6f8002a06a3 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 8 Jun 2014 22:38:50 +0700 Subject: [PATCH 025/174] Update basic example --- README.md | 18 ++++++++++++------ docs/general.rst | 9 +++++---- docs/src/documentation.md | 9 +++++---- src/PhpWord/PhpWord.php | 1 + 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a9006f2c44..97e5b6425c 100644 --- a/README.md +++ b/README.md @@ -67,11 +67,14 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); ``` -## Usages +## Getting started -The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/). +The following is a basic usage example of the PHPWord library. ```php +require_once 'src/PhpWord/Autoloader.php'; +\PhpOffice\PhpWord\Autoloader::register(); + $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Every element you want to append to the word document is placed in a section. @@ -93,10 +96,11 @@ $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); // You can also put the appended element to local object like this: -$fontStyle = new \PhpOffice\PhpWord\Style\Font(); -$fontStyle->setBold(true); -$fontStyle->setName('Verdana'); -$fontStyle->setSize(22); +$fontStyle = array( + 'name' => 'Verdana', + 'size' => 22, + 'bold' => true, +); $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); @@ -106,6 +110,8 @@ $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` +More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/) for more detail. + ## Known issues - GH-238: PHPWord uses temporary folder with `sys_get_temp_dir()` extensively. The default setting on some systems (especially Windows) do not give appropriate read/write permission to this folder. Run `samples/index.php` either by CLI or by web browsers to check if you have this requirement fulfilled. diff --git a/docs/general.rst b/docs/general.rst index 0bbeb2ec71..60d9b609c8 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -36,10 +36,11 @@ folder `__. 'myOwnStyle'); // You can also put the appended element to local object like this: - $fontStyle = new \PhpOffice\PhpWord\Style\Font(); - $fontStyle->setBold(true); - $fontStyle->setName('Verdana'); - $fontStyle->setSize(22); + $fontStyle = array( + 'name' => 'Verdana', + 'size' => 22, + 'bold' => true, + ); $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index c2fc5e7729..144222c197 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -231,10 +231,11 @@ $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); // You can also put the appended element to local object like this: -$fontStyle = new \PhpOffice\PhpWord\Style\Font(); -$fontStyle->setBold(true); -$fontStyle->setName('Verdana'); -$fontStyle->setSize(22); +$fontStyle = array( + 'name' => 'Verdana', + 'size' => 22, + 'bold' => true, +); $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 8e889cce60..c8ed568c87 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -280,6 +280,7 @@ public function save($filename, $format = 'Word2007', $download = false) 'PDF' => 'application/pdf', ); + /** @var \PhpOffice\PhpWord\Writer\WriterInterface $writer */ $writer = IOFactory::createWriter($this, $format); if ($download === true) { From 4c04071fd519a21d2234dcbee1ee195483ab2973 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 9 Jun 2014 18:52:06 +0700 Subject: [PATCH 026/174] Fix typo: ODT > ODText --- src/PhpWord/PhpWord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index c8ed568c87..de9d8433af 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -274,7 +274,7 @@ public function save($filename, $format = 'Word2007', $download = false) { $mime = array( 'Word2007' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'ODT' => 'application/vnd.oasis.opendocument.text', + 'ODText' => 'application/vnd.oasis.opendocument.text', 'RTF' => 'application/rtf', 'HTML' => 'text/html', 'PDF' => 'application/pdf', From d17a806305010b97b03441739cde7913645a745f Mon Sep 17 00:00:00 2001 From: Brandon Skrtich Date: Mon, 9 Jun 2014 15:17:40 -0600 Subject: [PATCH 027/174] Small fixes for addHtml. Adding some HTML Entities to the test for addHTML --- src/PhpWord/Shared/Html.php | 9 +++++++-- tests/PhpWord/Tests/Shared/HtmlTest.php | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 8abfea2fd7..fc23b5b0a8 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -42,9 +42,14 @@ public static function addHtml($element, $html, $fullHTML = false) * 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 + // Preprocess: remove all line ends, decode HTML entity, + // fix ampersand and angle brackets and add body tag for HTML fragments $html = str_replace(array("\n", "\r"), '', $html); - $html = html_entity_decode($html); + $html = str_replace(array('<', '>', '&'), array('_lt_', '_gt_', '_amp_'), $html); + $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); + $html = str_replace('&', '&', $html); + $html = str_replace(array('_lt_', '_gt_', '_amp_'), array('<', '>', '&'), $html); + if ($fullHTML === false) { $html = '' . $html . ''; } diff --git a/tests/PhpWord/Tests/Shared/HtmlTest.php b/tests/PhpWord/Tests/Shared/HtmlTest.php index 730600d743..e7b3533e74 100644 --- a/tests/PhpWord/Tests/Shared/HtmlTest.php +++ b/tests/PhpWord/Tests/Shared/HtmlTest.php @@ -60,6 +60,12 @@ public function testAddHtml() $content .= '
HeaderContent
'; $content .= '
  • Bullet
    • Bullet
'; $content .= '
  1. Bullet
'; + $content .= "'Single Quoted Text'"; + $content .= '"Double Quoted Text"'; + $content .= '& Ampersand'; + $content .= '<>“‘’«»‹›'; + $content .= '&•°…™©®—'; + $content .= '–   ²³¼½¾'; Html::addHtml($section, $content); } } From 8e93c91bb00c892347dc0f63b741eb5347d4e71b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 11 Jun 2014 00:57:52 +0700 Subject: [PATCH 028/174] Update changelog for #270 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d4010ecf8..9b741e57f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme ### Bugfixes - Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 +- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 ### Deprecated From 056ff5e676fcac97f48354ee2075a991de442fe1 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 10 Jun 2014 07:11:32 +0700 Subject: [PATCH 029/174] Basic chart support --- samples/Sample_32_Chart.php | 26 ++ src/PhpWord/Collection/Charts.php | 27 ++ src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/AbstractElement.php | 2 +- src/PhpWord/Element/Chart.php | 129 +++++++ src/PhpWord/Element/Footnote.php | 2 +- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/PhpWord.php | 6 +- src/PhpWord/Shared/XMLWriter.php | 23 ++ src/PhpWord/Writer/Word2007.php | 36 ++ src/PhpWord/Writer/Word2007/Element/Chart.php | 79 +++++ src/PhpWord/Writer/Word2007/Part/Chart.php | 331 ++++++++++++++++++ .../Writer/Word2007/Part/ContentTypes.php | 7 +- .../Tests/Writer/Word2007/ElementTest.php | 2 +- 14 files changed, 668 insertions(+), 8 deletions(-) create mode 100644 samples/Sample_32_Chart.php create mode 100644 src/PhpWord/Collection/Charts.php create mode 100644 src/PhpWord/Element/Chart.php create mode 100644 src/PhpWord/Writer/Word2007/Element/Chart.php create mode 100644 src/PhpWord/Writer/Word2007/Part/Chart.php diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php new file mode 100644 index 0000000000..52c19f3c61 --- /dev/null +++ b/samples/Sample_32_Chart.php @@ -0,0 +1,26 @@ +addSection(array('colsNum' => 2)); +$phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); + +$charts = array('pie', 'doughnut', 'line', 'area', 'scatter', 'bar', 'radar'); +$labels = array('A', 'B', 'C', 'D', 'E'); +$data = array(1, 3, 2, 5, 4); + +foreach ($charts as $chart) { + $section->addTitle(ucfirst($chart), 1); + $section->addChart($chart, $labels, $data); + $section->addTextBreak(); +} + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/Collection/Charts.php b/src/PhpWord/Collection/Charts.php new file mode 100644 index 0000000000..cfccee2ec3 --- /dev/null +++ b/src/PhpWord/Collection/Charts.php @@ -0,0 +1,27 @@ + array('Section'), 'TOC' => array('Section'), 'PageBreak' => array('Section'), + 'Chart' => array('Section'), ); // Special condition, e.g. preservetext can only exists in cell when // the cell is located in header or footer diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index fe133fddf5..3fd2e4d01a 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -109,7 +109,7 @@ abstract class AbstractElement protected $mediaRelation = false; /** - * Is part of collection; true for Title, Footnote, and Endnote + * Is part of collection; true for Title, Footnote, Endnote, and Chart * * @var bool */ diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php new file mode 100644 index 0000000000..46b7b784c4 --- /dev/null +++ b/src/PhpWord/Element/Chart.php @@ -0,0 +1,129 @@ +setType($type); + $this->setLabels($labels); + $this->setData($data); + } + + /** + * Get type + * + * @return array + */ + public function getType() + { + return $this->type; + } + + /** + * Set type + * + * @param array $value + */ + public function setType($value) + { + $enum = array('pie', 'doughnut', 'line', 'bar', 'area', 'radar', 'scatter'); + $this->type = $this->setEnumVal($value, $enum, 'pie'); + } + + /** + * Get labels + * + * @return array + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Set labels + * + * @param array $value + */ + public function setLabels($value) + { + $this->labels = $value; + } + + /** + * Get data + * + * @return array + */ + public function getData() + { + return $this->data; + } + + /** + * Set data + * + * @param array $value + */ + public function setData($value) + { + $this->data = $value; + } +} diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index e263933cf7..162a703ed5 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -37,7 +37,7 @@ class Footnote extends AbstractContainer protected $paragraphStyle; /** - * Is part of collection; true for Title, Footnote, and Endnote + * Is part of collection * * @var bool */ diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index a4faeb70a1..8d3858458f 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -47,7 +47,7 @@ class Title extends AbstractElement private $style; /** - * Is part of collection; true for Title, Footnote, and Endnote + * Is part of collection * * @var bool */ diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index de9d8433af..d4c8df9c11 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -26,9 +26,11 @@ * @method Collection\Titles getTitles() * @method Collection\Footnotes getFootnotes() * @method Collection\Endnotes getEndnotes() + * @method Collection\Charts getCharts() * @method int addTitle(Element\Title $title) * @method int addFootnote(Element\Footnote $footnote) * @method int addEndnote(Element\Endnote $endnote) + * @method int addChart(Element\Chart $chart) * * @method Style\Paragraph addParagraphStyle(string $styleName, array $styles) * @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null) @@ -80,7 +82,7 @@ public function __construct() { $this->documentProperties = new DocumentProperties(); - $collections = array('Titles', 'Footnotes', 'Endnotes'); + $collections = array('Titles', 'Footnotes', 'Endnotes', 'Charts'); foreach ($collections as $collection) { $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection; $this->collections[$collection] = new $class(); @@ -108,7 +110,7 @@ public function __call($function, $args) $addCollection = array(); $addStyle = array(); - $collections = array('Title', 'Footnote', 'Endnote'); + $collections = array('Title', 'Footnote', 'Endnote', 'Chart'); foreach ($collections as $collection) { $getCollection[] = strtolower("get{$collection}s"); $addCollection[] = strtolower("add{$collection}"); diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index cb00c70b74..b2057bb929 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -139,6 +139,29 @@ public function getData() } } + /** + * Write simple element and attribute(s) block + * + * There are two options: + * 1. If the `$attributes` is an array, then it's an associative array of attributes + * 2. If not, then it's a simple attribute-value pair + * + * @param string $element + * @param string|array $attributes + * @param string $value + */ + public function writeBlock($element, $attributes, $value = null) + { + $this->xmlWriter->startElement($element); + if (!is_array($attributes)) { + $attributes = array($attributes => $value); + } + foreach ($attributes as $attribute => $value) { + $this->xmlWriter->writeAttribute($attribute, $value); + } + $this->xmlWriter->endElement(); + } + /** * Write element if ... * diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 751b58b607..d15f40aca5 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -71,6 +71,7 @@ public function __construct(PhpWord $phpWord = null) 'Footer' => '', 'Footnotes' => '', 'Endnotes' => '', + 'Chart' => '', ); foreach (array_keys($this->parts) as $partName) { $partClass = get_class($this) . '\\Part\\' . $partName; @@ -127,6 +128,7 @@ public function save($filename = null) $this->addNotes($zip, $rId, 'footnote'); $this->addNotes($zip, $rId, 'endnote'); + $this->addChart($zip, $rId); // Write parts foreach ($this->parts as $partName => $fileName) { @@ -249,6 +251,40 @@ private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote') } } + /** + * Add chart + * + * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip + * @param integer $rId + */ + private function addChart(ZipArchive $zip, &$rId) + { + $phpWord = $this->getPhpWord(); + + $collection = $phpWord->getCharts(); + $index = 0; + if ($collection->countItems() > 0) { + foreach ($collection->getItems() as $chart) { + $index++; + $rId++; + $filename = "charts/chart{$index}.xml"; + + // ContentTypes.xml + $this->contentTypes['override']["/word/{$filename}"] = 'chart'; + + // word/_rels/document.xml.rel + $this->relationships[] = array('target' => $filename, 'type' => 'chart', 'rID' => $rId); + + // word/charts/chartN.xml + /** @var \PhpOffice\PhpWord\Element\Chart $chart */ + $chart->setRelationId($rId); + $writerPart = $this->getWriterPart('Chart'); + $writerPart->setElement($chart); + $zip->addFromString("word/{$filename}", $writerPart->write()); + } + } + } + /** * Register content types for each media * diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php new file mode 100644 index 0000000000..3c4e43f2e1 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Chart.php @@ -0,0 +1,79 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof ChartElement) { + return; + } + + if (!$this->withoutP) { + $xmlWriter->startElement('w:p'); + } + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:drawing'); + $xmlWriter->startElement('wp:inline'); + + // EMU + $xmlWriter->startElement('wp:extent'); + $xmlWriter->writeAttribute('cx', '2000000'); + $xmlWriter->writeAttribute('cy', '2000000'); + $xmlWriter->endElement(); // wp:extent + + $xmlWriter->startElement('wp:docPr'); + $xmlWriter->writeAttribute('id', $element->getRelationId()); + $xmlWriter->writeAttribute('name', 'Chart'. $element->getRelationId()); + $xmlWriter->endElement(); // wp:docPr + + $xmlWriter->startElement('a:graphic'); + $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $xmlWriter->startElement('a:graphicData'); + $xmlWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); + + $xmlWriter->startElement('c:chart'); + $xmlWriter->writeAttribute('r:id', 'rId' . $element->getRelationId()); + $xmlWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->endElement(); // c:chart + + $xmlWriter->endElement(); // a:graphicData + $xmlWriter->endElement(); // a:graphic + + $xmlWriter->endElement(); // wp:inline + $xmlWriter->endElement(); // w:drawing + $xmlWriter->endElement(); // w:r + + $this->endElementP(); // w:p + } +} diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php new file mode 100644 index 0000000000..13525fe778 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -0,0 +1,331 @@ +element = $element; + } + + /** + * Write part + * + * @return string + */ + public function write() + { + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startElement('c:chartSpace'); + $xmlWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); + $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + + $xmlWriter->writeBlock('c:roundedCorners', 'val', '0'); + + $xmlWriter->startElement('c:chart'); + $this->writePlotArea($xmlWriter); + $xmlWriter->endElement(); // c:chart + + $xmlWriter->endElement(); // c:chartSpace + + return $xmlWriter->getData(); + } + + /** + * Write plot area + */ + private function writePlotArea(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:plotArea'); + + $method = "write{$this->element->getType()}Chart"; + $this->$method($xmlWriter); + + $xmlWriter->endElement(); // c:plotArea + } + + /** + * Write pie chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html + */ + private function writePieChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:pieChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '1'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:pie3DChart + } + + /** + * Write doughnut chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_DoughnutChart.html + */ + private function writeDoughnutChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:doughnutChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '1'); + $xmlWriter->writeBlock('c:holeSize', 'val', '75'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:doughnutChart + } + + /** + * Write bar chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_BarChart.html + */ + private function writeBarChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:barChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '0'); + $xmlWriter->writeBlock('c:barDir', 'val', 'col'); // bar|col + $xmlWriter->writeBlock('c:axId', 'val', '1'); + $xmlWriter->writeBlock('c:axId', 'val', '2'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:barChart + + // Axes + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + /** + * Write line chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_LineChart.html + */ + private function writeLineChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:lineChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '0'); + $xmlWriter->writeBlock('c:axId', 'val', '1'); + $xmlWriter->writeBlock('c:axId', 'val', '2'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:lineChart + + // Axes + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + /** + * Write area chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html + */ + private function writeAreaChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:areaChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '0'); + $xmlWriter->writeBlock('c:axId', 'val', '1'); + $xmlWriter->writeBlock('c:axId', 'val', '2'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:areaChart + + // Axes + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + /** + * Write radar chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html + */ + private function writeRadarChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:radarChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '0'); + $xmlWriter->writeBlock('c:radarStyle', 'val', 'standard'); + $xmlWriter->writeBlock('c:axId', 'val', '1'); + $xmlWriter->writeBlock('c:axId', 'val', '2'); + + $this->writeSeries($xmlWriter); + + $xmlWriter->endElement(); // c:radarChart + + // Axes + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + /** + * Write scatter chart + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html + */ + private function writeScatterChart(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:scatterChart'); + + $xmlWriter->writeBlock('c:varyColors', 'val', '0'); + $xmlWriter->writeBlock('c:scatterStyle', 'val', 'lineMarker'); + $xmlWriter->writeBlock('c:axId', 'val', '1'); + $xmlWriter->writeBlock('c:axId', 'val', '2'); + + $this->writeSeries($xmlWriter, true); + + $xmlWriter->endElement(); // c:scatterChart + + // Axes + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + /** + * Write series + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param bool $scatter + */ + private function writeSeries(XMLWriter $xmlWriter, $scatter = false) + { + $xmlWriter->startElement('c:ser'); + + $xmlWriter->writeBlock('c:idx', 'val', '0'); + $xmlWriter->writeBlock('c:order', 'val', '0'); + + if ($scatter === true) { + $this->writeSeriesItems($xmlWriter, 'xVal', $this->element->getLabels()); + $this->writeSeriesItems($xmlWriter, 'yVal', $this->element->getData()); + } else { + $this->writeSeriesItems($xmlWriter, 'cat', $this->element->getLabels()); + $this->writeSeriesItems($xmlWriter, 'val', $this->element->getData()); + } + + $xmlWriter->endElement(); // c:ser + } + + /** + * Write series items + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $type + * @param array $values + */ + private function writeSeriesItems(XMLWriter $xmlWriter, $type, $values) + { + $types = array( + 'cat' => array('c:cat', 'c:strRef', 'c:strCache'), + 'val' => array('c:val', 'c:numRef', 'c:numCache'), + 'xVal' => array('c:xVal', 'c:strRef', 'c:strCache'), + 'yVal' => array('c:yVal', 'c:numRef', 'c:numCache'), + ); + list($itemType, $itemRef, $itemCache) = $types[$type]; + + $xmlWriter->startElement($itemType); + $xmlWriter->startElement($itemRef); + $xmlWriter->startElement($itemCache); + + $index = 0; + foreach ($values as $value) { + $xmlWriter->startElement('c:pt'); + $xmlWriter->writeAttribute('idx', $index); + + $xmlWriter->startElement('c:v'); + $xmlWriter->writeRaw($value); + $xmlWriter->endElement(); // c:v + + $xmlWriter->endElement(); // c:pt + $index++; + } + + $xmlWriter->endElement(); // $itemCache + + $xmlWriter->endElement(); // $itemRef + $xmlWriter->endElement(); // $itemType + } + + /** + * Write axis + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $type + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html + */ + private function writeAxis(XMLWriter $xmlWriter, $type) + { + $types = array( + 'cat' => array('c:catAx', '1', 'b', '2'), + 'val' => array('c:valAx', '2', 'l', '1'), + ); + list($axisType, $axisId, $axisPos, $axisCross) = $types[$type]; + + $xmlWriter->startElement($axisType); + + $xmlWriter->writeBlock('c:axId', 'val', $axisId); + $xmlWriter->writeBlock('c:axPos', 'val', $axisPos); + $xmlWriter->writeBlock('c:crossAx', 'val', $axisCross); + + $xmlWriter->startElement('c:scaling'); + $xmlWriter->writeBlock('c:orientation', 'val', 'minMax'); + $xmlWriter->endElement(); // c:scaling + + $xmlWriter->startElement('c:spPr'); + $xmlWriter->writeElement('a:noFill'); + $xmlWriter->startElement('a:ln'); + $xmlWriter->startElement('a:solidFill'); + $xmlWriter->writeBlock('a:srgbClr', 'val', '0FB7'); + $xmlWriter->endElement(); // a:solidFill + $xmlWriter->endElement(); // a:ln + $xmlWriter->endElement(); // c:crossAx + + $xmlWriter->endElement(); // $type + } +} diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index b6f23f4726..ac636d3a78 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -37,6 +37,7 @@ public function write() $openXMLPrefix = 'application/vnd.openxmlformats-'; $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; + $drawingMLPrefix = $openXMLPrefix . 'officedocument.drawingml.'; $overrides = array( '/docProps/core.xml' => $openXMLPrefix . 'package.core-properties+xml', '/docProps/app.xml' => $openXMLPrefix . 'officedocument.extended-properties+xml', @@ -53,7 +54,11 @@ public function write() $defaults = $contentTypes['default']; if (!empty($contentTypes['override'])) { foreach ($contentTypes['override'] as $key => $val) { - $overrides[$key] = $wordMLPrefix . $val . '+xml'; + if ($val == 'chart') { + $overrides[$key] = $drawingMLPrefix . $val . '+xml'; + } else { + $overrides[$key] = $wordMLPrefix . $val . '+xml'; + } } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index c774e9f352..2e76df121e 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -41,7 +41,7 @@ public function testUnmatchedElements() $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', - 'Field', 'Line', 'Shape' + 'Field', 'Line', 'Shape', 'Chart' ); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; From a93b686ca3826cf83dcec6a46a5dac2a10c9be4e Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 11 Jun 2014 23:04:13 +0700 Subject: [PATCH 030/174] Chart improvements --- src/PhpWord/Element/Chart.php | 4 +- src/PhpWord/Writer/Word2007/Element/Chart.php | 15 +- src/PhpWord/Writer/Word2007/Part/Chart.php | 281 ++++++++---------- 3 files changed, 135 insertions(+), 165 deletions(-) diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php index 46b7b784c4..5a93b8276a 100644 --- a/src/PhpWord/Element/Chart.php +++ b/src/PhpWord/Element/Chart.php @@ -69,7 +69,7 @@ public function __construct($type, $labels, $data) /** * Get type * - * @return array + * @return string */ public function getType() { @@ -79,7 +79,7 @@ public function getType() /** * Set type * - * @param array $value + * @param string $value */ public function setType($value) { diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php index 3c4e43f2e1..454ebce54c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Chart.php +++ b/src/PhpWord/Writer/Word2007/Element/Chart.php @@ -37,6 +37,8 @@ public function write() return; } + $rId = $element->getRelationId(); + if (!$this->withoutP) { $xmlWriter->startElement('w:p'); } @@ -46,15 +48,8 @@ public function write() $xmlWriter->startElement('wp:inline'); // EMU - $xmlWriter->startElement('wp:extent'); - $xmlWriter->writeAttribute('cx', '2000000'); - $xmlWriter->writeAttribute('cy', '2000000'); - $xmlWriter->endElement(); // wp:extent - - $xmlWriter->startElement('wp:docPr'); - $xmlWriter->writeAttribute('id', $element->getRelationId()); - $xmlWriter->writeAttribute('name', 'Chart'. $element->getRelationId()); - $xmlWriter->endElement(); // wp:docPr + $xmlWriter->writeBlock('wp:extent', array('cx' => '2000000', 'cy' => '2000000')); + $xmlWriter->writeBlock('wp:docPr', array('id' => $rId, 'name' => "Chart{$rId}")); $xmlWriter->startElement('a:graphic'); $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); @@ -62,7 +57,7 @@ public function write() $xmlWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); $xmlWriter->startElement('c:chart'); - $xmlWriter->writeAttribute('r:id', 'rId' . $element->getRelationId()); + $xmlWriter->writeAttribute('r:id', "rId{$rId}"); $xmlWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $xmlWriter->endElement(); // c:chart diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 13525fe778..8d9220136d 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -24,6 +24,7 @@ * Word2007 chart part writer: word/charts/chartx.xml * * @since 0.12.0 + * @link http://www.datypic.com/sc/ooxml/e-draw-chart_chartSpace.html * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ class Chart extends AbstractPart @@ -35,6 +36,18 @@ class Chart extends AbstractPart */ private $element; + private $types = array( + 'pie' => array('type' => 'pieChart', 'colors' => 1), + 'doughnut' => array('type' => 'doughnutChart', 'colors' => 1, 'hole' => 75), + 'bar' => array('type' => 'barChart', 'colors' => 0, 'axes' => true, 'bar' => 'col'), + 'line' => array('type' => 'lineChart', 'colors' => 0, 'axes' => true), + 'area' => array('type' => 'areaChart', 'colors' => 0, 'axes' => true), + 'radar' => array('type' => 'radarChart', 'colors' => 0, 'axes' => true, 'radar' => 'standard'), + 'scatter' => array('type' => 'scatterChart', 'colors' => 0, 'axes' => true, 'scatter' => 'marker'), + ); + + private $options = array(); + /** * Set chart element */ @@ -58,11 +71,13 @@ public function write() $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeBlock('c:roundedCorners', 'val', '0'); + $xmlWriter->writeBlock('c:date1904', 'val', 1); + $xmlWriter->writeBlock('c:lang', 'val', 'en-US'); + $xmlWriter->writeBlock('c:roundedCorners', 'val', 0); + + $this->writeChart($xmlWriter); + $this->writeShape($xmlWriter); - $xmlWriter->startElement('c:chart'); - $this->writePlotArea($xmlWriter); - $xmlWriter->endElement(); // c:chart $xmlWriter->endElement(); // c:chartSpace @@ -70,162 +85,76 @@ public function write() } /** - * Write plot area - */ - private function writePlotArea(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:plotArea'); - - $method = "write{$this->element->getType()}Chart"; - $this->$method($xmlWriter); - - $xmlWriter->endElement(); // c:plotArea - } - - /** - * Write pie chart + * Write chart * - * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html */ - private function writePieChart(XMLWriter $xmlWriter) + private function writeChart(XMLWriter $xmlWriter) { - $xmlWriter->startElement('c:pieChart'); + $xmlWriter->startElement('c:chart'); - $xmlWriter->writeBlock('c:varyColors', 'val', '1'); + $xmlWriter->writeBlock('c:autoTitleDeleted', 'val', 1); + $xmlWriter->writeBlock('c:dispBlanksAs', 'val', 'zero'); - $this->writeSeries($xmlWriter); + $this->writePlotArea($xmlWriter); + // $this->writeLegend($xmlWriter); - $xmlWriter->endElement(); // c:pie3DChart + $xmlWriter->endElement(); // c:chart } /** - * Write doughnut chart + * Write plot area * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PlotArea.html + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_DoughnutChart.html - */ - private function writeDoughnutChart(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:doughnutChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '1'); - $xmlWriter->writeBlock('c:holeSize', 'val', '75'); - - $this->writeSeries($xmlWriter); - - $xmlWriter->endElement(); // c:doughnutChart - } - - /** - * Write bar chart - * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_BarChart.html - */ - private function writeBarChart(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:barChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '0'); - $xmlWriter->writeBlock('c:barDir', 'val', 'col'); // bar|col - $xmlWriter->writeBlock('c:axId', 'val', '1'); - $xmlWriter->writeBlock('c:axId', 'val', '2'); - - $this->writeSeries($xmlWriter); - - $xmlWriter->endElement(); // c:barChart - - // Axes - $this->writeAxis($xmlWriter, 'cat'); - $this->writeAxis($xmlWriter, 'val'); - } - - /** - * Write line chart - * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_LineChart.html - */ - private function writeLineChart(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:lineChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '0'); - $xmlWriter->writeBlock('c:axId', 'val', '1'); - $xmlWriter->writeBlock('c:axId', 'val', '2'); - - $this->writeSeries($xmlWriter); - - $xmlWriter->endElement(); // c:lineChart - - // Axes - $this->writeAxis($xmlWriter, 'cat'); - $this->writeAxis($xmlWriter, 'val'); - } - - /** - * Write area chart - * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html - */ - private function writeAreaChart(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:areaChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '0'); - $xmlWriter->writeBlock('c:axId', 'val', '1'); - $xmlWriter->writeBlock('c:axId', 'val', '2'); - - $this->writeSeries($xmlWriter); - - $xmlWriter->endElement(); // c:areaChart - - // Axes - $this->writeAxis($xmlWriter, 'cat'); - $this->writeAxis($xmlWriter, 'val'); - } - - /** - * Write radar chart - * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html */ - private function writeRadarChart(XMLWriter $xmlWriter) + private function writePlotArea(XMLWriter $xmlWriter) { - $xmlWriter->startElement('c:radarChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '0'); - $xmlWriter->writeBlock('c:radarStyle', 'val', 'standard'); - $xmlWriter->writeBlock('c:axId', 'val', '1'); - $xmlWriter->writeBlock('c:axId', 'val', '2'); - - $this->writeSeries($xmlWriter); + $type = $this->element->getType(); + $this->options = $this->types[$type]; - $xmlWriter->endElement(); // c:radarChart + $xmlWriter->startElement('c:plotArea'); + $xmlWriter->writeElement('c:layout'); - // Axes - $this->writeAxis($xmlWriter, 'cat'); - $this->writeAxis($xmlWriter, 'val'); - } + // Chart + $xmlWriter->startElement('c:' . $this->options['type']); - /** - * Write scatter chart - * - * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html - */ - private function writeScatterChart(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:scatterChart'); - - $xmlWriter->writeBlock('c:varyColors', 'val', '0'); - $xmlWriter->writeBlock('c:scatterStyle', 'val', 'lineMarker'); - $xmlWriter->writeBlock('c:axId', 'val', '1'); - $xmlWriter->writeBlock('c:axId', 'val', '2'); + $xmlWriter->writeBlock('c:varyColors', 'val', $this->options['colors']); + if (isset($this->options['hole'])) { + $xmlWriter->writeBlock('c:holeSize', 'val', $this->options['hole']); + } + if (isset($this->options['bar'])) { + $xmlWriter->writeBlock('c:barDir', 'val', $this->options['bar']); // bar|col + } + if (isset($this->options['radar'])) { + $xmlWriter->writeBlock('c:radarStyle', 'val', $this->options['radar']); + } + if (isset($this->options['scatter'])) { + $xmlWriter->writeBlock('c:scatterStyle', 'val', $this->options['scatter']); + } + if (isset($this->options['axes'])) { + $xmlWriter->writeBlock('c:axId', 'val', 1); + $xmlWriter->writeBlock('c:axId', 'val', 2); + } - $this->writeSeries($xmlWriter, true); + // Series + $this->writeSeries($xmlWriter, isset($this->options['scatter'])); - $xmlWriter->endElement(); // c:scatterChart + $xmlWriter->endElement(); // chart type // Axes - $this->writeAxis($xmlWriter, 'cat'); - $this->writeAxis($xmlWriter, 'val'); + if (isset($this->options['axes'])) { + $this->writeAxis($xmlWriter, 'cat'); + $this->writeAxis($xmlWriter, 'val'); + } + + $xmlWriter->endElement(); // c:plotArea } /** @@ -238,8 +167,16 @@ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) { $xmlWriter->startElement('c:ser'); - $xmlWriter->writeBlock('c:idx', 'val', '0'); - $xmlWriter->writeBlock('c:order', 'val', '0'); + $xmlWriter->writeBlock('c:idx', 'val', 0); + $xmlWriter->writeBlock('c:order', 'val', 0); + + if (isset($this->options['scatter'])) { + $xmlWriter->startElement('c:spPr'); + $xmlWriter->startElement('a:ln'); + $xmlWriter->writeElement('a:noFill'); + $xmlWriter->endElement(); // a:ln + $xmlWriter->endElement(); // c:spPr + } if ($scatter === true) { $this->writeSeriesItems($xmlWriter, 'xVal', $this->element->getLabels()); @@ -262,16 +199,15 @@ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) private function writeSeriesItems(XMLWriter $xmlWriter, $type, $values) { $types = array( - 'cat' => array('c:cat', 'c:strRef', 'c:strCache'), - 'val' => array('c:val', 'c:numRef', 'c:numCache'), - 'xVal' => array('c:xVal', 'c:strRef', 'c:strCache'), - 'yVal' => array('c:yVal', 'c:numRef', 'c:numCache'), + 'cat' => array('c:cat', 'c:strLit'), + 'val' => array('c:val', 'c:numLit'), + 'xVal' => array('c:xVal', 'c:strLit'), + 'yVal' => array('c:yVal', 'c:numLit'), ); - list($itemType, $itemRef, $itemCache) = $types[$type]; + list($itemType, $itemLit) = $types[$type]; $xmlWriter->startElement($itemType); - $xmlWriter->startElement($itemRef); - $xmlWriter->startElement($itemCache); + $xmlWriter->startElement($itemLit); $index = 0; foreach ($values as $value) { @@ -286,9 +222,7 @@ private function writeSeriesItems(XMLWriter $xmlWriter, $type, $values) $index++; } - $xmlWriter->endElement(); // $itemCache - - $xmlWriter->endElement(); // $itemRef + $xmlWriter->endElement(); // $itemLit $xmlWriter->endElement(); // $itemType } @@ -302,8 +236,8 @@ private function writeSeriesItems(XMLWriter $xmlWriter, $type, $values) private function writeAxis(XMLWriter $xmlWriter, $type) { $types = array( - 'cat' => array('c:catAx', '1', 'b', '2'), - 'val' => array('c:valAx', '2', 'l', '1'), + 'cat' => array('c:catAx', 1, 'b', 2), + 'val' => array('c:valAx', 2, 'l', 1), ); list($axisType, $axisId, $axisPos, $axisCross) = $types[$type]; @@ -312,6 +246,18 @@ private function writeAxis(XMLWriter $xmlWriter, $type) $xmlWriter->writeBlock('c:axId', 'val', $axisId); $xmlWriter->writeBlock('c:axPos', 'val', $axisPos); $xmlWriter->writeBlock('c:crossAx', 'val', $axisCross); + $xmlWriter->writeBlock('c:auto', 'val', 1); + + if (isset($this->options['axes'])) { + $xmlWriter->writeBlock('c:delete', 'val', 0); + $xmlWriter->writeBlock('c:majorTickMark', 'val', 'none'); + $xmlWriter->writeBlock('c:minorTickMark', 'val', 'none'); + $xmlWriter->writeBlock('c:tickLblPos', 'val', 'none'); // nextTo + // $xmlWriter->writeBlock('c:crosses', 'val', 'autoZero'); + } + if (isset($this->options['radar'])) { + $xmlWriter->writeElement('c:majorGridlines'); + } $xmlWriter->startElement('c:scaling'); $xmlWriter->writeBlock('c:orientation', 'val', 'minMax'); @@ -319,13 +265,42 @@ private function writeAxis(XMLWriter $xmlWriter, $type) $xmlWriter->startElement('c:spPr'); $xmlWriter->writeElement('a:noFill'); + $xmlWriter->startElement('a:ln'); $xmlWriter->startElement('a:solidFill'); - $xmlWriter->writeBlock('a:srgbClr', 'val', '0FB7'); + // $xmlWriter->writeBlock('a:srgbClr', 'val', '0FF000'); $xmlWriter->endElement(); // a:solidFill $xmlWriter->endElement(); // a:ln - $xmlWriter->endElement(); // c:crossAx - $xmlWriter->endElement(); // $type + $xmlWriter->endElement(); // c:spPr + + $xmlWriter->endElement(); // $axisType + } + + /** + * Write legend + * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Legend.html + */ + private function writeLegend(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:legend'); + $xmlWriter->writeElement('c:layout'); + $xmlWriter->writeBlock('c:legendPos', 'val', 'r'); + $xmlWriter->endElement(); // c:legend + } + + /** + * Write shape + * + * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html + */ + private function writeShape(XMLWriter $xmlWriter) + { + $xmlWriter->startElement('c:spPr'); + $xmlWriter->startElement('a:ln'); + $xmlWriter->writeElement('a:noFill'); + $xmlWriter->endElement(); // a:ln + $xmlWriter->endElement(); // c:spPr } } From f54d9a1eb443dbb8dc631ff8eb8f25fe9bafa25c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 12 Jun 2014 02:25:34 +0700 Subject: [PATCH 031/174] #274: Page breaks on titles and tables --- CHANGELOG.md | 1 + .../Word2007/Element/AbstractElement.php | 32 ------------------- .../Writer/Word2007/Element/Container.php | 12 ------- .../Writer/Word2007/Element/PageBreak.php | 6 ++-- src/PhpWord/Writer/Word2007/Part/Settings.php | 3 +- .../Writer/Word2007/Part/DocumentTest.php | 6 ++-- 6 files changed, 8 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b741e57f6..ebfd326392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme - Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 - `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 +- Page breaks on titles and tables - @ivanlanin GH-274 ### Deprecated diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index e17640c864..1cbf213bb8 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -50,13 +50,6 @@ abstract class AbstractElement */ protected $withoutP = false; - /** - * Has page break before - * - * @var bool - */ - private $pageBreakBefore = false; - /** * Write element */ @@ -96,26 +89,6 @@ protected function getElement() return $this->element; } - /** - * Has page break before - * - * @return bool - */ - public function hasPageBreakBefore() - { - return $this->pageBreakBefore; - } - - /** - * Set page break before - * - * @param bool $value - */ - public function setPageBreakBefore($value = true) - { - $this->pageBreakBefore = (bool)$value; - } - /** * Start w:p DOM element * @@ -129,11 +102,6 @@ protected function startElementP() if (method_exists($this->element, 'getParagraphStyle')) { $this->writeParagraphStyle(); } - // PageBreak - if ($this->pageBreakBefore) { - $elementWriter = new PageBreak($this->xmlWriter, new PageBreakElement()); - $elementWriter->write(); - } } } diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 3dad824df1..9504b7a61b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -81,21 +81,9 @@ private function writeElement(XMLWriter $xmlWriter, Element $element, $withoutP) $elementClass = substr(get_class($element), strrpos(get_class($element), '\\') + 1); $writerClass = $this->namespace . '\\' . $elementClass; - // 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; - } - 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(); } diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index 47f3feb5bf..be317089a6 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -20,9 +20,6 @@ /** * PageBreak element writer * - * Originally, page break is rendered as a `w:p`, but this turns out to produce bug #150. - * As of 0.11.0, page break is rendered as a `w:r` with `w:br` type "page" and `w:lastRenderedPageBreak` - * * @since 0.10.0 */ class PageBreak extends AbstractElement @@ -36,11 +33,12 @@ public function write() { $xmlWriter = $this->getXmlWriter(); + $xmlWriter->startElement('w:p'); $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:br'); $xmlWriter->writeAttribute('w:type', 'page'); $xmlWriter->endElement(); // w:br - $xmlWriter->writeElement('w:lastRenderedPageBreak'); $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:p } } diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index 784a5d1e35..d8535d8c59 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -50,7 +50,8 @@ public function write() 'w:autofitToFirstFixedWidthCell' => '', 'w:underlineTabInNumList' => '', 'w:displayHangulFixedWidth' => '', - 'w:splitPgBreakAndParaMark' => '', + // Commented for GH-274 + // 'w:splitPgBreakAndParaMark' => '', 'w:doNotVertAlignCellWithSp' => '', 'w:doNotBreakConstrainedForcedTable' => '', 'w:doNotVertAlignInTxbx' => '', diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php index de5d63e88b..56be15d0cc 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -114,15 +114,15 @@ public function testElements() $this->assertEquals('page', $element->getAttribute('w:type')); // Title - $element = $doc->getElement('/w:document/w:body/w:p[5]/w:pPr/w:pStyle'); + $element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:pStyle'); $this->assertEquals('Heading1', $element->getAttribute('w:val')); // List item - $element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:numPr/w:numId'); + $element = $doc->getElement('/w:document/w:body/w:p[7]/w:pPr/w:numPr/w:numId'); $this->assertEquals(3, $element->getAttribute('w:val')); // Object - $element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject'); + $element = $doc->getElement('/w:document/w:body/w:p[12]/w:r/w:object/o:OLEObject'); $this->assertEquals('Embed', $element->getAttribute('Type')); } From e9f8e889f8fef4e141d14505e861d7995ad558a3 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 12 Jun 2014 02:41:49 +0700 Subject: [PATCH 032/174] #275: Recipe for adding a link within a title --- docs/recipes.rst | 22 ++++++++++++++++++++++ docs/src/documentation.md | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/recipes.rst b/docs/recipes.rst index d5678a520e..1b529d7bca 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -65,3 +65,25 @@ Define a numbering style and title styles, and match the two styles (with ``pSty $section->addTitle('Heading 1', 1); $section->addTitle('Heading 2', 2); $section->addTitle('Heading 3', 3); + +Add a link within a title +------------------------- + +Apply 'HeadingN' paragraph style to TextRun or Link. Sample code: + +.. code-block:: php + + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true)); + $phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true)); + $phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single')); + + $section = $phpWord->addSection(); + + // Textrun + $textrun = $section->addTextRun('Heading1'); + $textrun->addText('The '); + $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link'); + + // Link + $section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2'); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 144222c197..49505c7fdf 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -1017,6 +1017,27 @@ $section->addTitle('Heading 2', 2); $section->addTitle('Heading 3', 3); ``` +## Add a link within a title + +Apply 'HeadingN' paragraph style to TextRun or Link. Sample code: + +```php +$phpWord = new \PhpOffice\PhpWord\PhpWord(); +$phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true)); +$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true)); +$phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single')); + +$section = $phpWord->addSection(); + +// Textrun +$textrun = $section->addTextRun('Heading1'); +$textrun->addText('The '); +$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link'); + +// Link +$section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2'); +``` + # Frequently asked questions ## Is this the same with PHPWord that I found in CodePlex? From 8c2b099dbc428ce6dfb473023f91b472ce5659ab Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 14 Jun 2014 07:19:00 +0700 Subject: [PATCH 033/174] Merge `Shared\Drawing` and `Shared\Font` into `Shared\Converter` --- CHANGELOG.md | 3 + docs/general.rst | 6 +- docs/src/documentation.md | 6 +- samples/Sample_08_ParagraphPagination.php | 2 +- samples/Sample_13_Images.php | 12 +- samples/Sample_29_Line.php | 20 +- src/PhpWord/Shared/Converter.php | 245 ++++++++++++++++++ src/PhpWord/Shared/Drawing.php | 66 +---- src/PhpWord/Shared/Font.php | 21 +- src/PhpWord/Writer/ODText/Element/Image.php | 6 +- src/PhpWord/Writer/RTF/Element/Image.php | 6 +- src/PhpWord/Writer/RTF/Part/Header.php | 4 +- .../Word2007/Element/AbstractElement.php | 1 - tests/PhpWord/Tests/Element/LineTest.php | 16 +- tests/PhpWord/Tests/Element/TextBoxTest.php | 8 +- tests/PhpWord/Tests/Shared/ConverterTest.php | 108 ++++++++ tests/PhpWord/Tests/Shared/DrawingTest.php | 82 ------ tests/PhpWord/Tests/Shared/FontTest.php | 58 ----- 18 files changed, 424 insertions(+), 246 deletions(-) create mode 100644 src/PhpWord/Shared/Converter.php create mode 100644 tests/PhpWord/Tests/Shared/ConverterTest.php delete mode 100644 tests/PhpWord/Tests/Shared/DrawingTest.php delete mode 100644 tests/PhpWord/Tests/Shared/FontTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfd326392..5290ccb320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme - RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 - Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 - General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin +- General: New `Shared\Converter` static class - @ivanlanin ### Bugfixes @@ -25,6 +26,8 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme - `Element\Link::getTarget()` replaced by `Element\Link::getSource()` - `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` +- `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter` + ### Miscellaneous diff --git a/docs/general.rst b/docs/general.rst index 60d9b609c8..a2498affcc 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -130,13 +130,13 @@ points to twips. // Paragraph with 6 points space after $phpWord->addParagraphStyle('My Style', array( - 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(6)) ); $section = $phpWord->addSection(); $sectionStyle = $section->getStyle(); // half inch left margin - $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); + $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5)); // 2 cm right margin - $sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); + $sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2)); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 49505c7fdf..6ad2f67a7b 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -301,15 +301,15 @@ You can use PHPWord helper functions to convert inches, centimeters, or points t ```php // Paragraph with 6 points space after $phpWord->addParagraphStyle('My Style', array( - 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(6)) ); $section = $phpWord->addSection(); $sectionStyle = $section->getStyle(); // half inch left margin -$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); +$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5)); // 2 cm right margin -$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); +$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2)); ``` # Containers diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index d3f0c1fb3c..f39147588a 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -6,7 +6,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultParagraphStyle(array( 'align' => 'both', - 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), 'spacing' => 120, )); diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index dd0c88012d..29b3e73341 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -37,14 +37,14 @@ $section->addImage( 'resources/_mars.jpg', array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT, 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, - 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.5), - 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1.55) + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55) ) ); @@ -55,8 +55,8 @@ $section->addImage( 'resources/_mars.jpg', array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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, diff --git a/samples/Sample_29_Line.php b/samples/Sample_29_Line.php index 5a955702b7..f9162c2a7d 100644 --- a/samples/Sample_29_Line.php +++ b/samples/Sample_29_Line.php @@ -13,16 +13,16 @@ $section->addText('Horizontal Line (Inline style):'); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(0), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), 'positioning' => 'absolute' ) ); @@ -32,13 +32,13 @@ $section->addText('Positioned Line (red):'); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(1), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), 'positioning' => 'absolute', 'posHorizontalRel' => 'page', 'posVerticalRel' => 'page', - 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(10), - 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(8), + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8), 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, 'color' => 'red' ) @@ -47,8 +47,8 @@ $section->addText('Horizontal Formatted Line'); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(0), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), 'positioning' => 'absolute', 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK, 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL, diff --git a/src/PhpWord/Shared/Converter.php b/src/PhpWord/Shared/Converter.php new file mode 100644 index 0000000000..8bc1cecf07 --- /dev/null +++ b/src/PhpWord/Shared/Converter.php @@ -0,0 +1,245 @@ +getMediaIndex(); $target = 'Pictures/' . $element->getTarget(); $style = $element->getStyle(); - $width = Drawing::pixelsToCentimeters($style->getWidth()); - $height = Drawing::pixelsToCentimeters($style->getHeight()); + $width = Converter::pixelToCm($style->getWidth()); + $height = Converter::pixelToCm($style->getHeight()); $xmlWriter->startElement('text:p'); $xmlWriter->writeAttribute('text:style-name', 'Standard'); diff --git a/src/PhpWord/Writer/RTF/Element/Image.php b/src/PhpWord/Writer/RTF/Element/Image.php index 1daae2a0f3..52e705e9e2 100644 --- a/src/PhpWord/Writer/RTF/Element/Image.php +++ b/src/PhpWord/Writer/RTF/Element/Image.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; use PhpOffice\PhpWord\Element\Image as ImageElement; -use PhpOffice\PhpWord\Shared\Font; +use PhpOffice\PhpWord\Shared\Converter; /** * Image element RTF writer @@ -45,8 +45,8 @@ public function write() $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 .= '\picwgoal' . round(Converter::pixelToTwip($style->getWidth())); + $content .= '\pichgoal' . round(Converter::pixelToTwip($style->getHeight())); $content .= PHP_EOL; $content .= $this->element->getImageStringData(); $content .= '}}'; diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index 4d8d3a2726..68cf1803e3 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Part; use PhpOffice\PhpWord\Settings; -use PhpOffice\PhpWord\Shared\Drawing; +use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; @@ -151,7 +151,7 @@ private function writeColorTable() $content .= '{'; $content .= '\colortbl;'; foreach ($this->colorTable as $color) { - list($red, $green, $blue) = Drawing::htmlToRGB($color); + list($red, $green, $blue) = Converter::htmlToRgb($color); $content .= "\\red{$red}\\green{$green}\\blue{$blue};"; } $content .= '}'; diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 1cbf213bb8..b98b983dee 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\Element\PageBreak as PageBreakElement; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\XMLWriter; diff --git a/tests/PhpWord/Tests/Element/LineTest.php b/tests/PhpWord/Tests/Element/LineTest.php index 429f9df69c..5add9a6b07 100644 --- a/tests/PhpWord/Tests/Element/LineTest.php +++ b/tests/PhpWord/Tests/Element/LineTest.php @@ -37,17 +37,17 @@ public function testConstruct() $this->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 */ @@ -55,14 +55,14 @@ public function testStyleArray() { $oLine = new Line( array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(14), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(14), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), 'positioning' => 'absolute', 'posHorizontalRel' => 'page', 'posVerticalRel' => 'page', 'flip' => true, - 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(5), - 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(3), + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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, @@ -70,7 +70,7 @@ public function testStyleArray() 'weight' => 10 ) ); - + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Line', $oLine->getStyle()); } } diff --git a/tests/PhpWord/Tests/Element/TextBoxTest.php b/tests/PhpWord/Tests/Element/TextBoxTest.php index c3c89ed4cb..2c6da4655d 100644 --- a/tests/PhpWord/Tests/Element/TextBoxTest.php +++ b/tests/PhpWord/Tests/Element/TextBoxTest.php @@ -55,11 +55,11 @@ public function testStyleArray() { $oTextBox = new TextBox( array( - 'width' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(4.5), - 'height' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(17.5), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4.5), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(17.5), 'positioning' => 'absolute', - 'marginLeft' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(15.4), - 'marginTop' => \PhpOffice\PhpWord\Shared\Drawing::centimetersToPixels(9.9), + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.4), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(9.9), 'stroke' => 0, 'innerMargin' => 0, 'borderSize' => 1, diff --git a/tests/PhpWord/Tests/Shared/ConverterTest.php b/tests/PhpWord/Tests/Shared/ConverterTest.php new file mode 100644 index 0000000000..9525148cc4 --- /dev/null +++ b/tests/PhpWord/Tests/Shared/ConverterTest.php @@ -0,0 +1,108 @@ +assertEquals($value / 2.54 * 1440, $result); + + $result = Converter::cmToInch($value); + $this->assertEquals($value / 2.54, $result); + + $result = Converter::cmToPixel($value); + $this->assertEquals($value / 2.54 * 96, $result); + + $result = Converter::inchToTwip($value); + $this->assertEquals($value * 1440, $result); + + $result = Converter::inchToCm($value); + $this->assertEquals($value * 2.54, $result); + + $result = Converter::inchToPixel($value); + $this->assertEquals($value * 96, $result); + + $result = Converter::inchToPoint($value); + $this->assertEquals($value * 72, $result); + + $result = Converter::pixelToTwip($value); + $this->assertEquals($value / 96 * 1440, $result); + + $result = Converter::pixelToCm($value); + $this->assertEquals($value / 96 * 2.54, $result); + + $result = Converter::pixelToPoint($value); + $this->assertEquals($value / 96 * 72, $result); + + $result = Converter::pixelToEMU($value); + $this->assertEquals(round($value * 9525), $result); + + $result = Converter::pointToTwip($value); + $this->assertEquals($value * 20, $result); + + $result = Converter::pointToPixel($value); + $this->assertEquals($value / 72 * 96, $result); + + $result = Converter::pointToEMU($value); + $this->assertEquals(round($value / 72 * 96 * 9525), $result); + + $result = Converter::emuToPixel($value); + $this->assertEquals(round($value / 9525), $result); + + $result = Converter::degreeToAngle($value); + $this->assertEquals((int)round($value * 60000), $result); + + $result = Converter::angleToDegree($value); + $this->assertEquals(round($value / 60000), $result); + } + } + + /** + * Test htmlToRGB() + */ + public function testHtmlToRGB() + { + // Prepare test values [ original, expected ] + $values[] = array('#FF99DD', array(255, 153, 221)); // With # + $values[] = array('FF99DD', array(255, 153, 221)); // 6 characters + $values[] = array('F9D', array(255, 153, 221)); // 3 characters + $values[] = array('0F9D', false); // 4 characters + // Conduct test + foreach ($values as $value) { + $result = Converter::htmlToRGB($value[0]); + $this->assertEquals($value[1], $result); + } + } +} diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php deleted file mode 100644 index 25fd3a3886..0000000000 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ /dev/null @@ -1,82 +0,0 @@ -assertEquals(round($value * 9525), $result); - - $result = Drawing::emuToPixels($value); - $this->assertEquals(round($value / 9525), $result); - - $result = Drawing::pixelsToPoints($value); - $this->assertEquals($value * 0.75, $result); - - $result = Drawing::pointsToPixels($value); - $this->assertEquals($value * 1.333333333, $result); - - $result = Drawing::degreesToAngle($value); - $this->assertEquals((int)round($value * 60000), $result); - - $result = Drawing::angleToDegrees($value); - $this->assertEquals(round($value / 60000), $result); - - $result = Drawing::pixelsToCentimeters($value); - $this->assertEquals($value * 0.026458333, $result); - - $result = Drawing::centimetersToPixels($value); - $this->assertEquals($value / 0.026458333, $result); - } - } - - /** - * Test htmlToRGB() - */ - public function testHtmlToRGB() - { - // Prepare test values [ original, expected ] - $values[] = array('#FF99DD', array(255, 153, 221)); // With # - $values[] = array('FF99DD', array(255, 153, 221)); // 6 characters - $values[] = array('F9D', array(255, 153, 221)); // 3 characters - $values[] = array('0F9D', false); // 4 characters - // Conduct test - foreach ($values as $value) { - $result = Drawing::htmlToRGB($value[0]); - $this->assertEquals($value[1], $result); - } - } -} diff --git a/tests/PhpWord/Tests/Shared/FontTest.php b/tests/PhpWord/Tests/Shared/FontTest.php deleted file mode 100644 index c10f773959..0000000000 --- a/tests/PhpWord/Tests/Shared/FontTest.php +++ /dev/null @@ -1,58 +0,0 @@ -assertEquals($original * 16 / 12, $result); - - $result = Font::inchSizeToPixels($original); - $this->assertEquals($original * 96, $result); - - $result = Font::centimeterSizeToPixels($original); - $this->assertEquals($original * 37.795275591, $result); - - $result = Font::centimeterSizeToTwips($original); - $this->assertEquals($original * 565.217, $result); - - $result = Font::inchSizeToTwips($original); - $this->assertEquals($original * 565.217 * 2.54, $result); - - $result = Font::pixelSizeToTwips($original); - $this->assertEquals($original * 565.217 / 37.795275591, $result); - - $result = Font::pointSizeToTwips($original); - $this->assertEquals($original * 20, $result); - } -} From 3fef19093c9deaf8bdcb024bfad056451c0e0bdd Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Thu, 12 Jun 2014 18:15:00 +0700 Subject: [PATCH 034/174] #278: Basic chart --- CHANGELOG.md | 1 + README.md | 2 + docs/elements.rst | 7 + docs/intro.rst | 2 + docs/src/documentation.md | 8 + samples/Sample_32_Chart.php | 22 ++- src/PhpWord/Element/Chart.php | 55 ++----- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Writer/Word2007/Element/Chart.php | 4 +- src/PhpWord/Writer/Word2007/Part/Chart.php | 140 +++++++++--------- tests/PhpWord/Tests/Writer/RTFTest.php | 2 +- .../Tests/Writer/Word2007/ElementTest.php | 26 ++++ 12 files changed, 149 insertions(+), 122 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfd326392..302cbf9858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) eleme - RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 - Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 - General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin +- Element: Basic 2D charts (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 ### Bugfixes diff --git a/README.md b/README.md index 97e5b6425c..5a432cba6f 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your - Insert list items as bulleted, numbered, or multilevel - Insert hyperlinks - Insert footnotes and endnotes +- Insert drawing shapes (arc, curve, line, polyline, rect, oval) +- Insert charts (pie, doughnut, bar, line, area, scatter, radar) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template - ... and many more features on progress diff --git a/docs/elements.rst b/docs/elements.rst index a01c9fd421..ee8273260b 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -49,6 +49,8 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 20 | Shape | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 21 | Chart | v | - | - | - | - | - | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -399,3 +401,8 @@ Shapes ------ To be completed. + +Charts +------ + +To be completed. diff --git a/docs/intro.rst b/docs/intro.rst index 5045d4dc1d..241b581ce0 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -45,6 +45,8 @@ Features - Insert list items as bulleted, numbered, or multilevel - Insert hyperlinks - Insert footnotes and endnotes +- Insert drawing shapes (arc, curve, line, polyline, rect, oval) +- Insert charts (pie, doughnut, bar, line, area, scatter, radar) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 49505c7fdf..0b21f63492 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -37,6 +37,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Fields](#fields) - [Lines](#lines) - [Shapes](#shapes) + - [Charts](#charts) - [Styles](#styles) - [Section](#section) - [Font](#font) @@ -76,6 +77,8 @@ PHPWord is an open source project licensed under the terms of [LGPL version 3](h - Insert list items as bulleted, numbered, or multilevel - Insert hyperlinks - Insert footnotes and endnotes +- Insert drawing shapes (arc, curve, line, polyline, rect, oval) +- Insert charts (pie, doughnut, bar, line, area, scatter, radar) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template - ... and many more features on progress @@ -440,6 +443,7 @@ Below are the matrix of element availability in each container. The column shows | 18 | Field | v | v | v | v | v | v | | 19 | Line | v | v | v | v | v | v | | 20 | Shape | v | v | v | v | v | v | +| 21 | Chart | v | - | - | - | - | - | Legend: @@ -737,6 +741,10 @@ To be completed. To be completed. +## Charts + +To be completed. + # Styles ## Section diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php index 52c19f3c61..26d6c420cf 100644 --- a/samples/Sample_32_Chart.php +++ b/samples/Sample_32_Chart.php @@ -9,13 +9,23 @@ $section = $phpWord->addSection(array('colsNum' => 2)); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); -$charts = array('pie', 'doughnut', 'line', 'area', 'scatter', 'bar', 'radar'); -$labels = array('A', 'B', 'C', 'D', 'E'); -$data = array(1, 3, 2, 5, 4); +$chartTypes = array('pie', 'doughnut', 'bar', 'line', 'area', 'scatter', 'radar'); +$twoSeries = array('bar', 'line', 'area', 'scatter', 'radar'); +$threeSeries = array('bar', 'line'); +$categories = array('A', 'B', 'C', 'D', 'E'); +$series1 = array(1, 3, 2, 5, 4); +$series2 = array(3, 1, 7, 2, 6); +$series3 = array(8, 3, 2, 5, 4); -foreach ($charts as $chart) { - $section->addTitle(ucfirst($chart), 1); - $section->addChart($chart, $labels, $data); +foreach ($chartTypes as $chartType) { + $section->addTitle(ucfirst($chartType), 1); + $chart = $section->addChart($chartType, $categories, $series1); + if (in_array($chartType, $twoSeries)) { + $chart->addSeries($categories, $series2); + } + if (in_array($chartType, $threeSeries)) { + $chart->addSeries($categories, $series3); + } $section->addTextBreak(); } diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php index 5a93b8276a..24f2bb78c4 100644 --- a/src/PhpWord/Element/Chart.php +++ b/src/PhpWord/Element/Chart.php @@ -39,31 +39,23 @@ class Chart extends AbstractElement private $type = 'pie'; /** - * Labels + * Series * * @var array */ - private $labels = array(); - - /** - * Data - * - * @var array - */ - private $data = array(); + private $series = array(); /** * Create new instance * * @param string $type - * @param array $labels - * @param array $data + * @param array $categories + * @param array $values */ - public function __construct($type, $labels, $data) + public function __construct($type, $categories, $values) { $this->setType($type); - $this->setLabels($labels); - $this->setData($data); + $this->addSeries($categories, $values); } /** @@ -88,42 +80,23 @@ public function setType($value) } /** - * Get labels - * - * @return array - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Set labels + * Add series * - * @param array $value + * @param array $categories + * @param array $values */ - public function setLabels($value) + public function addSeries($categories, $values) { - $this->labels = $value; + $this->series[] = array('categories' => $categories, 'values' => $values); } /** - * Get data + * Get series * * @return array */ - public function getData() - { - return $this->data; - } - - /** - * Set data - * - * @param array $value - */ - public function setData($value) + public function getSeries() { - $this->data = $value; + return $this->series; } } diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index b2057bb929..8691ae1d9c 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -150,7 +150,7 @@ public function getData() * @param string|array $attributes * @param string $value */ - public function writeBlock($element, $attributes, $value = null) + public function writeElementBlock($element, $attributes, $value = null) { $this->xmlWriter->startElement($element); if (!is_array($attributes)) { diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php index 454ebce54c..4330e2fe74 100644 --- a/src/PhpWord/Writer/Word2007/Element/Chart.php +++ b/src/PhpWord/Writer/Word2007/Element/Chart.php @@ -48,8 +48,8 @@ public function write() $xmlWriter->startElement('wp:inline'); // EMU - $xmlWriter->writeBlock('wp:extent', array('cx' => '2000000', 'cy' => '2000000')); - $xmlWriter->writeBlock('wp:docPr', array('id' => $rId, 'name' => "Chart{$rId}")); + $xmlWriter->writeElementBlock('wp:extent', array('cx' => '2000000', 'cy' => '2000000')); + $xmlWriter->writeElementBlock('wp:docPr', array('id' => $rId, 'name' => "Chart{$rId}")); $xmlWriter->startElement('a:graphic'); $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 8d9220136d..66e4391484 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -25,7 +25,6 @@ * * @since 0.12.0 * @link http://www.datypic.com/sc/ooxml/e-draw-chart_chartSpace.html - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ class Chart extends AbstractPart { @@ -36,6 +35,11 @@ class Chart extends AbstractPart */ private $element; + /** + * Type definition + * + * @var array + */ private $types = array( 'pie' => array('type' => 'pieChart', 'colors' => 1), 'doughnut' => array('type' => 'doughnutChart', 'colors' => 1, 'hole' => 75), @@ -46,6 +50,11 @@ class Chart extends AbstractPart 'scatter' => array('type' => 'scatterChart', 'colors' => 0, 'axes' => true, 'scatter' => 'marker'), ); + /** + * Chart options + * + * @var array + */ private $options = array(); /** @@ -71,14 +80,9 @@ public function write() $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeBlock('c:date1904', 'val', 1); - $xmlWriter->writeBlock('c:lang', 'val', 'en-US'); - $xmlWriter->writeBlock('c:roundedCorners', 'val', 0); - $this->writeChart($xmlWriter); $this->writeShape($xmlWriter); - $xmlWriter->endElement(); // c:chartSpace return $xmlWriter->getData(); @@ -93,11 +97,9 @@ private function writeChart(XMLWriter $xmlWriter) { $xmlWriter->startElement('c:chart'); - $xmlWriter->writeBlock('c:autoTitleDeleted', 'val', 1); - $xmlWriter->writeBlock('c:dispBlanksAs', 'val', 'zero'); + $xmlWriter->writeElementBlock('c:autoTitleDeleted', 'val', 1); $this->writePlotArea($xmlWriter); - // $this->writeLegend($xmlWriter); $xmlWriter->endElement(); // c:chart } @@ -125,27 +127,33 @@ private function writePlotArea(XMLWriter $xmlWriter) // Chart $xmlWriter->startElement('c:' . $this->options['type']); - $xmlWriter->writeBlock('c:varyColors', 'val', $this->options['colors']); + $xmlWriter->writeElementBlock('c:varyColors', 'val', $this->options['colors']); + if ($type == 'area') { + $xmlWriter->writeElementBlock('c:grouping', 'val', 'standard'); + } if (isset($this->options['hole'])) { - $xmlWriter->writeBlock('c:holeSize', 'val', $this->options['hole']); + $xmlWriter->writeElementBlock('c:holeSize', 'val', $this->options['hole']); } if (isset($this->options['bar'])) { - $xmlWriter->writeBlock('c:barDir', 'val', $this->options['bar']); // bar|col + $xmlWriter->writeElementBlock('c:barDir', 'val', $this->options['bar']); // bar|col + $xmlWriter->writeElementBlock('c:grouping', 'val', 'clustered'); } if (isset($this->options['radar'])) { - $xmlWriter->writeBlock('c:radarStyle', 'val', $this->options['radar']); + $xmlWriter->writeElementBlock('c:radarStyle', 'val', $this->options['radar']); } if (isset($this->options['scatter'])) { - $xmlWriter->writeBlock('c:scatterStyle', 'val', $this->options['scatter']); - } - if (isset($this->options['axes'])) { - $xmlWriter->writeBlock('c:axId', 'val', 1); - $xmlWriter->writeBlock('c:axId', 'val', 2); + $xmlWriter->writeElementBlock('c:scatterStyle', 'val', $this->options['scatter']); } // Series $this->writeSeries($xmlWriter, isset($this->options['scatter'])); + // Axes + if (isset($this->options['axes'])) { + $xmlWriter->writeElementBlock('c:axId', 'val', 1); + $xmlWriter->writeElementBlock('c:axId', 'val', 2); + } + $xmlWriter->endElement(); // chart type // Axes @@ -165,28 +173,34 @@ private function writePlotArea(XMLWriter $xmlWriter) */ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) { - $xmlWriter->startElement('c:ser'); + $series = $this->element->getSeries(); + + $index = 0; + foreach ($series as $seriesItem) { + $categories = $seriesItem['categories']; + $values = $seriesItem['values']; - $xmlWriter->writeBlock('c:idx', 'val', 0); - $xmlWriter->writeBlock('c:order', 'val', 0); + $xmlWriter->startElement('c:ser'); - if (isset($this->options['scatter'])) { - $xmlWriter->startElement('c:spPr'); - $xmlWriter->startElement('a:ln'); - $xmlWriter->writeElement('a:noFill'); - $xmlWriter->endElement(); // a:ln - $xmlWriter->endElement(); // c:spPr - } + $xmlWriter->writeElementBlock('c:idx', 'val', $index); + $xmlWriter->writeElementBlock('c:order', 'val', $index); - if ($scatter === true) { - $this->writeSeriesItems($xmlWriter, 'xVal', $this->element->getLabels()); - $this->writeSeriesItems($xmlWriter, 'yVal', $this->element->getData()); - } else { - $this->writeSeriesItems($xmlWriter, 'cat', $this->element->getLabels()); - $this->writeSeriesItems($xmlWriter, 'val', $this->element->getData()); + if (isset($this->options['scatter'])) { + $this->writeShape($xmlWriter); + } + + if ($scatter === true) { + $this->writeSeriesItem($xmlWriter, 'xVal', $categories); + $this->writeSeriesItem($xmlWriter, 'yVal', $values); + } else { + $this->writeSeriesItem($xmlWriter, 'cat', $categories); + $this->writeSeriesItem($xmlWriter, 'val', $values); + } + + $xmlWriter->endElement(); // c:ser + $index++; } - $xmlWriter->endElement(); // c:ser } /** @@ -196,7 +210,7 @@ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) * @param string $type * @param array $values */ - private function writeSeriesItems(XMLWriter $xmlWriter, $type, $values) + private function writeSeriesItem(XMLWriter $xmlWriter, $type, $values) { $types = array( 'cat' => array('c:cat', 'c:strLit'), @@ -243,63 +257,47 @@ private function writeAxis(XMLWriter $xmlWriter, $type) $xmlWriter->startElement($axisType); - $xmlWriter->writeBlock('c:axId', 'val', $axisId); - $xmlWriter->writeBlock('c:axPos', 'val', $axisPos); - $xmlWriter->writeBlock('c:crossAx', 'val', $axisCross); - $xmlWriter->writeBlock('c:auto', 'val', 1); + $xmlWriter->writeElementBlock('c:axId', 'val', $axisId); + $xmlWriter->writeElementBlock('c:axPos', 'val', $axisPos); + $xmlWriter->writeElementBlock('c:crossAx', 'val', $axisCross); + $xmlWriter->writeElementBlock('c:auto', 'val', 1); if (isset($this->options['axes'])) { - $xmlWriter->writeBlock('c:delete', 'val', 0); - $xmlWriter->writeBlock('c:majorTickMark', 'val', 'none'); - $xmlWriter->writeBlock('c:minorTickMark', 'val', 'none'); - $xmlWriter->writeBlock('c:tickLblPos', 'val', 'none'); // nextTo - // $xmlWriter->writeBlock('c:crosses', 'val', 'autoZero'); + $xmlWriter->writeElementBlock('c:delete', 'val', 0); + $xmlWriter->writeElementBlock('c:majorTickMark', 'val', 'none'); + $xmlWriter->writeElementBlock('c:minorTickMark', 'val', 'none'); + $xmlWriter->writeElementBlock('c:tickLblPos', 'val', 'none'); // nextTo + $xmlWriter->writeElementBlock('c:crosses', 'val', 'autoZero'); } if (isset($this->options['radar'])) { $xmlWriter->writeElement('c:majorGridlines'); } $xmlWriter->startElement('c:scaling'); - $xmlWriter->writeBlock('c:orientation', 'val', 'minMax'); + $xmlWriter->writeElementBlock('c:orientation', 'val', 'minMax'); $xmlWriter->endElement(); // c:scaling - $xmlWriter->startElement('c:spPr'); - $xmlWriter->writeElement('a:noFill'); - - $xmlWriter->startElement('a:ln'); - $xmlWriter->startElement('a:solidFill'); - // $xmlWriter->writeBlock('a:srgbClr', 'val', '0FF000'); - $xmlWriter->endElement(); // a:solidFill - $xmlWriter->endElement(); // a:ln - - $xmlWriter->endElement(); // c:spPr + $this->writeShape($xmlWriter, true); $xmlWriter->endElement(); // $axisType } - /** - * Write legend - * - * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Legend.html - */ - private function writeLegend(XMLWriter $xmlWriter) - { - $xmlWriter->startElement('c:legend'); - $xmlWriter->writeElement('c:layout'); - $xmlWriter->writeBlock('c:legendPos', 'val', 'r'); - $xmlWriter->endElement(); // c:legend - } - /** * Write shape * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param bool $line * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html */ - private function writeShape(XMLWriter $xmlWriter) + private function writeShape(XMLWriter $xmlWriter, $line = false) { $xmlWriter->startElement('c:spPr'); $xmlWriter->startElement('a:ln'); - $xmlWriter->writeElement('a:noFill'); + if ($line === true) { + $xmlWriter->writeElement('a:solidFill'); + } else { + $xmlWriter->writeElement('a:noFill'); + } $xmlWriter->endElement(); // a:ln $xmlWriter->endElement(); // c:spPr } diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index c144810674..5b983b3578 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -91,7 +91,7 @@ public function testSave() $this->assertTrue(file_exists($file)); - unlink($file); + @unlink($file); } /** diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 2e76df121e..0ba29f2fc6 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -148,4 +148,30 @@ public function testShapeElements() $this->assertTrue($doc->elementExists($path)); } } + + /** + * Test shape elements + */ + public function testChartElement() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + $chartTypes = array('pie', 'doughnut', 'bar', 'line', 'area', 'scatter', 'radar'); + $categories = array('A', 'B', 'C', 'D', 'E'); + $series1 = array(1, 3, 2, 5, 4); + foreach ($chartTypes as $chartType) { + $section->addChart($chartType, $categories, $series1); + } + + $doc = TestHelperDOCX::getDocument($phpWord); + + $index = 0; + foreach ($chartTypes as $chartType) { + $index++; + $file = "word/charts/chart{$index}.xml"; + $path = "/c:chartSpace/c:chart/c:plotArea/c:{$chartType}Chart"; + $this->assertTrue($doc->elementExists($path, $file)); + } + } } From a13e5b20f98969f6e4ca44d8ab8d4e6180c60501 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 15 Jun 2014 20:48:26 +0700 Subject: [PATCH 035/174] #278: 3D charts and ability to set width and height --- CHANGELOG.md | 3 +- samples/Sample_32_Chart.php | 37 ++++- src/PhpWord/Element/Chart.php | 25 +++- src/PhpWord/Shared/Converter.php | 33 +++++ src/PhpWord/Style/AbstractStyle.php | 4 +- src/PhpWord/Style/Chart.php | 127 ++++++++++++++++++ src/PhpWord/Writer/Word2007/Element/Chart.php | 3 +- src/PhpWord/Writer/Word2007/Part/Chart.php | 23 ++-- tests/PhpWord/Tests/Shared/ConverterTest.php | 9 ++ .../Tests/Writer/Word2007/ElementTest.php | 3 +- 10 files changed, 247 insertions(+), 20 deletions(-) create mode 100644 src/PhpWord/Style/Chart.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c646ac2c..155ecb3505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) and b - Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 - General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin - General: New `Shared\Converter` static class - @ivanlanin -- Element: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 +- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 +- Chart: 3D charts and ability to set width and height - @ivanlanin ### Bugfixes diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php index 26d6c420cf..5f2188ed42 100644 --- a/samples/Sample_32_Chart.php +++ b/samples/Sample_32_Chart.php @@ -1,16 +1,22 @@ addSection(array('colsNum' => 2)); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); +$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); + +// 2D charts +$section = $phpWord->addSection(); +$section->addTitle('2D charts', 1); +$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous')); -$chartTypes = array('pie', 'doughnut', 'bar', 'line', 'area', 'scatter', 'radar'); -$twoSeries = array('bar', 'line', 'area', 'scatter', 'radar'); +$chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar'); +$twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar'); $threeSeries = array('bar', 'line'); $categories = array('A', 'B', 'C', 'D', 'E'); $series1 = array(1, 3, 2, 5, 4); @@ -18,8 +24,11 @@ $series3 = array(8, 3, 2, 5, 4); foreach ($chartTypes as $chartType) { - $section->addTitle(ucfirst($chartType), 1); + $section->addTitle(ucfirst($chartType), 2); $chart = $section->addChart($chartType, $categories, $series1); + $chart->getStyle() + ->setWidth(Converter::inchToEmu(2.5)) + ->setHeight(Converter::inchToEmu(2)); if (in_array($chartType, $twoSeries)) { $chart->addSeries($categories, $series2); } @@ -29,6 +38,24 @@ $section->addTextBreak(); } +// 3D charts +$section = $phpWord->addSection(array('breakType' => 'continuous')); +$section->addTitle('3D charts', 1); +$section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous')); + +$chartTypes = array('pie', 'bar', 'column', 'line', 'area'); +$multiSeries = array('bar', 'column', 'line', 'area'); +$style = array('width' => Converter::cmToEmu(5), 'height' => Converter::cmToEmu(4), '3d' => true); +foreach ($chartTypes as $chartType) { + $section->addTitle(ucfirst($chartType), 2); + $chart = $section->addChart($chartType, $categories, $series1, $style); + if (in_array($chartType, $multiSeries)) { + $chart->addSeries($categories, $series2); + $chart->addSeries($categories, $series3); + } + $section->addTextBreak(); +} + // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php index 24f2bb78c4..629db63b69 100644 --- a/src/PhpWord/Element/Chart.php +++ b/src/PhpWord/Element/Chart.php @@ -17,6 +17,9 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Style\Chart as ChartStyle; + + /** * Chart element * @@ -45,6 +48,13 @@ class Chart extends AbstractElement */ private $series = array(); + /** + * Chart style + * + * @var \PhpOffice\PhpWord\Style\Chart + */ + private $style; + /** * Create new instance * @@ -52,10 +62,11 @@ class Chart extends AbstractElement * @param array $categories * @param array $values */ - public function __construct($type, $categories, $values) + public function __construct($type, $categories, $values, $style = null) { $this->setType($type); $this->addSeries($categories, $values); + $this->style = $this->setNewStyle(new ChartStyle(), $style, true); } /** @@ -75,7 +86,7 @@ public function getType() */ public function setType($value) { - $enum = array('pie', 'doughnut', 'line', 'bar', 'area', 'radar', 'scatter'); + $enum = array('pie', 'doughnut', 'line', 'bar', 'column', 'area', 'radar', 'scatter'); $this->type = $this->setEnumVal($value, $enum, 'pie'); } @@ -99,4 +110,14 @@ public function getSeries() { return $this->series; } + + /** + * Get chart style + * + * @return \PhpOffice\PhpWord\Style\Chart + */ + public function getStyle() + { + return $this->style; + } } diff --git a/src/PhpWord/Shared/Converter.php b/src/PhpWord/Shared/Converter.php index 8bc1cecf07..c6727edd55 100644 --- a/src/PhpWord/Shared/Converter.php +++ b/src/PhpWord/Shared/Converter.php @@ -62,6 +62,28 @@ public static function cmToPixel($centimeter = 1) return $centimeter / self::INCH_TO_CM * self::INCH_TO_PIXEL; } + /** + * Convert centimeter to point + * + * @param int $centimeter + * @return float + */ + public static function cmToPoint($centimeter = 1) + { + return $centimeter / self::INCH_TO_CM * self::INCH_TO_POINT; + } + + /** + * Convert centimeter to EMU + * + * @param int $centimeter + * @return int + */ + public static function cmToEmu($centimeter = 1) + { + return round($centimeter / self::INCH_TO_CM * self::INCH_TO_PIXEL * self::PIXEL_TO_EMU); + } + /** * Convert inch to twip * @@ -106,6 +128,17 @@ public static function inchToPoint($inch = 1) return $inch * self::INCH_TO_POINT; } + /** + * Convert inch to EMU + * + * @param int $inch + * @return int + */ + public static function inchToEmu($inch = 1) + { + return round($inch * self::INCH_TO_PIXEL * self::PIXEL_TO_EMU); + } + /** * Convert pixel to twip * diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index cc275fc6a8..6f5272106f 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -244,8 +244,10 @@ protected function setIntVal($value, $default = null) if (is_string($value) && (preg_match('/[^\d]/', $value) == 0)) { $value = intval($value); } - if (!is_int($value)) { + if (!is_numeric($value)) { $value = $default; + } else { + $value = intval($value); } return $value; diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php new file mode 100644 index 0000000000..13b72a33f5 --- /dev/null +++ b/src/PhpWord/Style/Chart.php @@ -0,0 +1,127 @@ +setStyleByArray($style); + } + + /** + * Get width + * + * @return int + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set width + * + * @param int $value + * @return self + */ + public function setWidth($value = null) + { + $this->width = $this->setIntVal($value, $this->width); + + return $this; + } + + /** + * Get height + * + * @return int + */ + public function getHeight() + { + return $this->height; + } + + /** + * Set height + * + * @param int $value + * @return self + */ + public function setHeight($value = null) + { + $this->height = $this->setIntVal($value, $this->height); + + return $this; + } + + /** + * Is 3D + * + * @return bool + */ + public function is3d() + { + return $this->is3d; + } + + /** + * Set 3D + * + * @param bool $value + * @return self + */ + public function set3d($value = true) + { + $this->is3d = $this->setBoolVal($value, $this->is3d); + + return $this; + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php index 4330e2fe74..e185ee581d 100644 --- a/src/PhpWord/Writer/Word2007/Element/Chart.php +++ b/src/PhpWord/Writer/Word2007/Element/Chart.php @@ -38,6 +38,7 @@ public function write() } $rId = $element->getRelationId(); + $style = $element->getStyle(); if (!$this->withoutP) { $xmlWriter->startElement('w:p'); @@ -48,7 +49,7 @@ public function write() $xmlWriter->startElement('wp:inline'); // EMU - $xmlWriter->writeElementBlock('wp:extent', array('cx' => '2000000', 'cy' => '2000000')); + $xmlWriter->writeElementBlock('wp:extent', array('cx' => $style->getWidth(), 'cy' => $style->getHeight())); $xmlWriter->writeElementBlock('wp:docPr', array('id' => $rId, 'name' => "Chart{$rId}")); $xmlWriter->startElement('a:graphic'); diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 66e4391484..0a0ebac6f5 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -41,13 +41,14 @@ class Chart extends AbstractPart * @var array */ private $types = array( - 'pie' => array('type' => 'pieChart', 'colors' => 1), - 'doughnut' => array('type' => 'doughnutChart', 'colors' => 1, 'hole' => 75), - 'bar' => array('type' => 'barChart', 'colors' => 0, 'axes' => true, 'bar' => 'col'), - 'line' => array('type' => 'lineChart', 'colors' => 0, 'axes' => true), - 'area' => array('type' => 'areaChart', 'colors' => 0, 'axes' => true), - 'radar' => array('type' => 'radarChart', 'colors' => 0, 'axes' => true, 'radar' => 'standard'), - 'scatter' => array('type' => 'scatterChart', 'colors' => 0, 'axes' => true, 'scatter' => 'marker'), + 'pie' => array('type' => 'pie', 'colors' => 1), + 'doughnut' => array('type' => 'doughnut', 'colors' => 1, 'hole' => 75, 'no3d' => true), + 'bar' => array('type' => 'bar', 'colors' => 0, 'axes' => true, 'bar' => 'bar'), + 'column' => array('type' => 'bar', 'colors' => 0, 'axes' => true, 'bar' => 'col'), + 'line' => array('type' => 'line', 'colors' => 0, 'axes' => true), + 'area' => array('type' => 'area', 'colors' => 0, 'axes' => true), + 'radar' => array('type' => 'radar', 'colors' => 0, 'axes' => true, 'radar' => 'standard', 'no3d' => true), + 'scatter' => array('type' => 'scatter', 'colors' => 0, 'axes' => true, 'scatter' => 'marker', 'no3d' => true), ); /** @@ -119,13 +120,17 @@ private function writeChart(XMLWriter $xmlWriter) private function writePlotArea(XMLWriter $xmlWriter) { $type = $this->element->getType(); + $style = $this->element->getStyle(); $this->options = $this->types[$type]; $xmlWriter->startElement('c:plotArea'); $xmlWriter->writeElement('c:layout'); // Chart - $xmlWriter->startElement('c:' . $this->options['type']); + $chartType = $this->options['type']; + $chartType .= $style->is3d() && !isset($this->options['no3d'])? '3D' : ''; + $chartType .= 'Chart'; + $xmlWriter->startElement("c:{$chartType}"); $xmlWriter->writeElementBlock('c:varyColors', 'val', $this->options['colors']); if ($type == 'area') { @@ -136,7 +141,7 @@ private function writePlotArea(XMLWriter $xmlWriter) } if (isset($this->options['bar'])) { $xmlWriter->writeElementBlock('c:barDir', 'val', $this->options['bar']); // bar|col - $xmlWriter->writeElementBlock('c:grouping', 'val', 'clustered'); + $xmlWriter->writeElementBlock('c:grouping', 'val', 'clustered'); // 3d; standard = percentStacked } if (isset($this->options['radar'])) { $xmlWriter->writeElementBlock('c:radarStyle', 'val', $this->options['radar']); diff --git a/tests/PhpWord/Tests/Shared/ConverterTest.php b/tests/PhpWord/Tests/Shared/ConverterTest.php index 9525148cc4..002e2e33bf 100644 --- a/tests/PhpWord/Tests/Shared/ConverterTest.php +++ b/tests/PhpWord/Tests/Shared/ConverterTest.php @@ -45,6 +45,12 @@ public function testUnitConversions() $result = Converter::cmToPixel($value); $this->assertEquals($value / 2.54 * 96, $result); + $result = Converter::cmToPoint($value); + $this->assertEquals($value / 2.54 * 72, $result); + + $result = Converter::cmToEmu($value); + $this->assertEquals(round($value / 2.54 * 96 * 9525), $result); + $result = Converter::inchToTwip($value); $this->assertEquals($value * 1440, $result); @@ -57,6 +63,9 @@ public function testUnitConversions() $result = Converter::inchToPoint($value); $this->assertEquals($value * 72, $result); + $result = Converter::inchToEmu($value); + $this->assertEquals(round($value * 96 * 9525), $result); + $result = Converter::pixelToTwip($value); $this->assertEquals($value / 96 * 1440, $result); diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 0ba29f2fc6..528cafd5c7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -156,12 +156,13 @@ public function testChartElement() { $phpWord = new PhpWord(); $section = $phpWord->addSection(); + $style = array('width' => 1000000, 'height' => 1000000, '3d' => true); $chartTypes = array('pie', 'doughnut', 'bar', 'line', 'area', 'scatter', 'radar'); $categories = array('A', 'B', 'C', 'D', 'E'); $series1 = array(1, 3, 2, 5, 4); foreach ($chartTypes as $chartType) { - $section->addChart($chartType, $categories, $series1); + $section->addChart($chartType, $categories, $series1, $style); } $doc = TestHelperDOCX::getDocument($phpWord); From 6a81691d453c57c1215da78357b13a87636195a2 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 16 Jun 2014 00:09:14 +0700 Subject: [PATCH 036/174] #266: Ability to add textinput, checkbox, and dropdown form elements --- CHANGELOG.md | 3 +- README.md | 1 + docs/elements.rst | 7 + docs/intro.rst | 1 + docs/src/documentation.md | 7 + samples/Sample_33_FormField.php | 26 +++ src/PhpWord/Element/AbstractContainer.php | 6 +- src/PhpWord/Element/Chart.php | 2 +- src/PhpWord/Element/CheckBox.php | 2 + src/PhpWord/Element/FormField.php | 195 ++++++++++++++++++ src/PhpWord/Shared/Drawing.php | 20 +- src/PhpWord/Shared/Font.php | 18 +- .../Writer/Word2007/Element/FormField.php | 161 +++++++++++++++ .../Tests/Writer/Word2007/ElementTest.php | 25 ++- 14 files changed, 449 insertions(+), 25 deletions(-) create mode 100644 samples/Sample_33_FormField.php create mode 100644 src/PhpWord/Element/FormField.php create mode 100644 src/PhpWord/Writer/Word2007/Element/FormField.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 155ecb3505..49fe999333 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.12.0 - Not yet released -This release added drawing shapes (arc, curve, line, polyline, rect, oval) and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. +This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. ### Features @@ -17,6 +17,7 @@ This release added drawing shapes (arc, curve, line, polyline, rect, oval) and b - General: New `Shared\Converter` static class - @ivanlanin - Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 - Chart: 3D charts and ability to set width and height - @ivanlanin +- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 ### Bugfixes diff --git a/README.md b/README.md index 5a432cba6f..825f7926f8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ With PHPWord, you can create DOCX, ODT, or RTF documents dynamically using your - Insert footnotes and endnotes - Insert drawing shapes (arc, curve, line, polyline, rect, oval) - Insert charts (pie, doughnut, bar, line, area, scatter, radar) +- Insert form fields (textinput, checkbox, and dropdown) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template - ... and many more features on progress diff --git a/docs/elements.rst b/docs/elements.rst index ee8273260b..e4baf70e74 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -51,6 +51,8 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 21 | Chart | v | - | - | - | - | - | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 22 | Form fields | v | v | v | v | v | v | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -406,3 +408,8 @@ Charts ------ To be completed. + +Form fields +----------- + +To be completed. diff --git a/docs/intro.rst b/docs/intro.rst index 241b581ce0..b604298fd7 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -47,6 +47,7 @@ Features - Insert footnotes and endnotes - Insert drawing shapes (arc, curve, line, polyline, rect, oval) - Insert charts (pie, doughnut, bar, line, area, scatter, radar) +- Insert form fields (textinput, checkbox, and dropdown) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 39e618625d..2099680812 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -38,6 +38,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Lines](#lines) - [Shapes](#shapes) - [Charts](#charts) + - [FormFields](#form-fields) - [Styles](#styles) - [Section](#section) - [Font](#font) @@ -79,6 +80,7 @@ PHPWord is an open source project licensed under the terms of [LGPL version 3](h - Insert footnotes and endnotes - Insert drawing shapes (arc, curve, line, polyline, rect, oval) - Insert charts (pie, doughnut, bar, line, area, scatter, radar) +- Insert form fields (textinput, checkbox, and dropdown) - Create document from templates - Use XSL 1.0 style sheets to transform main document part of OOXML template - ... and many more features on progress @@ -444,6 +446,7 @@ Below are the matrix of element availability in each container. The column shows | 19 | Line | v | v | v | v | v | v | | 20 | Shape | v | v | v | v | v | v | | 21 | Chart | v | - | - | - | - | - | +| 22 | Form Fields | v | v | v | v | v | v | Legend: @@ -745,6 +748,10 @@ To be completed. To be completed. +## Form fields + +To be completed. + # Styles ## Section diff --git a/samples/Sample_33_FormField.php b/samples/Sample_33_FormField.php new file mode 100644 index 0000000000..f7b7c85259 --- /dev/null +++ b/samples/Sample_33_FormField.php @@ -0,0 +1,26 @@ +addSection(); + +$textrun = $section->addTextRun(); +$textrun->addText('Form fields can be added in a text run and can be in form of textinput '); +$textrun->addFormField('textinput')->setName('MyTextBox'); +$textrun->addText(', checkbox '); +$textrun->addFormField('checkbox')->setDefault(true); +$textrun->addText(', or dropdown '); +$textrun->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3')); +$textrun->addText('. You have to set document protection to "forms" to enable dropdown.'); + +$section->addText('They can also be added as a stand alone paragraph.'); +$section->addFormField('textinput')->setValue('Your name'); + +// 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 19e78c21f5..3ec113907e 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -41,7 +41,8 @@ * @method Field addField(string $type = null, array $properties = array(), array $options = array()) * @method Line addLine(mixed $lineStyle = null) * @method Shape addObject(string $type, mixed $style = null) - * @method Chart addChart() + * @method Chart addChart(string $type, array $categories, array $values, array $style = null) + * @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null) * * @since 0.10.0 */ @@ -78,7 +79,7 @@ public function __call($function, $args) $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape', - 'Title', 'TOC', 'PageBreak', 'Chart'); + 'Title', 'TOC', 'PageBreak', 'Chart', 'FormField'); $functions = array(); for ($i = 0; $i < count($elements); $i++) { $functions[$i] = 'add' . $elements[$i]; @@ -190,6 +191,7 @@ private function checkValidity($method) 'Field' => $allContainers, 'Line' => $allContainers, 'Shape' => $allContainers, + 'FormField' => $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/Chart.php b/src/PhpWord/Element/Chart.php index 629db63b69..2d709b8ca0 100644 --- a/src/PhpWord/Element/Chart.php +++ b/src/PhpWord/Element/Chart.php @@ -19,7 +19,6 @@ use PhpOffice\PhpWord\Style\Chart as ChartStyle; - /** * Chart element * @@ -61,6 +60,7 @@ class Chart extends AbstractElement * @param string $type * @param array $categories * @param array $values + * @param array $style */ public function __construct($type, $categories, $values, $style = null) { diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index a5620580fe..d3b2a3c6f4 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -21,6 +21,8 @@ /** * Check box element + * + * @since 0.10.0 */ class CheckBox extends Text { diff --git a/src/PhpWord/Element/FormField.php b/src/PhpWord/Element/FormField.php new file mode 100644 index 0000000000..7bd61be1e7 --- /dev/null +++ b/src/PhpWord/Element/FormField.php @@ -0,0 +1,195 @@ +setType($type); + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set type + * + * @param string $value + * @return self + */ + public function setType($value) + { + $enum = array('textinput', 'checkbox', 'dropdown'); + $this->type = $this->setEnumVal($value, $enum, $this->type); + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set name + * + * @param string|bool|int $value + * @return self + */ + public function setName($value) + { + $this->name = $value; + + return $this; + } + + /** + * Get default + * + * @return string|bool|int + */ + public function getDefault() + { + return $this->default; + } + + /** + * Set default + * + * @param string|bool|int $value + * @return self + */ + public function setDefault($value) + { + $this->default = $value; + + return $this; + } + + /** + * Get value + * + * @return string|bool|int + */ + public function getValue() + { + return $this->value; + } + + /** + * Set value + * + * @param string|bool|int $value + * @return self + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get entries + * + * @return array + */ + public function getEntries() + { + return $this->entries; + } + + /** + * Set entries + * + * @param array $value + * @return self + */ + public function setEntries($value) + { + $this->entries = $value; + + return $this; + } +} diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 00d8b56557..59fbe0269e 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -18,12 +18,12 @@ namespace PhpOffice\PhpWord\Shared; /** - * Common drawing functions; replaced by `Converter` + * DEPRECATED: Common drawing functions; Use 'Converter' * * @deprecated 0.12.0 * @codeCoverageIgnore */ -class Drawing extends Converter +class Drawing { /** * Convert pixels to EMU @@ -33,7 +33,7 @@ class Drawing extends Converter */ public static function pixelsToEMU($value = 0) { - return self::pixelToEmu($value); + return Converter::pixelToEmu($value); } /** @@ -44,7 +44,7 @@ public static function pixelsToEMU($value = 0) */ public static function emuToPixels($value = 0) { - return self::emuToPixel($value); + return Converter::emuToPixel($value); } /** @@ -55,7 +55,7 @@ public static function emuToPixels($value = 0) */ public static function pixelsToPoints($value = 0) { - return self::pixelToPoint($value); + return Converter::pixelToPoint($value); } /** @@ -66,7 +66,7 @@ public static function pixelsToPoints($value = 0) */ public static function pointsToPixels($value = 0) { - return self::pointToPixel($value); + return Converter::pointToPixel($value); } /** @@ -77,7 +77,7 @@ public static function pointsToPixels($value = 0) */ public static function degreesToAngle($value = 0) { - return self::degreeToAngle($value); + return Converter::degreeToAngle($value); } /** @@ -88,7 +88,7 @@ public static function degreesToAngle($value = 0) */ public static function angleToDegrees($value = 0) { - return self::angleToDegree($value); + return Converter::angleToDegree($value); } /** @@ -99,7 +99,7 @@ public static function angleToDegrees($value = 0) */ public static function pixelsToCentimeters($value = 0) { - return self::pixelToCm($value); + return Converter::pixelToCm($value); } /** @@ -110,6 +110,6 @@ public static function pixelsToCentimeters($value = 0) */ public static function centimetersToPixels($value = 0) { - return self::cmToPixel($value); + return Converter::cmToPixel($value); } } diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php index 6aeacef794..231b0bbdcc 100644 --- a/src/PhpWord/Shared/Font.php +++ b/src/PhpWord/Shared/Font.php @@ -18,12 +18,12 @@ namespace PhpOffice\PhpWord\Shared; /** - * Common font functions; replaced by `Converter` + * DEPRECATED: Common font functions; Use 'Converter' * * @deprecated 0.12.0 * @codeCoverageIgnore */ -class Font extends Converter +class Font { /** * Calculate an (approximate) pixel size, based on a font points size @@ -33,7 +33,7 @@ class Font extends Converter */ public static function fontSizeToPixels($fontSizeInPoints = 12) { - return self::pointToPixel($fontSizeInPoints); + return Converter::pointToPixel($fontSizeInPoints); } /** @@ -44,7 +44,7 @@ public static function fontSizeToPixels($fontSizeInPoints = 12) */ public static function inchSizeToPixels($sizeInInch = 1) { - return self::inchToPixel($sizeInInch); + return Converter::inchToPixel($sizeInInch); } /** @@ -55,7 +55,7 @@ public static function inchSizeToPixels($sizeInInch = 1) */ public static function centimeterSizeToPixels($sizeInCm = 1) { - return self::cmToPixel($sizeInCm); + return Converter::cmToPixel($sizeInCm); } /** @@ -66,7 +66,7 @@ public static function centimeterSizeToPixels($sizeInCm = 1) */ public static function centimeterSizeToTwips($sizeInCm = 1) { - return self::cmToTwip($sizeInCm); + return Converter::cmToTwip($sizeInCm); } /** @@ -77,7 +77,7 @@ public static function centimeterSizeToTwips($sizeInCm = 1) */ public static function inchSizeToTwips($sizeInInch = 1) { - return self::inchToTwip($sizeInInch); + return Converter::inchToTwip($sizeInInch); } /** @@ -88,7 +88,7 @@ public static function inchSizeToTwips($sizeInInch = 1) */ public static function pixelSizeToTwips($sizeInPixel = 1) { - return self::pixelToTwip($sizeInPixel); + return Converter::pixelToTwip($sizeInPixel); } /** @@ -99,6 +99,6 @@ public static function pixelSizeToTwips($sizeInPixel = 1) */ public static function pointSizeToTwips($sizeInPoint = 1) { - return self::pointToTwip($sizeInPoint); + return Converter::pointToTwip($sizeInPoint); } } diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php new file mode 100644 index 0000000000..21003314af --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/FormField.php @@ -0,0 +1,161 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof FormFieldElement) { + return; + } + + $type = $element->getType(); + $instructions = array('textinput' => 'FORMTEXT', 'checkbox' => 'FORMCHECKBOX', 'dropdown' => 'FORMDROPDOWN'); + $instruction = $instructions[$type]; + $writeFormField = "write{$type}"; + $name = $element->getName(); + if ($name === null) { + $name = $type . $element->getElementId(); + } + $value = $element->getValue(); + if ($value === null) { + $value = str_repeat(' ', self::FILLER_LENGTH); + } + + $this->startElementP(); + + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:fldChar'); + $xmlWriter->writeAttribute('w:fldCharType', 'begin'); + $xmlWriter->startElement('w:ffData'); + $xmlWriter->writeElementBlock('w:enabled', 'w:val', 1); + $xmlWriter->writeElementBlock('w:name', 'w:val', $name); + $xmlWriter->writeElementBlock('w:calcOnExit', 'w:val', 0); + $this->$writeFormField($xmlWriter, $element); + $xmlWriter->endElement(); // w:ffData + $xmlWriter->endElement(); // w:fldChar + $xmlWriter->endElement(); // w:r + + $xmlWriter->startElement('w:r'); + $this->writeFontStyle(); + $xmlWriter->startElement('w:instrText'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw("{$instruction}"); + $xmlWriter->endElement();// w:instrText + $xmlWriter->endElement(); // w:r + + $xmlWriter->startElement('w:r'); + $this->writeFontStyle(); + $xmlWriter->writeElementBlock('w:fldChar', 'w:fldCharType', 'separate'); + $xmlWriter->endElement(); // w:r + + $xmlWriter->startElement('w:r'); + $this->writeFontStyle(); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeAttribute('xml:space', 'preserve'); + $xmlWriter->writeRaw($value); + $xmlWriter->endElement(); // w:t + $xmlWriter->endElement(); // w:r + + $xmlWriter->startElement('w:r'); + $this->writeFontStyle(); + $xmlWriter->writeElementBlock('w:fldChar', 'w:fldCharType', 'end'); + $xmlWriter->endElement(); // w:r + + $this->endElementP(); // w:p + } + + /** + * Write textinput + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html + */ + private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element) + { + $default = $element->getDefault(); + + $xmlWriter->startElement('w:textInput'); + $xmlWriter->writeElementBlock('w:default', 'w:val', $default); + $xmlWriter->endElement(); + } + + /** + * Write checkbox + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html + */ + private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element) + { + $default = $element->getDefault() ? 1 : 0; + $value = $element->getValue(); + if ($value == null) { + $value = $default; + } + $value = $value ? 1 : 0; + + $xmlWriter->startElement('w:checkBox'); + $xmlWriter->writeElementBlock('w:sizeAuto', 'w:val', ''); + $xmlWriter->writeElementBlock('w:default', 'w:val', $default); + $xmlWriter->writeElementBlock('w:checked', 'w:val', $value); + $xmlWriter->endElement(); + } + + /** + * Write dropdown + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html + */ + private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element) + { + $default = $element->getDefault(); + $value = $element->getValue(); + if ($value == null) { + $value = $default; + } + $entries = $element->getEntries(); + + $xmlWriter->startElement('w:ddList'); + $xmlWriter->writeElementBlock('w:result', 'w:val', $value); + $xmlWriter->writeElementBlock('w:default', 'w:val', $default); + foreach ($entries as $entry) { + $xmlWriter->writeElementBlock('w:listEntry', 'w:val', $entry); + } + $xmlWriter->endElement(); + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 528cafd5c7..6c10f3a57a 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -152,11 +152,11 @@ public function testShapeElements() /** * Test shape elements */ - public function testChartElement() + public function testChartElements() { $phpWord = new PhpWord(); $section = $phpWord->addSection(); - $style = array('width' => 1000000, 'height' => 1000000, '3d' => true); + $style = array('width' => 1000000, 'height' => 1000000); $chartTypes = array('pie', 'doughnut', 'bar', 'line', 'area', 'scatter', 'radar'); $categories = array('A', 'B', 'C', 'D', 'E'); @@ -164,6 +164,7 @@ public function testChartElement() foreach ($chartTypes as $chartType) { $section->addChart($chartType, $categories, $series1, $style); } + $section->addChart('pie', $categories, $series1, array('3d' => true)); $doc = TestHelperDOCX::getDocument($phpWord); @@ -175,4 +176,24 @@ public function testChartElement() $this->assertTrue($doc->elementExists($path, $file)); } } + + /** + * Test form fields + */ + public function testFormFieldElements() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + $section->addFormField('textinput')->setName('MyTextBox'); + $section->addFormField('checkbox')->setDefault(true)->setValue('Your name'); + $section->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3')); + + $doc = TestHelperDOCX::getDocument($phpWord); + + $path = "/w:document/w:body/w:p/w:r/w:fldChar/w:ffData"; + $this->assertTrue($doc->elementExists($path . '/w:textInput')); + $this->assertTrue($doc->elementExists($path . '/w:checkBox')); + $this->assertTrue($doc->elementExists($path . '/w:ddList')); + } } From 384107e7cfd87bc8a01c129c644bdeead6df192b Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 16 Jun 2014 07:32:57 +0700 Subject: [PATCH 037/174] Ability to define document protection and new `Metadata` subnamespace --- CHANGELOG.md | 3 +- README.md | 13 +- docs/general.rst | 8 +- docs/src/documentation.md | 6 +- samples/Sample_33_FormField.php | 1 + samples/Sample_Header.php | 2 +- samples/index.php | 2 +- .../DocInfo.php} | 8 +- src/PhpWord/Metadata/Protection.php | 69 +++++++++ src/PhpWord/PhpWord.php | 68 ++++++--- src/PhpWord/Reader/ODText/Meta.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +- .../Reader/Word2007/DocPropsCustom.php | 8 +- src/PhpWord/Writer/HTML/Part/Head.php | 2 +- src/PhpWord/Writer/ODText/Part/Meta.php | 2 +- src/PhpWord/Writer/PDF/MPDF.php | 2 +- src/PhpWord/Writer/PDF/TCPDF.php | 2 +- src/PhpWord/Writer/RTF/Part/Document.php | 2 +- .../Writer/Word2007/Part/DocPropsApp.php | 4 +- .../Writer/Word2007/Part/DocPropsCore.php | 18 +-- .../Writer/Word2007/Part/DocPropsCustom.php | 2 +- src/PhpWord/Writer/Word2007/Part/Settings.php | 133 +++++++++++------- .../DocInfoTest.php} | 96 ++++++------- tests/PhpWord/Tests/PhpWordTest.php | 17 +-- tests/PhpWord/Tests/Writer/HTMLTest.php | 2 +- .../Tests/Writer/ODText/Part/ContentTest.php | 2 +- .../Writer/Word2007/Part/SettingsTest.php | 52 +++++++ 27 files changed, 357 insertions(+), 171 deletions(-) rename src/PhpWord/{DocumentProperties.php => Metadata/DocInfo.php} (99%) create mode 100644 src/PhpWord/Metadata/Protection.php rename tests/PhpWord/Tests/{DocumentPropertiesTest.php => Metadata/DocInfoTest.php} (67%) create mode 100644 tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fe999333..4775b4dc3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 - Chart: 3D charts and ability to set width and height - @ivanlanin - FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 +- Security: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin ### Bugfixes @@ -30,7 +31,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - `Element\Link::getTarget()` replaced by `Element\Link::getSource()` - `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` - `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter` - +- `DocumentProperties` replaced by `Metadata\DocInfo` ### Miscellaneous diff --git a/README.md b/README.md index 825f7926f8..841ab1a1d0 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,17 @@ PHPWord is a library written in pure PHP that provides a set of classes to write PHPWord is an open source project licensed under the terms of [LGPL version 3](https://github.com/PHPOffice/PHPWord/blob/develop/COPYING.LESSER). 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/). +Read more about PHPWord: + +- [Features](#features) +- [Requirements](#requirements) +- [Installation](#installation) +- [Getting started](#getting-started) +- [Known issues](#known-issues) +- [Contributing](#contributing) +- [Developers' Documentation](http://phpword.readthedocs.org/) +- [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) + ## 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: @@ -113,7 +124,7 @@ $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/develop/) for more detail. +More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. ## Known issues diff --git a/docs/general.rst b/docs/general.rst index a2498affcc..c6a893bc0d 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -97,15 +97,15 @@ default font by using the following two functions: $phpWord->setDefaultFontName('Times New Roman'); $phpWord->setDefaultFontSize(12); -Document properties -------------------- +Document information +-------------------- -You can set the document properties such as title, creator, and company +You can set the document information such as title, creator, and company name. Use the following functions: .. code-block:: php - $properties = $phpWord->getDocumentProperties(); + $properties = $phpWord->getDocInfo(); $properties->setCreator('My name'); $properties->setCompany('My factory'); $properties->setTitle('My title'); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 2099680812..60121d3305 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -279,12 +279,12 @@ $phpWord->setDefaultFontName('Times New Roman'); $phpWord->setDefaultFontSize(12); ``` -## Document properties +## Document information -You can set the document properties such as title, creator, and company name. Use the following functions: +You can set the document information such as title, creator, and company name. Use the following functions: ```php -$properties = $phpWord->getDocumentProperties(); +$properties = $phpWord->getDocInfo(); $properties->setCreator('My name'); $properties->setCompany('My factory'); $properties->setTitle('My title'); diff --git a/samples/Sample_33_FormField.php b/samples/Sample_33_FormField.php index f7b7c85259..d3811fc46b 100644 --- a/samples/Sample_33_FormField.php +++ b/samples/Sample_33_FormField.php @@ -4,6 +4,7 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); +$phpWord->getProtection()->setEditing('forms'); $section = $phpWord->addSection(); diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index d915c039d7..838784c230 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -142,7 +142,7 @@ function getEndingNotes($writers) diff --git a/samples/index.php b/samples/index.php index 8e466d9700..5632664fed 100644 --- a/samples/index.php +++ b/samples/index.php @@ -16,7 +16,7 @@

 

Fork us on Github! - Read the Docs + Read the Docs

setEditing($editing); + } + + /** + * Get editing protection + * + * @return string + */ + public function getEditing() + { + return $this->editing; + } + + /** + * Set editing protection + * + * @param string $editing + * @return self + */ + public function setEditing($editing = null) + { + $this->editing = $editing; + + return $this; + } +} diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index d4c8df9c11..c62da82bca 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -52,13 +52,6 @@ class PhpWord const DEFAULT_FONT_COLOR = Settings::DEFAULT_FONT_COLOR; const DEFAULT_FONT_CONTENT_TYPE = Settings::DEFAULT_FONT_CONTENT_TYPE; - /** - * Document properties object - * - * @var DocumentProperties - */ - private $documentProperties; - /** * Collection of sections * @@ -73,6 +66,14 @@ class PhpWord */ private $collections = array(); + /** + * Metadata + * + * @var array + * @since 0.12.0 + */ + private $metadata = array(); + /** * Create new instance * @@ -80,13 +81,17 @@ class PhpWord */ public function __construct() { - $this->documentProperties = new DocumentProperties(); - $collections = array('Titles', 'Footnotes', 'Endnotes', 'Charts'); foreach ($collections as $collection) { $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection; $this->collections[$collection] = new $class(); } + + $metadata = 'PhpOffice\\PhpWord\\Metadata\\Protection'; + $this->metadata['Protection'] = new $metadata(); + + $metadata = 'PhpOffice\\PhpWord\\Metadata\\DocInfo'; + $this->metadata['DocInfo'] = new $metadata(); } /** @@ -150,24 +155,22 @@ public function __call($function, $args) /** * Get document properties object * - * @return DocumentProperties + * @return \PhpOffice\PhpWord\Metadata\DocInfo */ - public function getDocumentProperties() + public function getDocInfo() { - return $this->documentProperties; + return $this->metadata['DocInfo']; } /** - * Set document properties object + * Get protection * - * @param DocumentProperties $documentProperties - * @return self + * @return \PhpOffice\PhpWord\Metadata\Protection + * @since 0.12.0 */ - public function setDocumentProperties(DocumentProperties $documentProperties) + public function getProtection() { - $this->documentProperties = $documentProperties; - - return $this; + return $this->metadata['Protection']; } /** @@ -312,4 +315,31 @@ public function createSection($settings = null) { return $this->addSection($settings); } + + /** + * Get document properties object + * + * @return \PhpOffice\PhpWord\Metadata\DocInfo + * @deprecated 0.12.0 + * @codeCoverageIgnore + */ + public function getDocumentProperties() + { + return $this->getDocInfo(); + } + + /** + * Set document properties object + * + * @param \PhpOffice\PhpWord\Metadata\DocInfo + * @return self + * @deprecated 0.12.0 + * @codeCoverageIgnore + */ + public function setDocumentProperties($documentProperties) + { + $this->metadata['Document'] = $documentProperties; + + return $this; + } } diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php index f7f4542dbc..518884fdc8 100644 --- a/src/PhpWord/Reader/ODText/Meta.php +++ b/src/PhpWord/Reader/ODText/Meta.php @@ -37,7 +37,7 @@ public function read(PhpWord &$phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $metaNode = $xmlReader->getElement('office:meta'); diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index 0b92b64dcd..e50f295be8 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -61,7 +61,7 @@ public function read(PhpWord &$phpWord) $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index efbbfaa5c8..54fe39eeba 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Reader\Word2007; -use PhpOffice\PhpWord\DocumentProperties; +use PhpOffice\PhpWord\Metadata\DocInfo; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLReader; @@ -37,7 +37,7 @@ public function read(PhpWord &$phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { @@ -46,8 +46,8 @@ public function read(PhpWord &$phpWord) $attributeNode = $xmlReader->getElement('*', $node); $attributeType = $attributeNode->nodeName; $attributeValue = $attributeNode->nodeValue; - $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); - $attributeType = DocumentProperties::convertPropertyType($attributeType); + $attributeValue = DocInfo::convertProperty($attributeValue, $attributeType); + $attributeType = DocInfo::convertPropertyType($attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); } } diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index edbc8dcf7f..23e30b8d34 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -39,7 +39,7 @@ class Head extends AbstractPart */ public function write() { - $docProps = $this->getParentWriter()->getPhpWord()->getDocumentProperties(); + $docProps = $this->getParentWriter()->getPhpWord()->getDocInfo(); $propertiesMapping = array( 'creator' => 'author', 'title' => '', diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index c9e729add5..9dab2e23bb 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -34,7 +34,7 @@ class Meta extends AbstractPart public function write() { $phpWord = $this->getParentWriter()->getPhpWord(); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $xmlWriter = $this->getXmlWriter(); $xmlWriter->startDocument('1.0', 'UTF-8'); diff --git a/src/PhpWord/Writer/PDF/MPDF.php b/src/PhpWord/Writer/PDF/MPDF.php index 9d4e050c87..3fab05c345 100644 --- a/src/PhpWord/Writer/PDF/MPDF.php +++ b/src/PhpWord/Writer/PDF/MPDF.php @@ -54,7 +54,7 @@ public function save($filename = null) // Write document properties $phpWord = $this->getPhpWord(); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $pdf->setTitle($docProps->getTitle()); $pdf->setAuthor($docProps->getCreator()); $pdf->setSubject($docProps->getSubject()); diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php index 669a2cddee..3d3104de06 100644 --- a/src/PhpWord/Writer/PDF/TCPDF.php +++ b/src/PhpWord/Writer/PDF/TCPDF.php @@ -58,7 +58,7 @@ public function save($filename = null) // Write document properties $phpWord = $this->getPhpWord(); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $pdf->setTitle($docProps->getTitle()); $pdf->setAuthor($docProps->getCreator()); $pdf->setSubject($docProps->getSubject()); diff --git a/src/PhpWord/Writer/RTF/Part/Document.php b/src/PhpWord/Writer/RTF/Part/Document.php index f0a9b8f20a..f239f9e253 100644 --- a/src/PhpWord/Writer/RTF/Part/Document.php +++ b/src/PhpWord/Writer/RTF/Part/Document.php @@ -52,7 +52,7 @@ public function write() */ private function writeInfo() { - $docProps = $this->getParentWriter()->getPhpWord()->getDocumentProperties(); + $docProps = $this->getParentWriter()->getPhpWord()->getDocInfo(); $properties = array('title', 'subject', 'category', 'keywords', 'comment', 'author', 'operator', 'creatim', 'revtim', 'company', 'manager'); $mapping = array('comment' => 'description', 'author' => 'creator', 'operator' => 'lastModifiedBy', diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php index 1e6549c52e..421ceefec2 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php @@ -41,8 +41,8 @@ public function write() $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->writeElement('Company', $phpWord->getDocInfo()->getCompany()); + $xmlWriter->writeElement('Manager', $phpWord->getDocInfo()->getManager()); $xmlWriter->endElement(); // Properties diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php index 38f6d2351f..252be01f02 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php @@ -43,24 +43,24 @@ public function write() $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator()); - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords()); - $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory()); - $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy()); + $xmlWriter->writeElement('dc:creator', $phpWord->getDocInfo()->getCreator()); + $xmlWriter->writeElement('dc:title', $phpWord->getDocInfo()->getTitle()); + $xmlWriter->writeElement('dc:description', $phpWord->getDocInfo()->getDescription()); + $xmlWriter->writeElement('dc:subject', $phpWord->getDocInfo()->getSubject()); + $xmlWriter->writeElement('cp:keywords', $phpWord->getDocInfo()->getKeywords()); + $xmlWriter->writeElement('cp:category', $phpWord->getDocInfo()->getCategory()); + $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocInfo()->getLastModifiedBy()); // dcterms:created $xmlWriter->startElement('dcterms:created'); $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date($this->dateFormat, $phpWord->getDocumentProperties()->getCreated())); + $xmlWriter->writeRaw(date($this->dateFormat, $phpWord->getDocInfo()->getCreated())); $xmlWriter->endElement(); // dcterms:modified $xmlWriter->startElement('dcterms:modified'); $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date($this->dateFormat, $phpWord->getDocumentProperties()->getModified())); + $xmlWriter->writeRaw(date($this->dateFormat, $phpWord->getDocInfo()->getModified())); $xmlWriter->endElement(); $xmlWriter->endElement(); // cp:coreProperties diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php index c5a3cf9e43..ba6547d9b9 100644 --- a/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php +++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php @@ -39,7 +39,7 @@ public function write() $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties'); $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $properties = $docProps->getCustomProperties(); foreach ($properties as $key => $property) { $propertyValue = $docProps->getCustomPropertyValue($property); diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index d8535d8c59..ac67b25db2 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -31,8 +31,91 @@ class Settings extends AbstractPart */ public function write() { - $settings = array( + $settings = $this->getSettings(); + + $xmlWriter = $this->getXmlWriter(); + + $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); + $xmlWriter->startElement('w:settings'); + $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); + $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); + $xmlWriter->writeAttribute('xmlns:sl', 'http://schemas.openxmlformats.org/schemaLibrary/2006/main'); + $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); + $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); + + foreach ($settings as $settingKey => $settingValue) { + $this->writeSetting($xmlWriter, $settingKey, $settingValue); + } + + $xmlWriter->endElement(); // w:settings + + return $xmlWriter->getData(); + } + + /** + * Write indivual setting, recursive to any child settings + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $settingKey + * @param array|string $settingValue + */ + protected function writeSetting($xmlWriter, $settingKey, $settingValue) + { + if ($settingValue == '') { + $xmlWriter->writeElement($settingKey); + } else { + $xmlWriter->startElement($settingKey); + + /** @var array $settingValue Type hint */ + foreach ($settingValue as $childKey => $childValue) { + if ($childKey == '@attributes') { + foreach ($childValue as $key => $val) { + $xmlWriter->writeAttribute($key, $val); + } + } else { + $this->writeSetting($xmlWriter, $childKey, $childValue); + } + } + $xmlWriter->endElement(); + } + } + + /** + * Get settings + * + * @return array + */ + private function getSettings() + { + // Default settings + $settings = $this->getDefaultSettings(); + + // Protection + $protection = $this->getParentWriter()->getPhpWord()->getProtection(); + if ($protection->getEditing() !== null) { + $settings['w:documentProtection'] = array( + '@attributes' => array( + 'w:enforcement' => 1, + 'w:edit' => $protection->getEditing(), + ) + ); + } + + return $settings; + } + + /** + * Get default settings + * + * @return array + */ + private function getDefaultSettings() + { + return array( 'w:zoom' => array('@attributes' => array('w:percent' => '100')), + 'w:view' => array('@attributes' => array('w:val' => 'print')), 'w:embedSystemFonts' => '', 'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')), 'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')), @@ -94,53 +177,5 @@ public function write() 'w:decimalSymbol' => array('@attributes' => array('w:val' => ',')), 'w:listSeparator' => array('@attributes' => array('w:val' => ';')), ); - - $xmlWriter = $this->getXmlWriter(); - - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - $xmlWriter->startElement('w:settings'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:sl', 'http://schemas.openxmlformats.org/schemaLibrary/2006/main'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - - foreach ($settings as $settingKey => $settingValue) { - $this->writeSetting($xmlWriter, $settingKey, $settingValue); - } - - $xmlWriter->endElement(); // w:settings - - return $xmlWriter->getData(); - } - - /** - * Write indivual setting, recursive to any child settings - * - * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $settingKey - * @param array|string $settingValue - */ - protected function writeSetting($xmlWriter, $settingKey, $settingValue) - { - if ($settingValue == '') { - $xmlWriter->writeElement($settingKey); - } else { - $xmlWriter->startElement($settingKey); - - /** @var array $settingValue Type hint */ - foreach ($settingValue as $childKey => $childValue) { - if ($childKey == '@attributes') { - foreach ($childValue as $key => $val) { - $xmlWriter->writeAttribute($key, $val); - } - } else { - $this->writeSetting($xmlWriter, $childKey, $childValue); - } - } - $xmlWriter->endElement(); - } } } diff --git a/tests/PhpWord/Tests/DocumentPropertiesTest.php b/tests/PhpWord/Tests/Metadata/DocInfoTest.php similarity index 67% rename from tests/PhpWord/Tests/DocumentPropertiesTest.php rename to tests/PhpWord/Tests/Metadata/DocInfoTest.php index 30b2a7bc48..c860a0d9a9 100644 --- a/tests/PhpWord/Tests/DocumentPropertiesTest.php +++ b/tests/PhpWord/Tests/Metadata/DocInfoTest.php @@ -15,23 +15,23 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ -namespace PhpOffice\PhpWord\Tests; +namespace PhpOffice\PhpWord\Tests\Metadata; -use PhpOffice\PhpWord\DocumentProperties; +use PhpOffice\PhpWord\Metadata\DocInfo; /** - * Test class for PhpOffice\PhpWord\DocumentProperties + * Test class for PhpOffice\PhpWord\Metadata\DocInfo * * @runTestsInSeparateProcesses */ -class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase +class DocInfoTest extends \PHPUnit_Framework_TestCase { /** * Creator */ public function testCreator() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setCreator(); $this->assertEquals('', $oProperties->getCreator()); @@ -44,7 +44,7 @@ public function testCreator() */ public function testLastModifiedBy() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setLastModifiedBy(); $this->assertEquals('', $oProperties->getLastModifiedBy()); @@ -57,7 +57,7 @@ public function testLastModifiedBy() */ public function testCreated() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setCreated(); $this->assertEquals(time(), $oProperties->getCreated()); @@ -71,7 +71,7 @@ public function testCreated() */ public function testModified() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setModified(); $this->assertEquals(time(), $oProperties->getModified()); @@ -85,7 +85,7 @@ public function testModified() */ public function testTitle() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setTitle(); $this->assertEquals('', $oProperties->getTitle()); @@ -98,7 +98,7 @@ public function testTitle() */ public function testDescription() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setDescription(); $this->assertEquals('', $oProperties->getDescription()); @@ -111,7 +111,7 @@ public function testDescription() */ public function testSubject() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setSubject(); $this->assertEquals('', $oProperties->getSubject()); @@ -124,7 +124,7 @@ public function testSubject() */ public function testKeywords() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setKeywords(); $this->assertEquals('', $oProperties->getKeywords()); @@ -137,7 +137,7 @@ public function testKeywords() */ public function testCategory() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setCategory(); $this->assertEquals('', $oProperties->getCategory()); @@ -150,7 +150,7 @@ public function testCategory() */ public function testCompany() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setCompany(); $this->assertEquals('', $oProperties->getCompany()); @@ -163,7 +163,7 @@ public function testCompany() */ public function testManager() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setManager(); $this->assertEquals('', $oProperties->getManager()); @@ -176,30 +176,30 @@ public function testManager() */ public function testCustomProperty() { - $oProperties = new DocumentProperties(); + $oProperties = new DocInfo(); $oProperties->setCustomProperty('key1', null); $oProperties->setCustomProperty('key2', true); $oProperties->setCustomProperty('key3', 3); $oProperties->setCustomProperty('key4', 4.4); $oProperties->setCustomProperty('key5', 'value5'); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_STRING, + DocInfo::PROPERTY_TYPE_STRING, $oProperties->getCustomPropertyType('key1') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_BOOLEAN, + DocInfo::PROPERTY_TYPE_BOOLEAN, $oProperties->getCustomPropertyType('key2') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_INTEGER, + DocInfo::PROPERTY_TYPE_INTEGER, $oProperties->getCustomPropertyType('key3') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_FLOAT, + DocInfo::PROPERTY_TYPE_FLOAT, $oProperties->getCustomPropertyType('key4') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_STRING, + DocInfo::PROPERTY_TYPE_STRING, $oProperties->getCustomPropertyType('key5') ); $this->assertEquals(null, $oProperties->getCustomPropertyType('key6')); @@ -225,50 +225,50 @@ public function testCustomProperty() */ public function testConvertProperty() { - $this->assertEquals('', DocumentProperties::convertProperty('a', 'empty')); - $this->assertEquals(null, DocumentProperties::convertProperty('a', 'null')); - $this->assertEquals(8, DocumentProperties::convertProperty('8', 'int')); - $this->assertEquals(8, DocumentProperties::convertProperty('8.3', 'uint')); - $this->assertEquals(8.3, DocumentProperties::convertProperty('8.3', 'decimal')); - $this->assertEquals('8.3', DocumentProperties::convertProperty('8.3', 'lpstr')); - $this->assertEquals(strtotime('10/11/2013'), DocumentProperties::convertProperty('10/11/2013', 'date')); - $this->assertEquals(true, DocumentProperties::convertProperty('true', 'bool')); - $this->assertEquals(false, DocumentProperties::convertProperty('1', 'bool')); - $this->assertEquals('1', DocumentProperties::convertProperty('1', 'array')); - $this->assertEquals('1', DocumentProperties::convertProperty('1', '')); + $this->assertEquals('', DocInfo::convertProperty('a', 'empty')); + $this->assertEquals(null, DocInfo::convertProperty('a', 'null')); + $this->assertEquals(8, DocInfo::convertProperty('8', 'int')); + $this->assertEquals(8, DocInfo::convertProperty('8.3', 'uint')); + $this->assertEquals(8.3, DocInfo::convertProperty('8.3', 'decimal')); + $this->assertEquals('8.3', DocInfo::convertProperty('8.3', 'lpstr')); + $this->assertEquals(strtotime('10/11/2013'), DocInfo::convertProperty('10/11/2013', 'date')); + $this->assertEquals(true, DocInfo::convertProperty('true', 'bool')); + $this->assertEquals(false, DocInfo::convertProperty('1', 'bool')); + $this->assertEquals('1', DocInfo::convertProperty('1', 'array')); + $this->assertEquals('1', DocInfo::convertProperty('1', '')); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_INTEGER, - DocumentProperties::convertPropertyType('int') + DocInfo::PROPERTY_TYPE_INTEGER, + DocInfo::convertPropertyType('int') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_INTEGER, - DocumentProperties::convertPropertyType('uint') + DocInfo::PROPERTY_TYPE_INTEGER, + DocInfo::convertPropertyType('uint') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_FLOAT, - DocumentProperties::convertPropertyType('decimal') + DocInfo::PROPERTY_TYPE_FLOAT, + DocInfo::convertPropertyType('decimal') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_STRING, - DocumentProperties::convertPropertyType('lpstr') + DocInfo::PROPERTY_TYPE_STRING, + DocInfo::convertPropertyType('lpstr') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_DATE, - DocumentProperties::convertPropertyType('date') + DocInfo::PROPERTY_TYPE_DATE, + DocInfo::convertPropertyType('date') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_BOOLEAN, - DocumentProperties::convertPropertyType('bool') + DocInfo::PROPERTY_TYPE_BOOLEAN, + DocInfo::convertPropertyType('bool') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_UNKNOWN, - DocumentProperties::convertPropertyType('array') + DocInfo::PROPERTY_TYPE_UNKNOWN, + DocInfo::convertPropertyType('array') ); $this->assertEquals( - DocumentProperties::PROPERTY_TYPE_UNKNOWN, - DocumentProperties::convertPropertyType('') + DocInfo::PROPERTY_TYPE_UNKNOWN, + DocInfo::convertPropertyType('') ); } } diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index ca49bf28b2..6fd4b29175 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\DocumentProperties; +use PhpOffice\PhpWord\Metadata\DocInfo; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Style; @@ -35,24 +35,11 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase public function testConstruct() { $phpWord = new PhpWord(); - $this->assertEquals(new DocumentProperties(), $phpWord->getDocumentProperties()); + $this->assertEquals(new DocInfo(), $phpWord->getDocInfo()); $this->assertEquals(Settings::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName()); $this->assertEquals(Settings::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize()); } - /** - * Test set/get document properties - */ - public function testSetGetDocumentProperties() - { - $phpWord = new PhpWord(); - $creator = 'PhpWord'; - $properties = $phpWord->getDocumentProperties(); - $properties->setCreator($creator); - $phpWord->setDocumentProperties($properties); - $this->assertEquals($creator, $phpWord->getDocumentProperties()->getCreator()); - } - /** * Test create/get section */ diff --git a/tests/PhpWord/Tests/Writer/HTMLTest.php b/tests/PhpWord/Tests/Writer/HTMLTest.php index f9b8e6ba91..c3339d1a4f 100644 --- a/tests/PhpWord/Tests/Writer/HTMLTest.php +++ b/tests/PhpWord/Tests/Writer/HTMLTest.php @@ -61,7 +61,7 @@ public function testSave() $phpWord = new PhpWord(); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $docProps->setTitle('HTML Test'); $phpWord->addTitleStyle(1, array('bold' => true)); diff --git a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php index 27b2427f9b..85ddada6ba 100644 --- a/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php @@ -47,7 +47,7 @@ public function testWriteContent() $phpWord = new PhpWord(); - $docProps = $phpWord->getDocumentProperties(); + $docProps = $phpWord->getDocInfo(); $docProps->setCustomProperty('Company', 'PHPWord'); $phpWord->setDefaultFontName('Verdana'); diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php new file mode 100644 index 0000000000..de78c34ac9 --- /dev/null +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php @@ -0,0 +1,52 @@ +getProtection()->setEditing('forms'); + + $doc = TestHelperDOCX::getDocument($phpWord); + + $file = 'word/settings.xml'; + + $path = '/w:settings/w:documentProtection'; + $this->assertTrue($doc->elementExists($path, $file)); + } +} From 5c8e100d4113641e93e1f150c0c84c2e15aeb3c6 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Mon, 16 Jun 2014 16:23:41 +0700 Subject: [PATCH 038/174] Bugfix #280: Table inside vertical border does not rendered properly --- CHANGELOG.md | 1 + src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4775b4dc3f..40805cb8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 - `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 - Page breaks on titles and tables - @ivanlanin GH-274 +- Table inside vertical border does not rendered properly - @ivanlanin GH-280 ### Deprecated diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 88bb010972..38dff1485d 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -55,7 +55,7 @@ public function write() $xmlWriter = $this->getXmlWriter(); $sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV'); - $sizeCount = count($this->sizes) - 1; + $sizeCount = count($this->sizes); for ($i = 0; $i < $sizeCount; $i++) { if ($this->sizes[$i] !== null) { From 71b4ac9c56f87763011e480257874103ea16bbf6 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 17 Jun 2014 15:48:39 +0200 Subject: [PATCH 039/174] FIXED : #282 : problem converting docx to pdf PHP Catchable fatal error: Argument 2 passed to DOMXPath::query() must be an instance of DOMNode, null given, called in /var/www/xxx/PhpWord/Reader/Word2007.php on line 145 and defined in /var/www/xxx/PhpWord/Shared/XMLReader.php on line 99, referer: XXX --- src/PhpWord/Shared/XMLReader.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 153152ee63..ca6869eb3c 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -96,7 +96,11 @@ public function getElements($path, \DOMElement $contextNode = null) $this->xpath = new \DOMXpath($this->dom); } - return $this->xpath->query($path, $contextNode); + if (is_null($contextNode)) { + return $this->xpath->query($path); + } else { + return $this->xpath->query($path, $contextNode); + } } /** From f19353405815589dd1dc055b7355774371e8f98a Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 17 Jun 2014 16:08:28 +0200 Subject: [PATCH 040/174] FIXED : CI : Error with the generation of the PHPDoc Deprecated: phpDocumentor2 should be run from the phpdoc file, not phpdoc.php in /home/travis/build/PHPOffice/PHPWord/vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php on line 13 Refs : https://github.com/phpDocumentor/phpDocumentor2/blob/395af1d42a3fe8af7eedeea28e530ab2fdd2bd06/bin/phpdoc.php --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73dd68ec83..dfee2bb9df 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 -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" + - vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" after_script: ## PHPDocumentor From eeca39670469f60110e6601714c240fb18b0ccad Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 19 Jun 2014 11:59:57 +0400 Subject: [PATCH 041/174] [CHANGED] Added annotations to StyleTest and performed minor refactoring. --- tests/PhpWord/Tests/StyleTest.php | 36 +++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index f446ecdf9a..ef6c665cba 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -22,43 +22,61 @@ /** * Test class for PhpOffice\PhpWord\Style * + * @coversDefaultClass \PhpOffice\PhpWord\Style * @runTestsInSeparateProcesses */ class StyleTest extends \PHPUnit_Framework_TestCase { /** * Add and get paragraph, font, link, title, and table styles + * + * @covers ::addParagraphStyle + * @covers ::addFontStyle + * @covers ::addLinkStyle + * @covers ::addTitleStyle + * @covers ::addTableStyle + * @covers ::setDefaultParagraphStyle + * @covers ::countStyles + * @covers ::getStyle + * @covers ::resetStyles + * @covers ::getStyles + * @test */ public function testStyles() { $paragraph = array('align' => 'center'); $font = array('italic' => true, '_bold' => true); $table = array('bgColor' => 'CCCCCC'); - $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', - 'Link' => 'Font', 'Table' => 'Table', - 'Heading_1' => 'Font', 'Normal' => 'Paragraph'); - $elementCount = 6; + $styles = array( + 'Paragraph' => 'Paragraph', + 'Font' => 'Font', + 'Link' => 'Font', + 'Table' => 'Table', + 'Heading_1' => 'Font', + 'Normal' => 'Paragraph' + ); Style::addParagraphStyle('Paragraph', $paragraph); Style::addFontStyle('Font', $font); Style::addLinkStyle('Link', $font); - Style::addTableStyle('Table', $table); + // @todo Style::addNumberingStyle Style::addTitleStyle(1, $font); + Style::addTableStyle('Table', $table); Style::setDefaultParagraphStyle($paragraph); - $this->assertEquals($elementCount, count(Style::getStyles())); + $this->assertEquals(count($styles), Style::countStyles()); foreach ($styles as $name => $style) { $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name)); } $this->assertNull(Style::getStyle('Unknown')); Style::resetStyles(); - $this->assertEquals(0, count(Style::getStyles())); - + $this->assertCount(0, Style::getStyles()); } /** - * Set default paragraph style + * @covers ::setDefaultParagraphStyle + * @test */ public function testDefaultParagraphStyle() { From c11df2e4263cbf394c8c6f51651d76944f8c3d71 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 19 Jun 2014 12:04:07 +0400 Subject: [PATCH 042/174] [CHANGED] Added annotations to StyleTest and performed minor refactoring. --- tests/PhpWord/Tests/StyleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index ef6c665cba..a8890b9627 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -53,7 +53,7 @@ public function testStyles() 'Link' => 'Font', 'Table' => 'Table', 'Heading_1' => 'Font', - 'Normal' => 'Paragraph' + 'Normal' => 'Paragraph', ); Style::addParagraphStyle('Paragraph', $paragraph); From d35db836dc59b096d14cc06e33a395a847a18586 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 20 Jun 2014 09:00:12 +0400 Subject: [PATCH 043/174] [CHANGED] Added annotations to StyleTest and performed minor refactoring. --- tests/PhpWord/Tests/StyleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index a8890b9627..23af4b2ee7 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -64,7 +64,7 @@ public function testStyles() Style::addTableStyle('Table', $table); Style::setDefaultParagraphStyle($paragraph); - $this->assertEquals(count($styles), Style::countStyles()); + $this->assertCount(count($styles), Style::getStyles()); foreach ($styles as $name => $style) { $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name)); } From 0ea21939067effbc80e8b7125db586afda173323 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 20 Jun 2014 09:34:49 +0400 Subject: [PATCH 044/174] [CHANGED] Replaced "assertEquals" with "assertCount" where it was necessary. --- tests/PhpWord/Tests/AutoloaderTest.php | 7 +++---- tests/PhpWord/Tests/Collection/CollectionTest.php | 3 +-- tests/PhpWord/Tests/MediaTest.php | 14 ++++++-------- tests/PhpWord/Tests/PhpWordTest.php | 2 +- tests/PhpWord/Tests/Shared/HtmlTest.php | 4 ++-- tests/PhpWord/Tests/Style/ParagraphTest.php | 2 +- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/tests/PhpWord/Tests/AutoloaderTest.php b/tests/PhpWord/Tests/AutoloaderTest.php index 92423fc62f..dace5bdb49 100644 --- a/tests/PhpWord/Tests/AutoloaderTest.php +++ b/tests/PhpWord/Tests/AutoloaderTest.php @@ -43,12 +43,11 @@ public function testRegister() */ public function testAutoload() { - $declared = get_declared_classes(); - $declaredCount = count($declared); + $declaredCount = count(get_declared_classes()); Autoloader::autoload('Foo'); - $this->assertEquals( + $this->assertCount( $declaredCount, - count(get_declared_classes()), + get_declared_classes(), 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\PhpWord namespace' ); diff --git a/tests/PhpWord/Tests/Collection/CollectionTest.php b/tests/PhpWord/Tests/Collection/CollectionTest.php index e3d08da276..833b3e8072 100644 --- a/tests/PhpWord/Tests/Collection/CollectionTest.php +++ b/tests/PhpWord/Tests/Collection/CollectionTest.php @@ -28,8 +28,7 @@ public function testCollection() $object->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->assertCount(2, $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 diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 1b89b7c105..0196a7e1a2 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -40,7 +40,7 @@ public function testGetSectionMediaElementsWithNull() */ public function testCountSectionMediaElementsWithNull() { - $this->assertEquals(Media::countElements('section'), 0); + $this->assertEquals(0, Media::countElements('section')); } /** @@ -57,7 +57,7 @@ public function testAddSectionMediaElement() Media::addElement('section', 'object', $object); Media::addElement('section', 'object', $object); - $this->assertEquals(3, Media::countElements('section')); + $this->assertCount(3, Media::getElements('section')); } /** @@ -69,8 +69,7 @@ public function testAddSectionLinkElement() $actual = Media::addElement('section', 'link', 'http://test.com'); $this->assertEquals($expected, $actual); - $this->assertEquals(1, Media::countElements('section', 'link')); - $this->assertEquals(1, count(Media::getElements('section', 'link'))); + $this->assertCount(1, Media::getElements('section', 'link')); } /** @@ -84,8 +83,7 @@ public function testAddHeaderMediaElement() Media::addElement('header1', 'image', $local, new Image($local)); Media::addElement('header1', 'image', $remote, new Image($remote)); - $this->assertEquals(2, Media::countElements('header1')); - $this->assertEquals(2, count(Media::getElements('header1'))); + $this->assertCount(2, Media::getElements('header1')); $this->assertEmpty(Media::getElements('header2')); } @@ -100,10 +98,10 @@ public function testAddFooterMediaElement() Media::addElement('footer1', 'image', $local, new Image($local)); Media::addElement('footer1', 'image', $remote, new Image($remote)); - $this->assertEquals(2, Media::countElements('footer1')); + $this->assertCount(2, Media::getElements('footer1')); Media::resetElements(); - $this->assertEquals(0, Media::countElements('footer1')); + $this->assertCount(0, Media::getElements('footer1')); } /** diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 6fd4b29175..75b2d28875 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -47,7 +47,7 @@ public function testCreateGetSections() { $phpWord = new PhpWord(); $phpWord->addSection(); - $this->assertEquals(1, count($phpWord->getSections())); + $this->assertCount(1, $phpWord->getSections()); } /** diff --git a/tests/PhpWord/Tests/Shared/HtmlTest.php b/tests/PhpWord/Tests/Shared/HtmlTest.php index e7b3533e74..c4c0fc9d5a 100644 --- a/tests/PhpWord/Tests/Shared/HtmlTest.php +++ b/tests/PhpWord/Tests/Shared/HtmlTest.php @@ -34,7 +34,7 @@ public function testAddHtml() // Default $section = new Section(1); - $this->assertEquals(0, $section->countElements()); + $this->assertCount(0, $section->getElements()); // Heading $styles = array('strong', 'em', 'sup', 'sub'); @@ -52,7 +52,7 @@ public function testAddHtml() // Add HTML Html::addHtml($section, $content); - $this->assertEquals(7, $section->countElements()); + $this->assertCount(7, $section->getElements()); // Other parts $section = new Section(1); diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 12aa51ceb6..73540b0c7b 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -119,7 +119,7 @@ public function testTabs() { $object = new Paragraph(); $object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300))); - $this->assertEquals(2, count($object->getTabs())); + $this->assertCount(2, $object->getTabs()); } /** From cd547927eaa6385cf1d2471d642e2d60677c193a Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Fri, 20 Jun 2014 22:24:59 +0700 Subject: [PATCH 045/174] New structured document tag (SDT) element --- samples/Sample_34_SDT.php | 17 +++ src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/SDT.php | 130 ++++++++++++++++++ src/PhpWord/Writer/Word2007/Element/SDT.php | 71 ++++++++++ .../Tests/Writer/Word2007/ElementTest.php | 2 +- 5 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 samples/Sample_34_SDT.php create mode 100644 src/PhpWord/Element/SDT.php create mode 100644 src/PhpWord/Writer/Word2007/Element/SDT.php diff --git a/samples/Sample_34_SDT.php b/samples/Sample_34_SDT.php new file mode 100644 index 0000000000..fc1e7de6c7 --- /dev/null +++ b/samples/Sample_34_SDT.php @@ -0,0 +1,17 @@ +getProtection()->setEditing('forms'); + +$section = $phpWord->addSection(); + +$section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); + +// 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 3ec113907e..afde4270cc 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -43,6 +43,7 @@ * @method Shape addObject(string $type, mixed $style = null) * @method Chart addChart(string $type, array $categories, array $values, array $style = null) * @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null) + * @method SDT addSDT(string $type) * * @since 0.10.0 */ @@ -79,7 +80,7 @@ public function __call($function, $args) $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape', - 'Title', 'TOC', 'PageBreak', 'Chart', 'FormField'); + 'Title', 'TOC', 'PageBreak', 'Chart', 'FormField', 'SDT'); $functions = array(); for ($i = 0; $i < count($elements); $i++) { $functions[$i] = 'add' . $elements[$i]; @@ -205,6 +206,7 @@ private function checkValidity($method) 'TOC' => array('Section'), 'PageBreak' => array('Section'), 'Chart' => array('Section'), + 'SDT' => array('Section'), ); // Special condition, e.g. preservetext can only exists in cell when // the cell is located in header or footer diff --git a/src/PhpWord/Element/SDT.php b/src/PhpWord/Element/SDT.php new file mode 100644 index 0000000000..477c50f357 --- /dev/null +++ b/src/PhpWord/Element/SDT.php @@ -0,0 +1,130 @@ +setType($type); + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set type + * + * @param string $value + * @return self + */ + public function setType($value) + { + $enum = array('comboBox', 'dropDownList', 'date'); + $this->type = $this->setEnumVal($value, $enum, $this->type); + + return $this; + } + + /** + * Get value + * + * @return string|bool|int + */ + public function getValue() + { + return $this->value; + } + + /** + * Set value + * + * @param string|bool|int $value + * @return self + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get listItems + * + * @return array + */ + public function getListItems() + { + return $this->listItems; + } + + /** + * Set listItems + * + * @param array $value + * @return self + */ + public function setListItems($value) + { + $this->listItems = $value; + + return $this; + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php new file mode 100644 index 0000000000..d25eaf981a --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -0,0 +1,71 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof SDTElement) { + return; + } + $type = $element->getType(); + $listItems = $element->getListItems(); + + $this->startElementP(); + + $xmlWriter->startElement('w:sdt'); + + $xmlWriter->startElement('w:sdtPr'); + $xmlWriter->writeElementBlock('w:id', 'w:val', rand(100000000, 999999999)); + $xmlWriter->writeElementBlock('w:lock', 'w:val', 'sdtLocked'); + + $xmlWriter->startElement('w:placeholder'); + $xmlWriter->writeElementBlock('w:docPart', 'w:val', 'string'); + $xmlWriter->endElement(); // w:placeholder + + $xmlWriter->startElement("w:{$type}"); + foreach ($listItems as $key => $val) { + $xmlWriter->writeElementBlock('w:listItem', array('w:value' => $key, 'w:displayText' => $val)); + } + $xmlWriter->endElement(); // w:{$type} + + $xmlWriter->endElement(); // w:sdtPr + + $xmlWriter->startElement('w:sdtContent'); + $xmlWriter->endElement(); // w:sdtContent + + $xmlWriter->endElement(); // w:sdt + + $this->endElementP(); // w:p + } +} diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 6c10f3a57a..752415a1b8 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -41,7 +41,7 @@ public function testUnmatchedElements() $elements = array( 'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', - 'Field', 'Line', 'Shape', 'Chart' + 'Field', 'Line', 'Shape', 'Chart', 'FormField', 'SDT' ); foreach ($elements as $element) { $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element; From b527d066086c7ed72ff07fd8fdae704b4dfdd946 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 21 Jun 2014 09:18:57 +0200 Subject: [PATCH 046/174] #23 : Implement Word97 aka MsDoc Reader --- samples/Sample_11_ReadWord97.php | 19 + samples/resources/Sample_11_ReadWord97.doc | Bin 0 -> 49664 bytes src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Reader/MsDoc.php | 1419 ++++++++++++++++++++ src/PhpWord/Shared/OLERead.php | 310 +++++ 5 files changed, 1749 insertions(+), 1 deletion(-) create mode 100644 samples/Sample_11_ReadWord97.php create mode 100644 samples/resources/Sample_11_ReadWord97.doc create mode 100644 src/PhpWord/Reader/MsDoc.php create mode 100644 src/PhpWord/Shared/OLERead.php diff --git a/samples/Sample_11_ReadWord97.php b/samples/Sample_11_ReadWord97.php new file mode 100644 index 0000000000..f0df59bf1d --- /dev/null +++ b/samples/Sample_11_ReadWord97.php @@ -0,0 +1,19 @@ + 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +foreach ($writers as $writer => $extension) { + echo date('H:i:s'), " Write to {$writer} format", EOL; + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); + $xmlWriter->save("{$name}.{$extension}"); + rename("{$name}.{$extension}", "results/{$name}.{$extension}"); +}*/ + +include_once 'Sample_Footer.php'; diff --git a/samples/resources/Sample_11_ReadWord97.doc b/samples/resources/Sample_11_ReadWord97.doc new file mode 100644 index 0000000000000000000000000000000000000000..a5ce295d8aa8c35e681eb66e26857259659f5955 GIT binary patch literal 49664 zcmeFY1yo#1m+0S(y9I)K13`la*Wm7+;O>nRf(1ed5Zr?{?!hgA;GW=`-~{}w`Q#=)~~Bhon5v|_CBYZPh!3ZFwHU=oo5;B$@&fChjLpaXyjfCYdJ zfCGRF04xCzJ^%s0Jpe)gB7pk;N194*@s|7VdV$OZWG0OmplR?I(k{;!n$$MfQ^ z$p4wl|Fr*i4g8s|;P?Mg|KPt}!}I=V|6>3$|DES(N4)jKX5rn}A z!juL79^Hch<`H%P0=z0dH29wTqd*6`p+34jyt9eufECdLte7e=t4=`Oes>lRZZF|7 zU@#p}$-kF@_u+RL{6CO^Tg=~OX#YS4Zc%@i;ras^xW)ZlM)D72;1>CJ8I3=Xfm`g~ zWz7CS2EL;Oq;pe=9Yz*`U$ zK#T?K3`8CPPXVNWw&80|3Xn$rhcySUnH+QvSXzWI9}o%z40v5?iYUN>Mge+60W4xv z&=W;8VDVA_D@p2Z-NLnm1Ly_5FI@j&yl_qU-01@Z>?sPMR`{az0i@|b5Aiy|<9Av| zz8eYjZ*mBLM~4KofDY^mI-vH|zwHWT(Dt3~obNOX?tEAaM_0e=x*>bI8Q^8f}RApABDuKzR-cz`YuAz(8I__y9$ z0;S>M3IORh*Y)nKgFCk;fOCrszX_zzfHVq_Yz0^bI0Jx}xu;KfOB4iny9d9mEtCTi zAQuc&g#g5Gz<&dtmH<&5;sG&m8@|iYfIPHwxT6dlP6t`Q4LlIq0nplS1pz5s5aIzR zaE%K>I(PuYU=aENyn^2YIOz5k4gv_{t{l8(c$eYwa5t3TZ~5>J!ToY52=jmiNCty} z^Bfck?;Gd?7!PQ-0}Sub&|S_g7!4RR7y;frVCf#f3&U@K|7|e0xc~b1o5a68=l$cc z4RrX)i)ygx3-ueKUSxP3fF|Mf{jszJg6WHnUw>8l6Clm`m!(Y+O<&|(|JAw=0BO9x zEFFYo`XcD+uhxx+Z2IEh@~=wg0Me#^S(+2Y^u?!(f3Ev(asj>n9)7d_f6s+4Xm~*Q zeTl&{)bADne8&S%J@;e(E)AFbg8;XAPQc!TpOvaW>oSR^@XyEAX29~Amo%*FLAboJ)>b%Ridk4{bcLhJ9kwBrb@R%Op z@44_Ccwj;Vx(yHTv-5w#e^~DAXcW@Id})30l@tf_|%%4Szocf4yiM-26znce-u6q?D$@^jN(UyfJ#A1C7AFA5CN9|B_Hmv z*#aBh1L%?v@CxrCU^w7^9KfcBzlO58bEY`}R~>Fj;IH^V*opA|S%NBfDt>z)foJ|L zC{rp^GTpr?{5|JCj^WOdHE`=4(r-@GowEcetQK&Vq=5Y3yJ8`CpP_f3FYZ2(B;i^{ zfq#I+?>_&%TXhTM!_Ne~J0}WA1Zjd$53~{hHx2p0)5KGFSuS4QL|`uPfVY-F{#`}z zY#`*wQXVh?dH*VTdpmo(48l{CRgeY2jm4c~c6$R7me!P!)K=3JqOq}Lw|BL&q4DD4 z;G}ur3AJ;!p;1tjqfu0sk)!eA=VoT3aq~2DwDa(#5v6&=hjF_AIQ(cRD5xmNXsD>D z=;&w|ScKSEn3!0k1ov8S7UAIG z<%U-RMn^}-!o(uM#wOvWrJ&{h-wwAOAbd3N3HSsNOb0^12P5KxZ@b~|gTct)yYQQ8 zfNKOqBxDp+G;|D1K%gEEgaAfFL_k7BMn*yc?gjw&K}h(>1hia|DEBnXQ0d$Vxr5_! z(deaWI*BwtA3%7_-9ykZ?h})ck})tcJz!?x<>P-OASfjLSVmS(UO`byTSr$<-@wqq z(#qP#*3KU4;pye=ATvx`i91)=9Z6L z-95d1{R4yJ6O&WZGqZE^E30ek8=G6-ws#JXj!#a{&VOE9!p8*$A^tWj;PbbU{mZ!U zfpH-qAt556!p8+h@P-c@9|@V33xz;Z1J%s!9vycu8lhBNZcQgTJ&)!Ak-7V4jQbGY z6^29j(C$X|*9I2yUmDrJ4eamZng?Ma0;d)}B0lgU{o*F_K@P%yE0|r?>_Ljmt4yMV zldtVq1JMifW{pE48`u~`OS)9!%jSlvDn-U~O{c@Fy7_+qpj^nZXVb|OaP3b00#|FONjowU`D3r8N z77Svok-M|%D0nJT`Pl(uQ(78k5T#&qf7#V%ltn3!ZtuhA@;v?H=spZ_jS&@Z z%Jlx{li!E^U>eEvhuf;5>a|`+xs9*zQIRwEsb3Nr@a62^n}tya5R;4z^61(*-9>zkudiEUPGn;Kj+$*p*!B^O47wgzk(h&al81 zR@d#6(y)zeNah|wK9z?ltMJxRt>*V&incG*FK>L-wtLhwx;`)OVX;ZR6MTe8okynb^hYiX#GSa`<&>ScIC|aA_ ziA3!e(c4w;xre2BfP$Nk6*<=Q?gbaJSGG>Et0XiluMSqTwL$wqT8C<}PEWVL$hnpFM$~b z_3~qz!Qw8;np*r8h`aBMk)~~wyTu)_DjMd86T19^5h+&gOg(U;Je0fojPicNX7hNP zXm^oE(N!O`=DcFk44ba9->H3=Qn*t$8I9@z(gf~WtR?O5jiczmt>hnNM4hMU=o0=k>Ot<_?($FSS~vWPL-7*uKxDHg4g3 zxl<;MXg-K~v^1mmA>V_{9!~SHP-L0_ZeQwTmhR++8zng?l-ZZ0dT8y9+Q-^c3&9F2 zx<+z#S_1<;HjA=H)rfTiZ(WN~RlfxW!9jm`Fjn5DVKeYGtZ=zNq=c zl5Em3ZEwcC> zib_@H-oV(Cq;@lR$i%n;s^oc1ItNcw*8HZFVm>lerg`yz6I}x);&&Af!;0a<;a-so zo73_Eq?w|m^}zdFip!Smt>AcAAWH>=ug+;*GF(&aElXQ0J&x>zyft|T%h~x~M&4k`Yk_Cn%5TeL`^7iWee8V>-EtZnA@T2<0(&7ov2jwg4ca@cS zM^SFoOwD~Xe&B^&oqWb` z%XG0ECOdzL90OQ;1CLhIh^uRZ@a?srj-B1(t=;&0K zdkeh0uL-K4My1yJIdwMm!hJ7JjRsF>vpJ!}aBi6FJ83Gdu4$(88s(wdly&`7T|xNg z;AH78Cz?n-%F)8{Bg|<}ZPKStPTqZd@nc>daesyfmXX1n8@cn4&2i<`kkal+WjuMP zusLUeL?3U+=CcVD1!ZF=s(^OXh0U+` z9?uCxLNtxoI@T?=_f(fhmDFqE$IS&SopoLw;udgEs}w{iJMJ1X3RXQNbc|bYlrIpHom!n4?cSDJCv)>oF=9;NOXYzYdb&D-b6K!w4 zv|?T3VydT;0`op9RJSNia{yYD-Vy&R?!t_WSG}37v0g0F#K- zE9#TjxKbNVr!^KcW%_xQRvM%rtJUxZ4GPB|_ZL=U`E1RXkA!Bv883aemV2q5+HVy^ zC8O;#NcJ8gdO1#LfGUCgh&;sFlZZDqNtA_bpp1}ELxu+9L0-^br$XhSV*Hu9yf8~H z>LW|W?{YL5kIB+^ z$Rd7f`(x&VK9f=3fq`$j-ny8CG!2}XPN)ZnjVp$_$?D4iuu|IHOdG`A$q5%e633#W z@-^z#<#>Vq(seaodNp?m>Lo<#aAAy5EhmD!*qO%2Rb4Jt5@{kCi%#HMoq8^68y)!u z-n70!A$8t`-7spah&(F9M@YYT^w{<)>N0{F6}A*{>BrwCE-WSHDcP-DmGyC~vm^}> z_~~Xo!I&5}gJl-?iQIxRb%e+68~1uiJJu9(D(vbL`<<>2%Vl*_&GlF=JY149x}OBo z7f_PV#oAWdQQRrqVA8U^$e=5qfj zmYgdO&DHy-6jy7-XC-8|^HY13VdKH#DP)<1);sUp+yhyvY#XK<>68bAovAq?ZeIm= zb(}bInj=^Dk2I}1)W^;xPe^V&b(L0Q(I1!4*=%U9KcE!2sSEe;o?q0Ut1o^nvgIQZ zz-8Rt_qxg{d+7C$IM?8J5~f*gp2fcE#YHZrkkUw3wdv+l>*h(UFX}p|=^RYZ=GvKg zpL3Chp*kDH@N*LJG4U{s_lFotti9v?;>~Swt>S~t+eE{`{THYpi=6U{7)!RESLb_L zZacPLpGIM4puKsMXoI>qWjVtkH^`4w{Vm7hD~%3y6AVe5vruYNFsUYrO7%fgxgTSw z`DI1k)2H$yHNe+z-Eke_gDnhM^KCzw)45WTW0 zQz9C@DDc9>LJ4Kqv z6FaQGehRTJ3n>3`KN@AWb3ovSvhu{|ZhRR+A6;{WF05Elw7rFTN8ZoO^Ut3uey&Q*s>*^(%M3AJiN zLy5BAnw6XrDJn;-9*IrUjaGM*C&aGe1^><>B-j@#zy~mGI%?H*9XH1$YeZ$6nBnHL zW4ouNH@bc1uq{F7KtpNH$_j>vv6uB+(3;;8;6wBp$_; zCjN+l4@SG}X9CgfsFyEEoZr_!u|-?gsVEWFCBwSjC0P7-eC3P)td2 zy6M-O6#{1oZ5W}31oEGv(@M_N_EtlZzWq0EfN_F%rajf|=$!A{JY#0V1_I4RU_?yz zFFzARDSh@A1rjn_anlXDJJWnrMlN0=EN|KZc4zVxG-J|h)7>}uoz#2tWEPUg*nDX` zi_}ULpY`J>(O(tW2%eQ2EfifTN<~HLl3gCp&qUEculgO?`vpztoXLLBc5waQpwlP!t|Z8ETQX2huHh2 zvMkk0y6N;}XTJOLWQ=Shv9c(>eNt+?p-S)XyL~Y>Gk5K=SQ-jI4V)kv?I|}jHmSpG zMGP54M@^5p(z07e@Lf+Bx=_C_pz#fvYS4S50d^%{;5B%jkjB73>>`S4-nn*3}X>GLto#bX%pmelYyTFlGI@JUTh67qSTDjxqkFc2r*AnX^1u z&mo$ekT*uuevBSnX`;!Y92MBU{Yh7OX2{!x`y?+8-+(sBm$vYHb#n6)qSPgpo;DW#D z5liOurbzX67PlZ_^WZvnHzJek4htztk7cw}=vRvLaa%E|U&m28UN0;twx+W=oAKkd z%iL6DJB43TCHX9b_amm;)(KL+X(uLrFgwJPmrxI#ATnF^e-&wj7}|k3Hkq!^mTthU z(7(P_;9{42WZ*kSV8Pl2-qlV`XZ==!oy+Qt>AMilzg1K+W_3!I z!U0o&MbnEKa4NVQR95LuFg8Xxg$_R%PJ=ur8d;PSOpMOvSD4om55rE3e<0_8J@qjo zIcYMJ7|Xrs1hr~ShoR2gSR%_(sl$S58d21LdO4B%r7YUAt(?yCCxpBuSaq$&RgjJ$d6($#2~tG5c41vkvfAIAuJtMnp#cP-pjkxhCMY#Qx{Ujb?Cy1a3HEx{eGfWCrH*v}>p4BK}!% zKD7BeEAGd6@-Y@+MuP|p)=v+g2n$=*1#R*P+Vp+3KXpy@YTs(*%&f{qK7(0D85%Lp zrhIb$y3Cxetaz-zu^5pOyqFG~D3$6&=N{;4%sHW+F5jMUo0HgMiD!hkZN~(@^`4B* znbe4%dQ~`jyu;o0l5GdNJ?Ul?XM{@A02%|~6xNoro7dGTz&vFWNUis>LJC4P>zgxg ze$5Q6CokiFX}jDTROzvelwWYT@)wp%HlUZ_6x$YlpVVz{*w$FfV+pef)0m+;%`HbP z?uXPvA&9}5*B{>M+zbYrEo>5}hQ{L#;x<;;$!NivH&5yGlEX}dj#vd>xo)U^nRn|e zFr3KR)qIcFhn`505CqcLQIim>Hy`S}9JvUrovRHaUFsl`+QeK?3NBhKuZ~*p{z`M1 zm3BEjqE+HeImaKMT1uKzyFi$N=Nw(V%E;biQzFpwNTaQ>ZIUT@#wVyjU16XU->!o4 zg*Uf?z19$SwJ)kFr@)rTv{~F*0)FFA)-M^K1mkzMU)a8y(*?E47bC1U_+j)lPC6NS zM~G2uVW>!@38h&F0zgP;$k4 zVygZgS3IJ{hbP&FUuT>lulw=)$c36AYi^(@n~O*lmL=pIFpvtUH0XQ^qmKb8DsKcyJcJcZm(nuN``NBL5GH4s9hV#=C?X0EG_%Q2Y zM1^#0YV}-8AK|1@j))l;5)j7fwPfWll6mlSuTu*n3iLrjwX0lRq?k`;S6*4KuV
BqNBYa8(zEWfSTK>R6|!0n3O|MXs#eAi_ZB$o?-A?m+xwIvcftLLSwO^_sIZWo zbtz3Z**;+}s$b!T+Hdw|^n;Ndrv@h?O6-ZiEr@LD-FP=Kqa0;*5o3jYaoqL<*NW6~ zkRV^4S_#``1wFUDy3}XioM*$!rnqL?CY-@azVTk)czSfJ@eA@=dQnyuO|vUxiXHAx zyP-6(XrJ|+ZY!gmzDg$%>6n%7Mb)_B>k^6Ub2Zqv1ZVv8?Ry`HF+Fp-Ye$8)Mj#K7 zQswHnzMK(t-?5MhnJl5t=IeT{Ut&eK)E~1-(RtMorHA3FCYD{Hy?{k5rd<%x0m-H8 zEAoq`5!4NP%Rt#lK_=4sc8SA$2(i1E>*s`Yjq|!R!}|rbbn#UrklfE{$FonM(MqL< zB%QDnFRZ7@DU;wy@e*kexhiN^b5YRL z-PK=5n&&<#g-wASlu^%JvJe)mA2UUt>ptu=#%B^PNElT8lg7NP#`0NAV&v9OHIjAB zG+Ey=2~@}3D6`hUF!f~a=_XZv*{z#Cvpu648C5ELpQJ&&p_vbRrUPsqxh~rJSzLiALmr(zS2Ts z1a$U+C~8h|=4ThL>36)5U~?FPzfHRzf$Hc&D!rUh(lFj*3a6!W;Shn%Dm$`guWg#5 z#5HlBBn^ji3ydl-K~5`MW;7dKswfPVEB=)Kbn`TY(qXK-SG_Rzp1eV=VV8WkC8Nxu z9Ie}VQ$g|oty;WzoKbL0AjXIM(T3>}ktpLe*3g-49ZTPN9jAOdCW`f$IA( zd7l)m>P9>xHfHKW6yx-+4@sV+VUx+zU+qDmbbW7zJ$|t`6vZn@UD#wxM#c{g4+%tD z>%T(XG;3nsyF64-RWi3Cv=Ymvm%x9b{9@&)0DVI6?ubSRr?=4<{_(w7Kl~9-cW&w8 z-sRk4!xfk18YgC80KMwv~q$uj^V)LFYG~QfOF0DzIbgM_k26 z=ayAe^@MsKSM~4(A)W)Ie8;DZiCTlM5kc`N4}D3bGTKhr-YWo^nj zw%NaQleys#zC0;!mnc_*pB}OshHS?WjAY$y(#l z3cbT1e@EGroN;5-C*6j*tZ}}kM>wRxSdhLV71+I7&`enh|GaLtYjxj7$`h|@CKrJL z5epz&WwP7_reqcUIL`+0+~x(PuXvbUDP!++iUoFiUb#_2yu7vh)-j*CHnK=Vuc-W} zy}!Q&Hq7mzuwJ}fqXzJL@VZ)%LN|pd>MC9;4F89+Au>-xIWa#5uspr5+Yd&k1?WzbY2ZXXknWHxuiMtW$*Klq&*|y`vkb|D4>dxMfpL( zediZdd{1mJ3RLAN!|k=xbh*CVL&uI+=mTl1Dh&3E)`p|b!WfPW`a6^+1LE)63@i3)qq8pNM8p1XkO;yIWMQ-}Cw_JhyXUL}8?eE_W5Dy)H9us3?H^ zlE%j-iqVO&qieE-EE196hg5Q7`|SazcYv5U&KPpKZ_6tQi+I^ydGVW;!`+CiFTS*i z=JK;;SX)RGWIys>6-9h_D2=Y=x)>w3*d0Vj^)dd-{g$_8x;jiEt)@69HL?r|NMRZS zkVygooE16L0y~cWL?`*ige6SsJ$mV)8WgBXb)V^5!s zHUYn{@$qAJPX3|pRI2yjWsGPb+3AlZsn=w5r4JDi-Um{fK;7kXm!vX&riIKCwbdYb zTC(`kei*Bl;5D;JiO9SC>LCb82fa3sh2TEU(hSe z^EymZc*a1Rcu}4yOU=;pS4Mqkj?9-iRLVZZn&-iu_gT2=jvqqUol32`l9+395al>y^$M87+1^@zNah+Or73 zEfP0O7v=xLe+!b6QFv(}F;H2MsuSg_>QXE@_Lfk*o{v&v(ipj}LA8VtQ(-UolQuhs z{Ci9HV$5rKu12cnisW}Dl|Q)b4&(iBk`$HfENR#xa2As+5{%`{qa$>UlB1kJEzsla zHc@w>PgGVmHqXj%?onb3ePPaL$NLy@1wxUl7aY9TI4mWxZ%?Yb&o4mbIjsDOW;dae zh;l!hp}Ukq_H*!{Gb+{39~vU@y=dAP;&YBu{4Hk2av zjP9EB>1p081d$uFF9;uKydhad0u{F)5rwcgSAnad+=_9dv_`jAKJmt>#HCS!e>@{JS3$fl5HO>xvm6eugHG>&RFBq#6(aTy7FWBoyX!3 zd!dI~zzZuAU9{u12k4aVNUjdkr<3Rr=-wnRB+~!DqH+%;%jdKuGA1G+=_l#DoU%na z==f~-D^JEs9a>if@_Wu__(LOIGju?rR7_oXa)hrl7U>zR$>zehPxQ)TL~D}n?Q0b5 zjTqpogCggTJeA}l3@;?ncl@S|UO&j98|=3D@az{0={^>l#;4E;B9p2FFHY_3Rn$vO zDJP=GTKNhuUj>U$WZuxlqk2MwvxM0B_r2_*UN>ent(M5|@8d2B?Dg3Br#C&BlNZ}VR>!Gj4!0pML#IPfL1rR4jrMp5z|PNM1STI+1heWI%60ErP&T3^S@^=%YWZN_hPAM2 z-Rz!I2Q!fPzD!-){q$Vtvomr-RFEhO?AsS3&JMx({PBwUT&7r`oq%1Tqs?c-+lBFu zs}aV1ts7^slhlokKTny%7k zZc{=oeQhu1B5hpt`WbGKPyE+&2B#lu)R59lYU{NEF99q>#2&r0cp~=J4a9822%RKB zsN@bSWBC|*LdPR6`9b8+Gf+7b)>7>v?(uX>!JDd~9c9kL&1M-7fB9Ur z;@1!f0?E_8pE?^jBOzeKc5c$C4acf}ck(ZlQq`q<*p0hS95)F z$?2IdsuO!b)|hqT??s^|H0r`zd_*IqWA_}v#+B$d+6mkVt<59$$y~!9Y15fPL{8wDb+}#1`r^3mh`VXEp>E-xQ0rkG9!PZTqDQ}}p&^}LPkoCbevYx= z8*%fX0!RN@XY((`Lv=P;U#^W5i;pFgzZ^>9NADkvbJBxdIfZnHxMoK?iPRqsj{36M zYgaOsn;Oqu5aZ3u_W8fx0!qpv=+kx*f~4wSQ3d{2-vg{=5SG`oO~vLyj?vOb~xEb2(s2EXb>ZmLpt6 zf4ZgViWh0^J!gQZ!^_qga+Ma0T-i+Re*g@qNA6ydnVTDwOzOTVH8p)X@AGo1ko7(&jM|(x4#4^ z1AgtSKQf|~F~7cUcl)_ntI08NuM8|^9GyeZgcP@XU1E)4V&uL5wOWwojiFEev2Zne~x^tq_w(R{8ge0v=C1-lfIB9e5?22PLyvkhxE*?*PDKOLEi z)y9K)kBt}4OJdpyZ(2Pfuu|=CZ6ZZoI4w_oQEh_mSV_##cz@|!R*iHYM^w~)g2ypD zfNg{x)=)mu%Bb_~FkAIB*gN02^1?#8x`td{kRr-$rri$U^Sy6s2q{L?RoI(v=R#1-3#!#U`!;$2(C>X$0oFzIsC=eAq3w+v?V zxQ4jupD!X_mzFDp%#$>^YBV^m#jLiVSv-FA*ym%+lo>5XHm#`OdHF3U9nIO&sjCuP zHj8Sq_%L}vzW?U1*CFl0R8qXW;+}KXl(j>0v$b^H^5L%W$j#$UZxqBzVGUP0?}y1u zMO3GTj_a8LD_L)uhx;-qf;EPC_;NT|XVsN%Y`@J(bwu zilFfl*o=?QG!p2iWC;gNBp%r1S3FcSg_Jdm_Gp(~xi|M{#d$RoWzJ~iCThr7bLK@p z0R009BT*=;`@EDR0h9+_a#wsW8i$+uj}k7jx1Zpz7(Erb7NlSg&|2B$D*86vu;6MD zai4mRN^M8QOYYo*e3wqQ_Jlo;H@1~?M?&N0RL|=n1jtn%@|yyF*`v=Oii95Ja+-R( zr<>;JV)dO&(4vBYoCrB;N;ODU-CO~FOE-!VRX{1L-MU4Z{QBD*9BhfXD|4%6CO2`# zUS)dBb`>#V43>(Y3mESO4DhlGS8f6^;pY_^t9wt;(Cm|>L=dA*<*FvGH92k5W5r(B$+6m@T8a*Q z8#xvDvi9OVNf!2+hqnQSnmOt%=t;Y{6>*s6uB(=P#T%WvT1M_8gnUY}G#ZI3;^IC1 z-Bm#tv$HD%HQCu!c>0A#vKv=iYQiY0#*Zh;CG}-OYfSA!8uB0(|C5sLNPz+R@zQ=V zQ@y6K@$!Y#b&()7>GToKOr1)fqF&65S-zh+Jk9m-$Z>kXq48+jdtavue_9mR-y{SU zDQ~2c-ha$gjNQ3)P?@oY8&0nE`JP?_(vT&ZXFutinFGGn8|p)bAK_Jytj`t}bl*K< zE%7sF+R@5oag&9shL7*9mkp0O;;rhD>%TkfE2{c%3o1?7HikMGbd1 z{dp^_&(~g4A&AOR`o^F^km5!=J+q-YC*96GcVgJ<`~V{OqVQS5~C@+6BT8~N{pt$cfCB)#Kme-aH6zOwIlJOo5%NpB6c@^8Szho9Gh%m?B@jB+3Emq>{ z6+ldXtv6ZFj__s9Abfvuob56^ACdlXEHjB6LYCxr9>e>(H66j4Tphiu+-j5Kn&aJk z!~5=XYDu}?*0XxSyXh0-_2`cDRxc90o~8;eXBW6sq+euKp?>lxeH1(I`_|%FrZ6EWyZ4Rw=}-EuTH4DyjTjpZ^lT_f=kU1qa}2I{G_R4I z69SuMM4!p>u`0K(1?I6u$y#KdvO|Pb=x~D9b7SU{O841}v}Y5sl7eeR&JN{mX1tot z{ZCx|^d6Evt>d*v2*Pw8vj@!?AaqM-a+Qx54f{V_YJd*(X|f0p6mTR;bR3ej?uwRD#uv#_{FyL=1Est@(X_ob8=8+Mgb*3)saEwSDXzupb@9#5Z=AxNt4}Mk21+#`4+{RKq9^?d^~u}TPeCDO z3x&wqsUfqJrKcT32{Hat8pLTFa%+YX7%Q%R!KxoKabDIG#CbJ}P%B1drsoDDQBdU- zJlEzVTqGuMIV&)54MXea?RZ8ioHAc#%!p&}W8|17u4n`smH+0Or}z!)@&T_d@;`q& zrWNb#Dyo8pEBDi>AfQa6Ue@>(g#5!2MfUjnH=3YmXvlYDU(}CI0`=ql#J`LK%dg zRpPISi5-P1@$`WVY0ZxW#xoP8er<(6YsSiswtycFwpK>O0vd z`M;#`O&H154mp)Jmz$8Qr0c)`OwNKUu#xI63C;1ibm^dBGRqwx6W$WZ#8 ztz|wJpg*k27Nh&=H`LYG;#5(3^J@>O5sRGm?W=FXftO|5U89nlZEHQ^7~k9Ess>8O zipLNJvqkK4-k;Ho^T4Jj(cUi6S<6aTA~(Ncw%CpT5C80;VwZoAqm0u5NgkA zdrxhmWzgJow6E{WrMSgy!vsZKs1&Q;&7%IPllRRp@9CK9`N(}`Hw6+5Tyr_W9-C)M ztGjpE+s`6P6m&j%!`lt73Tu-tf|1Rpq! zUHcaOW)zd1gsi7`M`Q(11QBtE^~M@6RdWmZ7ZwC_wm>bJ)Vbg6g&kgJ_-ZQo!XhQy z%VV@db=U|Q%1KzFZO8It-#{_P9FAvb0uf|T}3WxOHN=#Z#)y>3jE z=v$Y1*o8kcG#WoN`ofx<@!ua42wFoIL?~?dwvU$j%Is?T=_2oOhg-5Yz1cQyiW13* zjQWvJUn|oRE*M151pE%q9aD0XCwTxd=d@_fsLqX%5ZqWZCN^bF9lv7A+;}w=MQ_&3 zZ#c1c5WV?==8R8EW4vOp`e-UCoP560WPs+`W66&7z{_1R6^$oqwLv));q2QcI16~D zlq~a01n7@bkyc)finGkrPvqJWh9N(z20MRU(dzH7E)Ld}o``zxDd}?EJUYuLvK1UW z@u30|k7ECd_T3)WFdHn*+)&C;?S@Ag7+136aU1$KGHPkGOy4IIci z&QGc@NqYFAdu@#=amFy)&rRTP^hL1vnl?wFEr-!y4Q9QV$zmlmCN#HfH^2?2JF&N6 zLv|^&K;K`#a+yl8Sk$NB8;Y`KKpivi^K#Yv$y?Cnt~|4+wgmeA?4F9e;@ey`N}pZT zW18BPjI5>+O?<=4DaE{fhF9eo+eoqk*JBw-L8_0)OrGzYep&eLsJAsHf^t?Vd?m?o zTCV`pHC<=PeEUA{b;R7{()hSQT&kep0Og2HCpb;t21|7!cp=Ln*WaaH*1fg4kFtFS z(Xkr4G*z3zqMcLF;QJPFXmUSl_%`4#81Zgd$<8YWkD?-Gz1>w^&uEV9g%Ry0jpA15 ze5iM@eO$`lFCeh4jw~N#Z>bUg{Mhoi$Li~%oXD$9Muw+r^uRl)%UuAJ$bYF`Muc|FT;!(YaH-MVIJA{Egt zRii7$z~SuHvNz}@%PS|VeE|Hcj0Et5ED#(b^Imc8Bfe9k-;yHMWwyNxf`{i<+#86-Lmg zK4%}2cI!ET+@#i{yxtnbv3lVb#&HwrTP|91Ui-Z=bZHr(AJ@cw?bLVZVYgkwj@+(G z`BQu>sGyk^U$SYxIuCN8HEI`gJ0kAw9oIb^y&kBCC)~f&tOR8bDdK@5oaXWnrN-YV}o#1gbJ9c zg?JJaY7(Zz-fhvhtNo+kXiaO+P!m~yh)R@|>Le{=2;}a|TSQD?$J#%pu+E`C{<2*z zut)}KJH#Y>shg=QXl(OFLsJa_rbvxU2u*iYgW4z2EyZp5HHJQ4Dl{=jQ<7ncM>WR( zbc52yqdpP-)}OsGo3NLO`8`kU>^|$7y;>Xxy3hJ?&67h3 zL4T$_xJVPv*d&QSwyjW3-IKhJK#FA_-62r_v|H3mG?W&*}wV86a;9#@ZV`$f% zgDhZCh>Fl3*RXw6g&QSUq!{>JIc2HB*hSx#{-Hh_S8jczekYUX(2=T8809uUth_US z#;HCnGAw-Dy)Q~B2u1vtj-#45ck*!oMXYcDYuG_=Gn@NsN-14m5=4ro&aE82>BTQ5 z(ikvjIB?nKI{PXlz01Ob zXut)y!AA#zXMCEgd+Z4TAC<<2>SDw(M(Q*tr)y%!ZMbFlPt1B(ea=XC4aiOpA0|OD zy*p4{9MeZr3>>7d@-wq|22i*4tK6;MZp3?iL1%E4gsoSY+J1AYCoj^A_isaM=2!=x z(ABZkPw=!3Q8<@0#lt9nUg}YMyfgktq+?)&+z^6eKh+YD4uVloPlqwm`~A>&2oXu8 zi{u&=udti5zX&4c%ERHt)iO?;sB_~ulFAB-`4DYw@0UKeeYD6^@_;DD zQTi96C{@TaD|IY{0Ed+3Lv$@x#kFA!#oz%paL4uT$kt)lP#?YQ6^Yx-%*0W7)9LP+ z4cdh@$u|LN!|(duQ)z+<-`}X3xEoE!kV>GzP_~e$`uGwG3>Kd_%y0`x5J)$tu95JK z`I!GIY)YP9Pv(9TyY(UWtg?agaFO;we|eKxmiXoAm?lLBe4TEX%ce0qo$uB;47M{eZ;y+Lm zxMp!MN=cqn)cXNatLN6UOc-?x8y#=nTbznmcUgB39%IJO#1BJlS}QpzkJi!;A5dun zD_3&wqb`Yk4YTvfTYp`EpR0bo4(QAE5dm*)?W0OoMUB=;*%#i?bOXoNUq8ATyb~5= zc*P{Tvxrt^Pk}#^d0P6CO`+nRo*gZO({rrAI7EKd$qLKgZA9yv{ZtbuTs)|7kVEkU zOIFsDt}cdP89Rp-_IZs#!uw77^r7PZ*^N^9d=8&tIl~&~6(giWZQ92&#+DxW(aScW zJz}~;mLA2f3fIgzG|iMO?M9haECn{Ay&;hgib*tN2tjak&%^S+mLP8H^G*1OLZ7L4 znCa|vzq)3cnAc2gBXU4PeQhQFO0dier%VLDaaccGaPRA-cEj0Vi&Y&C4t7hnGqNO^ zv;*sqNOl|k^1W+59X>~eIdZbM<8yLHN8M36j|Ps478T!N1^G{-R0Xhi$7LzeEVLb9 zJAIq6cJML@PSVB?j-sxB4w4a(?&y1D532`xBJJP&s8?d>;3~~lwO0z!L^nX|C+RV- z7+tH2MW@7eS4H)J6f~PFByqc=sOa7^S0{ekMKYq*9G9-GdzG`Ec|&AQ$!+HEz$(vQ z^D%fbUf@PsHY@2vHHYi8D5Ro&IOs8w~&-p}4Y zWC0il&r7!E(>(Vhm#gfKhvEI=2=HKhSYeDr3^`zuK{a)0^>N!BmQ%Iz2%ZSZtRPT! zZ*Wb{BG8>UF7K#w5e+VC;Wi;VhITm<~2z6~xS2%i|@-&YtX!)BBR#n5O!U{~5-t>&qH_vkL*4I*E zh!M}sQmy51W18f8%71VaC0c*PWBLzZ(*T#7{o>qm{4=gZmu?6;(o!SICCP>ATsPL3 zH0Ig&)(~=*NVz)me2up!aEZ6Oo&xo_n_189+=v`f9IGIR6K5-ZW&M;KeSu!~p87^PjpT0Z{p0r9 z07zx+)@gvDH65aj4m+Sar!VG?Z1FG~mx>t>kApmhLN0XRSNEkOMeEwr;9%8gnH!`u%_~jKbpoU7yEa% zQ^}QwIa+PwU;SZ_GB62&_|@sh>h1T&B;mc}31|2Z!G*Q-y*mOhB2MRli|#yh+%$=i zeJT{;u9jLvBtjlBf2pSm_L`Q_^yQCk;;EQpx_4PlC(h2D?*=7r;?GhYU4~MpleVFZ z)P`{*;!$-Rc?%W_jZabS>^Qr*ySB}sA3VT>)&dP?bkF=H0_JTdgfgV7+ymcon*HDo zC?SyHh<2mI>Urd@EHuVr2s^OY2tP@R7Cd8@-NAQaTH5HVA z(lCEvSk{~__#Cyb^5{V1u^BUXQ_|b9ag{qQWj^#266t)hP_v<3G%9{ExBX+kaYqI% zy3n)?v7J28e5JNNpqT%j<0b*bKHBLuw)`qxrJ8}^n--Ql3Gf~0gwc~}d5dn|X@4An+ zB5D5t{Ddgdr%#`X&Hgm4BVP|!j89{cA>o=j&!#arfUI#)B#idF^_-L!+TBw&W756g zJ2eXM4E;tR76blX?2O7;V0=P@*`EPtJYGu$0B1kSRo&#um_~E!v)170DNh4NeCx8T zl>^;bw|j+U7Rb+R=(g&Owl|n#=;0$C=Lfu$BCLh6h6(z*lHi*9EsspLcLB+f-jrluAi;o!6pIbK*u(+8M*LH)?$on@6v3XEjq*Ij9n8;Ym z0ZgYX0u~~#JUW@$LfPlg1fVT7_13>Lh(EL-@U%SIj4utz2lJXykQg2hT_il*U~Rin zV6St1r&La%Hz)NVo>i~@cT4Y~F|@IzD8WcQ>pE!nmhangls5%sG#iaA*qp6IP_rRl zXiTj&@Y=u7e?=zN5Me`c;P-k6X{BSdr7q19D3$Dc+Dvzx?*NoA5{l_*kivsO7U$5z zsjxA8l}mv}X+GH0x&|qh%`!FUR3&c9!+vUx3rme#v};RVeP@+72Hf56Am`90jl7Hc z1@b@0f7dJzwmKB?N_wwYcY#ClDWZ-Cyx&+!#{FyheMb;eK<)v6KRNf+>4WKtmb|}< zGAAwFEbuvSRo}0C$OB*HAQWL#&g-8(Q=OSCTh7QmF*KPNfwObI;9uxBnb`X`t{chH!g(`A03!c%4gSP4QkP;N5 zRQ>ueu0ZCm25hUgv`2IqPTR{xZQHz@iC~ z73o=s^WVW`?|(7HX2^cwm@Wn+x`n*;_=)2+G^NUeJ95yd(>GC%=bk*wylY0Z_$&<* zP+z%BFQS1B_Es~tmbvFvb6*K_?}=Z{rNQ3XcKkseVTMn(v0vyny_&?v>@|40e$%vF z)U#_LfP81^<<-Ch85A^5LCHvsK)c*H=+3X5OD55(2Np+R!^Qp-ZLm*2JX4aG7Ef%A z0!LT#Q}*;Qam#`>}_`Am9k5co8AgV8}WP==p?^m9e)Ic%CFWcwc97B z`-t$2qtt43db!b3TN3+{FbAVntcjKy)S;L;V0^7=P=A-TDH5=mkiR@bfmVB##x>mE z&Tunh0iJ3T8gWy4`jN5j*T?X#9h$-0eljX-+d!?y$_Xc*!8csg`WIm_^KmZIo4NNS z72t6`vWZT0N0RWc)1W{dPHJ$!rN~iXHC~0?_=yItD&SuNh!9k8_B9>vp*+-3IS{Cg z01Qw6bXR==PQ0l?sjSGF)08F5`af+Horx$w(`1t#Z!^5$&M200RG1M+=bw5}%jQE< z;!N^nu_U3#i#%rBo6eby(-|5)9`5%)BG;<6>~5^Azoatl(+d8*YkZT77r(2yaN$;n zFM0f4QFnT^+}bhgRk3t__%Bkd877}4 zPjaSu7l!dI58pLf<@z3Y=_P*0GiYZ)u`?mBZKoCcn$FFmukxqnMW1kb-dKj1n+u^W zpKJD?z9xcxyt%vhe)lyoT-?!@vcF`cax?E!y4wjxSqBOc|#nWIsCzS2^U!9^N)tiukXO zUYdAQYQLN@#8&?uxo{)JY3C7lT-i-jy?S3{^-dv4hDWYyHigq;rGCRdY~YT zp{M1vt^~mRWb|ysnbxSP8}n?Ixm(s2Bdvs#e#Q*_z1t%3#N(MP)H^V~hCy zf08}V%m3KxF487kK4eH6t|LgiRm~J~{2ro6q%Ew>;6qCwU=v4Lje(H5hP3+X$0f_pmiD4>mHFVeG#J zyhBGJMqFI!UeyUd*2*p-U6S5pb)Sh6nnhf)?doBkHSFjS5dQYS=0;Y)F2NDNEbNsp z;(Mag>QVkLXK#g(HY!Mtd6x8t`K8Bo>i8XB&V1a_d7NH@Lq^j0DzS)`Pv)V@wH(*L z$w-hWJEhXMk1jRAJ5q}Ap@TuULVQ!uas&fsmS#8tckwN4B<_ha?f`+=C4Pt`i zH-^hg{2$Jih!SyKiU{(-CnslSHub0P0`BX4n=Y7xD2+C+WViPxWjbX)#G383-^zy+=s% zkfoI~BIced%`!RTaEgW)1|fbYr*0+;Cuo9)!xQPQ_+={m1M+%j&cIyIJzL}vQR?RHU@%XpD+Ts2q z1_^t+t)EnQQrw02%e?EWKCGo`baRhe=^_G&2y^kpdRzI2y0g(hH+Pko9nw`GIm;e` zV~S-5P)(@s5-yc`51gz1^yPbs*NM9BS{$ICT=CQ)Tb5)3x{?Y%F=Qr(J4iD5EutiAQ7*5@f6~ykWZPzXk8A8Js=1#-`N?4XkayA*KpJTNS>AMQk14mNCdY z&XqL70U!-L)npt>BZ!!j(pe<=znTq*6+8;0gYmz8SuA!#p3cko`K|H#-j$*~()16t z_FXzE*^Y@NFT~<=D)n!5f&@77X2mZ~>Y6QWw(kY~RGKltlpg9KWlkx76Pi|%0_?K3 z;@96Uu~{2wm3d#`^;K>6KzCP_nf z&!t&iy*ha7fZY3&{{W}e9|+n5O{5RfeKiaMDV3&kowL2rHc7B2c9XU4*_qF~Z0@K0 zH*hH@J1i6r-Uy|kM%X;$*VY&WC;D&)5?N0ue2T%sE77ggV*3PUt7mwq2#lYECX~N$ z8BUxO&8sm@?a;WW-O&#=igY4wbocFl|6$t=HpSxCO14y-EPx)Pe+@mpy08DV!lx|8 zp!8ECJ4(|ZrP69HSk<5WHY$Yw@MznEwF9LAQ_&0V0I=h zFTN<-5cL3(C#Jq*j-;n&z$|ZnWOG=qeiMX1CT^*b8`;N4{P&)EqCLo&b?vT_Cc*>n zqlph~U&vegvBsoqtU^*;hK3l|iQxk`b$aLk3OO@W?(2z-%I(C74ra|yl4wc}vpYnp zH&!SjpC_i$8v%-tdE)=GNL=YjcvGxvIdgEX4}a;t=F}(eI_8_vJS&`r?wu)H|Mm)C#l&F;8FJ%X zO^}?7^MQK_=jz)}IfW-GoSE(PMvvZZ5C%l=>g0z5dn+BosKOZJq&j(l5u0amA$L{f zVfC#dPCv8x_;8HUw>09AXBol_*EgWT<7_b2Iu*B|&Ry;bg;2!5w^ci!6*^-&9p(}9 zBMd3p4@=LtW6&AZDz?1oxl`%)s5;JRfmrGkkM+V=geCafBHgQPz8Ahpb8U;G9uY4m zvZkl+hfG79?F&squPFN$Gf4)4GksoiTTFhRo6mHJ)@klMFC*UVo#ZohF`3vns3}Oy-3d}+@`Pivc1{G%OaNqB zVpmD=oh8kxqb+MtO~UA3`&!HqSnUB%$yxxL2F%sKU2<$y49?61IvIJZll})76my~j zgVNWO?bh-`jK0Prx3;CwXHT*ak;TC9>Kkv75+T)wrx{QF8HR>mMnzpzpjWemwNVC% zL)T7z@oZ($bUk50=r=B|>j#N$fqlVyvBut?ayEV|hb8cUM)ke^Vb7sg3>_xHN^P zQH9aI6$bj$D63jJT*mIvE~zl4YvZi#Zfks7iP|yF<7g%Q2!Ua@gpF1-s;=!H zI+#T$@*DyC^xXoh0yvw+s2-74qy9D7x5f%9cEL*9#7r&`qPgw}mqt6Z^Aroju51qk zcI%N4!`^~O?Tp_xDJ1*rf|T41XDg`>l-#%w`45egm1A{+MdaUpwtMNZQ*&W(pexYk z%Q*_tZVi2yy9rxp(^54>5Sd&M7W$G7e8-ho2-8&Lq1X*Z7J{g8C7!9Zwh0I@{~Tm@ zhXkTaej*9K_Gc(0Xbhv5VOR5~TKP6_WSGl0mNO}?NoleSqA+3_BPNzg6Sosj)_W{10RTI{avwbnuEt8KpZkiF#U-Auq`gx#}lRlhnr|C?B!iT-CBE+-D^ z&SL!8{~;cG!+k4d6`+AiqfxP6J5873X5yzt#d|P)%z(?at_Gq(ksH?o9l$5bNibO? z1BTETVUTREs<gi-NU!B zC8>Z;IFkn4hj+HJ+KZJTq>{X?ENCN!pt+Xc8&yR>r(5l;-qu#mx8H{=Q{$L1SN0#^ zd`(U2jR{+Nm|`bl0o;{|?L{lsrPH|40eSCFSWZd?HYgMi#47EqAeT^@aF^GFr|;?= zb7|F>asPOB2#GZDYxQ{Y=+zXnmcRfZL83V|1YHQ)>jx%i0IkYRKCO2`RjF2tHw~r&XT8uLtS%uF#EwjyAk<3`Wq0(4= z>2Mj}dUL1z!c3MHIRfDS)>`YbyLM4P|A=wHXBkalOn^zD;GCS8ic*Wf}Nv~ z4X@;)vTB8!v4rVM^Co0jY$a6Ou;3wz(|^!Sz5*u~t3pKl*EU-l$cTAb;_&fpjcsRv z)>8OryYERsdU$vU{)pwBpJd?2@3pY~u4iC-@&rB;_Mvocj;Z^nV?eKO}n5yln z=Fj#(@nrgfpR4|@B*`(NAB{s@CBBR1Ld#8j>-^woj#=T{&if8My^Y^omONXO>VYux zfmNf!A0Icu(F$GW%%lqiMSVsEPsN;mUNLqyrLD`U4woN%#Os|-UAh}#?E3Rg#v)TV z!bCCT(1^Jb_h-5sMC6$Ex;p2mnQV*xyFZd%6P3M@Cpjv~bE%wXuvbj=Uf#R0^AGTj zwek+O=iwW#fj?pi9%d0`_8TmQtnUfZ1~=Ovh{T%|wm)ARLqW8 z^OsZkZHQFKDRLs?QrYqyCN@lw7~B>|e&N+2FX{rYJ7tMc$37KU%-&fpH0vs%_8J4? zv21qRp&OoU3#f2-v(I)}P^rr6bN8CK zAMw`fB}-I_Gc#%4nx^UZu_&g<7X8X+vVu6FxV*!eh!N{XiC)GUwiOo!Gt#3V19xVr zdX>)tk$@c-B|c-6udYrdORjeS^-N%cQ6V#Kf?vC(1apC6>+*UrQ6_)e^boh&KRdB2 zi28Ne!TEcn4Ue9Mw^>Itg#Q3vlyKC<ii6yE-I?2EpB7OP# zJk=Nwg@fZd5qYfU~ZLRjUKxE(IYC$GGM0$6Rs=S{`CU{HqLKDI?*Q)i9d97>i{5bKvnErjP@?Z^>Pc6|D*?$of+z@<9LZ%+#iac8M1$WmHL zo=3$M8HZHAVwmOr7v}n(tIr!o7uU1~KdKPnNfXStBwH|H4{_I5Z0v|-q(!9IrGgrQ zAXxvo@h6PbSw4!hUHyLo>@z|BOgHm~=UzH`$<7u2lkF%#T?Nx$o${lSVq+fq*phNw z8^1P+e$duS#M^;X>nqkdE-4*ZFncXr3ZdfRE&JU+Kdp$aZC%Q3{_}fZ0UF(g`Y(S< z&W(~NzpG%cr+C`8OK+x!jfn+N^hJ6p2{3PCDo@a+tnj=GP{KOWy?cV=Sc;l0$^mQC zd6^i{I-b!G0Lv5%6kW(fMJ$SkP2a;Y=xHn-NfL`Y`2mIaSm^R>lqI9s<f2pxpM`xbBkEJH>vC&1sMt5D3T#EGw;v{E@yt3`^D*5ML$=E({ zA3EkoBKR^e!|a`VXr(B^LSbHG>d14JIxCzFY*g)ekMKu=xjwjRrdo#71h1lSPrqVJ zYSz{9bZgsDuZV%{NITv2+w<|&h!tcxkh$692XDmsMq=Yglz%|AiEOt83 zlFj?i*5^G5`Acr_#n!9v*OoJ;zUC~`7U~H%7F&00;EmzLA6~x(eCxy`CmveV4+s=#Ua)Bd&Igzvpr?5ybs3 zf4~d$oe@)!7Ck;tuD;B^h}<``yTMbXdz*FO`@TIl?0?duB5Rw&)g7FkJF;@|tuOm^~|K705-cC!B7{yiW*B>3uN_B^yvGB?Z%w$2e4dm1DO3J*9j zXtm`jYq*Nz{NyK^k`8QF=X|zU26fN3M(}2?dkJ7vqsL)*Ls%$P|K>MaXcNV{<_*t!gXT6gpgQ#RyeOc(voMR$^Dw=L~p8gscV3D z3fpV3d#|t>MZ1(b2S1JKP-=Ai@$1Ybn#*QL#zm258{<2Eipu4SeY9)0KS;XnD&Bqd zGR4VM2QMBp>3ndO(pq3*4Z(joC48G*WHlI~FnrUM^;CR{Aqur#b0Dq3tw=T2L3$mI zI5hD+n=#E$P3mUxUEue8$FTzs9R6Zs-uI&`Prq5#I7dABO(-^#Ui*Fatup5AUV57V zTU+*mmO(oiWB|>j2`#}f!SZ-om2fCu53w&eKaok-?lD{o?Z2mluGIWiE!l>&QVhKm&EG^cZk}{>zHdm=H%7SIB!k5S;VQH;VcYfKRY^j_Br>M|t`dz7fNKW27Oxdn(cKz!RrN_KDvas-p2WX#yRts9Y zHQgJB7vx*pnhUZOV3%)%^WWl}pOZFif`X-87`r_(Nd#}KM8KDEG4%l)8;3zrN#iq- zJ38^b-=0F4J8CIgCsX=mI8}I@H`E1>^MiRHPIR%~7}v={p__0uh8d<@N#~SiV>(MA z5LYK0wA_OtXKMSecggwycRcHS(lZ@P4CR^_hgEu$Cu z9s0>>pZKd9$NQ;V%!H2@cN#ACf`U?k@hM_Xf^`wL7m53^dF)3*Meh{}UZ*jv7J7aT zIK0-|3H5bc8@ZHEBxsfFV(s3GKHZp$46qEa|ATD#)he_;!sy!J)du!9c+ObTsVmLZ z%0EAs`G^brT{80fLC614;3RKL?+`8c8L|)vwDvOj4{&c*D$F~i7B09PgCdKB{|`u6 z&v!yW+SqhO7@srib*RXHVl8Sx;V*QLE`fd<&!ZeQLLH9X6d>kVh$kmFKz_5ef>qDl zs7NU>wnwg}6JW6Qfp{^9OPU}d7dIaccu8?@8yNB~Y(3&YopHJGX2yhOf{uT9i^R)a zbFr8GU1v_AGI(GSsP;;QnThQ`3vtk=$$QYvv3^iEIRwDR`~_)}=1$wOAfIzjk(DMX zT9Rc?;gFT7vB-*g1lvAaWX9oiHTWL4mwG)A>0eKeC<=)X`r$d?4+VaI@Bh*e=w^Xw z52g4e+=Y!l8w7F*<{3wO>@|rLdq1z=+Tq>dQrylnoj_=4i0V=fzCU-$B$_j1G&snx ztiI`l)-MuzI>o9=s3*W{_}5w7MB|UidGhldfx5Tvge;p{^yu;SWg>Tz^c$%XM9}}- zGBk8X>ut#s4`^I-Z1D}()%ws4sk)Xh*YS^Uh9~qbM7R1zt>Y+^)A}w0T*Q|I+fcsj z;56r0`GwT%)4QxCQiZL(3qFM;(`Of(cKc?`xDy;q@w{6IO#K5UJp679W{2glp0dGye zU<4L8-k3_5uG|HE%P@{gAVy^`4jt;dJ~2x9m-27Bc~h~mAiN2OAZ(N2%urA)^xV*{ zHRj?iK#MUPvv#|;b@=zGr+@gLO$fx2!QNn0T@Bf0w*GX7rbAf>1Rv*VMowcU{JI~g z@AB)!$Tb*>qoBFd|sh= zbm$dBkGH2Wa$iQ!_f0Of7^q`CUswpYDskRH(x;iw7)fq~{*#Sw7sz@1cPqB}7boSZ zbkbbA2r%tW8!F8vW(waSY@-kY90{YcjWiYuHdyUsYFv`g=e1Wxg^c;-btA#Rqx(wym(OhdTaaQ*cL$qHR7Pdr$K6mKYvnF{|{CdVoD;Tgy!W zKldfow6tUxb~kC7lan;+66ZV7E$5L9JTkE)I>j z$PL0jGtx6699ix%o4y(Wj4HSBoW;1XI8xWrRKp!#igaJ&3CqQG<$#z#>OU+*vYcvq zLP*IM{bL?yGYYmrSuYJ>*~_>UikXq$g*b{#DRLG{ak|dP|N?$3vAo*;d^ziZ0QdN;Y!$KAY;NrMdFRy8>n$@>RY(~o}gTBnI za4t<#*82aOUI$bM`b@NTDI#3zGG6ME2zC`Z9)tfGy_oc`?1kagBfi%C-ut(b*3blm zmIf4juECnb}Fav=5wy(=&p+kNzaR8N_DdK{+z6lPmm6T_SHJ7 zqBm?N$SciqrGG)ly{pNuV5MtW7+}>NezumwDDmZ+KhyWUaY!DI!Fy9go)F>WnM-st z8Z^)(w875M9;dyotUu_oYe8SrkDrg?NnLH9TNR04H>UY;!T<(ycSWN~aG4=k86pm4 zO7E3Mi!bBuK_TS9SGTpuhHR6rNbr@IBDWQ?)-GJ5rcF$8r3#*<@cg@yWde(^|7sj3 ze|M>vpghV`BdZ|Q!0CKX)3F&%(-Ci@$Ri|L1e+zUgTF(4;3e+~YtxJZI~)ID$FEjP zJ|~Mg`#xld!L~k5j05q$(Sx{IYflN_hx@ueiapj02R1D=hW8ahh(6l#{&hqe0)#>X zC%3gCXj&_muS}@s`xsowZ+u84>g+VJ=!&@EYqP83%NF)S!D6t2^$UFw1naMF9kcDX zHNnz5=B)x*T?QOviN|+mM*I(64){c$*roQ;BN!zzc;XgLH>ys33%Kmu{V;#Cuu$|4 ze{IdHxh0v!K~Lb6Jl@FxSwELxJd7y?XklS-G7<4mi|8{v7v5D_c$<-2iRQRH(Mlcn zUl>MsDvqM;l$&C`duDgoA=vhR=_Kl)vS33XE=sorQ~4`7IwO zA0?N#+%(#az3VtuRLsaeUwDxUx{HzHmUrlzHY9jwC^evkEgdXh>$-W`Nneb?#GezI z#M6DiQ79p0hHY1+jzR5mB&0pqxQj5Wc4xV&-NmWcYsaH7oMZq6SpBUjm2bERimLwg z&yvpgfK%?Xg(5>-NTho{dt*@l!o~#RX0^qq>ekRVJdaf|r__wMJ1ZnpF6l^ZkH;Ug zUju!Qe&TO;mzL%D+;C!f`cX=X1un$%w}K}?e-GLwn+IrANVu3g_J|*V3Cr>tZLdRw z$#rD3951wqtA&*|+_hkHfd>GmDKtM%PR&Duu1k270Z*Q?&J*o+;A}}Z@JBgOq91n_ zA)!J3P`jhY-|nKY{5=}g;V)acSY9JOffUL9*IRrI*WtUidtdJbM}zcCccN>yw#Mnr z*(MGGLa{{l6I>)G!WSURKRs+yF>p(y34{Ng>6Rw1C)c5U{VBJF5#$Xs{bYvM6RZ4@ zjYV`IbglQevC{d4jBg>}VF9K$a1EWjKUI8@cv|X60ycD~a}j*RAoxpw)$yb|g~<-p z2(aw|X9#{QR`9KS`I?`;vF1;+F{URIz}He?kQPrX`n5X_>#eNTKU1s0*!U;44+%$n z(rYebBE{>C#^IVRX3g9Q z1y{=(q{+9T9+|Vg`+!VLDf8+?VcHmXBZkk+Qm#rLJVD^-Me9}F0VR!n~j(_Q|`ypRZ@CmyX zlN#62D9M3eo&XOgAgyeF?CQiY#fecj};>E@P8@pv$}ewrXDP?~&!2;BEv& zm9GJR!;q|!EFua0ueak-Y6v{xl?4_G0U0i?BtfRjN&$OVYV@fBlAX^gU3AOO9|XomF3~syASpt$I{K4;Iy2U#F^8;tU|uIgB+xg%VlHHk`#P9`Fq>dEgG zK3l+gt;@io@*qerAwHO{`~Wg)1DVZPjmFoF)}6 zIp;e5j${!oa(psCSW)d(z1jT{`*8dlE__H4^tzgeC?oacdV_Nt^obwkGu-tfYk;U5 zEbwj`i*yaA{WMOnGC0^G8Ef-O81@0`qpxVKk2X7GB99FAWg}I#6 z*x7t#=m=T~qa{v^kAbE}YhnIyE=D79k)Lio3#Td{NWd*c+)#K|5~efybYds2eV z!?vOyl;h!CT<+@wD8vt!YCQ{)bp_6}pYVrE($fJqI=L@3!UbcZ`+ z5Zx)V#6pCROT%h_!z+yqUuYUF17=Nvo|pAIzy^@DQe^WeL|VTx)Uth)Qkg)u6nku( z8Df2u@6m(!vlY<0I%Dk)(&pM}GiQ|!t?IGqU~D)w?3LLGgB^q&i|a{lY5HE$t`b*s z`j=hIlZd9V_Pep=ro2ZeDO@S?pkCo~VYdP+X|0K0ye7ija%?fd08vu1cd!JA0tjnaOfn(t|$zdoXHpzWNnq zX<%-X>esl`LjK*qXru5teRpxj#mLgB376**rlblismnKBDE%$M%-&Bje`t>374hy^ z3!YlYkNjX}7kQ0ESOi^X^QcBK&Z8FB8up3FYwGDo$n<~-LgQ4vL7={zH_l9Tpq(>*^Bk`cwpBXx$bqr$!;+@yq}?k77(LLnV>& zd#VgjQACd^T2kQTC-1kM&wLnGUUEEArHBlKR6;n7_tngW80ZSnHE<;}8L70p@GYUz zzDbHmPNV40kCb_KJVZjg`9Cb-0QCPIQU8Cs8~=Mx$ksiBG)0pyRZ&rvmp4bzvHKgB zVLV0RqTtZut3Js=uz=Nztvye#CV)&ee0uUR`ZKY=W030 zv%RTnTxRF_J)ikx$_d3EBCW5MJ*oy>?TxWhDGR1uy->utCsN~0^=-6bk)&&RpI?j0 zaMy_G(Zm|)&6m1XrWH+}sey4mH~LlI3tpJ>bVhVM9Qcj2c?@}Q1h0T&M#Ym;h;M76 zyk^oOLk4(_%qTx~CzkVzGB_o33(9ltUxAn|5N82TC#G|Y7Y5#`F zdd!T!QB}o9N_4d+j>qZol_k@i)5|{UBQc$lbi(ch>*}thP-0v`DTFB-8ancG3f+iL zF<)W{!^LJ=tBeMCLqxyYx}%Yc!P)39@M>9ZPRc<6`T=%4Sv=QGW(D6zJCb8D#@2b( zTK1o?2VB0I=vF#?5`9|mz0iGiihmYacFC0RIDk3uz?%WcIT|c{TNijLQ(>y`r>ZO3 zrJF0xhgnQ^!9~Srs0^J)VG#|dx`STCyxt>sjCF} zzEsn@1Rr3St0mZA^k7Mfp^m?BT`)WOM$uVOgT-C_k_wxS|8)Y7b4p2#YUd1~>C%{M zZ14t{U2FW+jbGz_Y(}TPSb8FP!uvEcc~_sC$43M0imEfcPBe|<7ev61ZBPbE8JM9b zuN;aD(K;H4;4#tcyPsN~yiwW8)i|)JQ#iNMLP=ni9Ftu~JWd)m)FodA$WL2RO6Q^{(SFSTB=B(q%Nsc=M5VN}SAGfBSipB%EhOgBl&n=Ipaffsg2HH zyH6iF_d$ag@bC96C8R^ogdZT0Zl8CDKp9CMK<=fPlbjs`v+Cy~Dd~6NyesD_qGg+P zoM|i~R0g6q13w3x2HO(@5n_C7wDN+F2E@?$SbN`+!%!l~%KPIPRaHEks)wX>Dg_E#--$;%0 z9CkG;Qn-9Mof#SF8AQhtu9)f!7MRWp+x7(`HNA}7WkE&I4A^aKbQl~TyONI}66noZBHw-%8 zkw6QBf?}p1DS}_tvaO=Y)zKiZ{(G@tmc-s=(J9_mX&8Enq!nB?G*~SrS0f68afnY} zH*;#zB*S6ZGuXdXggRDE$6k{a`uQ{BRz~oTmcj#Ia-zEwe7mjJBrV(0 z?q7Vf=sO~`-j%$GB4K`frsuL;te3w-pDrY)hK7Q2r9A5pP2@^zV?23}M0Ut3(n8-&j5B1gob|=#of||cJml&1lzh}~#tO5GnqIZbBNg(V z=j?xSlKNOwY4Y54i{XiRaRnMEe7?R?PKTVV$KjE)eXf0_b~TDPbat{T_zi{I34%yB zPa#GMABZmTwtOR{;uVN z9mmrc(%R{g7-Eqn1c#`sfZKGmKsN01)ZquW#}O|#s#uXP6~$ZFS|u28-kYF~=ffmN zq>pQE!fud zU~PNX%~t660)Lhd2b@o&8?Ync>2E&$m2iEG$(lwxe~Zyof_1Uvnr=3ml>3&1JY=vq z3rkgeQ6wYEhrxB1Ak?4c$E7O`yr-a#ocmWB!$M2cz(!*mHnVTRLM1u+r~d$n#?$p6 z6b;F8@AuxBz7V-T2JY@U*oU7yMj;EvN>g2+h_MqrS2m7cx;IqeHi#+34iX8DiK&ER z5Mt?}_&j@rCROgMj<&EkpBG0^pTBQY8|?pT?>fM$NVaref`BB4BpC!Gt8f+MB1!T^ z1<4>N5-!)$q@qX^K{ApCkenonAmCQxFpoDo^TzSb_jdQ&ss8@1 zI;T$6IaOWNUDctwys6YuyQG4ojt9*|*g|Rse(pc@xyGC1W0ZF_pfk`gki3 zXzF%k@mVX^Cg;K+qUmYvo~uy6!-=GB+&H6i{?(r3&6X$#S{W)XCJaAh4P}lEYsp-V z6IClCRa`$Uj<3semnzslON}uE@j>^rvnun@YKn1=ay5PP@T)}E|sd<@BXP}-#-a(-v=kzHrdKKKVw*;^Y6M`K6Mr>@0(uFE;|x7 z?AzyWc432(JMAV@!mQp_Dqa=-Gxa#14lqU)opri;{8X*r86OTta7TA*b~2FkQ<{~o zwsj?=twY&uiIOP1dlAb%w5_YTYsy0OF(kR&e($`QH4IAO90{wdsdFP-?qu@}rlX{$bpl6<<3>D; zQcFU&hsDVx!)*^2DDa2WBde6-Z7GAqE3_{s>b^eKd0H4%RxJOzhVyjZ$n*kV!SltI z2brh)jwdNTVysvs?~W8rn>(YwxPCuGpw?A<#!A;diS03A3!{m^R>kVJRhtvJ4`nic zv`e^~xgLjGl=bz4<5lR9Gfz2>KGk!J==uUZ`|*_7+iu_Nqn#1aC;f0tk@8CiG;8u% zS2sHwdF9i%yw$l>k;2_vajvtUx@aLq-6VTIdBINPdh574sf^^24+9=j5=Ezo9?>7m zjE&8ukcn&l0yTh1-`1u+;Vn%Qeee{A?0WZ=M>k0;@rEjCNwag6#h>W)P}H?~uiy-u zja$CdKL5=7hV!Jcbfw2+kl?CBSz7E5)K$$;^#bi!VExK$G`)HiSZ3);k-rNPbGcEx zWF=a8*w?<-i_Pc9{3}h+=8^}mLBUp2f?_(OixBUCqQTLyOhz(gOKC29+8+W2melG@ zpH|(|q2-t^5*(vc&ywyA1)1G_oR8y}LgF_9og-Z635BwHBdxm_~LDR>y0~#m+bQ;j+KtGMQbC%TLefXhWG8++r{B!sEeZXSw{$K?VTsZT(&GJ&|(_-{Fn73S$W>KKhA5G7vSdG=xobF zW%naK+d}CX8=I>$7B0udEvweW4v{l=33EGj&iW@TigufX9G2)rA90vJpAnWz1lIRd z`)?1z_ATkWe|cv(jA)qiI~YShU8HiTitO=%rVm~26%R!ebq;Sq+QR)X^?|j)GaB9( zo;lNtjd?ZX%)XJBSklsSIVr6`YmMBzDd#%$D7(@6h5oozS(}*j$7TLtbX4n*e>vVw zzOM8uLQZ;7Wn~MFL?iw04!@D{P#inJ63^0}R@fL&OxqQcdwLm=hCzOWc83qq1gn{xozp4N?K8uCZ4U2)iPMv{6S-g;D?~IWQ3D0 z%A&W5Zv>lbi+)z2wj`p{IHX9$XnpyyL#I1^cSn_Vsp@w0$JXWmmGC=I-rJss0&#RV z#+qfxABK&wtkg>MYeduNs;Pze#l-oqt!0l(^IIw;SjCZd6pQS%B~uku>~N>jY7vwQ zO+-Jt+Sui8-?qNYt;P~635VO>K9A7&yLE8fVHIaE?+{YS}yUc&jo#fhz#K; zy9H{o;>;OYoUYtWA!KsrOC4S%Tg8w?<*D{;;Y7wu#53|b#1AfQY9DqVjx~CHYl@g{ zGI)S&tsskz($vpp{+u_1?tS(|&f;rA=7xo#Eha0Xq}eK9H3F03AmM|;3tr=5UG_d4 z)YBJg1>_h*S#lgO;!&*q5#=dRsj`+Id zFe9;2N+nfX><%m0$<;J{{ke^c0#}rY$97PeoQ|3oLW$_Y7Ev$Wu(yQhrQIl`_e|A3 za!>M-lvIzPVnZ6`M3CU~;Ao377V|gFWEoWllwxsI@tRdj5Hzbd~ofR9~Ix; z81!J$g(j3iZrgGqZsrLz9L`t1K&f&}HGKSji9zn`ne>ku4Fsu+%&)`8#l5N+?90gtVedMQmT6p;t zBrgziFmWBJ!}2;uU!T0nmYkKcJFCS-QLy8!b4D5UKxlxVYG9Sr?7S9)Tdd&m<7m=4 z0tb>`C|X%}W7ROlmOn0NxsHpTE^EZZTh0^srY-1n=ssW!Me8bQ)1L(&b^7gn)cI$8 z-Z#Z_C9Pq`ni**+qYEAjj^u}1jgeJqVc41L;AyD>dg)qRG5F`$$CLm8&2n%H!QjjR zUVAc93*DI&y&&2UzFgY7$2d(#de@oMRRRbj51mY~PEKqJaPXsl5q-{1a!`H_r=(pH zS7(zY(CjV^PeYkcBAT3i>ULd8>LcZ@7&KS_k!P|o6xtzp>MX5&(mdS`r{Np{iQxKC zS`K$+?}t>jD17S9_facgBw$dN>J(QSYeMo4@0!hYUo7={IPuB;S{~K|)swRwd1X1* z2{ShBf~oq!pBMFU%C|nZ_s!VYutZ*`>v&x8L%GU`>e1DgQUShAWX_a3w|Pr)3+ogj z*wx78GQl~k-2yx_(ecs?wtZ~(B!Kqd(1SW>Brf%Gkpk_t*Fln-U6YIT2ZgCns5(ve z&!Zt`6)YSl81HwD~*g%hj(o z4610|*9gk8r{0@f@j*@9Zu?k=?2PgDf(7d z4#!<=ee{6BHO|8!|H-@lmlG-f);2rD{lnkZO; zq%QlIHpiY2K$u!gvZIIHKo2f^dChB>mQ)&f^U&f!clz0%ss=18CJF|i8pKz$jXN8Q z`Hf}Rgl)mYr3@E2Ha^!ORZiCv)g%Psfu}mKk8xWFPXsv&yRK)%&W}5pw}q`)#}TyO zu}w0F!ljQB8BO(M;g>Xf5c>QUq~5{{RV#{2_e95?%b1i?97SlC&uT>LG9!J z$|v@rM+EmzJ&5BBP(+Ufxgd6Kh1&~tEXeR5eo|4&YGR^^O4MlywyvqHTH(kGtV#(S z*Btj1B0k-heDsbKqeFlKHvS&?R~|{Ww1|zGf@CU2U#}?{->#Lzo?t{H8b|K4?6C?u zDtW|fo2HNhuHZ(BmiNO^LE|GR^OZq2f?1vFf(&M}=JY!aTa_-WDdhzMtdHK{>n|fX zcDSgbRqSGGpZn*e(3X2Eeu4UMy*^x0opC-qbMPF4S4Z@+9sk(kvY~>JD^+c@j+_5G z@(d0wwUi3-hjEYGQu_vQ+C~`q6Sw#dTo$>+p8ccSjhM;jHrH#4mX58J;Q1Xr+Zk6} zQ1LV^(NiD0ke1YP)V%qDKQG;B+D5Lt5#3{kqLtk2OdGi&8>PoPSrNT<(Jx{-DK|Xj zXs4rZyv&a`zN1Kj7XOq+dsR)x_GC5F49bl4*3#Q}RgJMqxfTY_#0F;;0mZ`5_^Xzg zE?5HMDPEov2$YEAr8^6aA2zhG#!t-Wm9r5U(IXmm8{i+pg45?Y;)+9~=2VV08uthh z*$-Y2_Vw=PeIZAs_Uqx>zfGr-D9E7Yp!1Px>GDDtA+&a$khE_x>R42^f0@wdd$;Ba zxISmgT{56(9w@2|%;J9IprQGAMS5I8S*STcDLx~WzQXK`wnRPk>xoFN?yOmg!)&59 z^BOPe=~jgpX1HqzBx4=QC5o^TMK=w7j+EILGeL`#rETub9OaVFZynev zd^_o#vJy=yN7UVMl3A~^7~HricaGDa#4f_UOQtBCjNr`z3fy07*Rc$=c|(8{%*Z*L zu6MtQq3B)dnPrhPPiCjzh+dFrmZCe}Stec2;T|OV+4woQtdl06UO<{3O%eXL{Aw|R4PLjEXqo)yNB!|qfm16uW|3&In< z+{>gSiUWhv7;~~D8n?Z*{yZQ2YE4jU^&a%m{+E<=YmGO%q;X{$OKz&-%uZG&q)re>uDl1LQ2iYtbg2=lg#RzgG~v0 zFXou^B>z>CFVF5$u6r-af3L6B2G;SWP`SjN2BF2xlYFfq3ZCZX-ho%cS54aFSn1Be zOU8!aQ(eRvTWC?fX>Q728x^ABAV(!Y;TH|G~kUJrSmGX zm!)utMRO-7{0K}X`SK3>+x_J=aH!uAp9q4a_GJu*J?utGCA3-*`@{Q0ehJQ{A`ll? ziSQuk6UFndT!CGW5Q08}e90ggLmO*DtjJgHFX`X_5grYMB>M;J^FM;W8T#^t9Kr`N z2mm;IU|;yx3GVGOIDlQS+w;FtzrBZLsD3-@H@PA}o&?0m{_O7wDG@->01gCQ1bmu3 z=6Co!AfNAXoChJu2q}RHwE=E`9G-tdsSZmO^z8PCIa%~j#Dci} z60AT517a*dj0K3Z*p)f{P5Ie^T>Hb>zDoF{rijXd-XE{g>IuB}489E1eY(Tps*lZzD=mgkYcDLi8oHk%H z+pXE-KOe0VKpFu?Jl~#zde=$>*za@TQX~ry0x$=l2*!Np0qg;s0bBu|0aOFL1egO@ z09XcC1%S4})(7=MZ+qYLLJj*e{yX?RH9(|Eh`_Z>07>x#l;|Od9M=-g<^UlAMBsop z;K@q!9?FC@} z<9=dwKe4=@Slmx6>?h{-6EpjXsr|&neqwAtF}k1l{}4uiLjERL0UrkRPrye&2RR{P zdB7$WfLQW9kF)02ojsE8i_ZqY9^{M95roA54hda40mA5aQ$C$dv^={9p0(0S_LP@0oZAP6sf(4MFfh1%u;V zCk6JfOf~=)@CpDApcw$3TXq7#^U8srX;_vR;H<5!7RKJe!UnsWi~_I}-E1-T z))rVR2N`oitQp2+HzRmHdmd(L+G^Oy8aiTjvxWPUy0M`(M#kO-ya)g&&<7xOb3=QK ztc@`U?%52_G(gvZ1d+!DfZNp#$lvwhxPQl~?Oqw+E34e@71kbHbN`H^0mTC+id_fS z?*SsXB;b6%yNBezdjGtK>%E%kD-Qw501K{xE0zkl-tV5P{#p1BC<;(>utxaU!AAUn z_%G3Wnh-!QJl^kP+3#}pMs>e$9XBXH z+@0V)^R49<2D0#Z0Csz0R9T?Yc-IolZa?@M`^S5FpdUWR{F(BD*Y$q6@Ab9SV}Nc) zFq(r$Y1V(Nbe{wbIIHdH{?_vE0KvU1@S$Iq{LdW^k)PZDo(+5X{wv=eL`uOYi@(V2 P>HePb{}m?uU)KL$=${T1 literal 0 HcmV?d00001 diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index ade4398e5b..0a156acab0 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -45,7 +45,7 @@ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') */ public static function createReader($name = 'Word2007') { - if ($name !== 'ReaderInterface' && $name !== 'Word2007') { + if ($name !== 'ReaderInterface' && !in_array($name, array('Word2007', 'MsDoc'))) { throw new Exception("\"{$name}\" is not a valid reader."); } diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php new file mode 100644 index 0000000000..13fde47941 --- /dev/null +++ b/src/PhpWord/Reader/MsDoc.php @@ -0,0 +1,1419 @@ +phpWord = new PhpWord(); + + $this->loadOLE($filename); + + $this->readFib($this->dataWorkDocument); + $this->readFibContent(); + /*$this->read1Table($this->data1Table); + $this->readData($this->dataData); + $this->readObjectPool($this->dataObjectPool);*/ + + return $this->phpWord; + } + + /** + * Load an OLE Document + * @param string $filename + */ + private function loadOLE($filename) + { + // OLE reader + $ole = new OLERead(); + $ole->read($filename); + + // Get WorkDocument stream + $this->dataWorkDocument = $ole->getStream($ole->wrkdocument); + // Get 1Table stream + $this->data1Table = $ole->getStream($ole->wrk1Table); + // Get Data stream + $this->dataData = $ole->getStream($ole->wrkData); + // Get Data stream + $this->dataObjectPool = $ole->getStream($ole->wrkObjectPool); + // Get Summary Information data + $this->_summaryInformation = $ole->getStream($ole->summaryInformation); + // Get Document Summary Information data + $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); + } + + /** + * + * @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx + * @link https://igor.io/2012/09/24/binary-parsing.html + */ + private function readFib($data) + { + $length = 0; + print_r('============ readFib'.PHP_EOL); + print_r('============ length : '.strlen($data).PHP_EOL); + print_r('======================== FibBase'.PHP_EOL); + //----- FibBase + // wIdent + $wIdent = self::_GetInt2d($data, $length); + $length += 2; + print_r('$wIdent : '.$wIdent.'#'.dechex($wIdent).PHP_EOL); + // nFib + $nFib = self::_GetInt2d($data, $length); + print_r('$nFib : '.$nFib.'#'.dechex($nFib).PHP_EOL); + $length += 2; + // unused + $length += 2; + // lid : Language Identifier + $lid = self::_GetInt2d($data, $length); + $length += 2; + // pnNext + $pnNext = self::_GetInt2d($data, $length); + $length += 2; + + $mem = self::_GetInt2d($data, $length); + $fDot = ($mem >> 15) & 1; + $fGlsy = ($mem >> 14) & 1; + $fComplex = ($mem >> 13) & 1; + $fHasPic = ($mem >> 12) & 1; + $cQuickSaves = ($mem >> 8) & bindec('1111'); + $fEncrypted = ($mem >> 7) & 1; + $fWhichTblStm = ($mem >> 6) & 1; + print_r('$fWhichTblStm : '.$fWhichTblStm.'#'.dechex($fWhichTblStm).PHP_EOL); + $fReadOnlyRecommended = ($mem >> 5) & 1; + $fWriteReservation = ($mem >> 4) & 1; + $fExtChar = ($mem >> 3) & 1; + $fLoadOverride = ($mem >> 2) & 1; + $fFarEast = ($mem >> 1) & 1; + $fObfuscated = ($mem >> 0) & 1; + $length += 2; + // nFibBack + $nFibBack = self::_GetInt2d($data, $length); + $length += 2; + // lKey + $lKey = self::_GetInt4d($data, $length); + $length += 4; + // envr + $envr = self::_GetInt1d($data, $length); + $length += 1; + + $mem = self::_GetInt1d($data, $length); + $fMac = ($mem >> 7) & 1; + $fEmptySpecial = ($mem >> 6) & 1; + $fLoadOverridePage = ($mem >> 5) & 1; + $reserved1 = ($mem >> 4) & 1; + $reserved2 = ($mem >> 3) & 1; + $fSpare0 = ($mem >> 0) & bindec('111'); + $length += 1; + + $reserved3 = self::_GetInt2d($data, $length); + $length += 2; + $reserved4 = self::_GetInt2d($data, $length); + $length += 2; + $reserved5 = self::_GetInt4d($data, $length); + $length += 4; + $reserved6 = self::_GetInt4d($data, $length); + $length += 4; + + //----- csw + print_r('======================== csw'.PHP_EOL); + $csw = self::_GetInt2d($data, $length); + $length += 2; + print_r('$csw : '.$csw.'#'.dechex($csw).PHP_EOL); + + //----- fibRgW + print_r('======================== fibRgW'.PHP_EOL); + $fibRgW_reserved1 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved2 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved3 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved4 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved5 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved6 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved7 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved8 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved9 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved10 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved11 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved12 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_reserved13 = self::_GetInt2d($data, $length); + $length += 2; + $fibRgW_lidFE = self::_GetInt2d($data, $length); + $length += 2; + + //----- cslw + print_r('======================== cslw'.PHP_EOL); + $cslw = self::_GetInt2d($data, $length); + $length += 2; + print_r('$cslw : '.$cslw.'#'.dechex($cslw).PHP_EOL); + + //----- fibRgLw + print_r('======================== fibRgLw'.PHP_EOL); + $fibRgLw_cbMac = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved1 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved2 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpText = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpFtn = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpHdd = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved3 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpAtn = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpEdn = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpTxbx = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_ccpHdrTxbx = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved4 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved5 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved6 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved7 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved8 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved9 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved10 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved11 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved12 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved13 = self::_GetInt4d($data, $length); + $length += 4; + $fibRgLw_reserved14 = self::_GetInt4d($data, $length); + $length += 4; + + //----- cbRgFcLcb + print_r('======================== cbRgFcLcb'.PHP_EOL); + $cbRgFcLcb = self::_GetInt2d($data, $length); + print_r('$cbRgFcLcb : '.$cbRgFcLcb.'#'.dechex($cbRgFcLcb).PHP_EOL); + $length += 2; + //----- fibRgFcLcbBlob + print_r('======================== fibRgFcLcbBlob'.PHP_EOL); + switch ($cbRgFcLcb) { + case 0x005D: + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + break; + case 0x006C: + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); + break; + case 0x0088: + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); + break; + case 0x00A4 : + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2003); + break; + case 0x00B7: + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2003); + $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2007); + break; + } + //print_r($this->arrayFib); + //----- cswNew + print_r('======================== cswNew'.PHP_EOL); + $cswNew = self::_GetInt2d($data, $length); + $length += 2; + print_r('$cswNew : '.$cswNew.'#'.dechex($cswNew).PHP_EOL); + + if($cswNew != 0){ + // fibRgCswNew + print_r('======================== fibRgCswNew'.PHP_EOL); + } + + print_r('======================== length : '.$length.'#'.dechex($length).PHP_EOL); + return $length; + } + + const VERSION_97 = '97'; + const VERSION_2000 = '2000'; + const VERSION_2002 = '2002'; + const VERSION_2003 = '2003'; + const VERSION_2007 = '2007'; + + /** + * @var array + */ + private $arrayFib = array(); + + private function readBlockFibRgFcLcb($data, $length, $version) + { + if($version == self::VERSION_97){ + $this->arrayFib['fcStshfOrig'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbStshfOrig'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcStshf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbStshf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcffndRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcffndRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcffndTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcffndTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfandRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfandRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfandTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfandTxt '] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfSed'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfSed'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcPad'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcPad'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfPhe'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfPhe'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfGlsy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfGlsy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfGlsy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfGlsy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfHdd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfHdd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBteChpx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBteChpx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBtePapx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBtePapx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfSea'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfSea'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfFfn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfFfn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldMom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldMom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldHdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldHdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldAtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldAtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldMcr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldMcr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmk'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmk'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcCmds'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbCmds'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfMcr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfMcr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPrDrvr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPrDrvr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPrEnvPort'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPrEnvPort'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPrEnvLand'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPrEnvLand'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcWss'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbWss'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcDop'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbDop'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfAssoc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfAssoc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcClx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbClx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfPgdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfPgdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAutosaveSource'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAutosaveSource'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcGrpXstAtnOwners'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbGrpXstAtnOwners'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfAtnBkmk'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfAtnBkmk'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused3'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused3'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcSpaMom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcSpaMom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcSpaHdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcSpaHdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfAtnBkf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfAtnBkf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfAtnBkl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfAtnBkl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPms'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPms'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcFormFldSttbs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbFormFldSttbs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfendRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfendRef'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfendTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfendTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused4'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused4'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcDggInfo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbDggInfo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfRMark'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfRMark'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfCaption'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfCaption'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfAutoCaption'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfAutoCaption'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfWkb'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfWkb'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfSpl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfSpl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcftxbxTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcftxbxTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfFldTxbx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfFldTxbx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfHdrtxbxTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfHdrtxbxTxt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcffldHdrTxbx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcffldHdrTxbx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcStwUser'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbStwUser'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbTtmbd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbTtmbd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcCookieData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbCookieData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdMotherOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdMotherOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdMotherOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdMotherOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdFtnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdFtnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdFtnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdFtnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdEdnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdEdnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdEdnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdEdnOldOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfIntlFld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfIntlFld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcRouteSlip'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbRouteSlip'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbSavedBy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbSavedBy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbFnm'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbFnm'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlfLst'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlfLst'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlfLfo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlfLfo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfTxbxBkd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfTxbxBkd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfTxbxHdrBkd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfTxbxHdrBkd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcDocUndoWord9'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbDocUndoWord9'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcRgbUse'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbRgbUse'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUsp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUsp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUskf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUskf'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcupcRgbUse'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcupcRgbUse'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcupcUsp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcupcUsp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbGlsyStyle'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbGlsyStyle'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlgosl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlgosl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcocx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcocx'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBteLvc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBteLvc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['dwLowDateTime'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['dwHighDateTime'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfLvcPre10'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfLvcPre10'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfAsumy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfAsumy'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfGram'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfGram'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbListNames'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbListNames'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfUssr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfUssr'] = self::_GetInt4d($data, $length); + $length += 4; + } + if($version == self::VERSION_2000){ + $this->arrayFib['fcPlcfTch'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfTch'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcRmdThreading'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbRmdThreading'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcMid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbMid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbRgtplc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbRgtplc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcMsoEnvelope'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbMsoEnvelope'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfLad'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfLad'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcRgDofr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbRgDofr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcosl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcosl'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfCookieOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfCookieOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdMotherOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdMotherOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdMotherOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdMotherOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdFtnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdFtnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdFtnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdFtnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdEdnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdEdnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdEdnOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdEdnOld'] = self::_GetInt4d($data, $length); + $length += 4; + } + if($version == self::VERSION_2002){ + $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfPgp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfPgp'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfuim'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfuim'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlfguidUim'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlfguidUim'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAtrdExtra'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAtrdExtra'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlrsid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlrsid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfcookie'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfcookie'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklFactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcFactoidData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbFactoidData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcDocUndo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbDocUndo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklFcc'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfbkmkBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfbkmkBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfbkfBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfbkfBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfbklBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfbklBPRepairs'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPmsNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPmsNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcODSO'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbODSO'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiOldXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiOldXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiNewXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiNewXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiMixedXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiMixedXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcffactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcffactoid'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcOldXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcOldXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcNewXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcNewXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcMixedXP'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcMixedXP'] = self::_GetInt4d($data, $length); + $length += 4; + } + if($version == self::VERSION_2003){ + $this->arrayFib['fcHplxsdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbHplxsdr'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklSdt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcCustomXForm'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbCustomXForm'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklProt'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbProtUser'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbProtUser'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiOldInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiOldInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfpmiNewInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfpmiNewInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcOld'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcOldInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcOldInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcNew'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcflvcNewInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcflvcNewInline'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAfdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAfdMother'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAfdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAfdFtn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPgdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPgdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcBkdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbBkdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAfdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAfdEdn'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcAfd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbAfd'] = self::_GetInt4d($data, $length); + $length += 4; + } + if($version == self::VERSION_2007){ + $this->arrayFib['fcPlcfmthd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfmthd'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklMoveFrom'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklMoveTo'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused3'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused3'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcSttbfBkmkArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbSttbfBkmkArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBkfArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBkfArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcPlcfBklArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbPlcfBklArto'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcArtoData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbArtoData'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused4'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused4'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused5'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused5'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcUnused6'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbUnused6'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcOssTheme'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbOssTheme'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['fcColorSchemeMapping'] = self::_GetInt4d($data, $length); + $length += 4; + $this->arrayFib['lcbColorSchemeMapping'] = self::_GetInt4d($data, $length); + $length += 4; + } + return $length; + } + + private function readFibContent() + { + #$this->readRecordSTSH(); + $this->readRecordPlcfSed(); + } + private function readRecordSTSH() + { + print_r('============ readRecordSTSH'.PHP_EOL); + // Table Stream + // fcStshf (4 bytes): An unsigned integer that specifies an offset in the Table Stream. An STSH that specifies the style sheet for this document begins at this offset. + // lcbStshf (4 bytes): An unsigned integer that specifies the size, in bytes, of the STSH that begins at offset fcStshf in the Table Stream. This MUST be a nonzero value. + /*[fcStshf] => 0 + [lcbStshf] => 1060*/ + + $posMem = $this->arrayFib['fcStshf']; + + // RECORD "STSH" + + // lpstshi (variable): An LPStshi that specifies information about the stylesheet. + // - LPStshi + // - LPStshi : cbStshi + $cbStshi = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + print_r('$cbStshi :'.$cbStshi.PHP_EOL); + + // - LPStshi : stshi + // - LPStshi : stshi : stshif (18o) + // - LPStshi : stshi : stshif : cstd + $cstd = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : cbSTDBaseInFile + $cbSTDBaseInFile = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : fStdStylenamesWritten (1 bit) + // - LPStshi : stshi : stshif : fReserved (15 bits) + $fStdStylenamesWritten = self::_GetInt1d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : stiMaxWhenSaved + $stiMaxWhenSaved = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + print_r('$stiMaxWhenSaved :'.$stiMaxWhenSaved.PHP_EOL); + // - LPStshi : stshi : stshif : istdMaxFixedWhenSaved + $istdMaxFixedWhenSaved = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : nVerBuiltInNamesWhenSaved + $nVerBuiltInNamesWhenSaved = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : ftcAsci + $ftcAsci = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : ftcFE + $ftcFE = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : stshif : ftcOther + $ftcOther = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + + // - LPStshi : stshi : ftcBi (2o) + $ftcBi = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + // - LPStshi : stshi : StshiLsd + // - LPStshi : stshi : StshiLsd : cbLSD + $cbLSD = self::_GetInt2d($this->data1Table, $posMem); + $posMem += 2; + print_r('$cbLSD :'.$cbLSD.PHP_EOL); + + + // - LPStshi : stshi : StshiLsd : mpstiilsd + // - LPStshi : stshi : StshiB + + // rglpstd (variable): An array of LPStd that specifies the style definitions. + } + private function readRecordPlcfSed(){ + // fcPlcfSed (4 bytes): An unsigned integer that specifies an offset in the Table Stream. A PlcfSed begins at this offset and specifies the locations of property lists for each section in the Main Document. If lcbPlcfSed is zero, fcPlcfSed is undefined and MUST be ignored. + // lcbPlcfSed (4 bytes): An unsigned integer that specifies the size, in bytes, of the PlcfSed that begins at offset fcPlcfSed in the Table Stream. + print_r('============ readRecordPlcfSed'.PHP_EOL); + + $posMem = $this->arrayFib['fcPlcfSed']; + // PlcfSed + // PlcfSed : aCP + $aCP = array(); + $aCP[0] = self::_GetInt4d($this->data1Table, $posMem); + $posMem += 4; + $aCP[1] = self::_GetInt4d($this->data1Table, $posMem); + $posMem += 4; + + print_r('$aCP :'.PHP_EOL); + print_r($aCP); + + // PlcfSed : aSed + $numSed = ($this->arrayFib['lcbPlcfSed'] - 4) / 12; + + $aSed = array(); + for($iInc = 1 ; $iInc < $numSed ; ++$iInc){ + // ignored + $posMem += 2; + // A signed integer value that specifies the position in the WordDocument Stream at which a Sepx structure is located. + $aSed[$iInc] = self::_GetInt4d($this->data1Table, $posMem); + $posMem += 4; + // ignored + $posMem += 2; + // ignored + $posMem += 4; + } + + // page 541 pour la lecture des informations sur la section + } + + + private function read1Table($data) + { + /* + offset[0] = offsetClx + 1; + int lcb = stream.getInteger(offset); + + int countPcd = (lcb - 4)/12; + int countCp = (lcb - countPcd*8)/4; + int offsetPlcpcd = offsetClx + 5; + + for(int i=0;i> 30; + start = (start << 2) >> 2; + + offset[0] = offsetPlcpcd + i*4; + int cpPre = stream.getInteger(offset); + int cpNext = stream.getInteger(offset); + int length = cpNext - cpPre -1; + if(fc == 0) + { + length *= 2; + } + else + { + start = start/2; + } + + start += 512; + bytesToString(ogiBytes, content, start, length, fc); + + System.out.println(start +", "+ length); + }*/ + + print_r('============ read1Table'.PHP_EOL); + $clxPosition = $this->arrayFib['fcClx']; + + $text = self::_GetInt1d($data, $clxPosition); + print_r('$text : '.$text.PHP_EOL); + $lcb_piece_table = self::_GetInt4d($data, $clxPosition + 1); + $piece_table = $clxPosition + 5; + $piece_count = ($lcb_piece_table - 4) / 12; + print_r('$piece_count : '.$piece_count.PHP_EOL); + + + $countCp = ($lcb_piece_table - $piece_count*8)/4; + print_r('$countCp : '.$countCp.PHP_EOL); + for($i=0 ; $i < $piece_count ; $i++) { + + $piece_start = self::_GetInt4d($data, $piece_table + ($i * 4)); + $piece_end = self::_GetInt4d($data, $piece_table + (($i + 1) * 4)); + $piece_descriptor = $piece_table + (($piece_count + 1) * 4) + ($i * 8); + $fc = self::_GetInt4d ($data, $piece_descriptor + 2); + $is_ansi = ($fc & 0x40000000) == 0x40000000; + if (!$is_ansi) { + $fc = ($fc & 0xBFFFFFFF); + } else { + $fc = ($fc & 0xBFFFFFFF) >> 1; + } + $piece_size = $piece_end - $piece_start; + print_r('$piece_size : '.$piece_size.PHP_EOL); + if (!$is_ansi) { + $piece_size *= 2; + } + print_r('$piece_size : '.$piece_size.PHP_EOL); + if ($piece_size >= 1) { + $fc+=512; + print_r(chr(self::_GetInt2d($data, $fc + 2))); + print_r(chr(self::_GetInt2d($data, $fc + 4))); + print_r(chr(self::_GetInt2d($data, $fc + 6))); + print_r(chr(self::_GetInt2d($data, $fc + 8))); + print_r(chr(self::_GetInt2d($data, $fc + 10))); + print_r(chr(self::_GetInt2d($data, $fc + 12))); + print_r(chr(self::_GetInt2d($data, $fc + 14))); + print_r(chr(self::_GetInt2d($data, $fc + 16))); + print_r(chr(self::_GetInt2d($data, $fc + 18))); + print_r(chr(self::_GetInt2d($data, $fc + 20))); + print_r(chr(self::_GetInt2d($data, $fc + 22))); + print_r(chr(self::_GetInt2d($data, $fc + 24))); + print_r(chr(self::_GetInt2d($data, $fc + 26))); + print_r(chr(self::_GetInt2d($data, $fc + 28))); + print_r(chr(self::_GetInt2d($data, $fc + 30))); + print_r(chr(self::_GetInt2d($data, $fc + 32))); + print_r(chr(self::_GetInt2d($data, $fc + 34))); + print_r(chr(self::_GetInt2d($data, $fc + 36))); + print_r(chr(self::_GetInt2d($data, $fc + 38))); + print_r(PHP_EOL); + } + + $offsetPcd = $piece_table + $countCp*4 + $i*8; + + $start = self::_GetInt4d($data, $offsetPcd+2); + print_r('$start : '.$start.PHP_EOL); + $fc = $start >> 30; + $start = ($start << 2) >> 2; + print_r('$fc : '.$fc.PHP_EOL); + print_r('$start : '.$start.PHP_EOL); + + $offset = $piece_table + $i*4; + print_r('$offset : '.$offset.PHP_EOL); + $cpPre = self::_GetInt4d($data, $offset); + print_r('$cpPre : '.$cpPre.PHP_EOL); + $cpNext = self::_GetInt4d($data, $offset + 4); + print_r('$cpNext : '.$cpNext.PHP_EOL); + $length = $cpNext - $cpPre -1; + if($fc == 0) { + $length *= 2; + } else { + $start = $start/2; + } + + $start += 512; + print_r($start); + print_r(PHP_EOL); + print_r($length); + print_r(PHP_EOL); + print_r(self::_GetInt2d($data, $start + 2)); + print_r(PHP_EOL); + print_r(chr(self::_GetInt2d($data, $start + 2))); + print_r(PHP_EOL); + print_r(chr(self::_GetInt2d($data, $start + 4))); + print_r(chr(self::_GetInt2d($data, $start + 6))); + print_r(chr(self::_GetInt2d($data, $start + 8))); + print_r(chr(self::_GetInt2d($data, $start + 10))); + print_r(chr(self::_GetInt2d($data, $start + 12))); + print_r(chr(self::_GetInt2d($data, $start + 14))); + print_r(chr(self::_GetInt2d($data, $start + 16))); + print_r(chr(self::_GetInt2d($data, $start + 18))); + print_r(chr(self::_GetInt2d($data, $start + 20))); + print_r(chr(self::_GetInt2d($data, $start + 22))); + print_r(chr(self::_GetInt2d($data, $start + 24))); + print_r(chr(self::_GetInt2d($data, $start + 26))); + print_r(chr(self::_GetInt2d($data, $start + 28))); + print_r(chr(self::_GetInt2d($data, $start + 30))); + print_r(chr(self::_GetInt2d($data, $start + 32))); + print_r(chr(self::_GetInt2d($data, $start + 34))); + print_r(chr(self::_GetInt2d($data, $start + 36))); + print_r(chr(self::_GetInt2d($data, $start + 38))); + } +/* + + $start = self::_GetInt4d($data, 1850); + print_r('$start : '.$start.PHP_EOL); + $end = self::_GetInt4d($data, 1854); + print_r('$end : '.$end.PHP_EOL);*/ + + print_r(PHP_EOL); + print_r(PHP_EOL); + print_r(PHP_EOL); + //print_r($data); + print_r(PHP_EOL); + //print_r(dechex($data)); + print_r(PHP_EOL); + } + + private function readData($data) + { + print_r('============ readData'.PHP_EOL); + $text = self::_GetInt1d($data, 0); + print_r(dechex($text)); + + print_r(PHP_EOL); + print_r(PHP_EOL); + print_r(PHP_EOL); + //print_r($data); + print_r(PHP_EOL); + //print_r(dechex($data)); + print_r(PHP_EOL); + } + + private function readObjectPool($data) + { + print_r('============ readObjectPool'.PHP_EOL); + + print_r(PHP_EOL); + print_r(PHP_EOL); + print_r(PHP_EOL); + //print_r($data); + print_r(PHP_EOL); + //print_r(dechex($data)); + print_r(PHP_EOL); + } + + /** + * Read 8-bit unsigned integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt1d($data, $pos) + { + return ord($data[$pos]); + } + + /** + * Read 16-bit unsigned integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt2d($data, $pos) + { + return ord($data[$pos]) | (ord($data[$pos+1]) << 8); + } + + /** + * Read 32-bit signed integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt4d($data, $pos) + { + // FIX: represent numbers correctly on 64-bit system + // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 + // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems + $_or_24 = ord($data[$pos + 3]); + if ($_or_24 >= 128) { + // negative number + $_ord_24 = -abs((256 - $_or_24) << 24); + } else { + $_ord_24 = ($_or_24 & 127) << 24; + } + return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24; + } +} diff --git a/src/PhpWord/Shared/OLERead.php b/src/PhpWord/Shared/OLERead.php new file mode 100644 index 0000000000..5235d37e7d --- /dev/null +++ b/src/PhpWord/Shared/OLERead.php @@ -0,0 +1,310 @@ +data = file_get_contents($sFileName, FALSE, NULL, 0, 8); + + // Check OLE identifier + if ($this->data != self::IDENTIFIER_OLE) { + throw new Exception('The filename ' . $sFileName . ' is not recognised as an OLE file'); + } + + // Get the file data + $this->data = file_get_contents($sFileName); + + // Total number of sectors used for the SAT + $this->numBigBlockDepotBlocks = self::_GetInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); + + // SecID of the first sector of the directory stream + $this->rootStartBlock = self::_GetInt4d($this->data, self::ROOT_START_BLOCK_POS); + + // SecID of the first sector of the SSAT (or -2 if not extant) + $this->sbdStartBlock = self::_GetInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS); + + // SecID of the first sector of the MSAT (or -2 if no additional sectors are used) + $this->extensionBlock = self::_GetInt4d($this->data, self::EXTENSION_BLOCK_POS); + + // Total number of sectors used by MSAT + $this->numExtensionBlocks = self::_GetInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS); + + $bigBlockDepotBlocks = array(); + $pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS; + + $bbdBlocks = $this->numBigBlockDepotBlocks; + + if ($this->numExtensionBlocks != 0) { + $bbdBlocks = (self::BIG_BLOCK_SIZE - self::BIG_BLOCK_DEPOT_BLOCKS_POS)/4; + } + + for ($i = 0; $i < $bbdBlocks; ++$i) { + $bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); + $pos += 4; + } + + for ($j = 0; $j < $this->numExtensionBlocks; ++$j) { + $pos = ($this->extensionBlock + 1) * self::BIG_BLOCK_SIZE; + $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1); + + for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) { + $bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); + $pos += 4; + } + + $bbdBlocks += $blocksToRead; + if ($bbdBlocks < $this->numBigBlockDepotBlocks) { + $this->extensionBlock = self::_GetInt4d($this->data, $pos); + } + } + + $pos = 0; + $this->bigBlockChain = ''; + $bbs = self::BIG_BLOCK_SIZE / 4; + for ($i = 0; $i < $this->numBigBlockDepotBlocks; ++$i) { + $pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE; + + $this->bigBlockChain .= substr($this->data, $pos, 4*$bbs); + $pos += 4*$bbs; + } + + $pos = 0; + $sbdBlock = $this->sbdStartBlock; + $this->smallBlockChain = ''; + while ($sbdBlock != -2) { + $pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE; + + $this->smallBlockChain .= substr($this->data, $pos, 4*$bbs); + $pos += 4*$bbs; + + $sbdBlock = self::_GetInt4d($this->bigBlockChain, $sbdBlock*4); + } + + // read the directory stream + $block = $this->rootStartBlock; + $this->entry = $this->_readData($block); + + $this->_readPropertySets(); + } + + /** + * Extract binary stream data + * + * @return string + */ + public function getStream($stream) + { + if ($stream === NULL) { + return null; + } + + $streamData = ''; + + if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) { + $rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']); + + $block = $this->props[$stream]['startBlock']; + + while ($block != -2) { + $pos = $block * self::SMALL_BLOCK_SIZE; + $streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); + + $block = self::_GetInt4d($this->smallBlockChain, $block*4); + } + + return $streamData; + } else { + $numBlocks = $this->props[$stream]['size'] / self::BIG_BLOCK_SIZE; + if ($this->props[$stream]['size'] % self::BIG_BLOCK_SIZE != 0) { + ++$numBlocks; + } + + if ($numBlocks == 0) return ''; + + $block = $this->props[$stream]['startBlock']; + + while ($block != -2) { + $pos = ($block + 1) * self::BIG_BLOCK_SIZE; + $streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); + $block = self::_GetInt4d($this->bigBlockChain, $block*4); + } + + return $streamData; + } + } + + /** + * Read a standard stream (by joining sectors using information from SAT) + * + * @param int $bl Sector ID where the stream starts + * @return string Data for standard stream + */ + private function _readData($bl) + { + $block = $bl; + $data = ''; + + while ($block != -2) { + $pos = ($block + 1) * self::BIG_BLOCK_SIZE; + $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); + $block = self::_GetInt4d($this->bigBlockChain, $block*4); + } + return $data; + } + + /** + * Read entries in the directory stream. + */ + private function _readPropertySets() { + $offset = 0; + + // loop through entires, each entry is 128 bytes + $entryLen = strlen($this->entry); + while ($offset < $entryLen) { + // entry data (128 bytes) + $d = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE); + + // size in bytes of name + $nameSize = ord($d[self::SIZE_OF_NAME_POS]) | (ord($d[self::SIZE_OF_NAME_POS+1]) << 8); + + // type of entry + $type = ord($d[self::TYPE_POS]); + + // sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook) + // sectorID of first sector of the short-stream container stream, if this entry is root entry + $startBlock = self::_GetInt4d($d, self::START_BLOCK_POS); + + $size = self::_GetInt4d($d, self::SIZE_POS); + + $name = str_replace("\x00", "", substr($d,0,$nameSize)); + + + $this->props[] = array ( + 'name' => $name, + 'type' => $type, + 'startBlock' => $startBlock, + 'size' => $size); + + // tmp helper to simplify checks + $upName = strtoupper($name); + + // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) + // print_r($upName.PHP_EOL); + if (($upName === 'WORDDOCUMENT')) { + $this->wrkdocument = count($this->props) - 1; + } elseif (($upName === '1TABLE')) { + $this->wrk1Table = count($this->props) - 1; + } elseif (($upName === 'DATA')) { + $this->wrkData = count($this->props) - 1; + } elseif (($upName === 'OBJECTPOOL')) { + $this->wrkObjectPoolelseif = count($this->props) - 1; + } elseif ( $upName === 'ROOT ENTRY' || $upName === 'R') { + $this->rootentry = count($this->props) - 1; + } + + // Summary information + if ($name == chr(5) . 'SummaryInformation') { + $this->summaryInformation = count($this->props) - 1; + } + + // Additional Document Summary information + if ($name == chr(5) . 'DocumentSummaryInformation') { + $this->documentSummaryInformation = count($this->props) - 1; + } + + $offset += self::PROPERTY_STORAGE_BLOCK_SIZE; + } + + } + + /** + * Read 4 bytes of data at specified position + * + * @param string $data + * @param int $pos + * @return int + */ + private static function _GetInt4d($data, $pos) + { + // FIX: represent numbers correctly on 64-bit system + // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 + // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems + $_or_24 = ord($data[$pos + 3]); + if ($_or_24 >= 128) { + // negative number + $_ord_24 = -abs((256 - $_or_24) << 24); + } else { + $_ord_24 = ($_or_24 & 127) << 24; + } + return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24; + } + +} From df8de962a9a48b6e66cb44e6aa539098c37a7c5f Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 21 Jun 2014 09:21:30 +0200 Subject: [PATCH 047/174] #23 : Implement Word97 aka MsDoc Reader --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2ea4fd9d4f..9fbc69f9e5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ composer.lock composer.phar vendor /report +/samples/resources +/samples/results /.settings /.buildpath /.project \ No newline at end of file From 5be8414ef878372adb29c9b3ad1e8746e9a43334 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 21 Jun 2014 03:07:11 +0700 Subject: [PATCH 048/174] Settings: OOXML compatibility --- CHANGELOG.md | 3 +- docs/recipes.rst | 9 ++ docs/src/documentation.md | 8 ++ src/PhpWord/Metadata/Compatibility.php | 62 ++++++++++ src/PhpWord/PhpWord.php | 28 +++-- src/PhpWord/Writer/Word2007/Part/Settings.php | 106 ++++++++---------- tests/PhpWord/Tests/StyleTest.php | 2 + .../Writer/Word2007/Part/SettingsTest.php | 16 +++ 8 files changed, 167 insertions(+), 67 deletions(-) create mode 100644 src/PhpWord/Metadata/Compatibility.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 40805cb8c9..22f22dd937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 - Chart: 3D charts and ability to set width and height - @ivanlanin - FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 -- Security: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin +- Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin +- Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin ### Bugfixes diff --git a/docs/recipes.rst b/docs/recipes.rst index 1b529d7bca..0be6b4e06a 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -87,3 +87,12 @@ Apply 'HeadingN' paragraph style to TextRun or Link. Sample code: // Link $section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2'); + +Remove [Compatibility Mode] text in the MS Word title bar +--------------------------------------------------------- + +Use the ``Metadata\Compatibility\setOoxmlVersion(n)`` method with ``n`` is the version of Office (14 = Office 2010, 15 = Office 2013). + +.. code-block:: php + + $phpWord->getCompatibility()->setOoxmlVersion(15); diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 60121d3305..9c0c865b07 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -1053,6 +1053,14 @@ $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link'); $section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2'); ``` +## Remove [Compatibility Mode] text in the MS Word title bar + +Use the `Metadata\Compatibility\setOoxmlVersion(n)` method with `n` is the version of Office (14 = Office 2010, 15 = Office 2013). + +```php +$phpWord->getCompatibility()->setOoxmlVersion(15); +``` + # Frequently asked questions ## Is this the same with PHPWord that I found in CodePlex? diff --git a/src/PhpWord/Metadata/Compatibility.php b/src/PhpWord/Metadata/Compatibility.php new file mode 100644 index 0000000000..d78b97f1f9 --- /dev/null +++ b/src/PhpWord/Metadata/Compatibility.php @@ -0,0 +1,62 @@ +ooxmlVersion; + } + + /** + * Set OOXML version + * + * @param int $value + * @return self + */ + public function setOoxmlVersion($value) + { + $this->ooxmlVersion = $value; + + return $this; + } +} diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index c62da82bca..be808f01a2 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -81,17 +81,19 @@ class PhpWord */ public function __construct() { + // Collection $collections = array('Titles', 'Footnotes', 'Endnotes', 'Charts'); foreach ($collections as $collection) { $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection; $this->collections[$collection] = new $class(); } - $metadata = 'PhpOffice\\PhpWord\\Metadata\\Protection'; - $this->metadata['Protection'] = new $metadata(); - - $metadata = 'PhpOffice\\PhpWord\\Metadata\\DocInfo'; - $this->metadata['DocInfo'] = new $metadata(); + // Metadata + $metadata = array('DocInfo', 'Protection', 'Compatibility'); + foreach ($metadata as $meta) { + $class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta; + $this->metadata[$meta] = new $class(); + } } /** @@ -147,9 +149,6 @@ public function __call($function, $args) if (in_array($function, $addStyle)) { return forward_static_call_array(array('PhpOffice\\PhpWord\\Style', $function), $args); } - - // All other methods - return null; } /** @@ -173,6 +172,17 @@ public function getProtection() return $this->metadata['Protection']; } + /** + * Get compatibility + * + * @return \PhpOffice\PhpWord\Metadata\Compatibility + * @since 0.12.0 + */ + public function getCompatibility() + { + return $this->metadata['Compatibility']; + } + /** * Get all sections * @@ -331,7 +341,7 @@ public function getDocumentProperties() /** * Set document properties object * - * @param \PhpOffice\PhpWord\Metadata\DocInfo + * @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties * @return self * @deprecated 0.12.0 * @codeCoverageIgnore diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index ac67b25db2..d381d26a51 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -24,6 +24,13 @@ */ class Settings extends AbstractPart { + /** + * Settings value + * + * @var array + */ + private $settings = array(); + /** * Write part * @@ -31,7 +38,7 @@ class Settings extends AbstractPart */ public function write() { - $settings = $this->getSettings(); + $this->getSettings(); $xmlWriter = $this->getXmlWriter(); @@ -45,7 +52,7 @@ public function write() $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - foreach ($settings as $settingKey => $settingValue) { + foreach ($this->settings as $settingKey => $settingValue) { $this->writeSetting($xmlWriter, $settingKey, $settingValue); } @@ -84,63 +91,19 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) /** * Get settings - * - * @return array */ private function getSettings() { // Default settings - $settings = $this->getDefaultSettings(); - - // Protection - $protection = $this->getParentWriter()->getPhpWord()->getProtection(); - if ($protection->getEditing() !== null) { - $settings['w:documentProtection'] = array( - '@attributes' => array( - 'w:enforcement' => 1, - 'w:edit' => $protection->getEditing(), - ) - ); - } - - return $settings; - } - - /** - * Get default settings - * - * @return array - */ - private function getDefaultSettings() - { - return array( + $this->settings = array( 'w:zoom' => array('@attributes' => array('w:percent' => '100')), - 'w:view' => array('@attributes' => array('w:val' => 'print')), - 'w:embedSystemFonts' => '', 'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')), 'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')), - 'w:doNotHyphenateCaps' => '', 'w:characterSpacingControl' => array('@attributes' => array('w:val' => 'doNotCompress')), - 'w:doNotValidateAgainstSchema' => '', - 'w:doNotDemarcateInvalidXml' => '', - 'w:compat' => array( - 'w:useNormalStyleForList' => '', - 'w:doNotUseIndentAsNumberingTabStop' => '', - 'w:useAltKinsokuLineBreakRules' => '', - 'w:allowSpaceOfSameStyleInTable' => '', - 'w:doNotSuppressIndentation' => '', - 'w:doNotAutofitConstrainedTables' => '', - 'w:autofitToFirstFixedWidthCell' => '', - 'w:underlineTabInNumList' => '', - 'w:displayHangulFixedWidth' => '', - // Commented for GH-274 - // 'w:splitPgBreakAndParaMark' => '', - 'w:doNotVertAlignCellWithSp' => '', - 'w:doNotBreakConstrainedForcedTable' => '', - 'w:doNotVertAlignInTxbx' => '', - 'w:useAnsiKerningPairs' => '', - 'w:cachedColBalance' => '', - ), + 'w:themeFontLang' => array('@attributes' => array('w:val' => 'en-US')), + 'w:decimalSymbol' => array('@attributes' => array('w:val' => '.')), + 'w:listSeparator' => array('@attributes' => array('w:val' => ';')), + 'w:compat' => '', 'm:mathPr' => array( 'm:mathFont' => array('@attributes' => array('m:val' => 'Cambria Math')), 'm:brkBin' => array('@attributes' => array('m:val' => 'before')), @@ -154,8 +117,6 @@ private function getDefaultSettings() 'm:intLim' => array('@attributes' => array('m:val' => 'subSup')), 'm:naryLim' => array('@attributes' => array('m:val' => 'undOvr')), ), - 'w:uiCompat97To2003' => '', - 'w:themeFontLang' => array('@attributes' => array('w:val' => 'de-DE')), 'w:clrSchemeMapping' => array( '@attributes' => array( 'w:bg1' => 'light1', @@ -172,10 +133,41 @@ private function getDefaultSettings() 'w:followedHyperlink' => 'followedHyperlink', ), ), - 'w:doNotIncludeSubdocsInStats' => '', - 'w:doNotAutoCompressPictures' => '', - 'w:decimalSymbol' => array('@attributes' => array('w:val' => ',')), - 'w:listSeparator' => array('@attributes' => array('w:val' => ';')), ); + + // Other settings + $this->getProtection(); + $this->getCompatibility(); + } + + /** + * Get protection settings + */ + private function getProtection() + { + $protection = $this->getParentWriter()->getPhpWord()->getProtection(); + if ($protection->getEditing() !== null) { + $this->settings['w:documentProtection'] = array( + '@attributes' => array( + 'w:enforcement' => 1, + 'w:edit' => $protection->getEditing(), + ) + ); + } + } + + /** + * Get compatibility setting + */ + private function getCompatibility() + { + $compatibility = $this->getParentWriter()->getPhpWord()->getCompatibility(); + if ($compatibility->getOoxmlVersion() !== null) { + $this->settings['w:compat']['w:compatSetting'] = array('@attributes' => array( + 'w:name' => 'compatibilityMode', + 'w:uri' => 'http://schemas.microsoft.com/office/word', + 'w:val' => $compatibility->getOoxmlVersion(), + )); + } } } diff --git a/tests/PhpWord/Tests/StyleTest.php b/tests/PhpWord/Tests/StyleTest.php index 23af4b2ee7..6165e4fd3b 100644 --- a/tests/PhpWord/Tests/StyleTest.php +++ b/tests/PhpWord/Tests/StyleTest.php @@ -75,6 +75,8 @@ public function testStyles() } /** + * Test default paragraph style + * * @covers ::setDefaultParagraphStyle * @test */ diff --git a/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php index de78c34ac9..7d4d1849c6 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/SettingsTest.php @@ -49,4 +49,20 @@ public function testDocumentProtection() $path = '/w:settings/w:documentProtection'; $this->assertTrue($doc->elementExists($path, $file)); } + + /** + * Test compatibility + */ + public function testCompatibility() + { + $phpWord = new PhpWord(); + $phpWord->getCompatibility()->setOoxmlVersion(15); + + $doc = TestHelperDOCX::getDocument($phpWord); + + $file = 'word/settings.xml'; + + $path = '/w:settings/w:compat/w:compatSetting'; + $this->assertTrue($doc->elementExists($path, $file)); + } } From 8efe80b5c106d87be68647bdfc2661342ebdacc3 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 22 Jun 2014 09:27:10 +0700 Subject: [PATCH 049/174] QA: Use Composer for Travis test tools --- .travis.yml | 23 +-- composer.json | 3 + composer.lock | 418 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 419 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfee2bb9df..d92e23b83f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,17 +23,6 @@ before_script: ## Composer - composer self-update - composer install --prefer-source --dev - ## 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 @@ -42,15 +31,15 @@ script: ## PHP_CodeSniffer - ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP Copy/Paste Detector - - php phpcpd.phar src/ tests/ --verbose + - ./vendor/bin/phpcpd src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php - ## PHPLOC - #- php phploc.phar src/ + - ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ## PHPUnit - - phpunit -c ./ --coverage-text --coverage-html ./build/coverage + - ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./build/coverage + ## PHPLOC + - ./vendor/bin/phploc src/ ## PHPDocumentor - - vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" + - ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" after_script: ## PHPDocumentor diff --git a/composer.json b/composer.json index 2f9a0915b0..add1dc1da0 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,9 @@ "phpunit/phpunit": "3.7.*", "phpdocumentor/phpdocumentor":"2.*", "squizlabs/php_codesniffer": "1.*", + "phpmd/phpmd": "dev-master", + "sebastian/phpcpd": "*", + "phploc/phploc": "*", "dompdf/dompdf":"0.6.*", "tecnick.com/tcpdf": "6.*", "mpdf/mpdf": "5.*" diff --git a/composer.lock b/composer.lock index 11a38043ab..d9cf9adf01 100644 --- a/composer.lock +++ b/composer.lock @@ -1,9 +1,10 @@ { "_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" + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], - "hash": "7d0a883164ca8e64ca34f4910aa64b96", + "hash": "8ffa35e0864738ed4325f961b941c0d2", "packages": [ ], @@ -706,6 +707,45 @@ ], "time": "2013-08-25 17:11:40" }, + { + "name": "pdepend/pdepend", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "b74f2bb68e86104cd97dfb8d74209692c9b465ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b74f2bb68e86104cd97dfb8d74209692c9b465ce", + "reference": "b74f2bb68e86104cd97dfb8d74209692c9b465ce", + "shasum": "" + }, + "require": { + "symfony/config": "@stable", + "symfony/dependency-injection": "@stable", + "symfony/filesystem": "@stable" + }, + "require-dev": { + "phpunit/phpunit": "3.*@stable", + "squizlabs/php_codesniffer": "@stable" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "autoload": { + "psr-0": { + "PDepend\\": "src/main/php/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "time": "2014-05-21 09:48:10" + }, { "name": "phenx/php-font-lib", "version": "0.2.2", @@ -1406,6 +1446,98 @@ ], "time": "2013-09-09 06:13:02" }, + { + "name": "phploc/phploc", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phploc.git", + "reference": "d177c22e2a08e448f7bdfa762045f7bd086834d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phploc/zipball/d177c22e2a08e448f7bdfa762045f7bd086834d7", + "reference": "d177c22e2a08e448f7bdfa762045f7bd086834d7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/finder-facade": ">=1.1.0", + "sebastian/git": ">=1.0.0", + "sebastian/version": ">=1.0.3", + "symfony/console": ">=2.2.0" + }, + "bin": [ + "phploc" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "A tool for quickly measuring the size of a PHP project.", + "homepage": "https://github.com/sebastianbergmann/phploc", + "time": "2014-04-27 06:47:27" + }, + { + "name": "phpmd/phpmd", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "68ced5452910d3555a38720bd87f5f2356c5a003" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/68ced5452910d3555a38720bd87f5f2356c5a003", + "reference": "68ced5452910d3555a38720bd87f5f2356c5a003", + "shasum": "" + }, + "require": { + "pdepend/pdepend": "2.0.*", + "php": ">=5.3.0", + "symfony/config": "@stable", + "symfony/dependency-injection": "@stable", + "symfony/filesystem": "@stable" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php", + "PDepend\\": "vendor/pdepend/pdepend/src/main/php/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "../../pdepend/pdepend/src/main/php", + "src/main/php" + ], + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of PHPMD handled with Composer.", + "time": "2014-05-21 12:45:23" + }, { "name": "phpoption/phpoption", "version": "1.4.0", @@ -1907,6 +2039,177 @@ ], "time": "2012-12-21 11:40:51" }, + { + "name": "sebastian/finder-facade", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/finder-facade.git", + "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/1e396fda3449fce9df032749fa4fa2619e0347e0", + "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0", + "shasum": "" + }, + "require": { + "symfony/finder": ">=2.2.0", + "theseer/fdomdocument": ">=1.3.1" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", + "homepage": "https://github.com/sebastianbergmann/finder-facade", + "time": "2013-05-28 06:10:03" + }, + { + "name": "sebastian/git", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/git.git", + "reference": "572c35353fefcc8607d6fef0e362a9f3a5e84d96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/git/zipball/572c35353fefcc8607d6fef0e362a9f3a5e84d96", + "reference": "572c35353fefcc8607d6fef0e362a9f3a5e84d96", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple wrapper for Git", + "homepage": "http://www.github.com/sebastianbergmann/git", + "keywords": [ + "git" + ], + "time": "2014-06-14 07:12:53" + }, + { + "name": "sebastian/phpcpd", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpcpd.git", + "reference": "a9462153f2dd90466a010179901d31fbff598365" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/a9462153f2dd90466a010179901d31fbff598365", + "reference": "a9462153f2dd90466a010179901d31fbff598365", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-timer": ">=1.0.4", + "sebastian/finder-facade": ">=1.1.0", + "sebastian/version": ">=1.0.3", + "symfony/console": ">=2.2.0", + "theseer/fdomdocument": "~1.4" + }, + "bin": [ + "phpcpd" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Copy/Paste Detector (CPD) for PHP code.", + "homepage": "https://github.com/sebastianbergmann/phpcpd", + "time": "2014-03-31 09:25:30" + }, + { + "name": "sebastian/version", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-03-07 15:35:33" + }, { "name": "squizlabs/php_codesniffer", "version": "1.5.3", @@ -2089,6 +2392,65 @@ "homepage": "http://symfony.com", "time": "2014-05-22 08:54:24" }, + { + "name": "symfony/dependency-injection", + "version": "v2.5.0", + "target-dir": "Symfony/Component/DependencyInjection", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection.git", + "reference": "5dfb4c2b74c4976efe1efa783370da656a2dd742" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/5dfb4c2b74c4976efe1efa783370da656a2dd742", + "reference": "5dfb4c2b74c4976efe1efa783370da656a2dd742", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/yaml": "~2.0" + }, + "suggest": { + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\DependencyInjection\\": "" + } + }, + "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 DependencyInjection Component", + "homepage": "http://symfony.com", + "time": "2014-05-12 09:28:39" + }, { "name": "symfony/event-dispatcher", "version": "v2.5.0", @@ -2524,11 +2886,11 @@ }, { "name": "tecnick.com/tcpdf", - "version": "6.0.083", + "version": "6.0.086", "source": { "type": "git", "url": "git://git.code.sf.net/p/tcpdf/code", - "reference": "d6a2206ab366f493680a22151429f17fd045fe04" + "reference": "b1c0cc74a84948029d8c9824736d9021871a63a7" }, "require": { "php": ">=5.3.0" @@ -2577,7 +2939,47 @@ "pdf417", "qrcode" ], - "time": "2014-05-29 18:28:56" + "time": "2014-06-20 15:28:34" + }, + { + "name": "theseer/fdomdocument", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/fDOMDocument.git", + "reference": "137aa3b13bef05b4e301899cbabdaf7d501847d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/137aa3b13bef05b4e301899cbabdaf7d501847d2", + "reference": "137aa3b13bef05b4e301899cbabdaf7d501847d2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "lib-libxml": "*", + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "lead" + } + ], + "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", + "homepage": "https://github.com/theseer/fDOMDocument", + "time": "2014-02-19 00:20:43" }, { "name": "twig/twig", @@ -3219,9 +3621,9 @@ ], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": { + "phpmd/phpmd": 20 + }, "platform": { "php": ">=5.3.3", "ext-xml": "*" From ea6ec473d26fc529cbbe0b1f0725243deab39309 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 22 Jun 2014 10:22:40 +0700 Subject: [PATCH 050/174] Update composer dependencies --- composer.json | 8 +- composer.lock | 328 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 291 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index add1dc1da0..798280d332 100644 --- a/composer.json +++ b/composer.json @@ -36,12 +36,12 @@ "ext-xml": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "4.*", "phpdocumentor/phpdocumentor":"2.*", "squizlabs/php_codesniffer": "1.*", - "phpmd/phpmd": "dev-master", - "sebastian/phpcpd": "*", - "phploc/phploc": "*", + "phpmd/phpmd": "2.*", + "sebastian/phpcpd": "2.*", + "phploc/phploc": "2.*", "dompdf/dompdf":"0.6.*", "tecnick.com/tcpdf": "6.*", "mpdf/mpdf": "5.*" diff --git a/composer.lock b/composer.lock index d9cf9adf01..2d21196d53 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8ffa35e0864738ed4325f961b941c0d2", + "hash": "cc4b56586d5cdffa05da9ee2cf50a622", "packages": [ ], @@ -1498,7 +1498,7 @@ }, { "name": "phpmd/phpmd", - "version": "dev-master", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", @@ -1589,40 +1589,44 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.17", + "version": "2.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" + "reference": "58401826c8cfc8fd689b60026e91c337df374bca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/58401826c8cfc8fd689b60026e91c337df374bca", + "reference": "58401826c8cfc8fd689b60026e91c337df374bca", "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" + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2.0", + "phpunit/php-token-stream": "~1.2.2", + "sebastian/environment": "~1.0.0", + "sebastian/version": "~1.0.3" }, "require-dev": { - "phpunit/phpunit": "3.7.*@dev" + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4.0.14" }, "suggest": { "ext-dom": "*", - "ext-xdebug": ">=2.0.5" + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1646,7 +1650,7 @@ "testing", "xunit" ], - "time": "2014-03-28 10:53:45" + "time": "2014-05-26 14:55:24" }, { "name": "phpunit/php-file-iterator", @@ -1833,51 +1837,52 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.37", + "version": "4.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", "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", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.1", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", "symfony/yaml": "~2.0" }, - "require-dev": { - "pear-pear.php.net/pear": "1.9.4" - }, "suggest": { "phpunit/php-invoker": "~1.1" }, "bin": [ - "composer/bin/phpunit" + "phpunit" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.7.x-dev" + "dev-master": "4.1.x-dev" } }, "autoload": { "classmap": [ - "PHPUnit/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1902,33 +1907,41 @@ "testing", "xunit" ], - "time": "2014-04-30 12:24:19" + "time": "2014-06-11 14:15:47" }, { "name": "phpunit/phpunit-mock-objects", - "version": "1.2.3", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" + "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", - "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", + "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", "shasum": "" }, "require": { "php": ">=5.3.3", - "phpunit/php-text-template": ">=1.1.1@stable" + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" }, "suggest": { "ext-soap": "*" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, "autoload": { "classmap": [ - "PHPUnit/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1951,7 +1964,7 @@ "mock", "xunit" ], - "time": "2013-01-13 10:24:48" + "time": "2014-06-07 16:22:57" }, { "name": "pimple/pimple", @@ -2039,6 +2052,239 @@ ], "time": "2012-12-21 11:40:51" }, + { + "name": "sebastian/comparator", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2014-05-02 07:05:58" + }, + { + "name": "sebastian/diff", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2013-08-03 16:46:33" + }, + { + "name": "sebastian/environment", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-02-18 16:17:19" + }, + { + "name": "sebastian/exporter", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net", + "role": "Lead" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2014-02-16 08:26:31" + }, { "name": "sebastian/finder-facade", "version": "1.1.0", @@ -3621,9 +3867,9 @@ ], "minimum-stability": "stable", - "stability-flags": { - "phpmd/phpmd": 20 - }, + "stability-flags": [ + + ], "platform": { "php": ">=5.3.3", "ext-xml": "*" From 6e175abfcd2e7a7a69b46582cbdedda2235606bd Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 22 Jun 2014 11:12:26 +0700 Subject: [PATCH 051/174] Revert phpunit to 3.7.* because 4.* is too slow sebastianbergmann/phpunit#1300 --- composer.json | 2 +- composer.lock | 320 ++++++-------------------------------------------- 2 files changed, 38 insertions(+), 284 deletions(-) diff --git a/composer.json b/composer.json index 798280d332..74009e3a7b 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "ext-xml": "*" }, "require-dev": { - "phpunit/phpunit": "4.*", + "phpunit/phpunit": "3.7.*", "phpdocumentor/phpdocumentor":"2.*", "squizlabs/php_codesniffer": "1.*", "phpmd/phpmd": "2.*", diff --git a/composer.lock b/composer.lock index 2d21196d53..122d7ab2bf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "cc4b56586d5cdffa05da9ee2cf50a622", + "hash": "50bae1209285a67796556b7ec42f64fc", "packages": [ ], @@ -1589,44 +1589,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.0.8", + "version": "1.2.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "58401826c8cfc8fd689b60026e91c337df374bca" + "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/58401826c8cfc8fd689b60026e91c337df374bca", - "reference": "58401826c8cfc8fd689b60026e91c337df374bca", + "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.1", - "phpunit/php-text-template": "~1.2.0", - "phpunit/php-token-stream": "~1.2.2", - "sebastian/environment": "~1.0.0", - "sebastian/version": "~1.0.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": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.0.14" + "phpunit/phpunit": "3.7.*@dev" }, "suggest": { "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "ext-xdebug": ">=2.0.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { "classmap": [ - "src/" + "PHP/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1650,7 +1646,7 @@ "testing", "xunit" ], - "time": "2014-05-26 14:55:24" + "time": "2014-03-28 10:53:45" }, { "name": "phpunit/php-file-iterator", @@ -1837,52 +1833,51 @@ }, { "name": "phpunit/phpunit", - "version": "4.1.3", + "version": "3.7.37", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91" + "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/939cb801b3b2aa253aedd0b279f40bb8f35cec91", - "reference": "939cb801b3b2aa253aedd0b279f40bb8f35cec91", + "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": "~2.0", - "phpunit/php-file-iterator": "~1.3.1", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.1", - "sebastian/comparator": "~1.0", - "sebastian/diff": "~1.1", - "sebastian/environment": "~1.0", - "sebastian/exporter": "~1.0", - "sebastian/version": "~1.0", + "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": [ - "phpunit" + "composer/bin/phpunit" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1.x-dev" + "dev-master": "3.7.x-dev" } }, "autoload": { "classmap": [ - "src/" + "PHPUnit/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1907,41 +1902,33 @@ "testing", "xunit" ], - "time": "2014-06-11 14:15:47" + "time": "2014-04-30 12:24:19" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.1.4", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f" + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", - "reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", + "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.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.1" + "phpunit/php-text-template": ">=1.1.1@stable" }, "suggest": { "ext-soap": "*" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1.x-dev" - } - }, "autoload": { "classmap": [ - "src/" + "PHPUnit/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1964,7 +1951,7 @@ "mock", "xunit" ], - "time": "2014-06-07 16:22:57" + "time": "2013-01-13 10:24:48" }, { "name": "pimple/pimple", @@ -2052,239 +2039,6 @@ ], "time": "2012-12-21 11:40:51" }, - { - "name": "sebastian/comparator", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.1", - "sebastian/exporter": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2014-05-02 07:05:58" - }, - { - "name": "sebastian/diff", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - } - ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2013-08-03 16:46:33" - }, - { - "name": "sebastian/environment", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "4.0.*@dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2014-02-18 16:17:19" - }, - { - "name": "sebastian/exporter", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "4.0.*@dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net", - "role": "Lead" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2014-02-16 08:26:31" - }, { "name": "sebastian/finder-facade", "version": "1.1.0", From a5c857f7491522699da3ac00c47f5b7d98ed5339 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 24 Jun 2014 10:36:58 +0200 Subject: [PATCH 052/174] #289 : Update elements.rst --- docs/elements.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/elements.rst b/docs/elements.rst index e4baf70e74..2f2fb91cd0 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -397,7 +397,23 @@ To be completed. Lines ----- -To be completed. +Line elements can be added to sections by using ``addLine``. + +.. code-block:: php + + $linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552); + $section->addLine($lineStyle) + +Available line style attributes: + +- ``weight`` Line width in twips +- ``color`` Defines the color of stroke +- ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot +- ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval +- ``endArrow`` End type of arrow: block, open, classic, diamond, ovel +- ``width`` Line-object width in pt +- ``height`` Line-object height in pt +- ``flip`` Flip the line element: true, false Shapes ------ From b5a63c5b55a77e9d75dc52439f9b60587ac76a20 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 28 Jun 2014 11:47:04 +0700 Subject: [PATCH 053/174] Elaborate SDT elements --- CHANGELOG.md | 1 + samples/Sample_34_SDT.php | 13 +++- src/PhpWord/Element/AbstractContainer.php | 2 +- src/PhpWord/Writer/Word2007/Element/SDT.php | 61 +++++++++++++++---- .../Tests/Writer/Word2007/ElementTest.php | 20 ++++++ 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22f22dd937..6f9bf239a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 - Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin - Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin +- SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin ### Bugfixes diff --git a/samples/Sample_34_SDT.php b/samples/Sample_34_SDT.php index fc1e7de6c7..241dee2a19 100644 --- a/samples/Sample_34_SDT.php +++ b/samples/Sample_34_SDT.php @@ -4,11 +4,20 @@ // New Word document echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$phpWord->getProtection()->setEditing('forms'); $section = $phpWord->addSection(); -$section->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); +$textrun = $section->addTextRun(); +$textrun->addText('Combobox: '); +$textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); + +$textrun = $section->addTextRun(); +$textrun->addText('Date: '); +$textrun->addSDT('date'); + +$textrun = $section->addTextRun(); +$textrun->addText('Drop down list: '); +$textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index afde4270cc..b934b2d827 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -193,6 +193,7 @@ private function checkValidity($method) 'Line' => $allContainers, 'Shape' => $allContainers, 'FormField' => $allContainers, + 'SDT' => $allContainers, 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), @@ -206,7 +207,6 @@ private function checkValidity($method) 'TOC' => array('Section'), 'PageBreak' => array('Section'), 'Chart' => array('Section'), - 'SDT' => array('Section'), ); // Special condition, e.g. preservetext can only exists in cell when // the cell is located in header or footer diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php index d25eaf981a..94578e1634 100644 --- a/src/PhpWord/Writer/Word2007/Element/SDT.php +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -39,33 +39,72 @@ public function write() return; } $type = $element->getType(); - $listItems = $element->getListItems(); + $writeFormField = "write{$type}"; $this->startElementP(); $xmlWriter->startElement('w:sdt'); + // Properties $xmlWriter->startElement('w:sdtPr'); $xmlWriter->writeElementBlock('w:id', 'w:val', rand(100000000, 999999999)); $xmlWriter->writeElementBlock('w:lock', 'w:val', 'sdtLocked'); + $this->$writeFormField($xmlWriter, $element); + $xmlWriter->endElement(); // w:sdtPr + + // Content + $xmlWriter->startElement('w:sdtContent'); + $xmlWriter->startElement('w:r'); + $xmlWriter->startElement('w:t'); + $xmlWriter->writeRaw('Pick value'); + $xmlWriter->endElement(); // w:t + $xmlWriter->endElement(); // w:r + $xmlWriter->endElement(); // w:sdtContent + + $xmlWriter->endElement(); // w:sdt - $xmlWriter->startElement('w:placeholder'); - $xmlWriter->writeElementBlock('w:docPart', 'w:val', 'string'); - $xmlWriter->endElement(); // w:placeholder + $this->endElementP(); // w:p + } + + /** + * Write combo box + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html + */ + private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element) + { + $type = $element->getType(); + $listItems = $element->getListItems(); $xmlWriter->startElement("w:{$type}"); foreach ($listItems as $key => $val) { $xmlWriter->writeElementBlock('w:listItem', array('w:value' => $key, 'w:displayText' => $val)); } $xmlWriter->endElement(); // w:{$type} + } - $xmlWriter->endElement(); // w:sdtPr - - $xmlWriter->startElement('w:sdtContent'); - $xmlWriter->endElement(); // w:sdtContent - - $xmlWriter->endElement(); // w:sdt + /** + * Write drop down list + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html + */ + private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element) + { + $this->writecomboBox($xmlWriter, $element); + } - $this->endElementP(); // w:p + /** + * Write date + * + * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html + */ + private function writeDate(XMLWriter $xmlWriter, SDTElement $element) + { + $xmlWriter->startElement("w:date"); + $xmlWriter->writeElementBlock('w:dateFormat', 'w:val', 'd/M/yyyy'); + $xmlWriter->writeElementBlock('w:lid', 'w:val', 'en-US'); + $xmlWriter->writeElementBlock('w:storeMappedDataAs', 'w:val', 'dateTime'); + $xmlWriter->writeElementBlock('w:calendar', 'w:val', 'gregorian'); + $xmlWriter->endElement(); // w:date } } diff --git a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php index 752415a1b8..92a74c1544 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/ElementTest.php @@ -196,4 +196,24 @@ public function testFormFieldElements() $this->assertTrue($doc->elementExists($path . '/w:checkBox')); $this->assertTrue($doc->elementExists($path . '/w:ddList')); } + + /** + * Test SDT elements + */ + public function testSDTElements() + { + $phpWord = new PhpWord(); + $section = $phpWord->addSection(); + + $section->addSDT('comboBox'); + $section->addSDT('dropDownList'); + $section->addSDT('date'); + + $doc = TestHelperDOCX::getDocument($phpWord); + + $path = "/w:document/w:body/w:p/w:sdt/w:sdtPr"; + $this->assertTrue($doc->elementExists($path . '/w:comboBox')); + $this->assertTrue($doc->elementExists($path . '/w:dropDownList')); + $this->assertTrue($doc->elementExists($path . '/w:date')); + } } From 689a7371cd0cd7c6929e86b9f6915bca811b5bd1 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 28 Jun 2014 12:01:53 +0700 Subject: [PATCH 054/174] Fix Travis errors --- src/PhpWord/Writer/Word2007/Element/SDT.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php index 94578e1634..b41bb696e1 100644 --- a/src/PhpWord/Writer/Word2007/Element/SDT.php +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -25,6 +25,7 @@ * * @since 0.12.0 * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtBlock.html + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ class SDT extends Text { @@ -100,7 +101,9 @@ private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element) */ private function writeDate(XMLWriter $xmlWriter, SDTElement $element) { - $xmlWriter->startElement("w:date"); + $type = $element->getType(); + + $xmlWriter->startElement("w:{$type}"); $xmlWriter->writeElementBlock('w:dateFormat', 'w:val', 'd/M/yyyy'); $xmlWriter->writeElementBlock('w:lid', 'w:val', 'en-US'); $xmlWriter->writeElementBlock('w:storeMappedDataAs', 'w:val', 'dateTime'); From 33570f7cd4e760cbb1c9e1ef26868f6805345907 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sat, 28 Jun 2014 22:59:00 +0700 Subject: [PATCH 055/174] #294: Support for paragraph with borders --- CHANGELOG.md | 1 + src/PhpWord/Style/Paragraph.php | 2 +- src/PhpWord/Writer/Word2007/Style/Paragraph.php | 12 ++++++++++++ .../Tests/Writer/Word2007/Part/DocumentTest.php | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f9bf239a1..0ba632cf07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin - Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin - SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin +- Paragraph: Support for paragraph with borders - @ivanlanin GH-294 ### Bugfixes diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 1825432185..964a4ec960 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -47,7 +47,7 @@ * * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_PPr.html */ -class Paragraph extends AbstractStyle +class Paragraph extends Border { /** * @const int One line height equals 240 twip diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index f8d6cf1e58..86efda2fc5 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -108,6 +108,18 @@ private function writeStyle() // Numbering $this->writeNumbering($xmlWriter, $styles['numbering']); + // Border + if ($style->hasBorder()) { + $xmlWriter->startElement('w:pBdr'); + + $styleWriter = new MarginBorder($xmlWriter); + $styleWriter->setSizes($style->getBorderSize()); + $styleWriter->setColors($style->getBorderColor()); + $styleWriter->write(); + + $xmlWriter->endElement(); + } + 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 56be15d0cc..ef36e0dd72 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php @@ -139,6 +139,7 @@ public function testElementStyles() 'align' => 'center', 'tabs' => $tabs, 'shading' => array('fill' => 'FFFF99'), + 'borderSize' => 4, )); // Style #1 $phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true, 'scale' => 200, 'spacing' => 240, 'kerning' => 10)); // Style #2 From 415d9b95c4fbefabb00d55f28d1481da3b86a17c Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 29 Jun 2014 14:10:49 +0700 Subject: [PATCH 056/174] Update tests --- src/PhpWord/Element/SDT.php | 2 +- src/PhpWord/PhpWord.php | 9 ++- .../Tests/Element/AbstractElementTest.php | 2 - tests/PhpWord/Tests/Element/SDTTest.php | 69 +++++++++++++++++++ tests/PhpWord/Tests/PhpWordTest.php | 12 ++++ tests/PhpWord/Tests/Shared/StringTest.php | 8 +++ 6 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 tests/PhpWord/Tests/Element/SDTTest.php diff --git a/src/PhpWord/Element/SDT.php b/src/PhpWord/Element/SDT.php index 477c50f357..c69ed42772 100644 --- a/src/PhpWord/Element/SDT.php +++ b/src/PhpWord/Element/SDT.php @@ -77,7 +77,7 @@ public function getType() public function setType($value) { $enum = array('comboBox', 'dropDownList', 'date'); - $this->type = $this->setEnumVal($value, $enum, $this->type); + $this->type = $this->setEnumVal($value, $enum, 'comboBox'); return $this; } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index be808f01a2..7c5cbbfe2b 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -99,14 +99,10 @@ public function __construct() /** * Dynamic function call to reduce static dependency * - * Usage: - * - Getting and adding collections (Titles, Footnotes, and Endnotes) - * - Adding style - * * @param mixed $function * @param mixed $args + * @throws \BadMethodCallException * @return mixed - * * @since 0.12.0 */ public function __call($function, $args) @@ -149,6 +145,9 @@ public function __call($function, $args) if (in_array($function, $addStyle)) { return forward_static_call_array(array('PhpOffice\\PhpWord\\Style', $function), $args); } + + // Exception + throw new \BadMethodCallException("Method $function is not defined."); } /** diff --git a/tests/PhpWord/Tests/Element/AbstractElementTest.php b/tests/PhpWord/Tests/Element/AbstractElementTest.php index c92469f348..180dd4d0b6 100644 --- a/tests/PhpWord/Tests/Element/AbstractElementTest.php +++ b/tests/PhpWord/Tests/Element/AbstractElementTest.php @@ -19,8 +19,6 @@ /** * Test class for PhpOffice\PhpWord\Element\AbstractElement - * - * @runTestsInSeparateProcesses */ class AbstractElementTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/PhpWord/Tests/Element/SDTTest.php b/tests/PhpWord/Tests/Element/SDTTest.php new file mode 100644 index 0000000000..aa7e89b3ef --- /dev/null +++ b/tests/PhpWord/Tests/Element/SDTTest.php @@ -0,0 +1,69 @@ +setValue($value);; + $object->setListItems($types);; + + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\SDT', $object); + $this->assertEquals($type, $object->getType()); + $this->assertEquals($types, $object->getListItems()); + $this->assertEquals($value, $object->getValue()); + } + + /** + * Test set type exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid style value + */ + public function testSetTypeException() + { + $object = new SDT('comboBox'); + $object->setType('foo'); + } + + /** + * Test set type + */ + public function testSetTypeNull() + { + $object = new SDT('comboBox'); + $object->setType(' '); + + $this->assertEquals('comboBox', $object->getType()); + } +} diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 75b2d28875..756f848f49 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -157,4 +157,16 @@ public function testSave() $this->assertTrue($phpWord->save('test.docx', 'Word2007', true)); } + + /** + * Test calling undefined method + * + * @expectedException \BadMethodCallException + * @expectedExceptionMessage is not defined + */ + public function testCallUndefinedMethod() + { + $phpWord = new PhpWord(); + $phpWord->undefinedMethod(); + } } diff --git a/tests/PhpWord/Tests/Shared/StringTest.php b/tests/PhpWord/Tests/Shared/StringTest.php index bf5862fbc0..a3524eded8 100644 --- a/tests/PhpWord/Tests/Shared/StringTest.php +++ b/tests/PhpWord/Tests/Shared/StringTest.php @@ -64,4 +64,12 @@ public function testToUnicode() $this->assertEquals('\uc0{\u8364}', String::toUnicode('€')); $this->assertEquals('\uc0{\u233}', String::toUnicode('é')); } + + /** + * Test remove underscore prefix + */ + public function testRemoveUnderscorePrefix() + { + $this->assertEquals('item', String::removeUnderscorePrefix('_item')); + } } From 40e41342ce87c5571277422d2562d64241115f35 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 29 Jun 2014 21:14:10 +0700 Subject: [PATCH 057/174] Fix PHPCS --- tests/PhpWord/Tests/Element/SDTTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Tests/Element/SDTTest.php b/tests/PhpWord/Tests/Element/SDTTest.php index aa7e89b3ef..8c7b4bf328 100644 --- a/tests/PhpWord/Tests/Element/SDTTest.php +++ b/tests/PhpWord/Tests/Element/SDTTest.php @@ -35,8 +35,8 @@ public function testConstruct() $type = $types[rand(0, 2)]; $value = rand(0, 100); $object = new SDT($type); - $object->setValue($value);; - $object->setListItems($types);; + $object->setValue($value); + $object->setListItems($types); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\SDT', $object); $this->assertEquals($type, $object->getType()); From d8aef5c502e9ec980f93b1647489c30bf4fe73a6 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 1 Jul 2014 09:52:24 +0700 Subject: [PATCH 058/174] Bugfix #294: `add` of container should be case insensitive --- CHANGELOG.md | 1 + src/PhpWord/Element/AbstractContainer.php | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ba632cf07..eae842bf7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 - Page breaks on titles and tables - @ivanlanin GH-274 - Table inside vertical border does not rendered properly - @ivanlanin GH-280 +- `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 ### Deprecated diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index b934b2d827..686644eb76 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -77,18 +77,22 @@ abstract class AbstractContainer extends AbstractElement */ public function __call($function, $args) { - $elements = array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', - 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', - 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape', - 'Title', 'TOC', 'PageBreak', 'Chart', 'FormField', 'SDT'); + $elements = array( + 'Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', + 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', + 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', + 'Line', 'Shape', 'Title', 'TOC', 'PageBreak', + 'Chart', 'FormField', 'SDT' + ); $functions = array(); - for ($i = 0; $i < count($elements); $i++) { - $functions[$i] = 'add' . $elements[$i]; + foreach ($elements as $element) { + $functions['add' . strtolower($element)] = $element; } // Run valid `add` command - if (in_array($function, $functions)) { - $element = str_replace('add', '', $function); + $function = strtolower($function); + if (array_key_exists($function, $functions)) { + $element = $functions[$function]; // Special case for TextBreak // @todo Remove the `$count` parameter in 1.0.0 to make this element similiar to other elements? From 3c694ea572304c0680b3ce4c5da193f433554a1d Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 2 Jul 2014 12:42:50 +0400 Subject: [PATCH 059/174] [NEW] Introduced CreateTemporaryFileException. --- .../CreateTemporaryFileException.php | 30 ++++++++++++++ src/PhpWord/Template.php | 20 ++++++---- .../CreateTemporaryFileExceptionTest.php | 39 +++++++++++++++++++ 3 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 src/PhpWord/Exception/CreateTemporaryFileException.php create mode 100644 tests/PhpWord/Tests/Exception/CreateTemporaryFileExceptionTest.php diff --git a/src/PhpWord/Exception/CreateTemporaryFileException.php b/src/PhpWord/Exception/CreateTemporaryFileException.php new file mode 100644 index 0000000000..f635dd6b6b --- /dev/null +++ b/src/PhpWord/Exception/CreateTemporaryFileException.php @@ -0,0 +1,30 @@ +message); + } +} diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 21e8b98886..6cfa664f03 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord; +use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\ZipArchive; @@ -54,24 +55,20 @@ class Template */ private $headerXMLs = array(); - /** - * Document footer XML - * - * @var string[] - */ - private $footerXMLs = array(); - /** * Create a new Template Object * + * @since 0.12.0 Throws CreateTemporaryFileException instead of Exception. + * * @param string $strFilename + * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException * @throws \PhpOffice\PhpWord\Exception\Exception */ public function __construct($strFilename) { $this->tempFileName = tempnam(sys_get_temp_dir(), ''); if ($this->tempFileName === false) { - throw new Exception('Could not create temporary file with unique name in the default temporary directory.'); + throw new CreateTemporaryFileException(); } // Copy the source File to the temp File @@ -98,6 +95,13 @@ public function __construct($strFilename) $this->documentXML = $this->zipClass->getFromName('word/document.xml'); } + /** + * Document footer XML + * + * @var string[] + */ + private $footerXMLs = array(); + /** * Applies XSL style sheet to template's parts * diff --git a/tests/PhpWord/Tests/Exception/CreateTemporaryFileExceptionTest.php b/tests/PhpWord/Tests/Exception/CreateTemporaryFileExceptionTest.php new file mode 100644 index 0000000000..7cf0cb773d --- /dev/null +++ b/tests/PhpWord/Tests/Exception/CreateTemporaryFileExceptionTest.php @@ -0,0 +1,39 @@ + Date: Wed, 2 Jul 2014 12:49:18 +0400 Subject: [PATCH 060/174] [NEW] Introduced CreateTemporaryFileException. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eae842bf7b..53533148cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - PclZip: Remove temporary file after used - @andrew-kzoo GH-265 - Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 - Element: Refactor elements to move set relation Id from container to element - @ivanlanin +- Introduced CreateTemporaryFileException - @RomanSyroeshko ## 0.11.1 - 2 June 2014 From dbc9737136801e0fa3c40a8862df8a54c6b987a8 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 2 Jul 2014 12:58:55 +0400 Subject: [PATCH 061/174] [NEW] Introduced CreateTemporaryFileException. --- src/PhpWord/Exception/CreateTemporaryFileException.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Exception/CreateTemporaryFileException.php b/src/PhpWord/Exception/CreateTemporaryFileException.php index f635dd6b6b..9cddb7ac94 100644 --- a/src/PhpWord/Exception/CreateTemporaryFileException.php +++ b/src/PhpWord/Exception/CreateTemporaryFileException.php @@ -24,7 +24,8 @@ final class CreateTemporaryFileException extends Exception { protected $message = 'Could not create a temporary file with unique name in the specified directory.'; - final public function __construct() { + final public function __construct() + { parent::__construct($this->message); } } From 369f55a71fee63d6d77aea8b9d935d322139a64e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 2 Jul 2014 13:17:13 +0400 Subject: [PATCH 062/174] [NEW] Introduced CreateTemporaryFileException. --- .../Exception/CreateTemporaryFileException.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/PhpWord/Exception/CreateTemporaryFileException.php b/src/PhpWord/Exception/CreateTemporaryFileException.php index 9cddb7ac94..b68569c95d 100644 --- a/src/PhpWord/Exception/CreateTemporaryFileException.php +++ b/src/PhpWord/Exception/CreateTemporaryFileException.php @@ -22,10 +22,16 @@ */ final class CreateTemporaryFileException extends Exception { - protected $message = 'Could not create a temporary file with unique name in the specified directory.'; - - final public function __construct() + /** + * @param integer $code The user defined exception code. + * @param \Exception $previous The previous exception used for the exception chaining. + */ + final public function __construct($code = 0, \Exception $previous = null) { - parent::__construct($this->message); + parent::__construct( + 'Could not create a temporary file with unique name in the specified directory.', + $code, + $previous + ); } } From 75c8e7e8166d0946ca604984875d8866203af907 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 2 Jul 2014 17:21:43 +0400 Subject: [PATCH 063/174] [NEW] Introduced CopyFileException. --- CHANGELOG.md | 2 +- src/PhpWord/Exception/CopyFileException.php | 39 +++++++++++++++++++ src/PhpWord/Template.php | 9 +++-- src/PhpWord/Writer/AbstractWriter.php | 7 +++- .../Tests/Exception/CopyFileExceptionTest.php | 39 +++++++++++++++++++ 5 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 src/PhpWord/Exception/CopyFileException.php create mode 100644 tests/PhpWord/Tests/Exception/CopyFileExceptionTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 53533148cc..f1ac091e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - PclZip: Remove temporary file after used - @andrew-kzoo GH-265 - Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 - Element: Refactor elements to move set relation Id from container to element - @ivanlanin -- Introduced CreateTemporaryFileException - @RomanSyroeshko +- Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko ## 0.11.1 - 2 June 2014 diff --git a/src/PhpWord/Exception/CopyFileException.php b/src/PhpWord/Exception/CopyFileException.php new file mode 100644 index 0000000000..97a900e3b2 --- /dev/null +++ b/src/PhpWord/Exception/CopyFileException.php @@ -0,0 +1,39 @@ +tempFileName)) { - throw new Exception("Could not copy the template from {$strFilename} to {$this->tempFileName}."); + if (false === copy($strFilename, $this->tempFileName)) { + throw new CopyFileException($strFilename, $this->tempFileName); } $this->zipClass = new ZipArchive(); diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 346e9b66ba..8e7cb71d2c 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Writer; +use PhpOffice\PhpWord\Exception\CopyFileException; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\ZipArchive; @@ -233,14 +234,16 @@ protected function getTempFile($filename) /** * Cleanup temporary file + * + * @throws \PhpOffice\PhpWord\Exception\CopyFileException */ 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."); + if (false === copy($this->tempFilename, $this->originalFilename)) { + throw new CopyFileException($this->tempFilename, $this->originalFilename); } // @codeCoverageIgnoreEnd @unlink($this->tempFilename); diff --git a/tests/PhpWord/Tests/Exception/CopyFileExceptionTest.php b/tests/PhpWord/Tests/Exception/CopyFileExceptionTest.php new file mode 100644 index 0000000000..3d92595f25 --- /dev/null +++ b/tests/PhpWord/Tests/Exception/CopyFileExceptionTest.php @@ -0,0 +1,39 @@ + Date: Wed, 2 Jul 2014 17:44:26 +0400 Subject: [PATCH 064/174] [Changed] Refactored Template a little. --- src/PhpWord/Template.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index e37b21dd3d..3c6065ff8c 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -29,7 +29,7 @@ class Template { /** - * ZipArchive object + * ZipArchive object. * * @var mixed */ @@ -61,20 +61,20 @@ class Template * * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception. * - * @param string $strFilename + * @param string $fileName The fully qualified template file name. * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException * @throws \PhpOffice\PhpWord\Exception\CopyFileException */ - public function __construct($strFilename) + public function __construct($fileName) { $this->tempFileName = tempnam(sys_get_temp_dir(), ''); - if ($this->tempFileName === false) { + if (false === $this->tempFileName) { throw new CreateTemporaryFileException(); } // Copy the source File to the temp File - if (false === copy($strFilename, $this->tempFileName)) { - throw new CopyFileException($strFilename, $this->tempFileName); + if (false === copy($fileName, $this->tempFileName)) { + throw new CopyFileException($fileName, $this->tempFileName); } $this->zipClass = new ZipArchive(); @@ -117,17 +117,17 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xsl $processor->importStylesheet($xslDOMDocument); - if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { + if (false === $processor->setParameter($xslOptionsURI, $xslOptions)) { throw new Exception('Could not set values for the given XSL style sheet parameters.'); } $xmlDOMDocument = new \DOMDocument(); - if ($xmlDOMDocument->loadXML($this->documentXML) === false) { + if (false === $xmlDOMDocument->loadXML($this->documentXML)) { throw new Exception('Could not load XML from the given template.'); } $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if ($xmlTransformed === false) { + if (false === $xmlTransformed) { throw new Exception('Could not transform the given XML document.'); } @@ -317,7 +317,7 @@ public function save() } // Close zip file - if ($this->zipClass->close() === false) { + if (false === $this->zipClass->close()) { throw new Exception('Could not close zip file.'); } @@ -327,18 +327,18 @@ public function save() /** * Save XML to defined name * - * @param string $strFilename + * @param string $fileName * @since 0.8.0 */ - public function saveAs($strFilename) + public function saveAs($fileName) { - $tempFilename = $this->save(); + $tempFileName = $this->save(); - if (file_exists($strFilename)) { - unlink($strFilename); + if (file_exists($fileName)) { + unlink($fileName); } - rename($tempFilename, $strFilename); + rename($tempFileName, $fileName); } /** From e1164f8989642a3f212ea491f0c0233b7b9b8f80 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 2 Jul 2014 17:49:53 +0400 Subject: [PATCH 065/174] [Changed] Refactored Template a little. --- src/PhpWord/Template.php | 52 ++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 3c6065ff8c..fc224d14de 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -36,28 +36,28 @@ class Template private $zipClass; /** - * Temporary file name + * Temporary file name. * * @var string */ private $tempFileName; /** - * Document XML + * Document XML. * * @var string */ private $documentXML; /** - * Document header XML + * Document header XML. * * @var string[] */ private $headerXMLs = array(); /** - * Create a new Template Object + * Create a new Template Object. * * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception. * @@ -97,18 +97,19 @@ public function __construct($fileName) } /** - * Document footer XML + * Document footer XML. * * @var string[] */ private $footerXMLs = array(); /** - * Applies XSL style sheet to template's parts + * Applies XSL style sheet to template's parts. * * @param \DOMDocument $xslDOMDocument * @param array $xslOptions * @param string $xslOptionsURI + * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') @@ -135,11 +136,12 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xsl } /** - * Set a Template value + * Set a Template value. * * @param mixed $search * @param mixed $replace * @param integer $limit + * @return void */ public function setValue($search, $replace, $limit = -1) { @@ -155,7 +157,8 @@ public function setValue($search, $replace, $limit = -1) } /** - * Returns array of all variables in template + * Returns array of all variables in template. + * * @return string[] */ public function getVariables() @@ -174,7 +177,7 @@ public function getVariables() } /** - * Clone a table row in a template document + * Clone a table row in a template document. * * @param string $search * @param integer $numberOfClones @@ -230,7 +233,7 @@ public function cloneRow($search, $numberOfClones) } /** - * Clone a block + * Clone a block. * * @param string $blockname * @param integer $clones @@ -266,10 +269,11 @@ public function cloneBlock($blockname, $clones = 1, $replace = true) } /** - * Replace a block + * Replace a block. * * @param string $blockname * @param string $replacement + * @return void */ public function replaceBlock($blockname, $replacement) { @@ -289,9 +293,10 @@ public function replaceBlock($blockname, $replacement) } /** - * Delete a block of text + * Delete a block of text. * * @param string $blockname + * @return void */ public function deleteBlock($blockname) { @@ -299,7 +304,7 @@ public function deleteBlock($blockname) } /** - * Save XML to temporary file + * Save XML to temporary file. * * @return string * @throws \PhpOffice\PhpWord\Exception\Exception @@ -325,10 +330,12 @@ public function save() } /** - * Save XML to defined name + * Save XML to defined name. * - * @param string $fileName * @since 0.8.0 + * + * @param string $fileName + * @return void */ public function saveAs($fileName) { @@ -375,7 +382,8 @@ protected function setValueForPart($documentPartXML, $search, $replace, $limit) } /** - * Find all variables in $documentPartXML + * Find all variables in $documentPartXML. + * * @param string $documentPartXML * @return string[] */ @@ -387,7 +395,8 @@ protected function getVariablesForPart($documentPartXML) } /** - * Get the name of the footer file for $index + * Get the name of the footer file for $index. + * * @param integer $index * @return string */ @@ -397,7 +406,8 @@ private function getFooterName($index) } /** - * Get the name of the header file for $index + * Get the name of the header file for $index. + * * @param integer $index * @return string */ @@ -407,7 +417,7 @@ private function getHeaderName($index) } /** - * Find the start position of the nearest table row before $offset + * Find the start position of the nearest table row before $offset. * * @param integer $offset * @return integer @@ -426,7 +436,7 @@ private function findRowStart($offset) } /** - * Find the end position of the nearest table row after $offset + * Find the end position of the nearest table row after $offset. * * @param integer $offset * @return integer @@ -438,7 +448,7 @@ private function findRowEnd($offset) } /** - * Get a slice of a string + * Get a slice of a string. * * @param integer $startPosition * @param integer $endPosition From 52406daee1cc01db8e77278e3877889a55b06850 Mon Sep 17 00:00:00 2001 From: Bas-Jan 't Jong Date: Wed, 2 Jul 2014 22:13:54 +0200 Subject: [PATCH 066/174] For absolute positioning vPos and hPos need to be set to POS_ABSOLUTE --- src/PhpWord/Style/Frame.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index 21b2771602..9a7997e220 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -362,7 +362,7 @@ public function getHPos() */ public function setHPos($value) { - $enum = array(self::POS_LEFT, self::POS_CENTER, self::POS_RIGHT, self::POS_INSIDE, self::POS_OUTSIDE); + $enum = array(self::POS_LEFT, self::POS_CENTER, self::POS_RIGHT, self::POS_INSIDE, self::POS_OUTSIDE, self::POS_ABSOLUTE); $this->hPos = $this->setEnumVal($value, $enum, $this->hPos); return $this; @@ -386,7 +386,7 @@ public function getVPos() */ public function setVPos($value) { - $enum = array(self::POS_TOP, self::POS_CENTER, self::POS_BOTTOM, self::POS_INSIDE, self::POS_OUTSIDE); + $enum = array(self::POS_TOP, self::POS_CENTER, self::POS_BOTTOM, self::POS_INSIDE, self::POS_OUTSIDE, self::POS_ABSOLUTE); $this->vPos = $this->setEnumVal($value, $enum, $this->vPos); return $this; From 20d986b11dcf28c0210ff28279a6844f16b4077b Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 3 Jul 2014 11:44:10 +0400 Subject: [PATCH 067/174] [CHANGED] Documentation on Zip API providers. --- docs/general.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/general.rst b/docs/general.rst index c6a893bc0d..8fc7130eb5 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -75,11 +75,10 @@ during development to make the resulting XML file easier to read. Zip class ~~~~~~~~~ -By default, PHPWord uses PHP -`ZipArchive `__ to read or write -ZIP compressed archive and the files inside them. If you can't have -ZipArchive installed on your server, you can use pure PHP library -alternative, `PCLZip `__, which +By default, PHPWord uses `Zip extension `__ +to deal with ZIP compressed archives and files inside them. If you can't have +Zip extension installed on your server, you can use pure PHP library +alternative, `PclZip `__, which included with PHPWord. .. code-block:: php From d0a609bc958e4c0d3b69e178d6220f61ef1cba09 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 3 Jul 2014 15:40:24 +0400 Subject: [PATCH 068/174] [CHANGED] Added "@return" annotation where it as missed. --- src/PhpWord/Autoloader.php | 1 + src/PhpWord/Collection/AbstractCollection.php | 3 +- src/PhpWord/Element/AbstractElement.php | 25 +++++++--- src/PhpWord/Element/Chart.php | 4 +- src/PhpWord/Element/Footer.php | 6 ++- src/PhpWord/Element/Image.php | 19 ++++--- src/PhpWord/Element/ListItemRun.php | 8 ++- src/PhpWord/Element/Object.php | 3 +- src/PhpWord/Element/Section.php | 3 +- src/PhpWord/Element/TOC.php | 6 ++- src/PhpWord/Element/Table.php | 3 +- src/PhpWord/PhpWord.php | 6 ++- src/PhpWord/Reader/ODText.php | 3 +- src/PhpWord/Reader/ODText/Content.php | 3 +- src/PhpWord/Reader/ODText/Meta.php | 3 +- src/PhpWord/Reader/RTF/Document.php | 49 +++++++++++++------ src/PhpWord/Reader/Word2007.php | 3 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 18 ++++--- src/PhpWord/Reader/Word2007/DocPropsCore.php | 3 +- .../Reader/Word2007/DocPropsCustom.php | 3 +- src/PhpWord/Reader/Word2007/Document.php | 14 ++++-- src/PhpWord/Reader/Word2007/Footnotes.php | 3 +- src/PhpWord/Reader/Word2007/Numbering.php | 3 +- src/PhpWord/Reader/Word2007/Styles.php | 3 +- src/PhpWord/Settings.php | 8 ++- src/PhpWord/Shared/Html.php | 9 ++-- src/PhpWord/Shared/String.php | 4 +- src/PhpWord/Shared/XMLWriter.php | 3 ++ src/PhpWord/Style.php | 5 +- src/PhpWord/Style/Cell.php | 16 ++++-- src/PhpWord/Style/TextBox.php | 21 +++++--- src/PhpWord/Template.php | 1 + src/PhpWord/Writer/AbstractWriter.php | 26 ++++++---- src/PhpWord/Writer/HTML.php | 6 ++- .../Writer/HTML/Element/AbstractElement.php | 3 +- src/PhpWord/Writer/HTML/Element/Text.php | 10 ++-- src/PhpWord/Writer/HTML/Part/AbstractPart.php | 3 +- src/PhpWord/Writer/HTML/Part/Head.php | 3 +- .../Writer/HTML/Style/AbstractStyle.php | 3 +- src/PhpWord/Writer/ODText.php | 5 +- .../Writer/ODText/Part/AbstractPart.php | 10 +++- src/PhpWord/Writer/ODText/Part/Content.php | 19 +++++-- src/PhpWord/Writer/ODText/Part/Meta.php | 1 + src/PhpWord/Writer/ODText/Part/Styles.php | 21 ++++++-- src/PhpWord/Writer/ODText/Style/Font.php | 4 +- src/PhpWord/Writer/ODText/Style/Image.php | 4 +- src/PhpWord/Writer/ODText/Style/Paragraph.php | 4 +- src/PhpWord/Writer/ODText/Style/Section.php | 4 +- src/PhpWord/Writer/ODText/Style/Table.php | 4 +- src/PhpWord/Writer/PDF/AbstractRenderer.php | 1 + src/PhpWord/Writer/PDF/DomPDF.php | 3 +- src/PhpWord/Writer/PDF/MPDF.php | 3 +- src/PhpWord/Writer/PDF/TCPDF.php | 3 +- src/PhpWord/Writer/RTF.php | 18 +++++-- .../Writer/RTF/Element/AbstractElement.php | 4 +- src/PhpWord/Writer/RTF/Part/Header.php | 23 ++++++--- src/PhpWord/Writer/RTF/Style/Border.php | 6 ++- src/PhpWord/Writer/RTF/Style/Font.php | 7 ++- src/PhpWord/Writer/RTF/Style/Paragraph.php | 3 +- src/PhpWord/Writer/Word2007.php | 16 ++++-- .../Word2007/Element/AbstractElement.php | 18 +++++-- src/PhpWord/Writer/Word2007/Element/Chart.php | 4 +- .../Writer/Word2007/Element/CheckBox.php | 4 +- .../Writer/Word2007/Element/Container.php | 6 ++- src/PhpWord/Writer/Word2007/Element/Field.php | 4 +- .../Writer/Word2007/Element/Footnote.php | 4 +- .../Writer/Word2007/Element/FormField.php | 19 +++++-- src/PhpWord/Writer/Word2007/Element/Image.php | 13 +++-- src/PhpWord/Writer/Word2007/Element/Line.php | 4 +- src/PhpWord/Writer/Word2007/Element/Link.php | 4 +- .../Writer/Word2007/Element/ListItem.php | 4 +- .../Writer/Word2007/Element/ListItemRun.php | 4 +- .../Writer/Word2007/Element/Object.php | 4 +- .../Writer/Word2007/Element/PageBreak.php | 3 +- .../Writer/Word2007/Element/PreserveText.php | 4 +- src/PhpWord/Writer/Word2007/Element/SDT.php | 19 +++++-- src/PhpWord/Writer/Word2007/Element/Shape.php | 21 +++++--- src/PhpWord/Writer/Word2007/Element/TOC.php | 12 ++++- src/PhpWord/Writer/Word2007/Element/Table.php | 22 +++++++-- src/PhpWord/Writer/Word2007/Element/Text.php | 4 +- .../Writer/Word2007/Element/TextBox.php | 4 +- .../Writer/Word2007/Element/TextBreak.php | 4 +- .../Writer/Word2007/Element/TextRun.php | 4 +- src/PhpWord/Writer/Word2007/Element/Title.php | 4 +- .../Writer/Word2007/Part/AbstractPart.php | 3 +- src/PhpWord/Writer/Word2007/Part/Chart.php | 25 +++++++--- .../Writer/Word2007/Part/ContentTypes.php | 1 + src/PhpWord/Writer/Word2007/Part/Document.php | 6 ++- .../Writer/Word2007/Part/FontTable.php | 4 +- .../Writer/Word2007/Part/Footnotes.php | 3 +- .../Writer/Word2007/Part/Numbering.php | 20 ++++++-- src/PhpWord/Writer/Word2007/Part/Rels.php | 9 ++-- src/PhpWord/Writer/Word2007/Part/Settings.php | 15 ++++-- src/PhpWord/Writer/Word2007/Part/Styles.php | 14 ++++-- .../Writer/Word2007/Style/AbstractStyle.php | 5 +- .../Writer/Word2007/Style/Alignment.php | 4 +- src/PhpWord/Writer/Word2007/Style/Cell.php | 7 ++- .../Writer/Word2007/Style/Extrusion.php | 4 +- src/PhpWord/Writer/Word2007/Style/Fill.php | 4 +- src/PhpWord/Writer/Word2007/Style/Font.php | 11 +++-- src/PhpWord/Writer/Word2007/Style/Frame.php | 11 +++-- .../Writer/Word2007/Style/Indentation.php | 4 +- src/PhpWord/Writer/Word2007/Style/Line.php | 3 +- .../Writer/Word2007/Style/LineNumbering.php | 4 +- .../Writer/Word2007/Style/MarginBorder.php | 16 ++++-- src/PhpWord/Writer/Word2007/Style/Outline.php | 4 +- .../Writer/Word2007/Style/Paragraph.php | 22 ++++++--- src/PhpWord/Writer/Word2007/Style/Row.php | 7 ++- src/PhpWord/Writer/Word2007/Style/Section.php | 4 +- src/PhpWord/Writer/Word2007/Style/Shading.php | 4 +- src/PhpWord/Writer/Word2007/Style/Shadow.php | 4 +- src/PhpWord/Writer/Word2007/Style/Shape.php | 4 +- src/PhpWord/Writer/Word2007/Style/Spacing.php | 4 +- src/PhpWord/Writer/Word2007/Style/Tab.php | 4 +- src/PhpWord/Writer/Word2007/Style/Table.php | 40 ++++++++++++--- src/PhpWord/Writer/Word2007/Style/TextBox.php | 8 ++- 116 files changed, 688 insertions(+), 262 deletions(-) diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index dbc4218705..68da845de3 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -41,6 +41,7 @@ public static function register($throw = true, $prepend = false) * Autoload * * @param string $class + * @return void */ public static function autoload($class) { diff --git a/src/PhpWord/Collection/AbstractCollection.php b/src/PhpWord/Collection/AbstractCollection.php index ae1b6efbe5..41e40e2e9e 100644 --- a/src/PhpWord/Collection/AbstractCollection.php +++ b/src/PhpWord/Collection/AbstractCollection.php @@ -57,10 +57,11 @@ public function getItem($index) } /** - * Set item + * Set item. * * @param int $index * @param mixed $item + * @return void */ public function setItem($index, $item) { diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 3fd2e4d01a..82aa543ec4 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -126,9 +126,10 @@ public function getPhpWord() } /** - * Set PhpWord as reference + * Set PhpWord as reference. * - * @param \PhpOffice\PhpWord\PhpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @return void */ public function setPhpWord(PhpWord &$phpWord = null) { @@ -146,10 +147,11 @@ public function getSectionId() } /** - * Set doc part + * Set doc part. * * @param string $docPart * @param int $docPartId + * @return void */ public function setDocPart($docPart, $docPartId = 1) { @@ -203,9 +205,10 @@ public function getElementIndex() } /** - * Set element index + * Set element index. * * @param int $value + * @return void */ public function setElementIndex($value) { @@ -223,7 +226,9 @@ public function getElementId() } /** - * Set element unique ID from 6 first digit of md5 + * Set element unique ID from 6 first digit of md5. + * + * @return void */ public function setElementId() { @@ -241,9 +246,10 @@ public function getRelationId() } /** - * Set relation Id + * Set relation Id. * * @param int $value + * @return void */ public function setRelationId($value) { @@ -266,6 +272,7 @@ public function getNestedLevel() * Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell) * * @param \PhpOffice\PhpWord\Element\AbstractElement $container + * @return void */ public function setParentContainer(AbstractElement $container) { @@ -295,6 +302,8 @@ public function setParentContainer(AbstractElement $container) * * - Image element needs to be passed to Media object * - Icon needs to be set for Object element + * + * @return void */ private function setMediaRelation() { @@ -320,7 +329,9 @@ private function setMediaRelation() } /** - * Set relation Id for elements that will be registered in the Collection subnamespaces + * Set relation Id for elements that will be registered in the Collection subnamespaces. + * + * @return void */ private function setCollectionRelation() { diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php index 2d709b8ca0..66c59ff52c 100644 --- a/src/PhpWord/Element/Chart.php +++ b/src/PhpWord/Element/Chart.php @@ -80,9 +80,10 @@ public function getType() } /** - * Set type + * Set type. * * @param string $value + * @return void */ public function setType($value) { @@ -95,6 +96,7 @@ public function setType($value) * * @param array $categories * @param array $values + * @return void */ public function addSeries($categories, $values) { diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 142ccfda1a..8e19eaf7db 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -59,10 +59,12 @@ public function __construct($sectionId, $containerId = 1, $type = self::AUTO) } /** - * Set type + * Set type. * - * @param string $value * @since 0.10.0 + * + * @param string $value + * @return void */ public function setType($value = self::AUTO) { diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 532905f428..e48f703ed1 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -257,9 +257,10 @@ public function getTarget() } /** - * Set target file name + * Set target file name. * * @param string $value + * @return void */ public function setTarget($value) { @@ -277,9 +278,10 @@ public function getMediaIndex() } /** - * Set media index + * Set media index. * * @param integer $value + * @return void */ public function setMediaIndex($value) { @@ -358,9 +360,10 @@ public function getImageStringData($base64 = false) } /** - * Check memory image, supported type, image functions, and proportional width/height + * Check memory image, supported type, image functions, and proportional width/height. * * @param string $source + * @return void * @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException */ @@ -395,9 +398,10 @@ private function checkImage($source) } /** - * Set source type + * Set source type. * * @param string $source + * @return void */ private function setSourceType($source) { @@ -443,7 +447,9 @@ private function getArchiveImageSize($source) } /** - * Set image functions and extensions + * Set image functions and extensions. + * + * @return void */ private function setFunctions() { @@ -476,10 +482,11 @@ private function setFunctions() } /** - * Set proportional width/height if one dimension not available + * Set proportional width/height if one dimension not available. * * @param integer $actualWidth * @param integer $actualHeight + * @return void */ private function setProportionalSize($actualWidth, $actualHeight) { diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php index 82c6f1ab8c..1b77830db3 100644 --- a/src/PhpWord/Element/ListItemRun.php +++ b/src/PhpWord/Element/ListItemRun.php @@ -65,7 +65,9 @@ public function __construct($depth = 0, $listStyle = null, $paragraphStyle = nul } /** - * Get ListItem style + * Get ListItem style. + * + * @return \PhpOffice\PhpWord\Style\ListItem */ public function getStyle() { @@ -73,7 +75,9 @@ public function getStyle() } /** - * Get ListItem depth + * Get ListItem depth. + * + * @return int */ public function getDepth() { diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index ae279ab020..31943ba68a 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -129,9 +129,10 @@ public function getImageRelationId() } /** - * Set Image Relation ID + * Set Image Relation ID. * * @param int $rId + * @return void */ public function setImageRelationId($rId) { diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 33c6979597..d746f69bb3 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -66,9 +66,10 @@ public function __construct($sectionCount, $style = null) } /** - * Set section style + * Set section style. * * @param array $style + * @return void */ public function setStyle($style = null) { diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php index 9ac745545c..a56d9ffe40 100644 --- a/src/PhpWord/Element/TOC.php +++ b/src/PhpWord/Element/TOC.php @@ -129,9 +129,10 @@ public function getStyleFont() } /** - * Set max depth + * Set max depth. * * @param int $value + * @return void */ public function setMaxDepth($value) { @@ -149,9 +150,10 @@ public function getMaxDepth() } /** - * Set min depth + * Set min depth. * * @param int $value + * @return void */ public function setMinDepth($value) { diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 5e14d6bc4b..5f0b8f7953 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -118,9 +118,10 @@ public function getWidth() } /** - * Set table width + * Set table width. * * @param int $width + * @return void */ public function setWidth($width) { diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 7c5cbbfe2b..3b991e2321 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -218,9 +218,10 @@ public function getDefaultFontName() } /** - * Set default font name + * Set default font name. * * @param string $fontName + * @return void */ public function setDefaultFontName($fontName) { @@ -238,9 +239,10 @@ public function getDefaultFontSize() } /** - * Set default font size + * Set default font size. * * @param int $fontSize + * @return void */ public function setDefaultFontSize($fontSize) { diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index 19efdc5170..d7d23c8064 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -51,13 +51,14 @@ public function load($docFile) } /** - * Read document part + * Read document part. * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param array $relationships * @param string $partName * @param string $docFile * @param string $xmlFile + * @return void */ private function readPart(PhpWord &$phpWord, $relationships, $partName, $docFile, $xmlFile) { diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index 034789ff6a..9feb669a2b 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -28,9 +28,10 @@ class Content extends AbstractPart { /** - * Read content.xml + * Read content.xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php index 518884fdc8..827446f0ad 100644 --- a/src/PhpWord/Reader/ODText/Meta.php +++ b/src/PhpWord/Reader/ODText/Meta.php @@ -28,9 +28,10 @@ class Meta extends AbstractPart { /** - * Read meta.xml + * Read meta.xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void * @todo Process property type */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index cb082fdc63..26763576cd 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -130,6 +130,7 @@ class Document * - Pushes every other character into the text queue * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void * @todo Use `fread` stream for scalability */ public function read(PhpWord &$phpWord) @@ -181,7 +182,9 @@ public function read(PhpWord &$phpWord) } /** - * Mark opening braket `{` character + * Mark opening braket `{` character. + * + * @return void */ private function markOpening() { @@ -190,7 +193,9 @@ private function markOpening() } /** - * Mark closing braket `}` character + * Mark closing braket `}` character. + * + * @return void */ private function markClosing() { @@ -199,7 +204,9 @@ private function markClosing() } /** - * Mark backslash `\` character + * Mark backslash `\` character. + * + * @return void */ private function markBackslash() { @@ -214,7 +221,9 @@ private function markBackslash() } /** - * Mark newline character: Flush control word because it's not possible to span multiline + * Mark newline character: Flush control word because it's not possible to span multiline. + * + * @return void */ private function markNewline() { @@ -224,9 +233,10 @@ private function markNewline() } /** - * Flush control word or text + * Flush control word or text. * * @param bool $isControl + * @return void */ private function flush($isControl = false) { @@ -238,9 +248,10 @@ private function flush($isControl = false) } /** - * Flush control word + * Flush control word. * * @param bool $isControl + * @return void */ private function flushControl($isControl = false) { @@ -255,7 +266,9 @@ private function flushControl($isControl = false) } /** - * Flush text in queue + * Flush text in queue. + * + * @return void */ private function flushText() { @@ -279,9 +292,10 @@ private function flushText() } /** - * Reset control word and first char state + * Reset control word and first char state. * * @param bool $value + * @return void */ private function setControl($value) { @@ -290,9 +304,10 @@ private function setControl($value) } /** - * Push text into queue + * Push text into queue. * * @param string $char + * @return void */ private function pushText($char) { @@ -306,10 +321,11 @@ private function pushText($char) } /** - * Parse control + * Parse control. * * @param string $control * @param string $parameter + * @return void */ private function parseControl($control, $parameter) { @@ -346,9 +362,10 @@ private function parseControl($control, $parameter) } /** - * Read paragraph + * Read paragraph. * * @param array $directives + * @return void */ private function readParagraph($directives) { @@ -358,9 +375,10 @@ private function readParagraph($directives) } /** - * Read style + * Read style. * * @param array $directives + * @return void */ private function readStyle($directives) { @@ -369,9 +387,10 @@ private function readStyle($directives) } /** - * Read skip + * Read skip. * * @param array $directives + * @return void */ private function readSkip($directives) { @@ -381,7 +400,9 @@ private function readSkip($directives) } /** - * Read text + * Read text. + * + * @return void */ private function readText() { diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 70d5f60b77..acf4048379 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -75,13 +75,14 @@ public function load($docFile) } /** - * Read document part + * Read document part. * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param array $relationships * @param string $partName * @param string $docFile * @param string $xmlFile + * @return void */ private function readPart(PhpWord &$phpWord, $relationships, $partName, $docFile, $xmlFile) { diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index ac26dee58e..0309f1938d 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -62,7 +62,7 @@ abstract class AbstractPart protected $rels = array(); /** - * Read part + * Read part. */ abstract public function read(PhpWord &$phpWord); @@ -79,9 +79,10 @@ public function __construct($docFile, $xmlFile) } /** - * Set relationships + * Set relationships. * * @param array $value + * @return void */ public function setRels($value) { @@ -89,12 +90,13 @@ public function setRels($value) } /** - * Read w:p + * Read w:p. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart + * @return void * * @todo Get font style for preserve text */ @@ -179,13 +181,14 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p } /** - * Read w:r + * Read w:r. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart * @param mixed $paragraphStyle + * @return void * * @todo Footnote paragraph style */ @@ -241,12 +244,13 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, } /** - * Read w:tbl + * Read w:tbl. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode * @param mixed $parent * @param string $docPart + * @return void */ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart = 'document') { @@ -301,7 +305,7 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, &$paren } /** - * Read w:pPr + * Read w:pPr. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode @@ -337,7 +341,7 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @return array + * @return array|null */ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode) { diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index e50f295be8..d8a8768dbe 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -52,9 +52,10 @@ class DocPropsCore extends AbstractPart protected $callbacks = array('dcterms:created' => 'strtotime', 'dcterms:modified' => 'strtotime'); /** - * Read core/extended document properties + * Read core/extended document properties. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 54fe39eeba..5f99495eac 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -29,9 +29,10 @@ class DocPropsCustom extends AbstractPart { /** - * Read custom document properties + * Read custom document properties. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 0208418924..1d51819f89 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -17,9 +17,9 @@ namespace PhpOffice\PhpWord\Reader\Word2007; +use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLReader; -use PhpOffice\PhpWord\Element\Section; /** * Document reader @@ -37,9 +37,10 @@ class Document extends AbstractPart private $phpWord; /** - * Read document.xml + * Read document.xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { @@ -61,10 +62,11 @@ public function read(PhpWord &$phpWord) } /** - * Read header footer + * Read header footer. * * @param array $settings * @param \PhpOffice\PhpWord\Element\Section $section + * @return void */ private function readHeaderFooter($settings, Section &$section) { @@ -138,11 +140,12 @@ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode) } /** - * Read w:p node + * Read w:p node. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $node * @param \PhpOffice\PhpWord\Element\Section $section + * @return void * * @todo */ @@ -167,11 +170,12 @@ private function readWPNode(XMLReader $xmlReader, \DOMElement $node, Section &$s } /** - * Read w:sectPr node + * Read w:sectPr node. * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $node * @param \PhpOffice\PhpWord\Element\Section $section + * @return void */ private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section) { diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index 47713cfbb7..fd3510146b 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -42,9 +42,10 @@ class Footnotes extends AbstractPart protected $element = 'footnote'; /** - * Read (footnotes|endnotes).xml + * Read (footnotes|endnotes).xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index 2dd3f5217b..bc34bd68d4 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -28,9 +28,10 @@ class Numbering extends AbstractPart { /** - * Read numbering.xml + * Read numbering.xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index 7dc4b6eaac..00010af6c1 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -28,9 +28,10 @@ class Styles extends AbstractPart { /** - * Read styles.xml + * Read styles.xml. * * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ public function read(PhpWord &$phpWord) { diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index cb74389a20..8481717b49 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -188,7 +188,9 @@ public static function setPdfRenderer($libraryName, $libraryBaseDir) } /** - * Return the PDF Rendering Library + * Return the PDF Rendering Library. + * + * @return string */ public static function getPdfRendererName() { @@ -214,7 +216,9 @@ public static function setPdfRendererName($libraryName) /** - * Return the directory path to the PDF Rendering Library + * Return the directory path to the PDF Rendering Library. + * + * @return string */ public static function getPdfRendererPath() { diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index fc23b5b0a8..86d466db97 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -27,13 +27,14 @@ class Html { /** - * Add HTML parts + * Add HTML parts. * * 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 bool $fullHTML If it's a full HTML, no need to add 'body' tag + * @return void */ public static function addHtml($element, $html, $fullHTML = false) { @@ -88,12 +89,13 @@ protected static function parseInlineStyle($node, $styles = array()) } /** - * Parse a node and add a corresponding element to the parent element + * Parse a node and add a corresponding element to the parent element. * * @param \DOMNode $node node to parse * @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 + * @return void */ protected static function parseNode($node, $element, $styles = array(), $data = array()) { @@ -162,12 +164,13 @@ protected static function parseNode($node, $element, $styles = array(), $data = } /** - * Parse child nodes + * Parse child nodes. * * @param \DOMNode $node * @param \PhpOffice\PhpWord\Element\AbstractContainer $element * @param array $styles * @param array $data + * @return void */ private static function parseChildNodes($node, $element, $styles, $data) { diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 1e4504cc01..be04fd0ec7 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -178,7 +178,9 @@ public static function removeUnderscorePrefix($value) } /** - * Build control characters array + * Build control characters array. + * + * @return void */ private static function buildControlCharacters() { diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 8691ae1d9c..3d8b845786 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -149,6 +149,7 @@ public function getData() * @param string $element * @param string|array $attributes * @param string $value + * @return void */ public function writeElementBlock($element, $attributes, $value = null) { @@ -169,6 +170,7 @@ public function writeElementBlock($element, $attributes, $value = null) * @param string $element * @param string $attribute * @param mixed $value + * @return void */ public function writeElementIf($condition, $element, $attribute = null, $value = null) { @@ -189,6 +191,7 @@ public function writeElementIf($condition, $element, $attribute = null, $value = * @param bool $condition * @param string $attribute * @param mixed $value + * @return void */ public function writeAttributeIf($condition, $attribute, $value) { diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index d56c73feca..73af4f5dfd 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -123,8 +123,11 @@ public static function countStyles() } /** - * Reset styles + * Reset styles. + * * @since 0.10.0 + * + * @return void */ public static function resetStyles() { diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 2d1b88d08f..11290c8752 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -94,7 +94,9 @@ class Cell extends Border private $shading; /** - * Get vertical align + * Get vertical align. + * + * @return string */ public function getVAlign() { @@ -116,7 +118,9 @@ public function setVAlign($value = null) } /** - * Get text direction + * Get text direction. + * + * @return string */ public function getTextDirection() { @@ -163,7 +167,9 @@ public function setBgColor($value = null) } /** - * Get grid span (colspan) + * Get grid span (colspan). + * + * @return integer */ public function getGridSpan() { @@ -184,7 +190,9 @@ public function setGridSpan($value = null) } /** - * Get vertical merge (rowspan) + * Get vertical merge (rowspan). + * + * @return string */ public function getVMerge() { diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php index 9f0a1ddec7..6220b74096 100644 --- a/src/PhpWord/Style/TextBox.php +++ b/src/PhpWord/Style/TextBox.php @@ -67,9 +67,10 @@ class TextBox extends Image private $borderColor; /** - * Set margin top + * Set margin top. * * @param int $value + * @return void */ public function setInnerMarginTop($value = null) { @@ -87,9 +88,10 @@ public function getInnerMarginTop() } /** - * Set margin left + * Set margin left. * * @param int $value + * @return void */ public function setInnerMarginLeft($value = null) { @@ -107,9 +109,10 @@ public function getInnerMarginLeft() } /** - * Set margin right + * Set margin right. * * @param int $value + * @return void */ public function setInnerMarginRight($value = null) { @@ -127,9 +130,10 @@ public function getInnerMarginRight() } /** - * Set margin bottom + * Set margin bottom. * * @param int $value + * @return void */ public function setInnerMarginBottom($value = null) { @@ -147,9 +151,10 @@ public function getInnerMarginBottom() } /** - * Set TLRB cell margin + * Set TLRB cell margin. * * @param int $value Margin in twips + * @return void */ public function setInnerMargin($value = null) { @@ -188,9 +193,10 @@ public function hasInnerMargins() } /** - * Set border size + * Set border size. * * @param int $value Size in points + * @return void */ public function setBorderSize($value = null) { @@ -208,9 +214,10 @@ public function getBorderSize() } /** - * Set border color + * Set border color. * * @param string $value + * @return void */ public function setBorderColor($value = null) { diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index fc224d14de..2d9945749a 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -181,6 +181,7 @@ public function getVariables() * * @param string $search * @param integer $numberOfClones + * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ public function cloneRow($search, $numberOfClones) diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 8e7cb71d2c..58ec89b006 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -233,8 +233,9 @@ protected function getTempFile($filename) } /** - * Cleanup temporary file + * Cleanup temporary file. * + * @return void * @throws \PhpOffice\PhpWord\Exception\CopyFileException */ protected function cleanupTempFile() @@ -253,7 +254,9 @@ protected function cleanupTempFile() } /** - * Clear temporary directory + * Clear temporary directory. + * + * @return void */ protected function clearTempDir() { @@ -314,11 +317,13 @@ protected function openFile($filename) } /** - * Write content to file + * Write content to file. * - * @param resource $fileHandle - * @param string $content * @since 0.11.0 + * + * @param resource &$fileHandle + * @param string $content + * @return void */ protected function writeFile(&$fileHandle, $content) { @@ -328,10 +333,11 @@ protected function writeFile(&$fileHandle, $content) } /** - * Add files to package + * Add files to package. * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param mixed $elements + * @return void */ protected function addFilesToPackage(ZipArchive $zip, $elements) { @@ -360,13 +366,14 @@ protected function addFilesToPackage(ZipArchive $zip, $elements) } /** - * Add file to package + * Add file to package. * - * Get the actual source from an archive image + * Get the actual source from an archive image. * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zipPackage * @param string $source * @param string $target + * @return void */ protected function addFileToPackage($zipPackage, $source, $target) { @@ -394,9 +401,10 @@ protected function addFileToPackage($zipPackage, $source, $target) } /** - * Delete directory + * Delete directory. * * @param string $dir + * @return void */ private function deleteDir($dir) { diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 29173ff23c..502c50e981 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -61,9 +61,10 @@ public function __construct(PhpWord $phpWord = null) } /** - * Save PhpWord to file + * Save PhpWord to file. * * @param string $filename + * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ public function save($filename = null) @@ -113,10 +114,11 @@ public function getNotes() } /** - * Add note + * Add note. * * @param int $noteId * @param string $noteMark + * @return void */ public function addNote($noteId, $noteMark) { diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php index 53b994df09..73f88d3d8d 100644 --- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php +++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php @@ -68,9 +68,10 @@ public function __construct(AbstractWriter $parentWriter, Element $element, $wit } /** - * Set without paragraph + * Set without paragraph. * * @param bool $value + * @return void */ public function setWithoutP($value) { diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index 52e7a6b5a5..c2d4134a52 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -81,9 +81,10 @@ public function write() } /** - * Set opening text + * Set opening text. * * @param string $value + * @return void */ public function setOpeningText($value) { @@ -91,9 +92,10 @@ public function setOpeningText($value) } /** - * Set closing text + * Set closing text. * * @param string $value + * @return void */ public function setClosingText($value) { @@ -164,7 +166,9 @@ private function getParagraphStyle() } /** - * Get font style + * Get font style. + * + * @return void */ private function getFontStyle() { diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php index 319aa20fbf..124cc15a8a 100644 --- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php +++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php @@ -42,9 +42,10 @@ abstract class AbstractPart abstract public function write(); /** - * Set parent writer + * Set parent writer. * * @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer + * @return void */ public function setParentWriter(AbstractWriter $writer = null) { diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index 23e30b8d34..4bfe304651 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -18,9 +18,9 @@ namespace PhpOffice\PhpWord\Writer\HTML\Part; use PhpOffice\PhpWord\Settings; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +use PhpOffice\PhpWord\Style; 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; @@ -71,6 +71,7 @@ public function write() return $content; } + /** * Get styles * diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php index c729ec552b..07ef16184c 100644 --- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php @@ -56,9 +56,10 @@ public function __construct($style = null) } /** - * Set parent writer + * Set parent writer. * * @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer + * @return void */ public function setParentWriter($writer) { diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index f9c8d5d453..8fa364bec9 100644 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -60,9 +60,10 @@ public function __construct(PhpWord $phpWord = null) } /** - * Save PhpWord to file + * Save PhpWord to file. * - * @param string $filename + * @param string $filename + * @return void */ public function save($filename = null) { diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index 31118ef993..edc8d07f4f 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -34,7 +34,10 @@ abstract class AbstractPart extends Word2007AbstractPart protected $dateFormat = 'Y-m-d\TH:i:s.000'; /** - * Write common root attributes + * Write common root attributes. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ protected function writeCommonRootAttributes(XMLWriter $xmlWriter) { @@ -68,7 +71,10 @@ protected function writeCommonRootAttributes(XMLWriter $xmlWriter) } /** - * Write font faces declaration + * Write font faces declaration. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ protected function writeFontFaces(XMLWriter $xmlWriter) { diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 51326210ea..b2159d7dd4 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -23,10 +23,10 @@ use PhpOffice\PhpWord\Element\TextRun; 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 as TableStyle; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\ODText\Element\Container; use PhpOffice\PhpWord\Writer\ODText\Style\Paragraph as ParagraphStyleWriter; @@ -106,9 +106,12 @@ public function write() } /** - * Write automatic styles other than fonts and paragraphs + * Write automatic styles other than fonts and paragraphs. * * @since 0.11.0 + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeAutoStyles(XMLWriter $xmlWriter) { @@ -129,7 +132,10 @@ private function writeAutoStyles(XMLWriter $xmlWriter) } /** - * Write automatic styles + * Write automatic styles. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeTextStyles(XMLWriter $xmlWriter) { @@ -160,7 +166,10 @@ private function writeTextStyles(XMLWriter $xmlWriter) } /** - * Get automatic styles + * Get automatic styles. + * + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return void */ private function getAutoStyles(PhpWord $phpWord) { @@ -183,6 +192,7 @@ private function getAutoStyles(PhpWord $phpWord) * @param \PhpOffice\PhpWord\Element\AbstractContainer $container * @param int $paragraphStyleCount * @param int $fontStyleCount + * @return void * @todo Simplify the logic */ private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyleCount) @@ -216,6 +226,7 @@ private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyl * @param \PhpOffice\PhpWord\Element\Text $element * @param int $paragraphStyleCount * @param int $fontStyleCount + * @return void */ private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount) { diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php index 9dab2e23bb..15c81a4e9c 100644 --- a/src/PhpWord/Writer/ODText/Part/Meta.php +++ b/src/PhpWord/Writer/ODText/Part/Meta.php @@ -89,6 +89,7 @@ public function write() * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $property * @param string $value + * @return void * * @todo Handle other `$type`: double|date|dateTime|duration|boolean (4th arguments) */ diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index b7864fe339..7522872d7e 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -61,7 +61,10 @@ public function write() } /** - * Write default styles + * Write default styles. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeDefault(XMLWriter $xmlWriter) { @@ -103,7 +106,10 @@ private function writeDefault(XMLWriter $xmlWriter) } /** - * Write named styles + * Write named styles. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeNamed(XMLWriter $xmlWriter) { @@ -122,7 +128,10 @@ private function writeNamed(XMLWriter $xmlWriter) } } /** - * Write page layout styles + * Write page layout styles. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writePageLayout(XMLWriter $xmlWriter) { @@ -170,8 +179,12 @@ private function writePageLayout(XMLWriter $xmlWriter) $xmlWriter->endElement(); // style:page-layout } + /** - * Write master style + * Write master style. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeMaster(XMLWriter $xmlWriter) { diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index acab0ee5c1..4518450555 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -25,7 +25,9 @@ class Font extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/ODText/Style/Image.php b/src/PhpWord/Writer/ODText/Style/Image.php index de97f474ea..21b9c4ee93 100644 --- a/src/PhpWord/Writer/ODText/Style/Image.php +++ b/src/PhpWord/Writer/ODText/Style/Image.php @@ -25,7 +25,9 @@ class Image extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php index 133b8cdf7b..03e605a196 100644 --- a/src/PhpWord/Writer/ODText/Style/Paragraph.php +++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php @@ -25,7 +25,9 @@ class Paragraph extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/ODText/Style/Section.php b/src/PhpWord/Writer/ODText/Style/Section.php index 3d910157a2..fa432856c7 100644 --- a/src/PhpWord/Writer/ODText/Style/Section.php +++ b/src/PhpWord/Writer/ODText/Style/Section.php @@ -25,7 +25,9 @@ class Section extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/ODText/Style/Table.php b/src/PhpWord/Writer/ODText/Style/Table.php index b32349af05..dbfb94ed84 100644 --- a/src/PhpWord/Writer/ODText/Style/Table.php +++ b/src/PhpWord/Writer/ODText/Style/Table.php @@ -25,7 +25,9 @@ class Table extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php index d4288c8a3f..572e4b1dfd 100644 --- a/src/PhpWord/Writer/PDF/AbstractRenderer.php +++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php @@ -190,6 +190,7 @@ protected function prepareForSave($filename = null) * Save PhpWord to PDF file, post-save * * @param resource $fileHandle + * @return void * @throws Exception */ protected function restoreStateAfterSave($fileHandle) diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php index a40e2ceac3..47054c4a48 100644 --- a/src/PhpWord/Writer/PDF/DomPDF.php +++ b/src/PhpWord/Writer/PDF/DomPDF.php @@ -35,9 +35,10 @@ class DomPDF extends AbstractRenderer implements WriterInterface protected $includeFile = 'dompdf_config.inc.php'; /** - * Save PhpWord to file + * Save PhpWord to file. * * @param string $filename Name of the file to save as + * @return void */ public function save($filename = null) { diff --git a/src/PhpWord/Writer/PDF/MPDF.php b/src/PhpWord/Writer/PDF/MPDF.php index 3fab05c345..46d456d4f7 100644 --- a/src/PhpWord/Writer/PDF/MPDF.php +++ b/src/PhpWord/Writer/PDF/MPDF.php @@ -35,9 +35,10 @@ class MPDF extends AbstractRenderer implements WriterInterface protected $includeFile = 'mpdf.php'; /** - * Save PhpWord to file + * Save PhpWord to file. * * @param string $filename Name of the file to save as + * @return void */ public function save($filename = null) { diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php index 3d3104de06..36849e24ad 100644 --- a/src/PhpWord/Writer/PDF/TCPDF.php +++ b/src/PhpWord/Writer/PDF/TCPDF.php @@ -35,9 +35,10 @@ class TCPDF extends AbstractRenderer implements WriterInterface protected $includeFile = 'tcpdf.php'; /** - * Save PhpWord to file + * Save PhpWord to file. * * @param string $filename Name of the file to save as + * @return vois */ public function save($filename = null) { diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index d7fed942dc..a5a5847507 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -55,9 +55,10 @@ public function __construct(PhpWord $phpWord = null) } /** - * Save content to file + * Save content to file. * * @param string $filename + * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ public function save($filename = null) @@ -86,7 +87,9 @@ private function getContent() } /** - * Get font table + * Get font table. + * + * @return array */ public function getFontTable() { @@ -94,7 +97,9 @@ public function getFontTable() } /** - * Get color table + * Get color table. + * + * @return array */ public function getColorTable() { @@ -102,7 +107,9 @@ public function getColorTable() } /** - * Get last paragraph style + * Get last paragraph style. + * + * @return mixed */ public function getLastParagraphStyle() { @@ -110,9 +117,10 @@ public function getLastParagraphStyle() } /** - * Set last paragraph style + * Set last paragraph style. * * @param mixed $value + * @return void */ public function setLastParagraphStyle($value = '') { diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index 79e139471b..73da5cbddb 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -47,7 +47,9 @@ abstract class AbstractElement extends HTMLAbstractElement private $paragraphStyle; /** - * Get font and paragraph styles + * Get font and paragraph styles. + * + * @return void */ protected function getStyles() { diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index 68cf1803e3..574bff762d 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -19,8 +19,8 @@ use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\Converter; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; +use PhpOffice\PhpWord\Style; /** * RTF header part writer @@ -52,7 +52,9 @@ class Header extends AbstractPart private $colorTable = array(); /** - * Get font table + * Get font table. + * + * @return array */ public function getFontTable() { @@ -60,7 +62,9 @@ public function getFontTable() } /** - * Get color table + * Get color table. + * + * @return array */ public function getColorTable() { @@ -176,7 +180,9 @@ private function writeGenerator() } /** - * Register all fonts and colors in both named and inline styles to appropriate header table + * Register all fonts and colors in both named and inline styles to appropriate header table. + * + * @return void */ private function registerFont() { @@ -204,9 +210,10 @@ private function registerFont() } /** - * Register border colors + * Register border colors. * * @param \PhpOffice\PhpWord\Style\Border $style + * @return void */ private function registerBorderColor($style) { @@ -219,9 +226,10 @@ private function registerBorderColor($style) } /** - * Register fonts and colors + * Register fonts and colors. * * @param \PhpOffice\PhpWord\Style\AbstractStyle $style + * @return void */ private function registerFontItems($style) { @@ -236,11 +244,12 @@ private function registerFontItems($style) } /** - * Register individual font and color + * Register individual font and color. * * @param array $table * @param string $value * @param string $default + * @return void */ private function registerTableItem(&$table, $value, $default = null) { diff --git a/src/PhpWord/Writer/RTF/Style/Border.php b/src/PhpWord/Writer/RTF/Style/Border.php index 8bb9703f43..88c517ad79 100644 --- a/src/PhpWord/Writer/RTF/Style/Border.php +++ b/src/PhpWord/Writer/RTF/Style/Border.php @@ -101,9 +101,10 @@ private function writeSide($side, $width, $color = '') } /** - * Set sizes + * Set sizes. * * @param integer[] $value + * @return void */ public function setSizes($value) { @@ -111,9 +112,10 @@ public function setSizes($value) } /** - * Set colors + * Set colors. * * @param string[] $value + * @return void */ public function setColors($value) { diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php index 9634b566cb..20c47aee08 100644 --- a/src/PhpWord/Writer/RTF/Style/Font.php +++ b/src/PhpWord/Writer/RTF/Style/Font.php @@ -66,9 +66,11 @@ public function write() } /** - * Set font name index + * Set font name index. + * * * @param int $value + * @return void */ public function setNameIndex($value = 0) { @@ -76,9 +78,10 @@ public function setNameIndex($value = 0) } /** - * Set font color index + * Set font color index. * * @param int $value + * @return void */ public function setColorIndex($value = 0) { diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php index b166cc2790..1a7de0a35b 100644 --- a/src/PhpWord/Writer/RTF/Style/Paragraph.php +++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php @@ -73,9 +73,10 @@ public function write() } /** - * Set nested level + * Set nested level. * * @param int $value + * @return void */ public function setNestedLevel($value) { diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index d15f40aca5..214715058d 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -88,9 +88,10 @@ public function __construct(PhpWord $phpWord = null) } /** - * Save document by name + * Save document by name. * * @param string $filename + * @return void */ public function save($filename = null) { @@ -163,10 +164,11 @@ public function getRelationships() } /** - * Add header/footer media files, e.g. footer1.xml.rels + * Add header/footer media files, e.g. footer1.xml.rels. * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param string $docPart + * @return void */ private function addHeaderFooterMedia(ZipArchive $zip, $docPart) { @@ -188,12 +190,13 @@ private function addHeaderFooterMedia(ZipArchive $zip, $docPart) } /** - * Add header/footer content + * Add header/footer content. * * @param \PhpOffice\PhpWord\Element\Section $section * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param string $elmType header|footer * @param integer $rId + * @return void */ private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elmType, &$rId) { @@ -220,6 +223,7 @@ private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elm * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param integer $rId * @param string $noteType + * @return void */ private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote') { @@ -252,10 +256,11 @@ private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote') } /** - * Add chart + * Add chart. * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param integer $rId + * @return void */ private function addChart(ZipArchive $zip, &$rId) { @@ -286,9 +291,10 @@ private function addChart(ZipArchive $zip, &$rId) } /** - * Register content types for each media + * Register content types for each media. * * @param array $media + * @return void */ private function registerContentTypes($media) { diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index b98b983dee..2c200f81ee 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -89,9 +89,10 @@ protected function getElement() } /** - * Start w:p DOM element + * Start w:p DOM element. * * @uses \PhpOffice\PhpWord\Writer\Word2007\Element\PageBreak::write() + * @return void */ protected function startElementP() { @@ -105,7 +106,9 @@ protected function startElementP() } /** - * End w:p DOM element + * End w:p DOM element. + * + * @return void */ protected function endElementP() { @@ -115,7 +118,9 @@ protected function endElementP() } /** - * Write ending + * Write ending. + * + * @return void */ protected function writeParagraphStyle() { @@ -123,7 +128,9 @@ protected function writeParagraphStyle() } /** - * Write ending + * Write ending. + * + * @return void */ protected function writeFontStyle() { @@ -132,9 +139,10 @@ protected function writeFontStyle() /** - * Write text style + * Write text style. * * @param string $styleType Font|Paragraph + * @return void */ private function writeTextStyle($styleType) { diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php index e185ee581d..ccd8cd77db 100644 --- a/src/PhpWord/Writer/Word2007/Element/Chart.php +++ b/src/PhpWord/Writer/Word2007/Element/Chart.php @@ -27,7 +27,9 @@ class Chart extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index d5f6a64e12..9d060726ff 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -25,7 +25,9 @@ class CheckBox extends Text { /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 9504b7a61b..771fe5c34e 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement; +use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; use PhpOffice\PhpWord\Shared\XMLWriter; @@ -37,7 +37,9 @@ class Container extends AbstractElement protected $namespace = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element'; /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php index 7133e83fe4..b9c3c34b81 100644 --- a/src/PhpWord/Writer/Word2007/Element/Field.php +++ b/src/PhpWord/Writer/Word2007/Element/Field.php @@ -25,7 +25,9 @@ class Field extends Text { /** - * Write field element + * Write field element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php index be5a21f13c..5640a90db4 100644 --- a/src/PhpWord/Writer/Word2007/Element/Footnote.php +++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php @@ -32,7 +32,9 @@ class Footnote extends Text protected $referenceType = 'footnoteReference'; /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php index 21003314af..432dc9c23b 100644 --- a/src/PhpWord/Writer/Word2007/Element/FormField.php +++ b/src/PhpWord/Writer/Word2007/Element/FormField.php @@ -35,7 +35,9 @@ class FormField extends Text const FILLER_LENGTH = 30; /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -102,9 +104,12 @@ public function write() } /** - * Write textinput + * Write textinput. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\FormField $element + * @return void */ private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element) { @@ -116,9 +121,12 @@ private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element) } /** - * Write checkbox + * Write checkbox. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\FormField $element + * @return void */ private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element) { @@ -137,9 +145,12 @@ private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element) } /** - * Write dropdown + * Write dropdown. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\FormField $element + * @return void */ private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element) { diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 02780ed1c1..7398842397 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -29,7 +29,9 @@ class Image extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -47,7 +49,9 @@ public function write() } /** - * Write image element + * Write image element. + * + * @return void */ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) { @@ -78,8 +82,11 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element) $this->endElementP(); } + /** - * Write watermark element + * Write watermark element. + * + * @return void */ private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element) { diff --git a/src/PhpWord/Writer/Word2007/Element/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php index ade5b8892a..a6c7c24081 100644 --- a/src/PhpWord/Writer/Word2007/Element/Line.php +++ b/src/PhpWord/Writer/Word2007/Element/Line.php @@ -27,7 +27,9 @@ class Line extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index d7e68ac15c..2a5a5ae1bb 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -25,7 +25,9 @@ class Link extends Text { /** - * Write link element + * Write link element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php index 7b86efaeb8..0f559a4e1d 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItem.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php @@ -27,7 +27,9 @@ class ListItem extends AbstractElement { /** - * Write list item element + * Write list item element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php index 747c262525..289cb05476 100644 --- a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php +++ b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php @@ -27,7 +27,9 @@ class ListItemRun extends AbstractElement { /** - * Write list item element + * Write list item element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php index f172f81b66..a9cc449abf 100644 --- a/src/PhpWord/Writer/Word2007/Element/Object.php +++ b/src/PhpWord/Writer/Word2007/Element/Object.php @@ -27,7 +27,9 @@ class Object extends AbstractElement { /** - * Write object element + * Write object element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php index be317089a6..fb831ca7ac 100644 --- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php @@ -25,9 +25,10 @@ class PageBreak extends AbstractElement { /** - * Write element + * Write element. * * @usedby \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement::startElementP() + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php index ef5b93cdb9..894b3050f3 100644 --- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php +++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php @@ -25,7 +25,9 @@ class PreserveText extends Text { /** - * Write preserve text element + * Write preserve text element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php index b41bb696e1..79d7004dd6 100644 --- a/src/PhpWord/Writer/Word2007/Element/SDT.php +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -30,7 +30,9 @@ class SDT extends Text { /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -68,9 +70,12 @@ public function write() } /** - * Write combo box + * Write combo box. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\SDT $element + * @return void */ private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element) { @@ -85,9 +90,12 @@ private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element) } /** - * Write drop down list + * Write drop down list. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\SDT $element + * @return void */ private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element) { @@ -95,9 +103,12 @@ private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element) } /** - * Write date + * Write date. * * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\SDT $element + * @return void */ private function writeDate(XMLWriter $xmlWriter, SDTElement $element) { diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php index 649e7384ca..bd9320a258 100644 --- a/src/PhpWord/Writer/Word2007/Element/Shape.php +++ b/src/PhpWord/Writer/Word2007/Element/Shape.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Shape as ShapeElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Shape as ShapeStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter; @@ -31,7 +31,9 @@ class Shape extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -74,10 +76,11 @@ public function write() } /** - * Write arc + * Write arc. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Shape $style + * @return void */ private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style) { @@ -88,10 +91,11 @@ private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style) } /** - * Write curve + * Write curve. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Shape $style + * @return void */ private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style) { @@ -103,10 +107,11 @@ private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style) } /** - * Write line + * Write line. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Shape $style + * @return void */ private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style) { @@ -117,10 +122,11 @@ private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style) } /** - * Write polyline + * Write polyline. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Shape $style + * @return void */ private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style) { @@ -128,10 +134,11 @@ private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style) } /** - * Write rectangle + * Write rectangle. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Shape $style + * @return void */ private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style) { diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 1db2efddbd..db2a65d07b 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -32,7 +32,9 @@ class TOC extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -68,6 +70,7 @@ public function write() * @param \PhpOffice\PhpWord\Element\TOC $element * @param \PhpOffice\PhpWord\Element\Title $title * @param bool $writeFieldMark + * @return void */ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $writeFieldMark) { @@ -135,6 +138,7 @@ private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $ * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Element\TOC $element * @param int $indent + * @return void */ private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent) { @@ -176,7 +180,11 @@ private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent) } /** - * Write TOC Field + * Write TOC Field. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\TOC $element + * @return void */ private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element) { diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 8cadfc384d..f090d05c89 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -35,7 +35,9 @@ class Table extends AbstractElement { /** - * Write element + * Write element. + * + * @return void */ public function write() { @@ -69,7 +71,11 @@ public function write() } /** - * Write column + * Write column. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\Table $element + * @return void */ private function writeColumns(XMLWriter $xmlWriter, TableElement $element) { @@ -102,7 +108,11 @@ private function writeColumns(XMLWriter $xmlWriter, TableElement $element) } /** - * Write row + * Write row. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\Row $row + * @return void */ private function writeRow(XMLWriter $xmlWriter, RowElement $row) { @@ -125,7 +135,11 @@ private function writeRow(XMLWriter $xmlWriter, RowElement $row) } /** - * Write cell + * Write cell. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Element\Cell $cell + * @return void */ private function writeCell(XMLWriter $xmlWriter, CellElement $cell) { diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php index 1fa4861f22..cfb991c2d0 100644 --- a/src/PhpWord/Writer/Word2007/Element/Text.php +++ b/src/PhpWord/Writer/Word2007/Element/Text.php @@ -25,7 +25,9 @@ class Text extends AbstractElement { /** - * Write text element + * Write text element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php index 71935d6e74..fe62c644f3 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php @@ -27,7 +27,9 @@ class TextBox extends Image { /** - * Write element + * Write element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php index 83ec22218b..fb52b86e62 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php +++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php @@ -25,7 +25,9 @@ class TextBreak extends Text { /** - * Write text break element + * Write text break element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php index 9ff348cf05..844e0b6bbb 100644 --- a/src/PhpWord/Writer/Word2007/Element/TextRun.php +++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php @@ -25,7 +25,9 @@ class TextRun extends Text { /** - * Write textrun element + * Write textrun element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 144e67abe8..f48e932a72 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -25,7 +25,9 @@ class Title extends AbstractElement { /** - * Write title element + * Write title element. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index 610a761621..e26853d737 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -46,9 +46,10 @@ abstract class AbstractPart abstract public function write(); /** - * Set parent writer + * Set parent writer. * * @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer + * @return void */ public function setParentWriter(AbstractWriter $writer = null) { diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 0a0ebac6f5..8423762c30 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Chart as ChartElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Word2007 chart part writer: word/charts/chartx.xml @@ -59,7 +59,10 @@ class Chart extends AbstractPart private $options = array(); /** - * Set chart element + * Set chart element. + * + * @param \PhpOffice\PhpWord\Element\Chart $element + * @return void */ public function setElement(ChartElement $element) { @@ -93,6 +96,8 @@ public function write() * Write chart * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writeChart(XMLWriter $xmlWriter) { @@ -106,7 +111,7 @@ private function writeChart(XMLWriter $xmlWriter) } /** - * Write plot area + * Write plot area. * * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PlotArea.html * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html @@ -116,6 +121,8 @@ private function writeChart(XMLWriter $xmlWriter) * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @return void */ private function writePlotArea(XMLWriter $xmlWriter) { @@ -171,10 +178,11 @@ private function writePlotArea(XMLWriter $xmlWriter) } /** - * Write series + * Write series. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param bool $scatter + * @return void */ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) { @@ -209,11 +217,12 @@ private function writeSeries(XMLWriter $xmlWriter, $scatter = false) } /** - * Write series items + * Write series items. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $type * @param array $values + * @return void */ private function writeSeriesItem(XMLWriter $xmlWriter, $type, $values) { @@ -248,9 +257,10 @@ private function writeSeriesItem(XMLWriter $xmlWriter, $type, $values) /** * Write axis * + * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $type - * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html + * @return void */ private function writeAxis(XMLWriter $xmlWriter, $type) { @@ -290,9 +300,10 @@ private function writeAxis(XMLWriter $xmlWriter, $type) /** * Write shape * + * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param bool $line - * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html + * @return void */ private function writeShape(XMLWriter $xmlWriter, $line = false) { diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index ac636d3a78..6ae4e8758e 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -82,6 +82,7 @@ public function write() * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer * @param array $parts * @param boolean $isDefault + * @return void */ private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault) { diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index e6639511af..ea607f09b7 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -79,10 +79,11 @@ public function write() } /** - * Write begin section + * Write begin section. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Element\Section $section + * @return void */ private function writeSection(XMLWriter $xmlWriter, Section $section) { @@ -94,10 +95,11 @@ private function writeSection(XMLWriter $xmlWriter, Section $section) } /** - * Write end section + * Write end section. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Element\Section $section + * @return void */ private function writeSectionSettings(XMLWriter $xmlWriter, Section $section) { diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php index 49a47e7dcc..314cf58679 100644 --- a/src/PhpWord/Writer/Word2007/Part/FontTable.php +++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php @@ -26,7 +26,9 @@ class FontTable extends AbstractPart { /** - * Write fontTable.xml + * Write fontTable.xml. + * + * @return string */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 903e5fe55d..9ceefd82ee 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -133,10 +133,11 @@ public function setElements($elements) } /** - * Write note item + * Write note item. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element + * @return void */ protected function writeNote(XMLWriter $xmlWriter, $element) { diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php index 8f735dd324..bbb8eeb455 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 @@ -95,7 +95,11 @@ public function write() } /** - * Write level + * Write level. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\NumberingLevel $level + * @return void */ private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) { @@ -129,9 +133,13 @@ private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level) } /** - * Write level paragraph + * Write level paragraph. * * @since 0.11.0 + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\NumberingLevel $level + * @return void * @todo Use paragraph style writer */ private function writeParagraph(XMLWriter $xmlWriter, NumberingLevel $level) @@ -158,9 +166,13 @@ private function writeParagraph(XMLWriter $xmlWriter, NumberingLevel $level) } /** - * Write level font + * Write level font. * * @since 0.11.0 + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\NumberingLevel $level + * @return void * @todo Use font style writer */ private function writeFont(XMLWriter $xmlWriter, NumberingLevel $level) diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 562deb35b5..80ab630726 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -47,12 +47,13 @@ public function write() } /** - * Write relationships + * Write relationships. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param array $xmlRels * @param array $mediaRels * @param int $relId + * @return void */ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = array(), $mediaRels = array(), $relId = 1) { @@ -74,11 +75,12 @@ protected function writeRels(XMLWriter $xmlWriter, $xmlRels = array(), $mediaRel } /** - * Write media relationships + * Write media relationships. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param int $relId * @param array $mediaRel + * @return void */ private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel) { @@ -96,7 +98,7 @@ private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel) } /** - * Write individual rels entry + * Write individual rels entry. * * Format: * @@ -106,6 +108,7 @@ private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel) * @param string $type Relationship type * @param string $target Relationship target * @param string $targetMode Relationship target mode + * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '') diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php index d381d26a51..50399c4aa0 100644 --- a/src/PhpWord/Writer/Word2007/Part/Settings.php +++ b/src/PhpWord/Writer/Word2007/Part/Settings.php @@ -62,11 +62,12 @@ public function write() } /** - * Write indivual setting, recursive to any child settings + * Write indivual setting, recursive to any child settings. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $settingKey * @param array|string $settingValue + * @return void */ protected function writeSetting($xmlWriter, $settingKey, $settingValue) { @@ -90,7 +91,9 @@ protected function writeSetting($xmlWriter, $settingKey, $settingValue) } /** - * Get settings + * Get settings. + * + * @return void */ private function getSettings() { @@ -141,7 +144,9 @@ private function getSettings() } /** - * Get protection settings + * Get protection settings. + * + * @return void */ private function getProtection() { @@ -157,7 +162,9 @@ private function getProtection() } /** - * Get compatibility setting + * Get compatibility setting. + * + * @return void */ private function getCompatibility() { diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 0d688e366f..6a8de48ac5 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -19,9 +19,9 @@ use PhpOffice\PhpWord\Settings as PhpWordSettings; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; +use PhpOffice\PhpWord\Style; 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; @@ -75,10 +75,11 @@ public function write() } /** - * Write default font and other default styles + * Write default font and other default styles. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles + * @return void */ private function writeDefaultStyles(XMLWriter $xmlWriter, $styles) { @@ -139,11 +140,12 @@ private function writeDefaultStyles(XMLWriter $xmlWriter, $styles) } /** - * Write font style + * Write font style. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $styleName * @param \PhpOffice\PhpWord\Style\Font $style + * @return void */ private function writeFontStyle(XMLWriter $xmlWriter, $styleName, FontStyle $style) { @@ -192,11 +194,12 @@ private function writeFontStyle(XMLWriter $xmlWriter, $styleName, FontStyle $sty } /** - * Write paragraph style + * Write paragraph style. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $styleName * @param \PhpOffice\PhpWord\Style\Paragraph $style + * @return void */ private function writeParagraphStyle(XMLWriter $xmlWriter, $styleName, ParagraphStyle $style) { @@ -224,11 +227,12 @@ private function writeParagraphStyle(XMLWriter $xmlWriter, $styleName, Paragraph } /** - * Write table style + * Write table style. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $styleName * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeTableStyle(XMLWriter $xmlWriter, $styleName, TableStyle $style) { diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index d91e37b8d2..16335680f0 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -47,7 +47,7 @@ abstract class AbstractStyle abstract public function write(); /** - * Create new instance + * Create new instance. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style @@ -104,11 +104,12 @@ protected function convertTwip($value, $default = 0) } /** - * Write child style + * Write child style. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $name * @param mixed $value + * @return void */ protected function writeChildStyle(XMLWriter $xmlWriter, $name, $value) { diff --git a/src/PhpWord/Writer/Word2007/Style/Alignment.php b/src/PhpWord/Writer/Word2007/Style/Alignment.php index cefadb5740..fabaf8eac4 100644 --- a/src/PhpWord/Writer/Word2007/Style/Alignment.php +++ b/src/PhpWord/Writer/Word2007/Style/Alignment.php @@ -25,7 +25,9 @@ class Alignment extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php index a4b1ae90da..0f90b3aa91 100644 --- a/src/PhpWord/Writer/Word2007/Style/Cell.php +++ b/src/PhpWord/Writer/Word2007/Style/Cell.php @@ -32,7 +32,9 @@ class Cell extends AbstractStyle private $width; /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -88,9 +90,10 @@ public function write() } /** - * Set width + * Set width. * * @param int $value + * @return void */ public function setWidth($value = null) { diff --git a/src/PhpWord/Writer/Word2007/Style/Extrusion.php b/src/PhpWord/Writer/Word2007/Style/Extrusion.php index aa8ba1eadf..ba1ee590ec 100644 --- a/src/PhpWord/Writer/Word2007/Style/Extrusion.php +++ b/src/PhpWord/Writer/Word2007/Style/Extrusion.php @@ -25,7 +25,9 @@ class Extrusion extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Fill.php b/src/PhpWord/Writer/Word2007/Style/Fill.php index 0695f8eff0..645f1ab053 100644 --- a/src/PhpWord/Writer/Word2007/Style/Fill.php +++ b/src/PhpWord/Writer/Word2007/Style/Fill.php @@ -25,7 +25,9 @@ class Fill extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 6eb38dc26b..67a0482965 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -32,7 +32,9 @@ class Font extends AbstractStyle private $isInline = false; /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -51,7 +53,9 @@ public function write() } /** - * Write full style + * Write full style. + * + * @return void */ private function writeStyle() { @@ -130,9 +134,10 @@ private function writeStyle() } /** - * Set is inline + * Set is inline. * * @param bool $value + * @return void */ public function setIsInline($value) { diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php index 6926081f4c..2dd6176546 100644 --- a/src/PhpWord/Writer/Word2007/Style/Frame.php +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -29,7 +29,9 @@ class Frame extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -74,7 +76,9 @@ public function write() } /** - * Write alignment + * Write alignment. + * + * @return void */ public function writeAlignment() { @@ -91,11 +95,12 @@ public function writeAlignment() } /** - * Write alignment + * Write alignment. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Frame $style * @param string $wrap + * @return void */ private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap) { diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php index f9bb696f1b..a1b4d8d113 100644 --- a/src/PhpWord/Writer/Word2007/Style/Indentation.php +++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php @@ -25,7 +25,9 @@ class Indentation extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php index 8a56cb7bbe..fd1c21de66 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -26,8 +26,9 @@ class Line extends Frame { /** - * Write Line stroke + * Write Line stroke. * + * @return void * @todo Merge with `Stroke` style */ public function writeStroke() diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php index b3c103b6d4..d06fa2d697 100644 --- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php +++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php @@ -25,7 +25,9 @@ class LineNumbering extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void * * The w:start seems to be zero based so we have to decrement by one */ diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index 38dff1485d..fec987d376 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -48,7 +48,9 @@ class MarginBorder extends AbstractStyle private $attributes = array(); /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -69,12 +71,13 @@ public function write() } /** - * Write side + * Write side. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $side * @param int $width * @param string $color + * @return void */ private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null) { @@ -101,9 +104,10 @@ private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null) } /** - * Set sizes + * Set sizes. * * @param integer[] $value + * @return void */ public function setSizes($value) { @@ -111,9 +115,10 @@ public function setSizes($value) } /** - * Set colors + * Set colors. * * @param string[] $value + * @return void */ public function setColors($value) { @@ -121,9 +126,10 @@ public function setColors($value) } /** - * Set attributes + * Set attributes. * * @param array $value + * @return void */ public function setAttributes($value) { diff --git a/src/PhpWord/Writer/Word2007/Style/Outline.php b/src/PhpWord/Writer/Word2007/Style/Outline.php index e53282a315..06064d188a 100644 --- a/src/PhpWord/Writer/Word2007/Style/Outline.php +++ b/src/PhpWord/Writer/Word2007/Style/Outline.php @@ -25,7 +25,9 @@ class Outline extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index 86efda2fc5..039b78bfad 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -18,9 +18,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; use PhpOffice\PhpWord\Shared\XMLWriter; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Alignment as AlignmentStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; +use PhpOffice\PhpWord\Style; /** * Paragraph style writer @@ -44,7 +44,9 @@ class Paragraph extends AbstractStyle private $isInline = false; /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -67,7 +69,9 @@ public function write() } /** - * Write full style + * Write full style. + * + * @return void */ private function writeStyle() { @@ -126,10 +130,11 @@ private function writeStyle() } /** - * Write tabs + * Write tabs. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Tab[] $tabs + * @return void */ private function writeTabs(XMLWriter $xmlWriter, $tabs) { @@ -144,10 +149,11 @@ private function writeTabs(XMLWriter $xmlWriter, $tabs) } /** - * Write numbering + * Write numbering. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param array $numbering + * @return void */ private function writeNumbering(XMLWriter $xmlWriter, $numbering) { @@ -173,9 +179,10 @@ private function writeNumbering(XMLWriter $xmlWriter, $numbering) } /** - * Set without w:pPr + * Set without w:pPr. * * @param bool $value + * @return void */ public function setWithoutPPR($value) { @@ -183,9 +190,10 @@ public function setWithoutPPR($value) } /** - * Set is inline + * Set is inline. * * @param bool $value + * @return void */ public function setIsInline($value) { diff --git a/src/PhpWord/Writer/Word2007/Style/Row.php b/src/PhpWord/Writer/Word2007/Style/Row.php index 5517cc2b82..98841dd846 100644 --- a/src/PhpWord/Writer/Word2007/Style/Row.php +++ b/src/PhpWord/Writer/Word2007/Style/Row.php @@ -30,7 +30,9 @@ class Row extends AbstractStyle private $height; /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -55,9 +57,10 @@ public function write() } /** - * Set height + * Set height. * * @param int $value + * @return void */ public function setHeight($value = null) { diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php index fb32a39a05..486d0ed228 100644 --- a/src/PhpWord/Writer/Word2007/Style/Section.php +++ b/src/PhpWord/Writer/Word2007/Style/Section.php @@ -27,7 +27,9 @@ class Section extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php index 72054c207b..8ef8c6b184 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shading.php +++ b/src/PhpWord/Writer/Word2007/Style/Shading.php @@ -25,7 +25,9 @@ class Shading extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Shadow.php b/src/PhpWord/Writer/Word2007/Style/Shadow.php index dd7c769aca..cc74605994 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shadow.php +++ b/src/PhpWord/Writer/Word2007/Style/Shadow.php @@ -25,7 +25,9 @@ class Shadow extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Shape.php b/src/PhpWord/Writer/Word2007/Style/Shape.php index 7eafb18e1a..ba8dce5bd1 100644 --- a/src/PhpWord/Writer/Word2007/Style/Shape.php +++ b/src/PhpWord/Writer/Word2007/Style/Shape.php @@ -25,7 +25,9 @@ class Shape extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php index 5dfb5c43cf..2f7e122a22 100644 --- a/src/PhpWord/Writer/Word2007/Style/Spacing.php +++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php @@ -25,7 +25,9 @@ class Spacing extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php index 865a5a9c6e..aa00acc788 100644 --- a/src/PhpWord/Writer/Word2007/Style/Tab.php +++ b/src/PhpWord/Writer/Word2007/Style/Tab.php @@ -25,7 +25,9 @@ class Tab extends AbstractStyle { /** - * Write style + * Write style. + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index e89b121c87..8bbad107c3 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -34,7 +34,9 @@ class Table extends AbstractStyle private $width; /** - * Write style + * Write style. + * + * @return void */ public function write() { @@ -56,7 +58,11 @@ public function write() } /** - * Write full style + * Write full style. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeStyle(XMLWriter $xmlWriter, TableStyle $style) { @@ -83,11 +89,12 @@ private function writeStyle(XMLWriter $xmlWriter, TableStyle $style) } /** - * Write width + * Write width. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param int $width * @param string $unit + * @return void */ private function writeWidth(XMLWriter $xmlWriter, $width, $unit) { @@ -98,7 +105,11 @@ private function writeWidth(XMLWriter $xmlWriter, $width, $unit) } /** - * Write margin + * Write margin. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeMargin(XMLWriter $xmlWriter, TableStyle $style) { @@ -114,7 +125,11 @@ private function writeMargin(XMLWriter $xmlWriter, TableStyle $style) } /** - * Write border + * Write border. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeBorder(XMLWriter $xmlWriter, TableStyle $style) { @@ -131,7 +146,11 @@ private function writeBorder(XMLWriter $xmlWriter, TableStyle $style) } /** - * Write row style + * Write row style. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style) { @@ -147,7 +166,11 @@ private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style) } /** - * Write shading + * Write shading. + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param \PhpOffice\PhpWord\Style\Table $style + * @return void */ private function writeShading(XMLWriter $xmlWriter, TableStyle $style) { @@ -162,9 +185,10 @@ private function writeShading(XMLWriter $xmlWriter, TableStyle $style) } /** - * Set width + * Set width. * * @param int $value + * @return void */ public function setWidth($value = null) { diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php index a5f82e53db..20c68c7421 100644 --- a/src/PhpWord/Writer/Word2007/Style/TextBox.php +++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php @@ -27,7 +27,9 @@ class TextBox extends Frame { /** - * Writer inner margin + * Writer inner margin. + * + * @return void */ public function writeInnerMargin() { @@ -43,7 +45,9 @@ public function writeInnerMargin() } /** - * Writer border + * Writer border. + * + * @return void */ public function writeBorder() { From 8056b6926c850d7d85db90ecee2ad9dea69d0292 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 3 Jul 2014 16:11:15 +0400 Subject: [PATCH 069/174] [CHANGED] Docblock for pass-by-reference parameters. --- src/PhpWord/Media.php | 2 +- src/PhpWord/Reader/ODText.php | 2 +- src/PhpWord/Reader/ODText/Content.php | 2 +- src/PhpWord/Reader/ODText/Meta.php | 2 +- src/PhpWord/Reader/RTF/Document.php | 2 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 6 +++--- src/PhpWord/Reader/Word2007/DocPropsCore.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCustom.php | 2 +- src/PhpWord/Reader/Word2007/Document.php | 8 ++++---- src/PhpWord/Reader/Word2007/Footnotes.php | 2 +- src/PhpWord/Reader/Word2007/Numbering.php | 2 +- src/PhpWord/Reader/Word2007/Styles.php | 2 +- src/PhpWord/Shared/Html.php | 16 ++++++++-------- src/PhpWord/Style/AbstractStyle.php | 6 +++--- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/ODText/Part/Content.php | 12 ++++++------ src/PhpWord/Writer/RTF/Part/Header.php | 4 ++-- src/PhpWord/Writer/Word2007.php | 8 ++++---- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 7f35841c43..aa289edc92 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -38,7 +38,7 @@ class Media * @param string $container section|headerx|footerx|footnote|endnote * @param string $mediaType image|object|link * @param string $source - * @param \PhpOffice\PhpWord\Element\Image $image + * @param \PhpOffice\PhpWord\Element\Image &$image * @return integer * @throws \PhpOffice\PhpWord\Exception\Exception * @since 0.9.2 diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index d7d23c8064..0c24185da7 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -53,7 +53,7 @@ public function load($docFile) /** * Read document part. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @param array $relationships * @param string $partName * @param string $docFile diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index 9feb669a2b..aecb7419ca 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -30,7 +30,7 @@ class Content extends AbstractPart /** * Read content.xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php index 827446f0ad..fc061ba143 100644 --- a/src/PhpWord/Reader/ODText/Meta.php +++ b/src/PhpWord/Reader/ODText/Meta.php @@ -30,7 +30,7 @@ class Meta extends AbstractPart /** * Read meta.xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void * @todo Process property type */ diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index 26763576cd..1f3dbb3498 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -129,7 +129,7 @@ class Document * - Builds control words and control symbols * - Pushes every other character into the text queue * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void * @todo Use `fread` stream for scalability */ diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index acf4048379..556b0bb01e 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -77,7 +77,7 @@ public function load($docFile) /** * Read document part. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @param array $relationships * @param string $partName * @param string $docFile diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 0309f1938d..eead400f6b 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -94,7 +94,7 @@ public function setRels($value) * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed $parent + * @param mixed &$parent * @param string $docPart * @return void * @@ -185,7 +185,7 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed $parent + * @param mixed &$parent * @param string $docPart * @param mixed $paragraphStyle * @return void @@ -248,7 +248,7 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed $parent + * @param mixed &$parent * @param string $docPart * @return void */ diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index d8a8768dbe..3889db0c19 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -54,7 +54,7 @@ class DocPropsCore extends AbstractPart /** * Read core/extended document properties. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 5f99495eac..0d81333eb5 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -31,7 +31,7 @@ class DocPropsCustom extends AbstractPart /** * Read custom document properties. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 1d51819f89..afe0e0a5a0 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -39,7 +39,7 @@ class Document extends AbstractPart /** * Read document.xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) @@ -65,7 +65,7 @@ public function read(PhpWord &$phpWord) * Read header footer. * * @param array $settings - * @param \PhpOffice\PhpWord\Element\Section $section + * @param \PhpOffice\PhpWord\Element\Section &$section * @return void */ private function readHeaderFooter($settings, Section &$section) @@ -144,7 +144,7 @@ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode) * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $node - * @param \PhpOffice\PhpWord\Element\Section $section + * @param \PhpOffice\PhpWord\Element\Section &$section * @return void * * @todo @@ -174,7 +174,7 @@ private function readWPNode(XMLReader $xmlReader, \DOMElement $node, Section &$s * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $node - * @param \PhpOffice\PhpWord\Element\Section $section + * @param \PhpOffice\PhpWord\Element\Section &$section * @return void */ private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section) diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index fd3510146b..30e6c58b43 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -44,7 +44,7 @@ class Footnotes extends AbstractPart /** * Read (footnotes|endnotes).xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index bc34bd68d4..7b33bc4c87 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -30,7 +30,7 @@ class Numbering extends AbstractPart /** * Read numbering.xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index 00010af6c1..964147ad03 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -30,7 +30,7 @@ class Styles extends AbstractPart /** * Read styles.xml. * - * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @param \PhpOffice\PhpWord\PhpWord &$phpWord * @return void */ public function read(PhpWord &$phpWord) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 86d466db97..13824f3388 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -191,7 +191,7 @@ private static function parseChildNodes($node, $element, $styles, $data) * * @param \DOMNode $node * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - * @param array $styles + * @param array &$styles * @return \PhpOffice\PhpWord\Element\TextRun */ private static function parseParagraph($node, $element, &$styles) @@ -206,7 +206,7 @@ private static function parseParagraph($node, $element, &$styles) * Parse heading node * * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - * @param array $styles + * @param array &$styles * @param string $argument1 Name of heading style * @return \PhpOffice\PhpWord\Element\TextRun * @@ -226,7 +226,7 @@ private static function parseHeading($element, &$styles, $argument1) * * @param \DOMNode $node * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - * @param array $styles + * @param array &$styles * @return null */ private static function parseText($node, $element, &$styles) @@ -245,7 +245,7 @@ private static function parseText($node, $element, &$styles) /** * Parse property node * - * @param array $styles + * @param array &$styles * @param string $argument1 Style name * @param string $argument2 Style value * @return null @@ -262,7 +262,7 @@ private static function parseProperty(&$styles, $argument1, $argument2) * * @param \DOMNode $node * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - * @param array $styles + * @param array &$styles * @param string $argument1 Method name * @return \PhpOffice\PhpWord\Element\AbstractContainer $element * @@ -292,8 +292,8 @@ private static function parseTable($node, $element, &$styles, $argument1) /** * Parse list node * - * @param array $styles - * @param array $data + * @param array &$styles + * @param array &$data * @param string $argument1 List type * @return null */ @@ -314,7 +314,7 @@ private static function parseList(&$styles, &$data, $argument1) * * @param \DOMNode $node * @param \PhpOffice\PhpWord\Element\AbstractContainer $element - * @param array $styles + * @param array &$styles * @param array $data * @return null * diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 6f5272106f..aec490b5a1 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -297,7 +297,7 @@ protected function setEnumVal($value = null, $enum = array(), $default = null) * * @param mixed $value * @param string $styleName - * @param mixed $style + * @param mixed &$style * @return mixed */ protected function setObjectVal($value, $styleName, &$style) @@ -319,8 +319,8 @@ protected function setObjectVal($value, $styleName, &$style) /** * Set $property value and set $pairProperty = false when $value = true * - * @param bool $property - * @param bool $pairProperty + * @param bool &$property + * @param bool &$pairProperty * @param bool $value * @return self */ diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 2d9945749a..f91e99a221 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -106,7 +106,7 @@ public function __construct($fileName) /** * Applies XSL style sheet to template's parts. * - * @param \DOMDocument $xslDOMDocument + * @param \DOMDocument &$xslDOMDocument * @param array $xslOptions * @param string $xslOptionsURI * @return void diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index b2159d7dd4..4bde66ee97 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -23,10 +23,10 @@ use PhpOffice\PhpWord\Element\TextRun; 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 as TableStyle; -use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Writer\ODText\Element\Container; use PhpOffice\PhpWord\Writer\ODText\Style\Paragraph as ParagraphStyleWriter; @@ -190,8 +190,8 @@ private function getAutoStyles(PhpWord $phpWord) * Table style can be null or string of the style name * * @param \PhpOffice\PhpWord\Element\AbstractContainer $container - * @param int $paragraphStyleCount - * @param int $fontStyleCount + * @param int &$paragraphStyleCount + * @param int &$fontStyleCount * @return void * @todo Simplify the logic */ @@ -223,9 +223,9 @@ private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyl /** * Get style of individual element * - * @param \PhpOffice\PhpWord\Element\Text $element - * @param int $paragraphStyleCount - * @param int $fontStyleCount + * @param \PhpOffice\PhpWord\Element\Text &$element + * @param int &$paragraphStyleCount + * @param int &$fontStyleCount * @return void */ private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount) diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php index 574bff762d..31fbb7f4af 100644 --- a/src/PhpWord/Writer/RTF/Part/Header.php +++ b/src/PhpWord/Writer/RTF/Part/Header.php @@ -19,8 +19,8 @@ use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\Converter; -use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\Style\Font; /** * RTF header part writer @@ -246,7 +246,7 @@ private function registerFontItems($style) /** * Register individual font and color. * - * @param array $table + * @param array &$table * @param string $value * @param string $default * @return void diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 214715058d..baac822275 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -192,10 +192,10 @@ private function addHeaderFooterMedia(ZipArchive $zip, $docPart) /** * Add header/footer content. * - * @param \PhpOffice\PhpWord\Element\Section $section + * @param \PhpOffice\PhpWord\Element\Section &$section * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip * @param string $elmType header|footer - * @param integer $rId + * @param integer &$rId * @return void */ private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elmType, &$rId) @@ -221,7 +221,7 @@ private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elm * Add footnotes/endnotes * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip - * @param integer $rId + * @param integer &$rId * @param string $noteType * @return void */ @@ -259,7 +259,7 @@ private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote') * Add chart. * * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip - * @param integer $rId + * @param integer &$rId * @return void */ private function addChart(ZipArchive $zip, &$rId) From 4a02142d632ea9a35bab34484647aed454983685 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 12:13:11 +0400 Subject: [PATCH 070/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Element/AbstractElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 82aa543ec4..4bc6b8e540 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -133,7 +133,7 @@ public function getPhpWord() */ public function setPhpWord(PhpWord &$phpWord = null) { - $this->phpWord = &$phpWord; + $this->phpWord = $phpWord; } /** From 2c5d13c88e30debc0cb35f60c772c2cf8c124c62 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 12:25:53 +0400 Subject: [PATCH 071/174] [FIXED] Typo in Section->addHeaderFooter(). --- src/PhpWord/Element/Section.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index d746f69bb3..6377ad497a 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -164,7 +164,7 @@ 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'; - $collection = &$this->$collectionArray; + $collection = &$collectionArray; if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { $index = count($collection); From f2e9e3716b2266e07d6a0b33d9d99fce7c95bde7 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 13:00:52 +0400 Subject: [PATCH 072/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Reader/Word2007/AbstractPart.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index eead400f6b..d63a65ad5a 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -166,15 +166,15 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p if ($runLinkCount == 0) { $parent->addTextBreak(null, $paragraphStyle); } else { - if ($runLinkCount > 1) { - $textrun = $parent->addTextRun($paragraphStyle); - $textParent = &$textrun; - } else { - $textParent = &$parent; - } $nodes = $xmlReader->getElements('*', $domNode); foreach ($nodes as $node) { - $this->readRun($xmlReader, $node, $textParent, $docPart, $paragraphStyle); + $this->readRun( + $xmlReader, + $node, + ($runLinkCount > 1) ? $parent->addTextRun($paragraphStyle) : $parent, + $docPart, + $paragraphStyle + ); } } } From 47a17a33e848acef81075de182330c7b0c674797 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 13:02:28 +0400 Subject: [PATCH 073/174] Revert: [FIXED] Wrong use of passing by reference. --- src/PhpWord/Element/Section.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index 6377ad497a..d746f69bb3 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -164,7 +164,7 @@ 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'; - $collection = &$collectionArray; + $collection = &$this->$collectionArray; if (in_array($type, array(Header::AUTO, Header::FIRST, Header::EVEN))) { $index = count($collection); From 1b9b8d4f90e7cef2cebe6e217c2bd46b04eb8492 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 14:44:22 +0400 Subject: [PATCH 074/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Reader/Word2007/AbstractPart.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index d63a65ad5a..efca196210 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -166,15 +166,13 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p if ($runLinkCount == 0) { $parent->addTextBreak(null, $paragraphStyle); } else { + $textParent = $parent; + if ($runLinkCount > 1) { + $textParent = &$parent->addTextRun($paragraphStyle); + } $nodes = $xmlReader->getElements('*', $domNode); foreach ($nodes as $node) { - $this->readRun( - $xmlReader, - $node, - ($runLinkCount > 1) ? $parent->addTextRun($paragraphStyle) : $parent, - $docPart, - $paragraphStyle - ); + $this->readRun($xmlReader, $node, $textParent, $docPart, $paragraphStyle); } } } From d54a674b97a60af84b27f4e2555ad6d3d462e3cd Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 13:07:08 +0200 Subject: [PATCH 075/174] add element bookmark and allow links to internal bookmarks in Word2007 --- src/PhpWord/Element/AbstractContainer.php | 4 +- src/PhpWord/Element/Bookmark.php | 64 +++++++++++++++++++ src/PhpWord/Element/Link.php | 21 +++++- src/PhpWord/PhpWord.php | 11 ++-- .../Writer/Word2007/Element/Bookmark.php | 49 ++++++++++++++ src/PhpWord/Writer/Word2007/Element/Link.php | 10 +-- src/PhpWord/Writer/Word2007/Element/Title.php | 9 ++- 7 files changed, 150 insertions(+), 18 deletions(-) create mode 100644 src/PhpWord/Element/Bookmark.php create mode 100644 src/PhpWord/Writer/Word2007/Element/Bookmark.php diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 686644eb76..9b5989061c 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -22,6 +22,7 @@ * * @method Text addText(string $text, mixed $fStyle = null, mixed $pStyle = null) * @method TextRun addTextRun(mixed $pStyle = null) + * @method Bookmark addBookmark(string $name) * @method Link addLink(string $target, string $text = null, mixed $fStyle = null, mixed $pStyle = null) * @method PreserveText addPreserveText(string $text, mixed $fStyle = null, mixed $pStyle = null) * @method void addTextBreak(int $count = 1, mixed $fStyle = null, mixed $pStyle = null) @@ -78,7 +79,7 @@ abstract class AbstractContainer extends AbstractElement public function __call($function, $args) { $elements = array( - 'Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', + 'Text', 'TextRun', 'Bookmark', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Line', 'Shape', 'Title', 'TOC', 'PageBreak', @@ -189,6 +190,7 @@ private function checkValidity($method) ); $validContainers = array( 'Text' => $allContainers, + 'Bookmark' => $allContainers, 'Link' => $allContainers, 'TextBreak' => $allContainers, 'Image' => $allContainers, diff --git a/src/PhpWord/Element/Bookmark.php b/src/PhpWord/Element/Bookmark.php new file mode 100644 index 0000000000..39b6d69a69 --- /dev/null +++ b/src/PhpWord/Element/Bookmark.php @@ -0,0 +1,64 @@ +name = String::toUTF8($name); + return $this; + } + + /** + * Get Bookmark name + * + * @return string + */ + public function getName() + { + return $this->name; + } + +} diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 4b00dc9047..81349b5d2f 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -61,6 +61,13 @@ class Link extends AbstractElement */ protected $mediaRelation = true; + /** + * Has internal flag - anchor to internal bookmark + * + * @var bool + */ + protected $internal = false; + /** * Create a new Link Element * @@ -69,13 +76,13 @@ class Link extends AbstractElement * @param mixed $fontStyle * @param mixed $paragraphStyle */ - public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null) + public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false) { $this->source = String::toUTF8($source); $this->text = is_null($text) ? $this->source : String::toUTF8($text); $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); - + $this->internal = $internal; return $this; } @@ -154,4 +161,14 @@ public function getLinkName() { return $this->getText(); } + + /** + * is internal + * + * @return bool + */ + public function isInternal() + { + return $this->internal; + } } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 3b991e2321..93835d9117 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -27,6 +27,7 @@ * @method Collection\Footnotes getFootnotes() * @method Collection\Endnotes getEndnotes() * @method Collection\Charts getCharts() + * @method int addBookmark(Element\Bookmark $bookmark) * @method int addTitle(Element\Title $title) * @method int addFootnote(Element\Footnote $footnote) * @method int addEndnote(Element\Endnote $endnote) @@ -82,7 +83,7 @@ class PhpWord public function __construct() { // Collection - $collections = array('Titles', 'Footnotes', 'Endnotes', 'Charts'); + $collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts'); foreach ($collections as $collection) { $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection; $this->collections[$collection] = new $class(); @@ -113,7 +114,7 @@ public function __call($function, $args) $addCollection = array(); $addStyle = array(); - $collections = array('Title', 'Footnote', 'Endnote', 'Chart'); + $collections = array('Bookmark', 'Title', 'Footnote', 'Endnote', 'Chart'); foreach ($collections as $collection) { $getCollection[] = strtolower("get{$collection}s"); $addCollection[] = strtolower("add{$collection}"); @@ -218,10 +219,9 @@ public function getDefaultFontName() } /** - * Set default font name. + * Set default font name * * @param string $fontName - * @return void */ public function setDefaultFontName($fontName) { @@ -239,10 +239,9 @@ public function getDefaultFontSize() } /** - * Set default font size. + * Set default font size * * @param int $fontSize - * @return void */ public function setDefaultFontSize($fontSize) { diff --git a/src/PhpWord/Writer/Word2007/Element/Bookmark.php b/src/PhpWord/Writer/Word2007/Element/Bookmark.php new file mode 100644 index 0000000000..df5a104a18 --- /dev/null +++ b/src/PhpWord/Writer/Word2007/Element/Bookmark.php @@ -0,0 +1,49 @@ +getXmlWriter(); + $element = $this->getElement(); + if (!$element instanceof \PhpOffice\PhpWord\Element\Bookmark) { + return; + } + + $rId = $element->getRelationId(); + + $xmlWriter->startElement('w:bookmarkStart'); + $xmlWriter->writeAttribute('w:id', $rId); + $xmlWriter->writeAttribute('w:name', $element->getName()); + $xmlWriter->endElement(); + + $xmlWriter->startElement('w:bookmarkEnd'); + $xmlWriter->writeAttribute('w:id', $rId); + $xmlWriter->endElement(); + } +} diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 2a5a5ae1bb..31bfa3fdf6 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -25,9 +25,7 @@ class Link extends Text { /** - * Write link element. - * - * @return void + * Write link element */ public function write() { @@ -42,7 +40,11 @@ public function write() $this->startElementP(); $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + if($element->isInternal()) { + $xmlWriter->writeAttribute('w:anchor', $element->getSource()); + }else { + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + } $xmlWriter->writeAttribute('w:history', '1'); $xmlWriter->startElement('w:r'); diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index f48e932a72..2c2fe0b0b9 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -25,9 +25,7 @@ class Title extends AbstractElement { /** - * Write title element. - * - * @return void + * Write title element */ public function write() { @@ -50,10 +48,11 @@ public function write() } $rId = $element->getRelationId(); + $bookmarkRId = $element->getPhpWord()->addBookmark(); // Bookmark start for TOC $xmlWriter->startElement('w:bookmarkStart'); - $xmlWriter->writeAttribute('w:id', $rId); + $xmlWriter->writeAttribute('w:id', $bookmarkRId); $xmlWriter->writeAttribute('w:name', "_Toc{$rId}"); $xmlWriter->endElement(); @@ -66,7 +65,7 @@ public function write() // Bookmark end $xmlWriter->startElement('w:bookmarkEnd'); - $xmlWriter->writeAttribute('w:id', $rId); + $xmlWriter->writeAttribute('w:id', $bookmarkRId); $xmlWriter->endElement(); $xmlWriter->endElement(); From fdeefb77d95eb4d17c355ba42f816e38e48a7585 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 13:24:14 +0200 Subject: [PATCH 076/174] include minor changes from develop branch --- src/PhpWord/PhpWord.php | 6 ++++-- src/PhpWord/Writer/Word2007/Element/Link.php | 2 ++ src/PhpWord/Writer/Word2007/Element/Title.php | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 93835d9117..e83ce08f00 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -219,9 +219,10 @@ public function getDefaultFontName() } /** - * Set default font name + * Set default font name. * * @param string $fontName + * @return void */ public function setDefaultFontName($fontName) { @@ -239,9 +240,10 @@ public function getDefaultFontSize() } /** - * Set default font size + * Set default font size. * * @param int $fontSize + * @return void */ public function setDefaultFontSize($fontSize) { diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 31bfa3fdf6..50f6d1312c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -26,6 +26,8 @@ class Link extends Text { /** * Write link element + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index 2c2fe0b0b9..a53af3faf0 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -26,6 +26,8 @@ class Title extends AbstractElement { /** * Write title element + * + * @return void */ public function write() { From 475c76dd7907a534dc642dbbbd5400d8bce49e07 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 13:30:07 +0200 Subject: [PATCH 077/174] convert tabs to spaces --- src/PhpWord/PhpWord.php | 4 ++-- src/PhpWord/Writer/Word2007/Element/Link.php | 4 ++-- src/PhpWord/Writer/Word2007/Element/Title.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index e83ce08f00..419af4bee5 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -222,7 +222,7 @@ public function getDefaultFontName() * Set default font name. * * @param string $fontName - * @return void + * @return void */ public function setDefaultFontName($fontName) { @@ -243,7 +243,7 @@ public function getDefaultFontSize() * Set default font size. * * @param int $fontSize - * @return void + * @return void */ public function setDefaultFontSize($fontSize) { diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 50f6d1312c..9f53fc7d9a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -26,8 +26,8 @@ class Link extends Text { /** * Write link element - * - * @return void + * + * @return void */ public function write() { diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index a53af3faf0..abdfc94435 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -26,8 +26,8 @@ class Title extends AbstractElement { /** * Write title element - * - * @return void + * + * @return void */ public function write() { From 4d060b3f07f3058e245b07f93ea3965fc674c774 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 13:32:47 +0200 Subject: [PATCH 078/174] sync with develop-branch --- src/PhpWord/Writer/Word2007/Element/Link.php | 2 +- src/PhpWord/Writer/Word2007/Element/Title.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 9f53fc7d9a..58156ebc37 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -25,7 +25,7 @@ class Link extends Text { /** - * Write link element + * Write link element. * * @return void */ diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php index abdfc94435..ce9aeea529 100644 --- a/src/PhpWord/Writer/Word2007/Element/Title.php +++ b/src/PhpWord/Writer/Word2007/Element/Title.php @@ -25,7 +25,7 @@ class Title extends AbstractElement { /** - * Write title element + * Write title element. * * @return void */ From f2c43291088f2080edfc2ef48b6d94d686d23f10 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 16:00:17 +0400 Subject: [PATCH 079/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Reader/Word2007/AbstractPart.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index efca196210..90538aec7e 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -94,13 +94,13 @@ public function setRels($value) * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed &$parent + * @param mixed $parent * @param string $docPart * @return void * * @todo Get font style for preserve text */ - protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart = 'document') + protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $parent, $docPart = 'document') { // Paragraph style $paragraphStyle = null; @@ -168,7 +168,7 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p } else { $textParent = $parent; if ($runLinkCount > 1) { - $textParent = &$parent->addTextRun($paragraphStyle); + $textParent = $parent->addTextRun($paragraphStyle); } $nodes = $xmlReader->getElements('*', $domNode); foreach ($nodes as $node) { @@ -183,14 +183,14 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, &$p * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed &$parent + * @param mixed $parent * @param string $docPart * @param mixed $paragraphStyle * @return void * * @todo Footnote paragraph style */ - protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart, $paragraphStyle = null) + protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, $parent, $docPart, $paragraphStyle = null) { if (!in_array($domNode->nodeName, array('w:r', 'w:hyperlink'))) { return; From 87c3df55361bed6204e158de16980d015c5ecbf2 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 14:10:20 +0200 Subject: [PATCH 080/174] add missing file apply formatting to CGL --- src/PhpWord/Collection/Bookmarks.php | 27 ++++++++++++++++++++ src/PhpWord/Element/Bookmark.php | 1 - src/PhpWord/Element/Link.php | 2 +- src/PhpWord/Writer/Word2007/Element/Link.php | 8 +++--- 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 src/PhpWord/Collection/Bookmarks.php diff --git a/src/PhpWord/Collection/Bookmarks.php b/src/PhpWord/Collection/Bookmarks.php new file mode 100644 index 0000000000..cb9d74d53f --- /dev/null +++ b/src/PhpWord/Collection/Bookmarks.php @@ -0,0 +1,27 @@ +name; } - } diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 81349b5d2f..9d0eb76662 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -82,7 +82,7 @@ public function __construct($source, $text = null, $fontStyle = null, $paragraph $this->text = is_null($text) ? $this->source : String::toUTF8($text); $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); - $this->internal = $internal; + $this->internal = $internal; return $this; } diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php index 58156ebc37..2cb8407f5b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Link.php +++ b/src/PhpWord/Writer/Word2007/Element/Link.php @@ -42,10 +42,10 @@ public function write() $this->startElementP(); $xmlWriter->startElement('w:hyperlink'); - if($element->isInternal()) { - $xmlWriter->writeAttribute('w:anchor', $element->getSource()); - }else { - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); + if ($element->isInternal()) { + $xmlWriter->writeAttribute('w:anchor', $element->getSource()); + } else { + $xmlWriter->writeAttribute('r:id', 'rId' . $rId); } $xmlWriter->writeAttribute('w:history', '1'); $xmlWriter->startElement('w:r'); From fd209fc999ca3e4fb9b75a1f32375fb80bc4233c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 16:20:18 +0400 Subject: [PATCH 081/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Reader/Word2007/AbstractPart.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 90538aec7e..f5bab01131 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -166,13 +166,15 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $pa if ($runLinkCount == 0) { $parent->addTextBreak(null, $paragraphStyle); } else { - $textParent = $parent; - if ($runLinkCount > 1) { - $textParent = $parent->addTextRun($paragraphStyle); - } $nodes = $xmlReader->getElements('*', $domNode); foreach ($nodes as $node) { - $this->readRun($xmlReader, $node, $textParent, $docPart, $paragraphStyle); + $this->readRun( + $xmlReader, + $node, + ($runLinkCount > 1) ? $parent->addTextRun($paragraphStyle) : $parent, + $docPart, + $paragraphStyle + ); } } } From c4638df0d668de3fd62734f86e257afa4050eec8 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 16:35:13 +0400 Subject: [PATCH 082/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Element/AbstractElement.php | 7 +++---- src/PhpWord/Media.php | 4 ++-- src/PhpWord/Reader/ODText.php | 5 ++--- src/PhpWord/Reader/ODText/Content.php | 4 ++-- src/PhpWord/Reader/ODText/Meta.php | 4 ++-- src/PhpWord/Reader/RTF/Document.php | 4 ++-- src/PhpWord/Reader/Word2007.php | 4 ++-- src/PhpWord/Reader/Word2007/AbstractPart.php | 2 +- src/PhpWord/Reader/Word2007/DocPropsCore.php | 4 ++-- src/PhpWord/Reader/Word2007/DocPropsCustom.php | 4 ++-- src/PhpWord/Reader/Word2007/Document.php | 4 ++-- src/PhpWord/Reader/Word2007/Footnotes.php | 4 ++-- src/PhpWord/Reader/Word2007/Numbering.php | 4 ++-- src/PhpWord/Reader/Word2007/Styles.php | 4 ++-- src/PhpWord/Template.php | 4 ++-- 15 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 4bc6b8e540..4b994a18ba 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -128,10 +128,10 @@ public function getPhpWord() /** * Set PhpWord as reference. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function setPhpWord(PhpWord &$phpWord = null) + public function setPhpWord(PhpWord $phpWord) { $this->phpWord = $phpWord; } @@ -285,8 +285,7 @@ public function setParentContainer(AbstractElement $container) } // Set phpword - $phpWord = $container->getPhpWord(); - $this->setPhpWord($phpWord); + $this->setPhpWord($container->getPhpWord()); // Set doc part if (!$this instanceof Footnote) { diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index aa289edc92..4bea57acac 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -38,13 +38,13 @@ class Media * @param string $container section|headerx|footerx|footnote|endnote * @param string $mediaType image|object|link * @param string $source - * @param \PhpOffice\PhpWord\Element\Image &$image + * @param \PhpOffice\PhpWord\Element\Image $image * @return integer * @throws \PhpOffice\PhpWord\Exception\Exception * @since 0.9.2 * @since 0.10.0 */ - public static function addElement($container, $mediaType, $source, Image &$image = null) + public static function addElement($container, $mediaType, $source, Image $image = null) { // Assign unique media Id and initiate media container if none exists $mediaId = md5($container . $source); diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php index 0c24185da7..d992f7fd3c 100644 --- a/src/PhpWord/Reader/ODText.php +++ b/src/PhpWord/Reader/ODText.php @@ -53,14 +53,14 @@ public function load($docFile) /** * Read document part. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param array $relationships * @param string $partName * @param string $docFile * @param string $xmlFile * @return void */ - private function readPart(PhpWord &$phpWord, $relationships, $partName, $docFile, $xmlFile) + private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile) { $partClass = "PhpOffice\\PhpWord\\Reader\\ODText\\{$partName}"; if (class_exists($partClass)) { @@ -69,7 +69,6 @@ private function readPart(PhpWord &$phpWord, $relationships, $partName, $docFile $part->setRels($relationships); $part->read($phpWord); } - } /** diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php index aecb7419ca..cf2fd65368 100644 --- a/src/PhpWord/Reader/ODText/Content.php +++ b/src/PhpWord/Reader/ODText/Content.php @@ -30,10 +30,10 @@ class Content extends AbstractPart /** * Read content.xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php index fc061ba143..d08ce3a679 100644 --- a/src/PhpWord/Reader/ODText/Meta.php +++ b/src/PhpWord/Reader/ODText/Meta.php @@ -30,11 +30,11 @@ class Meta extends AbstractPart /** * Read meta.xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void * @todo Process property type */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index 1f3dbb3498..fcd9703fd0 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -129,11 +129,11 @@ class Document * - Builds control words and control symbols * - Pushes every other character into the text queue * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void * @todo Use `fread` stream for scalability */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $markers = array( 123 => 'markOpening', // { diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 556b0bb01e..6079567fcb 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -77,14 +77,14 @@ public function load($docFile) /** * Read document part. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param array $relationships * @param string $partName * @param string $docFile * @param string $xmlFile * @return void */ - private function readPart(PhpWord &$phpWord, $relationships, $partName, $docFile, $xmlFile) + private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile) { $partClass = "PhpOffice\\PhpWord\\Reader\\Word2007\\{$partName}"; if (class_exists($partClass)) { diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index f5bab01131..e7155c0b77 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -64,7 +64,7 @@ abstract class AbstractPart /** * Read part. */ - abstract public function read(PhpWord &$phpWord); + abstract public function read(PhpWord $phpWord); /** * Create new instance diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index 3889db0c19..4c48ecbc73 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -54,10 +54,10 @@ class DocPropsCore extends AbstractPart /** * Read core/extended document properties. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php index 0d81333eb5..eb725b2ec3 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php @@ -31,10 +31,10 @@ class DocPropsCustom extends AbstractPart /** * Read custom document properties. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index afe0e0a5a0..3ced6763cb 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -39,10 +39,10 @@ class Document extends AbstractPart /** * Read document.xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $this->phpWord = $phpWord; $xmlReader = new XMLReader(); diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index 30e6c58b43..c66b13fe90 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -44,10 +44,10 @@ class Footnotes extends AbstractPart /** * Read (footnotes|endnotes).xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $getMethod = "get{$this->collection}"; $collection = $phpWord->$getMethod()->getItems(); diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php index 7b33bc4c87..872d45033b 100644 --- a/src/PhpWord/Reader/Word2007/Numbering.php +++ b/src/PhpWord/Reader/Word2007/Numbering.php @@ -30,10 +30,10 @@ class Numbering extends AbstractPart /** * Read numbering.xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $abstracts = array(); $numberings = array(); diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php index 964147ad03..299fe1df77 100644 --- a/src/PhpWord/Reader/Word2007/Styles.php +++ b/src/PhpWord/Reader/Word2007/Styles.php @@ -30,10 +30,10 @@ class Styles extends AbstractPart /** * Read styles.xml. * - * @param \PhpOffice\PhpWord\PhpWord &$phpWord + * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function read(PhpWord &$phpWord) + public function read(PhpWord $phpWord) { $xmlReader = new XMLReader(); $xmlReader->getDomFromZip($this->docFile, $this->xmlFile); diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index f91e99a221..28055ceac0 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -106,13 +106,13 @@ public function __construct($fileName) /** * Applies XSL style sheet to template's parts. * - * @param \DOMDocument &$xslDOMDocument + * @param \DOMDocument $xslDOMDocument * @param array $xslOptions * @param string $xslOptionsURI * @return void * @throws \PhpOffice\PhpWord\Exception\Exception */ - public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') + public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') { $processor = new \XSLTProcessor(); From 7bbe1ed620de8b9835171818953c5b04342ddd36 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 16:49:01 +0400 Subject: [PATCH 083/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Reader/Word2007/AbstractPart.php | 4 ++-- src/PhpWord/Writer/AbstractWriter.php | 4 ++-- src/PhpWord/Writer/HTML.php | 3 +-- src/PhpWord/Writer/RTF.php | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index e7155c0b77..8a40937944 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -248,11 +248,11 @@ protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, $parent, * * @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader * @param \DOMElement $domNode - * @param mixed &$parent + * @param mixed $parent * @param string $docPart * @return void */ - protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart = 'document') + protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent, $docPart = 'document') { // Table style $tblStyle = null; diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 58ec89b006..52a2098f49 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -321,11 +321,11 @@ protected function openFile($filename) * * @since 0.11.0 * - * @param resource &$fileHandle + * @param resource $fileHandle * @param string $content * @return void */ - protected function writeFile(&$fileHandle, $content) + protected function writeFile($fileHandle, $content) { fwrite($fileHandle, $content); fclose($fileHandle); diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 502c50e981..5c58acfc9d 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -69,8 +69,7 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - $fileHandle = $this->openFile($filename); - $this->writeFile($fileHandle, $this->getContent()); + $this->writeFile($this->openFile($filename), $this->getContent()); } /** diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index a5a5847507..58210c997f 100644 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -63,8 +63,7 @@ public function __construct(PhpWord $phpWord = null) */ public function save($filename = null) { - $fileHandle = $this->openFile($filename); - $this->writeFile($fileHandle, $this->getContent()); + $this->writeFile($this->openFile($filename), $this->getContent()); } /** From 197c6ec0b380ba0bae640a876455198e6826db4b Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 4 Jul 2014 16:52:39 +0400 Subject: [PATCH 084/174] [FIXED] Wrong use of passing by reference. --- src/PhpWord/Element/AbstractElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 4b994a18ba..99a7a1becc 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -131,7 +131,7 @@ public function getPhpWord() * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return void */ - public function setPhpWord(PhpWord $phpWord) + public function setPhpWord(PhpWord $phpWord = null) { $this->phpWord = $phpWord; } From 7c8ff2884bcbd0e075929e221580d3e266d97a29 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 15:31:48 +0200 Subject: [PATCH 085/174] add sample fix undefined Index --- samples/Sample_35_InternalLink.php | 22 ++++++++++++++++++++++ src/PhpWord/PhpWord.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 samples/Sample_35_InternalLink.php diff --git a/samples/Sample_35_InternalLink.php b/samples/Sample_35_InternalLink.php new file mode 100644 index 0000000000..3b6aae5157 --- /dev/null +++ b/samples/Sample_35_InternalLink.php @@ -0,0 +1,22 @@ +addSection(); +$section->addTitle( 'This is page 1', 1 ); +$linkIsInternal = true; +$section->addLink('MyBookmark', 'Take me to page 3', null ,null,$linkIsInternal); +$section->addPageBreak(); +$section->addTitle( 'This is page 2', 1 ); +$section->addPageBreak(); +$section->addTitle( 'This is page 3', 1 ); +$section->addBookmark('MyBookmark'); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 419af4bee5..cde4351e64 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -139,7 +139,7 @@ public function __call($function, $args) /** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */ $collectionObject = $this->collections[$key]; - return $collectionObject->addItem($args[0]); + return $collectionObject->addItem(array_key_exists(0,$args) ? $args[0] : null); } // Run add style method From 6c9cffd83b8d40ebf82663722389f596d3b5c945 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 15:40:48 +0200 Subject: [PATCH 086/174] updated documentation for link-Element. added documentation for bookmark-Element. --- docs/elements.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/elements.rst b/docs/elements.rst index 2f2fb91cd0..46db6e40e9 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -53,6 +53,8 @@ column shows the containers while the rows lists the elements. +-------+-----------------+-----------+----------+----------+---------+------------+------------+ | 22 | Form fields | v | v | v | v | v | v | +-------+-----------------+-----------+----------+----------+---------+------------+------------+ +| 23 | Bookmarks | v | - | - | v | v | - | ++-------+-----------------+-----------+----------+----------+---------+------------+------------+ Legend: @@ -129,12 +131,13 @@ You can add Hyperlinks to the document by using the function addLink: .. code-block:: php - $section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle]); + $section->addLink($linkSrc, [$linkName], [$fontStyle], [$paragraphStyle], [$isInternal]); - ``$linkSrc`` The URL of the link. - ``$linkName`` Placeholder of the URL that appears in the document. - ``$fontStyle`` See "Font style" section. - ``$paragraphStyle`` See "Paragraph style" section. +- ``$isInternal`` Set to true, if the link points to a bookmark inside the document Preserve texts ~~~~~~~~~~~~~~ @@ -429,3 +432,14 @@ Form fields ----------- To be completed. + +Bookmarks +~~~~~ + +You can add Bookmarks to the document by using the function addBookmark: + +.. code-block:: php + + $section->addBookmark($name); + +- ``$name`` The name of the bookmark which can be referenced in the addLink-Function as target. Should obviously be unique throughout the document. \ No newline at end of file From 72026345730a0548b55664ebe218a8398cd8ad92 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 15:54:20 +0200 Subject: [PATCH 087/174] fix wrong formatting --- src/PhpWord/PhpWord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index cde4351e64..083f9d3768 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -139,7 +139,7 @@ public function __call($function, $args) /** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */ $collectionObject = $this->collections[$key]; - return $collectionObject->addItem(array_key_exists(0,$args) ? $args[0] : null); + return $collectionObject->addItem(array_key_exists(0, $args) ? $args[0] : null); } // Run add style method From 61406af166c7c049fb5ddb146e3f43562e6380f9 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 9 Jul 2014 08:51:18 +0200 Subject: [PATCH 088/174] FIXED : #292 : Update elements.rst --- CHANGELOG.md | 1 + docs/elements.rst | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ac091e22..44bf46dbc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap ### Miscellaneous - Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 +- Docs: Correct elements.rst about Line - @chrissharkman GH-292 - PclZip: Remove temporary file after used - @andrew-kzoo GH-265 - Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 - Element: Refactor elements to move set relation Id from container to element - @ivanlanin diff --git a/docs/elements.rst b/docs/elements.rst index 46db6e40e9..eae23c9dc6 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -404,13 +404,13 @@ Line elements can be added to sections by using ``addLine``. .. code-block:: php - $linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => 635552); + $linestyle = array('weight' => 1, 'width' => 100, 'height' => 0, 'color' => '#b2a68b'); $section->addLine($lineStyle) Available line style attributes: - ``weight`` Line width in twips -- ``color`` Defines the color of stroke +- ``color`` Defines the color of stroke. The hex value must be introduced with #. - ``dash`` Line types: dash, rounddot, squaredot, dashdot, longdash, longdashdot, longdashdotdot - ``beginArrow`` Start type of arrow: block, open, classic, diamond, oval - ``endArrow`` End type of arrow: block, open, classic, diamond, ovel From 07e03fc955ca39bb96647e8365c99d7ad73dd926 Mon Sep 17 00:00:00 2001 From: Philipp Scheit Date: Tue, 15 Jul 2014 10:24:36 +0200 Subject: [PATCH 089/174] bugfix: specific borders were not written correctly in word2007 --- CHANGELOG.md | 1 + src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bf46dbc7..4cb0a08610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Page breaks on titles and tables - @ivanlanin GH-274 - Table inside vertical border does not rendered properly - @ivanlanin GH-280 - `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 +- Fix specific borders (and margins) were not written correctly in word2007 writer ### Deprecated diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index fec987d376..ace1e1ac19 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -59,8 +59,8 @@ public function write() $sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV'); $sizeCount = count($this->sizes); - for ($i = 0; $i < $sizeCount; $i++) { - if ($this->sizes[$i] !== null) { + foreach ($this->sizes as $i => $size) { + if ($size !== null) { $color = null; if (isset($this->colors[$i])) { $color = $this->colors[$i]; From 06005e335d612f87dbaa37c150021a7631788a28 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 4 Aug 2014 10:50:51 +0200 Subject: [PATCH 090/174] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cb0a08610..09ba8668d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Page breaks on titles and tables - @ivanlanin GH-274 - Table inside vertical border does not rendered properly - @ivanlanin GH-280 - `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 -- Fix specific borders (and margins) were not written correctly in word2007 writer +- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 ### Deprecated From f25833c60d554b4ca73985cd28c721fe3348b154 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Mon, 4 Aug 2014 11:17:05 +0200 Subject: [PATCH 091/174] #327 : Fixes PHP-MD errors @link : https://travis-ci.org/PHPOffice/PHPWord/jobs/31598319#L539 --- src/PhpWord/Writer/Word2007/Style/MarginBorder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index ace1e1ac19..fb4afedeff 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -57,7 +57,6 @@ public function write() $xmlWriter = $this->getXmlWriter(); $sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV'); - $sizeCount = count($this->sizes); foreach ($this->sizes as $i => $size) { if ($size !== null) { From 56c3d8eda294d787af1602e4ca7227c3fed0ecbb Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 10 Aug 2014 20:00:19 +0400 Subject: [PATCH 092/174] https://github.com/PHPOffice/PHPWord/issues/310 --- CHANGELOG.md | 1 + phpword.ini.dist | 1 + samples/index.php | 2 +- src/PhpWord/Element/Image.php | 7 ++-- src/PhpWord/Settings.php | 36 +++++++++++++++++++ src/PhpWord/Shared/ZipArchive.php | 4 +-- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/AbstractWriter.php | 5 +-- tests/PhpWord/Tests/SettingsTest.php | 26 ++++++++++++++ tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php | 4 +-- .../Tests/_includes/TestHelperDOCX.php | 15 ++++---- 11 files changed, 85 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ba8668d9..e7564f686c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 - Element: Refactor elements to move set relation Id from container to element - @ivanlanin - Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko +- Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 ## 0.11.1 - 2 June 2014 diff --git a/phpword.ini.dist b/phpword.ini.dist index 4a51ee11ce..f8eafb6a78 100644 --- a/phpword.ini.dist +++ b/phpword.ini.dist @@ -7,6 +7,7 @@ compatibility = true zipClass = ZipArchive pdfRendererName = DomPDF pdfRendererPath = +; tempDir = "C:\PhpWordTemp" [Font] diff --git a/samples/index.php b/samples/index.php index 5632664fed..4281f6fb10 100644 --- a/samples/index.php +++ b/samples/index.php @@ -3,7 +3,7 @@ $requirements = array( 'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), 'xml' => array('PHP extension XML', extension_loaded('xml')), - 'temp' => array('Temp folder "' . sys_get_temp_dir() . '" is writable', is_writable(sys_get_temp_dir())), + 'temp' => array('Temp folder "' . Settings::getTempDir() . '" is writable', is_writable(Settings::getTempDir())), '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')), diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index e48f703ed1..4a812f6cc2 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\UnsupportedImageTypeException; +use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\ZipArchive; use PhpOffice\PhpWord\Style\Image as ImageStyle; @@ -313,8 +314,8 @@ public function getImageStringData($base64 = false) 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; + $zip->extractTo(Settings::getTempDir(), $imageFilename); + $actualSource = Settings::getTempDir() . DIRECTORY_SEPARATOR . $imageFilename; } } $zip->close(); @@ -428,7 +429,7 @@ private function getArchiveImageSize($source) $imageData = null; $source = substr($source, 6); list($zipFilename, $imageFilename) = explode('#', $source); - $tempFilename = tempnam(sys_get_temp_dir(), 'PHPWordImage'); + $tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage'); $zip = new ZipArchive(); if ($zip->open($zipFilename) !== false) { diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 8481717b49..009c849ced 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -119,6 +119,13 @@ class Settings */ private static $defaultFontSize = self::DEFAULT_FONT_SIZE; + /** + * The user defined temporary directory. + * + * @var string + */ + private static $tempDir = ''; + /** * Return the compatibility option used by the XMLWriter * @@ -269,6 +276,35 @@ public static function setMeasurementUnit($value) return true; } + /** + * Sets the user defined path to temporary directory. + * + * @param string $tempDir The user defined path to temporary directory. + * @return void + * @since 0.12.0 + */ + public static function setTempDir($tempDir) + { + self::$tempDir = $tempDir; + } + + /** + * Returns path to temporary directory. + * + * @return string + * @since 0.12.0 + */ + public static function getTempDir() + { + $tempDir = sys_get_temp_dir(); + + if (!empty(self::$tempDir)) { + $tempDir = self::$tempDir; + } + + return $tempDir; + } + /** * Get default font name * diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 7515c5b50a..38781a80fa 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -83,7 +83,7 @@ public function __construct() $this->usePclzip = (Settings::getZipClass() != 'ZipArchive'); if ($this->usePclzip) { if (!defined('PCLZIP_TEMPORARY_DIR')) { - define('PCLZIP_TEMPORARY_DIR', sys_get_temp_dir() . '/'); + define('PCLZIP_TEMPORARY_DIR', Settings::getTempDir() . '/'); } require_once 'PCLZip/pclzip.lib.php'; } @@ -139,7 +139,7 @@ public function open($filename, $flags = null) $this->numFiles = $zip->numFiles; } else { $zip = new \PclZip($this->filename); - $this->tempDir = sys_get_temp_dir(); + $this->tempDir = Settings::getTempDir(); $this->numFiles = count($zip->listContent()); } $this->zip = $zip; diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index 28055ceac0..c8f8802605 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -67,7 +67,7 @@ class Template */ public function __construct($fileName) { - $this->tempFileName = tempnam(sys_get_temp_dir(), ''); + $this->tempFileName = tempnam(Settings::getTempDir(), 'PhpWord'); if (false === $this->tempFileName) { throw new CreateTemporaryFileException(); } diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 52a2098f49..c74819b55e 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -20,6 +20,7 @@ use PhpOffice\PhpWord\Exception\CopyFileException; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\ZipArchive; /** @@ -214,12 +215,12 @@ public function setTempDir($value) protected function getTempFile($filename) { // Temporary directory - $this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/'); + $this->setTempDir(Settings::getTempDir() . '/PHPWordWriter/'); // Temporary file $this->originalFilename = $filename; if (strtolower($filename) == 'php://output' || strtolower($filename) == 'php://stdout') { - $filename = @tempnam(sys_get_temp_dir(), 'phpword_'); + $filename = tempnam(Settings::getTempDir(), 'phpword_'); // @codeCoverageIgnoreStart // Can't find any test case. Uncomment when found. if ($filename == '') { diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 6136403449..0d3d66aecc 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -22,6 +22,7 @@ /** * Test class for PhpOffice\PhpWord\Settings * + * @coversDefaultClass \PhpOffice\PhpWord\Settings * @runTestsInSeparateProcesses */ class SettingsTest extends \PHPUnit_Framework_TestCase @@ -70,6 +71,31 @@ public function testSetGetMeasurementUnit() $this->assertFalse(Settings::setMeasurementUnit('foo')); } + /** + * @covers ::getTempDir + * @test + */ + public function testPhpTempDirIsUsedByDefault() + { + $this->assertEquals(sys_get_temp_dir(), Settings::getTempDir()); + } + + + /** + * @covers ::setTempDir + * @covers ::getTempDir + * @depends testPhpTempDirIsUsedByDefault + * @test + */ + public function testTempDirCanBeSet() + { + $userDefinedTempDir = 'C:\PhpWordTemp'; + Settings::setTempDir($userDefinedTempDir); + $currentTempDir = Settings::getTempDir(); + $this->assertEquals($userDefinedTempDir, $currentTempDir); + $this->assertNotEquals(sys_get_temp_dir(), $currentTempDir); + } + /** * Test set/get default font name */ diff --git a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php index a22cb53051..476c9011dc 100644 --- a/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php +++ b/tests/PhpWord/Tests/Writer/PDF/DomPDFTest.php @@ -71,7 +71,7 @@ public function testSetGetAbstractRendererProperties() $writer->setOrientation(); $this->assertEquals('default', $writer->getOrientation()); - $writer->setTempDir(sys_get_temp_dir()); - $this->assertEquals(sys_get_temp_dir(), $writer->getTempDir()); + $writer->setTempDir(Settings::getTempDir()); + $this->assertEquals(Settings::getTempDir(), $writer->getTempDir()); } } diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index 7998cbdc8a..553a51beec 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -19,6 +19,7 @@ use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Settings; /** * Test helper class @@ -41,9 +42,9 @@ class TestHelperDOCX */ public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007') { - self::$file = tempnam(sys_get_temp_dir(), 'PhpWord'); - if (!is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) { - mkdir(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); + self::$file = tempnam(Settings::getTempDir(), 'PhpWord'); + if (!is_dir(Settings::getTempDir() . '/PhpWord_Unit_Test/')) { + mkdir(Settings::getTempDir() . '/PhpWord_Unit_Test/'); } $xmlWriter = IOFactory::createWriter($phpWord, $writerName); @@ -52,11 +53,11 @@ public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007') $zip = new \ZipArchive; $res = $zip->open(self::$file); if ($res === true) { - $zip->extractTo(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); + $zip->extractTo(Settings::getTempDir() . '/PhpWord_Unit_Test/'); $zip->close(); } - return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); + return new XmlDocument(Settings::getTempDir() . '/PhpWord_Unit_Test/'); } /** @@ -67,8 +68,8 @@ public static function clear() if (file_exists(self::$file)) { unlink(self::$file); } - if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) { - self::deleteDir(sys_get_temp_dir() . '/PhpWord_Unit_Test/'); + if (is_dir(Settings::getTempDir() . '/PhpWord_Unit_Test/')) { + self::deleteDir(Settings::getTempDir() . '/PhpWord_Unit_Test/'); } } From e6d88a27e881c318a8435d0b254a7ba2cd2e4275 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 10 Aug 2014 20:30:14 +0400 Subject: [PATCH 093/174] Refactored usages of "tempnam()" function. --- src/PhpWord/Element/Image.php | 8 +++++++- src/PhpWord/Shared/XMLWriter.php | 4 ++-- src/PhpWord/Writer/AbstractWriter.php | 7 ++----- tests/PhpWord/Tests/_includes/TestHelperDOCX.php | 6 ++++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 4a812f6cc2..ab350e0788 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\UnsupportedImageTypeException; use PhpOffice\PhpWord\Settings; @@ -423,13 +424,18 @@ private function setSourceType($source) * * @param string $source * @return array|null + * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException */ private function getArchiveImageSize($source) { $imageData = null; $source = substr($source, 6); list($zipFilename, $imageFilename) = explode('#', $source); + $tempFilename = tempnam(Settings::getTempDir(), 'PHPWordImage'); + if (false === $tempFilename) { + throw new CreateTemporaryFileException(); + } $zip = new ZipArchive(); if ($zip->open($zipFilename) !== false) { @@ -437,7 +443,7 @@ private function getArchiveImageSize($source) $imageContent = $zip->getFromName($imageFilename); if ($imageContent !== false) { file_put_contents($tempFilename, $imageContent); - $imageData = @getimagesize($tempFilename); + $imageData = getimagesize($tempFilename); unlink($tempFilename); } } diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 3d8b845786..2134f62a9d 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -66,12 +66,12 @@ public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = $this->xmlWriter->openMemory(); } else { // Create temporary filename - $this->tempFile = @tempnam($tempFolder, 'xml'); + $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) { + if (false === $this->tempFile || false === $this->xmlWriter->openUri($this->tempFile)) { $this->xmlWriter->openMemory(); } // @codeCoverageIgnoreEnd diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index c74819b55e..31097b899f 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -220,13 +220,10 @@ protected function getTempFile($filename) // Temporary file $this->originalFilename = $filename; if (strtolower($filename) == 'php://output' || strtolower($filename) == 'php://stdout') { - $filename = tempnam(Settings::getTempDir(), 'phpword_'); - // @codeCoverageIgnoreStart - // Can't find any test case. Uncomment when found. - if ($filename == '') { + $filename = tempnam(Settings::getTempDir(), 'PhpWord'); + if (false === $filename) { $filename = $this->originalFilename; } - // @codeCoverageIgnoreEnd } $this->tempFilename = $filename; diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index 553a51beec..6ca6a14d55 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Tests; +use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Settings; @@ -39,10 +40,15 @@ class TestHelperDOCX * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $writerName * @return \PhpOffice\PhpWord\Tests\XmlDocument + * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException */ public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007') { self::$file = tempnam(Settings::getTempDir(), 'PhpWord'); + if (false === self::$file) { + throw new CreateTemporaryFileException(); + } + if (!is_dir(Settings::getTempDir() . '/PhpWord_Unit_Test/')) { mkdir(Settings::getTempDir() . '/PhpWord_Unit_Test/'); } From e31f080ea6149a309e73c31acba4efe47eab9e31 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 10 Aug 2014 20:46:10 +0400 Subject: [PATCH 094/174] Removed unused comment. --- src/PhpWord/PhpWord.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 083f9d3768..84e5ebc778 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -297,7 +297,6 @@ public function save($filename, $format = 'Word2007', $download = false) 'PDF' => 'application/pdf', ); - /** @var \PhpOffice\PhpWord\Writer\WriterInterface $writer */ $writer = IOFactory::createWriter($this, $format); if ($download === true) { From 3d06c77fc1a49d04555ce240ba64bc06383adc10 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 10 Aug 2014 21:01:46 +0400 Subject: [PATCH 095/174] Minor refactoring of "Shared\ZipArchive" class. --- src/PhpWord/Shared/ZipArchive.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 38781a80fa..157959e8e9 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -158,7 +158,7 @@ public function close() { if (!$this->usePclzip) { if ($this->zip->close() === false) { - throw new Exception("Could not close zip file $this->filename."); + throw new Exception("Could not close zip file {$this->filename}."); } } @@ -233,7 +233,7 @@ public function pclzipAddFile($filename, $localname = null) $tempFile = false; if ($filenameParts['basename'] != $localnameParts['basename']) { $tempFile = true; // temp file created - $temppath = $this->tempDir . '/' . $localnameParts['basename']; + $temppath = $this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']; copy($filename, $temppath); $filename = $temppath; $filenameParts = pathinfo($temppath); @@ -246,7 +246,7 @@ public function pclzipAddFile($filename, $localname = null) if ($tempFile) { // Remove temp file, if created - @unlink($this->tempDir . '/' . $localnameParts["basename"]); + unlink($this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']); } return ($res == 0) ? false : true; @@ -266,19 +266,19 @@ public function pclzipAddFromString($localname, $contents) $filenameParts = pathinfo($localname); // Write $contents to a temp file - $handle = fopen($this->tempDir . '/' . $filenameParts["basename"], "wb"); + $handle = fopen($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'], 'wb'); fwrite($handle, $contents); fclose($handle); // Add temp file to zip - $filename = $this->tempDir . '/' . $filenameParts["basename"]; + $filename = $this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']; $pathRemoved = $this->tempDir; $pathAdded = $filenameParts['dirname']; $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); // Remove temp file - @unlink($this->tempDir . '/' . $filenameParts["basename"]); + @unlink($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']); return ($res == 0) ? false : true; } @@ -338,7 +338,7 @@ public function pclzipGetFromName($filename) $extracted = $zip->extractByIndex($listIndex, PCLZIP_OPT_EXTRACT_AS_STRING); } if ((is_array($extracted)) && ($extracted != 0)) { - $contents = $extracted[0]["content"]; + $contents = $extracted[0]['content']; } return $contents; @@ -377,8 +377,8 @@ public function pclzipLocateName($filename) $listCount = count($list); $listIndex = -1; for ($i = 0; $i < $listCount; ++$i) { - if (strtolower($list[$i]["filename"]) == strtolower($filename) || - strtolower($list[$i]["stored_filename"]) == strtolower($filename)) { + if (strtolower($list[$i]['filename']) == strtolower($filename) || + strtolower($list[$i]['stored_filename']) == strtolower($filename)) { $listIndex = $i; break; } From 6f2d444ba9dd97a2c2fb18b3022e3fefa46a64bc Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 11 Aug 2014 22:30:46 +0400 Subject: [PATCH 096/174] https://github.com/PHPOffice/PHPWord/issues/310 --- src/PhpWord/Element/Image.php | 2 ++ src/PhpWord/Settings.php | 6 ++++-- tests/PhpWord/Tests/_includes/TestHelperDOCX.php | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index ab350e0788..cab2527a4e 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -422,6 +422,8 @@ private function setSourceType($source) /** * Get image size from archive * + * @since 0.12.0 Throws CreateTemporaryFileException. + * * @param string $source * @return array|null * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 009c849ced..6c7f17e17b 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -279,9 +279,10 @@ public static function setMeasurementUnit($value) /** * Sets the user defined path to temporary directory. * + * @since 0.12.0 + * * @param string $tempDir The user defined path to temporary directory. * @return void - * @since 0.12.0 */ public static function setTempDir($tempDir) { @@ -291,8 +292,9 @@ public static function setTempDir($tempDir) /** * Returns path to temporary directory. * - * @return string * @since 0.12.0 + * + * @return string */ public static function getTempDir() { diff --git a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php index 6ca6a14d55..2a0043d5c8 100644 --- a/tests/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/tests/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -37,6 +37,8 @@ class TestHelperDOCX /** * Get document content * + * @since 0.12.0 Throws CreateTemporaryFileException. + * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $writerName * @return \PhpOffice\PhpWord\Tests\XmlDocument From 8d9e85b2ba21752c1cbfe7b7a48b14e4b54bfa03 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 12 Aug 2014 13:32:05 +0200 Subject: [PATCH 097/174] #331 : Word2007 Writer : Support for RTL --- .gitignore | 1 + CHANGELOG.md | 1 + docs/intro.rst | 1 + docs/styles.rst | 1 + samples/Sample_36_RTL.php | 19 +++++++ samples/index.php | 2 + src/PhpWord/Reader/Word2007/AbstractPart.php | 1 + src/PhpWord/Style/Font.php | 30 +++++++++++ src/PhpWord/Writer/Word2007/Style/Font.php | 6 +++ .../Tests/Writer/Word2007/Style/FontTest.php | 54 +++++++++++++++++++ 10 files changed, 116 insertions(+) create mode 100644 samples/Sample_36_RTL.php create mode 100644 tests/PhpWord/Tests/Writer/Word2007/Style/FontTest.php diff --git a/.gitignore b/.gitignore index 810a7b0ae1..a74da9de19 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ phpword.ini /.settings /build /vendor +/phpunit.bat diff --git a/CHANGELOG.md b/CHANGELOG.md index e7564f686c..6040c46e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin - SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin - Paragraph: Support for paragraph with borders - @ivanlanin GH-294 +- Word2007 Writer : Support for RTL - @Progi1984 GH-331 ### Bugfixes diff --git a/docs/intro.rst b/docs/intro.rst index b604298fd7..03821c9113 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -37,6 +37,7 @@ Features run) that contains other elements - Insert titles (headers) and table of contents - Insert text breaks and page breaks +- Insert right-to-left text - 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 diff --git a/docs/styles.rst b/docs/styles.rst index cd07a9f7e0..91d5ed7a8a 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -56,6 +56,7 @@ Available font styles: - ``bgColor`` Font background color, e.g. *FF0000* - ``smallCaps`` Small caps, *true* or *false* - ``allCaps`` All caps, *true* or *false* +- ``rtl`` Right to Left language, *true* or *false* Paragraph --------- diff --git a/samples/Sample_36_RTL.php b/samples/Sample_36_RTL.php new file mode 100644 index 0000000000..9b85fb1e1f --- /dev/null +++ b/samples/Sample_36_RTL.php @@ -0,0 +1,19 @@ +addSection(); +$textrun = $section->addTextRun(); +$textrun->addText('This is a Left to Right paragraph.'); + +$textrun = $section->addTextRun(array('align' => 'right')); +$textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true)); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/samples/index.php b/samples/index.php index 4281f6fb10..f25f7f334b 100644 --- a/samples/index.php +++ b/samples/index.php @@ -1,5 +1,7 @@ array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), 'xml' => array('PHP extension XML', extension_loaded('xml')), diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 8a40937944..7d3e0f66df 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -373,6 +373,7 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode) 'superScript' => array(self::READ_EQUAL, 'w:vertAlign', 'w:val', 'superscript'), 'subScript' => array(self::READ_EQUAL, 'w:vertAlign', 'w:val', 'subscript'), 'fgColor' => array(self::READ_VALUE, 'w:highlight'), + 'rtl' => array(self::READ_TRUE, 'w:rtl'), ); return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs); diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 000e2bb688..8980258b43 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -222,6 +222,12 @@ class Font extends AbstractStyle */ private $shading; + /** + * Right to left languages + * @var boolean + */ + private $rtl = false; + /** * Create new font style * @@ -268,6 +274,7 @@ public function getStyleValues() 'kerning' => $this->getKerning(), ), 'paragraph' => $this->getParagraph(), + 'rtl' => $this->isRTL(), 'shading' => $this->getShading(), ); @@ -730,6 +737,29 @@ public function setParagraph($value = null) return $this; } + /** + * Get rtl + * + * @return bool + */ + public function isRTL() + { + return $this->rtl; + } + + /** + * Set rtl + * + * @param bool $value + * @return self + */ + public function setRTL($value = true) + { + $this->rtl = $this->setBoolVal($value, $this->rtl); + + return $this; + } + /** * Get shading * diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 67a0482965..9371f97003 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -129,6 +129,12 @@ private function writeStyle() $styleWriter = new Shading($xmlWriter, $shading); $styleWriter->write(); } + + // RTL + if ($this->isInline === true) { + $styleName = $style->getStyleName(); + $xmlWriter->writeElementIf($styleName === null && $style->isRTL(), 'w:rtl'); + } $xmlWriter->endElement(); } diff --git a/tests/PhpWord/Tests/Writer/Word2007/Style/FontTest.php b/tests/PhpWord/Tests/Writer/Word2007/Style/FontTest.php new file mode 100644 index 0000000000..af11c054ff --- /dev/null +++ b/tests/PhpWord/Tests/Writer/Word2007/Style/FontTest.php @@ -0,0 +1,54 @@ +addSection(); + $textrun = $section->addTextRun(); + $textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true)); + $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); + + $file = 'word/document.xml'; + $path = '/w:document/w:body/w:p/w:r/w:rPr/w:rtl'; + $this->assertTrue($doc->elementExists($path, $file)); + } +} From ca69de396200461c7a5fe7bec38fff72cdac96bd Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Fri, 15 Aug 2014 19:26:23 +0200 Subject: [PATCH 098/174] #23 : Implement Word97 aka MsDoc Reader --- samples/Sample_11_ReadWord97.php | 6 +- samples/Sample_Header.php | 3 + src/PhpWord/Reader/MsDoc.php | 3267 +++++++++++++++++++----------- src/PhpWord/Shared/Drawing.php | 70 + src/PhpWord/Style/Font.php | 1 - 5 files changed, 2168 insertions(+), 1179 deletions(-) diff --git a/samples/Sample_11_ReadWord97.php b/samples/Sample_11_ReadWord97.php index f0df59bf1d..68a30d362d 100644 --- a/samples/Sample_11_ReadWord97.php +++ b/samples/Sample_11_ReadWord97.php @@ -5,15 +5,15 @@ $name = basename(__FILE__, '.php'); $source = "resources/{$name}.doc"; echo date('H:i:s'), " Reading contents from `{$source}`", EOL; -$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'Word97'); +$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'MsDoc'); // (Re)write contents -/*$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); +$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); -}*/ +} include_once 'Sample_Footer.php'; diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index c6431c03c4..a7721559a2 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -1,4 +1,7 @@ readFib($this->dataWorkDocument); $this->readFibContent(); - /*$this->read1Table($this->data1Table); - $this->readData($this->dataData); - $this->readObjectPool($this->dataObjectPool);*/ return $this->phpWord; } @@ -99,9 +139,22 @@ private function loadOLE($filename) // Get Data stream $this->dataObjectPool = $ole->getStream($ole->wrkObjectPool); // Get Summary Information data - $this->_summaryInformation = $ole->getStream($ole->summaryInformation); + $this->_SummaryInformation = $ole->getStream($ole->summaryInformation); // Get Document Summary Information data - $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); + $this->_DocumentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); + } + + private function getNumInLcb($lcb, $iSize){ + return ($lcb - 4) / (4 + $iSize); + } + + private function getArrayCP($data, $posMem, $iNum){ + $arrayCP = array(); + for($inc = 0 ; $inc < $iNum ; $inc++){ + $arrayCP[$inc] = self::getInt4d($data, $posMem); + $posMem += 4; + } + return $arrayCP; } /** @@ -111,1264 +164,2116 @@ private function loadOLE($filename) */ private function readFib($data) { - $length = 0; - print_r('============ readFib'.PHP_EOL); - print_r('============ length : '.strlen($data).PHP_EOL); - print_r('======================== FibBase'.PHP_EOL); + $pos = 0; //----- FibBase // wIdent - $wIdent = self::_GetInt2d($data, $length); - $length += 2; - print_r('$wIdent : '.$wIdent.'#'.dechex($wIdent).PHP_EOL); + $pos += 2; // nFib - $nFib = self::_GetInt2d($data, $length); - print_r('$nFib : '.$nFib.'#'.dechex($nFib).PHP_EOL); - $length += 2; + $pos += 2; // unused - $length += 2; + $pos += 2; // lid : Language Identifier - $lid = self::_GetInt2d($data, $length); - $length += 2; + $pos += 2; // pnNext - $pnNext = self::_GetInt2d($data, $length); - $length += 2; - - $mem = self::_GetInt2d($data, $length); - $fDot = ($mem >> 15) & 1; - $fGlsy = ($mem >> 14) & 1; - $fComplex = ($mem >> 13) & 1; - $fHasPic = ($mem >> 12) & 1; - $cQuickSaves = ($mem >> 8) & bindec('1111'); - $fEncrypted = ($mem >> 7) & 1; - $fWhichTblStm = ($mem >> 6) & 1; - print_r('$fWhichTblStm : '.$fWhichTblStm.'#'.dechex($fWhichTblStm).PHP_EOL); - $fReadOnlyRecommended = ($mem >> 5) & 1; - $fWriteReservation = ($mem >> 4) & 1; - $fExtChar = ($mem >> 3) & 1; - $fLoadOverride = ($mem >> 2) & 1; - $fFarEast = ($mem >> 1) & 1; - $fObfuscated = ($mem >> 0) & 1; - $length += 2; + $pos += 2; + + // $mem = self::getInt2d($data, $pos); + // $fDot = ($mem >> 15) & 1; + // $fGlsy = ($mem >> 14) & 1; + // $fComplex = ($mem >> 13) & 1; + // $fHasPic = ($mem >> 12) & 1; + // $cQuickSaves = ($mem >> 8) & bindec('1111'); + // $fEncrypted = ($mem >> 7) & 1; + // $fWhichTblStm = ($mem >> 6) & 1; + // $fReadOnlyRecommended = ($mem >> 5) & 1; + // $fWriteReservation = ($mem >> 4) & 1; + // $fExtChar = ($mem >> 3) & 1; + // $fLoadOverride = ($mem >> 2) & 1; + // $fFarEast = ($mem >> 1) & 1; + // $fObfuscated = ($mem >> 0) & 1; + $pos += 2; // nFibBack - $nFibBack = self::_GetInt2d($data, $length); - $length += 2; + $pos += 2; // lKey - $lKey = self::_GetInt4d($data, $length); - $length += 4; + $pos += 4; // envr - $envr = self::_GetInt1d($data, $length); - $length += 1; - - $mem = self::_GetInt1d($data, $length); - $fMac = ($mem >> 7) & 1; - $fEmptySpecial = ($mem >> 6) & 1; - $fLoadOverridePage = ($mem >> 5) & 1; - $reserved1 = ($mem >> 4) & 1; - $reserved2 = ($mem >> 3) & 1; - $fSpare0 = ($mem >> 0) & bindec('111'); - $length += 1; - - $reserved3 = self::_GetInt2d($data, $length); - $length += 2; - $reserved4 = self::_GetInt2d($data, $length); - $length += 2; - $reserved5 = self::_GetInt4d($data, $length); - $length += 4; - $reserved6 = self::_GetInt4d($data, $length); - $length += 4; + $pos += 1; + + // $mem = self::getInt1d($data, $pos); + // $fMac = ($mem >> 7) & 1; + // $fEmptySpecial = ($mem >> 6) & 1; + // $fLoadOverridePage = ($mem >> 5) & 1; + // $reserved1 = ($mem >> 4) & 1; + // $reserved2 = ($mem >> 3) & 1; + // $fSpare0 = ($mem >> 0) & bindec('111'); + $pos += 1; + + // reserved3 + $pos += 2; + // reserved4 + $pos += 2; + // reserved5 + $pos += 4; + // reserved6 + $pos += 4; //----- csw - print_r('======================== csw'.PHP_EOL); - $csw = self::_GetInt2d($data, $length); - $length += 2; - print_r('$csw : '.$csw.'#'.dechex($csw).PHP_EOL); + $pos += 2; //----- fibRgW - print_r('======================== fibRgW'.PHP_EOL); - $fibRgW_reserved1 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved2 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved3 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved4 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved5 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved6 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved7 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved8 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved9 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved10 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved11 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved12 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_reserved13 = self::_GetInt2d($data, $length); - $length += 2; - $fibRgW_lidFE = self::_GetInt2d($data, $length); - $length += 2; + // reserved1 + $pos += 2; + // reserved2 + $pos += 2; + // reserved3 + $pos += 2; + // reserved4 + $pos += 2; + // reserved5 + $pos += 2; + // reserved6 + $pos += 2; + // reserved7 + $pos += 2; + // reserved8 + $pos += 2; + // reserved9 + $pos += 2; + // reserved10 + $pos += 2; + // reserved11 + $pos += 2; + // reserved12 + $pos += 2; + // reserved13 + $pos += 2; + // lidFE + $pos += 2; //----- cslw - print_r('======================== cslw'.PHP_EOL); - $cslw = self::_GetInt2d($data, $length); - $length += 2; - print_r('$cslw : '.$cslw.'#'.dechex($cslw).PHP_EOL); + $pos += 2; //----- fibRgLw - print_r('======================== fibRgLw'.PHP_EOL); - $fibRgLw_cbMac = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved1 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved2 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpText = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpFtn = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpHdd = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved3 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpAtn = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpEdn = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpTxbx = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_ccpHdrTxbx = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved4 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved5 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved6 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved7 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved8 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved9 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved10 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved11 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved12 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved13 = self::_GetInt4d($data, $length); - $length += 4; - $fibRgLw_reserved14 = self::_GetInt4d($data, $length); - $length += 4; + // cbMac + $pos += 4; + // reserved1 + $pos += 4; + // reserved2 + $pos += 4; + $this->arrayFib['ccpText'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['ccpFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['ccpHdd'] = self::getInt4d($data, $pos); + $pos += 4; + // reserved3 + $pos += 4; + // ccpAtn + $pos += 4; + // ccpEdn + $pos += 4; + // ccpTxbx + $pos += 4; + // ccpHdrTxbx + $pos += 4; + // reserved4 + $pos += 4; + // reserved5 + $pos += 4; + // reserved6 + $pos += 4; + // reserved7 + $pos += 4; + // reserved8 + $pos += 4; + // reserved9 + $pos += 4; + // reserved10 + $pos += 4; + // reserved11 + $pos += 4; + // reserved12 + $pos += 4; + // reserved13 + $pos += 4; + // reserved14 + $pos += 4; //----- cbRgFcLcb - print_r('======================== cbRgFcLcb'.PHP_EOL); - $cbRgFcLcb = self::_GetInt2d($data, $length); - print_r('$cbRgFcLcb : '.$cbRgFcLcb.'#'.dechex($cbRgFcLcb).PHP_EOL); - $length += 2; + $cbRgFcLcb = self::getInt2d($data, $pos); + $pos += 2; //----- fibRgFcLcbBlob - print_r('======================== fibRgFcLcbBlob'.PHP_EOL); switch ($cbRgFcLcb) { case 0x005D: - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); break; case 0x006C: - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); break; case 0x0088: - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002); break; case 0x00A4 : - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2003); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2003); break; case 0x00B7: - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_97); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2000); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2002); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2003); - $length = $this->readBlockFibRgFcLcb($data, $length, self::VERSION_2007); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2003); + $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2007); break; } - //print_r($this->arrayFib); //----- cswNew - print_r('======================== cswNew'.PHP_EOL); - $cswNew = self::_GetInt2d($data, $length); - $length += 2; - print_r('$cswNew : '.$cswNew.'#'.dechex($cswNew).PHP_EOL); - - if($cswNew != 0){ - // fibRgCswNew - print_r('======================== fibRgCswNew'.PHP_EOL); + $this->arrayFib['cswNew'] = self::getInt2d($data, $pos); + $pos += 2; + + if($this->arrayFib['cswNew'] != 0){ + //@todo : fibRgCswNew } - print_r('======================== length : '.$length.'#'.dechex($length).PHP_EOL); - return $length; + return $pos; } - const VERSION_97 = '97'; - const VERSION_2000 = '2000'; - const VERSION_2002 = '2002'; - const VERSION_2003 = '2003'; - const VERSION_2007 = '2007'; - - /** - * @var array - */ - private $arrayFib = array(); - - private function readBlockFibRgFcLcb($data, $length, $version) + private function readBlockFibRgFcLcb($data, $pos, $version) { if($version == self::VERSION_97){ - $this->arrayFib['fcStshfOrig'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbStshfOrig'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcStshf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbStshf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcffndRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcffndRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcffndTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcffndTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfandRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfandRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfandTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfandTxt '] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfSed'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfSed'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcPad'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcPad'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfPhe'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfPhe'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfGlsy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfGlsy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfGlsy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfGlsy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfHdd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfHdd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBteChpx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBteChpx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBtePapx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBtePapx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfSea'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfSea'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfFfn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfFfn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldMom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldMom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldHdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldHdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldAtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldAtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldMcr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldMcr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmk'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmk'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcCmds'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbCmds'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfMcr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfMcr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPrDrvr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPrDrvr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPrEnvPort'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPrEnvPort'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPrEnvLand'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPrEnvLand'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcWss'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbWss'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcDop'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbDop'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfAssoc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfAssoc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcClx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbClx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfPgdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfPgdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAutosaveSource'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAutosaveSource'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcGrpXstAtnOwners'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbGrpXstAtnOwners'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfAtnBkmk'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfAtnBkmk'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused3'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused3'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcSpaMom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcSpaMom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcSpaHdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcSpaHdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfAtnBkf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfAtnBkf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfAtnBkl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfAtnBkl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPms'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPms'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcFormFldSttbs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbFormFldSttbs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfendRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfendRef'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfendTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfendTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused4'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused4'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcDggInfo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbDggInfo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfRMark'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfRMark'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfCaption'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfCaption'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfAutoCaption'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfAutoCaption'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfWkb'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfWkb'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfSpl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfSpl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcftxbxTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcftxbxTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfFldTxbx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfFldTxbx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfHdrtxbxTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfHdrtxbxTxt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcffldHdrTxbx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcffldHdrTxbx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcStwUser'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbStwUser'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbTtmbd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbTtmbd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcCookieData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbCookieData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdMotherOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdMotherOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdMotherOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdMotherOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdFtnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdFtnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdFtnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdFtnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdEdnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdEdnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdEdnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdEdnOldOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfIntlFld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfIntlFld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcRouteSlip'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbRouteSlip'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbSavedBy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbSavedBy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbFnm'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbFnm'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlfLst'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlfLst'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlfLfo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlfLfo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfTxbxBkd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfTxbxBkd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfTxbxHdrBkd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfTxbxHdrBkd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcDocUndoWord9'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbDocUndoWord9'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcRgbUse'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbRgbUse'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUsp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUsp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUskf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUskf'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcupcRgbUse'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcupcRgbUse'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcupcUsp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcupcUsp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbGlsyStyle'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbGlsyStyle'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlgosl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlgosl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcocx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcocx'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBteLvc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBteLvc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['dwLowDateTime'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['dwHighDateTime'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfLvcPre10'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfLvcPre10'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfAsumy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfAsumy'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfGram'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfGram'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbListNames'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbListNames'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfUssr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfUssr'] = self::_GetInt4d($data, $length); - $length += 4; + $this->arrayFib['fcStshfOrig'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbStshfOrig'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcStshf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbStshf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcffndRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcffndRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcffndTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcffndTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfandRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfandRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfandTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfandTxt '] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfSed'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfSed'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcPad'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcPad'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfPhe'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfPhe'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfGlsy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfGlsy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfGlsy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfGlsy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfHdd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfHdd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBteChpx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBteChpx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBtePapx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBtePapx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfSea'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfSea'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfFfn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfFfn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldMom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldMom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldHdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldHdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldAtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldAtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldMcr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldMcr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmk'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmk'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcCmds'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbCmds'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfMcr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfMcr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPrDrvr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPrDrvr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPrEnvPort'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPrEnvPort'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPrEnvLand'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPrEnvLand'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcWss'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbWss'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcDop'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbDop'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfAssoc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfAssoc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcClx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbClx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfPgdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfPgdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAutosaveSource'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAutosaveSource'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcGrpXstAtnOwners'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbGrpXstAtnOwners'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfAtnBkmk'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfAtnBkmk'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused3'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused3'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcSpaMom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcSpaMom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcSpaHdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcSpaHdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfAtnBkf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfAtnBkf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfAtnBkl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfAtnBkl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPms'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPms'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcFormFldSttbs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbFormFldSttbs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfendRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfendRef'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfendTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfendTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused4'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused4'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcDggInfo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbDggInfo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfRMark'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfRMark'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfCaption'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfCaption'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfAutoCaption'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfAutoCaption'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfWkb'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfWkb'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfSpl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfSpl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcftxbxTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcftxbxTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfFldTxbx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfFldTxbx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfHdrtxbxTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfHdrtxbxTxt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcffldHdrTxbx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcffldHdrTxbx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcStwUser'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbStwUser'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbTtmbd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbTtmbd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcCookieData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbCookieData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdMotherOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdMotherOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdMotherOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdMotherOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdFtnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdFtnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdFtnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdFtnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdEdnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdEdnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdEdnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdEdnOldOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfIntlFld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfIntlFld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcRouteSlip'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbRouteSlip'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbSavedBy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbSavedBy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbFnm'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbFnm'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlfLst'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlfLst'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlfLfo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlfLfo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfTxbxBkd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfTxbxBkd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfTxbxHdrBkd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfTxbxHdrBkd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcDocUndoWord9'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbDocUndoWord9'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcRgbUse'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbRgbUse'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUsp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUsp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUskf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUskf'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcupcRgbUse'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcupcRgbUse'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcupcUsp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcupcUsp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbGlsyStyle'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbGlsyStyle'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlgosl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlgosl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcocx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcocx'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBteLvc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBteLvc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['dwLowDateTime'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['dwHighDateTime'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfLvcPre10'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfLvcPre10'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfAsumy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfAsumy'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfGram'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfGram'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbListNames'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbListNames'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfUssr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfUssr'] = self::getInt4d($data, $pos); + $pos += 4; } if($version == self::VERSION_2000){ - $this->arrayFib['fcPlcfTch'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfTch'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcRmdThreading'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbRmdThreading'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcMid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbMid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbRgtplc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbRgtplc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcMsoEnvelope'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbMsoEnvelope'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfLad'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfLad'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcRgDofr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbRgDofr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcosl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcosl'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfCookieOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfCookieOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdMotherOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdMotherOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdMotherOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdMotherOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdFtnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdFtnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdFtnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdFtnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdEdnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdEdnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdEdnOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdEdnOld'] = self::_GetInt4d($data, $length); - $length += 4; + $this->arrayFib['fcPlcfTch'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfTch'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcRmdThreading'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbRmdThreading'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcMid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbMid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbRgtplc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbRgtplc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcMsoEnvelope'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbMsoEnvelope'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfLad'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfLad'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcRgDofr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbRgDofr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcosl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcosl'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfCookieOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfCookieOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdMotherOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdMotherOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdMotherOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdMotherOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdFtnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdFtnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdFtnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdFtnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdEdnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdEdnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdEdnOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdEdnOld'] = self::getInt4d($data, $pos); + $pos += 4; } if($version == self::VERSION_2002){ - $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfPgp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfPgp'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfuim'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfuim'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlfguidUim'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlfguidUim'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAtrdExtra'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAtrdExtra'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlrsid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlrsid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfcookie'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfcookie'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklFactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcFactoidData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbFactoidData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcDocUndo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbDocUndo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklFcc'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfbkmkBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfbkmkBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfbkfBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfbkfBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfbklBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfbklBPRepairs'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPmsNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPmsNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcODSO'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbODSO'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiOldXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiOldXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiNewXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiNewXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiMixedXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiMixedXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcffactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcffactoid'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcOldXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcOldXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcNewXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcNewXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcMixedXP'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcMixedXP'] = self::_GetInt4d($data, $length); - $length += 4; + $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfPgp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfPgp'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfuim'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfuim'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlfguidUim'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlfguidUim'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAtrdExtra'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAtrdExtra'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlrsid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlrsid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfcookie'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfcookie'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklFactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcFactoidData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbFactoidData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcDocUndo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbDocUndo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklFcc'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfbkmkBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfbkmkBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfbkfBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfbkfBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfbklBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfbklBPRepairs'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPmsNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPmsNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcODSO'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbODSO'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiOldXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiOldXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiNewXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiNewXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiMixedXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiMixedXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcffactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcffactoid'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcOldXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcOldXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcNewXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcNewXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcMixedXP'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcMixedXP'] = self::getInt4d($data, $pos); + $pos += 4; } if($version == self::VERSION_2003){ - $this->arrayFib['fcHplxsdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbHplxsdr'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklSdt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcCustomXForm'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbCustomXForm'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklProt'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbProtUser'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbProtUser'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiOldInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiOldInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfpmiNewInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfpmiNewInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcOld'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcOldInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcOldInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcNew'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcflvcNewInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcflvcNewInline'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAfdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAfdMother'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAfdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAfdFtn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPgdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPgdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcBkdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbBkdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAfdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAfdEdn'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcAfd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbAfd'] = self::_GetInt4d($data, $length); - $length += 4; + $this->arrayFib['fcHplxsdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbHplxsdr'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklSdt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcCustomXForm'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbCustomXForm'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklProt'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbProtUser'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbProtUser'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiOldInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiOldInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfpmiNewInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfpmiNewInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcOld'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcOldInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcOldInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcNew'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcflvcNewInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcflvcNewInline'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAfdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAfdMother'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAfdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAfdFtn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPgdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPgdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcBkdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbBkdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAfdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAfdEdn'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcAfd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbAfd'] = self::getInt4d($data, $pos); + $pos += 4; } if($version == self::VERSION_2007){ - $this->arrayFib['fcPlcfmthd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfmthd'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklMoveFrom'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklMoveTo'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused1'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused2'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused3'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused3'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcSttbfBkmkArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbSttbfBkmkArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBkfArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBkfArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcPlcfBklArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbPlcfBklArto'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcArtoData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbArtoData'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused4'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused4'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused5'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused5'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcUnused6'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbUnused6'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcOssTheme'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbOssTheme'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['fcColorSchemeMapping'] = self::_GetInt4d($data, $length); - $length += 4; - $this->arrayFib['lcbColorSchemeMapping'] = self::_GetInt4d($data, $length); - $length += 4; + $this->arrayFib['fcPlcfmthd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfmthd'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklMoveFrom'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklMoveTo'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused3'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused3'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcSttbfBkmkArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbSttbfBkmkArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBkfArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBkfArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcPlcfBklArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbPlcfBklArto'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcArtoData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbArtoData'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused4'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused4'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused5'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused5'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcUnused6'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbUnused6'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcOssTheme'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbOssTheme'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['fcColorSchemeMapping'] = self::getInt4d($data, $pos); + $pos += 4; + $this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos); + $pos += 4; } - return $length; + return $pos; } private function readFibContent() { - #$this->readRecordSTSH(); - $this->readRecordPlcfSed(); - } - private function readRecordSTSH() - { - print_r('============ readRecordSTSH'.PHP_EOL); - // Table Stream - // fcStshf (4 bytes): An unsigned integer that specifies an offset in the Table Stream. An STSH that specifies the style sheet for this document begins at this offset. - // lcbStshf (4 bytes): An unsigned integer that specifies the size, in bytes, of the STSH that begins at offset fcStshf in the Table Stream. This MUST be a nonzero value. - /*[fcStshf] => 0 - [lcbStshf] => 1060*/ - - $posMem = $this->arrayFib['fcStshf']; - - // RECORD "STSH" - - // lpstshi (variable): An LPStshi that specifies information about the stylesheet. - // - LPStshi - // - LPStshi : cbStshi - $cbStshi = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - print_r('$cbStshi :'.$cbStshi.PHP_EOL); + // Informations about Font + $this->readRecordSttbfFfn(); - // - LPStshi : stshi - // - LPStshi : stshi : stshif (18o) - // - LPStshi : stshi : stshif : cstd - $cstd = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : cbSTDBaseInFile - $cbSTDBaseInFile = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : fStdStylenamesWritten (1 bit) - // - LPStshi : stshi : stshif : fReserved (15 bits) - $fStdStylenamesWritten = self::_GetInt1d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : stiMaxWhenSaved - $stiMaxWhenSaved = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - print_r('$stiMaxWhenSaved :'.$stiMaxWhenSaved.PHP_EOL); - // - LPStshi : stshi : stshif : istdMaxFixedWhenSaved - $istdMaxFixedWhenSaved = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : nVerBuiltInNamesWhenSaved - $nVerBuiltInNamesWhenSaved = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : ftcAsci - $ftcAsci = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : ftcFE - $ftcFE = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : stshif : ftcOther - $ftcOther = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - - // - LPStshi : stshi : ftcBi (2o) - $ftcBi = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - // - LPStshi : stshi : StshiLsd - // - LPStshi : stshi : StshiLsd : cbLSD - $cbLSD = self::_GetInt2d($this->data1Table, $posMem); - $posMem += 2; - print_r('$cbLSD :'.$cbLSD.PHP_EOL); + // Informations about page + $this->readRecordPlcfSed(); + // reading paragraphs + //@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86 + $this->readRecordPlcfBtePapx(); - // - LPStshi : stshi : StshiLsd : mpstiilsd - // - LPStshi : stshi : StshiB + // reading character formattings + //@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94 + $this->readRecordPlcfBteChpx(); - // rglpstd (variable): An array of LPStd that specifies the style definitions. + $this->generatePhpWord(); } - private function readRecordPlcfSed(){ - // fcPlcfSed (4 bytes): An unsigned integer that specifies an offset in the Table Stream. A PlcfSed begins at this offset and specifies the locations of property lists for each section in the Main Document. If lcbPlcfSed is zero, fcPlcfSed is undefined and MUST be ignored. - // lcbPlcfSed (4 bytes): An unsigned integer that specifies the size, in bytes, of the PlcfSed that begins at offset fcPlcfSed in the Table Stream. - print_r('============ readRecordPlcfSed'.PHP_EOL); + /** + * Section and information about them + * @link : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx + */ + private function readRecordPlcfSed(){ $posMem = $this->arrayFib['fcPlcfSed']; // PlcfSed // PlcfSed : aCP $aCP = array(); - $aCP[0] = self::_GetInt4d($this->data1Table, $posMem); + $aCP[0] = self::getInt4d($this->data1Table, $posMem); $posMem += 4; - $aCP[1] = self::_GetInt4d($this->data1Table, $posMem); + $aCP[1] = self::getInt4d($this->data1Table, $posMem); $posMem += 4; - print_r('$aCP :'.PHP_EOL); - print_r($aCP); - // PlcfSed : aSed - $numSed = ($this->arrayFib['lcbPlcfSed'] - 4) / 12; + //@link : http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx + $numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12); $aSed = array(); - for($iInc = 1 ; $iInc < $numSed ; ++$iInc){ - // ignored + for($iInc = 0 ; $iInc < $numSed ; ++$iInc){ + // Sed : http://msdn.microsoft.com/en-us/library/dd950982%28v=office.12%29.aspx + // fn $posMem += 2; - // A signed integer value that specifies the position in the WordDocument Stream at which a Sepx structure is located. - $aSed[$iInc] = self::_GetInt4d($this->data1Table, $posMem); + // fnMpr + $aSed[$iInc] = self::getInt4d($this->data1Table, $posMem); $posMem += 4; - // ignored + // fnMpr $posMem += 2; - // ignored + // fcMpr $posMem += 4; } - // page 541 pour la lecture des informations sur la section - } + foreach($aSed as $keySed => $offsetSed){ + // Sepx : http://msdn.microsoft.com/en-us/library/dd921348%28v=office.12%29.aspx + $cb = self::getInt2d($this->dataWorkDocument, $offsetSed); + $offsetSed += 2; + + $oStylePrl = $this->readPrl($this->dataWorkDocument, $offsetSed, $cb); + $offsetSed += $oStylePrl->length; + $this->arraySections[] = $oStylePrl; + } + } - private function read1Table($data) + /** + * Specifies the fonts that are used in the document + * @link : http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx + */ + private function readRecordSttbfFfn() { - /* - offset[0] = offsetClx + 1; - int lcb = stream.getInteger(offset); - - int countPcd = (lcb - 4)/12; - int countCp = (lcb - countPcd*8)/4; - int offsetPlcpcd = offsetClx + 5; - - for(int i=0;i> 30; - start = (start << 2) >> 2; - - offset[0] = offsetPlcpcd + i*4; - int cpPre = stream.getInteger(offset); - int cpNext = stream.getInteger(offset); - int length = cpNext - cpPre -1; - if(fc == 0) - { - length *= 2; + $posMem = $this->arrayFib['fcSttbfFfn']; + + $cData = self::getInt2d($this->data1Table, $posMem); + $posMem += 2; + $cbExtra = self::getInt2d($this->data1Table, $posMem); + $posMem += 2; + + if ($cData < 0x7FF0 && $cbExtra == 0) { + for ($inc = 0; $inc < $cData; $inc++) { + // len + $posMem += 1; + // ffid + $posMem += 1; + // wWeight (400 : Normal - 700 bold) + $posMem += 2; + // chs + $posMem += 1; + // ixchSzAlt + $ixchSzAlt = self::getInt1d($this->data1Table, $posMem); + $posMem += 1; + // panose + $posMem += 10; + // fs + $posMem += 24; + // xszFfn + $xszFfn = ''; + do { + $char = self::getInt2d($this->data1Table, $posMem); + $posMem += 2; + if($char > 0) { + $xszFfn .= chr($char); + } + } while ($char != 0); + // xszAlt + $xszAlt = ''; + if($ixchSzAlt > 0) { + do { + $char = self::getInt2d($this->data1Table, $posMem); + $posMem += 2; + if($char == 0) { + break; + } + $xszAlt .= chr($char); + } while ($char != 0); + } + $this->arrayFonts[] = array( + 'main' => $xszFfn, + 'alt' => $xszAlt, + ); } - else - { - start = start/2; + } + } + + /** + * Paragraph and information about them + * @link http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx + */ + private function readRecordPlcfBtePapx(){ + $posMem = $this->arrayFib['fcPlcfBtePapx']; + $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBtePapx'], 4); + $posMem += 4 * ($num + 1); + $plcfBtePapx_aPnBtePapx = $this->getArrayCP($this->data1Table, $posMem, $num); + $posMem += 4 * $num; + + foreach($plcfBtePapx_aPnBtePapx as $aPnBtePapx){ + $offsetBase = $aPnBtePapx * 512; + $offset = $offsetBase; + + $string = ''; + + $numRun = self::getInt1d($this->dataWorkDocument, $offset + 511); + $arrayRGFC = array(); + for($inc = 0 ; $inc <= $numRun ; $inc++){ + $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset); + $offset += 4; + } + $arrayRGB = array(); + for($inc = 1 ; $inc <= $numRun ; $inc++){ + // @link http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx + $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset); + $offset += 1; + // reserved + $offset += 12; } - start += 512; - bytesToString(ogiBytes, content, start, length, fc); + foreach ($arrayRGFC as $key => $rgFc) { + if(!isset($arrayRGFC[$key + 1])){ + break; + } + $strLen = $arrayRGFC[$key + 1] - $arrayRGFC[$key] - 1; + for ($inc = 0; $inc < $strLen; $inc++) { + $byte = self::getInt1d($this->dataWorkDocument, $arrayRGFC[$key] + $inc); + if($byte > 0) { + $string .= chr($byte); + } + } + } + $this->arrayParagraphs[] = $string; + + //@todo readPrl for paragraphs + /*// use $this->readPrl() + foreach ($arrayRGB as $key => $rgb) { + $offset = $offsetBase + ($rgb * 2); + + $cb = self::getInt1d($this->dataWorkDocument, $offset); + $offset += 1; + print_r('$cb : '.$cb.PHP_EOL); + if($cb == 0){ + $cb = self::getInt1d($this->dataWorkDocument, $offset); + $cb = $cb * 2; + $offset += 1; + print_r('$cb0 : '.$cb.PHP_EOL); + } else { + $cb = $cb * 2 - 1; + print_r('$cbD : '.$cb.PHP_EOL); + } + $istd = self::getInt2d($this->dataWorkDocument, $offset); + $offset += 2; + $cb -= 2; + print_r('$istd : '.$istd.($istd == 0 ? ' (Normal)' : '').PHP_EOL); + if($cb > 0){ + do{ + $sprm = self::getInt2d($this->dataWorkDocument, $offset); + $offset += 2; + $cb -= 2; + $sprm_IsPmd = $sprm & 0x01FF; + $sprm_F = ($sprm/512) & 0x0001; + $sprm_Sgc = ($sprm/1024) & 0x0007; + $sprm_Spra = ($sprm/8192); + + print_r('$sprm : 0x'.dechex($sprm).PHP_EOL); + print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL); + print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL); + print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc)); + switch(dechex($sprm_Sgc)){ + case 0x01: + print_r(' (Paragraph property)'); + break; + case 0x02: + print_r(' (Character property)'); + break; + case 0x03: + print_r(' (Picture property)'); + break; + case 0x04: + print_r(' (Section property)'); + break; + case 0x05: + print_r(' (Table property)'); + break; + } + print_r(PHP_EOL); + print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL); + switch(dechex($sprm_Spra)){ + case 0x0: + $operand = self::getInt1d($this->dataWorkDocument, $offset); + $offset += 1; + $cb -= 1; + switch(dechex($operand)){ + case 0x00: + $operand = 'OFF'; + break; + case 0x01: + $operand = 'ON'; + break; + case 0x80: + $operand = 'CURRENT VALUE'; + print_r(''.PHP_EOL.PHP_EOL); + break; + case 0x81: + $operand = 'OPPOSITE OF THE CURRENT VALUE'; + break; + } + break; + case 0x1: + $operand = self::getInt1d($this->dataWorkDocument, $offset); + $offset += 1; + $cb -= 1; + print_r('$operand : 0x'.dechex($operand).PHP_EOL); + break; + case 0x2: + case 0x4: + case 0x5: + $operand = self::getInt2d($this->dataWorkDocument, $offset); + $offset += 2; + $cb -= 2; + print_r('$operand : 0x'.dechex($operand).PHP_EOL); + break; + case 0x3: + if($sprm_IsPmd != 0x70){ + $operand = self::getInt4d($this->dataWorkDocument, $offset); + $offset += 4; + $cb -= 4; + print_r('$operand : 0x'.dechex($operand).PHP_EOL); + } + break; + case 0x7: + $operand = self::_GetInt3d($this->dataWorkDocument, $offset); + $offset += 3; + $cb -= 3; + print_r('$operand : 0x'.dechex($operand).PHP_EOL); + break; + default: + print_r('YO YO YO : '.PHP_EOL); + } + + // + switch(dechex($sprm_Sgc)){ + case 0x01: // Sprm is modifying a paragraph property. + switch($sprm_IsPmd){ + case 0x0A: // sprmPIlvl + print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL); + break; + case 0x0B: // sprmPIlfo + print_r('sprmPIlfo : '.$operand.PHP_EOL.PHP_EOL); + break; + default: + print_r('$sprm_IsPmd(1) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); + break; + } + break; + case 0x02: // Sprm is modifying a character property. + switch($sprm_IsPmd){ + default: + print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); + break; + } + break; + case 0x03: // Sprm is modifying a picture property. + switch($sprm_IsPmd){ + default: + print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); + break; + } + break; + case 0x04: // Sprm is modifying a section property. + switch($sprm_IsPmd){ + default: + print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); + break; + } + break; + case 0x05: // Sprm is modifying a table property. + switch($sprm_IsPmd){ + default: + print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); + break; + } + break; + default: + print_r('$sprm_Sgc : '.dechex($sprm_Sgc).PHP_EOL.PHP_EOL); + break; + } + } while($cb > 0); + } else { + if($istd > 0){ + // @todo : Determining Properties of a Paragraph Style + # @link http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx + } + } + }*/ + } + } - System.out.println(start +", "+ length); - }*/ + /** + * Character formatting properties to text in a document + * @link http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx + */ + private function readRecordPlcfBteChpx(){ + $posMem = $this->arrayFib['fcPlcfBteChpx']; + $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBteChpx'], 4); + $PlcBteChpx_aPnBteChpx = array(); + for($inc = 0 ; $inc <= $num ; $inc++){ + $PlcBteChpx_aPnBteChpx[$inc] = self::getInt4d($this->data1Table, $posMem); + $posMem += 4; + } + $PnFkpChpx = self::getInt4d($this->data1Table, $posMem); + $posMem += 4; - print_r('============ read1Table'.PHP_EOL); - $clxPosition = $this->arrayFib['fcClx']; + $offsetBase = $PnFkpChpx * 512; + $offset = $offsetBase; - $text = self::_GetInt1d($data, $clxPosition); - print_r('$text : '.$text.PHP_EOL); - $lcb_piece_table = self::_GetInt4d($data, $clxPosition + 1); - $piece_table = $clxPosition + 5; - $piece_count = ($lcb_piece_table - 4) / 12; - print_r('$piece_count : '.$piece_count.PHP_EOL); + // ChpxFkp + // @link : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx + $numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511); + $arrayRGFC = array(); + for($inc = 0 ; $inc <= $numRGFC ; $inc++){ + $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset); + $offset += 4; + } + $arrayRGB = array(); + for($inc = 1 ; $inc <= $numRGFC ; $inc++){ + $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset); + $offset += 1; + } - $countCp = ($lcb_piece_table - $piece_count*8)/4; - print_r('$countCp : '.$countCp.PHP_EOL); - for($i=0 ; $i < $piece_count ; $i++) { + $start = 0; + foreach ($arrayRGB as $keyRGB => $rgb) { + $oStyle = new \stdClass(); + $oStyle->pos_start = $start; + $oStyle->pos_len = (int)ceil((($arrayRGFC[$keyRGB] -1) - $arrayRGFC[$keyRGB -1]) / 2); + $start += $oStyle->pos_len; - $piece_start = self::_GetInt4d($data, $piece_table + ($i * 4)); - $piece_end = self::_GetInt4d($data, $piece_table + (($i + 1) * 4)); - $piece_descriptor = $piece_table + (($piece_count + 1) * 4) + ($i * 8); - $fc = self::_GetInt4d ($data, $piece_descriptor + 2); - $is_ansi = ($fc & 0x40000000) == 0x40000000; - if (!$is_ansi) { - $fc = ($fc & 0xBFFFFFFF); - } else { - $fc = ($fc & 0xBFFFFFFF) >> 1; - } - $piece_size = $piece_end - $piece_start; - print_r('$piece_size : '.$piece_size.PHP_EOL); - if (!$is_ansi) { - $piece_size *= 2; - } - print_r('$piece_size : '.$piece_size.PHP_EOL); - if ($piece_size >= 1) { - $fc+=512; - print_r(chr(self::_GetInt2d($data, $fc + 2))); - print_r(chr(self::_GetInt2d($data, $fc + 4))); - print_r(chr(self::_GetInt2d($data, $fc + 6))); - print_r(chr(self::_GetInt2d($data, $fc + 8))); - print_r(chr(self::_GetInt2d($data, $fc + 10))); - print_r(chr(self::_GetInt2d($data, $fc + 12))); - print_r(chr(self::_GetInt2d($data, $fc + 14))); - print_r(chr(self::_GetInt2d($data, $fc + 16))); - print_r(chr(self::_GetInt2d($data, $fc + 18))); - print_r(chr(self::_GetInt2d($data, $fc + 20))); - print_r(chr(self::_GetInt2d($data, $fc + 22))); - print_r(chr(self::_GetInt2d($data, $fc + 24))); - print_r(chr(self::_GetInt2d($data, $fc + 26))); - print_r(chr(self::_GetInt2d($data, $fc + 28))); - print_r(chr(self::_GetInt2d($data, $fc + 30))); - print_r(chr(self::_GetInt2d($data, $fc + 32))); - print_r(chr(self::_GetInt2d($data, $fc + 34))); - print_r(chr(self::_GetInt2d($data, $fc + 36))); - print_r(chr(self::_GetInt2d($data, $fc + 38))); - print_r(PHP_EOL); + if($rgb > 0){ + // Chp Structure + // @link : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx + $posRGB = $offsetBase + $rgb * 2; + + $cb = self::getInt1d($this->dataWorkDocument, $posRGB); + $posRGB += 1; + + $oStyle->style = $this->readPrl($this->dataWorkDocument, $posRGB, $cb); + $posRGB += $oStyle->style->length; } + $this->arrayCharacters[] = $oStyle; + } + } + + /** + * @param $sprm + * @return \stdClass + */ + private function readSprm($sprm) + { + $oSprm = new \stdClass(); + $oSprm->isPmd = $sprm & 0x01FF; + $oSprm->f = ($sprm / 512) & 0x0001; + $oSprm->sgc = ($sprm / 1024) & 0x0007; + $oSprm->spra = ($sprm / 8192); + return $oSprm; + } + + /** + * @param string $data + * @param integer $pos + * @param \stdClass $oSprm + * @return array + */ + private function readSprmSpra($data, $pos, $oSprm) + { + $length = 0; + $operand = null; + + switch(dechex($oSprm->spra)){ + case 0x0: + $operand = self::getInt1d($data, $pos); + $length = 1; + switch(dechex($operand)){ + case 0x00: + $operand = false; + break; + case 0x01: + $operand = true; + break; + case 0x80: + $operand = self::SPRA_VALUE; + break; + case 0x81: + $operand = self::SPRA_VALUE_OPPOSITE; + break; + } + break; + case 0x1: + $operand = self::getInt1d($data, $pos); + $length = 1; + break; + case 0x2: + case 0x4: + case 0x5: + $operand = self::getInt2d($data, $pos); + $length = 2; + break; + case 0x3: + if($oSprm->isPmd != 0x70){ + $operand = self::getInt4d($data, $pos); + $length = 4; + } + break; + case 0x7: + $operand = self::_GetInt3d($data, $pos); + $length = 3; + break; + default: + // print_r('YO YO YO : '.PHP_EOL); + } + + return array( + 'length' => $length, + 'operand' => $operand, + ); + } - $offsetPcd = $piece_table + $countCp*4 + $i*8; - - $start = self::_GetInt4d($data, $offsetPcd+2); - print_r('$start : '.$start.PHP_EOL); - $fc = $start >> 30; - $start = ($start << 2) >> 2; - print_r('$fc : '.$fc.PHP_EOL); - print_r('$start : '.$start.PHP_EOL); - - $offset = $piece_table + $i*4; - print_r('$offset : '.$offset.PHP_EOL); - $cpPre = self::_GetInt4d($data, $offset); - print_r('$cpPre : '.$cpPre.PHP_EOL); - $cpNext = self::_GetInt4d($data, $offset + 4); - print_r('$cpNext : '.$cpNext.PHP_EOL); - $length = $cpNext - $cpPre -1; - if($fc == 0) { - $length *= 2; + /** + * @param $data integer + * @param $pos integer + * @return \stdClass + * @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx + */ + private function readPrl($data, $pos, $cb) + { + $posStart = $pos; + $oStylePrl = new \stdClass(); + + // Variables + $sprmCPicLocation = null; + $sprmCFData = null; + $sprmCFSpec = null; + + do { + // Variables + $operand = null; + + $sprm = self::getInt2d($data, $pos); + $oSprm = $this->readSprm($sprm); + $pos += 2; + $cb -= 2; + + $arrayReturn = $this->readSprmSpra($data, $pos, $oSprm); + $pos += $arrayReturn['length']; + $cb -= $arrayReturn['length']; + $operand = $arrayReturn['operand']; + + switch(dechex($oSprm->sgc)){ + // Paragraph property + case 0x01: + break; + // Character property + case 0x02: + if(!isset($oStylePrl->styleFont)) { + $oStylePrl->styleFont = array(); + } + switch($oSprm->isPmd){ + // sprmCFRMarkIns + case 0x01: + break; + // sprmCFFldVanish + case 0x02: + break; + // sprmCPicLocation + case 0x03: + $sprmCPicLocation = $operand; + break; + // sprmCFData + case 0x06: + $sprmCFData = dechex($operand) == 0x00 ? false : true; + break; + // sprmCFItalic + case 0x36: + // By default, text is not italicized. + switch($operand) { + case false: + case true: + $oStylePrl->styleFont['italic'] = $operand; + break; + case self::SPRA_VALUE: + $oStylePrl->styleFont['italic'] = false; + break; + case self::SPRA_VALUE_OPPOSITE: + $oStylePrl->styleFont['italic'] = true; + break; + } + break; + // sprmCIstd + case 0x30: + //print_r('sprmCIstd : '.dechex($operand).PHP_EOL.PHP_EOL); + break; + // sprmCFBold + case 0x35: + // By default, text is not bold. + switch($operand) { + case false: + case true: + $oStylePrl->styleFont['bold'] = $operand; + break; + case self::SPRA_VALUE: + $oStylePrl->styleFont['bold'] = false; + break; + case self::SPRA_VALUE_OPPOSITE: + $oStylePrl->styleFont['bold'] = true; + break; + } + break; + // sprmCFStrike + case 0x37: + // By default, text is not struck through. + switch($operand) { + case false: + case true: + $oStylePrl->styleFont['strikethrough'] = $operand; + break; + case self::SPRA_VALUE: + $oStylePrl->styleFont['strikethrough'] = false; + break; + case self::SPRA_VALUE_OPPOSITE: + $oStylePrl->styleFont['strikethrough'] = true; + break; + } + break; + // sprmCKul + case 0x3E: + switch(dechex($operand)){ + case 0x00: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE; + break; + case 0x01: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_SINGLE; + break; + case 0x02: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WORDS; + break; + case 0x03: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOUBLE; + break; + case 0x04: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTTED; + break; + case 0x06: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_HEAVY; + break; + case 0x07: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASH; + break; + case 0x09: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASH; + break; + case 0x0A: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASH; + break; + case 0x0B: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVY; + break; + case 0x14: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTTEDHEAVY; + break; + case 0x17: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHHEAVY; + break; + case 0x19: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTHASHHEAVY; + break; + case 0x1A: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASHHEAVY; + break; + case 0x1B: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVYHEAVY; + break; + case 0x27: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHLONG; + break; + case 0x2B: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVYDOUBLE; + break; + case 0x37: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHLONGHEAVY; + break; + default: + $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE; + break; + } + break; + // sprmCIco + //@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx + case 0x42: + switch(dechex($operand)){ + case 0x00: + case 0x01: + $oStylePrl->styleFont['color'] = '000000'; + break; + case 0x02: + $oStylePrl->styleFont['color'] = '0000FF'; + break; + case 0x03: + $oStylePrl->styleFont['color'] = '00FFFF'; + break; + case 0x04: + $oStylePrl->styleFont['color'] = '00FF00'; + break; + case 0x05: + $oStylePrl->styleFont['color'] = 'FF00FF'; + break; + case 0x06: + $oStylePrl->styleFont['color'] = 'FF0000'; + break; + case 0x07: + $oStylePrl->styleFont['color'] = 'FFFF00'; + break; + case 0x08: + $oStylePrl->styleFont['color'] = 'FFFFFF'; + break; + case 0x09: + $oStylePrl->styleFont['color'] = '000080'; + break; + case 0x0A: + $oStylePrl->styleFont['color'] = '008080'; + break; + case 0x0B: + $oStylePrl->styleFont['color'] = '008000'; + break; + case 0x0C: + $oStylePrl->styleFont['color'] = '800080'; + break; + case 0x0D: + $oStylePrl->styleFont['color'] = '800080'; + break; + case 0x0E: + $oStylePrl->styleFont['color'] = '808000'; + break; + case 0x0F: + $oStylePrl->styleFont['color'] = '808080'; + break; + case 0x10: + $oStylePrl->styleFont['color'] = 'C0C0C0'; + } + break; + // sprmCHps + case 0x43: + $oStylePrl->styleFont['size'] = dechex($operand/2); + break; + // sprmCIss + case 0x48: + if (!isset($oStylePrl->styleFont['superScript'])) { + $oStylePrl->styleFont['superScript'] = false; + } + if (!isset($oStylePrl->styleFont['subScript'])) { + $oStylePrl->styleFont['subScript'] = false; + } + switch (dechex($operand)) { + case 0x00: + // Normal text + break; + case 0x01: + $oStylePrl->styleFont['superScript'] = true; + break; + case 0x02: + $oStylePrl->styleFont['subScript'] = true; + break; + } + break; + // sprmCRgFtc0 + case 0x4F: + $oStylePrl->styleFont['name'] = ''; + if(isset($this->arrayFonts[$operand])) { + $oStylePrl->styleFont['name'] = $this->arrayFonts[$operand]['main']; + } + break; + // sprmCRgFtc1 + case 0x50: + // if the language for the text is an East Asian language + break; + // sprmCRgFtc2 + case 0x51: + // if the character falls outside the Unicode character range + break; + // sprmCFSpec + case 0x55: + $sprmCFSpec = $operand; + break; + // sprmCFtcBi + case 0x5E: + break; + // sprmCFItalicBi + case 0x5D: + break; + // sprmCHpsBi + case 0x61: + break; + // sprmCShd80 + //@link http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx + case 0x66: + // $operand = self::getInt2d($data, $pos); + $pos += 2; + $cb -= 2; + // $ipat = ($operand >> 0) && bindec('111111'); + // $icoBack = ($operand >> 6) && bindec('11111'); + // $icoFore = ($operand >> 11) && bindec('11111'); + break; + // sprmCCv + //@link : http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx + case 0x70: + $red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT); + $pos += 1; + $green = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT); + $pos += 1; + $blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT); + $pos += 1; + $pos += 1; + $oStylePrl->styleFont['color'] = $red.$green.$blue; + $cb -= 4; + break; + default: + // print_r('@todo Character : 0x'.dechex($oSprm->isPmd)); + // print_r(PHP_EOL); + } + break; + // Picture property + case 0x03: + break; + // Section property + case 0x04: + if(!isset($oStylePrl->styleSection)) { + $oStylePrl->styleSection = array(); + } + switch($oSprm->isPmd){ + // sprmSNfcPgn + case 0x0E: + // numbering format used for page numbers + break; + // sprmSXaPage + case 0x1F: + $oStylePrl->styleSection['pageSizeW'] = $operand; + break; + // sprmSYaPage + case 0x20: + $oStylePrl->styleSection['pageSizeH'] = $operand; + break; + // sprmSDxaLeft + case 0x21: + $oStylePrl->styleSection['marginLeft'] = $operand; + break; + // sprmSDxaRight + case 0x22: + $oStylePrl->styleSection['marginRight'] = $operand; + break; + // sprmSDyaTop + case 0x23: + $oStylePrl->styleSection['marginTop'] = $operand; + break; + // sprmSDyaBottom + case 0x24: + $oStylePrl->styleSection['marginBottom'] = $operand; + break; + // sprmSFBiDi + case 0x28: + // RTL layout + break; + // sprmSDxtCharSpace + case 0x30: + // characpter pitch + break; + // sprmSDyaLinePitch + case 0x31: + // line height + break; + // sprmSClm + case 0x32: + // document grid mode + break; + // sprmSTextFlow + case 0x33: + // text flow + break; + default: + // print_r('@todo Section : 0x'.dechex($oSprm->isPmd)); + // print_r(PHP_EOL); + + } + break; + // Table property + case 0x05: + break; + } + } while($cb > 0); + + if (!is_null($sprmCPicLocation)) { + if (!is_null($sprmCFData) && $sprmCFData == 0x01) { + // NilPICFAndBinData + //@todo Read Hyperlink structure + /*$lcb = self::getInt4d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 4; + $cbHeader = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // ignored + $sprmCPicLocation += 62; + // depending of the element + // Hyperlink => HFD + // HFD > bits + $sprmCPicLocation += 1; + // HFD > clsid + $sprmCPicLocation += 16; + // HFD > hyperlink + //@link : http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx + $streamVersion = self::getInt4d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 4; + $data = self::getInt4d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 4; + $hlstmfAbsFromGetdataRel = ($data >> 9) & bindec('1'); + $hlstmfMonikerSavedAsStr = ($data >> 8) & bindec('1'); + $hlstmfHasFrameName = ($data >> 7) & bindec('1'); + $hlstmfHasCreationTime = ($data >> 6) & bindec('1'); + $hlstmfHasGUID = ($data >> 5) & bindec('1'); + $hlstmfHasDisplayName = ($data >> 4) & bindec('1'); + $hlstmfHasLocationStr = ($data >> 3) & bindec('1'); + $hlstmfSiteGaveDisplayName = ($data >> 2) & bindec('1'); + $hlstmfIsAbsolute = ($data >> 1) & bindec('1'); + $hlstmfHasMoniker = ($data >> 0) & bindec('1'); + for($inc = 0 ; $inc <= 32 ; $inc++){ + echo ($data >> $inc) & bindec('1'); + } + + print_r('$hlstmfHasMoniker > '.$hlstmfHasMoniker.PHP_EOL); + print_r('$hlstmfIsAbsolute > '.$hlstmfIsAbsolute.PHP_EOL); + print_r('$hlstmfSiteGaveDisplayName > '.$hlstmfSiteGaveDisplayName.PHP_EOL); + print_r('$hlstmfHasLocationStr > '.$hlstmfHasLocationStr.PHP_EOL); + print_r('$hlstmfHasDisplayName > '.$hlstmfHasDisplayName.PHP_EOL); + print_r('$hlstmfHasGUID > '.$hlstmfHasGUID.PHP_EOL); + print_r('$hlstmfHasCreationTime > '.$hlstmfHasCreationTime.PHP_EOL); + print_r('$hlstmfHasFrameName > '.$hlstmfHasFrameName.PHP_EOL); + print_r('$hlstmfMonikerSavedAsStr > '.$hlstmfMonikerSavedAsStr.PHP_EOL); + print_r('$hlstmfAbsFromGetdataRel > '.$hlstmfAbsFromGetdataRel.PHP_EOL); + if($streamVersion == 2){ + $AAA = self::getInt4d($this->dataData, $sprmCPicLocation); + echo 'AAAA : '.$AAA.PHP_EOL; + if($hlstmfHasDisplayName == 1){ + echo 'displayName'.PHP_EOL; + } + if($hlstmfHasFrameName == 1){ + echo 'targetFrameName'.PHP_EOL; + } + if($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1){ + $sprmCPicLocation += 16; + $length = self::getInt4d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 4; + for($inc = 0 ; $inc < ($length / 2) ; $inc++) { + $chr = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + print_r(chr($chr)); + } + echo PHP_EOL; + echo 'moniker : '.$length.PHP_EOL; + } + if($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1){ + echo 'oleMoniker'.PHP_EOL; + } + if($hlstmfHasLocationStr == 1){ + echo 'location'.PHP_EOL; + } + if($hlstmfHasGUID == 1) { + echo 'guid'.PHP_EOL; + $sprmCPicLocation += 16; + } + if($hlstmfHasCreationTime == 1) { + echo 'fileTime'.PHP_EOL; + $sprmCPicLocation += 4; + } + echo 'HYPERLINK'.PHP_EOL; + }*/ } else { - $start = $start/2; + // Pictures + //@link : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx + //@link : http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx + // PICF : lcb + $sprmCPicLocation += 4; + // PICF : cbHeader + $sprmCPicLocation += 2; + // PICF : mfpf : mm + $mfpf_mm = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : mfpf : xExt + $sprmCPicLocation += 2; + // PICF : mfpf : yExt + $sprmCPicLocation += 2; + // PICF : mfpf : swHMF + $sprmCPicLocation += 2; + // PICF : innerHeader : grf + $sprmCPicLocation += 4; + // PICF : innerHeader : padding1 + $sprmCPicLocation += 4; + // PICF : innerHeader : mmPM + $sprmCPicLocation += 2; + // PICF : innerHeader : padding2 + $sprmCPicLocation += 4; + // PICF : picmid : dxaGoal + $picmid_dxaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : dyaGoal + $picmid_dyaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : mx + $picmid_mx = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : my + $picmid_my = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : dxaReserved1 + $picmid_dxaCropLeft = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : dyaReserved1 + $picmid_dxaCropTop = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : dxaReserved2 + $picmid_dxaCropRight = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : dyaReserved2 + $picmid_dxaCropBottom = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + // PICF : picmid : fReserved + $sprmCPicLocation += 1; + // PICF : picmid : bpp + $sprmCPicLocation += 1; + // PICF : picmid : brcTop80 + $sprmCPicLocation += 4; + // PICF : picmid : brcLeft80 + $sprmCPicLocation += 4; + // PICF : picmid : brcBottom80 + $sprmCPicLocation += 4; + // PICF : picmid : brcRight80 + $sprmCPicLocation += 4; + // PICF : picmid : dxaReserved3 + $sprmCPicLocation += 2; + // PICF : picmid : dyaReserved3 + $sprmCPicLocation += 2; + // PICF : cProps + $sprmCPicLocation += 2; + + if ($mfpf_mm == 0x0066) { + // cchPicName + $cchPicName = self::getInt1d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 1; + + // stPicName + $stPicName = ''; + for($inc = 0; $inc <= $cchPicName; $inc++){ + $chr = self::getInt1d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 1; + $stPicName .= chr($chr); + } + } + + // picture (OfficeArtInlineSpContainer) + // picture : shape + $shapeRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 8; + if($shapeRH['recVer'] == 0xF && $shapeRH['recInstance'] == 0x000 && $shapeRH['recType'] == 0xF004){ + $sprmCPicLocation += $shapeRH['recLen']; + } + // picture : rgfb + //@link : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx + $fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); + while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)){ + $sprmCPicLocation += 8; + switch ($fileBlockRH['recType']) { + // OfficeArtFBSE + //@link : http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx + case 0xF007: + // btWin32 + $sprmCPicLocation += 1; + // btMacOS + $sprmCPicLocation += 1; + // rgbUid + $sprmCPicLocation += 16; + // tag + $sprmCPicLocation += 2; + // size + $sprmCPicLocation += 4; + // cRef + $sprmCPicLocation += 4; + // foDelay + $sprmCPicLocation += 4; + // unused1 + $sprmCPicLocation += 1; + // cbName + $cbName = self::getInt1d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 1; + // unused2 + $sprmCPicLocation += 1; + // unused3 + $sprmCPicLocation += 1; + // nameData + if ($cbName > 0) { + $nameData = ''; + for($inc = 0; $inc <= ($cbName / 2); $inc++){ + $chr = self::getInt2d($this->dataData, $sprmCPicLocation); + $sprmCPicLocation += 2; + $nameData .= chr($chr); + } + } + // embeddedBlip + //@link : http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx + $embeddedBlipRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); + switch ($embeddedBlipRH['recType']) { + case self::OFFICEARTBLIPJPG: + case self::OFFICEARTBLIPJPEG: + if(!isset($oStylePrl->image)){ + $oStylePrl->image = array(); + } + $sprmCPicLocation += 8; + // embeddedBlip : rgbUid1 + $sprmCPicLocation += 16; + if ($embeddedBlipRH['recInstance'] == 0x6E1) { + // rgbUid2 + $sprmCPicLocation += 16; + } + // embeddedBlip : tag + $sprmCPicLocation += 1; + // embeddedBlip : BLIPFileData + $oStylePrl->image['data'] = substr($this->dataData, $sprmCPicLocation, $embeddedBlipRH['recLen']); + $oStylePrl->image['format'] = 'jpg'; + // Image Size + $iCropWidth = $picmid_dxaGoal - ($picmid_dxaCropLeft + $picmid_dxaCropRight); + $iCropHeight = $picmid_dyaGoal - ($picmid_dxaCropTop + $picmid_dxaCropBottom); + if (!$iCropWidth){ + $iCropWidth = 1; + } + if (!$iCropHeight){ + $iCropHeight = 1; + } + $oStylePrl->image['width'] = Drawing::twipsToPixels($iCropWidth * $picmid_mx / 1000); + $oStylePrl->image['height'] = Drawing::twipsToPixels($iCropHeight * $picmid_my / 1000); + + $sprmCPicLocation += $embeddedBlipRH['recLen']; + break; + default: + // print_r(dechex($embeddedBlipRH['recType'])); + } + break; + } + $fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); + } } - - $start += 512; - print_r($start); - print_r(PHP_EOL); - print_r($length); - print_r(PHP_EOL); - print_r(self::_GetInt2d($data, $start + 2)); - print_r(PHP_EOL); - print_r(chr(self::_GetInt2d($data, $start + 2))); - print_r(PHP_EOL); - print_r(chr(self::_GetInt2d($data, $start + 4))); - print_r(chr(self::_GetInt2d($data, $start + 6))); - print_r(chr(self::_GetInt2d($data, $start + 8))); - print_r(chr(self::_GetInt2d($data, $start + 10))); - print_r(chr(self::_GetInt2d($data, $start + 12))); - print_r(chr(self::_GetInt2d($data, $start + 14))); - print_r(chr(self::_GetInt2d($data, $start + 16))); - print_r(chr(self::_GetInt2d($data, $start + 18))); - print_r(chr(self::_GetInt2d($data, $start + 20))); - print_r(chr(self::_GetInt2d($data, $start + 22))); - print_r(chr(self::_GetInt2d($data, $start + 24))); - print_r(chr(self::_GetInt2d($data, $start + 26))); - print_r(chr(self::_GetInt2d($data, $start + 28))); - print_r(chr(self::_GetInt2d($data, $start + 30))); - print_r(chr(self::_GetInt2d($data, $start + 32))); - print_r(chr(self::_GetInt2d($data, $start + 34))); - print_r(chr(self::_GetInt2d($data, $start + 36))); - print_r(chr(self::_GetInt2d($data, $start + 38))); } -/* - - $start = self::_GetInt4d($data, 1850); - print_r('$start : '.$start.PHP_EOL); - $end = self::_GetInt4d($data, 1854); - print_r('$end : '.$end.PHP_EOL);*/ - - print_r(PHP_EOL); - print_r(PHP_EOL); - print_r(PHP_EOL); - //print_r($data); - print_r(PHP_EOL); - //print_r(dechex($data)); - print_r(PHP_EOL); + + $oStylePrl->length = $pos - $posStart; + return $oStylePrl; } - private function readData($data) + /** + * Read a record header + * @param string $stream + * @param integer $pos + * @return array + */ + private function loadRecordHeader($stream, $pos) { - print_r('============ readData'.PHP_EOL); - $text = self::_GetInt1d($data, 0); - print_r(dechex($text)); - - print_r(PHP_EOL); - print_r(PHP_EOL); - print_r(PHP_EOL); - //print_r($data); - print_r(PHP_EOL); - //print_r(dechex($data)); - print_r(PHP_EOL); + $rec = self::getInt2d($stream, $pos); + $recType = self::getInt2d($stream, $pos + 2); + $recLen = self::getInt4d($stream, $pos + 4); + return array( + 'recVer' => ($rec >> 0) & bindec('1111'), + 'recInstance' => ($rec >> 4) & bindec('111111111111'), + 'recType' => $recType, + 'recLen' => $recLen, + ); } - private function readObjectPool($data) + private function generatePhpWord() { - print_r('============ readObjectPool'.PHP_EOL); - - print_r(PHP_EOL); - print_r(PHP_EOL); - print_r(PHP_EOL); - //print_r($data); - print_r(PHP_EOL); - //print_r(dechex($data)); - print_r(PHP_EOL); + foreach ($this->arraySections as $itmSection) { + $oSection = $this->phpWord->addSection(); + $oSection->setSettings($itmSection->styleSection); + + $sHYPERLINK = ''; + foreach ($this->arrayParagraphs as $itmParagraph) { + $textPara = $itmParagraph; + foreach ($this->arrayCharacters as $keyCharacters => $oCharacters) { + $subText = substr($textPara, $oCharacters->pos_start, $oCharacters->pos_len); + $subText = str_replace(chr(13), PHP_EOL, $subText); + $arrayText = explode(PHP_EOL, $subText); + if (end($arrayText) == '') { + array_pop($arrayText); + } + if (reset($arrayText) == '') { + array_shift($arrayText); + } + + // Style Character + $styleFont = array(); + if(isset($oCharacters->style)){ + if(isset($oCharacters->style->styleFont)){ + $styleFont = $oCharacters->style->styleFont; + } + } + + foreach ($arrayText as $sText) { + // HyperLink + if(empty($sText) && !empty($sHYPERLINK)) { + $arrHYPERLINK = explode('"', $sHYPERLINK); + $oSection->addLink($arrHYPERLINK[1], null); + // print_r('>addHyperLink<'.$sHYPERLINK.'>'.ord($sHYPERLINK[0]).EOL); + $sHYPERLINK = ''; + } + + // TextBreak + if(empty($sText)) { + $oSection->addTextBreak(); + $sHYPERLINK = ''; + // print_r('>addTextBreak<' . EOL); + } + + if(!empty($sText)){ + if(!empty($sHYPERLINK) && ord($sText[0]) > 20){ + $sHYPERLINK .= $sText; + } + if(empty($sHYPERLINK)) { + if(ord($sText[0]) > 20){ + if(strpos(trim($sText), 'HYPERLINK "') === 0){ + $sHYPERLINK = $sText; + } else { + $oSection->addText($sText, $styleFont); + // print_r('>addText<'.$sText.'>'.ord($sText[0]).EOL); + } + } + if(ord($sText[0]) == 1) { + if(isset($oCharacters->style->image)){ + $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc').'.'.$oCharacters->style->image['format']; + file_put_contents($fileImage, $oCharacters->style->image['data']); + $oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height'])); + // print_r('>addImage<'.$fileImage.'>'.EOL); + } + } + } + } + } + } + } + + } } /** @@ -1378,7 +2283,7 @@ private function readObjectPool($data) * @param int $pos * @return int */ - public static function _GetInt1d($data, $pos) + public static function getInt1d($data, $pos) { return ord($data[$pos]); } @@ -1390,11 +2295,23 @@ public static function _GetInt1d($data, $pos) * @param int $pos * @return int */ - public static function _GetInt2d($data, $pos) + public static function getInt2d($data, $pos) { return ord($data[$pos]) | (ord($data[$pos+1]) << 8); } + /** + * Read 24-bit signed integer + * + * @param string $data + * @param int $pos + * @return int + */ + public static function _GetInt3d($data, $pos) + { + return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16); + } + /** * Read 32-bit signed integer * @@ -1402,7 +2319,7 @@ public static function _GetInt2d($data, $pos) * @param int $pos * @return int */ - public static function _GetInt4d($data, $pos) + public static function getInt4d($data, $pos) { // FIX: represent numbers correctly on 64-bit system // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 58a6ee1a9c..85ce595f37 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -118,6 +118,76 @@ public static function centimetersToPixels($pValue = 0) } } + /** + * Convert centimeters width to twips + * + * @param integer $pValue + */ + public static function centimetersToTwips($pValue = 0) + { + if ($pValue != 0) { + return $pValue * 566.928; + } else { + return 0; + } + } + + /** + * Convert twips width to centimeters + * + * @param integer $pValue + */ + public static function twipsToCentimeters($pValue = 0) + { + if ($pValue != 0) { + return $pValue / 566.928; + } else { + return 0; + } + } + + /** + * Convert inches width to twips + * + * @param integer $pValue + */ + public static function inchesToTwips($pValue = 0) + { + if ($pValue != 0) { + return $pValue * 1440; + } else { + return 0; + } + } + + /** + * Convert twips width to inches + * + * @param integer $pValue + */ + public static function twipsToInches($pValue = 0) + { + if ($pValue != 0) { + return $pValue / 1440; + } else { + return 0; + } + } + + /** + * Convert twips width to pixels + * + * @param integer $pValue + */ + public static function twipsToPixels($pValue = 0) + { + if ($pValue != 0) { + return round($pValue / 15.873984); + } else { + return 0; + } + } + /** * Convert HTML hexadecimal to RGB * diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index dd8ff02a02..149f7c5430 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -225,7 +225,6 @@ public function setName($pValue = PhpWord::DEFAULT_FONT_NAME) return $this; } - /** * Get font size * From 4ade9c3c6e56bef45addd73d741a1125fe66ce3e Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 16 Aug 2014 12:33:37 +0200 Subject: [PATCH 099/174] #23 : Implement Word97 aka MsDoc Reader (PHPCS-PHPMD Fixes) --- samples/Sample_Footer.php | 3 + src/PhpWord/IOFactory.php | 34 ++++- src/PhpWord/Reader/MsDoc.php | 229 +++++++++++++++++---------------- src/PhpWord/Shared/Drawing.php | 14 +- src/PhpWord/Shared/OLERead.php | 129 ++++++++++--------- 5 files changed, 223 insertions(+), 186 deletions(-) diff --git a/samples/Sample_Footer.php b/samples/Sample_Footer.php index f7e2305f14..95ac693fc3 100644 --- a/samples/Sample_Footer.php +++ b/samples/Sample_Footer.php @@ -2,6 +2,9 @@ /** * Footer file */ +if (CLI) { + return; +} ?> diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 599153c2c1..f3808f72c3 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -48,20 +48,46 @@ public static function createReader($name = 'Word2007') return self::createObject('Reader', $name); } - $fqName = "PhpOffice\\PhpWord\\Reader\\{$name}"; - return new $fqName(); + /** + * Create new object + * + * @param string $type + * @param string $name + * @param \PhpOffice\PhpWord\PhpWord $phpWord + * @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + private static function createObject($type, $name, $phpWord = null) + { + $class = "PhpOffice\\PhpWord\\{$type}\\{$name}"; + if (class_exists($class) && self::isConcreteClass($class)) { + return new $class($phpWord); + } else { + throw new Exception("\"{$name}\" is not a valid {$type}."); + } } - /** * Loads PhpWord from file * * @param string $filename The name of the file * @param string $readerName - * @return PhpWord + * @return \PhpOffice\PhpWord\PhpWord $phpWord */ public static function load($filename, $readerName = 'Word2007') { + /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ $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/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php index 5c36262166..d3f5a44b55 100644 --- a/src/PhpWord/Reader/MsDoc.php +++ b/src/PhpWord/Reader/MsDoc.php @@ -144,13 +144,15 @@ private function loadOLE($filename) $this->_DocumentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); } - private function getNumInLcb($lcb, $iSize){ + private function getNumInLcb($lcb, $iSize) + { return ($lcb - 4) / (4 + $iSize); } - private function getArrayCP($data, $posMem, $iNum){ + private function getArrayCP($data, $posMem, $iNum) + { $arrayCP = array(); - for($inc = 0 ; $inc < $iNum ; $inc++){ + for ($inc = 0; $inc < $iNum; $inc++) { $arrayCP[$inc] = self::getInt4d($data, $posMem); $posMem += 4; } @@ -334,7 +336,7 @@ private function readFib($data) $this->arrayFib['cswNew'] = self::getInt2d($data, $pos); $pos += 2; - if($this->arrayFib['cswNew'] != 0){ + if ($this->arrayFib['cswNew'] != 0) { //@todo : fibRgCswNew } @@ -343,7 +345,7 @@ private function readFib($data) private function readBlockFibRgFcLcb($data, $pos, $version) { - if($version == self::VERSION_97){ + if ($version == self::VERSION_97) { $this->arrayFib['fcStshfOrig'] = self::getInt4d($data, $pos); $pos += 4; $this->arrayFib['lcbStshfOrig'] = self::getInt4d($data, $pos); @@ -717,7 +719,7 @@ private function readBlockFibRgFcLcb($data, $pos, $version) $this->arrayFib['lcbSttbfUssr'] = self::getInt4d($data, $pos); $pos += 4; } - if($version == self::VERSION_2000){ + if ($version == self::VERSION_2000) { $this->arrayFib['fcPlcfTch'] = self::getInt4d($data, $pos); $pos += 4; $this->arrayFib['lcbPlcfTch'] = self::getInt4d($data, $pos); @@ -779,7 +781,7 @@ private function readBlockFibRgFcLcb($data, $pos, $version) $this->arrayFib['lcbBkdEdnOld'] = self::getInt4d($data, $pos); $pos += 4; } - if($version == self::VERSION_2002){ + if ($version == self::VERSION_2002) { $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos); $pos += 4; $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos); @@ -893,7 +895,7 @@ private function readBlockFibRgFcLcb($data, $pos, $version) $this->arrayFib['lcbPlcflvcMixedXP'] = self::getInt4d($data, $pos); $pos += 4; } - if($version == self::VERSION_2003){ + if ($version == self::VERSION_2003) { $this->arrayFib['fcHplxsdr'] = self::getInt4d($data, $pos); $pos += 4; $this->arrayFib['lcbHplxsdr'] = self::getInt4d($data, $pos); @@ -1007,7 +1009,7 @@ private function readBlockFibRgFcLcb($data, $pos, $version) $this->arrayFib['lcbAfd'] = self::getInt4d($data, $pos); $pos += 4; } - if($version == self::VERSION_2007){ + if ($version == self::VERSION_2007) { $this->arrayFib['fcPlcfmthd'] = self::getInt4d($data, $pos); $pos += 4; $this->arrayFib['lcbPlcfmthd'] = self::getInt4d($data, $pos); @@ -1111,7 +1113,8 @@ private function readFibContent() * Section and information about them * @link : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx */ - private function readRecordPlcfSed(){ + private function readRecordPlcfSed() + { $posMem = $this->arrayFib['fcPlcfSed']; // PlcfSed // PlcfSed : aCP @@ -1126,7 +1129,7 @@ private function readRecordPlcfSed(){ $numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12); $aSed = array(); - for($iInc = 0 ; $iInc < $numSed ; ++$iInc){ + for ($iInc = 0; $iInc < $numSed; ++$iInc) { // Sed : http://msdn.microsoft.com/en-us/library/dd950982%28v=office.12%29.aspx // fn $posMem += 2; @@ -1139,7 +1142,7 @@ private function readRecordPlcfSed(){ $posMem += 4; } - foreach($aSed as $keySed => $offsetSed){ + foreach ($aSed as $offsetSed) { // Sepx : http://msdn.microsoft.com/en-us/library/dd921348%28v=office.12%29.aspx $cb = self::getInt2d($this->dataWorkDocument, $offsetSed); $offsetSed += 2; @@ -1186,17 +1189,17 @@ private function readRecordSttbfFfn() do { $char = self::getInt2d($this->data1Table, $posMem); $posMem += 2; - if($char > 0) { + if ($char > 0) { $xszFfn .= chr($char); } } while ($char != 0); // xszAlt $xszAlt = ''; - if($ixchSzAlt > 0) { + if ($ixchSzAlt > 0) { do { $char = self::getInt2d($this->data1Table, $posMem); $posMem += 2; - if($char == 0) { + if ($char == 0) { break; } $xszAlt .= chr($char); @@ -1214,14 +1217,15 @@ private function readRecordSttbfFfn() * Paragraph and information about them * @link http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx */ - private function readRecordPlcfBtePapx(){ + private function readRecordPlcfBtePapx() + { $posMem = $this->arrayFib['fcPlcfBtePapx']; $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBtePapx'], 4); $posMem += 4 * ($num + 1); - $plcfBtePapx_aPnBtePapx = $this->getArrayCP($this->data1Table, $posMem, $num); + $arrAPnBtePapx = $this->getArrayCP($this->data1Table, $posMem, $num); $posMem += 4 * $num; - foreach($plcfBtePapx_aPnBtePapx as $aPnBtePapx){ + foreach ($arrAPnBtePapx as $aPnBtePapx) { $offsetBase = $aPnBtePapx * 512; $offset = $offsetBase; @@ -1229,12 +1233,12 @@ private function readRecordPlcfBtePapx(){ $numRun = self::getInt1d($this->dataWorkDocument, $offset + 511); $arrayRGFC = array(); - for($inc = 0 ; $inc <= $numRun ; $inc++){ + for ($inc = 0; $inc <= $numRun; $inc++) { $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset); $offset += 4; } $arrayRGB = array(); - for($inc = 1 ; $inc <= $numRun ; $inc++){ + for ($inc = 1; $inc <= $numRun; $inc++) { // @link http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset); $offset += 1; @@ -1242,14 +1246,14 @@ private function readRecordPlcfBtePapx(){ $offset += 12; } - foreach ($arrayRGFC as $key => $rgFc) { - if(!isset($arrayRGFC[$key + 1])){ + foreach (array_keys($arrayRGFC) as $key) { + if (!isset($arrayRGFC[$key + 1])) { break; } $strLen = $arrayRGFC[$key + 1] - $arrayRGFC[$key] - 1; for ($inc = 0; $inc < $strLen; $inc++) { $byte = self::getInt1d($this->dataWorkDocument, $arrayRGFC[$key] + $inc); - if($byte > 0) { + if ($byte > 0) { $string .= chr($byte); } } @@ -1264,7 +1268,7 @@ private function readRecordPlcfBtePapx(){ $cb = self::getInt1d($this->dataWorkDocument, $offset); $offset += 1; print_r('$cb : '.$cb.PHP_EOL); - if($cb == 0){ + if ($cb == 0) { $cb = self::getInt1d($this->dataWorkDocument, $offset); $cb = $cb * 2; $offset += 1; @@ -1277,7 +1281,7 @@ private function readRecordPlcfBtePapx(){ $offset += 2; $cb -= 2; print_r('$istd : '.$istd.($istd == 0 ? ' (Normal)' : '').PHP_EOL); - if($cb > 0){ + if ($cb > 0) { do{ $sprm = self::getInt2d($this->dataWorkDocument, $offset); $offset += 2; @@ -1291,7 +1295,7 @@ private function readRecordPlcfBtePapx(){ print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL); print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL); print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc)); - switch(dechex($sprm_Sgc)){ + switch(dechex($sprm_Sgc)) { case 0x01: print_r(' (Paragraph property)'); break; @@ -1310,12 +1314,12 @@ private function readRecordPlcfBtePapx(){ } print_r(PHP_EOL); print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL); - switch(dechex($sprm_Spra)){ + switch(dechex($sprm_Spra)) { case 0x0: $operand = self::getInt1d($this->dataWorkDocument, $offset); $offset += 1; $cb -= 1; - switch(dechex($operand)){ + switch(dechex($operand)) { case 0x00: $operand = 'OFF'; break; @@ -1346,7 +1350,7 @@ private function readRecordPlcfBtePapx(){ print_r('$operand : 0x'.dechex($operand).PHP_EOL); break; case 0x3: - if($sprm_IsPmd != 0x70){ + if ($sprm_IsPmd != 0x70) { $operand = self::getInt4d($this->dataWorkDocument, $offset); $offset += 4; $cb -= 4; @@ -1354,7 +1358,7 @@ private function readRecordPlcfBtePapx(){ } break; case 0x7: - $operand = self::_GetInt3d($this->dataWorkDocument, $offset); + $operand = self::getInt3d($this->dataWorkDocument, $offset); $offset += 3; $cb -= 3; print_r('$operand : 0x'.dechex($operand).PHP_EOL); @@ -1364,9 +1368,9 @@ private function readRecordPlcfBtePapx(){ } // - switch(dechex($sprm_Sgc)){ + switch(dechex($sprm_Sgc)) { case 0x01: // Sprm is modifying a paragraph property. - switch($sprm_IsPmd){ + switch($sprm_IsPmd) { case 0x0A: // sprmPIlvl print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL); break; @@ -1379,28 +1383,28 @@ private function readRecordPlcfBtePapx(){ } break; case 0x02: // Sprm is modifying a character property. - switch($sprm_IsPmd){ + switch($sprm_IsPmd) { default: print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); break; } break; case 0x03: // Sprm is modifying a picture property. - switch($sprm_IsPmd){ + switch($sprm_IsPmd) { default: print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); break; } break; case 0x04: // Sprm is modifying a section property. - switch($sprm_IsPmd){ + switch($sprm_IsPmd) { default: print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); break; } break; case 0x05: // Sprm is modifying a table property. - switch($sprm_IsPmd){ + switch($sprm_IsPmd) { default: print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); break; @@ -1410,9 +1414,9 @@ private function readRecordPlcfBtePapx(){ print_r('$sprm_Sgc : '.dechex($sprm_Sgc).PHP_EOL.PHP_EOL); break; } - } while($cb > 0); + } while ($cb > 0); } else { - if($istd > 0){ + if ($istd > 0) { // @todo : Determining Properties of a Paragraph Style # @link http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx } @@ -1425,12 +1429,13 @@ private function readRecordPlcfBtePapx(){ * Character formatting properties to text in a document * @link http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx */ - private function readRecordPlcfBteChpx(){ + private function readRecordPlcfBteChpx() + { $posMem = $this->arrayFib['fcPlcfBteChpx']; $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBteChpx'], 4); - $PlcBteChpx_aPnBteChpx = array(); - for($inc = 0 ; $inc <= $num ; $inc++){ - $PlcBteChpx_aPnBteChpx[$inc] = self::getInt4d($this->data1Table, $posMem); + $aPnBteChpx = array(); + for ($inc = 0; $inc <= $num; $inc++) { + $aPnBteChpx[$inc] = self::getInt4d($this->data1Table, $posMem); $posMem += 4; } $PnFkpChpx = self::getInt4d($this->data1Table, $posMem); @@ -1443,13 +1448,13 @@ private function readRecordPlcfBteChpx(){ // @link : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx $numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511); $arrayRGFC = array(); - for($inc = 0 ; $inc <= $numRGFC ; $inc++){ + for ($inc = 0; $inc <= $numRGFC; $inc++) { $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset); $offset += 4; } $arrayRGB = array(); - for($inc = 1 ; $inc <= $numRGFC ; $inc++){ + for ($inc = 1; $inc <= $numRGFC; $inc++) { $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset); $offset += 1; } @@ -1461,7 +1466,7 @@ private function readRecordPlcfBteChpx(){ $oStyle->pos_len = (int)ceil((($arrayRGFC[$keyRGB] -1) - $arrayRGFC[$keyRGB -1]) / 2); $start += $oStyle->pos_len; - if($rgb > 0){ + if ($rgb > 0) { // Chp Structure // @link : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx $posRGB = $offsetBase + $rgb * 2; @@ -1501,11 +1506,11 @@ private function readSprmSpra($data, $pos, $oSprm) $length = 0; $operand = null; - switch(dechex($oSprm->spra)){ + switch(dechex($oSprm->spra)) { case 0x0: $operand = self::getInt1d($data, $pos); $length = 1; - switch(dechex($operand)){ + switch(dechex($operand)) { case 0x00: $operand = false; break; @@ -1531,13 +1536,13 @@ private function readSprmSpra($data, $pos, $oSprm) $length = 2; break; case 0x3: - if($oSprm->isPmd != 0x70){ + if ($oSprm->isPmd != 0x70) { $operand = self::getInt4d($data, $pos); $length = 4; } break; case 0x7: - $operand = self::_GetInt3d($data, $pos); + $operand = self::getInt3d($data, $pos); $length = 3; break; default: @@ -1556,7 +1561,7 @@ private function readSprmSpra($data, $pos, $oSprm) * @return \stdClass * @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx */ - private function readPrl($data, $pos, $cb) + private function readPrl($data, $pos, $cbNum) { $posStart = $pos; $oStylePrl = new \stdClass(); @@ -1573,23 +1578,23 @@ private function readPrl($data, $pos, $cb) $sprm = self::getInt2d($data, $pos); $oSprm = $this->readSprm($sprm); $pos += 2; - $cb -= 2; + $cbNum -= 2; $arrayReturn = $this->readSprmSpra($data, $pos, $oSprm); $pos += $arrayReturn['length']; - $cb -= $arrayReturn['length']; + $cbNum -= $arrayReturn['length']; $operand = $arrayReturn['operand']; - switch(dechex($oSprm->sgc)){ + switch(dechex($oSprm->sgc)) { // Paragraph property case 0x01: break; // Character property case 0x02: - if(!isset($oStylePrl->styleFont)) { + if (!isset($oStylePrl->styleFont)) { $oStylePrl->styleFont = array(); } - switch($oSprm->isPmd){ + switch($oSprm->isPmd) { // sprmCFRMarkIns case 0x01: break; @@ -1658,7 +1663,7 @@ private function readPrl($data, $pos, $cb) break; // sprmCKul case 0x3E: - switch(dechex($operand)){ + switch(dechex($operand)) { case 0x00: $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE; break; @@ -1721,7 +1726,7 @@ private function readPrl($data, $pos, $cb) // sprmCIco //@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx case 0x42: - switch(dechex($operand)){ + switch(dechex($operand)) { case 0x00: case 0x01: $oStylePrl->styleFont['color'] = '000000'; @@ -1799,7 +1804,7 @@ private function readPrl($data, $pos, $cb) // sprmCRgFtc0 case 0x4F: $oStylePrl->styleFont['name'] = ''; - if(isset($this->arrayFonts[$operand])) { + if (isset($this->arrayFonts[$operand])) { $oStylePrl->styleFont['name'] = $this->arrayFonts[$operand]['main']; } break; @@ -1829,7 +1834,7 @@ private function readPrl($data, $pos, $cb) case 0x66: // $operand = self::getInt2d($data, $pos); $pos += 2; - $cb -= 2; + $cbNum -= 2; // $ipat = ($operand >> 0) && bindec('111111'); // $icoBack = ($operand >> 6) && bindec('11111'); // $icoFore = ($operand >> 11) && bindec('11111'); @@ -1845,7 +1850,7 @@ private function readPrl($data, $pos, $cb) $pos += 1; $pos += 1; $oStylePrl->styleFont['color'] = $red.$green.$blue; - $cb -= 4; + $cbNum -= 4; break; default: // print_r('@todo Character : 0x'.dechex($oSprm->isPmd)); @@ -1857,10 +1862,10 @@ private function readPrl($data, $pos, $cb) break; // Section property case 0x04: - if(!isset($oStylePrl->styleSection)) { + if (!isset($oStylePrl->styleSection)) { $oStylePrl->styleSection = array(); } - switch($oSprm->isPmd){ + switch($oSprm->isPmd) { // sprmSNfcPgn case 0x0E: // numbering format used for page numbers @@ -1919,7 +1924,7 @@ private function readPrl($data, $pos, $cb) case 0x05: break; } - } while($cb > 0); + } while ($cbNum > 0); if (!is_null($sprmCPicLocation)) { if (!is_null($sprmCFData) && $sprmCFData == 0x01) { @@ -1953,7 +1958,7 @@ private function readPrl($data, $pos, $cb) $hlstmfSiteGaveDisplayName = ($data >> 2) & bindec('1'); $hlstmfIsAbsolute = ($data >> 1) & bindec('1'); $hlstmfHasMoniker = ($data >> 0) & bindec('1'); - for($inc = 0 ; $inc <= 32 ; $inc++){ + for ($inc = 0; $inc <= 32; $inc++) { echo ($data >> $inc) & bindec('1'); } @@ -1967,20 +1972,20 @@ private function readPrl($data, $pos, $cb) print_r('$hlstmfHasFrameName > '.$hlstmfHasFrameName.PHP_EOL); print_r('$hlstmfMonikerSavedAsStr > '.$hlstmfMonikerSavedAsStr.PHP_EOL); print_r('$hlstmfAbsFromGetdataRel > '.$hlstmfAbsFromGetdataRel.PHP_EOL); - if($streamVersion == 2){ + if ($streamVersion == 2) { $AAA = self::getInt4d($this->dataData, $sprmCPicLocation); echo 'AAAA : '.$AAA.PHP_EOL; - if($hlstmfHasDisplayName == 1){ + if ($hlstmfHasDisplayName == 1) { echo 'displayName'.PHP_EOL; } - if($hlstmfHasFrameName == 1){ + if ($hlstmfHasFrameName == 1) { echo 'targetFrameName'.PHP_EOL; } - if($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1){ + if ($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1) { $sprmCPicLocation += 16; $length = self::getInt4d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 4; - for($inc = 0 ; $inc < ($length / 2) ; $inc++) { + for ($inc = 0; $inc < ($length / 2); $inc++) { $chr = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; print_r(chr($chr)); @@ -1988,17 +1993,17 @@ private function readPrl($data, $pos, $cb) echo PHP_EOL; echo 'moniker : '.$length.PHP_EOL; } - if($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1){ + if ($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1) { echo 'oleMoniker'.PHP_EOL; } - if($hlstmfHasLocationStr == 1){ + if ($hlstmfHasLocationStr == 1) { echo 'location'.PHP_EOL; } - if($hlstmfHasGUID == 1) { + if ($hlstmfHasGUID == 1) { echo 'guid'.PHP_EOL; $sprmCPicLocation += 16; } - if($hlstmfHasCreationTime == 1) { + if ($hlstmfHasCreationTime == 1) { echo 'fileTime'.PHP_EOL; $sprmCPicLocation += 4; } @@ -2013,7 +2018,7 @@ private function readPrl($data, $pos, $cb) // PICF : cbHeader $sprmCPicLocation += 2; // PICF : mfpf : mm - $mfpf_mm = self::getInt2d($this->dataData, $sprmCPicLocation); + $mfpfMm = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : mfpf : xExt $sprmCPicLocation += 2; @@ -2030,28 +2035,28 @@ private function readPrl($data, $pos, $cb) // PICF : innerHeader : padding2 $sprmCPicLocation += 4; // PICF : picmid : dxaGoal - $picmid_dxaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDxaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : dyaGoal - $picmid_dyaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDyaGoal = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : mx - $picmid_mx = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidMx = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : my - $picmid_my = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidMy = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : dxaReserved1 - $picmid_dxaCropLeft = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDxaCropLeft = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : dyaReserved1 - $picmid_dxaCropTop = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDxaCropTop = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : dxaReserved2 - $picmid_dxaCropRight = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDxaCropRight = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : dyaReserved2 - $picmid_dxaCropBottom = self::getInt2d($this->dataData, $sprmCPicLocation); + $picmidDxaCropBottom = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; // PICF : picmid : fReserved $sprmCPicLocation += 1; @@ -2072,14 +2077,14 @@ private function readPrl($data, $pos, $cb) // PICF : cProps $sprmCPicLocation += 2; - if ($mfpf_mm == 0x0066) { + if ($mfpfMm == 0x0066) { // cchPicName $cchPicName = self::getInt1d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 1; // stPicName $stPicName = ''; - for($inc = 0; $inc <= $cchPicName; $inc++){ + for ($inc = 0; $inc <= $cchPicName; $inc++) { $chr = self::getInt1d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 1; $stPicName .= chr($chr); @@ -2090,13 +2095,13 @@ private function readPrl($data, $pos, $cb) // picture : shape $shapeRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 8; - if($shapeRH['recVer'] == 0xF && $shapeRH['recInstance'] == 0x000 && $shapeRH['recType'] == 0xF004){ + if ($shapeRH['recVer'] == 0xF && $shapeRH['recInstance'] == 0x000 && $shapeRH['recType'] == 0xF004) { $sprmCPicLocation += $shapeRH['recLen']; } // picture : rgfb //@link : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx $fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation); - while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)){ + while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) { $sprmCPicLocation += 8; switch ($fileBlockRH['recType']) { // OfficeArtFBSE @@ -2128,7 +2133,7 @@ private function readPrl($data, $pos, $cb) // nameData if ($cbName > 0) { $nameData = ''; - for($inc = 0; $inc <= ($cbName / 2); $inc++){ + for ($inc = 0; $inc <= ($cbName / 2); $inc++) { $chr = self::getInt2d($this->dataData, $sprmCPicLocation); $sprmCPicLocation += 2; $nameData .= chr($chr); @@ -2140,7 +2145,7 @@ private function readPrl($data, $pos, $cb) switch ($embeddedBlipRH['recType']) { case self::OFFICEARTBLIPJPG: case self::OFFICEARTBLIPJPEG: - if(!isset($oStylePrl->image)){ + if (!isset($oStylePrl->image)) { $oStylePrl->image = array(); } $sprmCPicLocation += 8; @@ -2156,16 +2161,16 @@ private function readPrl($data, $pos, $cb) $oStylePrl->image['data'] = substr($this->dataData, $sprmCPicLocation, $embeddedBlipRH['recLen']); $oStylePrl->image['format'] = 'jpg'; // Image Size - $iCropWidth = $picmid_dxaGoal - ($picmid_dxaCropLeft + $picmid_dxaCropRight); - $iCropHeight = $picmid_dyaGoal - ($picmid_dxaCropTop + $picmid_dxaCropBottom); - if (!$iCropWidth){ + $iCropWidth = $picmidDxaGoal - ($picmidDxaCropLeft + $picmidDxaCropRight); + $iCropHeight = $picmidDyaGoal - ($picmidDxaCropTop + $picmidDxaCropBottom); + if (!$iCropWidth) { $iCropWidth = 1; } - if (!$iCropHeight){ + if (!$iCropHeight) { $iCropHeight = 1; } - $oStylePrl->image['width'] = Drawing::twipsToPixels($iCropWidth * $picmid_mx / 1000); - $oStylePrl->image['height'] = Drawing::twipsToPixels($iCropHeight * $picmid_my / 1000); + $oStylePrl->image['width'] = Drawing::twipsToPixels($iCropWidth * $picmidMx / 1000); + $oStylePrl->image['height'] = Drawing::twipsToPixels($iCropHeight * $picmidMy / 1000); $sprmCPicLocation += $embeddedBlipRH['recLen']; break; @@ -2211,7 +2216,7 @@ private function generatePhpWord() $sHYPERLINK = ''; foreach ($this->arrayParagraphs as $itmParagraph) { $textPara = $itmParagraph; - foreach ($this->arrayCharacters as $keyCharacters => $oCharacters) { + foreach ($this->arrayCharacters as $oCharacters) { $subText = substr($textPara, $oCharacters->pos_start, $oCharacters->pos_len); $subText = str_replace(chr(13), PHP_EOL, $subText); $arrayText = explode(PHP_EOL, $subText); @@ -2224,15 +2229,15 @@ private function generatePhpWord() // Style Character $styleFont = array(); - if(isset($oCharacters->style)){ - if(isset($oCharacters->style->styleFont)){ + if (isset($oCharacters->style)) { + if (isset($oCharacters->style->styleFont)) { $styleFont = $oCharacters->style->styleFont; } } foreach ($arrayText as $sText) { // HyperLink - if(empty($sText) && !empty($sHYPERLINK)) { + if (empty($sText) && !empty($sHYPERLINK)) { $arrHYPERLINK = explode('"', $sHYPERLINK); $oSection->addLink($arrHYPERLINK[1], null); // print_r('>addHyperLink<'.$sHYPERLINK.'>'.ord($sHYPERLINK[0]).EOL); @@ -2240,27 +2245,27 @@ private function generatePhpWord() } // TextBreak - if(empty($sText)) { + if (empty($sText)) { $oSection->addTextBreak(); $sHYPERLINK = ''; // print_r('>addTextBreak<' . EOL); } - if(!empty($sText)){ - if(!empty($sHYPERLINK) && ord($sText[0]) > 20){ + if (!empty($sText)) { + if (!empty($sHYPERLINK) && ord($sText[0]) > 20) { $sHYPERLINK .= $sText; } - if(empty($sHYPERLINK)) { - if(ord($sText[0]) > 20){ - if(strpos(trim($sText), 'HYPERLINK "') === 0){ + if (empty($sHYPERLINK)) { + if (ord($sText[0]) > 20) { + if (strpos(trim($sText), 'HYPERLINK "') === 0) { $sHYPERLINK = $sText; } else { $oSection->addText($sText, $styleFont); // print_r('>addText<'.$sText.'>'.ord($sText[0]).EOL); } } - if(ord($sText[0]) == 1) { - if(isset($oCharacters->style->image)){ + if (ord($sText[0]) == 1) { + if (isset($oCharacters->style->image)) { $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc').'.'.$oCharacters->style->image['format']; file_put_contents($fileImage, $oCharacters->style->image['data']); $oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height'])); @@ -2307,7 +2312,7 @@ public static function getInt2d($data, $pos) * @param int $pos * @return int */ - public static function _GetInt3d($data, $pos) + public static function getInt3d($data, $pos) { return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16); } @@ -2324,13 +2329,13 @@ public static function getInt4d($data, $pos) // FIX: represent numbers correctly on 64-bit system // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems - $_or_24 = ord($data[$pos + 3]); - if ($_or_24 >= 128) { + $or24 = ord($data[$pos + 3]); + if ($or24 >= 128) { // negative number - $_ord_24 = -abs((256 - $_or_24) << 24); + $ord24 = -abs((256 - $or24) << 24); } else { - $_ord_24 = ($_or_24 & 127) << 24; + $ord24 = ($or24 & 127) << 24; } - return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24; + return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24; } } diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 85ce595f37..e3a33e5b69 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -31,7 +31,7 @@ public static function pixelsToEMU($pValue = 0) * @param integer $pValue Value in EMU * @return integer Value in pixels */ - public static function EMUToPixels($pValue = 0) + public static function emuToPixels($pValue = 0) { if ($pValue != 0) { return round($pValue / 9525); @@ -201,17 +201,17 @@ public static function htmlToRGB($pValue) } if (strlen($pValue) == 6) { - list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]); + list($colorR, $colorG, $colorB) = 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]); + list($colorR, $colorG, $colorB) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]); } else { return false; } - $color_R = hexdec($color_R); - $color_G = hexdec($color_G); - $color_B = hexdec($color_B); + $colorR = hexdec($colorR); + $colorG = hexdec($colorG); + $colorB = hexdec($colorB); - return array($color_R, $color_G, $color_B); + return array($colorR, $colorG, $colorB); } } diff --git a/src/PhpWord/Shared/OLERead.php b/src/PhpWord/Shared/OLERead.php index 5235d37e7d..aa1ad48a38 100644 --- a/src/PhpWord/Shared/OLERead.php +++ b/src/PhpWord/Shared/OLERead.php @@ -15,46 +15,47 @@ defined('IDENTIFIER_OLE') || define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)); -class OLERead { +class OLERead +{ private $data = ''; // OLE identifier const IDENTIFIER_OLE = IDENTIFIER_OLE; // Size of a sector = 512 bytes - const BIG_BLOCK_SIZE = 0x200; + const BIG_BLOCK_SIZE = 0x200; // Size of a short sector = 64 bytes - const SMALL_BLOCK_SIZE = 0x40; + const SMALL_BLOCK_SIZE = 0x40; // Size of a directory entry always = 128 bytes - const PROPERTY_STORAGE_BLOCK_SIZE = 0x80; + const PROPERTY_STORAGE_BLOCK_SIZE = 0x80; // Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams - const SMALL_BLOCK_THRESHOLD = 0x1000; + const SMALL_BLOCK_THRESHOLD = 0x1000; // header offsets - const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c; - const ROOT_START_BLOCK_POS = 0x30; - const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c; - const EXTENSION_BLOCK_POS = 0x44; - const NUM_EXTENSION_BLOCK_POS = 0x48; - const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c; + const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c; + const ROOT_START_BLOCK_POS = 0x30; + const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c; + const EXTENSION_BLOCK_POS = 0x44; + const NUM_EXTENSION_BLOCK_POS = 0x48; + const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c; // property storage offsets (directory offsets) - const SIZE_OF_NAME_POS = 0x40; - const TYPE_POS = 0x42; - const START_BLOCK_POS = 0x74; - const SIZE_POS = 0x78; + const SIZE_OF_NAME_POS = 0x40; + const TYPE_POS = 0x42; + const START_BLOCK_POS = 0x74; + const SIZE_POS = 0x78; - public $wrkdocument = null; - public $wrk1Table = null; - public $wrkData = null; - public $wrkObjectPool = null; - public $summaryInformation = null; - public $documentSummaryInformation = null; + public $wrkdocument = null; + public $wrk1Table = null; + public $wrkData = null; + public $wrkObjectPool = null; + public $summaryInformation = null; + public $docSummaryInformation = null; /** @@ -66,13 +67,13 @@ class OLERead { public function read($sFileName) { // Check if file exists and is readable - if(!is_readable($sFileName)) { + if (!is_readable($sFileName)) { throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable."); } // Get the file identifier // Don't bother reading the whole file until we know it's a valid OLE file - $this->data = file_get_contents($sFileName, FALSE, NULL, 0, 8); + $this->data = file_get_contents($sFileName, false, null, 0, 8); // Check OLE identifier if ($this->data != self::IDENTIFIER_OLE) { @@ -83,19 +84,19 @@ public function read($sFileName) $this->data = file_get_contents($sFileName); // Total number of sectors used for the SAT - $this->numBigBlockDepotBlocks = self::_GetInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); + $this->numBigBlockDepotBlocks = self::getInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); // SecID of the first sector of the directory stream - $this->rootStartBlock = self::_GetInt4d($this->data, self::ROOT_START_BLOCK_POS); + $this->rootStartBlock = self::getInt4d($this->data, self::ROOT_START_BLOCK_POS); // SecID of the first sector of the SSAT (or -2 if not extant) - $this->sbdStartBlock = self::_GetInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS); + $this->sbdStartBlock = self::getInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS); // SecID of the first sector of the MSAT (or -2 if no additional sectors are used) - $this->extensionBlock = self::_GetInt4d($this->data, self::EXTENSION_BLOCK_POS); + $this->extensionBlock = self::getInt4d($this->data, self::EXTENSION_BLOCK_POS); // Total number of sectors used by MSAT - $this->numExtensionBlocks = self::_GetInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS); + $this->numExtensionBlocks = self::getInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS); $bigBlockDepotBlocks = array(); $pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS; @@ -107,7 +108,7 @@ public function read($sFileName) } for ($i = 0; $i < $bbdBlocks; ++$i) { - $bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); + $bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos); $pos += 4; } @@ -116,13 +117,13 @@ public function read($sFileName) $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1); for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) { - $bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); + $bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos); $pos += 4; } $bbdBlocks += $blocksToRead; if ($bbdBlocks < $this->numBigBlockDepotBlocks) { - $this->extensionBlock = self::_GetInt4d($this->data, $pos); + $this->extensionBlock = self::getInt4d($this->data, $pos); } } @@ -145,14 +146,14 @@ public function read($sFileName) $this->smallBlockChain .= substr($this->data, $pos, 4*$bbs); $pos += 4*$bbs; - $sbdBlock = self::_GetInt4d($this->bigBlockChain, $sbdBlock*4); + $sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4); } // read the directory stream $block = $this->rootStartBlock; - $this->entry = $this->_readData($block); + $this->entry = $this->readData($block); - $this->_readPropertySets(); + $this->readPropertySets(); } /** @@ -162,14 +163,14 @@ public function read($sFileName) */ public function getStream($stream) { - if ($stream === NULL) { + if ($stream === null) { return null; } $streamData = ''; if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) { - $rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']); + $rootdata = $this->readData($this->props[$this->rootentry]['startBlock']); $block = $this->props[$stream]['startBlock']; @@ -177,7 +178,7 @@ public function getStream($stream) $pos = $block * self::SMALL_BLOCK_SIZE; $streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); - $block = self::_GetInt4d($this->smallBlockChain, $block*4); + $block = self::getInt4d($this->smallBlockChain, $block*4); } return $streamData; @@ -187,14 +188,16 @@ public function getStream($stream) ++$numBlocks; } - if ($numBlocks == 0) return ''; + if ($numBlocks == 0) { + return ''; + } $block = $this->props[$stream]['startBlock']; while ($block != -2) { $pos = ($block + 1) * self::BIG_BLOCK_SIZE; $streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); - $block = self::_GetInt4d($this->bigBlockChain, $block*4); + $block = self::getInt4d($this->bigBlockChain, $block*4); } return $streamData; @@ -204,18 +207,18 @@ public function getStream($stream) /** * Read a standard stream (by joining sectors using information from SAT) * - * @param int $bl Sector ID where the stream starts + * @param int $blSectorId Sector ID where the stream starts * @return string Data for standard stream */ - private function _readData($bl) + private function readData($blSectorId) { - $block = $bl; + $block = $blSectorId; $data = ''; - while ($block != -2) { + while ($block != -2) { $pos = ($block + 1) * self::BIG_BLOCK_SIZE; $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); - $block = self::_GetInt4d($this->bigBlockChain, $block*4); + $block = self::getInt4d($this->bigBlockChain, $block*4); } return $data; } @@ -223,28 +226,29 @@ private function _readData($bl) /** * Read entries in the directory stream. */ - private function _readPropertySets() { + private function readPropertySets() + { $offset = 0; // loop through entires, each entry is 128 bytes $entryLen = strlen($this->entry); while ($offset < $entryLen) { // entry data (128 bytes) - $d = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE); + $data = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE); // size in bytes of name - $nameSize = ord($d[self::SIZE_OF_NAME_POS]) | (ord($d[self::SIZE_OF_NAME_POS+1]) << 8); + $nameSize = ord($data[self::SIZE_OF_NAME_POS]) | (ord($data[self::SIZE_OF_NAME_POS+1]) << 8); // type of entry - $type = ord($d[self::TYPE_POS]); + $type = ord($data[self::TYPE_POS]); // sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook) // sectorID of first sector of the short-stream container stream, if this entry is root entry - $startBlock = self::_GetInt4d($d, self::START_BLOCK_POS); + $startBlock = self::getInt4d($data, self::START_BLOCK_POS); - $size = self::_GetInt4d($d, self::SIZE_POS); + $size = self::getInt4d($data, self::SIZE_POS); - $name = str_replace("\x00", "", substr($d,0,$nameSize)); + $name = str_replace("\x00", "", substr($data, 0, $nameSize)); $this->props[] = array ( @@ -260,13 +264,13 @@ private function _readPropertySets() { // print_r($upName.PHP_EOL); if (($upName === 'WORDDOCUMENT')) { $this->wrkdocument = count($this->props) - 1; - } elseif (($upName === '1TABLE')) { + } elseif ($upName === '1TABLE') { $this->wrk1Table = count($this->props) - 1; - } elseif (($upName === 'DATA')) { + } elseif ($upName === 'DATA') { $this->wrkData = count($this->props) - 1; - } elseif (($upName === 'OBJECTPOOL')) { + } elseif ($upName === 'OBJECTPOOL') { $this->wrkObjectPoolelseif = count($this->props) - 1; - } elseif ( $upName === 'ROOT ENTRY' || $upName === 'R') { + } elseif ($upName === 'ROOT ENTRY' || $upName === 'R') { $this->rootentry = count($this->props) - 1; } @@ -277,7 +281,7 @@ private function _readPropertySets() { // Additional Document Summary information if ($name == chr(5) . 'DocumentSummaryInformation') { - $this->documentSummaryInformation = count($this->props) - 1; + $this->docSummaryInformation = count($this->props) - 1; } $offset += self::PROPERTY_STORAGE_BLOCK_SIZE; @@ -292,19 +296,18 @@ private function _readPropertySets() { * @param int $pos * @return int */ - private static function _GetInt4d($data, $pos) + private static function getInt4d($data, $pos) { // FIX: represent numbers correctly on 64-bit system // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems - $_or_24 = ord($data[$pos + 3]); - if ($_or_24 >= 128) { + $or24 = ord($data[$pos + 3]); + if ($or24 >= 128) { // negative number - $_ord_24 = -abs((256 - $_or_24) << 24); + $ord24 = -abs((256 - $or24) << 24); } else { - $_ord_24 = ($_or_24 & 127) << 24; + $ord24 = ($or24 & 127) << 24; } - return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24; + return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24; } - } From 90d64bd3475c05814d47ba497dba5c392308b7cd Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 16 Aug 2014 12:44:12 +0200 Subject: [PATCH 100/174] #23 : Implement Word97 aka MsDoc Reader (PHPCS-PHPMD Fixes) --- src/PhpWord/Reader/MsDoc.php | 8 ++++---- src/PhpWord/Shared/OLERead.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php index d3f5a44b55..c63d8d9e22 100644 --- a/src/PhpWord/Reader/MsDoc.php +++ b/src/PhpWord/Reader/MsDoc.php @@ -318,7 +318,7 @@ private function readFib($data) $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002); break; - case 0x00A4 : + case 0x00A4: $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97); $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000); $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002); @@ -1438,10 +1438,10 @@ private function readRecordPlcfBteChpx() $aPnBteChpx[$inc] = self::getInt4d($this->data1Table, $posMem); $posMem += 4; } - $PnFkpChpx = self::getInt4d($this->data1Table, $posMem); + $pnFkpChpx = self::getInt4d($this->data1Table, $posMem); $posMem += 4; - $offsetBase = $PnFkpChpx * 512; + $offsetBase = $pnFkpChpx * 512; $offset = $offsetBase; // ChpxFkp @@ -2258,7 +2258,7 @@ private function generatePhpWord() if (empty($sHYPERLINK)) { if (ord($sText[0]) > 20) { if (strpos(trim($sText), 'HYPERLINK "') === 0) { - $sHYPERLINK = $sText; + $sHYPERLINK = $sText; } else { $oSection->addText($sText, $styleFont); // print_r('>addText<'.$sText.'>'.ord($sText[0]).EOL); diff --git a/src/PhpWord/Shared/OLERead.php b/src/PhpWord/Shared/OLERead.php index aa1ad48a38..82815afc4b 100644 --- a/src/PhpWord/Shared/OLERead.php +++ b/src/PhpWord/Shared/OLERead.php @@ -55,7 +55,7 @@ class OLERead public $wrkData = null; public $wrkObjectPool = null; public $summaryInformation = null; - public $docSummaryInformation = null; + public $docSummaryInfos = null; /** @@ -281,7 +281,7 @@ private function readPropertySets() // Additional Document Summary information if ($name == chr(5) . 'DocumentSummaryInformation') { - $this->docSummaryInformation = count($this->props) - 1; + $this->docSummaryInfos = count($this->props) - 1; } $offset += self::PROPERTY_STORAGE_BLOCK_SIZE; From 1a40f66a714f85e0ecb52fb4d9384cac75c816db Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 16 Aug 2014 13:10:39 +0200 Subject: [PATCH 101/174] #23 : Implement Word97 aka MsDoc Reader (Changelog) --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6040c46e92..ff02b1f30b 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.12.0 - Not yet released -This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. +This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced. ### Features @@ -23,6 +23,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin - Paragraph: Support for paragraph with borders - @ivanlanin GH-294 - Word2007 Writer : Support for RTL - @Progi1984 GH-331 +- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287 ### Bugfixes From ec25dd338bedbdcb20fa9ec553096cd808253d09 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 16 Aug 2014 15:21:58 +0400 Subject: [PATCH 102/174] https://github.com/PHPOffice/PHPWord/issues/216 --- CHANGELOG.md | 3 + composer.json | 4 +- docs/index.rst | 2 +- docs/src/documentation.md | 20 +- docs/templates-processing.rst | 25 + docs/templates.rst | 27 -- samples/Sample_07_TemplateCloneRow.php | 92 ++-- samples/Sample_23_TemplateBlock.php | 18 +- src/PhpWord/PhpWord.php | 6 +- src/PhpWord/Template.php | 445 +---------------- src/PhpWord/TemplateProcessor.php | 456 ++++++++++++++++++ tests/PhpWord/Tests/PhpWordTest.php | 6 +- ...lateTest.php => TemplateProcessorTest.php} | 118 ++--- 13 files changed, 623 insertions(+), 599 deletions(-) create mode 100644 docs/templates-processing.rst delete mode 100644 docs/templates.rst create mode 100644 src/PhpWord/TemplateProcessor.php rename tests/PhpWord/Tests/{TemplateTest.php => TemplateProcessorTest.php} (64%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6040c46e92..f42d810499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` - `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter` - `DocumentProperties` replaced by `Metadata\DocInfo` +- `Template` replaced by `TemplateProcessor` +- `PhpWord->loadTemplate($filename)` ### Miscellaneous @@ -49,6 +51,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Element: Refactor elements to move set relation Id from container to element - @ivanlanin - Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko - Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 +- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 ## 0.11.1 - 2 June 2014 diff --git a/composer.json b/composer.json index 74009e3a7b..b55d8340ca 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "phpoffice/phpword", "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", + "PHP", "PhpOffice", "office", "PhpWord", "word", "template", "template processor", "reader", "writer", "docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML", "RTF", "Rich Text Format", "doc", "odt", "OpenDocument", "PDF", "HTML" ], @@ -50,7 +50,7 @@ "ext-zip": "Used to write DOCX and ODT", "ext-gd2": "Used to add images", "ext-xmlwriter": "Used to write DOCX and ODT", - "ext-xsl": "Used to apply XSL style sheet to template part", + "ext-xsl": "Used to apply XSL style sheet to main document part of OOXML template", "dompdf/dompdf": "Used to write PDF" }, "autoload": { diff --git a/docs/index.rst b/docs/index.rst index 4f200cca79..671c32a64c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,7 +23,7 @@ Format (RTF). containers elements styles - templates + templates-processing writersreaders recipes faq diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 9c0c865b07..3e7d41b0a2 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -44,7 +44,7 @@ Don't forget to change `code::` directive to `code-block::` in the resulting rst - [Font](#font) - [Paragraph](#paragraph) - [Table](#table) -- [Templates](#templates) +- [Templates processing](#templates-processing) - [Writers & readers](#writers-readers) - [OOXML](#ooxml) - [OpenDocument](#opendocument) @@ -873,21 +873,25 @@ Available image styles: - `font` Font name - `hint` See font style -# Templates +# Templates processing -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. +You can create a .docx document template with included search-patterns which can be replaced by any value you wish. Only single-line values can be replaced. + +To deal with a template file, use `new TemplateProcessor` statement. After TemplateProcessor instance creation the document template is copied into the temporary directory. Then you can use `TemplateProcessor::setValue` method to change the value of a search pattern. The search-pattern model is: `${search-pattern}`. Example: ```php -$template = $phpWord->loadTemplate('Template.docx'); -$template->setValue('Name', 'Somebody someone'); -$template->setValue('Street', 'Coming-Undone-Street 32'); +$templateProcessor = new TemplateProcessor('Template.docx'); +$templateProcessor->setValue('Name', 'Somebody someone'); +$templateProcessor->setValue('Street', 'Coming-Undone-Street 32'); ``` -See `Sample_07_TemplateCloneRow.php` for example on how to create multirow from a single row in a template by using `cloneRow`. +It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform main document part of the template using XSLT (see `TemplateProcessor::applyXslStyleSheet`). + +See `Sample_07_TemplateCloneRow.php` for example on how to create multirow from a single row in a template by using `TemplateProcessor::cloneRow`. -See `Sample_23_TemplateBlock.php` for example on how to clone a block of text using `cloneBlock` and delete a block of text using `deleteBlock`. +See `Sample_23_TemplateBlock.php` for example on how to clone a block of text using `TemplateProcessor::cloneBlock` and delete a block of text using `TemplateProcessor::deleteBlock`. # Writers & readers diff --git a/docs/templates-processing.rst b/docs/templates-processing.rst new file mode 100644 index 0000000000..6a65ea0d57 --- /dev/null +++ b/docs/templates-processing.rst @@ -0,0 +1,25 @@ +.. _templates-processing: + +Templates processing +==================== + +You can create a .docx document template with included search-patterns which can be replaced by any value you wish. Only single-line values can be replaced. + +To deal with a template file, use ``new TemplateProcessor`` statement. After TemplateProcessor instance creation the document template is copied into the temporary directory. Then you can use ``TemplateProcessor::setValue`` method to change the value of a search pattern. The search-pattern model is: ``${search-pattern}``. + +Example: + +.. code-block:: php + + $templateProcessor = new TemplateProcessor('Template.docx'); + $templateProcessor->setValue('Name', 'Somebody someone'); + $templateProcessor->setValue('Street', 'Coming-Undone-Street 32'); + +It is not possible to directly add new OOXML elements to the template file being processed, but it is possible to transform main document part of the template using XSLT (see ``TemplateProcessor::applyXslStyleSheet``). + +See ``Sample_07_TemplateCloneRow.php`` for example on how to create +multirow from a single row in a template by using ``TemplateProcessor::cloneRow``. + +See ``Sample_23_TemplateBlock.php`` for example on how to clone a block +of text using ``TemplateProcessor::cloneBlock`` and delete a block of text using +``TemplateProcessor::deleteBlock``. diff --git a/docs/templates.rst b/docs/templates.rst deleted file mode 100644 index b1d9d205e1..0000000000 --- a/docs/templates.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _templates: - -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. - -Example: - -.. code-block:: php - - $template = $phpWord->loadTemplate('Template.docx'); - $template->setValue('Name', 'Somebody someone'); - $template->setValue('Street', 'Coming-Undone-Street 32'); - -See ``Sample_07_TemplateCloneRow.php`` for example on how to create -multirow from a single row in a template by using ``cloneRow``. - -See ``Sample_23_TemplateBlock.php`` for example on how to clone a block -of text using ``cloneBlock`` and delete a block of text using -``deleteBlock``. diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index 899bc82bbf..0712ddfc0a 100644 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -1,64 +1,60 @@ loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); +// Template processor instance creation +echo date('H:i:s') , ' Creating new TemplateProcessor instance...' , EOL; +$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx'); // Variables on different parts of document -$document->setValue('weekday', date('l')); // On section/content -$document->setValue('time', date('H:i')); // On footer -$document->setValue('serverName', realpath(__DIR__)); // On header +$templateProcessor->setValue('weekday', date('l')); // On section/content +$templateProcessor->setValue('time', date('H:i')); // On footer +$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header // Simple table -$document->cloneRow('rowValue', 10); - -$document->setValue('rowValue#1', 'Sun'); -$document->setValue('rowValue#2', 'Mercury'); -$document->setValue('rowValue#3', 'Venus'); -$document->setValue('rowValue#4', 'Earth'); -$document->setValue('rowValue#5', 'Mars'); -$document->setValue('rowValue#6', 'Jupiter'); -$document->setValue('rowValue#7', 'Saturn'); -$document->setValue('rowValue#8', 'Uranus'); -$document->setValue('rowValue#9', 'Neptun'); -$document->setValue('rowValue#10', 'Pluto'); - -$document->setValue('rowNumber#1', '1'); -$document->setValue('rowNumber#2', '2'); -$document->setValue('rowNumber#3', '3'); -$document->setValue('rowNumber#4', '4'); -$document->setValue('rowNumber#5', '5'); -$document->setValue('rowNumber#6', '6'); -$document->setValue('rowNumber#7', '7'); -$document->setValue('rowNumber#8', '8'); -$document->setValue('rowNumber#9', '9'); -$document->setValue('rowNumber#10', '10'); +$templateProcessor->cloneRow('rowValue', 10); + +$templateProcessor->setValue('rowValue#1', 'Sun'); +$templateProcessor->setValue('rowValue#2', 'Mercury'); +$templateProcessor->setValue('rowValue#3', 'Venus'); +$templateProcessor->setValue('rowValue#4', 'Earth'); +$templateProcessor->setValue('rowValue#5', 'Mars'); +$templateProcessor->setValue('rowValue#6', 'Jupiter'); +$templateProcessor->setValue('rowValue#7', 'Saturn'); +$templateProcessor->setValue('rowValue#8', 'Uranus'); +$templateProcessor->setValue('rowValue#9', 'Neptun'); +$templateProcessor->setValue('rowValue#10', 'Pluto'); + +$templateProcessor->setValue('rowNumber#1', '1'); +$templateProcessor->setValue('rowNumber#2', '2'); +$templateProcessor->setValue('rowNumber#3', '3'); +$templateProcessor->setValue('rowNumber#4', '4'); +$templateProcessor->setValue('rowNumber#5', '5'); +$templateProcessor->setValue('rowNumber#6', '6'); +$templateProcessor->setValue('rowNumber#7', '7'); +$templateProcessor->setValue('rowNumber#8', '8'); +$templateProcessor->setValue('rowNumber#9', '9'); +$templateProcessor->setValue('rowNumber#10', '10'); // Table with a spanned cell -$document->cloneRow('userId', 3); +$templateProcessor->cloneRow('userId', 3); -$document->setValue('userId#1', '1'); -$document->setValue('userFirstName#1', 'James'); -$document->setValue('userName#1', 'Taylor'); -$document->setValue('userPhone#1', '+1 428 889 773'); +$templateProcessor->setValue('userId#1', '1'); +$templateProcessor->setValue('userFirstName#1', 'James'); +$templateProcessor->setValue('userName#1', 'Taylor'); +$templateProcessor->setValue('userPhone#1', '+1 428 889 773'); -$document->setValue('userId#2', '2'); -$document->setValue('userFirstName#2', 'Robert'); -$document->setValue('userName#2', 'Bell'); -$document->setValue('userPhone#2', '+1 428 889 774'); +$templateProcessor->setValue('userId#2', '2'); +$templateProcessor->setValue('userFirstName#2', 'Robert'); +$templateProcessor->setValue('userName#2', 'Bell'); +$templateProcessor->setValue('userPhone#2', '+1 428 889 774'); -$document->setValue('userId#3', '3'); -$document->setValue('userFirstName#3', 'Michael'); -$document->setValue('userName#3', 'Ray'); -$document->setValue('userPhone#3', '+1 428 889 775'); +$templateProcessor->setValue('userId#3', '3'); +$templateProcessor->setValue('userFirstName#3', 'Michael'); +$templateProcessor->setValue('userName#3', 'Ray'); +$templateProcessor->setValue('userPhone#3', '+1 428 889 775'); -$name = 'Sample_07_TemplateCloneRow.docx'; -echo date('H:i:s'), " Write to Word2007 format", EOL; -$document->saveAs($name); -rename($name, "results/{$name}"); +echo date('H:i:s'), ' Saving the result document...', EOL; +$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx'); echo getEndingNotes(array('Word2007' => 'docx')); if (!CLI) { diff --git a/samples/Sample_23_TemplateBlock.php b/samples/Sample_23_TemplateBlock.php index 8ee8fc6d01..2b7e9f6856 100644 --- a/samples/Sample_23_TemplateBlock.php +++ b/samples/Sample_23_TemplateBlock.php @@ -1,22 +1,18 @@ loadTemplate('resources/Sample_23_TemplateBlock.docx'); +// Template processor instance creation +echo date('H:i:s') , ' Creating new TemplateProcessor instance...' , EOL; +$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_23_TemplateBlock.docx'); // Will clone everything between ${tag} and ${/tag}, the number of times. By default, 1. -$document->cloneBlock('CLONEME', 3); +$templateProcessor->cloneBlock('CLONEME', 3); // Everything between ${tag} and ${/tag}, will be deleted/erased. -$document->deleteBlock('DELETEME'); +$templateProcessor->deleteBlock('DELETEME'); -$name = 'Sample_23_TemplateBlock.docx'; -echo date('H:i:s'), " Write to Word2007 format", EOL; -$document->saveAs($name); -rename($name, "results/{$name}"); +echo date('H:i:s'), ' Saving the result document...', EOL; +$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx'); echo getEndingNotes(array('Word2007' => 'docx')); if (!CLI) { diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 84e5ebc778..aba1ee3863 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -264,14 +264,16 @@ public function setDefaultParagraphStyle($styles) /** * Load template by filename * + * @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead. + * * @param string $filename Fully qualified filename. - * @return Template + * @return TemplateProcessor * @throws \PhpOffice\PhpWord\Exception\Exception */ public function loadTemplate($filename) { if (file_exists($filename)) { - return new Template($filename); + return new TemplateProcessor($filename); } else { throw new Exception("Template file {$filename} not found."); } diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index c8f8802605..dbbb54f1f4 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -17,449 +17,10 @@ namespace PhpOffice\PhpWord; -use PhpOffice\PhpWord\Exception\CopyFileException; -use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; -use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Shared\String; -use PhpOffice\PhpWord\Shared\ZipArchive; - /** - * Template + * @deprecated 0.12.0 Use \PhpOffice\PhpWord\TemplateProcessor instead. */ -class Template +class Template extends TemplateProcessor { - /** - * ZipArchive object. - * - * @var mixed - */ - private $zipClass; - - /** - * Temporary file name. - * - * @var string - */ - private $tempFileName; - - /** - * Document XML. - * - * @var string - */ - private $documentXML; - - /** - * Document header XML. - * - * @var string[] - */ - private $headerXMLs = array(); - - /** - * Create a new Template Object. - * - * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception. - * - * @param string $fileName The fully qualified template file name. - * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException - * @throws \PhpOffice\PhpWord\Exception\CopyFileException - */ - public function __construct($fileName) - { - $this->tempFileName = tempnam(Settings::getTempDir(), 'PhpWord'); - if (false === $this->tempFileName) { - throw new CreateTemporaryFileException(); - } - - // Copy the source File to the temp File - if (false === copy($fileName, $this->tempFileName)) { - throw new CopyFileException($fileName, $this->tempFileName); - } - - $this->zipClass = new ZipArchive(); - $this->zipClass->open($this->tempFileName); - - // Find and load headers and footers - $index = 1; - while ($this->zipClass->locateName($this->getHeaderName($index)) !== false) { - $this->headerXMLs[$index] = $this->zipClass->getFromName($this->getHeaderName($index)); - $index++; - } - - $index = 1; - while ($this->zipClass->locateName($this->getFooterName($index)) !== false) { - $this->footerXMLs[$index] = $this->zipClass->getFromName($this->getFooterName($index)); - $index++; - } - - $this->documentXML = $this->zipClass->getFromName('word/document.xml'); - } - - /** - * Document footer XML. - * - * @var string[] - */ - private $footerXMLs = array(); - - /** - * Applies XSL style sheet to template's parts. - * - * @param \DOMDocument $xslDOMDocument - * @param array $xslOptions - * @param string $xslOptionsURI - * @return void - * @throws \PhpOffice\PhpWord\Exception\Exception - */ - public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') - { - $processor = new \XSLTProcessor(); - - $processor->importStylesheet($xslDOMDocument); - - if (false === $processor->setParameter($xslOptionsURI, $xslOptions)) { - throw new Exception('Could not set values for the given XSL style sheet parameters.'); - } - - $xmlDOMDocument = new \DOMDocument(); - if (false === $xmlDOMDocument->loadXML($this->documentXML)) { - throw new Exception('Could not load XML from the given template.'); - } - - $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if (false === $xmlTransformed) { - throw new Exception('Could not transform the given XML document.'); - } - - $this->documentXML = $xmlTransformed; - } - - /** - * Set a Template value. - * - * @param mixed $search - * @param mixed $replace - * @param integer $limit - * @return void - */ - public function setValue($search, $replace, $limit = -1) - { - foreach ($this->headerXMLs as $index => $headerXML) { - $this->headerXMLs[$index] = $this->setValueForPart($this->headerXMLs[$index], $search, $replace, $limit); - } - - $this->documentXML = $this->setValueForPart($this->documentXML, $search, $replace, $limit); - - foreach ($this->footerXMLs as $index => $headerXML) { - $this->footerXMLs[$index] = $this->setValueForPart($this->footerXMLs[$index], $search, $replace, $limit); - } - } - - /** - * Returns array of all variables in template. - * - * @return string[] - */ - public function getVariables() - { - $variables = $this->getVariablesForPart($this->documentXML); - - foreach ($this->headerXMLs as $headerXML) { - $variables = array_merge($variables, $this->getVariablesForPart($headerXML)); - } - - foreach ($this->footerXMLs as $footerXML) { - $variables = array_merge($variables, $this->getVariablesForPart($footerXML)); - } - - return array_unique($variables); - } - - /** - * Clone a table row in a template document. - * - * @param string $search - * @param integer $numberOfClones - * @return void - * @throws \PhpOffice\PhpWord\Exception\Exception - */ - public function cloneRow($search, $numberOfClones) - { - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - $tagPos = strpos($this->documentXML, $search); - if (!$tagPos) { - throw new Exception("Can not clone row, template variable not found or variable contains markup."); - } - - $rowStart = $this->findRowStart($tagPos); - $rowEnd = $this->findRowEnd($tagPos); - $xmlRow = $this->getSlice($rowStart, $rowEnd); - - // Check if there's a cell spanning multiple rows. - if (preg_match('##', $xmlRow)) { - // $extraRowStart = $rowEnd; - $extraRowEnd = $rowEnd; - while (true) { - $extraRowStart = $this->findRowStart($extraRowEnd + 1); - $extraRowEnd = $this->findRowEnd($extraRowEnd + 1); - - // If extraRowEnd is lower then 7, there was no next row found. - if ($extraRowEnd < 7) { - break; - } - - // 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)) { - break; - } - // This row was a spanned row, update $rowEnd and search for the next row. - $rowEnd = $extraRowEnd; - } - $xmlRow = $this->getSlice($rowStart, $rowEnd); - } - - $result = $this->getSlice(0, $rowStart); - for ($i = 1; $i <= $numberOfClones; $i++) { - $result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlRow); - } - $result .= $this->getSlice($rowEnd); - - $this->documentXML = $result; - } - - /** - * Clone a block. - * - * @param string $blockname - * @param integer $clones - * @param boolean $replace - * @return string|null - */ - public function cloneBlock($blockname, $clones = 1, $replace = true) - { - $xmlBlock = null; - preg_match( - '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', - $this->documentXML, - $matches - ); - - if (isset($matches[3])) { - $xmlBlock = $matches[3]; - $cloned = array(); - for ($i = 1; $i <= $clones; $i++) { - $cloned[] = $xmlBlock; - } - - if ($replace) { - $this->documentXML = str_replace( - $matches[2] . $matches[3] . $matches[4], - implode('', $cloned), - $this->documentXML - ); - } - } - - return $xmlBlock; - } - - /** - * Replace a block. - * - * @param string $blockname - * @param string $replacement - * @return void - */ - public function replaceBlock($blockname, $replacement) - { - 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 - ); - } - } - - /** - * Delete a block of text. - * - * @param string $blockname - * @return void - */ - public function deleteBlock($blockname) - { - $this->replaceBlock($blockname, ''); - } - - /** - * Save XML to temporary file. - * - * @return string - * @throws \PhpOffice\PhpWord\Exception\Exception - */ - public function save() - { - foreach ($this->headerXMLs as $index => $headerXML) { - $this->zipClass->addFromString($this->getHeaderName($index), $this->headerXMLs[$index]); - } - - $this->zipClass->addFromString('word/document.xml', $this->documentXML); - - foreach ($this->footerXMLs as $index => $headerXML) { - $this->zipClass->addFromString($this->getFooterName($index), $this->footerXMLs[$index]); - } - - // Close zip file - if (false === $this->zipClass->close()) { - throw new Exception('Could not close zip file.'); - } - - return $this->tempFileName; - } - - /** - * Save XML to defined name. - * - * @since 0.8.0 - * - * @param string $fileName - * @return void - */ - public function saveAs($fileName) - { - $tempFileName = $this->save(); - - if (file_exists($fileName)) { - unlink($fileName); - } - - rename($tempFileName, $fileName); - } - - /** - * Find and replace placeholders in the given XML section. - * - * @param string $documentPartXML - * @param string $search - * @param string $replace - * @param integer $limit - * @return string - */ - protected function setValueForPart($documentPartXML, $search, $replace, $limit) - { - $pattern = '|\$\{([^\}]+)\}|U'; - preg_match_all($pattern, $documentPartXML, $matches); - foreach ($matches[0] as $value) { - $valueCleaned = preg_replace('/<[^>]+>/', '', $value); - $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned); - $documentPartXML = str_replace($value, $valueCleaned, $documentPartXML); - } - - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - if (!String::isUTF8($replace)) { - $replace = utf8_encode($replace); - } - $replace = htmlspecialchars($replace); - - $regExpDelim = '/'; - $escapedSearch = preg_quote($search, $regExpDelim); - return preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u", $replace, $documentPartXML, $limit); - } - - /** - * Find all variables in $documentPartXML. - * - * @param string $documentPartXML - * @return string[] - */ - protected function getVariablesForPart($documentPartXML) - { - preg_match_all('/\$\{(.*?)}/i', $documentPartXML, $matches); - - return $matches[1]; - } - - /** - * Get the name of the footer file for $index. - * - * @param integer $index - * @return string - */ - private function getFooterName($index) - { - return sprintf('word/footer%d.xml', $index); - } - - /** - * Get the name of the header file for $index. - * - * @param integer $index - * @return string - */ - private function getHeaderName($index) - { - return sprintf('word/header%d.xml', $index); - } - - /** - * Find the start position of the nearest table row before $offset. - * - * @param integer $offset - * @return integer - * @throws \PhpOffice\PhpWord\Exception\Exception - */ - private function findRowStart($offset) - { - $rowStart = strrpos($this->documentXML, "documentXML) - $offset) * -1)); - if (!$rowStart) { - $rowStart = strrpos($this->documentXML, "", ((strlen($this->documentXML) - $offset) * -1)); - } - if (!$rowStart) { - throw new Exception("Can not find the start position of the row to clone."); - } - return $rowStart; - } - - /** - * Find the end position of the nearest table row after $offset. - * - * @param integer $offset - * @return integer - */ - private function findRowEnd($offset) - { - $rowEnd = strpos($this->documentXML, "", $offset) + 7; - return $rowEnd; - } - /** - * Get a slice of a string. - * - * @param integer $startPosition - * @param integer $endPosition - * @return string - */ - private function getSlice($startPosition, $endPosition = 0) - { - if (!$endPosition) { - $endPosition = strlen($this->documentXML); - } - return substr($this->documentXML, $startPosition, ($endPosition - $startPosition)); - } -} +} \ No newline at end of file diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php new file mode 100644 index 0000000000..1de520f67a --- /dev/null +++ b/src/PhpWord/TemplateProcessor.php @@ -0,0 +1,456 @@ +temporaryDocumentFilename = tempnam(Settings::getTempDir(), 'PhpWord'); + if (false === $this->temporaryDocumentFilename) { + throw new CreateTemporaryFileException(); + } + + // Template file cloning + if (false === copy($documentTemplate, $this->temporaryDocumentFilename)) { + throw new CopyFileException($documentTemplate, $this->temporaryDocumentFilename); + } + + // Temporary document content extraction + $this->zipClass = new ZipArchive(); + $this->zipClass->open($this->temporaryDocumentFilename); + $index = 1; + while ($this->zipClass->locateName($this->getHeaderName($index)) !== false) { + $this->temporaryDocumentHeaders[$index] = $this->zipClass->getFromName($this->getHeaderName($index)); + $index++; + } + $index = 1; + while ($this->zipClass->locateName($this->getFooterName($index)) !== false) { + $this->temporaryDocumentFooters[$index] = $this->zipClass->getFromName($this->getFooterName($index)); + $index++; + } + $this->temporaryDocumentMainPart = $this->zipClass->getFromName('word/document.xml'); + } + + /** + * Applies XSL style sheet to template's parts. + * + * @param \DOMDocument $xslDOMDocument + * @param array $xslOptions + * @param string $xslOptionsURI + * @return void + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') + { + $xsltProcessor = new \XSLTProcessor(); + + $xsltProcessor->importStylesheet($xslDOMDocument); + + if (false === $xsltProcessor->setParameter($xslOptionsURI, $xslOptions)) { + throw new Exception('Could not set values for the given XSL style sheet parameters.'); + } + + $xmlDOMDocument = new \DOMDocument(); + if (false === $xmlDOMDocument->loadXML($this->temporaryDocumentMainPart)) { + throw new Exception('Could not load XML from the given template.'); + } + + $xmlTransformed = $xsltProcessor->transformToXml($xmlDOMDocument); + if (false === $xmlTransformed) { + throw new Exception('Could not transform the given XML document.'); + } + + $this->temporaryDocumentMainPart = $xmlTransformed; + } + + /** + * @param mixed $search + * @param mixed $replace + * @param integer $limit + * @return void + */ + public function setValue($search, $replace, $limit = -1) + { + foreach ($this->temporaryDocumentHeaders as $index => $headerXML) { + $this->temporaryDocumentHeaders[$index] = $this->setValueForPart($this->temporaryDocumentHeaders[$index], $search, $replace, $limit); + } + + $this->temporaryDocumentMainPart = $this->setValueForPart($this->temporaryDocumentMainPart, $search, $replace, $limit); + + foreach ($this->temporaryDocumentFooters as $index => $headerXML) { + $this->temporaryDocumentFooters[$index] = $this->setValueForPart($this->temporaryDocumentFooters[$index], $search, $replace, $limit); + } + } + + /** + * Returns array of all variables in template. + * + * @return string[] + */ + public function getVariables() + { + $variables = $this->getVariablesForPart($this->temporaryDocumentMainPart); + + foreach ($this->temporaryDocumentHeaders as $headerXML) { + $variables = array_merge($variables, $this->getVariablesForPart($headerXML)); + } + + foreach ($this->temporaryDocumentFooters as $footerXML) { + $variables = array_merge($variables, $this->getVariablesForPart($footerXML)); + } + + return array_unique($variables); + } + + /** + * Clone a table row in a template document. + * + * @param string $search + * @param integer $numberOfClones + * @return void + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + public function cloneRow($search, $numberOfClones) + { + if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; + } + + $tagPos = strpos($this->temporaryDocumentMainPart, $search); + if (!$tagPos) { + throw new Exception("Can not clone row, template variable not found or variable contains markup."); + } + + $rowStart = $this->findRowStart($tagPos); + $rowEnd = $this->findRowEnd($tagPos); + $xmlRow = $this->getSlice($rowStart, $rowEnd); + + // Check if there's a cell spanning multiple rows. + if (preg_match('##', $xmlRow)) { + // $extraRowStart = $rowEnd; + $extraRowEnd = $rowEnd; + while (true) { + $extraRowStart = $this->findRowStart($extraRowEnd + 1); + $extraRowEnd = $this->findRowEnd($extraRowEnd + 1); + + // If extraRowEnd is lower then 7, there was no next row found. + if ($extraRowEnd < 7) { + break; + } + + // 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)) { + break; + } + // This row was a spanned row, update $rowEnd and search for the next row. + $rowEnd = $extraRowEnd; + } + $xmlRow = $this->getSlice($rowStart, $rowEnd); + } + + $result = $this->getSlice(0, $rowStart); + for ($i = 1; $i <= $numberOfClones; $i++) { + $result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlRow); + } + $result .= $this->getSlice($rowEnd); + + $this->temporaryDocumentMainPart = $result; + } + + /** + * Clone a block. + * + * @param string $blockname + * @param integer $clones + * @param boolean $replace + * @return string|null + */ + public function cloneBlock($blockname, $clones = 1, $replace = true) + { + $xmlBlock = null; + preg_match( + '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + $this->temporaryDocumentMainPart, + $matches + ); + + if (isset($matches[3])) { + $xmlBlock = $matches[3]; + $cloned = array(); + for ($i = 1; $i <= $clones; $i++) { + $cloned[] = $xmlBlock; + } + + if ($replace) { + $this->temporaryDocumentMainPart = str_replace( + $matches[2] . $matches[3] . $matches[4], + implode('', $cloned), + $this->temporaryDocumentMainPart + ); + } + } + + return $xmlBlock; + } + + /** + * Replace a block. + * + * @param string $blockname + * @param string $replacement + * @return void + */ + public function replaceBlock($blockname, $replacement) + { + preg_match( + '/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is', + $this->temporaryDocumentMainPart, + $matches + ); + + if (isset($matches[3])) { + $this->temporaryDocumentMainPart = str_replace( + $matches[2] . $matches[3] . $matches[4], + $replacement, + $this->temporaryDocumentMainPart + ); + } + } + + /** + * Delete a block of text. + * + * @param string $blockname + * @return void + */ + public function deleteBlock($blockname) + { + $this->replaceBlock($blockname, ''); + } + + /** + * Saves the result document. + * + * @return string + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + public function save() + { + foreach ($this->temporaryDocumentHeaders as $index => $headerXML) { + $this->zipClass->addFromString($this->getHeaderName($index), $this->temporaryDocumentHeaders[$index]); + } + + $this->zipClass->addFromString('word/document.xml', $this->temporaryDocumentMainPart); + + foreach ($this->temporaryDocumentFooters as $index => $headerXML) { + $this->zipClass->addFromString($this->getFooterName($index), $this->temporaryDocumentFooters[$index]); + } + + // Close zip file + if (false === $this->zipClass->close()) { + throw new Exception('Could not close zip file.'); + } + + return $this->temporaryDocumentFilename; + } + + /** + * Saves the result document to the user defined file. + * + * @since 0.8.0 + * + * @param string $fileName + * @return void + */ + public function saveAs($fileName) + { + $tempFileName = $this->save(); + + if (file_exists($fileName)) { + unlink($fileName); + } + + rename($tempFileName, $fileName); + } + + /** + * Find and replace placeholders in the given XML section. + * + * @param string $documentPartXML + * @param string $search + * @param string $replace + * @param integer $limit + * @return string + */ + protected function setValueForPart($documentPartXML, $search, $replace, $limit) + { + $pattern = '|\$\{([^\}]+)\}|U'; + preg_match_all($pattern, $documentPartXML, $matches); + foreach ($matches[0] as $value) { + $valueCleaned = preg_replace('/<[^>]+>/', '', $value); + $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned); + $documentPartXML = str_replace($value, $valueCleaned, $documentPartXML); + } + + if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { + $search = '${' . $search . '}'; + } + + if (!String::isUTF8($replace)) { + $replace = utf8_encode($replace); + } + $replace = htmlspecialchars($replace); + + $regExpDelim = '/'; + $escapedSearch = preg_quote($search, $regExpDelim); + return preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u", $replace, $documentPartXML, $limit); + } + + /** + * Find all variables in $documentPartXML. + * + * @param string $documentPartXML + * @return string[] + */ + protected function getVariablesForPart($documentPartXML) + { + preg_match_all('/\$\{(.*?)}/i', $documentPartXML, $matches); + + return $matches[1]; + } + + /** + * Get the name of the footer file for $index. + * + * @param integer $index + * @return string + */ + private function getFooterName($index) + { + return sprintf('word/footer%d.xml', $index); + } + + /** + * Get the name of the header file for $index. + * + * @param integer $index + * @return string + */ + private function getHeaderName($index) + { + return sprintf('word/header%d.xml', $index); + } + + /** + * Find the start position of the nearest table row before $offset. + * + * @param integer $offset + * @return integer + * @throws \PhpOffice\PhpWord\Exception\Exception + */ + private function findRowStart($offset) + { + $rowStart = strrpos($this->temporaryDocumentMainPart, 'temporaryDocumentMainPart) - $offset) * -1)); + + if (!$rowStart) { + $rowStart = strrpos($this->temporaryDocumentMainPart, '', ((strlen($this->temporaryDocumentMainPart) - $offset) * -1)); + } + if (!$rowStart) { + throw new Exception('Can not find the start position of the row to clone.'); + } + + return $rowStart; + } + + /** + * Find the end position of the nearest table row after $offset. + * + * @param integer $offset + * @return integer + */ + private function findRowEnd($offset) + { + return strpos($this->temporaryDocumentMainPart, '', $offset) + 7; + } + + /** + * Get a slice of a string. + * + * @param integer $startPosition + * @param integer $endPosition + * @return string + */ + private function getSlice($startPosition, $endPosition = 0) + { + if (!$endPosition) { + $endPosition = strlen($this->temporaryDocumentMainPart); + } + + return substr($this->temporaryDocumentMainPart, $startPosition, ($endPosition - $startPosition)); + } +} diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 756f848f49..85c6a7f291 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -119,6 +119,8 @@ public function testAddTitleStyle() /** * Test load template + * + * @deprecated 0.12.0 */ public function testLoadTemplate() { @@ -126,7 +128,7 @@ public function testLoadTemplate() $phpWord = new PhpWord(); $this->assertInstanceOf( - 'PhpOffice\\PhpWord\\Template', + 'PhpOffice\\PhpWord\\TemplateProcessor', $phpWord->loadTemplate($templateFqfn) ); } @@ -134,6 +136,8 @@ public function testLoadTemplate() /** * Test load template exception * + * @deprecated 0.12.0 + * * @expectedException \PhpOffice\PhpWord\Exception\Exception */ public function testLoadTemplateException() diff --git a/tests/PhpWord/Tests/TemplateTest.php b/tests/PhpWord/Tests/TemplateProcessorTest.php similarity index 64% rename from tests/PhpWord/Tests/TemplateTest.php rename to tests/PhpWord/Tests/TemplateProcessorTest.php index 57ee229e62..04d1e77715 100644 --- a/tests/PhpWord/Tests/TemplateTest.php +++ b/tests/PhpWord/Tests/TemplateProcessorTest.php @@ -17,35 +17,33 @@ namespace PhpOffice\PhpWord\Tests; -use PhpOffice\PhpWord\Template; +use PhpOffice\PhpWord\TemplateProcessor; /** - * Test class for PhpOffice\PhpWord\Template - * - * @covers \PhpOffice\PhpWord\Template - * @coversDefaultClass \PhpOffice\PhpWord\Template + * @covers \PhpOffice\PhpWord\TemplateProcessor + * @coversDefaultClass \PhpOffice\PhpWord\TemplateProcessor * @runTestsInSeparateProcesses */ -final class TemplateTest extends \PHPUnit_Framework_TestCase +final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase { /** - * Template can be saved in temporary location + * Template can be saved in temporary location. * * @covers ::save * @test */ final public function testTemplateCanBeSavedInTemporaryLocation() { - $templateFqfn = __DIR__ . "/_files/templates/with_table_macros.docx"; + $templateFqfn = __DIR__ . '/_files/templates/with_table_macros.docx'; - $document = new Template($templateFqfn); + $templateProcessor = new TemplateProcessor($templateFqfn); $xslDOMDocument = new \DOMDocument(); $xslDOMDocument->load(__DIR__ . "/_files/xsl/remove_tables_by_needle.xsl"); foreach (array('${employee.', '${scoreboard.') as $needle) { - $document->applyXslStyleSheet($xslDOMDocument, array('needle' => $needle)); + $templateProcessor->applyXslStyleSheet($xslDOMDocument, array('needle' => $needle)); } - $documentFqfn = $document->save(); + $documentFqfn = $templateProcessor->save(); $this->assertNotEmpty($documentFqfn, 'FQFN of the saved document is empty.'); $this->assertFileExists($documentFqfn, "The saved document \"{$documentFqfn}\" doesn't exist."); @@ -70,9 +68,10 @@ final public function testTemplateCanBeSavedInTemporaryLocation() } /** - * XSL stylesheet can be applied + * XSL stylesheet can be applied. * * @param string $actualDocumentFqfn + * @throws \Exception * @covers ::applyXslStyleSheet * @depends testTemplateCanBeSavedInTemporaryLocation * @test @@ -99,7 +98,7 @@ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) } /** - * XSL stylesheet cannot be applied on failure in setting parameter value + * XSL stylesheet cannot be applied on failure in setting parameter value. * * @covers ::applyXslStyleSheet * @expectedException \PhpOffice\PhpWord\Exception\Exception @@ -108,20 +107,20 @@ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { - $template = new Template(__DIR__ . "/_files/templates/blank.docx"); + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/blank.docx'); $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load(__DIR__ . "/_files/xsl/passthrough.xsl"); + $xslDOMDocument->load(__DIR__ . '/_files/xsl/passthrough.xsl'); /* * We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure. * This warning fails the test. */ - @$template->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); + @$templateProcessor->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); } /** - * XSL stylesheet can be applied on failure of loading XML from template + * XSL stylesheet can be applied on failure of loading XML from template. * * @covers ::applyXslStyleSheet * @expectedException \PhpOffice\PhpWord\Exception\Exception @@ -130,83 +129,88 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { - $template = new Template(__DIR__ . "/_files/templates/corrupted_main_document_part.docx"); + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/corrupted_main_document_part.docx'); $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load(__DIR__ . "/_files/xsl/passthrough.xsl"); + $xslDOMDocument->load(__DIR__ . '/_files/xsl/passthrough.xsl'); /* * We have to use error control below, because \DOMDocument::loadXML omits warning on failure. * This warning fails the test. */ - @$template->applyXslStyleSheet($xslDOMDocument); + @$templateProcessor->applyXslStyleSheet($xslDOMDocument); } /** - * Get variables and clone row + * @civers ::setValue + * @covers ::cloneRow + * @covers ::saveAs + * @test */ public function testCloneRow() { - $template = __DIR__ . "/_files/templates/clone-merge.docx"; - $expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation'); - $docName = 'clone-test-result.docx'; + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/clone-merge.docx'); - $document = new Template($template); - $actualVar = $document->getVariables(); - $document->setValue('tableHeader', utf8_decode('ééé')); - $document->cloneRow('userId', 1); - $document->setValue('userId#1', 'Test'); - $document->saveAs($docName); + $this->assertEquals( + array('tableHeader', 'userId', 'userName', 'userLocation'), + $templateProcessor->getVariables() + ); + + $docName = 'clone-test-result.docx'; + $templateProcessor->setValue('tableHeader', utf8_decode('ééé')); + $templateProcessor->cloneRow('userId', 1); + $templateProcessor->setValue('userId#1', 'Test'); + $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName); - - $this->assertEquals($expectedVar, $actualVar); $this->assertTrue($docFound); } /** - * Replace variables in header and footer + * @covers ::setValue + * @covers ::saveAs + * @test */ public function testVariablesCanBeReplacedInHeaderAndFooter() { - $template = __DIR__ . "/_files/templates/header-footer.docx"; - $expectedVar = array('documentContent', 'headerValue', 'footerValue'); - $docName = 'header-footer-test-result.docx'; + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/header-footer.docx'); + + $this->assertEquals( + array('documentContent', 'headerValue', 'footerValue'), + $templateProcessor->getVariables() + ); - $document = new Template($template); - $actualVar = $document->getVariables(); - $document->setValue('headerValue', 'Header Value'); - $document->setValue('documentContent', 'Document text.'); - $document->setValue('footerValue', 'Footer Value'); - $document->saveAs($docName); + $docName = 'header-footer-test-result.docx'; + $templateProcessor->setValue('headerValue', 'Header Value'); + $templateProcessor->setValue('documentContent', 'Document text.'); + $templateProcessor->setValue('footerValue', 'Footer Value'); + $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName); - - $this->assertEquals($expectedVar, $actualVar); $this->assertTrue($docFound); - } /** - * Clone and delete block + * @covers ::cloneBlock + * @covers ::deleteBlock + * @covers ::saveAs + * @test */ public function testCloneDeleteBlock() { - $template = __DIR__ . "/_files/templates/clone-delete-block.docx"; - $expectedVar = array('DELETEME', '/DELETEME', 'CLONEME', '/CLONEME'); - $docName = 'clone-delete-block-result.docx'; - - $document = new Template($template); - $actualVar = $document->getVariables(); + $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/clone-delete-block.docx'); - $document->cloneBlock('CLONEME', 3); - $document->deleteBlock('DELETEME'); + $this->assertEquals( + array('DELETEME', '/DELETEME', 'CLONEME', '/CLONEME'), + $templateProcessor->getVariables() + ); - $document->saveAs($docName); + $docName = 'clone-delete-block-result.docx'; + $templateProcessor->cloneBlock('CLONEME', 3); + $templateProcessor->deleteBlock('DELETEME'); + $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName); - - $this->assertEquals($expectedVar, $actualVar); $this->assertTrue($docFound); } } From 0151a21c0f011c6a409da2392aedb741863ebc9a Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 16 Aug 2014 13:25:38 +0200 Subject: [PATCH 103/174] #23 : Implement Word97 aka MsDoc Reader (Documentation ) --- docs/intro.rst | 110 ++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index 03821c9113..acb7011ec2 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -121,61 +121,61 @@ Writers Readers ~~~~~~~ -+---------------------------+----------------------+--------+-------+-------+-------+ -| 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 | | | | | -+---------------------------+----------------------+--------+-------+-------+-------+ ++---------------------------+----------------------+--------+-------+-------+-------+-------+ +| Features | | DOCX | DOC | 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 ------------ From d66e8559e6248eb26ea4942a244993731da9c5ce Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 16 Aug 2014 13:28:27 +0200 Subject: [PATCH 104/174] #23 : Implement Word97 aka MsDoc Reader (Documentation ) --- docs/intro.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/intro.rst b/docs/intro.rst index acb7011ec2..a7dca9476f 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -130,7 +130,7 @@ Readers +---------------------------+----------------------+--------+-------+-------+-------+-------+ | **Element Type** | Text | ✓ | ✓ | ✓ | ✓ | ✓ | +---------------------------+----------------------+--------+-------+-------+-------+-------+ -| | Text Run | ✓ | ✓ | | | | +| | Text Run | ✓ | | | | | +---------------------------+----------------------+--------+-------+-------+-------+-------+ | | Title | ✓ | | ✓ | | | +---------------------------+----------------------+--------+-------+-------+-------+-------+ From bf0136c15680266bc31bcb662809843162f7b11d Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 16 Aug 2014 15:46:38 +0400 Subject: [PATCH 105/174] https://github.com/PHPOffice/PHPWord/issues/216 --- src/PhpWord/Template.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index dbbb54f1f4..f6ad790eab 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -22,5 +22,4 @@ */ class Template extends TemplateProcessor { - -} \ No newline at end of file +} From 62c799172ecb3f36e2f858b1db61c90ef43c5264 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Mon, 18 Aug 2014 20:36:13 +0200 Subject: [PATCH 106/174] Update CONTRIBUTING.md misspelling --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 34985610b0..0b0f948f74 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to PHPWord -PHPWord is build by the crowd and for the crowd. Every contributions are welcomed; either by [submitting](https://github.com/PHPOffice/PHPWord/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/PHPOffice/PHPWord/pulls) a pull. +PHPWord is built by the crowd and for the crowd. Every contribution is welcome; either by [submitting](https://github.com/PHPOffice/PHPWord/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/PHPOffice/PHPWord/pulls) a pull. We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get a life merrily. Thus, below are some guidelines that we expect to be followed by each contributor. @@ -11,4 +11,4 @@ We want to create a high quality document writer and reader library that people That's it. Thank you for your interest in PHPWord, and welcome! -May the Force be with you. \ No newline at end of file +May the Force be with you. From 9757fbb033c0303f1e437d56d543947d5478bd27 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 23 Aug 2014 20:19:48 +0400 Subject: [PATCH 107/174] [FIXED] https://github.com/PHPOffice/PHPWord/issues/340 --- src/PhpWord/IOFactory.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index f3808f72c3..ab46b87ebc 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -10,12 +10,9 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Writer\WriterInterface; use PhpOffice\PhpWord\Reader\ReaderInterface; +use PhpOffice\PhpWord\Writer\WriterInterface; -/** - * IO factory - */ abstract class IOFactory { /** @@ -24,15 +21,16 @@ abstract class IOFactory * @param PhpWord $phpWord * @param string $name * @return WriterInterface - * @throws Exception + * @throws \PhpOffice\PhpWord\Exception\Exception */ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') { - if ($name !== 'WriterInterface' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') { + if ($name !== 'WriterInterface' && !in_array($name, array('ODText', 'RTF', 'Word2007', 'HTML', 'PDF'), true)) { throw new Exception("\"{$name}\" is not a valid writer."); } $fqName = "PhpOffice\\PhpWord\\Writer\\{$name}"; + return new $fqName($phpWord); } From d11b0deaf9778a979b71b822dabab2d103bf8fc0 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 23 Aug 2014 20:25:41 +0400 Subject: [PATCH 108/174] [FIXED] https://github.com/PHPOffice/PHPWord/issues/340 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f8edfdb2a..5593d20b51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Table inside vertical border does not rendered properly - @ivanlanin GH-280 - `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 - Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 +- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 ### Deprecated From 9b3b1aa7a0664ff90232ed1d69a17c326526de6e Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 31 Aug 2014 00:06:00 +0200 Subject: [PATCH 109/174] Set the right method name for addShape() in PHPDoc @method for AbstractContainer. --- 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 9b5989061c..6a26c15fa6 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -41,7 +41,7 @@ * @method TextBox addTextBox(mixed $style = null) * @method Field addField(string $type = null, array $properties = array(), array $options = array()) * @method Line addLine(mixed $lineStyle = null) - * @method Shape addObject(string $type, mixed $style = null) + * @method Shape addShape(string $type, mixed $style = null) * @method Chart addChart(string $type, array $categories, array $values, array $style = null) * @method FormField addFormField(string $type, mixed $fStyle = null, mixed $pStyle = null) * @method SDT addSDT(string $type) From 42955f17ddbe2c7bee13d1cae2b141e495faf564 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 7 Sep 2014 18:19:10 +0400 Subject: [PATCH 110/174] Merge pull request #302 from basjan/absolute-positioning --- CHANGELOG.md | 1 + src/PhpWord/Style/Frame.php | 58 ++++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5593d20b51..b264497829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Paragraph: Support for paragraph with borders - @ivanlanin GH-294 - Word2007 Writer : Support for RTL - @Progi1984 GH-331 - MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287 +- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302 ### Bugfixes diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index 9a7997e220..579a1c9558 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -36,7 +36,7 @@ class Frame extends AbstractStyle const UNIT_PX = 'px'; // Mostly for images /** - * Position type, relative/absolute + * General positioning options. * * @const string */ @@ -338,7 +338,10 @@ public function getPos() */ public function setPos($value) { - $enum = array(self::POS_RELATIVE, self::POS_ABSOLUTE); + $enum = array( + self::POS_ABSOLUTE, + self::POS_RELATIVE, + ); $this->pos = $this->setEnumVal($value, $enum, $this->pos); return $this; @@ -357,12 +360,21 @@ public function getHPos() /** * Set horizontal position * + * @since 0.12.0 "absolute" option is available. + * * @param string $value * @return self */ public function setHPos($value) { - $enum = array(self::POS_LEFT, self::POS_CENTER, self::POS_RIGHT, self::POS_INSIDE, self::POS_OUTSIDE, self::POS_ABSOLUTE); + $enum = array( + self::POS_ABSOLUTE, + self::POS_LEFT, + self::POS_CENTER, + self::POS_RIGHT, + self::POS_INSIDE, + self::POS_OUTSIDE, + ); $this->hPos = $this->setEnumVal($value, $enum, $this->hPos); return $this; @@ -381,12 +393,21 @@ public function getVPos() /** * Set vertical position * + * @since 0.12.0 "absolute" option is available. + * * @param string $value * @return self */ public function setVPos($value) { - $enum = array(self::POS_TOP, self::POS_CENTER, self::POS_BOTTOM, self::POS_INSIDE, self::POS_OUTSIDE, self::POS_ABSOLUTE); + $enum = array( + self::POS_ABSOLUTE, + self::POS_TOP, + self::POS_CENTER, + self::POS_BOTTOM, + self::POS_INSIDE, + self::POS_OUTSIDE, + ); $this->vPos = $this->setEnumVal($value, $enum, $this->vPos); return $this; @@ -411,8 +432,14 @@ public function getHPosRelTo() public function setHPosRelTo($value) { $enum = array( - self::POS_RELTO_MARGIN, self::POS_RELTO_PAGE, self::POS_RELTO_COLUMN, self::POS_RELTO_CHAR, - self::POS_RELTO_LMARGIN, self::POS_RELTO_RMARGIN, self::POS_RELTO_IMARGIN, self::POS_RELTO_OMARGIN, + self::POS_RELTO_MARGIN, + self::POS_RELTO_PAGE, + self::POS_RELTO_COLUMN, + self::POS_RELTO_CHAR, + self::POS_RELTO_LMARGIN, + self::POS_RELTO_RMARGIN, + self::POS_RELTO_IMARGIN, + self::POS_RELTO_OMARGIN, ); $this->hPosRelTo = $this->setEnumVal($value, $enum, $this->hPosRelTo); @@ -438,8 +465,14 @@ public function getVPosRelTo() public function setVPosRelTo($value) { $enum = array( - self::POS_RELTO_MARGIN, self::POS_RELTO_PAGE, self::POS_RELTO_TEXT, self::POS_RELTO_LINE, - self::POS_RELTO_TMARGIN, self::POS_RELTO_BMARGIN, self::POS_RELTO_IMARGIN, self::POS_RELTO_OMARGIN, + self::POS_RELTO_MARGIN, + self::POS_RELTO_PAGE, + self::POS_RELTO_TEXT, + self::POS_RELTO_LINE, + self::POS_RELTO_TMARGIN, + self::POS_RELTO_BMARGIN, + self::POS_RELTO_IMARGIN, + self::POS_RELTO_OMARGIN, ); $this->vPosRelTo = $this->setEnumVal($value, $enum, $this->vPosRelTo); @@ -465,8 +498,13 @@ public function getWrap() public function setWrap($value) { $enum = array( - self::WRAP_INLINE, self::WRAP_SQUARE, self::WRAP_TIGHT, self::WRAP_THROUGH, - self::WRAP_TOPBOTTOM, self::WRAP_BEHIND, self::WRAP_INFRONT + self::WRAP_INLINE, + self::WRAP_SQUARE, + self::WRAP_TIGHT, + self::WRAP_THROUGH, + self::WRAP_TOPBOTTOM, + self::WRAP_BEHIND, + self::WRAP_INFRONT ); $this->wrap = $this->setEnumVal($value, $enum, $this->wrap); From 5811aac2724f5983576d7d3fce4a4b44d0cae6e2 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 7 Sep 2014 18:21:24 +0400 Subject: [PATCH 111/174] Merge pull request #302 from basjan/absolute-positioning --- src/PhpWord/Style/Frame.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index 579a1c9558..5fef5f0182 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -504,7 +504,7 @@ public function setWrap($value) self::WRAP_THROUGH, self::WRAP_TOPBOTTOM, self::WRAP_BEHIND, - self::WRAP_INFRONT + self::WRAP_INFRONT, ); $this->wrap = $this->setEnumVal($value, $enum, $this->wrap); From 5adbae4f2977da8ce658dde8e7a409336bfc8dde Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 7 Sep 2014 19:07:39 +0400 Subject: [PATCH 112/174] Merge pull request #356 from GMTA/develop --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b264497829..7731448544 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 - Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 - "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 +- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 ### Deprecated From 941d2c7a58e8a2096727b7aa88a265cdaeab4fce Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Wed, 10 Sep 2014 17:05:38 +0200 Subject: [PATCH 113/174] Update CONTRIBUTING.md --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b0f948f74..dac94c3248 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,12 @@ PHPWord is built by the crowd and for the crowd. Every contribution is welcome; either by [submitting](https://github.com/PHPOffice/PHPWord/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/PHPOffice/PHPWord/pulls) a pull. -We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get a life merrily. Thus, below are some guidelines that we expect to be followed by each contributor. +We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor. -- **Be brief, but be bold**: State your issues briefly, but speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. -- **Code in PSR**: We use PHP Standards Recommendation (PSR) from as the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. -- **Test your code**: Nobody else knows your code better than you. So, please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. -- **Request pull in separate branch**: Do not submit your request to the master branch, but create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get you familiar with forks and how git works in general. +- **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. +- **Code in PSR**: We use PHP Standards Recommendation (PSR) from the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. +- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. +- **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. That's it. Thank you for your interest in PHPWord, and welcome! From 5cdf329919e1907f738588bcfc6a240eb1cd60be Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Tue, 16 Sep 2014 21:59:14 +0200 Subject: [PATCH 114/174] Update CONTRIBUTING.md The PHPUnit tests run into error messages if PHPWord has not been installed by Composer. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dac94c3248..1fec41d476 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ We want to create a high quality document writer and reader library that people - **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. - **Code in PSR**: We use PHP Standards Recommendation (PSR) from the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. -- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. +- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. The PHPUnit tests only work if PHPWord has been fetched and installed by Composer. - **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. That's it. Thank you for your interest in PHPWord, and welcome! From 24d8cc7e64199eedb8a14acd4b27d329eccf5756 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 18 Sep 2014 09:39:27 +0200 Subject: [PATCH 115/174] Update installing.rst Show the way how to install PHPWord using Git. --- docs/installing.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/installing.rst b/docs/installing.rst index e5d61b4ea1..a545fe8bf5 100644 --- a/docs/installing.rst +++ b/docs/installing.rst @@ -44,10 +44,17 @@ To install via Composer, add the following lines to your Manual install ~~~~~~~~~~~~~~ -To install manually, `download PHPWord package from -github `__. -Extract the package and put the contents to your machine. To use the -library, include ``src/PhpWord/Autoloader.php`` in your script and +To install manually, you change to the webserver directory of your file system . +Then you have 2 possibilities. + + 1. `download PHPWord package from github `__. + Extract the package and put the contents to your machine. + 2. Alternatively you can use Git to install it: + .. code-block:: console + + git clone https://github.com/PHPOffice/PHPWord.git + +To use the library, include ``src/PhpWord/Autoloader.php`` in your PHP script and invoke ``Autoloader::register``. .. code-block:: php @@ -55,6 +62,7 @@ invoke ``Autoloader::register``. require_once '/path/to/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); + Using samples ------------- From 891278632e5e1ccd14872578658193c5b3fa74fa Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Sat, 20 Sep 2014 19:21:36 +0200 Subject: [PATCH 116/174] Update CONTRIBUTING.md I have added a link to an important video. Without this video I was not able to synchronise my Fork with the Develop branch. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fec41d476..c48760198a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ We want to create a high quality document writer and reader library that people - **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. - **Code in PSR**: We use PHP Standards Recommendation (PSR) from the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. - **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. The PHPUnit tests only work if PHPWord has been fetched and installed by Composer. -- **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. +- **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. That's it. Thank you for your interest in PHPWord, and welcome! From c8b649933258aef43e6cc2e7bce43d8d7170b634 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Mon, 22 Sep 2014 14:51:21 +0200 Subject: [PATCH 117/174] Update installing.rst Add the missing info how to setup Composer to fetch the latest Develop branch instead of the outdated Master branch. --- docs/installing.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/installing.rst b/docs/installing.rst index a545fe8bf5..6599590460 100644 --- a/docs/installing.rst +++ b/docs/installing.rst @@ -41,6 +41,18 @@ To install via Composer, add the following lines to your } } +If you are a developer or if you want to help us with testing then fetch the latest branch for developers. +Notice: All contributions must be done against the developer branch. + +.. code-block:: json + + { + "require": { + "phpoffice/phpword": "dev-develop" + } + } + + Manual install ~~~~~~~~~~~~~~ From 27b0c69fd410b353e91e48762627f01ee9948e3d Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Mon, 22 Sep 2014 15:46:55 +0200 Subject: [PATCH 118/174] Update Head.php The generated HTML and PDF tables are missing the border lines. Sample_07_TemplateCloneRow.docx shows the lines around the table and the table cells. However the generated HTML and PDF file are missing those lines. This patch fixes this issue. --- src/PhpWord/Writer/HTML/Part/Head.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index 4bfe304651..7339c74c52 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -97,6 +97,14 @@ private function writeStyles() 'border' => '0', 'border-top' => '1px solid #CCC', ), + 'table' => array( + 'border' => '1px solid black', + 'border-spacing' => '0px', + 'width' => '100%', + ), + 'td' => array( + 'border' => '1px solid black', + ), ); foreach ($defaultStyles as $selector => $style) { $styleWriter = new GenericStyleWriter($style); From 4e25283195a7b088a57b901d8b9731042e6bb004 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Mon, 22 Sep 2014 16:58:00 -0600 Subject: [PATCH 119/174] Add missing setters for pageSizeW and pageSizeH --- src/PhpWord/Style/Section.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index c56b0a1950..e196dfbd81 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -282,6 +282,13 @@ public function getPageSizeW() return $this->pageSizeW; } + public function setPageSizeW($value = null) + { + $this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH); + + return $this; + } + /** * Get Page Size Height * @@ -292,6 +299,13 @@ public function getPageSizeH() return $this->pageSizeH; } + public function setPageSizeH($value = null) + { + $this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT); + + return $this; + } + /** * Get Margin Top * From cf96ea0e18496ebd302562e4bbd2045d301b004e Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 08:33:53 -0600 Subject: [PATCH 120/174] Width/Height set/get tests --- tests/PhpWord/Tests/Style/SectionTest.php | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 8e8c1e8794..6ad52a6c5b 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -97,6 +97,34 @@ public function testMargin() $this->assertEquals($iVal, $oSettings->getMarginRight()); } + /** + * Set/get page width + */ + public function testPageWidth() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(11906, $oSettings->getPageSizeW()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeW', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeW()); + } + + /** + * Set/get page height + */ + public function testPageHeight() + { + // Section Settings + $oSettings = new Section(); + + $this->assertEquals(16838, $oSettings->getPageSizeH()); + $iVal = rand(1, 1000); + $oSettings->setSettingValue('pageSizeH', $iVal); + $this->assertEquals($iVal, $oSettings->getPageSizeH()); + } + /** * Set/get landscape orientation */ From cf5625b643d4887978102d1fb9d3c785806c42b5 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 09:04:45 -0600 Subject: [PATCH 121/174] Update pageSizeW and pageSizeH docs Conflicts: docs/containers.rst --- docs/styles.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/styles.rst b/docs/styles.rst index 91d5ed7a8a..f4c1e8ebd4 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -8,6 +8,8 @@ Section Below are the available styles for section: +- ``pageSizeW`` Page width in twips (the default is 11906/A4 size) +- ``pageSizeH`` Page height in twips (the default is 16838/A4 size) - ``orientation`` Page orientation, i.e. 'portrait' (default) or 'landscape' - ``marginTop`` Page margin top in twips @@ -30,12 +32,6 @@ Below are the available styles for section: - ``breakType`` Section break type (nextPage, nextColumn, continuous, evenPage, oddPage) -The following two styles are automatically set by the use of the -``orientation`` style. You can alter them but that's not recommended. - -- ``pageSizeW`` Page width in twips -- ``pageSizeH`` Page height in twips - Font ---- From cea15f3d2361ea4156976fe59ea540e00a4acd6c Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 10:50:50 -0600 Subject: [PATCH 122/174] Use page width and height default constants in tests --- tests/PhpWord/Tests/Style/SectionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 6ad52a6c5b..e5becd7296 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -105,7 +105,7 @@ public function testPageWidth() // Section Settings $oSettings = new Section(); - $this->assertEquals(11906, $oSettings->getPageSizeW()); + $this->assertEquals(Section::DEFAULT_WIDTH, $oSettings->getPageSizeW()); $iVal = rand(1, 1000); $oSettings->setSettingValue('pageSizeW', $iVal); $this->assertEquals($iVal, $oSettings->getPageSizeW()); @@ -119,7 +119,7 @@ public function testPageHeight() // Section Settings $oSettings = new Section(); - $this->assertEquals(16838, $oSettings->getPageSizeH()); + $this->assertEquals(Section::DEFAULT_HEIGHT, $oSettings->getPageSizeH()); $iVal = rand(1, 1000); $oSettings->setSettingValue('pageSizeH', $iVal); $this->assertEquals($iVal, $oSettings->getPageSizeH()); From 112712012e62fcf2aba742cb12cbb63f2143e295 Mon Sep 17 00:00:00 2001 From: Spike Ilacqua Date: Thu, 2 Oct 2014 11:06:14 -0600 Subject: [PATCH 123/174] Update Changelog for setPageSizeW and setPageSizeH --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7731448544..1ad2d884bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 - "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 - "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 +- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. ### Deprecated From 4445fd3258084f855d044f4ed8f1d92a62229dc6 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 10 Oct 2014 21:10:29 +0400 Subject: [PATCH 124/174] Replaced `array_key_exists` with `isset` for better performance. --- src/PhpWord/Element/AbstractContainer.php | 41 ++++++++++--------- src/PhpWord/Element/Field.php | 6 +-- src/PhpWord/Element/Title.php | 5 +-- src/PhpWord/Media.php | 8 ++-- src/PhpWord/PhpWord.php | 2 +- src/PhpWord/Reader/RTF/Document.php | 4 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Reader/Word2007/AbstractPart.php | 9 ++-- src/PhpWord/Reader/Word2007/DocPropsCore.php | 4 +- src/PhpWord/Reader/Word2007/Document.php | 8 ++-- src/PhpWord/Reader/Word2007/Footnotes.php | 2 +- src/PhpWord/Shared/Html.php | 3 +- src/PhpWord/Style.php | 4 +- src/PhpWord/Writer/AbstractWriter.php | 2 +- src/PhpWord/Writer/HTML/Part/Body.php | 2 +- src/PhpWord/Writer/RTF/Part/Document.php | 2 +- src/PhpWord/Writer/Word2007.php | 4 +- src/PhpWord/Writer/Word2007/Part/Rels.php | 4 +- src/PhpWord/Writer/Word2007/Part/Styles.php | 6 +-- src/PhpWord/Writer/Word2007/Style/Frame.php | 6 +-- src/PhpWord/Writer/Word2007/Style/Line.php | 2 +- .../Writer/Word2007/Style/MarginBorder.php | 4 +- 22 files changed, 64 insertions(+), 66 deletions(-) diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 6a26c15fa6..57d646a01b 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -92,7 +92,7 @@ public function __call($function, $args) // Run valid `add` command $function = strtolower($function); - if (array_key_exists($function, $functions)) { + if (isset($functions[$function])) { $element = $functions[$function]; // Special case for TextBreak @@ -183,23 +183,22 @@ public function countElements() */ private function checkValidity($method) { - // Valid containers for each element - $allContainers = array( - 'Section', 'Header', 'Footer', 'Footnote', 'Endnote', - 'Cell', 'TextRun', 'TextBox', 'ListItemRun', + $generalContainers = array( + 'Section', 'Header', 'Footer', 'Footnote', 'Endnote', 'Cell', 'TextRun', 'TextBox', 'ListItemRun', ); + $validContainers = array( - 'Text' => $allContainers, - 'Bookmark' => $allContainers, - 'Link' => $allContainers, - 'TextBreak' => $allContainers, - 'Image' => $allContainers, - 'Object' => $allContainers, - 'Field' => $allContainers, - 'Line' => $allContainers, - 'Shape' => $allContainers, - 'FormField' => $allContainers, - 'SDT' => $allContainers, + 'Text' => $generalContainers, + 'Bookmark' => $generalContainers, + 'Link' => $generalContainers, + 'TextBreak' => $generalContainers, + 'Image' => $generalContainers, + 'Object' => $generalContainers, + 'Field' => $generalContainers, + 'Line' => $generalContainers, + 'Shape' => $generalContainers, + 'FormField' => $generalContainers, + 'SDT' => $generalContainers, 'TextRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItem' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), 'ListItemRun' => array('Section', 'Header', 'Footer', 'Cell', 'TextBox'), @@ -214,6 +213,7 @@ private function checkValidity($method) 'PageBreak' => array('Section'), 'Chart' => array('Section'), ); + // Special condition, e.g. preservetext can only exists in cell when // the cell is located in header or footer $validSubcontainers = array( @@ -223,19 +223,20 @@ private function checkValidity($method) ); // Check if a method is valid for current container - if (array_key_exists($method, $validContainers)) { + if (isset($validContainers[$method])) { if (!in_array($this->container, $validContainers[$method])) { - throw new \BadMethodCallException("Cannot add $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 - if (array_key_exists($method, $validSubcontainers)) { + if (isset($validSubcontainers[$method])) { $rules = $validSubcontainers[$method]; $containers = $rules[0]; $allowedDocParts = $rules[1]; foreach ($containers as $container) { if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { - throw new \BadMethodCallException("Cannot add $method in $this->container."); + throw new \BadMethodCallException("Cannot add {$method} in {$this->container}."); } } } diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index 50f0522fb1..1eaa6f242f 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -100,7 +100,7 @@ public function __construct($type = null, $properties = array(), $options = arra public function setType($type = null) { if (isset($type)) { - if (array_key_exists($type, $this->fieldsArray)) { + if (isset($this->fieldsArray[$type])) { $this->type = $type; } else { throw new \InvalidArgumentException("Invalid type"); @@ -130,7 +130,7 @@ 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']))) { + if (!(isset($this->fieldsArray[$this->type]['properties'][$propkey]))) { throw new \InvalidArgumentException("Invalid property"); } } @@ -160,7 +160,7 @@ public function setOptions($options = array()) { if (is_array($options)) { foreach (array_keys($options) as $optionkey) { - if (!(array_key_exists($optionkey, $this->fieldsArray[$this->type]['options']))) { + if (!(isset($this->fieldsArray[$this->type]['options'][$optionkey]))) { throw new \InvalidArgumentException("Invalid option"); } } diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 8d3858458f..cf1d49c81a 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -61,11 +61,10 @@ class Title extends AbstractElement */ public function __construct($text, $depth = 1) { - $this->text = String::toUTF8($text); $this->depth = $depth; - if (array_key_exists('Heading_' . $this->depth, Style::getStyles())) { - $this->style = 'Heading' . $this->depth; + if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) { + $this->style = "Heading{$this->depth}"; } return $this; diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 4bea57acac..59735cea4c 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -48,12 +48,12 @@ public static function addElement($container, $mediaType, $source, Image $image { // Assign unique media Id and initiate media container if none exists $mediaId = md5($container . $source); - if (!array_key_exists($container, self::$elements)) { + if (!isset(self::$elements[$container])) { self::$elements[$container] = array(); } // Add media if not exists or point to existing media - if (!array_key_exists($mediaId, self::$elements[$container])) { + if (!isset(self::$elements[$container][$mediaId])) { $mediaCount = self::countElements($container); $mediaTypeCount = self::countElements($container, $mediaType); $mediaTypeCount++; @@ -120,7 +120,7 @@ public static function countElements($container, $mediaType = null) { $mediaCount = 0; - if (array_key_exists($container, self::$elements)) { + if (isset(self::$elements[$container])) { foreach (self::$elements[$container] as $mediaData) { if (!is_null($mediaType)) { if ($mediaType == $mediaData['type']) { @@ -156,7 +156,7 @@ public static function getElements($container, $type = null) } return $elements; } else { - if (!array_key_exists($container, self::$elements)) { + if (!isset(self::$elements[$container])) { return $elements; } return self::getElementsByType($container, $type); diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index aba1ee3863..7568d81bb7 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -139,7 +139,7 @@ public function __call($function, $args) /** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */ $collectionObject = $this->collections[$key]; - return $collectionObject->addItem(array_key_exists(0, $args) ? $args[0] : null); + return $collectionObject->addItem(isset($args[0]) ? $args[0] : null); } // Run add style method diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php index fcd9703fd0..3f63e3398e 100644 --- a/src/PhpWord/Reader/RTF/Document.php +++ b/src/PhpWord/Reader/RTF/Document.php @@ -155,7 +155,7 @@ public function read(PhpWord $phpWord) $char = $this->rtf[$this->offset]; $ascii = ord($char); - if (array_key_exists($ascii, $markers)) { // Marker found: {, }, \, LF, or CR + if (isset($markers[$ascii])) { // Marker found: {, }, \, LF, or CR $markerFunction = $markers[$ascii]; $this->$markerFunction(); } else { @@ -351,7 +351,7 @@ private function parseControl($control, $parameter) 'fldinst' => array(self::SKIP, 'link', null), ); - if (array_key_exists($control, $controls)) { + if (isset($controls[$control])) { list($function) = $controls[$control]; if (method_exists($this, $function)) { $directives = $controls[$control]; diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 6079567fcb..ebe6c4f765 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -63,7 +63,7 @@ public function load($docFile) $stepItems = $step['stepItems']; foreach ($relationships[$stepPart] as $relItem) { $relType = $relItem['type']; - if (array_key_exists($relType, $stepItems)) { + if (isset($stepItems[$relType])) { $partName = $stepItems[$relType]; $xmlFile = $relItem['target']; $this->readPart($phpWord, $relationships, $partName, $docFile, $xmlFile); diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 7d3e0f66df..021bdba11e 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -107,7 +107,7 @@ protected function readParagraph(XMLReader $xmlReader, \DOMElement $domNode, $pa $headingMatches = array(); if ($xmlReader->elementExists('w:pPr', $domNode)) { $paragraphStyle = $this->readParagraphStyle($xmlReader, $domNode); - if (is_array($paragraphStyle) && array_key_exists('styleName', $paragraphStyle)) { + if (is_array($paragraphStyle) && isset($paragraphStyle['styleName'])) { preg_match('/Heading(\d)/', $paragraphStyle['styleName'], $headingMatches); } } @@ -505,10 +505,9 @@ private function readStyleDef($method, $attributeValue, $expected) private function getMediaTarget($docPart, $rId) { $target = null; - if (array_key_exists($docPart, $this->rels)) { - if (array_key_exists($rId, $this->rels[$docPart])) { - $target = $this->rels[$docPart][$rId]['target']; - } + + if (isset($this->rels[$docPart]) && isset($this->rels[$docPart][$rId])) { + $target = $this->rels[$docPart][$rId]['target']; } return $target; diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php index 4c48ecbc73..54537525b6 100644 --- a/src/PhpWord/Reader/Word2007/DocPropsCore.php +++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php @@ -67,12 +67,12 @@ public function read(PhpWord $phpWord) $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { foreach ($nodes as $node) { - if (!array_key_exists($node->nodeName, $this->mapping)) { + if (!isset($this->mapping[$node->nodeName])) { continue; } $method = $this->mapping[$node->nodeName]; $value = $node->nodeValue == '' ? null : $node->nodeValue; - if (array_key_exists($node->nodeName, $this->callbacks)) { + if (isset($this->callbacks[$node->nodeName])) { $value = $this->callbacks[$node->nodeName]($value); } if (method_exists($docProps, $method)) { diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php index 3ced6763cb..e1beed0666 100644 --- a/src/PhpWord/Reader/Word2007/Document.php +++ b/src/PhpWord/Reader/Word2007/Document.php @@ -53,7 +53,7 @@ public function read(PhpWord $phpWord) if ($nodes->length > 0) { $section = $this->phpWord->addSection(); foreach ($nodes as $node) { - if (array_key_exists($node->nodeName, $readMethods)) { + if (isset($readMethods[$node->nodeName])) { $readMethod = $readMethods[$node->nodeName]; $this->$readMethod($xmlReader, $node, $section); } @@ -72,9 +72,9 @@ private function readHeaderFooter($settings, Section &$section) { $readMethods = array('w:p' => 'readParagraph', 'w:tbl' => 'readTable'); - if (is_array($settings) && array_key_exists('hf', $settings)) { + if (is_array($settings) && isset($settings['hf'])) { foreach ($settings['hf'] as $rId => $hfSetting) { - if (array_key_exists($rId, $this->rels['document'])) { + if (isset($this->rels['document'][$rId])) { list($hfType, $xmlFile, $docPart) = array_values($this->rels['document'][$rId]); $addMethod = "add{$hfType}"; $hfObject = $section->$addMethod($hfSetting['type']); @@ -85,7 +85,7 @@ private function readHeaderFooter($settings, Section &$section) $nodes = $xmlReader->getElements('*'); if ($nodes->length > 0) { foreach ($nodes as $node) { - if (array_key_exists($node->nodeName, $readMethods)) { + if (isset($readMethods[$node->nodeName])) { $readMethod = $readMethods[$node->nodeName]; $this->$readMethod($xmlReader, $node, $hfObject, $docPart); } diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php index c66b13fe90..6f6adc879e 100644 --- a/src/PhpWord/Reader/Word2007/Footnotes.php +++ b/src/PhpWord/Reader/Word2007/Footnotes.php @@ -62,7 +62,7 @@ public function read(PhpWord $phpWord) // Avoid w:type "separator" and "continuationSeparator" // Only look for or without w:type attribute - if (is_null($type) && array_key_exists($id, $collection)) { + if (is_null($type) && isset($collection[$id])) { $element = $collection[$id]; $pNodes = $xmlReader->getElements('w:p/*', $node); foreach ($pNodes as $pNode) { diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 13824f3388..2b4acd05b9 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -133,8 +133,7 @@ protected static function parseNode($node, $element, $styles = array(), $data = $newElement = null; $keys = array('node', 'element', 'styles', 'data', 'argument1', 'argument2'); - if (array_key_exists($node->nodeName, $nodes)) { - + if (isset($nodes[$node->nodeName])) { // Execute method based on node mapping table and return $newElement or null // Arguments are passed by reference $arguments = array(); diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 73af4f5dfd..ab03106fce 100644 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -163,7 +163,7 @@ public static function getStyles() */ public static function getStyle($styleName) { - if (array_key_exists($styleName, self::$styles)) { + if (isset(self::$styles[$styleName])) { return self::$styles[$styleName]; } else { return null; @@ -182,7 +182,7 @@ public static function getStyle($styleName) */ private static function setStyleValues($name, $style, $value = null) { - if (!array_key_exists($name, self::$styles)) { + if (!isset(self::$styles[$name])) { if ($value !== null) { if (is_array($value)) { $style->setStyleByArray($value); diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php index 31097b899f..599d8a6fdd 100644 --- a/src/PhpWord/Writer/AbstractWriter.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -343,7 +343,7 @@ protected function addFilesToPackage(ZipArchive $zip, $elements) $type = $element['type']; // image|object|link // Skip nonregistered types and set target - if (!array_key_exists($type, $this->mediaPaths)) { + if (!isset($this->mediaPaths[$type])) { continue; } $target = $this->mediaPaths[$type] . $element['target']; diff --git a/src/PhpWord/Writer/HTML/Part/Body.php b/src/PhpWord/Writer/HTML/Part/Body.php index 4fd61a834f..b91ca3ad2d 100644 --- a/src/PhpWord/Writer/HTML/Part/Body.php +++ b/src/PhpWord/Writer/HTML/Part/Body.php @@ -72,7 +72,7 @@ private function writeNotes() $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); $collection = $phpWord->$method()->getItems(); - if (array_key_exists($noteTypeId, $collection)) { + if (isset($collection[$noteTypeId])) { $element = $collection[$noteTypeId]; $noteAnchor = ""; $noteAnchor .= "{$noteId}"; diff --git a/src/PhpWord/Writer/RTF/Part/Document.php b/src/PhpWord/Writer/RTF/Part/Document.php index f239f9e253..edcdbd84a4 100644 --- a/src/PhpWord/Writer/RTF/Part/Document.php +++ b/src/PhpWord/Writer/RTF/Part/Document.php @@ -64,7 +64,7 @@ private function writeInfo() $content .= '{'; $content .= '\info'; foreach ($properties as $property) { - $method = 'get' . (array_key_exists($property, $mapping) ? $mapping[$property] : $property); + $method = 'get' . (isset($mapping[$property]) ? $mapping[$property] : $property); $value = $docProps->$method(); $value = in_array($property, $dateFields) ? $this->getDateValue($value) : $value; $content .= "{\\{$property} {$value}}"; diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index baac822275..09d095093f 100644 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -302,11 +302,11 @@ private function registerContentTypes($media) $mediumType = $medium['type']; if ($mediumType == 'image') { $extension = $medium['imageExtension']; - if (!array_key_exists($extension, $this->contentTypes['default'])) { + if (!isset($this->contentTypes['default'][$extension])) { $this->contentTypes['default'][$extension] = $medium['imageType']; } } elseif ($mediumType == 'object') { - if (!array_key_exists('bin', $this->contentTypes['default'])) { + if (!isset($this->contentTypes['default']['bin'])) { $this->contentTypes['default']['bin'] = 'application/vnd.openxmlformats-officedocument.oleObject'; } } diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 80ab630726..9a7f444bd4 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -89,8 +89,8 @@ private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel) $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] : ''; + $type = isset($typeMapping[$mediaType]) ? $typeMapping[$mediaType] : $mediaType; + $targetPrefix = isset($targetMapping[$mediaType]) ? $targetMapping[$mediaType] : ''; $target = $mediaRel['target']; $targetMode = ($type == 'hyperlink') ? 'External' : ''; diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php index 6a8de48ac5..0194222948 100644 --- a/src/PhpWord/Writer/Word2007/Part/Styles.php +++ b/src/PhpWord/Writer/Word2007/Part/Styles.php @@ -19,9 +19,9 @@ use PhpOffice\PhpWord\Settings as PhpWordSettings; use PhpOffice\PhpWord\Shared\XMLWriter; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; -use PhpOffice\PhpWord\Style; 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; @@ -114,14 +114,14 @@ private function writeDefaultStyles(XMLWriter $xmlWriter, $styles) $xmlWriter->startElement('w:name'); $xmlWriter->writeAttribute('w:val', 'Normal'); $xmlWriter->endElement(); // w:name - if (array_key_exists('Normal', $styles)) { + if (isset($styles['Normal'])) { $styleWriter = new ParagraphStyleWriter($xmlWriter, $styles['Normal']); $styleWriter->write(); } $xmlWriter->endElement(); // w:style // FootnoteReference style - if (!array_key_exists('FootnoteReference', $styles)) { + if (!isset($styles['FootnoteReference'])) { $xmlWriter->startElement('w:style'); $xmlWriter->writeAttribute('w:type', 'character'); $xmlWriter->writeAttribute('w:styleId', 'FootnoteReference'); diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php index 2dd6176546..28ebeaf52e 100644 --- a/src/PhpWord/Writer/Word2007/Style/Frame.php +++ b/src/PhpWord/Writer/Word2007/Style/Frame.php @@ -64,7 +64,7 @@ public function write() // zIndex for infront & behind wrap $wrap = $style->getWrap(); - if ($wrap !== null && array_key_exists($wrap, $zIndices)) { + if ($wrap !== null && isset($zIndices[$wrap])) { $styles['z-index'] = $zIndices[$wrap]; $wrap = null; } @@ -124,10 +124,10 @@ private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap) $xmlWriter->writeAttribute('anchorx', "page"); $xmlWriter->writeAttribute('anchory', "page"); } elseif ($pos == FrameStyle::POS_RELATIVE) { - if (array_key_exists($hPos, $relativePositions)) { + if (isset($relativePositions[$hPos])) { $xmlWriter->writeAttribute('anchorx', $relativePositions[$hPos]); } - if (array_key_exists($vPos, $relativePositions)) { + if (isset($relativePositions[$vPos])) { $xmlWriter->writeAttribute('anchory', $relativePositions[$vPos]); } } diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php index fd1c21de66..48e27492ac 100644 --- a/src/PhpWord/Writer/Word2007/Style/Line.php +++ b/src/PhpWord/Writer/Word2007/Style/Line.php @@ -58,7 +58,7 @@ public function writeStroke() $xmlWriter->writeAttributeIf($style->getEndArrow() !== null, 'endarrow', $style->getEndArrow()); if ($dash !== null) { - if (array_key_exists($dash, $dashStyles)) { + if (isset($dashStyles[$dash])) { $xmlWriter->writeAttribute('dashstyle', $dashStyles[$dash]); } if ($dash == LineStyle::DASH_STYLE_ROUND_DOT) { diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php index fb4afedeff..30029112f8 100644 --- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php +++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php @@ -83,7 +83,7 @@ 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)) { + if (isset($this->attributes['defaultColor'])) { $color = $this->attributes['defaultColor']; } } @@ -91,7 +91,7 @@ private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null) $xmlWriter->writeAttribute('w:sz', $width); $xmlWriter->writeAttribute('w:color', $color); if (!empty($this->attributes)) { - if (array_key_exists('space', $this->attributes)) { + if (isset($this->attributes['space'])) { $xmlWriter->writeAttribute('w:space', $this->attributes['space']); } } From 2c81d5f38b2a18e5ee43ab6e32f15b6ceda99ca0 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 10 Oct 2014 21:20:52 +0400 Subject: [PATCH 125/174] Some phpdoc for https://github.com/PHPOffice/PHPWord/pull/390. --- src/PhpWord/Style/Section.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index e196dfbd81..128e8e6b21 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -275,13 +275,22 @@ public function setLandscape() /** * Get Page Size Width * - * @return int|float + * @return int|float|null + * + * @since 0.12.0 */ public function getPageSizeW() { return $this->pageSizeW; } + /** + * @param int|float|null $value + * + * @return \PhpOffice\PhpWord\Style\Section + * + * @since 0.12.0 + */ public function setPageSizeW($value = null) { $this->pageSizeW = $this->setNumericVal($value, self::DEFAULT_WIDTH); @@ -292,13 +301,22 @@ public function setPageSizeW($value = null) /** * Get Page Size Height * - * @return int|float + * @return int|float|null + * + * @since 0.12.0 */ public function getPageSizeH() { return $this->pageSizeH; } + /** + * @param int|float|null $value + * + * @return \PhpOffice\PhpWord\Style\Section + * + * @since 0.12.0 + */ public function setPageSizeH($value = null) { $this->pageSizeH = $this->setNumericVal($value, self::DEFAULT_HEIGHT); From 06d6b715a3be119a2bb688a44a95eaa25f8b9cd2 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 14 Oct 2014 21:06:47 +0400 Subject: [PATCH 126/174] [CHANGED] "tests/bootstrap.php". --- tests/bootstrap.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d0dcdba7ff..4932a21b26 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,16 +23,10 @@ } $vendor = realpath(__DIR__ . '/../vendor'); - -if (file_exists($vendor . "/autoload.php")) { - require $vendor . "/autoload.php"; +if (file_exists($vendor . '/autoload.php')) { + require $vendor . '/autoload.php'; } else { - $vendor = realpath(__DIR__ . '/../../../'); - if (file_exists($vendor . "/autoload.php")) { - require $vendor . "/autoload.php"; - } else { - throw new Exception("Unable to load dependencies"); - } + throw new Exception('Unable to load dependencies'); } spl_autoload_register(function ($class) { @@ -49,5 +43,5 @@ } }); -require_once __DIR__ . "/../src/PhpWord/Autoloader.php"; +require_once __DIR__ . '/../src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); From fa575ef12c2028baa07c5c46665b9795424e1668 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 14 Oct 2014 21:33:04 +0400 Subject: [PATCH 127/174] Minor refactoring. --- src/PhpWord/Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 6c7f17e17b..67b1dbedbd 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -240,7 +240,7 @@ public static function getPdfRendererPath() */ public static function setPdfRendererPath($libraryBaseDir) { - if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { + if (false === file_exists($libraryBaseDir) || false === is_readable($libraryBaseDir)) { return false; } self::$pdfRendererPath = $libraryBaseDir; From d231641680cabb226567e120ce3b55be735b3443 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 15 Oct 2014 22:13:38 +0200 Subject: [PATCH 128/174] Update Documentation --- docs/faq.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index ec158356e7..79652ae025 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -3,6 +3,12 @@ Frequently asked questions ========================== +How contribute to PHPWord ? +--------------------------- + +- Improve the documentation (`Sphinx Format `__) + + Is this the same with PHPWord that I found in CodePlex? ------------------------------------------------------- From 7b2ec5e85e40859ccb2202bb2900870036722afc Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 16 Oct 2014 21:04:59 +0400 Subject: [PATCH 129/174] Reverted #373. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c48760198a..44177e0993 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ We want to create a high quality document writer and reader library that people - **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. - **Code in PSR**: We use PHP Standards Recommendation (PSR) from the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. -- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. The PHPUnit tests only work if PHPWord has been fetched and installed by Composer. +- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. - **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. That's it. Thank you for your interest in PHPWord, and welcome! From b1acecb255a677fa9545412161f2b6ea97573915 Mon Sep 17 00:00:00 2001 From: pjt33 Date: Mon, 20 Oct 2014 11:27:57 +0200 Subject: [PATCH 130/174] Correct spelling of fldCharType separate. See http://www.ecma-international.org/news/TC45_current_work/OfficeOpenXML-XMLSchema.zip , file wml.xsd, line 3977. --- src/PhpWord/Writer/Word2007/Element/CheckBox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php index 9d060726ff..deafbd1de3 100644 --- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php +++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php @@ -68,7 +68,7 @@ public function write() $xmlWriter->endElement(); // w:r $xmlWriter->startElement('w:r'); $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'seperate'); + $xmlWriter->writeAttribute('w:fldCharType', 'separate'); $xmlWriter->endElement();// w:fldChar $xmlWriter->endElement(); // w:r $xmlWriter->startElement('w:r'); From b2286f85454ebe0757d8e02816d6840d07ff89be Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 22 Oct 2014 19:53:50 +0400 Subject: [PATCH 131/174] [FIXED] https://github.com/PHPOffice/PHPWord/issues/401 --- src/PhpWord/Writer/Word2007/Element/AbstractElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 2c200f81ee..3b6432ed6a 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -167,6 +167,6 @@ private function writeTextStyle($styleType) */ protected function getText($text) { - return String::controlCharacterPHP2OOXML(htmlspecialchars($text)); + return String::controlCharacterPHP2OOXML($text); } } From b4be9c65bd486e06e4559e862a0157d75f5e8795 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Nov 2014 19:40:43 +0400 Subject: [PATCH 132/174] https://github.com/PHPOffice/PHPWord/issues/310 --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 841ab1a1d0..27a0ed171f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Read more about PHPWord: - [Requirements](#requirements) - [Installation](#installation) - [Getting started](#getting-started) -- [Known issues](#known-issues) - [Contributing](#contributing) - [Developers' Documentation](http://phpword.readthedocs.org/) - [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) @@ -126,10 +125,6 @@ $phpWord->save('helloWorld.rtf', 'RTF'); More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. -## Known issues - -- GH-238: PHPWord uses temporary folder with `sys_get_temp_dir()` extensively. The default setting on some systems (especially Windows) do not give appropriate read/write permission to this folder. Run `samples/index.php` either by CLI or by web browsers to check if you have this requirement fulfilled. - ## Contributing We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: From 53eaf47309f224a6a8dc0e86fd3b440112b9c06d Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Nov 2014 19:56:54 +0400 Subject: [PATCH 133/174] [CHANGED] "CONTRIBUTING.md". --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44177e0993..fa6f76c2bb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ PHPWord is built by the crowd and for the crowd. Every contribution is welcome; We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor. - **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. -- **Code in PSR**: We use PHP Standards Recommendation (PSR) from the PHP Framework Interoperability Group (PHP-FIG). If you're not familiar with this standard, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to check your code against this standard. +- **Follow PHP-FIG standards**: We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these recommendations, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against these standards. - **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. - **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. From 3a11daadeddb4d9b2bc6e3a5e48cbe01275cfb3e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Nov 2014 19:59:33 +0400 Subject: [PATCH 134/174] [CHANGED] "CONTRIBUTING.md". --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa6f76c2bb..32292c6ab3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,10 +4,10 @@ PHPWord is built by the crowd and for the crowd. Every contribution is welcome; We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor. -- **Be brief, but be bold**: State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. -- **Follow PHP-FIG standards**: We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these recommendations, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against these standards. -- **Test your code**: Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. -- **Request pull in separate branch**: Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. +- **Be brief, but be bold**. State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. +- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these recommendations, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against these standards. +- **Test your code**. Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. +- **Request pull in separate branch**. Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. That's it. Thank you for your interest in PHPWord, and welcome! From 89e722e6a131bdafbfcc8d9b09fd7f32f5c60a9e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Mon, 3 Nov 2014 20:00:38 +0400 Subject: [PATCH 135/174] [CHANGED] "CONTRIBUTING.md". --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32292c6ab3..e061dcd061 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ PHPWord is built by the crowd and for the crowd. Every contribution is welcome; We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor. - **Be brief, but be bold**. State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. -- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these recommendations, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against these standards. +- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these standards, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against PSRs. - **Test your code**. Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. - **Request pull in separate branch**. Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. From f4b5eaaa29bebc9ecc06702c93ef05bdefca2d2c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 4 Nov 2014 14:05:11 +0400 Subject: [PATCH 136/174] [FIXED] https://github.com/PHPOffice/PHPWord/issues/401 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad2d884bd..aa3f232cfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 - "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 - `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. +- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401 ### Deprecated From c0e04fac51e77e439265d8202cb24e8c04df66c1 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 7 Nov 2014 20:54:24 +0400 Subject: [PATCH 137/174] Reverted #51. --- src/PhpWord/TemplateProcessor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 1de520f67a..cbed973011 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -364,7 +364,6 @@ protected function setValueForPart($documentPartXML, $search, $replace, $limit) if (!String::isUTF8($replace)) { $replace = utf8_encode($replace); } - $replace = htmlspecialchars($replace); $regExpDelim = '/'; $escapedSearch = preg_quote($search, $regExpDelim); From e7fdb7f50d1c65fc15249603ce273df08eb7490e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 7 Nov 2014 20:56:58 +0400 Subject: [PATCH 138/174] Reverted #51. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3f232cfa..a00d31b44a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko - Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 - Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 +- Reverted GH-51 - @RomanSyroeshko ## 0.11.1 - 2 June 2014 From 37ca0097690b84578c32cb6a331aa53be642a43a Mon Sep 17 00:00:00 2001 From: chc88 Date: Fri, 14 Nov 2014 17:26:23 +0100 Subject: [PATCH 139/174] Extend HTML output for pagebreaks for PDF generation Make HTML output of pagebreak compatible for the different PDF writers by combining: http://mpdf1.com/manual/index.php?tid=110 (tested and working) and https://code.google.com/p/dompdf/wiki/FAQ (tested and working) and http://chandeshparekh.com/css-to-create-new-page-in-php-tcpdf-pdf/ --- src/PhpWord/Writer/HTML/Element/PageBreak.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index a3fb1f3b5c..403ca129d9 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -24,4 +24,13 @@ */ class PageBreak extends TextBreak { + /** + * Write page break + * + * @return string + */ + public function write() + { + return ''; + } } From f18e51a19f57c83bd3bb0a6e31b41c60d2dc3bfe Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Fri, 14 Nov 2014 22:13:58 +0400 Subject: [PATCH 140/174] [CHANGED] "CONTRIBUTING.md". --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e061dcd061..335ad2d519 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,8 +5,8 @@ PHPWord is built by the crowd and for the crowd. Every contribution is welcome; We want to create a high quality document writer and reader library that people can use with more confidence and less bugs. We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor. - **Be brief, but be bold**. State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations. -- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these standards, please [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against PSRs. -- **Test your code**. Nobody else knows your code better than you. So please, test your own code before submitting your pull request. PHPWord uses [PHPUnit](http://phpunit.de/) as our testing framework. +- **Follow PHP-FIG standards**. We follow PHP Standards Recommendations (PSRs) by [PHP Framework Interoperability Group](http://www.php-fig.org/). If you're not familiar with these standards, please, [familiarize yourself now](https://github.com/php-fig/fig-standards). Also, please, use [PHPCodeSniffer](http://pear.php.net/package/PHP_CodeSniffer/) to validate your code against PSRs. +- **Test your code**. Nobody else knows your code better than you. So, it's completely yours mission to test the changes you made before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and recommend you using this tool too. [Here](https://phpunit.de/presentations.html) you can find PHPUnit best practices and additional information on effective unit testing, which helps us making PHPWord better day to day. Do not hesitate to smoke it carefully. It's a great investment in quality of your work, and it saves you years of life. - **Request pull in separate branch**. Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of PHPWord. That's it. Thank you for your interest in PHPWord, and welcome! From 7b11002989ca1bab30390f21394b369e258216f2 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 12:38:18 +0400 Subject: [PATCH 141/174] [CHANGED] "README.md". --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 27a0ed171f..379402ed33 100644 --- a/README.md +++ b/README.md @@ -127,9 +127,9 @@ More examples are provided in the [samples folder](samples/). You can also read ## Contributing -We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute: +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 +- 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. From 34e6f5060913258bad805e64300b9b38d99d3869 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 12:48:23 +0400 Subject: [PATCH 142/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 379402ed33..1cc4edf7e8 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` - +:exclamation: Don't forget to escape any string you pass to PHPWord API. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. ## Contributing From beeaf89fd6bb3e973bf19c8903fdb706408aca20 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 12:51:10 +0400 Subject: [PATCH 143/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1cc4edf7e8..5567ebbe48 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` :exclamation: Don't forget to escape any string you pass to PHPWord API. + More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. ## Contributing From 4a0da83f28353a6b4cb0151257c2d74b33518153 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 12:59:52 +0400 Subject: [PATCH 144/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5567ebbe48..8821c04aef 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:exclamation: Don't forget to escape any string you pass to PHPWord API. +:exclamation: Don't forget to escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or through [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From 41f6aec45f6181df355fafbcee624b0156a9fc5d Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 13:07:30 +0400 Subject: [PATCH 145/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8821c04aef..afd7535df2 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:exclamation: Don't forget to escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or through [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. +:warning: Escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or through [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From 9a6c224e47a4c111af2408232f6e9ea475afee00 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 13:09:33 +0400 Subject: [PATCH 146/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index afd7535df2..721ccd4aca 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:warning: Escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or through [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. +:warning: Escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From b8ee099d9665c58c845f438849247a2c9b0a0e0c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 13:22:34 +0400 Subject: [PATCH 147/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 721ccd4aca..0d654ee955 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:warning: Escape any string PHPWord API consumes by passing it through [Zend\Escaper](http://framework.zend.com/manual/2.3/en/index.html#zend-escaper) or [``htmlspecialchars``](https://php.net/manual/en/function.htmlspecialchars.php) at least. +:warning: Escape any string you pass to your document with PHPWord API. Otherwise you may broke the document. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From 07cec9c66ad58528a73e069294344fd9987d496c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 13:31:27 +0400 Subject: [PATCH 148/174] [CHANGED] "intro.rst". --- docs/intro.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index a7dca9476f..d2decd7c94 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -181,15 +181,15 @@ Contributing ------------ We welcome everyone to contribute to PHPWord. Below are some of the -things that you can do to contribute: +things that you can do to contribute. - Read `our contributing - guide `__ + guide `__. - `Fork us `__ and `request a pull `__ to the `develop `__ - branch + branch. - Submit `bug reports or feature - requests `__ to GitHub + requests `__ to GitHub. - Follow `@PHPWord `__ and - `@PHPOffice `__ on Twitter + `@PHPOffice `__ on Twitter. From d1993a4ab7c8d2fe5f20d1196169cf2cebf0fab5 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 13:35:18 +0400 Subject: [PATCH 149/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d654ee955..b28add103f 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:warning: Escape any string you pass to your document with PHPWord API. Otherwise you may broke the document. +:warning: Escape any string you pass to your document. Otherwise you may broke the document. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From b4d31cafd90574b5280109b5644f4206947c477e Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 16:08:35 +0400 Subject: [PATCH 150/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b28add103f..ef9fed1d35 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:warning: Escape any string you pass to your document. Otherwise you may broke the document. +:warning: Escape any string you pass to your document. Otherwise you may break the document. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From 8dcbc92df67b036c1c5720367ff4d2a0a22e16d8 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 23 Nov 2014 16:12:57 +0400 Subject: [PATCH 151/174] [CHANGED] "README.md". Added notice required about input escaping. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef9fed1d35..f243f05b51 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ $phpWord->save('helloWorld.docx'); $phpWord->save('helloWorld.odt', 'ODText'); $phpWord->save('helloWorld.rtf', 'RTF'); ``` -:warning: Escape any string you pass to your document. Otherwise you may break the document. +:warning: Escape any string you pass to your document, otherwise it may get broken. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. From ca664a53d7c90f90ed5312db6bce159bc4182c59 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Wed, 3 Dec 2014 17:01:27 +0100 Subject: [PATCH 152/174] Update Table.php You must not open a and close it as a . read http://www.w3schools.com/tags/tag_th.asp --- src/PhpWord/Writer/HTML/Element/Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php index c8813a67f9..9027603b8f 100644 --- a/src/PhpWord/Writer/HTML/Element/Table.php +++ b/src/PhpWord/Writer/HTML/Element/Table.php @@ -51,7 +51,7 @@ public function write() $cellTag = $tblHeader ? 'th' : 'td'; $content .= "<{$cellTag}>" . PHP_EOL; $content .= $writer->write(); - $content .= '' . PHP_EOL; + $content .= "" . PHP_EOL; } $content .= '' . PHP_EOL; } From 455a4c4f291dffe9558d4b17273d7b017ac52093 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 4 Dec 2014 21:58:51 +0400 Subject: [PATCH 153/174] #438 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a00d31b44a..9808f02a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 - `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. - Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401 +- `` tag is closed with `` tag: - @franzholz GH-438 ### Deprecated From f8ee23049587e407c51d6f83337be885ea560e31 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 4 Dec 2014 22:12:16 +0400 Subject: [PATCH 154/174] [FIXED] Typo. --- src/PhpWord/PhpWord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 7568d81bb7..99c95c7912 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -122,7 +122,7 @@ public function __call($function, $args) $styles = array('Paragraph', 'Font', 'Table', 'Numbering', 'Link', 'Title'); foreach ($styles as $style) { - $addStyle[] = strtolower("add{$style}style"); + $addStyle[] = strtolower("add{$style}Style"); } // Run get collection method From 2cb124f5b10c3591d9e0fc10a016fda784dfff58 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 9 Dec 2014 21:35:26 +0400 Subject: [PATCH 155/174] https://github.com/PHPOffice/PHPWord/issues/51 --- README.md | 77 +++++++++++++------- docs/general.rst | 75 ++++++++++++------- docs/src/documentation.md | 75 ++++++++++++------- src/PhpWord/Writer/HTML/Element/ListItem.php | 2 +- src/PhpWord/Writer/HTML/Element/Text.php | 2 +- src/PhpWord/Writer/HTML/Element/Title.php | 2 +- src/PhpWord/Writer/HTML/Part/Head.php | 6 +- 7 files changed, 154 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index f243f05b51..e6e0bf777a 100644 --- a/README.md +++ b/README.md @@ -85,44 +85,67 @@ require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php'; The following is a basic usage example of the PHPWord library. ```php +addSection(); +// Adding Text element to the Section having font styled by default... +$section->addText( + htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') +); + +/* + * Note: it is possible to customize font style of the Text element you add in three ways: + * - inline; + * - using named font style (new font style object will be implicitly created); + * - using explicitly created font style object. + */ + +// Adding Text element having font customized inline... +$section->addText( + htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + array('name' => 'Tahoma', 'size' => 10) +); -// After creating a section, you can append elements: -$section->addText('Hello world!'); - -// You can directly style your text by giving the addText function an array: -$section->addText('Hello world! I am formatted.', - array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); - -// If you often need the same style again you can create a user defined style -// to the word document and give the addText function the name of the style: -$phpWord->addFontStyle('myOwnStyle', - array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); -$section->addText('Hello world! I am formatted by a user defined style', - 'myOwnStyle'); - -// You can also put the appended element to local object like this: -$fontStyle = array( - 'name' => 'Verdana', - 'size' => 22, - 'bold' => true, +// Adding Text element having font customized using named font style... +$fontStyleName = 'oneUserDefinedStyle'; +$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); +$section->addText( + htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + $fontStyleName ); -$myTextElement = $section->addText('Hello World!'); + +// Adding Text element having font customized using explicitly created font style object... +$fontStyle = new \PhpOffice\PhpWord\Style\Font(); +$fontStyle->setBold(true); +$fontStyle->setName('Tahoma'); +$fontStyle->setSize(13); +$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); $myTextElement->setFontStyle($fontStyle); -// Finally, save the document: -$phpWord->save('helloWorld.docx'); -$phpWord->save('helloWorld.odt', 'ODText'); -$phpWord->save('helloWorld.rtf', 'RTF'); +// Saving the document as OOXML file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); +$objWriter->save('helloWorld.docx'); + +// Saving the document as ODF file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); +$objWriter->save('helloWorld.odt'); + +// Saving the document as HTML file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); +$objWriter->save('helloWorld.html'); + +/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ +/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ ``` -:warning: Escape any string you pass to your document, otherwise it may get broken. +:warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken. More examples are provided in the [samples folder](samples/). You can also read the [Developers' Documentation](http://phpword.readthedocs.org/) and the [API Documentation](http://phpoffice.github.io/PHPWord/docs/master/) for more detail. diff --git a/docs/general.rst b/docs/general.rst index 8fc7130eb5..b0edb38de2 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -12,42 +12,65 @@ folder `__. .. code-block:: php + addSection(); + // Adding Text element to the Section having font styled by default... + $section->addText( + htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') + ); + + /* + * Note: it is possible to customize font style of the Text element you add in three ways: + * - inline; + * - using named font style (new font style object will be implicitly created); + * - using explicitly created font style object. + */ + + // Adding Text element having font customized inline... + $section->addText( + htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + array('name' => 'Tahoma', 'size' => 10) + ); - // After creating a section, you can append elements: - $section->addText('Hello world!'); - - // You can directly style your text by giving the addText function an array: - $section->addText('Hello world! I am formatted.', - array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); - - // If you often need the same style again you can create a user defined style - // to the word document and give the addText function the name of the style: - $phpWord->addFontStyle('myOwnStyle', - array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); - $section->addText('Hello world! I am formatted by a user defined style', - 'myOwnStyle'); - - // You can also put the appended element to local object like this: - $fontStyle = array( - 'name' => 'Verdana', - 'size' => 22, - 'bold' => true, + // Adding Text element having font customized using named font style... + $fontStyleName = 'oneUserDefinedStyle'; + $phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); + $section->addText( + htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + $fontStyleName ); - $myTextElement = $section->addText('Hello World!'); + + // Adding Text element having font customized using explicitly created font style object... + $fontStyle = new \PhpOffice\PhpWord\Style\Font(); + $fontStyle->setBold(true); + $fontStyle->setName('Tahoma'); + $fontStyle->setSize(13); + $myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); $myTextElement->setFontStyle($fontStyle); - // Finally, save the document: - $phpWord->save('helloWorld.docx'); - $phpWord->save('helloWorld.odt', 'ODText'); - $phpWord->save('helloWorld.rtf', 'RTF'); + // Saving the document as OOXML file... + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); + $objWriter->save('helloWorld.docx'); + + // Saving the document as ODF file... + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); + $objWriter->save('helloWorld.odt'); + + // Saving the document as HTML file... + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); + $objWriter->save('helloWorld.html'); + + /* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ + /* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ Settings -------- diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 3e7d41b0a2..434360482e 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -212,42 +212,65 @@ After installation, you can browse and use the samples that we've provided, eith The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](https://github.com/PHPOffice/PHPWord/tree/master/samples/). ```php +addSection(); +// Adding Text element to the Section having font styled by default... +$section->addText( + htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') +); + +/* + * Note: it is possible to customize font style of the Text element you add in three ways: + * - inline; + * - using named font style (new font style object will be implicitly created); + * - using explicitly created font style object. + */ + +// Adding Text element having font customized inline... +$section->addText( + htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + array('name' => 'Tahoma', 'size' => 10) +); -// After creating a section, you can append elements: -$section->addText('Hello world!'); - -// You can directly style your text by giving the addText function an array: -$section->addText('Hello world! I am formatted.', - array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); - -// If you often need the same style again you can create a user defined style -// to the word document and give the addText function the name of the style: -$phpWord->addFontStyle('myOwnStyle', - array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); -$section->addText('Hello world! I am formatted by a user defined style', - 'myOwnStyle'); - -// You can also put the appended element to local object like this: -$fontStyle = array( - 'name' => 'Verdana', - 'size' => 22, - 'bold' => true, +// Adding Text element having font customized using named font style... +$fontStyleName = 'oneUserDefinedStyle'; +$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); +$section->addText( + htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + $fontStyleName ); -$myTextElement = $section->addText('Hello World!'); + +// Adding Text element having font customized using explicitly created font style object... +$fontStyle = new \PhpOffice\PhpWord\Style\Font(); +$fontStyle->setBold(true); +$fontStyle->setName('Tahoma'); +$fontStyle->setSize(13); +$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); $myTextElement->setFontStyle($fontStyle); -// Finally, save the document: -$phpWord->save('helloWorld.docx'); -$phpWord->save('helloWorld.odt', 'ODText'); -$phpWord->save('helloWorld.rtf', 'RTF'); +// Saving the document as OOXML file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); +$objWriter->save('helloWorld.docx'); + +// Saving the document as ODF file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); +$objWriter->save('helloWorld.odt'); + +// Saving the document as HTML file... +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); +$objWriter->save('helloWorld.html'); + +/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ +/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ ``` ## Settings diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php index 79a3b393d2..ef8eb34d75 100644 --- a/src/PhpWord/Writer/HTML/Element/ListItem.php +++ b/src/PhpWord/Writer/HTML/Element/ListItem.php @@ -35,7 +35,7 @@ public function write() return ''; } - $text = htmlspecialchars($this->element->getTextObject()->getText()); + $text = $this->element->getTextObject()->getText(); $content = '

' . $text . '

' . PHP_EOL; return $content; diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index c2d4134a52..0c31df3632 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -72,7 +72,7 @@ public function write() $content .= $this->writeOpening(); $content .= $this->openingText; $content .= $this->openingTags; - $content .= htmlspecialchars($element->getText()); + $content .= $element->getText(); $content .= $this->closingTags; $content .= $this->closingText; $content .= $this->writeClosing(); diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php index 20747bf9ec..c054ccf98b 100644 --- a/src/PhpWord/Writer/HTML/Element/Title.php +++ b/src/PhpWord/Writer/HTML/Element/Title.php @@ -36,7 +36,7 @@ public function write() } $tag = 'h' . $this->element->getDepth(); - $text = htmlspecialchars($this->element->getText()); + $text = $this->element->getText(); $content = "<{$tag}>{$text}" . PHP_EOL; return $content; diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index 7339c74c52..503f75b879 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -18,9 +18,9 @@ namespace PhpOffice\PhpWord\Writer\HTML\Part; use PhpOffice\PhpWord\Settings; +use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; -use PhpOffice\PhpWord\Style; 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; @@ -57,13 +57,13 @@ public function write() $content .= '' . PHP_EOL; $content .= '' . PHP_EOL; - $content .= '' . htmlspecialchars($title) . '' . PHP_EOL; + $content .= '' . $title . '' . PHP_EOL; foreach ($propertiesMapping as $key => $value) { $value = ($value == '') ? $key : $value; $method = "get" . $key; if ($docProps->$method() != '') { $content .= '' . PHP_EOL; + $docProps->$method() . '" />' . PHP_EOL; } } $content .= $this->writeStyles(); From fa7f2cdc25b780d580ff5ce43bd8280696802637 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 9 Dec 2014 21:46:19 +0400 Subject: [PATCH 156/174] https://github.com/PHPOffice/PHPWord/issues/51 --- README.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e6e0bf777a..f0f2ae2ea3 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,15 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); // Adding Text element to the Section having font styled by default... $section->addText( - htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') + htmlspecialchars( + '"Learn from yesterday, live for today, hope for tomorrow. ' + . 'The important thing is not to stop questioning." ' + . '(Albert Einstein)' + ) ); /* - * Note: it is possible to customize font style of the Text element you add in three ways: + * Note: it's possible to customize font style of the Text element you add in three ways: * - inline; * - using named font style (new font style object will be implicitly created); * - using explicitly created font style object. @@ -110,15 +114,26 @@ $section->addText( // Adding Text element having font customized inline... $section->addText( - htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + htmlspecialchars( + '"Great achievement is usually born of great sacrifice, ' + . 'and is never the result of selfishness." ' + . '(Napoleon Hill)' + ), array('name' => 'Tahoma', 'size' => 10) ); // Adding Text element having font customized using named font style... $fontStyleName = 'oneUserDefinedStyle'; -$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); +$phpWord->addFontStyle( + $fontStyleName, + array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true) +); $section->addText( - htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + htmlspecialchars( + '"The greatest accomplishment is not in never falling, ' + . 'but in rising again after you fall." ' + . '(Vince Lombardi)' + ), $fontStyleName ); @@ -127,7 +142,9 @@ $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Tahoma'); $fontStyle->setSize(13); -$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); +$myTextElement = $section->addText( + htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)') +); $myTextElement->setFontStyle($fontStyle); // Saving the document as OOXML file... @@ -142,8 +159,8 @@ $objWriter->save('helloWorld.odt'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('helloWorld.html'); -/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ -/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ +/* Note: RTF was skipped, because it's not XML-based and requires a different example. */ +/* Note: PDF was skipped, because we use "HTML-to-PDF" approach to create PDF documents. */ ``` :warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken. From 41983e01f3fdb62de5790872934a9d127d9c8d04 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 9 Dec 2014 21:52:17 +0400 Subject: [PATCH 157/174] Merge pull request #356 from GMTA/develop --- README.md | 10 +++++----- docs/general.rst | 39 ++++++++++++++++++++++++++++----------- docs/src/documentation.md | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index f0f2ae2ea3..8f499a8ebb 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ $section->addText( * - using explicitly created font style object. */ -// Adding Text element having font customized inline... +// Adding Text element with font customized inline... $section->addText( htmlspecialchars( '"Great achievement is usually born of great sacrifice, ' @@ -122,7 +122,7 @@ $section->addText( array('name' => 'Tahoma', 'size' => 10) ); -// Adding Text element having font customized using named font style... +// Adding Text element with font customized using named font style... $fontStyleName = 'oneUserDefinedStyle'; $phpWord->addFontStyle( $fontStyleName, @@ -137,7 +137,7 @@ $section->addText( $fontStyleName ); -// Adding Text element having font customized using explicitly created font style object... +// Adding Text element with font customized using explicitly created font style object... $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Tahoma'); @@ -159,8 +159,8 @@ $objWriter->save('helloWorld.odt'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('helloWorld.html'); -/* Note: RTF was skipped, because it's not XML-based and requires a different example. */ -/* Note: PDF was skipped, because we use "HTML-to-PDF" approach to create PDF documents. */ +/* Note: we skip RTF, because it's not XML-based and requires a different example. */ +/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */ ``` :warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken. diff --git a/docs/general.rst b/docs/general.rst index b0edb38de2..34d3af2477 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -25,36 +25,53 @@ folder `__. $section = $phpWord->addSection(); // Adding Text element to the Section having font styled by default... $section->addText( - htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') + htmlspecialchars( + '"Learn from yesterday, live for today, hope for tomorrow. ' + . 'The important thing is not to stop questioning." ' + . '(Albert Einstein)' + ) ); /* - * Note: it is possible to customize font style of the Text element you add in three ways: + * Note: it's possible to customize font style of the Text element you add in three ways: * - inline; * - using named font style (new font style object will be implicitly created); * - using explicitly created font style object. */ - // Adding Text element having font customized inline... + // Adding Text element with font customized inline... $section->addText( - htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + htmlspecialchars( + '"Great achievement is usually born of great sacrifice, ' + . 'and is never the result of selfishness." ' + . '(Napoleon Hill)' + ), array('name' => 'Tahoma', 'size' => 10) ); - // Adding Text element having font customized using named font style... + // Adding Text element with font customized using named font style... $fontStyleName = 'oneUserDefinedStyle'; - $phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); + $phpWord->addFontStyle( + $fontStyleName, + array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true) + ); $section->addText( - htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + htmlspecialchars( + '"The greatest accomplishment is not in never falling, ' + . 'but in rising again after you fall." ' + . '(Vince Lombardi)' + ), $fontStyleName ); - // Adding Text element having font customized using explicitly created font style object... + // Adding Text element with font customized using explicitly created font style object... $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Tahoma'); $fontStyle->setSize(13); - $myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); + $myTextElement = $section->addText( + htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)') + ); $myTextElement->setFontStyle($fontStyle); // Saving the document as OOXML file... @@ -69,8 +86,8 @@ folder `__. $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('helloWorld.html'); - /* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ - /* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ + /* Note: we skip RTF, because it's not XML-based and requires a different example. */ + /* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */ Settings -------- diff --git a/docs/src/documentation.md b/docs/src/documentation.md index 434360482e..1a59e94230 100644 --- a/docs/src/documentation.md +++ b/docs/src/documentation.md @@ -225,36 +225,53 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); // Adding Text element to the Section having font styled by default... $section->addText( - htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)') + htmlspecialchars( + '"Learn from yesterday, live for today, hope for tomorrow. ' + . 'The important thing is not to stop questioning." ' + . '(Albert Einstein)' + ) ); /* - * Note: it is possible to customize font style of the Text element you add in three ways: + * Note: it's possible to customize font style of the Text element you add in three ways: * - inline; * - using named font style (new font style object will be implicitly created); * - using explicitly created font style object. */ -// Adding Text element having font customized inline... +// Adding Text element with font customized inline... $section->addText( - htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'), + htmlspecialchars( + '"Great achievement is usually born of great sacrifice, ' + . 'and is never the result of selfishness." ' + . '(Napoleon Hill)' + ), array('name' => 'Tahoma', 'size' => 10) ); -// Adding Text element having font customized using named font style... +// Adding Text element with font customized using named font style... $fontStyleName = 'oneUserDefinedStyle'; -$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)); +$phpWord->addFontStyle( + $fontStyleName, + array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true) +); $section->addText( - htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'), + htmlspecialchars( + '"The greatest accomplishment is not in never falling, ' + . 'but in rising again after you fall." ' + . '(Vince Lombardi)' + ), $fontStyleName ); -// Adding Text element having font customized using explicitly created font style object... +// Adding Text element with font customized using explicitly created font style object... $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Tahoma'); $fontStyle->setSize(13); -$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')); +$myTextElement = $section->addText( + htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)') +); $myTextElement->setFontStyle($fontStyle); // Saving the document as OOXML file... @@ -269,8 +286,8 @@ $objWriter->save('helloWorld.odt'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('helloWorld.html'); -/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */ -/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */ +/* Note: we skip RTF, because it's not XML-based and requires a different example. */ +/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */ ``` ## Settings From 9e36c29a645458ef1c04e0cb2020aee1fc5a17e9 Mon Sep 17 00:00:00 2001 From: chc88 Date: Wed, 10 Dec 2014 15:47:12 +0100 Subject: [PATCH 158/174] Update pdf-generation Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59cbba6cf4..1419f60cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +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.2 - 10 December 2014 +- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 + ## 0.11.1 - 2 June 2014 This is an immediate bugfix release for HTML reader. From d330e57018ba69230b7704c6f2c0f638f5d6a8e0 Mon Sep 17 00:00:00 2001 From: chc88 Date: Wed, 10 Dec 2014 15:49:40 +0100 Subject: [PATCH 159/174] Update PageBreak.php Update pdf-generation; check if we're generating a pdf --- src/PhpWord/Writer/HTML/Element/PageBreak.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index 403ca129d9..8cd5906e69 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -31,6 +31,11 @@ class PageBreak extends TextBreak */ public function write() { - return ''; + /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ + $parentWriter = $this->parentWriter; + if ($parentWriter->isPdf()) { + return ''; + } + return ""; } } From 9b58606696b85e438263a7e2fc4346c69ae7d40c Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 10 Dec 2014 19:56:04 +0100 Subject: [PATCH 160/174] Merge PR #441 --- CHANGELOG.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1419f60cb9..3a33ad8669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,66 @@ 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.2 - 10 December 2014 +## 0.12.0 - Not yet released + +This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced. + +### Features + +- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 +- Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin +- Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 +- RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 +- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 +- General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin +- General: New `Shared\Converter` static class - @ivanlanin +- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 +- Chart: 3D charts and ability to set width and height - @ivanlanin +- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 +- Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin +- Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin +- SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin +- Paragraph: Support for paragraph with borders - @ivanlanin GH-294 +- Word2007 Writer : Support for RTL - @Progi1984 GH-331 +- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287 +- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302 - Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 +### Bugfixes + +- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 +- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 +- Page breaks on titles and tables - @ivanlanin GH-274 +- Table inside vertical border does not rendered properly - @ivanlanin GH-280 +- `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 +- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 +- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 +- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 +- `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. +- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401 +- `` tag is closed with `` tag: - @franzholz GH-438 + +### Deprecated + +- `Element\Link::getTarget()` replaced by `Element\Link::getSource()` +- `Element\Section::getSettings()` and `Element\Section::setSettings()` replaced by `Element\Section::getStyle()` and `Element\Section::setStyle()` +- `Shared\Drawing` and `Shared\Font` merged into `Shared\Converter` +- `DocumentProperties` replaced by `Metadata\DocInfo` +- `Template` replaced by `TemplateProcessor` +- `PhpWord->loadTemplate($filename)` + +### Miscellaneous + +- Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 +- Docs: Correct elements.rst about Line - @chrissharkman GH-292 +- PclZip: Remove temporary file after used - @andrew-kzoo GH-265 +- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 +- Element: Refactor elements to move set relation Id from container to element - @ivanlanin +- Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko +- Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 +- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 +- Reverted GH-51 - @RomanSyroeshko + ## 0.11.1 - 2 June 2014 This is an immediate bugfix release for HTML reader. From 6490b7e60d1096488652f19bf57afe77d6a7e51f Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 11 Dec 2014 22:33:55 +0100 Subject: [PATCH 161/174] UPDATED : composer.lock --- composer.lock | 1175 ++++++++++++++++++++++++++++++------------------- 1 file changed, 710 insertions(+), 465 deletions(-) diff --git a/composer.lock b/composer.lock index 122d7ab2bf..47351b0efd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,10 +4,8 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "50bae1209285a67796556b7ec42f64fc", - "packages": [ - - ], + "hash": "1a31c30080e1b0b550cdb47b7f764ca6", + "packages": [], "packages-dev": [ { "name": "cilex/cilex", @@ -129,16 +127,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.1.2", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "40db0c96985aab2822edbc4848b3bd2429e02670" + "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/40db0c96985aab2822edbc4848b3bd2429e02670", - "reference": "40db0c96985aab2822edbc4848b3bd2429e02670", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/6a6bec0670bb6e71a263b08bc1b98ea242928633", + "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633", "shasum": "" }, "require": { @@ -146,12 +144,13 @@ "php": ">=5.3.2" }, "require-dev": { - "doctrine/cache": "1.*" + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -164,17 +163,6 @@ "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" @@ -184,10 +172,16 @@ "email": "kontakt@beberlei.de" }, { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", - "role": "Developer of wrapped JMSSerializerBundle" + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" } ], "description": "Docblock Annotations Parser", @@ -197,7 +191,7 @@ "docblock", "parser" ], - "time": "2013-06-16 21:33:03" + "time": "2014-09-25 16:45:30" }, { "name": "doctrine/lexer", @@ -294,16 +288,16 @@ }, { "name": "erusev/parsedown", - "version": "0.9.4", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f" + "reference": "495e7ac73bb5fde6b857b88ff2bb1b5e79a4263a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/d29ff18299210b52a75a631a70963e7c8b35b04f", - "reference": "d29ff18299210b52a75a631a70963e7c8b35b04f", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/495e7ac73bb5fde6b857b88ff2bb1b5e79a4263a", + "reference": "495e7ac73bb5fde6b857b88ff2bb1b5e79a4263a", "shasum": "" }, "type": "library", @@ -329,20 +323,139 @@ "markdown", "parser" ], - "time": "2014-02-06 12:16:14" + "time": "2014-11-29 02:29:14" + }, + { + "name": "herrera-io/json", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/herrera-io/php-json.git", + "reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/herrera-io/php-json/zipball/60c696c9370a1e5136816ca557c17f82a6fa83f1", + "reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1", + "shasum": "" + }, + "require": { + "ext-json": "*", + "justinrainbow/json-schema": ">=1.0,<2.0-dev", + "php": ">=5.3.3", + "seld/jsonlint": ">=1.0,<2.0-dev" + }, + "require-dev": { + "herrera-io/phpunit-test-case": "1.*", + "mikey179/vfsstream": "1.1.0", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/lib/json_version.php" + ], + "psr-0": { + "Herrera\\Json": "src/lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io/", + "role": "Developer" + } + ], + "description": "A library for simplifying JSON linting and validation.", + "homepage": "http://herrera-io.github.com/php-json", + "keywords": [ + "json", + "lint", + "schema", + "validate" + ], + "time": "2013-10-30 16:51:34" + }, + { + "name": "herrera-io/phar-update", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/herrera-io/php-phar-update.git", + "reference": "00a79e1d5b8cf3c080a2e3becf1ddf7a7fea025b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/herrera-io/php-phar-update/zipball/00a79e1d5b8cf3c080a2e3becf1ddf7a7fea025b", + "reference": "00a79e1d5b8cf3c080a2e3becf1ddf7a7fea025b", + "shasum": "" + }, + "require": { + "herrera-io/json": "1.*", + "kherge/version": "1.*", + "php": ">=5.3.3" + }, + "require-dev": { + "herrera-io/phpunit-test-case": "1.*", + "mikey179/vfsstream": "1.1.0", + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/lib/constants.php" + ], + "psr-0": { + "Herrera\\Phar\\Update": "src/lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io/", + "role": "Developer" + } + ], + "description": "A library for self-updating Phars.", + "homepage": "http://herrera-io.github.com/php-phar-update", + "keywords": [ + "phar", + "update" + ], + "time": "2013-10-30 17:23:01" }, { "name": "jms/metadata", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/schmittjoh/metadata.git", - "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459" + "reference": "22b72455559a25777cfd28c4ffda81ff7639f353" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/88ffa28bc987e4c26229fc84a2e541b6ed4e1459", - "reference": "88ffa28bc987e4c26229fc84a2e541b6ed4e1459", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/22b72455559a25777cfd28c4ffda81ff7639f353", + "reference": "22b72455559a25777cfd28c4ffda81ff7639f353", "shasum": "" }, "require": { @@ -368,9 +481,9 @@ ], "authors": [ { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -381,7 +494,7 @@ "xml", "yaml" ], - "time": "2013-11-05 23:02:36" + "time": "2014-07-12 07:13:19" }, { "name": "jms/parser-lib", @@ -489,94 +602,143 @@ "time": "2014-03-18 08:39:00" }, { - "name": "knplabs/knp-menu", - "version": "v1.1.2", + "name": "justinrainbow/json-schema", + "version": "1.3.7", "source": { "type": "git", - "url": "https://github.com/KnpLabs/KnpMenu.git", - "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873" + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "87b54b460febed69726c781ab67462084e97a105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/KnpLabs/KnpMenu/zipball/f8e867268f63f561c1adadd6cbb5d8524f921873", - "reference": "f8e867268f63f561c1adadd6cbb5d8524f921873", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/87b54b460febed69726c781ab67462084e97a105", + "reference": "87b54b460febed69726c781ab67462084e97a105", "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" + "json-schema/json-schema-test-suite": "1.1.0", + "phpdocumentor/phpdocumentor": "~2", + "phpunit/phpunit": "~3.7" }, + "bin": [ + "bin/validate-json" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { "psr-0": { - "Knp\\Menu\\": "src/" + "JsonSchema": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Christophe Coevoet", - "email": "stof@notk.org" + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" }, { - "name": "KnpLabs", - "homepage": "http://knplabs.com" + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" }, { - "name": "Symfony Community", - "homepage": "https://github.com/KnpLabs/KnpMenu/contributors" + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" } ], - "description": "An object oriented menu library", - "homepage": "http://knplabs.com", + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", "keywords": [ - "menu", - "tree" + "json", + "schema" + ], + "time": "2014-08-25 02:48:14" + }, + { + "name": "kherge/version", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/kherge-unmaintained/Version.git", + "reference": "f07cf83f8ce533be8f93d2893d96d674bbeb7e30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kherge-unmaintained/Version/zipball/f07cf83f8ce533be8f93d2893d96d674bbeb7e30", + "reference": "f07cf83f8ce533be8f93d2893d96d674bbeb7e30", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "KevinGH\\Version": "src/lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "me@kevingh.com", + "homepage": "http://www.kevingh.com/" + } ], - "time": "2012-06-10 16:20:40" + "description": "A parsing and comparison library for semantic versioning.", + "homepage": "http://github.com/kherge/Version", + "time": "2012-08-16 17:13:03" }, { "name": "monolog/monolog", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "25b16e801979098cb2f120e697bfce454b18bf23" + "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/25b16e801979098cb2f120e697bfce454b18bf23", - "reference": "25b16e801979098cb2f120e697bfce454b18bf23", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", + "reference": "ec3961874c43840e96da3a8a1ed20d8c73d7e5aa", "shasum": "" }, "require": { "php": ">=5.3.0", "psr/log": "~1.0" }, + "provide": { + "psr/log-implementation": "1.0.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.*" + "ruflin/elastica": "0.90.*", + "videlalvaro/php-amqplib": "~2.4" }, "suggest": { "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", @@ -586,12 +748,13 @@ "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" + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -607,8 +770,7 @@ { "name": "Jordi Boggiano", "email": "j.boggiano@seld.be", - "homepage": "http://seld.be", - "role": "Developer" + "homepage": "http://seld.be" } ], "description": "Sends your logs to files, sockets, inboxes, databases and various web services", @@ -618,20 +780,20 @@ "logging", "psr-3" ], - "time": "2014-06-04 16:30:04" + "time": "2014-09-30 13:30:58" }, { "name": "mpdf/mpdf", - "version": "v5.7.2", + "version": "v5.7.3", "source": { "type": "git", "url": "https://github.com/finwe/mpdf.git", - "reference": "1627f9e7d2ef0f635a886f611079216ed2929717" + "reference": "ace190986978df40b9c416cf7ba8761945fc1758" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/finwe/mpdf/zipball/1627f9e7d2ef0f635a886f611079216ed2929717", - "reference": "1627f9e7d2ef0f635a886f611079216ed2929717", + "url": "https://api.github.com/repos/finwe/mpdf/zipball/ace190986978df40b9c416cf7ba8761945fc1758", + "reference": "ace190986978df40b9c416cf7ba8761945fc1758", "shasum": "" }, "require": { @@ -661,23 +823,24 @@ "php", "utf-8" ], - "time": "2014-05-16 07:18:10" + "time": "2014-08-24 08:33:20" }, { "name": "nikic/php-parser", - "version": "v0.9.4", + "version": "v0.9.5", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", - "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ef70767475434bdb3615b43c327e2cae17ef12eb", + "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb", "shasum": "" }, "require": { + "ext-tokenizer": "*", "php": ">=5.2" }, "type": "library", @@ -705,29 +868,29 @@ "parser", "php" ], - "time": "2013-08-25 17:11:40" + "time": "2014-07-23 18:24:17" }, { "name": "pdepend/pdepend", - "version": "2.0.0", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "b74f2bb68e86104cd97dfb8d74209692c9b465ce" + "reference": "1b0acf162da4f30237987e61e177a57f78e3d87e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b74f2bb68e86104cd97dfb8d74209692c9b465ce", - "reference": "b74f2bb68e86104cd97dfb8d74209692c9b465ce", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/1b0acf162da4f30237987e61e177a57f78e3d87e", + "reference": "1b0acf162da4f30237987e61e177a57f78e3d87e", "shasum": "" }, "require": { - "symfony/config": "@stable", - "symfony/dependency-injection": "@stable", - "symfony/filesystem": "@stable" + "symfony/config": ">=2.4", + "symfony/dependency-injection": ">=2.4", + "symfony/filesystem": ">=2.4" }, "require-dev": { - "phpunit/phpunit": "3.*@stable", + "phpunit/phpunit": "4.*@stable", "squizlabs/php_codesniffer": "@stable" }, "bin": [ @@ -744,7 +907,7 @@ "BSD-3-Clause" ], "description": "Official version of pdepend to be handled with Composer", - "time": "2014-05-21 09:48:10" + "time": "2014-12-04 12:38:39" }, { "name": "phenx/php-font-lib", @@ -875,16 +1038,16 @@ }, { "name": "phpdocumentor/graphviz", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/GraphViz.git", - "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc" + "reference": "aa243118c8a055fc853c02802e8503c5435862f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/GraphViz/zipball/13595130b9bc185109f40f1b70f0b231f490f5fc", - "reference": "13595130b9bc185109f40f1b70f0b231f490f5fc", + "url": "https://api.github.com/repos/phpDocumentor/GraphViz/zipball/aa243118c8a055fc853c02802e8503c5435862f7", + "reference": "aa243118c8a055fc853c02802e8503c5435862f7", "shasum": "" }, "require": { @@ -912,28 +1075,28 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2014-02-26 17:45:01" + "time": "2014-07-19 06:52:59" }, { "name": "phpdocumentor/phpdocumentor", - "version": "v2.5.0", + "version": "v2.8.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/phpDocumentor2.git", - "reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216" + "reference": "5920dd42a5a92e4486f342ba8ded979db149ceb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/bf9fa40f6d00412410025b2e16eb16c315eb0216", - "reference": "bf9fa40f6d00412410025b2e16eb16c315eb0216", + "url": "https://api.github.com/repos/phpDocumentor/phpDocumentor2/zipball/5920dd42a5a92e4486f342ba8ded979db149ceb2", + "reference": "5920dd42a5a92e4486f342ba8ded979db149ceb2", "shasum": "" }, "require": { "cilex/cilex": "~1.0", "dompdf/dompdf": "~0.6", - "erusev/parsedown": "~0.7", + "erusev/parsedown": "~1.0", + "herrera-io/phar-update": "1.0.3", "jms/serializer": "~0.12", - "knplabs/knp-menu": "~1.1", "monolog/monolog": "~1.6", "php": ">=5.3.3", "phpdocumentor/fileset": "~1.0", @@ -956,20 +1119,20 @@ "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.*", + "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", + "mockery/mockery": "~0.9@dev", + "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "~1.4", "symfony/expression-language": "~2.4" }, @@ -984,7 +1147,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-develop": "2.5-dev" + "dev-develop": "2.9-dev" } }, "autoload": { @@ -992,6 +1155,9 @@ "phpDocumentor": [ "src/", "tests/unit/" + ], + "Cilex\\Provider": [ + "src/" ] } }, @@ -1008,34 +1174,39 @@ "documentation", "phpdoc" ], - "time": "2014-05-17 12:25:35" + "time": "2014-11-11 14:08:43" }, { "name": "phpdocumentor/reflection", - "version": "1.0.5", + "version": "1.0.7", "source": { "type": "git", "url": "https://github.com/phpDocumentor/Reflection.git", - "reference": "df82db631acd60739c8796b3c6d5e4da970808f3" + "reference": "fc40c3f604ac2287eb5c314174d5109b2c699372" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/df82db631acd60739c8796b3c6d5e4da970808f3", - "reference": "df82db631acd60739c8796b3c6d5e4da970808f3", + "url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/fc40c3f604ac2287eb5c314174d5109b2c699372", + "reference": "fc40c3f604ac2287eb5c314174d5109b2c699372", "shasum": "" }, "require": { - "nikic/php-parser": "0.9.4", + "nikic/php-parser": "~0.9.4", "php": ">=5.3.3", - "phpdocumentor/reflection-docblock": "2.*", + "phpdocumentor/reflection-docblock": "~2.0", "psr/log": "~1.0" }, "require-dev": { "behat/behat": "~2.4", - "mockery/mockery": ">=0.7.0", - "phpunit/phpunit": "~3.7" + "mockery/mockery": "~0.8", + "phpunit/phpunit": "~4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { "psr-0": { "phpDocumentor": [ @@ -1057,20 +1228,20 @@ "reflection", "static analysis" ], - "time": "2014-03-28 11:20:22" + "time": "2014-11-14 11:43:04" }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "0bca477a34baea39add016af90046f002a175619" + "reference": "38743b677965c48a637097b2746a281264ae2347" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0bca477a34baea39add016af90046f002a175619", - "reference": "0bca477a34baea39add016af90046f002a175619", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/38743b677965c48a637097b2746a281264ae2347", + "reference": "38743b677965c48a637097b2746a281264ae2347", "shasum": "" }, "require": { @@ -1106,24 +1277,23 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2014-03-28 09:21:30" + "time": "2014-08-09 10:27:07" }, { "name": "phpdocumentor/template-abstract", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.abstract.git", - "reference": "43fa2db351d7a150803397721e778f9dd8a20b47" + "reference": "df1d11cf11cf5da433789e2be07f4d2d6e51aaca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.abstract/zipball/43fa2db351d7a150803397721e778f9dd8a20b47", - "reference": "43fa2db351d7a150803397721e778f9dd8a20b47", + "url": "https://api.github.com/repos/phpDocumentor/template.abstract/zipball/df1d11cf11cf5da433789e2be07f4d2d6e51aaca", + "reference": "df1d11cf11cf5da433789e2be07f4d2d6e51aaca", "shasum": "" }, "require": { - "ext-xsl": "*", "phpdocumentor/unified-asset-installer": "~1.1" }, "type": "phpdocumentor-template", @@ -1138,24 +1308,23 @@ "phpdoc", "template" ], - "time": "2013-08-02 06:11:13" + "time": "2014-06-04 19:32:56" }, { "name": "phpdocumentor/template-checkstyle", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.checkstyle.git", - "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b" + "reference": "cfa86d19327b0d762332787ff2dda0d55226a2e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.checkstyle/zipball/22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", - "reference": "22a45684e737c8c3ec3f1a12edb7743b7a82ac8b", + "url": "https://api.github.com/repos/phpDocumentor/template.checkstyle/zipball/cfa86d19327b0d762332787ff2dda0d55226a2e2", + "reference": "cfa86d19327b0d762332787ff2dda0d55226a2e2", "shasum": "" }, "require": { - "ext-xsl": "*", "phpdocumentor/unified-asset-installer": "~1.1" }, "type": "phpdocumentor-template", @@ -1170,20 +1339,20 @@ "phpdoc", "template" ], - "time": "2013-08-01 19:43:19" + "time": "2014-08-17 19:32:38" }, { "name": "phpdocumentor/template-clean", - "version": "1.0.4", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.clean.git", - "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806" + "reference": "6fc0f7f6c55c1f94ac5b1c6fccde7aac77755e45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.clean/zipball/78f2048c5ecd62f0b79dbac093687d78a66d1806", - "reference": "78f2048c5ecd62f0b79dbac093687d78a66d1806", + "url": "https://api.github.com/repos/phpDocumentor/template.clean/zipball/6fc0f7f6c55c1f94ac5b1c6fccde7aac77755e45", + "reference": "6fc0f7f6c55c1f94ac5b1c6fccde7aac77755e45", "shasum": "" }, "require": { @@ -1202,24 +1371,23 @@ "responsive", "template" ], - "time": "2014-03-29 08:22:15" + "time": "2014-08-15 21:45:34" }, { "name": "phpdocumentor/template-new-black", - "version": "1.3.1", + "version": "1.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.new_black.git", - "reference": "be38beba2b2674be292f32f88efe8a60c658a139" + "reference": "d98f84633b94b279582735aecd91015c1e191d98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.new_black/zipball/be38beba2b2674be292f32f88efe8a60c658a139", - "reference": "be38beba2b2674be292f32f88efe8a60c658a139", + "url": "https://api.github.com/repos/phpDocumentor/template.new_black/zipball/d98f84633b94b279582735aecd91015c1e191d98", + "reference": "d98f84633b94b279582735aecd91015c1e191d98", "shasum": "" }, "require": { - "ext-xsl": "*", "phpdocumentor/template-abstract": "1.*", "phpdocumentor/unified-asset-installer": "~1.1" }, @@ -1235,24 +1403,23 @@ "phpdoc", "template" ], - "time": "2013-08-02 06:16:30" + "time": "2014-06-27 17:00:31" }, { "name": "phpdocumentor/template-old-ocean", - "version": "1.3.1", + "version": "1.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.old_ocean.git", - "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489" + "reference": "2fdb786038351c0ec88633d4e2aa103e4bbb8655" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.old_ocean/zipball/3a0e2bcced4045a694d53b4607aad04e99d78489", - "reference": "3a0e2bcced4045a694d53b4607aad04e99d78489", + "url": "https://api.github.com/repos/phpDocumentor/template.old_ocean/zipball/2fdb786038351c0ec88633d4e2aa103e4bbb8655", + "reference": "2fdb786038351c0ec88633d4e2aa103e4bbb8655", "shasum": "" }, "require": { - "ext-xsl": "*", "phpdocumentor/unified-asset-installer": "~1.1" }, "type": "phpdocumentor-template", @@ -1267,24 +1434,23 @@ "phpdoc", "template" ], - "time": "2013-08-02 06:21:07" + "time": "2014-06-27 16:59:35" }, { "name": "phpdocumentor/template-responsive", - "version": "1.3.3", + "version": "1.3.5", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.responsive.git", - "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1" + "reference": "949e742f350f70fc8ec7c945b3cf0070a4e1825e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.responsive/zipball/26f895a2ed3148e1686ae4d802f65a3ef04c04e1", - "reference": "26f895a2ed3148e1686ae4d802f65a3ef04c04e1", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive/zipball/949e742f350f70fc8ec7c945b3cf0070a4e1825e", + "reference": "949e742f350f70fc8ec7c945b3cf0070a4e1825e", "shasum": "" }, "require": { - "ext-xsl": "*", "phpdocumentor/unified-asset-installer": "~1.1" }, "type": "phpdocumentor-template", @@ -1299,20 +1465,20 @@ "phpdoc", "template" ], - "time": "2014-03-29 08:55:54" + "time": "2014-08-05 20:47:53" }, { "name": "phpdocumentor/template-responsive-twig", - "version": "1.2.3", + "version": "1.2.5", "source": { "type": "git", "url": "https://github.com/phpDocumentor/template.responsive-twig.git", - "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a" + "reference": "493e204be607583efd2d75f1728cd5210e23cf96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/template.responsive-twig/zipball/cd6d82be6a4626d865fd01d40aad170cea08db0a", - "reference": "cd6d82be6a4626d865fd01d40aad170cea08db0a", + "url": "https://api.github.com/repos/phpDocumentor/template.responsive-twig/zipball/493e204be607583efd2d75f1728cd5210e23cf96", + "reference": "493e204be607583efd2d75f1728cd5210e23cf96", "shasum": "" }, "require": { @@ -1330,7 +1496,7 @@ "phpdoc", "template" ], - "time": "2014-03-30 21:02:00" + "time": "2014-07-30 20:00:37" }, { "name": "phpdocumentor/template-xml", @@ -1448,24 +1614,24 @@ }, { "name": "phploc/phploc", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phploc.git", - "reference": "d177c22e2a08e448f7bdfa762045f7bd086834d7" + "reference": "322ad07c112d5c6832abed4269d648cacff5959b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phploc/zipball/d177c22e2a08e448f7bdfa762045f7bd086834d7", - "reference": "d177c22e2a08e448f7bdfa762045f7bd086834d7", + "url": "https://api.github.com/repos/sebastianbergmann/phploc/zipball/322ad07c112d5c6832abed4269d648cacff5959b", + "reference": "322ad07c112d5c6832abed4269d648cacff5959b", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/finder-facade": ">=1.1.0", - "sebastian/git": ">=1.0.0", - "sebastian/version": ">=1.0.3", - "symfony/console": ">=2.2.0" + "sebastian/finder-facade": "~1.1", + "sebastian/git": "~1.0", + "sebastian/version": "~1.0", + "symfony/console": "~2.2" }, "bin": [ "phploc" @@ -1494,28 +1660,28 @@ ], "description": "A tool for quickly measuring the size of a PHP project.", "homepage": "https://github.com/sebastianbergmann/phploc", - "time": "2014-04-27 06:47:27" + "time": "2014-06-25 08:11:02" }, { "name": "phpmd/phpmd", - "version": "2.0.0", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "68ced5452910d3555a38720bd87f5f2356c5a003" + "reference": "1a485d9db869137af5e9678bd844568c92998b25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/68ced5452910d3555a38720bd87f5f2356c5a003", - "reference": "68ced5452910d3555a38720bd87f5f2356c5a003", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/1a485d9db869137af5e9678bd844568c92998b25", + "reference": "1a485d9db869137af5e9678bd844568c92998b25", "shasum": "" }, "require": { "pdepend/pdepend": "2.0.*", "php": ">=5.3.0", - "symfony/config": "@stable", - "symfony/dependency-injection": "@stable", - "symfony/filesystem": "@stable" + "symfony/config": "2.5.*", + "symfony/dependency-injection": "2.5.*", + "symfony/filesystem": "2.5.*" }, "bin": [ "src/bin/phpmd" @@ -1523,20 +1689,15 @@ "type": "library", "autoload": { "psr-0": { - "PHPMD\\": "src/main/php", - "PDepend\\": "vendor/pdepend/pdepend/src/main/php/" + "PHPMD\\": "src/main/php" } }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "../../pdepend/pdepend/src/main/php", - "src/main/php" - ], "license": [ "BSD-3-Clause" ], "description": "Official version of PHPMD handled with Composer.", - "time": "2014-05-21 12:45:23" + "time": "2014-09-25 15:56:22" }, { "name": "phpoption/phpoption", @@ -1589,23 +1750,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.17", + "version": "1.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34" + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", - "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", "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" + "phpunit/php-token-stream": ">=1.1.3,<1.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.*@dev" @@ -1646,7 +1807,7 @@ "testing", "xunit" ], - "time": "2014-03-28 10:53:45" + "time": "2014-09-02 10:13:14" }, { "name": "phpunit/php-file-iterator", @@ -1833,16 +1994,16 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.37", + "version": "3.7.38", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", "shasum": "" }, "require": { @@ -1902,7 +2063,7 @@ "testing", "xunit" ], - "time": "2014-04-30 12:24:19" + "time": "2014-10-17 09:04:17" }, { "name": "phpunit/phpunit-mock-objects", @@ -2080,16 +2241,16 @@ }, { "name": "sebastian/git", - "version": "2.0.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/git.git", - "reference": "572c35353fefcc8607d6fef0e362a9f3a5e84d96" + "reference": "a99fbc102e982c1404041ef3e4d431562b29bcba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/git/zipball/572c35353fefcc8607d6fef0e362a9f3a5e84d96", - "reference": "572c35353fefcc8607d6fef0e362a9f3a5e84d96", + "url": "https://api.github.com/repos/sebastianbergmann/git/zipball/a99fbc102e982c1404041ef3e4d431562b29bcba", + "reference": "a99fbc102e982c1404041ef3e4d431562b29bcba", "shasum": "" }, "require": { @@ -2098,7 +2259,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -2122,7 +2283,7 @@ "keywords": [ "git" ], - "time": "2014-06-14 07:12:53" + "time": "2013-08-04 09:35:29" }, { "name": "sebastian/phpcpd", @@ -2210,18 +2371,64 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2014-03-07 15:35:33" }, + { + "name": "seld/jsonlint", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "a7bc2ec9520ad15382292591b617c43bdb1fec35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/a7bc2ec9520ad15382292591b617c43bdb1fec35", + "reference": "a7bc2ec9520ad15382292591b617c43bdb1fec35", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "bin": [ + "bin/jsonlint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], + "time": "2014-09-05 15:36:20" + }, { "name": "squizlabs/php_codesniffer", - "version": "1.5.3", + "version": "1.5.6", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "396178ada8499ec492363587f037125bf7b07fcc" + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/396178ada8499ec492363587f037125bf7b07fcc", - "reference": "396178ada8499ec492363587f037125bf7b07fcc", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6f3e42d311b882b25b4d409d23a289f4d3b803d5", + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5", "shasum": "" }, "require": { @@ -2283,21 +2490,21 @@ "phpcs", "standards" ], - "time": "2014-05-01 03:07:07" + "time": "2014-12-04 22:32:15" }, { "name": "symfony/config", - "version": "v2.5.0", + "version": "v2.5.8", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "9c8caadb38ecc69ac35ab31af4d1996944b5a09f" + "reference": "92f0b4c625b8c42d394b53f879d2795d84bb8c4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/9c8caadb38ecc69ac35ab31af4d1996944b5a09f", - "reference": "9c8caadb38ecc69ac35ab31af4d1996944b5a09f", + "url": "https://api.github.com/repos/symfony/Config/zipball/92f0b4c625b8c42d394b53f879d2795d84bb8c4f", + "reference": "92f0b4c625b8c42d394b53f879d2795d84bb8c4f", "shasum": "" }, "require": { @@ -2320,34 +2527,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-04-22 08:11:23" + "time": "2014-12-02 20:15:53" }, { "name": "symfony/console", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c" + "reference": "ef825fd9f809d275926547c9e57cbf14968793e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", - "reference": "ef4ca73b0b3a10cbac653d3ca482d0cdd4502b2c", + "url": "https://api.github.com/repos/symfony/Console/zipball/ef825fd9f809d275926547c9e57cbf14968793e8", + "reference": "ef825fd9f809d275926547c9e57cbf14968793e8", "shasum": "" }, "require": { @@ -2355,16 +2560,18 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1" + "symfony/event-dispatcher": "~2.1", + "symfony/process": "~2.1" }, "suggest": { "psr/log": "For using the console logger", - "symfony/event-dispatcher": "" + "symfony/event-dispatcher": "", + "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2377,34 +2584,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-05-22 08:54:24" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/dependency-injection", - "version": "v2.5.0", + "version": "v2.5.8", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "5dfb4c2b74c4976efe1efa783370da656a2dd742" + "reference": "b4afda3c24867a17f93237ac1fcce917cc9d7695" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/5dfb4c2b74c4976efe1efa783370da656a2dd742", - "reference": "5dfb4c2b74c4976efe1efa783370da656a2dd742", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/b4afda3c24867a17f93237ac1fcce917cc9d7695", + "reference": "b4afda3c24867a17f93237ac1fcce917cc9d7695", "shasum": "" }, "require": { @@ -2436,34 +2641,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2014-05-12 09:28:39" + "time": "2014-12-02 21:48:32" }, { "name": "symfony/event-dispatcher", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8" + "reference": "720fe9bca893df7ad1b4546649473b5afddf0216" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", - "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/720fe9bca893df7ad1b4546649473b5afddf0216", + "reference": "720fe9bca893df7ad1b4546649473b5afddf0216", "shasum": "" }, "require": { @@ -2472,7 +2675,8 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.0", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", "symfony/stopwatch": "~2.2" }, "suggest": { @@ -2482,7 +2686,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2495,34 +2699,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-04-29 10:13:57" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/filesystem", - "version": "v2.5.0", + "version": "v2.5.8", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "98e831eac836a0a5911626ce82684155f21d0e4d" + "reference": "e5fc05a3a1dbb4ea0bed80fe7bd21ba3cab88c42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/98e831eac836a0a5911626ce82684155f21d0e4d", - "reference": "98e831eac836a0a5911626ce82684155f21d0e4d", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/e5fc05a3a1dbb4ea0bed80fe7bd21ba3cab88c42", + "reference": "e5fc05a3a1dbb4ea0bed80fe7bd21ba3cab88c42", "shasum": "" }, "require": { @@ -2544,34 +2746,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2014-04-16 10:36:21" + "time": "2014-12-02 20:15:53" }, { "name": "symfony/finder", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "307aad2c541bbdf43183043645e186ef2cd6b973" + "reference": "0d3ef7f6ec55a7af5eca7914eaa0dacc04ccc721" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/307aad2c541bbdf43183043645e186ef2cd6b973", - "reference": "307aad2c541bbdf43183043645e186ef2cd6b973", + "url": "https://api.github.com/repos/symfony/Finder/zipball/0d3ef7f6ec55a7af5eca7914eaa0dacc04ccc721", + "reference": "0d3ef7f6ec55a7af5eca7914eaa0dacc04ccc721", "shasum": "" }, "require": { @@ -2580,7 +2780,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2593,34 +2793,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-05-22 13:47:45" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/process", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "5d7d78e23894544740219e006320678cfa4cd45b" + "reference": "bf0c9bd625f13b0b0bbe39919225cf145dfb935a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/5d7d78e23894544740219e006320678cfa4cd45b", - "reference": "5d7d78e23894544740219e006320678cfa4cd45b", + "url": "https://api.github.com/repos/symfony/Process/zipball/bf0c9bd625f13b0b0bbe39919225cf145dfb935a", + "reference": "bf0c9bd625f13b0b0bbe39919225cf145dfb935a", "shasum": "" }, "require": { @@ -2629,7 +2827,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2642,34 +2840,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2014-05-23 09:02:52" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/stopwatch", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1" + "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/724d73604ebe6c1c9bdf36533b556123bd9075a1", - "reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/261abd360cfb6ac65ea93ffd82073e2011d034fc", + "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc", "shasum": "" }, "require": { @@ -2678,7 +2874,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2691,51 +2887,52 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Stopwatch Component", "homepage": "http://symfony.com", - "time": "2014-04-18 20:40:13" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/translation", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "5f23265dcf8927a84be832608069c9edca3cf5f4" + "reference": "5b8bf84a43317021849813f556f26dc35968156b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/5f23265dcf8927a84be832608069c9edca3cf5f4", - "reference": "5f23265dcf8927a84be832608069c9edca3cf5f4", + "url": "https://api.github.com/repos/symfony/Translation/zipball/5b8bf84a43317021849813f556f26dc35968156b", + "reference": "5b8bf84a43317021849813f556f26dc35968156b", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { + "psr/log": "~1.0", "symfony/config": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.2" }, "suggest": { + "psr/log": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2748,34 +2945,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2014-05-22 13:47:45" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/validator", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "62f6f7735fbd3897b9347ae60fda4a40d0122640" + "reference": "4583e0321f1bcdad14d93e265eaca1001035b5c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/62f6f7735fbd3897b9347ae60fda4a40d0122640", - "reference": "62f6f7735fbd3897b9347ae60fda4a40d0122640", + "url": "https://api.github.com/repos/symfony/Validator/zipball/4583e0321f1bcdad14d93e265eaca1001035b5c4", + "reference": "4583e0321f1bcdad14d93e265eaca1001035b5c4", "shasum": "" }, "require": { @@ -2807,7 +3002,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2820,34 +3015,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2014-05-31 02:02:56" + "time": "2014-12-02 20:19:20" }, { "name": "symfony/yaml", - "version": "v2.5.0", + "version": "v2.6.1", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "b4b09c68ec2f2727574544ef0173684281a5033c" + "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b4b09c68ec2f2727574544ef0173684281a5033c", - "reference": "b4b09c68ec2f2727574544ef0173684281a5033c", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20", + "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20", "shasum": "" }, "require": { @@ -2856,7 +3049,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2869,28 +3062,32 @@ "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" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-05-16 14:25:18" + "time": "2014-12-02 20:19:20" }, { "name": "tecnick.com/tcpdf", - "version": "6.0.086", + "version": "6.2.0", "source": { "type": "git", - "url": "git://git.code.sf.net/p/tcpdf/code", - "reference": "b1c0cc74a84948029d8c9824736d9021871a63a7" + "url": "https://github.com/tecnickcom/TCPDF.git", + "reference": "40662daa766bd3a6b5eafa44dfde680ee6661716" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/40662daa766bd3a6b5eafa44dfde680ee6661716", + "reference": "40662daa766bd3a6b5eafa44dfde680ee6661716", + "shasum": "" }, "require": { "php": ">=5.3.0" @@ -2928,7 +3125,7 @@ "homepage": "http://nicolaasuni.tecnick.com" } ], - "description": "TCPDF is a PHP class for generating PDF documents.", + "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", "homepage": "http://www.tcpdf.org/", "keywords": [ "PDFD32000-2008", @@ -2939,20 +3136,20 @@ "pdf417", "qrcode" ], - "time": "2014-06-20 15:28:34" + "time": "2014-12-10 18:53:49" }, { "name": "theseer/fdomdocument", - "version": "1.5.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/theseer/fDOMDocument.git", - "reference": "137aa3b13bef05b4e301899cbabdaf7d501847d2" + "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/137aa3b13bef05b4e301899cbabdaf7d501847d2", - "reference": "137aa3b13bef05b4e301899cbabdaf7d501847d2", + "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/d08cf070350f884c63fc9078d27893c2ab6c7cef", + "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef", "shasum": "" }, "require": { @@ -2979,20 +3176,20 @@ ], "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", "homepage": "https://github.com/theseer/fDOMDocument", - "time": "2014-02-19 00:20:43" + "time": "2014-09-13 10:57:19" }, { "name": "twig/twig", - "version": "v1.15.1", + "version": "v1.16.2", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" + "url": "https://github.com/twigphp/Twig.git", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", "shasum": "" }, "require": { @@ -3001,7 +3198,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.16-dev" } }, "autoload": { @@ -3021,7 +3218,7 @@ "role": "Lead Developer" }, { - "name": "Armin Ronacher2", + "name": "Armin Ronacher", "email": "armin.ronacher@active-4.com", "role": "Project Founder" }, @@ -3036,31 +3233,32 @@ "keywords": [ "templating" ], - "time": "2014-02-13 10:19:29" + "time": "2014-10-17 12:53:44" }, { "name": "zendframework/zend-cache", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Cache", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendCache.git", - "reference": "560355160f06cdc3ef549a7eef843af3bead7e39" + "reference": "1966038a1568ebeaeeeaa78ce27bc7b340e30747" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendCache/zipball/560355160f06cdc3ef549a7eef843af3bead7e39", - "reference": "560355160f06cdc3ef549a7eef843af3bead7e39", + "url": "https://api.github.com/repos/zendframework/Component_ZendCache/zipball/1966038a1568ebeaeeeaa78ce27bc7b340e30747", + "reference": "1966038a1568ebeaeeeaa78ce27bc7b340e30747", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version", "zendframework/zend-servicemanager": "self.version", "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-serializer": "self.version" + "zendframework/zend-serializer": "self.version", + "zendframework/zend-session": "self.version" }, "suggest": { "ext-apc": "APC >= 3.1.6 to use the APC storage adapter", @@ -3073,8 +3271,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3087,40 +3285,49 @@ "BSD-3-Clause" ], "description": "provides a generic way to cache any data", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "cache", "zf2" ], - "time": "2014-03-03 23:00:17" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-config", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Config", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendConfig.git", - "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08" + "reference": "a9ad512e1482461a5b500ee3fcf2d06ec9c7c7e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendConfig/zipball/a31c3980cf7ec88418a931e9cf4ba21079f47a08", - "reference": "a31c3980cf7ec88418a931e9cf4ba21079f47a08", + "url": "https://api.github.com/repos/zendframework/Component_ZendConfig/zipball/a9ad512e1482461a5b500ee3fcf2d06ec9c7c7e8", + "reference": "a9ad512e1482461a5b500ee3fcf2d06ec9c7c7e8", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "zendframework/zend-filter": "self.version", + "zendframework/zend-i18n": "self.version", + "zendframework/zend-json": "self.version", + "zendframework/zend-servicemanager": "self.version" + }, "suggest": { + "zendframework/zend-filter": "Zend\\Filter component", + "zendframework/zend-i18n": "Zend\\I18n component", "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" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3133,36 +3340,37 @@ "BSD-3-Clause" ], "description": "provides a nested object property based user interface for accessing this configuration data within application code", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "config", "zf2" ], - "time": "2014-01-02 18:00:10" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-eventmanager", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/EventManager", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendEventManager.git", - "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c" + "reference": "4110fe64b10616b9bb71429a206d8e9e6d99e3ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/89368704bb37303fba64c3ddd6bce0506aa7187c", - "reference": "89368704bb37303fba64c3ddd6bce0506aa7187c", + "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/4110fe64b10616b9bb71429a206d8e9e6d99e3ba", + "reference": "4110fe64b10616b9bb71429a206d8e9e6d99e3ba", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3174,45 +3382,48 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "eventmanager", "zf2" ], - "time": "2014-01-04 13:00:14" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-filter", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Filter", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendFilter.git", - "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72" + "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/8ceece474b29d079e86976dbd3efffe6064b3d72", - "reference": "8ceece474b29d079e86976dbd3efffe6064b3d72", + "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", + "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-crypt": "self.version" + "zendframework/zend-crypt": "self.version", + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-uri": "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" + "zendframework/zend-servicemanager": "Zend\\ServiceManager component", + "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3225,44 +3436,57 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "filter", "zf2" ], - "time": "2014-03-03 21:00:06" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-i18n", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/I18n", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendI18n.git", - "reference": "10f56e0869761d62699782e4dd04eb77262cc353" + "reference": "7939bd8eaa573f10fe33a799714199ed7c1fad5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendI18n/zipball/10f56e0869761d62699782e4dd04eb77262cc353", - "reference": "10f56e0869761d62699782e4dd04eb77262cc353", + "url": "https://api.github.com/repos/zendframework/Component_ZendI18n/zipball/7939bd8eaa573f10fe33a799714199ed7c1fad5c", + "reference": "7939bd8eaa573f10fe33a799714199ed7c1fad5c", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "zendframework/zend-cache": "self.version", + "zendframework/zend-config": "self.version", + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-filter": "self.version", + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-validator": "self.version", + "zendframework/zend-view": "self.version" + }, "suggest": { "ext-intl": "Required for most features of Zend\\I18n; included in default builds of PHP", + "zendframework/zend-cache": "Zend\\Cache component", + "zendframework/zend-config": "Zend\\Config component", "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-servicemanager": "Zend\\ServiceManager component", "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" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3274,39 +3498,45 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "i18n", "zf2" ], - "time": "2014-01-04 13:00:19" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-json", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Json", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendJson.git", - "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92" + "reference": "4093e5a0a166a5d02532bac6e5671a7b21d203b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendJson/zipball/dd8a8239a7c08c7449a6ea219da3e2369bd90d92", - "reference": "dd8a8239a7c08c7449a6ea219da3e2369bd90d92", + "url": "https://api.github.com/repos/zendframework/Component_ZendJson/zipball/4093e5a0a166a5d02532bac6e5671a7b21d203b5", + "reference": "4093e5a0a166a5d02532bac6e5671a7b21d203b5", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "zendframework/zend-http": "self.version", + "zendframework/zend-server": "self.version" + }, "suggest": { + "zendframework/zend-http": "Zend\\Http component", "zendframework/zend-server": "Zend\\Server component" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3319,29 +3549,30 @@ "BSD-3-Clause" ], "description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "json", "zf2" ], - "time": "2014-03-06 18:00:05" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-math", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Math", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendMath.git", - "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e" + "reference": "a197ee44ade44a289f0f250c2aedb321b3618573" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendMath/zipball/b982ee2edafd4075b22372596ab2e2fdd0f6424e", - "reference": "b982ee2edafd4075b22372596ab2e2fdd0f6424e", + "url": "https://api.github.com/repos/zendframework/Component_ZendMath/zipball/a197ee44ade44a289f0f250c2aedb321b3618573", + "reference": "a197ee44ade44a289f0f250c2aedb321b3618573", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.23" }, "suggest": { "ext-bcmath": "If using the bcmath functionality", @@ -3352,8 +3583,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3365,41 +3596,45 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "math", "zf2" ], - "time": "2014-03-05 18:00:06" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-serializer", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Serializer", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendSerializer.git", - "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade" + "reference": "34ee4925e7e256bfa80c4c3dcc8e764d02a51edd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendSerializer/zipball/d76b931d3ffa842a496c9fa319bbe285b5ddfade", - "reference": "d76b931d3ffa842a496c9fa319bbe285b5ddfade", + "url": "https://api.github.com/repos/zendframework/Component_ZendSerializer/zipball/34ee4925e7e256bfa80c4c3dcc8e764d02a51edd", + "reference": "34ee4925e7e256bfa80c4c3dcc8e764d02a51edd", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-json": "self.version", "zendframework/zend-math": "self.version", "zendframework/zend-stdlib": "self.version" }, + "require-dev": { + "zendframework/zend-servicemanager": "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" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3412,29 +3647,33 @@ "BSD-3-Clause" ], "description": "provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "serializer", "zf2" ], - "time": "2014-01-02 18:00:26" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-servicemanager", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/ServiceManager", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendServiceManager.git", - "reference": "de182a20dfdcf978c49570514103c7477ef16e4f" + "reference": "559403e4fd10db2516641f20f129a568d7e6a993" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/de182a20dfdcf978c49570514103c7477ef16e4f", - "reference": "de182a20dfdcf978c49570514103c7477ef16e4f", + "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/559403e4fd10db2516641f20f129a568d7e6a993", + "reference": "559403e4fd10db2516641f20f129a568d7e6a993", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-di": "self.version" }, "suggest": { "zendframework/zend-di": "Zend\\Di component" @@ -3442,8 +3681,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3455,39 +3694,46 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "servicemanager", "zf2" ], - "time": "2014-03-03 21:00:04" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-stdlib", - "version": "2.1.6", + "version": "2.3.3", "target-dir": "Zend/Stdlib", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendStdlib.git", - "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5" + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/e646729f2274f4552b6a92e38d8e458efe08ebc5", - "reference": "e646729f2274f4552b6a92e38d8e458efe08ebc5", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-serializer": "self.version", + "zendframework/zend-servicemanager": "self.version" }, "suggest": { "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-serializer": "Zend\\Serializer component", "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev", - "dev-develop": "2.3-dev" + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" } }, "autoload": { @@ -3499,26 +3745,30 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "stdlib", "zf2" ], - "time": "2014-01-04 13:00:28" + "time": "2014-09-16 22:58:11" }, { "name": "zetacomponents/base", - "version": "1.8", + "version": "1.9", "source": { "type": "git", "url": "https://github.com/zetacomponents/Base.git", - "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c" + "reference": "f20df24e8de3e48b6b69b2503f917e457281e687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zetacomponents/Base/zipball/52ca69c1de55f3fa4f595779e5bc831da7ee176c", - "reference": "52ca69c1de55f3fa4f595779e5bc831da7ee176c", + "url": "https://api.github.com/repos/zetacomponents/Base/zipball/f20df24e8de3e48b6b69b2503f917e457281e687", + "reference": "f20df24e8de3e48b6b69b2503f917e457281e687", "shasum": "" }, + "require-dev": { + "zetacomponents/unit-test": "*" + }, "type": "library", "autoload": { "classmap": [ @@ -3527,7 +3777,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "apache2" + "Apache-2.0" ], "authors": [ { @@ -3563,7 +3813,7 @@ ], "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" + "time": "2014-09-19 03:28:34" }, { "name": "zetacomponents/document", @@ -3617,18 +3867,13 @@ "time": "2013-12-19 11:40:00" } ], - "aliases": [ - - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": [], + "prefer-stable": false, "platform": { "php": ">=5.3.3", "ext-xml": "*" }, - "platform-dev": [ - - ] + "platform-dev": [] } From 56cd78440d5a279844d152f35e3bc23ff3fa2f3e Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 11 Dec 2014 23:08:44 +0100 Subject: [PATCH 162/174] UPDATED : travis.yml for support of PHP 5.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d92e23b83f..22f45d9b2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.3.3 - 5.3 - 5.4 - 5.5 @@ -10,6 +9,7 @@ php: matrix: allow_failures: + - php: 5.2 - php: hhvm env: From fbfde2e0ee13a46cf721331e77bf2be6521a2d26 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 17 Dec 2014 21:39:19 +0400 Subject: [PATCH 163/174] #441 (added @since annotation). --- src/PhpWord/Writer/HTML/Element/PageBreak.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php index 8cd5906e69..774ed9d23c 100644 --- a/src/PhpWord/Writer/HTML/Element/PageBreak.php +++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php @@ -27,6 +27,8 @@ class PageBreak extends TextBreak /** * Write page break * + * @since 0.12.0 + * * @return string */ public function write() @@ -36,6 +38,7 @@ public function write() if ($parentWriter->isPdf()) { return ''; } + return ""; } } From 42c0b70a60dda8ab465778bfca78eed5a0396277 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 17 Dec 2014 21:47:06 +0400 Subject: [PATCH 164/174] Replaced "phpversion()" function call with "PHP_VERSION" constant usage. --- samples/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/index.php b/samples/index.php index f25f7f334b..a65d8fd90e 100644 --- a/samples/index.php +++ b/samples/index.php @@ -2,8 +2,9 @@ include_once 'Sample_Header.php'; use PhpOffice\PhpWord\Settings; + $requirements = array( - 'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')), + 'php' => array('PHP 5.3.3', version_compare(PHP_VERSION, '5.3.3', '>=')), 'xml' => array('PHP extension XML', extension_loaded('xml')), 'temp' => array('Temp folder "' . Settings::getTempDir() . '" is writable', is_writable(Settings::getTempDir())), 'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')), From 20c4232454e0c933da87bf9fc9a2e58772b96dfe Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 17 Dec 2014 21:53:32 +0400 Subject: [PATCH 165/174] [CHANGED] "Sample_Header.php" (added @return annotations where missed). --- samples/Sample_Header.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 69afd56e30..f74067a0eb 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -55,6 +55,8 @@ * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $filename * @param array $writers + * + * @return string */ function write($phpWord, $filename, $writers) { @@ -81,6 +83,8 @@ function write($phpWord, $filename, $writers) * Get ending notes * * @param array $writers + * + * @return string */ function getEndingNotes($writers) { From 42b878ec1d5e0f81c13edaf552aec37984406da6 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Wed, 17 Dec 2014 21:56:32 +0400 Subject: [PATCH 166/174] [CHANGED] "Sample_Header.php" (changed date default timezone to UTC). --- samples/Sample_Header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index f74067a0eb..5e5ec0e18b 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -1,6 +1,6 @@ Date: Wed, 17 Dec 2014 22:02:56 +0400 Subject: [PATCH 167/174] Minor refactoring. --- samples/Sample_Header.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 5e5ec0e18b..22d27a4a6b 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -1,4 +1,5 @@ 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf'); // Set PDF renderer -if (Settings::getPdfRendererPath() === null) { +if (null === Settings::getPdfRendererPath()) { $writers['PDF'] = null; } @@ -65,7 +65,7 @@ function write($phpWord, $filename, $writers) // Write documents foreach ($writers as $format => $extension) { $result .= date('H:i:s') . " Write to {$format} format"; - if ($extension !== null) { + if (null !== $extension) { $targetFile = __DIR__ . "/results/{$filename}.{$extension}"; $phpWord->save($targetFile, $format); } else { From 474f8ef2f77762acf79cf76e8a660b1aa0d6e48f Mon Sep 17 00:00:00 2001 From: h6w Date: Mon, 29 Dec 2014 18:16:05 +1100 Subject: [PATCH 168/174] Update AbstractStyle.php --- src/PhpWord/Style/AbstractStyle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index aec490b5a1..ab1a1ee729 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -284,7 +284,7 @@ protected function setFloatVal($value, $default = null) 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: {$value}"); + throw new \InvalidArgumentException("Invalid style value: {$value} Options:".join(',', $enum)); } elseif ($value === null || trim($value) == '') { $value = $default; } From 7d2c0a693753e6eb4b60b9746f9fb8c3b5bc5529 Mon Sep 17 00:00:00 2001 From: h6w Date: Mon, 29 Dec 2014 18:20:39 +1100 Subject: [PATCH 169/174] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a33ad8669..5b8c06f43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287 - "absolute" horizontal and vertical positioning of Frame - @basjan GH-302 - Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 +- Report style options enumerated when style unknown - @h6w ### Bugfixes From c116afbd02bc0e5a61b6d4fe3c5ae9d7f17d9220 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 1 Jan 2015 20:41:42 +0400 Subject: [PATCH 170/174] #51 (updated samples). --- samples/Sample_01_SimpleText.php | 74 ++++++++-------- samples/Sample_02_TabStops.php | 43 ++++----- samples/Sample_03_Sections.php | 33 +++++-- samples/Sample_04_Textrun.php | 40 +++++---- samples/Sample_05_Multicolumn.php | 42 +++++---- samples/Sample_06_Footnote.php | 40 +++++---- samples/Sample_07_TemplateCloneRow.php | 74 ++++++++-------- samples/Sample_08_ParagraphPagination.php | 101 ++++++++++++++-------- samples/Sample_09_Tables.php | 58 ++++++------- samples/Sample_10_EastAsianFontStyle.php | 4 +- samples/Sample_12_HeaderFooter.php | 22 ++--- samples/Sample_13_Images.php | 57 +++++++----- samples/Sample_14_ListItem.php | 91 +++++++++---------- samples/Sample_15_Link.php | 10 ++- samples/Sample_16_Object.php | 4 +- samples/Sample_17_TitleTOC.php | 46 +++++----- samples/Sample_18_Watermark.php | 4 +- samples/Sample_19_TextBreak.php | 14 +-- samples/Sample_20_BGColor.php | 14 ++- samples/Sample_21_TableRowRules.php | 48 +++++++--- samples/Sample_22_CheckBox.php | 10 +-- samples/Sample_25_TextBox.php | 32 ++++--- samples/Sample_26_Html.php | 2 +- samples/Sample_27_Field.php | 20 ++--- samples/Sample_29_Line.php | 50 +++++------ samples/Sample_31_Shape.php | 55 +++++++----- samples/Sample_32_Chart.php | 10 +-- samples/Sample_33_FormField.php | 12 +-- samples/Sample_34_SDT.php | 8 +- samples/Sample_35_InternalLink.php | 10 +-- samples/Sample_36_RTL.php | 6 +- 31 files changed, 579 insertions(+), 455 deletions(-) diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 8c93f9176f..f7aaece30a 100644 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true)); $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100)); @@ -12,16 +12,16 @@ $section = $phpWord->addSection(); // Simple text -$section->addTitle('Welcome to PhpWord', 1); -$section->addText('Hello World!'); +$section->addTitle(htmlspecialchars('Welcome to PhpWord'), 1); +$section->addText(htmlspecialchars('Hello World!')); // Two text break $section->addTextBreak(2); // Defined style -$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->addText(htmlspecialchars('I am styled by a font style definition.'), 'rStyle'); +$section->addText(htmlspecialchars('I am styled by a paragraph style definition.'), null, 'pStyle'); +$section->addText(htmlspecialchars('I am styled by both font and paragraph style.'), 'rStyle', 'pStyle'); $section->addTextBreak(); @@ -30,39 +30,39 @@ $fontStyle['size'] = 20; $textrun = $section->addTextRun(); -$textrun->addText('I am inline styled ', $fontStyle); -$textrun->addText('with '); -$textrun->addText('color', array('color' => '996699')); -$textrun->addText(', '); -$textrun->addText('bold', array('bold' => true)); -$textrun->addText(', '); -$textrun->addText('italic', array('italic' => true)); -$textrun->addText(', '); -$textrun->addText('underline', array('underline' => 'dash')); -$textrun->addText(', '); -$textrun->addText('strikethrough', array('strikethrough' => true)); -$textrun->addText(', '); -$textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true)); -$textrun->addText(', '); -$textrun->addText('superScript', array('superScript' => true)); -$textrun->addText(', '); -$textrun->addText('subScript', array('subScript' => true)); -$textrun->addText(', '); -$textrun->addText('smallCaps', array('smallCaps' => true)); -$textrun->addText(', '); -$textrun->addText('allCaps', array('allCaps' => true)); -$textrun->addText(', '); -$textrun->addText('fgColor', array('fgColor' => 'yellow')); -$textrun->addText(', '); -$textrun->addText('scale', array('scale' => 200)); -$textrun->addText(', '); -$textrun->addText('spacing', array('spacing' => 120)); -$textrun->addText(', '); -$textrun->addText('kerning', array('kerning' => 10)); -$textrun->addText('. '); +$textrun->addText(htmlspecialchars('I am inline styled '), $fontStyle); +$textrun->addText(htmlspecialchars('with ')); +$textrun->addText(htmlspecialchars('color'), array('color' => '996699')); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('bold'), array('bold' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('italic'), array('italic' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('underline'), array('underline' => 'dash')); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('strikethrough'), array('strikethrough' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('doubleStrikethrough'), array('doubleStrikethrough' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('superScript'), array('superScript' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('subScript'), array('subScript' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('smallCaps'), array('smallCaps' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('allCaps'), array('allCaps' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('fgColor'), array('fgColor' => 'yellow')); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('scale'), array('scale' => 200)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('spacing'), array('spacing' => 120)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addText(htmlspecialchars('kerning'), array('kerning' => 10)); +$textrun->addText(htmlspecialchars('. ')); // Link -$section->addLink('http://www.google.com', 'Google'); +$section->addLink('http://www.google.com', htmlspecialchars('Google')); $section->addTextBreak(); // Image diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index d6e4cdbc87..46d91cec34 100644 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -2,35 +2,36 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles -$phpWord->addParagraphStyle('multipleTab', array( - 'tabs' => array( - new \PhpOffice\PhpWord\Style\Tab('left', 1550), - new \PhpOffice\PhpWord\Style\Tab('center', 3200), - new \PhpOffice\PhpWord\Style\Tab('right', 5300) - ) -)); -$phpWord->addParagraphStyle('rightTab', array( - 'tabs' => array( - new \PhpOffice\PhpWord\Style\Tab('right', 9090) - ) -)); -$phpWord->addParagraphStyle('centerTab', array( - 'tabs' => array( - new \PhpOffice\PhpWord\Style\Tab('center', 4680) - ) -)); +$phpWord->addParagraphStyle( + 'multipleTab', + array( + 'tabs' => array( + new \PhpOffice\PhpWord\Style\Tab('left', 1550), + new \PhpOffice\PhpWord\Style\Tab('center', 3200), + new \PhpOffice\PhpWord\Style\Tab('right', 5300), + ) + ) +); +$phpWord->addParagraphStyle( + 'rightTab', + array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090))) +); +$phpWord->addParagraphStyle( + 'centerTab', + array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680))) +); // New portrait section $section = $phpWord->addSection(); // Add listitem elements -$section->addText("Multiple Tabs:\tOne\tTwo\tThree", null, 'multipleTab'); -$section->addText("Left Aligned\tRight Aligned", null, 'rightTab'); -$section->addText("\tCenter Aligned", null, 'centerTab'); +$section->addText(htmlspecialchars("Multiple Tabs:\tOne\tTwo\tThree"), null, 'multipleTab'); +$section->addText(htmlspecialchars("Left Aligned\tRight Aligned"), null, 'rightTab'); +$section->addText(htmlspecialchars("\tCenter Aligned"), null, 'centerTab'); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 9ed75c731a..a95b15d644 100644 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -2,28 +2,43 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12)); -$section->addText('I am placed on a default section.'); +$section->addText(htmlspecialchars('I am placed on a default section.')); // New landscape section $section = $phpWord->addSection(array('orientation' => 'landscape')); -$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.'); +$section->addText( + htmlspecialchars( + 'I am placed on a landscape section. Every page starting from this section will be landscape style.' + ) +); $section->addPageBreak(); $section->addPageBreak(); // New portrait section -$section = $phpWord->addSection(array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); -$section->addText('This section uses other margins with folio papersize.'); +$section = $phpWord->addSection( + array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600) +); +$section->addText(htmlspecialchars('This section uses other margins with folio papersize.')); // New portrait section with Header & Footer -$section = $phpWord->addSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); -$section->addText('This section and we play with header/footer height.'); -$section->addHeader()->addText('Header'); -$section->addFooter()->addText('Footer'); +$section = $phpWord->addSection( + array( + 'marginLeft' => 200, + 'marginRight' => 200, + 'marginTop' => 200, + 'marginBottom' => 200, + 'headerHeight' => 50, + 'footerHeight' => 50, + ) +); +$section->addText(htmlspecialchars('This section and we play with header/footer height.')); +$section->addHeader()->addText(htmlspecialchars('Header')); +$section->addFooter()->addText(htmlspecialchars('Footer')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index e41f4ddbac..7ebf6e3365 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -2,14 +2,17 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles -$phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); -$phpWord->addFontStyle('BoldText', array('bold'=>true)); -$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080', 'bgColor' => 'FFFFCC')); -$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addParagraphStyle('pStyle', array('spacing' => 100)); +$phpWord->addFontStyle('BoldText', array('bold' => true)); +$phpWord->addFontStyle('ColoredText', array('color' => 'FF8080', 'bgColor' => 'FFFFCC')); +$phpWord->addLinkStyle( + 'NLink', + array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE) +); // New portrait section $section = $phpWord->addSection(); @@ -17,21 +20,24 @@ // Add text run $textrun = $section->addTextRun('pStyle'); -$textrun->addText('Each textrun can contain native text, link elements or an image.'); -$textrun->addText(' No break is placed after adding an element.', 'BoldText'); -$textrun->addText(' Both '); -$textrun->addText('superscript', array('superScript' => true)); -$textrun->addText(' and '); -$textrun->addText('subscript', array('subScript' => true)); -$textrun->addText(' are also available.'); -$textrun->addText(' All elements are placed inside a paragraph with the optionally given p-Style.', 'ColoredText'); -$textrun->addText(' Sample Link: '); +$textrun->addText(htmlspecialchars('Each textrun can contain native text, link elements or an image.')); +$textrun->addText(htmlspecialchars(' No break is placed after adding an element.'), 'BoldText'); +$textrun->addText(htmlspecialchars(' Both ')); +$textrun->addText(htmlspecialchars('superscript'), array('superScript' => true)); +$textrun->addText(htmlspecialchars(' and ')); +$textrun->addText(htmlspecialchars('subscript'), array('subScript' => true)); +$textrun->addText(htmlspecialchars(' are also available.')); +$textrun->addText( + htmlspecialchars(' All elements are placed inside a paragraph with the optionally given p-Style.'), + 'ColoredText' +); +$textrun->addText(htmlspecialchars(' Sample Link: ')); $textrun->addLink('http://www.google.com', null, 'NLink'); -$textrun->addText(' Sample Image: '); +$textrun->addText(htmlspecialchars(' Sample Image: ')); $textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); -$textrun->addText(' Sample Object: '); +$textrun->addText(htmlspecialchars(' Sample Object: ')); $textrun->addObject('resources/_sheet.xls'); -$textrun->addText(' Here is some more text. '); +$textrun->addText(htmlspecialchars(' Here is some more text. ')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index f47370605e..b93ab344c1 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -2,38 +2,44 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . - 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . - 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . - 'Suspendisse congue congue leo sed pellentesque.'; +$filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' + . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' + . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' + . 'Suspendisse congue congue leo sed pellentesque.'; // Normal $section = $phpWord->addSection(); -$section->addText('Normal paragraph. ' . $filler); +$section->addText(htmlspecialchars("Normal paragraph. {$filler}")); // Two columns -$section = $phpWord->addSection(array( - 'colsNum' => 2, - 'colsSpace' => 1440, - 'breakType' => 'continuous')); -$section->addText('Two columns, one inch (1440 twips) spacing. ' . $filler); +$section = $phpWord->addSection( + array( + 'colsNum' => 2, + 'colsSpace' => 1440, + 'breakType' => 'continuous', + ) +); +$section->addText(htmlspecialchars("Two columns, one inch (1440 twips) spacing. {$filler}")); // Normal $section = $phpWord->addSection(array('breakType' => 'continuous')); -$section->addText('Normal paragraph again. ' . $filler); +$section->addText(htmlspecialchars("Normal paragraph again. {$filler}")); // Three columns -$section = $phpWord->addSection(array( - 'colsNum' => 3, - 'colsSpace' => 720, - 'breakType' => 'continuous')); -$section->addText('Three columns, half inch (720 twips) spacing. ' . $filler); +$section = $phpWord->addSection( + array( + 'colsNum' => 3, + 'colsSpace' => 720, + 'breakType' => 'continuous', + ) +); +$section->addText(htmlspecialchars("Three columns, half inch (720 twips) spacing. {$filler}")); // Normal $section = $phpWord->addSection(array('breakType' => 'continuous')); -$section->addText('Normal paragraph again.'); +$section->addText(htmlspecialchars('Normal paragraph again.')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 1bec44e447..c7f3d8c0bc 100644 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); \PhpOffice\PhpWord\Settings::setCompatibility(false); @@ -10,32 +10,40 @@ $section = $phpWord->addSection(); // Add style definitions -$phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); -$phpWord->addFontStyle('BoldText', array('bold'=>true)); -$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); -$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$phpWord->addParagraphStyle('pStyle', array('spacing' => 100)); +$phpWord->addFontStyle('BoldText', array('bold' => true)); +$phpWord->addFontStyle('ColoredText', array('color' => 'FF8080')); +$phpWord->addLinkStyle( + 'NLink', + array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE) +); // Add text elements $textrun = $section->addTextRun('pStyle'); -$textrun->addText('This is some lead text in a paragraph with a following footnote. ','pStyle'); +$textrun->addText(htmlspecialchars('This is some lead text in a paragraph with a following footnote. '), 'pStyle'); $footnote = $textrun->addFootnote(); -$footnote->addText('Just like a textrun, a footnote can contain native texts. '); -$footnote->addText('No break is placed after adding an element. ', 'BoldText'); -$footnote->addText('All elements are placed inside a paragraph. ', 'ColoredText'); +$footnote->addText(htmlspecialchars('Just like a textrun, a footnote can contain native texts. ')); +$footnote->addText(htmlspecialchars('No break is placed after adding an element. '), 'BoldText'); +$footnote->addText(htmlspecialchars('All elements are placed inside a paragraph. '), 'ColoredText'); $footnote->addTextBreak(); -$footnote->addText('But you can insert a manual text break like above, '); -$footnote->addText('links like '); +$footnote->addText(htmlspecialchars('But you can insert a manual text break like above, ')); +$footnote->addText(htmlspecialchars('links like ')); $footnote->addLink('http://www.google.com', null, 'NLink'); -$footnote->addText(', image like '); +$footnote->addText(htmlspecialchars(', image like ')); $footnote->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); -$footnote->addText(', or object like '); +$footnote->addText(htmlspecialchars(', or object like ')); $footnote->addObject('resources/_sheet.xls'); -$footnote->addText('But you can only put footnote in section, not in header or footer.'); +$footnote->addText(htmlspecialchars('But you can only put footnote in section, not in header or footer.')); -$section->addText('You can also create the footnote directly from the section making it wrap in a paragraph like the footnote below this paragraph. But is is best used from within a textrun.'); +$section->addText( + htmlspecialchars( + 'You can also create the footnote directly from the section making it wrap in a paragraph ' + . 'like the footnote below this paragraph. But is is best used from within a textrun.' + ) +); $footnote = $section->addFootnote(); -$footnote->addText('The reference for this is wrapped in its own line'); +$footnote->addText(htmlspecialchars('The reference for this is wrapped in its own line')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index 0712ddfc0a..60edacb5a7 100644 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -2,56 +2,56 @@ include_once 'Sample_Header.php'; // Template processor instance creation -echo date('H:i:s') , ' Creating new TemplateProcessor instance...' , EOL; +echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL; $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx'); // Variables on different parts of document -$templateProcessor->setValue('weekday', date('l')); // On section/content -$templateProcessor->setValue('time', date('H:i')); // On footer -$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header +$templateProcessor->setValue('weekday', htmlspecialchars(date('l'))); // On section/content +$templateProcessor->setValue('time', htmlspecialchars(date('H:i'))); // On footer +$templateProcessor->setValue('serverName', htmlspecialchars(realpath(__DIR__))); // On header // Simple table $templateProcessor->cloneRow('rowValue', 10); -$templateProcessor->setValue('rowValue#1', 'Sun'); -$templateProcessor->setValue('rowValue#2', 'Mercury'); -$templateProcessor->setValue('rowValue#3', 'Venus'); -$templateProcessor->setValue('rowValue#4', 'Earth'); -$templateProcessor->setValue('rowValue#5', 'Mars'); -$templateProcessor->setValue('rowValue#6', 'Jupiter'); -$templateProcessor->setValue('rowValue#7', 'Saturn'); -$templateProcessor->setValue('rowValue#8', 'Uranus'); -$templateProcessor->setValue('rowValue#9', 'Neptun'); -$templateProcessor->setValue('rowValue#10', 'Pluto'); - -$templateProcessor->setValue('rowNumber#1', '1'); -$templateProcessor->setValue('rowNumber#2', '2'); -$templateProcessor->setValue('rowNumber#3', '3'); -$templateProcessor->setValue('rowNumber#4', '4'); -$templateProcessor->setValue('rowNumber#5', '5'); -$templateProcessor->setValue('rowNumber#6', '6'); -$templateProcessor->setValue('rowNumber#7', '7'); -$templateProcessor->setValue('rowNumber#8', '8'); -$templateProcessor->setValue('rowNumber#9', '9'); -$templateProcessor->setValue('rowNumber#10', '10'); +$templateProcessor->setValue('rowValue#1', htmlspecialchars('Sun')); +$templateProcessor->setValue('rowValue#2', htmlspecialchars('Mercury')); +$templateProcessor->setValue('rowValue#3', htmlspecialchars('Venus')); +$templateProcessor->setValue('rowValue#4', htmlspecialchars('Earth')); +$templateProcessor->setValue('rowValue#5', htmlspecialchars('Mars')); +$templateProcessor->setValue('rowValue#6', htmlspecialchars('Jupiter')); +$templateProcessor->setValue('rowValue#7', htmlspecialchars('Saturn')); +$templateProcessor->setValue('rowValue#8', htmlspecialchars('Uranus')); +$templateProcessor->setValue('rowValue#9', htmlspecialchars('Neptun')); +$templateProcessor->setValue('rowValue#10', htmlspecialchars('Pluto')); + +$templateProcessor->setValue('rowNumber#1', htmlspecialchars('1')); +$templateProcessor->setValue('rowNumber#2', htmlspecialchars('2')); +$templateProcessor->setValue('rowNumber#3', htmlspecialchars('3')); +$templateProcessor->setValue('rowNumber#4', htmlspecialchars('4')); +$templateProcessor->setValue('rowNumber#5', htmlspecialchars('5')); +$templateProcessor->setValue('rowNumber#6', htmlspecialchars('6')); +$templateProcessor->setValue('rowNumber#7', htmlspecialchars('7')); +$templateProcessor->setValue('rowNumber#8', htmlspecialchars('8')); +$templateProcessor->setValue('rowNumber#9', htmlspecialchars('9')); +$templateProcessor->setValue('rowNumber#10', htmlspecialchars('10')); // Table with a spanned cell $templateProcessor->cloneRow('userId', 3); -$templateProcessor->setValue('userId#1', '1'); -$templateProcessor->setValue('userFirstName#1', 'James'); -$templateProcessor->setValue('userName#1', 'Taylor'); -$templateProcessor->setValue('userPhone#1', '+1 428 889 773'); +$templateProcessor->setValue('userId#1', htmlspecialchars('1')); +$templateProcessor->setValue('userFirstName#1', htmlspecialchars('James')); +$templateProcessor->setValue('userName#1', htmlspecialchars('Taylor')); +$templateProcessor->setValue('userPhone#1', htmlspecialchars('+1 428 889 773')); -$templateProcessor->setValue('userId#2', '2'); -$templateProcessor->setValue('userFirstName#2', 'Robert'); -$templateProcessor->setValue('userName#2', 'Bell'); -$templateProcessor->setValue('userPhone#2', '+1 428 889 774'); +$templateProcessor->setValue('userId#2', htmlspecialchars('2')); +$templateProcessor->setValue('userFirstName#2', htmlspecialchars('Robert')); +$templateProcessor->setValue('userName#2', htmlspecialchars('Bell')); +$templateProcessor->setValue('userPhone#2', htmlspecialchars('+1 428 889 774')); -$templateProcessor->setValue('userId#3', '3'); -$templateProcessor->setValue('userFirstName#3', 'Michael'); -$templateProcessor->setValue('userName#3', 'Ray'); -$templateProcessor->setValue('userPhone#3', '+1 428 889 775'); +$templateProcessor->setValue('userId#3', htmlspecialchars('3')); +$templateProcessor->setValue('userFirstName#3', htmlspecialchars('Michael')); +$templateProcessor->setValue('userName#3', htmlspecialchars('Ray')); +$templateProcessor->setValue('userPhone#3', htmlspecialchars('+1 428 889 775')); echo date('H:i:s'), ' Saving the result document...', EOL; $templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx'); diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index f39147588a..dd364562d0 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -2,48 +2,75 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$phpWord->setDefaultParagraphStyle(array( - 'align' => 'both', - 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), - 'spacing' => 120, -)); +$phpWord->setDefaultParagraphStyle( + array( + 'align' => 'both', + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), + 'spacing' => 120, + ) +); // Sample $section = $phpWord->addSection(); -$section->addText('Below are the samples on how to control your paragraph ' . - 'pagination. See "Line and Page Break" tab on paragraph properties ' . - 'window to see the attribute set by these controls.', - array('bold' => true), array('space' => array('before' => 360, 'after' => 480))); - -$section->addText('Paragraph with widowControl = false (default: true). ' . - 'A "widow" is the last line of a paragraph printed by itself at the top ' . - 'of a page. An "orphan" is the first line of a paragraph printed by ' . - 'itself at the bottom of a page. Set this option to "false" if you want ' . - 'to disable this automatic control.', - null, array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120))); - -$section->addText('Paragraph with keepNext = true (default: false). ' . - '"Keep with next" is used to prevent Word from inserting automatic page ' . - 'breaks between paragraphs. Set this option to "true" if you do not want ' . - 'your paragraph to be separated with the next paragraph.', - null, array('keepNext' => true, 'indentation' => array('firstLine' => 240))); - -$section->addText('Paragraph with keepLines = true (default: false). ' . - '"Keep lines together" will prevent Word from inserting an automatic page ' . - 'break within a paragraph. Set this option to "true" if you do not want ' . - 'all lines of your paragraph to be in the same page.', - null, array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240))); - -$section->addText('Keep scrolling. More below.'); - -$section->addText('Paragraph with pageBreakBefore = true (default: false). ' . - 'Different with all other control above, "page break before" separates ' . - 'your paragraph into the next page. This option is most useful for ' . - 'heading styles.', - null, array('pageBreakBefore' => true)); +$section->addText( + htmlspecialchars( + 'Below are the samples on how to control your paragraph ' + . 'pagination. See "Line and Page Break" tab on paragraph properties ' + . 'window to see the attribute set by these controls.' + ), + array('bold' => true), + array('space' => array('before' => 360, 'after' => 480)) +); + +$section->addText( + htmlspecialchars( + 'Paragraph with widowControl = false (default: true). ' + . 'A "widow" is the last line of a paragraph printed by itself at the top ' + . 'of a page. An "orphan" is the first line of a paragraph printed by ' + . 'itself at the bottom of a page. Set this option to "false" if you want ' + . 'to disable this automatic control.' + ), + null, + array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120)) +); + +$section->addText( + htmlspecialchars( + 'Paragraph with keepNext = true (default: false). ' + . '"Keep with next" is used to prevent Word from inserting automatic page ' + . 'breaks between paragraphs. Set this option to "true" if you do not want ' + . 'your paragraph to be separated with the next paragraph.' + ), + null, + array('keepNext' => true, 'indentation' => array('firstLine' => 240)) +); + +$section->addText( + htmlspecialchars( + 'Paragraph with keepLines = true (default: false). ' + . '"Keep lines together" will prevent Word from inserting an automatic page ' + . 'break within a paragraph. Set this option to "true" if you do not want ' + . 'all lines of your paragraph to be in the same page.' + ), + null, + array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240)) +); + +$section->addText(htmlspecialchars('Keep scrolling. More below.')); + +$section->addText( + htmlspecialchars( + 'Paragraph with pageBreakBefore = true (default: false). ' + . 'Different with all other control above, "page break before" separates ' + . 'your paragraph into the next page. This option is most useful for ' + . 'heading styles.' + ), + null, + array('pageBreakBefore' => true) +); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 882653bc71..5c305c8342 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); @@ -11,20 +11,20 @@ $rows = 10; $cols = 5; -$section->addText("Basic table", $header); +$section->addText(htmlspecialchars('Basic table'), $header); $table = $section->addTable(); -for($r = 1; $r <= 8; $r++) { +for ($r = 1; $r <= 8; $r++) { $table->addRow(); - for($c = 1; $c <= 5; $c++) { - $table->addCell(1750)->addText("Row $r, Cell $c"); + for ($c = 1; $c <= 5; $c++) { + $table->addCell(1750)->addText(htmlspecialchars("Row {$r}, Cell {$c}")); } } // 2. Advanced table $section->addTextBreak(1); -$section->addText("Fancy table", $header); +$section->addText(htmlspecialchars('Fancy table'), $header); $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); @@ -34,25 +34,25 @@ $phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); $table->addRow(900); -$table->addCell(2000, $styleCell)->addText('Row 1', $fontStyle); -$table->addCell(2000, $styleCell)->addText('Row 2', $fontStyle); -$table->addCell(2000, $styleCell)->addText('Row 3', $fontStyle); -$table->addCell(2000, $styleCell)->addText('Row 4', $fontStyle); -$table->addCell(500, $styleCellBTLR)->addText('Row 5', $fontStyle); -for($i = 1; $i <= 8; $i++) { +$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 1'), $fontStyle); +$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 2'), $fontStyle); +$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 3'), $fontStyle); +$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 4'), $fontStyle); +$table->addCell(500, $styleCellBTLR)->addText(htmlspecialchars('Row 5'), $fontStyle); +for ($i = 1; $i <= 8; $i++) { $table->addRow(); - $table->addCell(2000)->addText("Cell $i"); - $table->addCell(2000)->addText("Cell $i"); - $table->addCell(2000)->addText("Cell $i"); - $table->addCell(2000)->addText("Cell $i"); - $text = ($i % 2 == 0) ? 'X' : ''; - $table->addCell(500)->addText($text); + $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}")); + $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}")); + $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}")); + $table->addCell(2000)->addText(htmlspecialchars("Cell {$i}")); + $text = (0== $i % 2) ? 'X' : ''; + $table->addCell(500)->addText(htmlspecialchars($text)); } // 3. colspan (gridSpan) and rowspan (vMerge) $section->addPageBreak(); -$section->addText("Table with colspan and rowspan", $header); +$section->addText(htmlspecialchars('Table with colspan and rowspan'), $header); $styleTable = array('borderSize' => 6, 'borderColor' => '999999'); $cellRowSpan = array('vMerge' => 'restart', 'valign' => 'center', 'bgColor' => 'FFFF00'); @@ -68,32 +68,32 @@ $cell1 = $table->addCell(2000, $cellRowSpan); $textrun1 = $cell1->addTextRun($cellHCentered); -$textrun1->addText('A'); -$textrun1->addFootnote()->addText('Row span'); +$textrun1->addText(htmlspecialchars('A')); +$textrun1->addFootnote()->addText(htmlspecialchars('Row span')); $cell2 = $table->addCell(4000, $cellColSpan); $textrun2 = $cell2->addTextRun($cellHCentered); -$textrun2->addText('B'); -$textrun2->addFootnote()->addText('Colspan span'); +$textrun2->addText(htmlspecialchars('B')); +$textrun2->addFootnote()->addText(htmlspecialchars('Colspan span')); -$table->addCell(2000, $cellRowSpan)->addText('E', null, $cellHCentered); +$table->addCell(2000, $cellRowSpan)->addText(htmlspecialchars('E'), null, $cellHCentered); $table->addRow(); $table->addCell(null, $cellRowContinue); -$table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered); -$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered); +$table->addCell(2000, $cellVCentered)->addText(htmlspecialchars('C'), null, $cellHCentered); +$table->addCell(2000, $cellVCentered)->addText(htmlspecialchars('D'), null, $cellHCentered); $table->addCell(null, $cellRowContinue); // 4. Nested table $section->addTextBreak(2); -$section->addText('Nested table in a centered and 50% width table.', $header); +$section->addText(htmlspecialchars('Nested table in a centered and 50% width table.'), $header); $table = $section->addTable(array('width' => 50 * 50, 'unit' => 'pct', 'align' => 'center')); $cell = $table->addRow()->addCell(); -$cell->addText('This cell contains nested table.'); +$cell->addText(htmlspecialchars('This cell contains nested table.')); $innerCell = $cell->addTable(array('align' => 'center'))->addRow()->addCell(); -$innerCell->addText('Inside nested table'); +$innerCell->addText(htmlspecialchars('Inside nested table')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index 44bca8a63b..f3553bfef2 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -2,12 +2,12 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); //1.Use EastAisa FontStyle -$section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); +$section->addText(htmlspecialchars('中文楷体样式测试'), array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 0fd56edc0a..dc4fc129cb 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section @@ -15,8 +15,8 @@ $table->addRow(); $cell = $table->addCell(4500); $textrun = $cell->addTextRun(); -$textrun->addText('This is the header with '); -$textrun->addLink('http://google.com', 'link to Google'); +$textrun->addText(htmlspecialchars('This is the header with ')); +$textrun->addLink('http://google.com', htmlspecialchars('link to Google')); $table->addCell(4500)->addImage( 'resources/PhpWord.png', array('width' => 80, 'height' => 80, 'align' => 'right') @@ -24,41 +24,41 @@ // Add header for all other pages $subsequent = $section->addHeader(); -$subsequent->addText("Subsequent pages in Section 1 will Have this!"); +$subsequent->addText(htmlspecialchars('Subsequent pages in Section 1 will Have this!')); $subsequent->addImage('resources/_mars.jpg', array('width' => 80, 'height' => 80)); // Add footer $footer = $section->addFooter(); -$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align' => 'center')); -$footer->addLink('http://google.com', 'Direct Google'); +$footer->addPreserveText(htmlspecialchars('Page {PAGE} of {NUMPAGES}.'), array('align' => 'center')); +$footer->addLink('http://google.com', htmlspecialchars('Direct Google')); // Write some text $section->addTextBreak(); -$section->addText('Some text...'); +$section->addText(htmlspecialchars('Some text...')); // Create a second page $section->addPageBreak(); // Write some text $section->addTextBreak(); -$section->addText('Some text...'); +$section->addText(htmlspecialchars('Some text...')); // Create a third page $section->addPageBreak(); // Write some text $section->addTextBreak(); -$section->addText('Some text...'); +$section->addText(htmlspecialchars('Some text...')); // New portrait section $section2 = $phpWord->addSection(); $sec2Header = $section2->addHeader(); -$sec2Header->addText("All pages in Section 2 will Have this!"); +$sec2Header->addText(htmlspecialchars('All pages in Section 2 will Have this!')); // Write some text $section2->addTextBreak(); -$section2->addText('Some text...'); +$section2->addText(htmlspecialchars('Some text...')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 29b3e73341..d13912119b 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -2,22 +2,22 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->addSection(); -$section->addText('Local image without any styles:'); +$section->addText(htmlspecialchars('Local image without any styles:')); $section->addImage('resources/_mars.jpg'); $section->addTextBreak(2); -$section->addText('Local image with styles:'); +$section->addText(htmlspecialchars('Local image with styles:')); $section->addImage('resources/_earth.jpg', array('width' => 210, 'height' => 210, 'align' => 'center')); $section->addTextBreak(2); // Remote image $source = 'http://php.net/images/logos/php-med-trans-light.gif'; -$section->addText("Remote image from: {$source}"); +$section->addText(htmlspecialchars("Remote image from: {$source}")); $section->addImage($source); //Wrapping style @@ -25,43 +25,52 @@ $wrappingStyles = array('inline', 'behind', 'infront', 'square', 'tight'); foreach ($wrappingStyles as $wrappingStyle) { $section->addTextBreak(5); - $section->addText('Wrapping style ' . $wrappingStyle); - $section->addImage('resources/_earth.jpg', array('positioning' => 'relative', 'marginTop' => -1, 'marginLeft' => 1, - 'width' => 80, 'height' => 80, 'wrappingStyle' => $wrappingStyle)); - $section->addText($text); + $section->addText(htmlspecialchars("Wrapping style {$wrappingStyle}")); + $section->addImage( + 'resources/_earth.jpg', + array( + 'positioning' => 'relative', + 'marginTop' => -1, + 'marginLeft' => 1, + 'width' => 80, + 'height' => 80, + 'wrappingStyle' => $wrappingStyle, + ) + ); + $section->addText(htmlspecialchars($text)); } //Absolute positioning $section->addTextBreak(3); -$section->addText('Absolute positioning: see top right corner of page'); +$section->addText(htmlspecialchars('Absolute positioning: see top right corner of page')); $section->addImage( 'resources/_mars.jpg', array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), - 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, - 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT, + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), + 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE, + 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT, 'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, - 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, - 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5), - 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.55) + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE, + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15.5), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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->addText(htmlspecialchars('Relative positioning: Horizontal position center relative to column,')); +$section->addText(htmlspecialchars('Vertical position top relative to line')); $section->addImage( 'resources/_mars.jpg', array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), - 'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE, - 'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER, + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(3), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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 + 'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_VERTICAL_TOP, + 'posVerticalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_LINE, ) ); diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index 3a3d34abc5..3a29e3fdee 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -10,80 +10,83 @@ // Style definition -$phpWord->addFontStyle('myOwnStyle', array('color'=>'FF0000')); -$phpWord->addParagraphStyle('P-Style', array('spaceAfter'=>95)); +$phpWord->addFontStyle('myOwnStyle', array('color' => 'FF0000')); +$phpWord->addParagraphStyle('P-Style', array('spaceAfter' => 95)); $phpWord->addNumberingStyle( 'multilevel', - array('type' => 'multilevel', 'levels' => array( - array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360), - array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720), - ) + array( + 'type' => 'multilevel', + 'levels' => array( + 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); // Lists -$section->addText('Multilevel list.'); -$section->addListItem('List Item I', 0, null, 'multilevel'); -$section->addListItem('List Item I.a', 1, null, 'multilevel'); -$section->addListItem('List Item I.b', 1, null, 'multilevel'); -$section->addListItem('List Item II', 0, null, 'multilevel'); -$section->addListItem('List Item II.a', 1, null, 'multilevel'); -$section->addListItem('List Item III', 0, null, 'multilevel'); +$section->addText(htmlspecialchars('Multilevel list.')); +$section->addListItem(htmlspecialchars('List Item I'), 0, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item I.a'), 1, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item I.b'), 1, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item II'), 0, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item II.a'), 1, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item III'), 0, null, 'multilevel'); $section->addTextBreak(2); -$section->addText('Basic simple bulleted list.'); -$section->addListItem('List Item 1'); -$section->addListItem('List Item 2'); -$section->addListItem('List Item 3'); +$section->addText(htmlspecialchars('Basic simple bulleted list.')); +$section->addListItem(htmlspecialchars('List Item 1')); +$section->addListItem(htmlspecialchars('List Item 2')); +$section->addListItem(htmlspecialchars('List Item 3')); $section->addTextBreak(2); -$section->addText('Continue from multilevel list above.'); -$section->addListItem('List Item IV', 0, null, 'multilevel'); -$section->addListItem('List Item IV.a', 1, null, 'multilevel'); +$section->addText(htmlspecialchars('Continue from multilevel list above.')); +$section->addListItem(htmlspecialchars('List Item IV'), 0, null, 'multilevel'); +$section->addListItem(htmlspecialchars('List Item IV.a'), 1, null, 'multilevel'); $section->addTextBreak(2); -$section->addText('Multilevel predefined list.'); -$section->addListItem('List Item 1', 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 2', 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 3', 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 4', 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 5', 2, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 6', 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); -$section->addListItem('List Item 7', 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addText(htmlspecialchars('Multilevel predefined list.')); +$section->addListItem(htmlspecialchars('List Item 1'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 2'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 3'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 4'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 5'), 2, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 6'), 1, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); +$section->addListItem(htmlspecialchars('List Item 7'), 0, 'myOwnStyle', $predefinedMultilevel, 'P-Style'); $section->addTextBreak(2); -$section->addText('List with inline formatting.'); +$section->addText(htmlspecialchars('List with inline formatting.')); $listItemRun = $section->addListItemRun(); -$listItemRun->addText('List item 1'); -$listItemRun->addText(' in bold', array('bold'=>true)); +$listItemRun->addText(htmlspecialchars('List item 1')); +$listItemRun->addText(htmlspecialchars(' in bold'), array('bold' => true)); $listItemRun = $section->addListItemRun(); -$listItemRun->addText('List item 2'); -$listItemRun->addText(' in italic', array('italic'=>true)); +$listItemRun->addText(htmlspecialchars('List item 2')); +$listItemRun->addText(htmlspecialchars(' in italic'), array('italic' => true)); $listItemRun = $section->addListItemRun(); -$listItemRun->addText('List item 3'); -$listItemRun->addText(' underlined', array('underline'=>'dash')); +$listItemRun->addText(htmlspecialchars('List item 3')); +$listItemRun->addText(htmlspecialchars(' 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'), - ) + 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); +$section->addTitle(htmlspecialchars('Heading 1'), 1); +$section->addTitle(htmlspecialchars('Heading 2'), 2); +$section->addTitle(htmlspecialchars('Heading 3'), 3); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index 1bd61e79c6..dd06670e65 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -2,17 +2,21 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->addSection(); // Add hyperlink elements -$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); +$section->addLink( + 'http://www.google.com', + htmlspecialchars('Best search engine'), + array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE) +); $section->addTextBreak(2); -$phpWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000')); +$phpWord->addLinkStyle('myOwnLinkStyle', array('bold' => true, 'color' => '808000')); $section->addLink('http://www.bing.com', null, 'myOwnLinkStyle'); $section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle'); diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index af23a00f02..2a216c2378 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -2,12 +2,12 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code $section = $phpWord->addSection(); -$section->addText('You can open this OLE object by double clicking on the icon:'); +$section->addText(htmlspecialchars('You can open this OLE object by double clicking on the icon:')); $section->addTextBreak(2); $section->addObject('resources/_sheet.xls'); diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index b18b1bc9ae..8f8889b83c 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -19,7 +19,7 @@ $phpWord->addTitleStyle(4, array('size' => 12)); // Add text elements -$section->addText('Table of contents 1'); +$section->addText(htmlspecialchars('Table of contents 1')); $section->addTextBreak(2); // Add TOC #1 @@ -27,11 +27,11 @@ $section->addTextBreak(2); // Filler -$section->addText('Text between TOC'); +$section->addText(htmlspecialchars('Text between TOC')); $section->addTextBreak(2); // Add TOC #1 -$section->addText('Table of contents 2'); +$section->addText(htmlspecialchars('Table of contents 2')); $section->addTextBreak(2); $toc2 = $section->addTOC($fontStyle2); $toc2->setMinDepth(2); @@ -40,33 +40,33 @@ // Add Titles $section->addPageBreak(); -$section->addTitle('I am Title 1', 1); -$section->addText('Some text...'); +$section->addTitle(htmlspecialchars('Foo & Bar'), 1); +$section->addText(htmlspecialchars('Some text...')); $section->addTextBreak(2); -$section->addTitle('I am a Subtitle of Title 1', 2); +$section->addTitle(htmlspecialchars('I am a Subtitle of Title 1'), 2); $section->addTextBreak(2); -$section->addText('Some more text...'); +$section->addText(htmlspecialchars('Some more text...')); $section->addTextBreak(2); -$section->addTitle('Another Title (Title 2)', 1); -$section->addText('Some text...'); +$section->addTitle(htmlspecialchars('Another Title (Title 2)'), 1); +$section->addText(htmlspecialchars('Some text...')); $section->addPageBreak(); -$section->addTitle('I am Title 3', 1); -$section->addText('And more text...'); +$section->addTitle(htmlspecialchars('I am Title 3'), 1); +$section->addText(htmlspecialchars('And more text...')); $section->addTextBreak(2); -$section->addTitle('I am a Subtitle of Title 3', 2); -$section->addText('Again and again, more text...'); -$section->addTitle('Subtitle 3.1.1', 3); -$section->addText('Text'); -$section->addTitle('Subtitle 3.1.1.1', 4); -$section->addText('Text'); -$section->addTitle('Subtitle 3.1.1.2', 4); -$section->addText('Text'); -$section->addTitle('Subtitle 3.1.2', 3); -$section->addText('Text'); +$section->addTitle(htmlspecialchars('I am a Subtitle of Title 3'), 2); +$section->addText(htmlspecialchars('Again and again, more text...')); +$section->addTitle(htmlspecialchars('Subtitle 3.1.1'), 3); +$section->addText(htmlspecialchars('Text')); +$section->addTitle(htmlspecialchars('Subtitle 3.1.1.1'), 4); +$section->addText(htmlspecialchars('Text')); +$section->addTitle(htmlspecialchars('Subtitle 3.1.1.2'), 4); +$section->addText(htmlspecialchars('Text')); +$section->addTitle(htmlspecialchars('Subtitle 3.1.2'), 3); +$section->addText(htmlspecialchars('Text')); -echo date('H:i:s'), " Note: Please refresh TOC manually.", EOL; +echo date('H:i:s'), ' Note: Please refresh TOC manually.', EOL; // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 313cfbed49..f630bdf22d 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -10,7 +10,7 @@ $section = $phpWord->addSection(); $header = $section->addHeader(); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); -$section->addText('The header reference to the current section includes a watermark image.'); +$section->addText(htmlspecialchars('The header reference to the current section includes a watermark image.')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index a209ce3906..fc0e5419b0 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -13,17 +13,17 @@ $fontStyle = array('size' => 24); $section = $phpWord->addSection(); -$section->addText('Text break with no style:'); +$section->addText(htmlspecialchars('Text break with no style:')); $section->addTextBreak(); -$section->addText('Text break with defined font style:'); +$section->addText(htmlspecialchars('Text break with defined font style:')); $section->addTextBreak(1, 'fontStyle'); -$section->addText('Text break with defined paragraph style:'); +$section->addText(htmlspecialchars('Text break with defined paragraph style:')); $section->addTextBreak(1, null, 'paragraphStyle'); -$section->addText('Text break with inline font style:'); +$section->addText(htmlspecialchars('Text break with inline font style:')); $section->addTextBreak(1, $fontStyle); -$section->addText('Text break with inline paragraph style:'); +$section->addText(htmlspecialchars('Text break with inline paragraph style:')); $section->addTextBreak(1, null, $paragraphStyle); -$section->addText('Done.'); +$section->addText(htmlspecialchars('Done.')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_20_BGColor.php b/samples/Sample_20_BGColor.php index 892cd8b2a5..ebee8544fa 100644 --- a/samples/Sample_20_BGColor.php +++ b/samples/Sample_20_BGColor.php @@ -2,13 +2,19 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$section->addText("This is some text highlighted using fgColor (limited to 15 colors) ", array("fgColor" => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); -$section->addText("This one uses bgColor and is using hex value (0xfbbb10)", array("bgColor" => "fbbb10")); -$section->addText("Compatible with font colors", array("color"=>"0000ff", "bgColor" => "fbbb10")); +$section->addText( + htmlspecialchars('This is some text highlighted using fgColor (limited to 15 colors) '), + array('fgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW) +); +$section->addText( + htmlspecialchars('This one uses bgColor and is using hex value (0xfbbb10)'), + array('bgColor' => 'fbbb10') +); +$section->addText(htmlspecialchars('Compatible with font colors'), array('color' => '0000ff', 'bgColor' => 'fbbb10')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php index b600ec006e..df3162c33c 100644 --- a/samples/Sample_21_TableRowRules.php +++ b/samples/Sample_21_TableRowRules.php @@ -2,30 +2,50 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$section->addText("By default, when you insert an image, it adds a textbreak after its content."); -$section->addText("If we want a simple border around an image, we wrap the image inside a table->row->cell"); -$section->addText("On the image with the red border, even if we set the row height to the height of the image, the textbreak is still there:"); +$section->addText(htmlspecialchars('By default, when you insert an image, it adds a textbreak after its content.')); +$section->addText( + htmlspecialchars('If we want a simple border around an image, we wrap the image inside a table->row->cell') +); +$section->addText( + htmlspecialchars( + 'On the image with the red border, even if we set the row height to the height of the image, ' + . 'the textbreak is still there:' + ) +); -$table1 = $section->addTable(array("cellMargin" => 0, "cellMarginRight" => 0, "cellMarginBottom" => 0, "cellMarginLeft" => 0)); +$table1 = $section->addTable(array('cellMargin' => 0, 'cellMarginRight' => 0, 'cellMarginBottom' => 0, 'cellMarginLeft' => 0)); $table1->addRow(3750); -$cell1 = $table1->addCell(null, array("valign" => "top", "borderSize" => 30, "borderColor" => "ff0000")); -$cell1->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center")); +$cell1 = $table1->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => 'ff0000')); +$cell1->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center')); $section->addTextBreak(); -$section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:"); +$section->addText( + htmlspecialchars( + "But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:" + ) +); -$table2 = $section->addTable(array("cellMargin" => 0, "cellMarginRight" => 0, "cellMarginBottom" => 0, "cellMarginLeft" => 0)); -$table2->addRow(3750, array("exactHeight" => true)); -$cell2 = $table2->addCell(null, array("valign" => "top", "borderSize" => 30, "borderColor" => "00ff00")); -$cell2->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center")); +$table2 = $section->addTable( + array( + 'cellMargin' => 0, + 'cellMarginRight' => 0, + 'cellMarginBottom' => 0, + 'cellMarginLeft' => 0, + ) +); +$table2->addRow(3750, array('exactHeight' => true)); +$cell2 = $table2->addCell(null, array('valign' => 'top', 'borderSize' => 30, 'borderColor' => '00ff00')); +$cell2->addImage('./resources/_earth.jpg', array('width' => 250, 'height' => 250, 'align' => 'center')); $section->addTextBreak(); -$section->addText("In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips."); -$section->addText("So: $"."table2->addRow(3750, array('exactHeight'=>true));"); +$section->addText( + htmlspecialchars('In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.') +); +$section->addText(htmlspecialchars('So: $' . "table2->addRow(3750, array('exactHeight'=>true));")); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_22_CheckBox.php b/samples/Sample_22_CheckBox.php index e7aae5bad2..b5d4a7a5a8 100644 --- a/samples/Sample_22_CheckBox.php +++ b/samples/Sample_22_CheckBox.php @@ -2,17 +2,17 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$section->addText('Check box in section'); -$section->addCheckBox('chkBox1', 'Checkbox 1'); -$section->addText('Check box in table cell'); +$section->addText(htmlspecialchars('Check box in section')); +$section->addCheckBox('chkBox1', htmlspecialchars('Checkbox 1')); +$section->addText(htmlspecialchars('Check box in table cell')); $table = $section->addTable(); $table->addRow(); $cell = $table->addCell(); -$cell->addCheckBox('chkBox2', 'Checkbox 2'); +$cell->addCheckBox('chkBox2', htmlspecialchars('Checkbox 2')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_25_TextBox.php b/samples/Sample_25_TextBox.php index 0a659ddb3d..afeb863d1c 100644 --- a/samples/Sample_25_TextBox.php +++ b/samples/Sample_25_TextBox.php @@ -2,35 +2,43 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); // In section -$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.'); +$textbox = $section->addTextBox( + array( + 'align' => 'center', + 'width' => 400, + 'height' => 150, + 'borderSize' => 1, + 'borderColor' => '#FF0000', + ) +); +$textbox->addText(htmlspecialchars('Text box content in section.')); +$textbox->addText(htmlspecialchars('Another line.')); $cell = $textbox->addTable()->addRow()->addCell(); -$cell->addText('Table inside textbox'); +$cell->addText(htmlspecialchars('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('Textbox inside table'); +$textbox->addText(htmlspecialchars('Textbox inside table')); // Inside header with textrun $header = $section->addHeader(); $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)); -$textrun->addText(', '); -$textrun->addLink('http://www.google.com', 'link'); -$textrun->addText(', and image '); +$textrun->addText(htmlspecialchars('TextBox in header. TextBox can contain a TextRun ')); +$textrun->addText(htmlspecialchars('with bold text'), array('bold' => true)); +$textrun->addText(htmlspecialchars(', ')); +$textrun->addLink('http://www.google.com', htmlspecialchars('link')); +$textrun->addText(htmlspecialchars(', and image ')); $textrun->addImage('resources/_earth.jpg', array('width' => 18, 'height' => 18)); -$textrun->addText('.'); +$textrun->addText(htmlspecialchars('.')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_26_Html.php b/samples/Sample_26_Html.php index 92b3aa498c..4235c94650 100644 --- a/samples/Sample_26_Html.php +++ b/samples/Sample_26_Html.php @@ -20,4 +20,4 @@ echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { include_once 'Sample_Footer.php'; -} \ No newline at end of file +} diff --git a/samples/Sample_27_Field.php b/samples/Sample_27_Field.php index fd75037275..9bdbef8243 100644 --- a/samples/Sample_27_Field.php +++ b/samples/Sample_27_Field.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -10,19 +10,19 @@ // Add Field elements // See Element/Field.php for all options -$section->addText('Date field:'); -$section->addField('DATE', array('dateformat'=>'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat')); +$section->addText(htmlspecialchars('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(htmlspecialchars('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')); +$section->addText(htmlspecialchars('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.'); +$textrun->addText(htmlspecialchars('This is the date of lunar calendar ')); +$textrun->addField('DATE', array('dateformat' => 'd-M-yyyy H:mm:ss'), array('PreserveFormat', 'LunarCalendar')); +$textrun->addText(htmlspecialchars(' written in a textrun.')); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); diff --git a/samples/Sample_29_Line.php b/samples/Sample_29_Line.php index f9162c2a7d..8bb192cfc8 100644 --- a/samples/Sample_29_Line.php +++ b/samples/Sample_29_Line.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -10,50 +10,50 @@ // Add Line elements // See Element/Line.php for all options -$section->addText('Horizontal Line (Inline style):'); +$section->addText(htmlspecialchars('Horizontal Line (Inline style):')); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), - 'positioning' => 'absolute' + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), + 'positioning' => 'absolute', ) ); -$section->addText('Vertical Line (Inline style):'); +$section->addText(htmlspecialchars('Vertical Line (Inline style):')); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), - 'positioning' => 'absolute' + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), + 'positioning' => 'absolute', ) ); // Two text break $section->addTextBreak(1); -$section->addText('Positioned Line (red):'); +$section->addText(htmlspecialchars('Positioned Line (red):')); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), - 'positioning' => 'absolute', + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1), + 'positioning' => 'absolute', 'posHorizontalRel' => 'page', - 'posVerticalRel' => 'page', - 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10), - 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8), - 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, - 'color' => 'red' + 'posVerticalRel' => 'page', + 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10), + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8), + 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE, + 'color' => 'red', ) ); -$section->addText('Horizontal Formatted Line'); +$section->addText(htmlspecialchars('Horizontal Formatted Line')); $section->addLine( array( - 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15), - 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0), + 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15), + 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(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 + '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, ) ); diff --git a/samples/Sample_31_Shape.php b/samples/Sample_31_Shape.php index 02399992e7..3df71b4cc8 100644 --- a/samples/Sample_31_Shape.php +++ b/samples/Sample_31_Shape.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true)); @@ -10,67 +10,80 @@ $section = $phpWord->addSection(); // Arc -$section->addTitle('Arc', 1); +$section->addTitle(htmlspecialchars('Arc'), 1); $section->addShape( 'arc', array( - 'points' => '-90 20', - 'frame' => array('width' => 120, 'height' => 120), + 'points' => '-90 20', + 'frame' => array('width' => 120, 'height' => 120), 'outline' => array('color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'), ) ); // Curve -$section->addTitle('Curve', 1); +$section->addTitle(htmlspecialchars('Curve'), 1); $section->addShape( 'curve', array( - 'points' => '1,100 200,1 1,50 200,50', 'connector' => 'elbow', - 'outline' => array('color' => '#66cc00', 'weight' => 2, 'dash' => 'dash', 'startArrow' => 'diamond', 'endArrow' => 'block'), + 'points' => '1,100 200,1 1,50 200,50', + 'connector' => 'elbow', + 'outline' => array( + 'color' => '#66cc00', + 'weight' => 2, + 'dash' => 'dash', + 'startArrow' => 'diamond', + 'endArrow' => 'block', + ), ) ); // Line -$section->addTitle('Line', 1); +$section->addTitle(htmlspecialchars('Line'), 1); $section->addShape( 'line', array( - 'points' => '1,1 150,30', - 'outline' => array('color' => '#cc00ff', 'line' => 'thickThin', 'weight' => 3, 'startArrow' => 'oval', 'endArrow' => 'classic'), + 'points' => '1,1 150,30', + 'outline' => array( + 'color' => '#cc00ff', + 'line' => 'thickThin', + 'weight' => 3, + 'startArrow' => 'oval', + 'endArrow' => 'classic', + ), ) ); // Polyline -$section->addTitle('Polyline', 1); +$section->addTitle(htmlspecialchars('Polyline'), 1); $section->addShape( 'polyline', array( - 'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50', + 'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50', 'outline' => array('color' => '#cc6666', 'weight' => 2, 'startArrow' => 'none', 'endArrow' => 'classic'), ) ); // Rectangle -$section->addTitle('Rectangle', 1); +$section->addTitle(htmlspecialchars('Rectangle'), 1); $section->addShape( 'rect', array( 'roundness' => 0.2, - 'frame' => array('width' => 100, 'height' => 100, 'left' => 1, 'top' => 1), - 'fill' => array('color' => '#FFCC33'), - 'outline' => array('color' => '#990000', 'weight' => 1), - 'shadow' => array(), + 'frame' => array('width' => 100, 'height' => 100, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#FFCC33'), + 'outline' => array('color' => '#990000', 'weight' => 1), + 'shadow' => array(), ) ); // Oval -$section->addTitle('Oval', 1); +$section->addTitle(htmlspecialchars('Oval'), 1); $section->addShape( 'oval', array( - 'frame' => array('width' => 100, 'height' => 70, 'left' => 1, 'top' => 1), - 'fill' => array('color' => '#33CC99'), - 'outline' => array('color' => '#333333', 'weight' => 2), + 'frame' => array('width' => 100, 'height' => 70, 'left' => 1, 'top' => 1), + 'fill' => array('color' => '#33CC99'), + 'outline' => array('color' => '#333333', 'weight' => 2), 'extrusion' => array(), ) ); diff --git a/samples/Sample_32_Chart.php b/samples/Sample_32_Chart.php index 5f2188ed42..b61a646fde 100644 --- a/samples/Sample_32_Chart.php +++ b/samples/Sample_32_Chart.php @@ -4,7 +4,7 @@ use PhpOffice\PhpWord\Shared\Converter; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); @@ -12,7 +12,7 @@ // 2D charts $section = $phpWord->addSection(); -$section->addTitle('2D charts', 1); +$section->addTitle(htmlspecialchars('2D charts'), 1); $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous')); $chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar'); @@ -26,9 +26,7 @@ foreach ($chartTypes as $chartType) { $section->addTitle(ucfirst($chartType), 2); $chart = $section->addChart($chartType, $categories, $series1); - $chart->getStyle() - ->setWidth(Converter::inchToEmu(2.5)) - ->setHeight(Converter::inchToEmu(2)); + $chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2)); if (in_array($chartType, $twoSeries)) { $chart->addSeries($categories, $series2); } @@ -40,7 +38,7 @@ // 3D charts $section = $phpWord->addSection(array('breakType' => 'continuous')); -$section->addTitle('3D charts', 1); +$section->addTitle(htmlspecialchars('3D charts'), 1); $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous')); $chartTypes = array('pie', 'bar', 'column', 'line', 'area'); diff --git a/samples/Sample_33_FormField.php b/samples/Sample_33_FormField.php index d3811fc46b..9f356810dc 100644 --- a/samples/Sample_33_FormField.php +++ b/samples/Sample_33_FormField.php @@ -2,22 +2,22 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->getProtection()->setEditing('forms'); $section = $phpWord->addSection(); $textrun = $section->addTextRun(); -$textrun->addText('Form fields can be added in a text run and can be in form of textinput '); +$textrun->addText(htmlspecialchars('Form fields can be added in a text run and can be in form of textinput ')); $textrun->addFormField('textinput')->setName('MyTextBox'); -$textrun->addText(', checkbox '); +$textrun->addText(htmlspecialchars(', checkbox ')); $textrun->addFormField('checkbox')->setDefault(true); -$textrun->addText(', or dropdown '); +$textrun->addText(htmlspecialchars(', or dropdown ')); $textrun->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3')); -$textrun->addText('. You have to set document protection to "forms" to enable dropdown.'); +$textrun->addText(htmlspecialchars('. You have to set document protection to "forms" to enable dropdown.')); -$section->addText('They can also be added as a stand alone paragraph.'); +$section->addText(htmlspecialchars('They can also be added as a stand alone paragraph.')); $section->addFormField('textinput')->setValue('Your name'); // Save file diff --git a/samples/Sample_34_SDT.php b/samples/Sample_34_SDT.php index 241dee2a19..19ac42fe34 100644 --- a/samples/Sample_34_SDT.php +++ b/samples/Sample_34_SDT.php @@ -2,21 +2,21 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $textrun = $section->addTextRun(); -$textrun->addText('Combobox: '); +$textrun->addText(htmlspecialchars('Combobox: ')); $textrun->addSDT('comboBox')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); $textrun = $section->addTextRun(); -$textrun->addText('Date: '); +$textrun->addText(htmlspecialchars('Date: ')); $textrun->addSDT('date'); $textrun = $section->addTextRun(); -$textrun->addText('Drop down list: '); +$textrun->addText(htmlspecialchars('Drop down list: ')); $textrun->addSDT('dropDownList')->setListItems(array('1' => 'Choice 1', '2' => 'Choice 2')); // Save file diff --git a/samples/Sample_35_InternalLink.php b/samples/Sample_35_InternalLink.php index 3b6aae5157..1b907f8724 100644 --- a/samples/Sample_35_InternalLink.php +++ b/samples/Sample_35_InternalLink.php @@ -2,17 +2,17 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); -$section->addTitle( 'This is page 1', 1 ); +$section->addTitle(htmlspecialchars('This is page 1'), 1); $linkIsInternal = true; -$section->addLink('MyBookmark', 'Take me to page 3', null ,null,$linkIsInternal); +$section->addLink('MyBookmark', htmlspecialchars('Take me to page 3'), null, null, $linkIsInternal); $section->addPageBreak(); -$section->addTitle( 'This is page 2', 1 ); +$section->addTitle(htmlspecialchars('This is page 2'), 1); $section->addPageBreak(); -$section->addTitle( 'This is page 3', 1 ); +$section->addTitle(htmlspecialchars('This is page 3'), 1); $section->addBookmark('MyBookmark'); // Save file diff --git a/samples/Sample_36_RTL.php b/samples/Sample_36_RTL.php index 9b85fb1e1f..ec326ae025 100644 --- a/samples/Sample_36_RTL.php +++ b/samples/Sample_36_RTL.php @@ -2,15 +2,15 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", EOL; +echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $textrun = $section->addTextRun(); -$textrun->addText('This is a Left to Right paragraph.'); +$textrun->addText(htmlspecialchars('This is a Left to Right paragraph.')); $textrun = $section->addTextRun(array('align' => 'right')); -$textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true)); +$textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است'), array('rtl' => true)); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); From 5285f0034d18a22eb5f447daa7ab0a30d83f9e8c Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 1 Jan 2015 20:46:30 +0400 Subject: [PATCH 171/174] #51 (updated changelog). --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8c06f43e..8cb157ff90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap - Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko - Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 - Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 -- Reverted GH-51 - @RomanSyroeshko +- Reverted #51. All text escaping must be performed out of the library - @RomanSyroeshko #51 ## 0.11.1 - 2 June 2014 From 5d8a49949e2841243e64d769e8d0fd4f0d359032 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 1 Jan 2015 20:52:04 +0400 Subject: [PATCH 172/174] Changelog minor refactoring. --- CHANGELOG.md | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb157ff90..efc7e42ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,39 +8,39 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap ### Features -- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin GH-123 +- Element: Ability to add drawing shapes (arc, curve, line, polyline, rect, oval) using new `Shape` element - @ivanlanin #123 - Font: New `scale`, `spacing`, and `kerning` property of font style - @ivanlanin -- Paragraph: Added shading to the paragraph style for full width shading - @lrobert GH-264 -- RTF Writer: Support for sections, margins, and borders - @ivanlanin GH-249 -- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin GH-249 +- Paragraph: Added shading to the paragraph style for full width shading - @lrobert #264 +- RTF Writer: Support for sections, margins, and borders - @ivanlanin #249 +- Section: Ability to set paper size, e.g. A4, A3, and Legal - @ivanlanin #249 - General: New `PhpWord::save()` method to encapsulate `IOFactory` - @ivanlanin - General: New `Shared\Converter` static class - @ivanlanin -- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin GH-278 +- Chart: Basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) - @ivanlanin #278 - Chart: 3D charts and ability to set width and height - @ivanlanin -- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin GH-266 +- FormField: Ability to add textinput, checkbox, and dropdown form elements - @ivanlanin #266 - Setting: Ability to define document protection (readOnly, comments, trackedChanges, forms) - @ivanlanin - Setting: Ability to remove [Compatibility Mode] text in the MS Word title bar - @ivanlanin - SDT: Ability to add structured document tag elements (comboBox, dropDownList, date) - @ivanlanin -- Paragraph: Support for paragraph with borders - @ivanlanin GH-294 -- Word2007 Writer : Support for RTL - @Progi1984 GH-331 -- MsDOC Reader: Basic MsDOC Reader - @Progi1984 GH-23 GH-287 -- "absolute" horizontal and vertical positioning of Frame - @basjan GH-302 -- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 GH-426 +- Paragraph: Support for paragraph with borders - @ivanlanin #294 +- Word2007 Writer : Support for RTL - @Progi1984 #331 +- MsDOC Reader: Basic MsDOC Reader - @Progi1984 #23, #287 +- "absolute" horizontal and vertical positioning of Frame - @basjan #302 +- Add new-page function for PDF generation. For multiple PDF-backends - @chc88 #426 - Report style options enumerated when style unknown - @h6w ### Bugfixes -- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo GH-261 -- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich GH-270 -- Page breaks on titles and tables - @ivanlanin GH-274 -- Table inside vertical border does not rendered properly - @ivanlanin GH-280 -- `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin GH-294 -- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit GH-327 -- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko GH-340 -- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA GH-356 +- Fix rare PclZip/realpath/PHP version problem - @andrew-kzoo #261 +- `addHTML` encoding and ampersand fixes for PHP 5.3 - @bskrtich #270 +- Page breaks on titles and tables - @ivanlanin #274 +- Table inside vertical border does not rendered properly - @ivanlanin #280 +- `add` of container should be case insensitive, e.g. `addToc` should be accepted, not only `addTOC` - @ivanlanin #294 +- Fix specific borders (and margins) were not written correctly in word2007 writer - @pscheit #327 +- "HTML is not a valid writer" exception while running "Sample_36_RTL.php" - @RomanSyroeshko #340 +- "addShape()" magic method in AbstractContainer is mistakenly named as "addObject()" - @GMTA #356 - `Element\Section::setPageSizeW()` and `Element\Section::setPageSizeH()` were mentioned in the docs but not implemented. -- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko GH-401 -- `` tag is closed with `` tag: - @franzholz GH-438 +- Special Characters (ampersand) in Title break docx output - @RomanSyroeshko #401 +- `` tag is closed with `` tag: - @franzholz #438 ### Deprecated @@ -53,14 +53,14 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap ### Miscellaneous -- Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin GH-238 -- Docs: Correct elements.rst about Line - @chrissharkman GH-292 -- PclZip: Remove temporary file after used - @andrew-kzoo GH-265 -- Autoloader: Add the ability to set the autoloader options - @bskrtich GH-267 +- Docs: Add known issue on `README` about requirement for temporary folder to be writable and update `samples/index.php` for this requirement check - @ivanlanin #238 +- Docs: Correct elements.rst about Line - @chrissharkman #292 +- PclZip: Remove temporary file after used - @andrew-kzoo #265 +- Autoloader: Add the ability to set the autoloader options - @bskrtich #267 - Element: Refactor elements to move set relation Id from container to element - @ivanlanin - Introduced CreateTemporaryFileException, CopyFileException - @RomanSyroeshko -- Settings: added method to set user defined temporary directory - @RomanSyroeshko GH-310 -- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko GH-216 +- Settings: added method to set user defined temporary directory - @RomanSyroeshko #310 +- Renamed `Template` into `TemplateProcessor` - @RomanSyroeshko #216 - Reverted #51. All text escaping must be performed out of the library - @RomanSyroeshko #51 ## 0.11.1 - 2 June 2014 From 81be513200778991c944480794008eee413a40c6 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Thu, 1 Jan 2015 21:10:31 +0400 Subject: [PATCH 173/174] Changelog minor refactoring. --- CHANGELOG.md | 218 +++++++++++++++++++++++++-------------------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efc7e42ea7..70b1ba6a34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,7 @@ This release added form fields (textinput, checkbox, and dropdown), drawing shap This is an immediate bugfix release for HTML reader. -- HTML Reader: `

` and header tags puts no output - @canyildiz @ivanlanin GH-257 +- HTML Reader: `

` and header tags puts no output - @canyildiz @ivanlanin #257 ## 0.11.0 - 1 June 2014 @@ -75,17 +75,17 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four ### 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 +- Image: Ability to define relative and absolute positioning - @basjan #217 +- Footer: Conform footer with header by adding firstPage, evenPage and by inheritance - @basjan @ivanlanin #219 +- Element: New `TextBox` element - @basjan @ivanlanin #228, #229, #231 +- HTML: Ability to add elements to PHPWord object via html - @basjan #231 +- Element: New `ListItemRun` element that can add a list item with inline formatting like a textrun - @basjan #235 +- Table: Ability to add table inside a cell (nested table) - @ivanlanin #149 +- RTF Writer: UTF8 support for RTF: Internal UTF8 text is converted to Unicode before writing - @ivanlanin #158 +- Table: Ability to define table width (in percent and twip) and position - @ivanlanin #237 +- RTF Writer: Ability to add links and page breaks in RTF - @ivanlanin #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 +- Config: Ability to use a config file to store various common settings - @ivanlanin #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 @@ -93,23 +93,23 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four - 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 +- Image: Enable "image float left" - @ivanlanin #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 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 GH-254 -- RTF Writer: Basic table writing - @ivanlanin GH-245 +- Element: New `Field` element - @basjan #251 +- RTF Reader: Basic RTF reader - @ivanlanin #72, #252 +- Element: New `Line` element - @basjan #253 +- Title: Ability to apply numbering in heading - @ivanlanin #193 +- HTML Reader: Basic HTML reader - @ivanlanin #80, #254 +- RTF Writer: Basic table writing - @ivanlanin #245 ### 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 -- Title: Orphan `w:fldChar` caused OpenOffice to crash when opening DOCX - @ivanlanin GH-236 +- Header: All images added to the second header were assigned to the first header - @basjan #222 +- Conversion: Fix conversion from cm to pixel, pixel to cm, and pixel to point - @basjan #233, #234 +- PageBreak: Page break adds new line in the beginning of the new page - @ivanlanin #150 +- Image: `marginLeft` and `marginTop` cannot accept float value - @ivanlanin #248 +- Title: Orphan `w:fldChar` caused OpenOffice to crash when opening DOCX - @ivanlanin #236 ### Deprecated @@ -121,13 +121,13 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four ### Miscellaneous -- License: Change the project license from LGPL 2.1 into LGPL 3.0 - GH-211 +- License: Change the project license from LGPL 2.1 into LGPL 3.0 - #211 - Word2007 Writer: New `Style\Image` class - @ivanlanin -- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 +- Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin #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 +- Docs: Create gh-pages branch for API documentation - @Progi1984 #154 +- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin #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 @@ -140,7 +140,7 @@ This release marked the change of PHPWord license from LGPL 2.1 to LGPL 3. Four This is a bugfix release for `php-zip` requirement in Composer. -- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich GH-246 +- Change Composer requirements for php-zip from `require` to `suggest` - @bskrtich #246 ## 0.10.0 - 4 May 2014 @@ -148,48 +148,48 @@ This release marked heavy refactorings on internal code structure with the creat ### 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 +- Image: Get image dimensions without EXIF extension - @andrew-kzoo #184 +- Table: Add `tblGrid` element for Libre/Open Office table sizing - @gianis6 #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 +- Font: Add `bgColor` to font style to define background using HEX color - @jcarignan #168 +- Table: Add `exactHeight` to row style to define whether row height should be exact or atLeast - @jcarignan #168 +- Element: New `CheckBox` element for sections and table cells - @ozilion #156 +- Settings: Ability to use PCLZip as alternative to ZipArchive - @bskrtich @ivanlanin #106, #140, #185 +- Template: Ability to find & replace variables in headers & footers - @dgudgeon #190 +- Template: Ability to clone & delete block of text using `cloneBlock` and `deleteBlock` - @diego-vieira #191 +- TOC: Ability to have two or more TOC in one document and to set min and max depth for TOC - @Pyreweb #189 +- Table: Ability to add footnote in table cell - @ivanlanin #187 +- Footnote: Ability to add image in footnote - @ivanlanin #187 +- ListItem: Ability to add list item in header/footer - @ivanlanin #187 +- CheckBox: Ability to add checkbox in header/footer - @ivanlanin #187 +- Link: Ability to add link in header/footer - @ivanlanin #187 +- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin #187 +- Media: Add `Media::resetElements()` to reset all media data - @juzi #19 +- General: Add `Style::resetStyles()` - @ivanlanin #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 +- ListItem: Ability to create custom list and reset list number - @ivanlanin #10, #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 +- Image: Keep image aspect ratio if only 1 dimension styled - @japonicus #194 +- HTML Writer: Basic HTML writer: text, textrun, link, title, textbreak, table, image (as Base64), footnote, endnote - @ivanlanin #203, #67, #147 +- PDF Writer: Basic PDF writer using DomPDF: All HTML element except image - @ivanlanin #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 +- ODT Reader: Basic ODText Reader - @ivanlanin #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 +- Font: Small caps, all caps, and double strikethrough - @ivanlanin #151 +- Settings: Ability to use measurement unit other than twips with `setMeasurementUnit` - @ivanlanin #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 +- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin #170 +- Documentation: Error in a function - @theBeerNut #195 ### Deprecated @@ -209,20 +209,20 @@ This release marked heavy refactorings on internal code structure with the creat ### 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 +- Documentation: Simplify page level docblock - @ivanlanin #179 +- Writer: Refactor writer classes and create a new `Write\AbstractWriter` abstract class - @ivanlanin #160 +- General: Refactor folders: `Element` and `Exception` - @ivanlanin #187 +- General: Remove legacy `HashTable` and `Shared\ZipStreamWrapper` and all related properties/methods - @ivanlanin #187 +- Element: New `AbstractElement` abstract class - @ivanlanin #187 +- Media: Refactor media class to use one method for all docPart (section, header, footer, footnote) - @ivanlanin #187 +- General: Remove underscore prefix from all private properties name - @ivanlanin #187 +- General: Move Section `Settings` to `Style\Section` - @ivanlanin #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 #187 +- Style: New `Style\AbstractStyle` abstract class - @ivanlanin #187 +- Writer: New 'ODText\Base` class - @ivanlanin #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 +- Test: Add some samples and tests for image wrapping style - @brunocasado #59 - Refactor: Remove Style\Tabs - @ivanlanin - Refactor: Apply composite pattern for writers - @ivanlanin - Refactor: Split `AbstractContainer` from `AbstractElement` - @ivanlanin @@ -249,13 +249,13 @@ This release marked the transformation to namespaces (PHP 5.3+). ### 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 +- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin #82 +- Reorganize and redesign samples folder - @ivanlanin #137 +- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull #159, #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 +- Merge Style\TableFull into Style\Table. Style\TableFull is deprecated - @ivanlanin #160 +- Merge Section\MemoryImage into Section\Image. Section\Image is deprecated - @ivanlanin #160 ## 0.8.1 - 17 Mar 2014 @@ -269,44 +269,44 @@ This release merged a lot of improvements from the community. Unit tests introdu ### Features -- Template: Permit to save a template generated as a file (PHPWord_Template::saveAs()) - @RomanSyroeshko GH-56 GH-57 +- Template: Permit to save a template generated as a file (PHPWord_Template::saveAs()) - @RomanSyroeshko #56, #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 +- Word2007: Added support for page header & page footer height - @JillElaine #5 +- General: Add ability to manage line breaks after image insertion - @bskrtich #6, #66, #84 +- Template: Ability to limit number of replacements performed by setValue() method of Template class - @RomanSyroeshko #52, #53, #85 +- Table row: Repeat as header row & allow row to break across pages - @ivanlanin #48, #86 +- Table: Table width in percentage - @ivanlanin #48, #86 +- Font: Superscript and subscript - @ivanlanin #48, #86 +- Paragraph: Hanging paragraph - @ivanlanin #48, #86 +- Section: Multicolumn and section break - @ivanlanin #48, #86 +- Template: Ability to apply XSL style sheet to Template - @RomanSyroeshko #46, #47, #83 +- General: PHPWord_Shared_Font::pointSizeToTwips() converter - @ivanlanin #87 +- Paragraph: Ability to define normal paragraph style with PHPWord::setNormalStyle() - @ivanlanin #87 +- Paragraph: Ability to define parent style (basedOn) and style for following paragraph (next) - @ivanlanin #87 +- Clone table rows on the fly when using a template document - @jeroenmoors #44, #88 +- Initial addition of basic footnote support - @deds #16 +- Paragraph: Ability to define paragraph pagination: widow control, keep next, keep lines, and page break before - @ivanlanin #92 +- General: PHPWord_Style_Font refactoring - @ivanlanin #93 +- Font: Use points instead of halfpoints internally. Conversion to halfpoints done during XML Writing. - @ivanlanin #93 +- Paragraph: setTabs() function - @ivanlanin #92 +- General: Basic support for TextRun on ODT and RTF - @ivanlanin #99 +- Reader: Basic Reader for Word2007 - @ivanlanin #104 +- TextRun: Allow Text Break in Text Run - @bskrtich #109 +- General: Support for East Asian fontstyle - @jhfangying #111, #118 +- Image: Use exif_imagetype to check image format instead of extension name - @gabrielbull #114 +- General: Setting for XMLWriter Compatibility option - @bskrtich #103 +- MemoryImage: Allow remote image when allow_url_open = on - @ivanlanin #122 +- TextBreak: Allow font and paragraph style for text break - @ivanlanin #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 +- Adding a value that contains "&" in a template breaks it - @SiebelsTim #51 +- Example in README.md is broken - @Progi1984 #89 +- General: PHPWord_Shared_Drawing::centimetersToPixels() conversion - @ivanlanin #94 +- Footnote: Corrupt DOCX reported by MS Word when sections > 1 and not every sections have footnote - @ivanlanin #125 ### Miscellaneous @@ -318,8 +318,8 @@ This is the first release after a long development hiatus in [CodePlex](https:// ### Features -- Implement RTF Writer - @Progi1984 GH-1 -- Implement ODT Writer - @Progi1984 GH-2 +- Implement RTF Writer - @Progi1984 #1 +- Implement ODT Writer - @Progi1984 #2 - Word2007: Add rowspan and colspan to cells - @kaystrobach - Word2007: Support for tab stops - @RLovelett - Word2007: Support Multiple headers - @RLovelett @@ -328,16 +328,16 @@ This is the first release after a long development hiatus in [CodePlex](https:// ### 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 +- "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found - @RomanSyroeshko #32 +- PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input - @RomanSyroeshko #34 +- Temporary files naming logic in PHPWord_Template can lead to a collision - @RomanSyroeshko #38 ### Miscellaneous - Add superscript/subscript styling in Excel2007 Writer - @MarkBaker - add indentation support to paragraphs - @deds -- Support for Composer - @Progi1984 GH-27 +- Support for Composer - @Progi1984 #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 +- IMPROVED: Advanced string replace in setValue for Template - @Esmeraldo [#49](http://phpword.codeplex.com/workitem/49) From 2b9111f8e9c0e38ac55e8cf3714d74afe955b2cf Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 3 Jan 2015 10:25:04 +0100 Subject: [PATCH 174/174] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b1ba6a34..93ab0127a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ 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.12.0 - Not yet released +## 0.12.0 - 3 January 2015 This release added form fields (textinput, checkbox, and dropdown), drawing shapes (arc, curve, line, polyline, rect, oval), and basic 2D chart (pie, doughnut, bar, line, area, scatter, radar) elements along with some new styles. Basic MsDoc reader is introduced.