Merge branch 'cleanup' into develop
This commit is contained in:
commit
f9123d2f2e
|
|
@ -416,8 +416,9 @@ class DocumentProperties
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['value'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -430,8 +431,9 @@ class DocumentProperties
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['type'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
*
|
||||
* @param string $method
|
||||
* @return bool
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
private function checkValidity($method)
|
||||
{
|
||||
|
|
@ -389,6 +390,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
* @return \PhpOffice\PhpWord\Element\Image
|
||||
* @deprecated 0.9.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -401,6 +403,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
* Create textrun element
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Element\TextRun
|
||||
* @deprecated 0.10.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -413,6 +416,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
* Create footnote element
|
||||
*
|
||||
* @param mixed $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Element\Footnote
|
||||
* @deprecated 0.10.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ abstract class AbstractElement
|
|||
* @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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -283,6 +283,8 @@ class Image extends AbstractElement
|
|||
* Check memory image, supported type, image functions, and proportional width/height
|
||||
*
|
||||
* @param string $source
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
private function checkImage($source)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class Object extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidObjectException
|
||||
*/
|
||||
public function __construct($source, $style = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PreserveText extends AbstractElement
|
|||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Section as SectionSettings;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -301,13 +301,13 @@ class PhpWord
|
|||
/**
|
||||
* Adds a heading style definition to styles.xml
|
||||
*
|
||||
* @param int $titleCount
|
||||
* @param int $depth
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null)
|
||||
public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
||||
{
|
||||
Style::addTitleStyle($titleCount, $fontStyle, $paragraphStyle);
|
||||
Style::addTitleStyle($depth, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractP
|
|||
/**
|
||||
* Read w:r (override)
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @param mixed $parent
|
||||
* @param string $docPart
|
||||
* @param mixed $paragraphStyle
|
||||
|
|
|
|||
|
|
@ -138,12 +138,14 @@ abstract class AbstractPart
|
|||
/**
|
||||
* Read w:pPr
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @return array|null
|
||||
*/
|
||||
protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
{
|
||||
if (!$xmlReader->elementExists('w:pPr', $domNode)) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$style = array();
|
||||
|
|
@ -200,19 +202,21 @@ abstract class AbstractPart
|
|||
/**
|
||||
* Read w:rPr
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @return array|null
|
||||
*/
|
||||
protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
{
|
||||
if (is_null($domNode)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
// Hyperlink has an extra w:r child
|
||||
if ($domNode->nodeName == 'w:hyperlink') {
|
||||
$domNode = $xmlReader->getElement('w:r', $domNode);
|
||||
}
|
||||
if (!$xmlReader->elementExists('w:rPr', $domNode)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$style = array();
|
||||
|
|
@ -272,6 +276,8 @@ abstract class AbstractPart
|
|||
/**
|
||||
* Read w:tblPr
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @return string|array|null
|
||||
* @todo Capture w:tblStylePr w:type="firstRow"
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ class Document extends AbstractPart
|
|||
/**
|
||||
* Read w:p
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @param mixed $parent
|
||||
* @param string $docPart
|
||||
*
|
||||
|
|
@ -209,6 +211,8 @@ class Document extends AbstractPart
|
|||
/**
|
||||
* Read w:tbl
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @param mixed $parent
|
||||
* @param string $docPart
|
||||
*/
|
||||
|
|
@ -266,6 +270,8 @@ class Document extends AbstractPart
|
|||
/**
|
||||
* Read w:sectPr
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @return array|null
|
||||
*/
|
||||
private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
|
|
@ -326,6 +332,8 @@ class Document extends AbstractPart
|
|||
/**
|
||||
* Read w:tcPr
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $domNode
|
||||
* @return array|null
|
||||
*/
|
||||
private function readCellStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ class Numbering extends AbstractPart
|
|||
/**
|
||||
* Read numbering level definition from w:abstractNum and w:num
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
|
||||
* @param \DOMElement $subnode
|
||||
* @param integer $levelId
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class Html
|
|||
*
|
||||
* @param \DOMNode $node Node to check on attributes and to compile a style array
|
||||
* @param array $style is supplied, the inline style attributes are added to the already existing style
|
||||
* @return array
|
||||
*/
|
||||
protected static function parseInlineStyle($node, $style = array())
|
||||
{
|
||||
|
|
@ -91,6 +92,7 @@ class Html
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $style;
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +175,7 @@ class Html
|
|||
// }
|
||||
break;
|
||||
case 'tr':
|
||||
/** @var \PhpOffice\PhpWord\Element\Table $object Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Table $object Type hint */
|
||||
$styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']);
|
||||
$newobject = $object->addRow();
|
||||
// if ($attributes->getNamedItem('height') !== null) {
|
||||
|
|
@ -181,7 +183,7 @@ class Html
|
|||
// }
|
||||
break;
|
||||
case 'td':
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $object Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $object Type hint */
|
||||
$styles['paragraphStyle'] = self::parseInlineStyle($node, $styles['paragraphStyle']);
|
||||
// if ($attributes->getNamedItem('width') !== null) {
|
||||
// $newobject=$object->addCell($width=$attributes->getNamedItem('width')->value);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class XMLReader
|
|||
* @param string $zipFile
|
||||
* @param string $xmlFile
|
||||
* @return \DOMDocument|false
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getDomFromZip($zipFile, $xmlFile)
|
||||
{
|
||||
|
|
@ -76,6 +77,7 @@ class XMLReader
|
|||
* Get elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMNodeList
|
||||
*/
|
||||
public function getElements($path, \DOMElement $contextNode = null)
|
||||
|
|
@ -94,6 +96,7 @@ class XMLReader
|
|||
* Get element
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return \DOMElement|null
|
||||
*/
|
||||
public function getElement($path, \DOMElement $contextNode = null)
|
||||
|
|
@ -110,6 +113,7 @@ class XMLReader
|
|||
* Get element attribute
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param \DOMElement $contextNode
|
||||
* @param string $path
|
||||
* @return string|null
|
||||
*/
|
||||
|
|
@ -134,6 +138,7 @@ class XMLReader
|
|||
* Get element value
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue($path, \DOMElement $contextNode = null)
|
||||
|
|
@ -150,6 +155,7 @@ class XMLReader
|
|||
* Count elements
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return integer
|
||||
*/
|
||||
public function countElements($path, \DOMElement $contextNode = null)
|
||||
|
|
@ -163,6 +169,7 @@ class XMLReader
|
|||
* Element exists
|
||||
*
|
||||
* @param string $path
|
||||
* @param \DOMElement $contextNode
|
||||
* @return boolean
|
||||
*/
|
||||
public function elementExists($path, \DOMElement $contextNode = null)
|
||||
|
|
|
|||
|
|
@ -84,8 +84,9 @@ class ZipArchive
|
|||
/**
|
||||
* Add a new file to the zip archive (emulate \ZipArchive)
|
||||
*
|
||||
* @param string $filename Directory/Name of the file to add to the zip archive
|
||||
* @param string $filename Directory/Name of the file to add to the zip archive
|
||||
* @param string $localname Directory/Name of the file added to the zip
|
||||
* @return bool
|
||||
*/
|
||||
public function addFile($filename, $localname = null)
|
||||
{
|
||||
|
|
@ -117,7 +118,8 @@ class ZipArchive
|
|||
* Add a new file to the zip archive from a string of raw data (emulate \ZipArchive)
|
||||
*
|
||||
* @param string $localname Directory/Name of the file to add to the zip archive
|
||||
* @param string $contents String of data to add to the zip archive
|
||||
* @param string $contents String of data to add to the zip archive
|
||||
* @return bool
|
||||
*/
|
||||
public function addFromString($localname, $contents)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,13 +83,13 @@ class Style
|
|||
/**
|
||||
* Add title style
|
||||
*
|
||||
* @param int $titleCount
|
||||
* @param int $depth
|
||||
* @param array $fontStyle
|
||||
* @param array $paragraphStyle
|
||||
*/
|
||||
public static function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null)
|
||||
public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
|
||||
{
|
||||
self::setStyleValues("Heading_{$titleCount}", new Font('title', $paragraphStyle), $fontStyle);
|
||||
self::setStyleValues("Heading_{$depth}", new Font('title', $paragraphStyle), $fontStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -227,6 +227,8 @@ abstract class AbstractStyle
|
|||
* @param mixed $value
|
||||
* @param array $enum
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function setEnumVal($value = null, $enum = array(), $default = null)
|
||||
{
|
||||
|
|
@ -245,11 +247,13 @@ abstract class AbstractStyle
|
|||
* @param mixed $value
|
||||
* @param string $styleName
|
||||
* @param mixed $style
|
||||
* @return mixed
|
||||
*/
|
||||
protected function setObjectVal($value, $styleName, &$style)
|
||||
{
|
||||
$styleClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $styleName;
|
||||
if (is_array($value)) {
|
||||
/** @var \PhpOffice\PhpWord\Style\AbstractStyle $style Type hint */
|
||||
if (!$style instanceof $styleClass) {
|
||||
$style = new $styleClass();
|
||||
}
|
||||
|
|
@ -265,6 +269,7 @@ abstract class AbstractStyle
|
|||
* Set style using associative array
|
||||
*
|
||||
* @param array $style
|
||||
* @return self
|
||||
* @deprecated 0.11.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ class Cell extends Border
|
|||
{
|
||||
if (!is_null($this->shading)) {
|
||||
return $this->shading->getFill();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -562,6 +562,8 @@ class Font extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->shading)) {
|
||||
return $this->shading->getFill();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ class Paragraph extends AbstractStyle
|
|||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return self
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
|
|
@ -172,6 +173,8 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->spacing)) {
|
||||
return $this->spacing->getBefore();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,6 +198,8 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->spacing)) {
|
||||
return $this->spacing->getAfter();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +223,8 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->spacing)) {
|
||||
return $this->spacing->getLine();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +253,7 @@ class Paragraph extends AbstractStyle
|
|||
* Set the line height
|
||||
*
|
||||
* @param int|float|string $lineHeight
|
||||
* @return $this
|
||||
* @return self
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
|
||||
*/
|
||||
public function setLineHeight($lineHeight)
|
||||
|
|
@ -273,6 +280,8 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->indentation)) {
|
||||
return $this->indentation->getLeft();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -296,6 +305,8 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
if (!is_null($this->indentation)) {
|
||||
return $this->indentation->getHanging();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ class Section extends Border
|
|||
* Set page numbering start
|
||||
*
|
||||
* @param null|int $pageNumberingStart
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setPageNumberingStart($pageNumberingStart = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
* @param bool $value
|
||||
* @param string $directory
|
||||
* @return self
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function setUseDiskCaching($value = false, $directory = null)
|
||||
{
|
||||
|
|
@ -257,6 +258,7 @@ abstract class AbstractWriter implements WriterInterface
|
|||
*
|
||||
* @param string $filename
|
||||
* @return mixed ZipArchive object
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
protected function getZipArchive($filename)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ namespace PhpOffice\PhpWord\Writer;
|
|||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Writer\HTML\Element\Container;
|
||||
use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter;
|
||||
use PhpOffice\PhpWord\Writer\HTML\Style\Font as FontStyleWriter;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $parentWriter
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
public function __construct(AbstractWriter $parentWriter, Element $element, $withoutP = false)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Container extends AbstractElement
|
|||
{
|
||||
$container = $this->element;
|
||||
if (!$container instanceof \PhpOffice\PhpWord\Element\AbstractContainer) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
$containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
|
||||
$withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false;
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ class Footnote extends AbstractElement
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Footnote) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
$noteId = count($parentWriter->getNotes()) + 1;
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ class Image extends Text
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Image) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
$content = '';
|
||||
|
|
@ -59,6 +59,7 @@ class Image extends Text
|
|||
/**
|
||||
* Get Base64 image data
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\Image $element
|
||||
* @return string|null
|
||||
*/
|
||||
private function getBase64ImageData(ImageElement $element)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Link extends Text
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ListItem extends AbstractElement
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\ListItem) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$text = htmlspecialchars($this->element->getTextObject()->getText());
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Table extends AbstractElement
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Text extends AbstractElement
|
|||
/**
|
||||
* Closing tag
|
||||
*
|
||||
* @var strings
|
||||
* @var string
|
||||
*/
|
||||
private $closingTags = '';
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class Text extends AbstractElement
|
|||
*/
|
||||
public function write()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
$this->getFontStyle();
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ class Text extends AbstractElement
|
|||
*/
|
||||
private function getParagraphStyle()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
$style = '';
|
||||
if (method_exists($element, 'getParagraphStyle')) {
|
||||
|
|
@ -168,7 +168,7 @@ class Text extends AbstractElement
|
|||
*/
|
||||
private function getFontStyle()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
$style = '';
|
||||
$fontStyle = $element->getFontStyle();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Title extends AbstractElement
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Title) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$tag = 'h' . $this->element->getDepth();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ abstract class AbstractStyle
|
|||
public function getStyle()
|
||||
{
|
||||
if (!$this->style instanceof Style && !is_array($this->style)) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->style;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Font extends AbstractStyle
|
|||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Font) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
$css = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Image extends AbstractStyle
|
|||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Image) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
$css = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
$css = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
||||
/**
|
||||
* Text element writer
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
|||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
|
||||
/**
|
||||
* ODText writer part abstract
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ use PhpOffice\PhpWord\Media;
|
|||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Element\Container;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
||||
/**
|
||||
* ODText meta part writer: meta.xml
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class PDF
|
|||
* Instantiate a new renderer of the configured type within this container class
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function __construct(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -62,6 +63,7 @@ class PDF
|
|||
* @param string $name Renderer library method name
|
||||
* @param mixed[] $arguments Array of arguments to pass to the renderer method
|
||||
* @return mixed Returned data from the PDF renderer wrapper method
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,10 +90,12 @@ abstract class AbstractRenderer extends \PhpOffice\PhpWord\Writer\HTML
|
|||
* 'arialunicid0-japanese'
|
||||
*
|
||||
* @param string $fontName
|
||||
* @return self
|
||||
*/
|
||||
public function setFont($fontName)
|
||||
{
|
||||
$this->font = $fontName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +148,7 @@ abstract class AbstractRenderer extends \PhpOffice\PhpWord\Writer\HTML
|
|||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @return resource
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
protected function prepareForSave($pFilename = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class DomPDF extends AbstractRenderer implements \PhpOffice\PhpWord\Writer\Write
|
|||
* Create new instance
|
||||
*
|
||||
* @param PhpWord $phpWord PhpWord object
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function __construct(PhpWord $phpWord)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class RTF extends AbstractWriter implements WriterInterface
|
|||
|
||||
// Set the color tbl group
|
||||
$content .= '{\colortbl ';
|
||||
foreach ($this->colorTable as $idx => $color) {
|
||||
foreach ($this->colorTable as $color) {
|
||||
$arrColor = Drawing::htmlToRGB($color);
|
||||
$content .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
namespace PhpOffice\PhpWord\Writer\RTF\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\String;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle;
|
||||
use PhpOffice\PhpWord\Writer\RTF\Style\Font as FontStyleWriter;
|
||||
use PhpOffice\PhpWord\Writer\RTF\Style\Paragraph as ParagraphStyleWriter;
|
||||
|
|
@ -34,14 +34,14 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
|
|||
/**
|
||||
* Font style
|
||||
*
|
||||
* @var \PhpWord\PhpOffice\Style\Font
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var \PhpWord\PhpOffice\Style\Paragraph
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
|
|||
*/
|
||||
protected function getStyles()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
|
||||
// Font style
|
||||
|
|
@ -93,7 +93,7 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
|
|||
protected function writeOpening()
|
||||
{
|
||||
if ($this->withoutP || !$this->paragraphStyle instanceof ParagraphStyle) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$styleWriter = new ParagraphStyleWriter($this->paragraphStyle);
|
||||
|
|
@ -119,7 +119,7 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
|
|||
protected function writeClosing()
|
||||
{
|
||||
if ($this->withoutP) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
return '\par' . PHP_EOL;
|
||||
|
|
@ -136,7 +136,7 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
|
|||
return '';
|
||||
}
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
// Create style writer and set color/name index
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Link extends AbstractElement
|
|||
public function write()
|
||||
{
|
||||
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Link) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->getStyles();
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class Text extends AbstractElement
|
|||
*/
|
||||
public function write()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
$elementClass = str_replace('\\Writer\\RTF', '', get_class($this));
|
||||
if (!$element instanceof $elementClass) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->getStyles();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TextBreak extends AbstractElement
|
|||
*/
|
||||
public function write()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
$parentWriter->setLastParagraphStyle();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\RTF\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\RTF\Element\Container;
|
||||
|
||||
/**
|
||||
* TextRun element RTF writer
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\RTF\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Style\AbstractStyle as Style;
|
||||
|
||||
/**
|
||||
* Abstract RTF style writer
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\RTF\Style;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Font as FontStyle;
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +45,7 @@ class Font extends AbstractStyle
|
|||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Font) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Paragraph extends AbstractStyle
|
|||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$alignments = array(
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
* Save document by name
|
||||
*
|
||||
* @param string $filename
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function save($filename = null)
|
||||
{
|
||||
|
|
@ -191,6 +192,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
/**
|
||||
* Add header/footer content
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\Section $section
|
||||
* @param mixed $objZip
|
||||
* @param string $elmType header|footer
|
||||
* @param integer $rId
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ abstract class AbstractElement
|
|||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
public function __construct(XMLWriter $xmlWriter, Element $element, $withoutP = false)
|
||||
|
|
@ -81,14 +83,11 @@ abstract class AbstractElement
|
|||
* Get element
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
protected function getElement()
|
||||
{
|
||||
if (!is_null($this->element)) {
|
||||
return $this->element;
|
||||
} else {
|
||||
throw new Exception('No element assigned.');
|
||||
}
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ class TOC extends AbstractElement
|
|||
/**
|
||||
* Write title
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Element\TOC $element
|
||||
* @param \PhpOffice\PhpWord\Element\Title $title
|
||||
* @param bool $writeFieldMark
|
||||
*/
|
||||
|
|
@ -130,6 +132,8 @@ class TOC extends AbstractElement
|
|||
/**
|
||||
* Write style
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Element\TOC $element
|
||||
* @param int $indent
|
||||
*/
|
||||
private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent)
|
||||
|
|
@ -141,8 +145,8 @@ class TOC extends AbstractElement
|
|||
$xmlWriter->startElement('w:pPr');
|
||||
|
||||
// Paragraph
|
||||
if ($isObject && !is_null($fontStyle->getParagraphStyle())) {
|
||||
$styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraphStyle());
|
||||
if ($isObject && !is_null($fontStyle->getParagraph())) {
|
||||
$styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraph());
|
||||
$styleWriter->write();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Text extends AbstractElement
|
|||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->getElement();
|
||||
$paragraphStyle = $element->getParagraphStyle();
|
||||
$styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle);
|
||||
|
|
@ -104,7 +104,7 @@ class Text extends AbstractElement
|
|||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->getElement();
|
||||
$fontStyle = $element->getFontStyle();
|
||||
$styleWriter = new FontStyleWriter($xmlWriter, $fontStyle);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ContentTypes extends AbstractPart
|
|||
*/
|
||||
public function write()
|
||||
{
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Type hint */
|
||||
$parentWriter = $this->getParentWriter();
|
||||
$contentTypes = $parentWriter->getContentTypes();
|
||||
|
||||
|
|
@ -82,16 +82,12 @@ class ContentTypes extends AbstractPart
|
|||
private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault)
|
||||
{
|
||||
foreach ($parts as $partName => $contentType) {
|
||||
if ($partName != '' && $contentType != '') {
|
||||
$partType = $isDefault ? 'Default' : 'Override';
|
||||
$partAttribute = $isDefault ? 'Extension' : 'PartName';
|
||||
$xmlWriter->startElement($partType);
|
||||
$xmlWriter->writeAttribute($partAttribute, $partName);
|
||||
$xmlWriter->writeAttribute('ContentType', $contentType);
|
||||
$xmlWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
$partType = $isDefault ? 'Default' : 'Override';
|
||||
$partAttribute = $isDefault ? 'Extension' : 'PartName';
|
||||
$xmlWriter->startElement($partType);
|
||||
$xmlWriter->writeAttribute($partAttribute, $partName);
|
||||
$xmlWriter->writeAttribute('ContentType', $contentType);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
||||
/**
|
||||
* Word2007 extended document properties part writer: docProps/app.xml
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
||||
/**
|
||||
* Word2007 core document properties part writer: docProps/core.xml
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Section;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class Footnotes extends AbstractPart
|
|||
$xmlWriter->endElement(); // w:p
|
||||
$xmlWriter->endElement(); // $this->elementNode
|
||||
|
||||
/** @var array $elements Scrutinizer type hint */
|
||||
/** @var array $elements Type hint */
|
||||
$elements = $this->elements;
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof Footnote) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class Rels extends AbstractPart
|
|||
* @param string $type Relationship type
|
||||
* @param string $target Relationship target
|
||||
* @param string $targetMode Relationship target mode
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class RelsDocument extends Rels
|
|||
);
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Scrutinizer type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007 $parentWriter Type hint */
|
||||
$parentWriter = $this->getParentWriter();
|
||||
$this->writeRels($xmlWriter, $xmlRels, $parentWriter->getRelationships());
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class Settings extends AbstractPart
|
|||
} else {
|
||||
$xmlWriter->startElement($settingKey);
|
||||
|
||||
/** @var array $settingValue Scrutinizer type hint */
|
||||
/** @var array $settingValue Type hint */
|
||||
foreach ($settingValue as $childKey => $childValue) {
|
||||
if ($childKey == '@attributes') {
|
||||
foreach ($childValue as $key => $val) {
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
|||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Table;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
||||
|
|
@ -155,6 +155,7 @@ class Styles extends AbstractPart
|
|||
* Write default font and other default styles
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @param array $styles
|
||||
*/
|
||||
private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ abstract class AbstractStyle
|
|||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param string|\PhpOffice\PhpWord\Style\AbstractStyle $style
|
||||
*/
|
||||
public function __construct(XMLWriter $xmlWriter, $style = null)
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ class Image extends AbstractStyle
|
|||
/**
|
||||
* Get element style
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Style\Image $style
|
||||
* @return array
|
||||
*/
|
||||
private function getElementStyle(ImageStyle $style)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class MarginBorder extends AbstractStyle
|
|||
/**
|
||||
* Write side
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param string $side
|
||||
* @param int $width
|
||||
* @param string $color
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class Table extends AbstractStyle
|
|||
/**
|
||||
* Write width
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param int $width
|
||||
* @param string $unit
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testUnmatchedElements()
|
||||
{
|
||||
$styles = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title');
|
||||
foreach ($styles as $style) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $style;
|
||||
$elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title');
|
||||
foreach ($elements as $element) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $element;
|
||||
$parentWriter = new HTML();
|
||||
$element = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($parentWriter, $element);
|
||||
$newElement = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($parentWriter, $newElement);
|
||||
|
||||
$this->assertEquals('', $object->write());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
|
|||
$docProps = $phpWord->getDocumentProperties();
|
||||
$docProps->setTitle('HTML Test');
|
||||
|
||||
$phpWord->addTitleStyle(1, array('bold' => true));
|
||||
$phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11,
|
||||
'color' => 'FF0000', 'fgColor' => 'FF0000'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testUnmatchedElements()
|
||||
{
|
||||
$styles = array('Image', 'Link', 'Table', 'Text');
|
||||
foreach ($styles as $style) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $style;
|
||||
$elements = array('Image', 'Link', 'Table', 'Text');
|
||||
foreach ($elements as $element) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $element;
|
||||
$xmlWriter = new XMLWriter();
|
||||
$element = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($xmlWriter, $element);
|
||||
$newElement = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($xmlWriter, $newElement);
|
||||
$object->write();
|
||||
|
||||
$this->assertEquals('', $xmlWriter->getData());
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ class ElementTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testUnmatchedElements()
|
||||
{
|
||||
$styles = array('Container', 'Text', 'Title', 'Link');
|
||||
foreach ($styles as $style) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $style;
|
||||
$elements = array('Container', 'Text', 'Title', 'Link');
|
||||
foreach ($elements as $element) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\RTF\\Element\\' . $element;
|
||||
$parentWriter = new RTF();
|
||||
$element = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($parentWriter, $element);
|
||||
$newElement = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($parentWriter, $newElement);
|
||||
|
||||
$this->assertEquals('', $object->write());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11,
|
||||
'color' => 'FF0000', 'fgColor' => 'FF0000'));
|
||||
'color' => 'FF0000', 'fgColor' => '00FF00'));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addText('Test 1', 'Font', 'Paragraph');
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ class ElementTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testUnmatchedElements()
|
||||
{
|
||||
$styles = array(
|
||||
$elements = array(
|
||||
'CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun',
|
||||
'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC'
|
||||
);
|
||||
foreach ($styles as $style) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $style;
|
||||
foreach ($elements as $element) {
|
||||
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element;
|
||||
$xmlWriter = new XMLWriter();
|
||||
$element = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($xmlWriter, $element);
|
||||
$newElement = new \PhpOffice\PhpWord\Element\PageBreak();
|
||||
$object = new $objectClass($xmlWriter, $newElement);
|
||||
$object->write();
|
||||
|
||||
$this->assertEquals('', $xmlWriter->getData());
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$section->addListItem('List Item 1', 0);
|
||||
$section->addListItem('List Item 2', 0);
|
||||
$section->addListItem('List Item 3', 0);
|
||||
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTitle('Title 2', 2);
|
||||
$section->addObject($objectSrc);
|
||||
|
|
@ -80,6 +81,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
'posHorizontalRel' => 'margin', 'posVerticalRel' => 'margin',
|
||||
'innerMargin' => 10, 'borderSize' => 1, 'borderColor' => '#FF0'));
|
||||
$section->addTextBox(array('wrappingStyle' => 'tight', 'positioning' => 'absolute', 'align' => 'center'));
|
||||
$section->addListItemRun()->addText('List item run 1');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
|
|
@ -113,22 +115,27 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
|
||||
|
||||
$tabs = array(new \PhpOffice\PhpWord\Style\Tab('right', 9090));
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1
|
||||
$phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'tabs' => $tabs)); // Style #1
|
||||
$phpWord->addFontStyle('fStyle', array('size' => '20', 'bold' => true, 'allCaps' => true)); // Style #2
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'doubleStrikethrough' => true)); // Style #3
|
||||
$phpWord->addTableStyle('tStyle', array('borderSize' => 1));
|
||||
$fontStyle = new Font('text', array('align' => 'center'));
|
||||
|
||||
$section = $phpWord->addSection();
|
||||
$section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4
|
||||
$section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #5
|
||||
$section->addObject($objectSrc, array('align' => 'center'));
|
||||
$section->addTOC($fontStyle);
|
||||
$section->addTitle('Title 1', 1);
|
||||
$section->addTOC('fStyle');
|
||||
$table = $section->addTable('tStyle');
|
||||
$table->setWidth(100);
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
// List item
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId');
|
||||
$this->assertEquals(4, $element->getAttribute('w:val'));
|
||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||
|
||||
// Object
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject');
|
||||
|
|
@ -497,6 +504,10 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
|
||||
$table->addRow();
|
||||
$cell = $table->addCell(200, array('borderRightColor' => 'FF0000'));
|
||||
$cell->getStyle()->setGridSpan(5);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2010-2014 PHPWord contributors
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\RelsPart;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part subnamespace
|
||||
*
|
||||
* Covers miscellaneous tests
|
||||
*/
|
||||
class PartTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test exception when no type or target assigned to a relation
|
||||
*
|
||||
* @covers \PhpOffice\PhpWord\Writer\Word2007\Part\Rels::writeRel
|
||||
* @expectedException \PhpOffice\PhpWord\Exception\Exception
|
||||
* @expectedExceptionMessage Invalid parameters passed.
|
||||
*/
|
||||
public function testRelsWriteRelException()
|
||||
{
|
||||
$object = new RelsPart();
|
||||
$object->setMedia(array(array('foo' => 'bar')));
|
||||
$object->write();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue