Refactoring & remove underscore prefix from method and property names
This commit is contained in:
parent
4127860f1e
commit
acba6b448a
@ -39,14 +39,14 @@ class DocumentProperties
|
|||||||
/**
|
/**
|
||||||
* Created
|
* Created
|
||||||
*
|
*
|
||||||
* @var datetime
|
* @var datetime|int
|
||||||
*/
|
*/
|
||||||
private $_created;
|
private $_created;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified
|
* Modified
|
||||||
*
|
*
|
||||||
* @var datetime
|
* @var datetime|int
|
||||||
*/
|
*/
|
||||||
private $_modified;
|
private $_modified;
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class DocumentProperties
|
|||||||
/**
|
/**
|
||||||
* Custom Properties
|
* Custom Properties
|
||||||
*
|
*
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_customProperties = array();
|
private $_customProperties = array();
|
||||||
|
|
||||||
@ -542,26 +542,21 @@ class DocumentProperties
|
|||||||
case 'ui8': // 8-Byte Unsigned Integer
|
case 'ui8': // 8-Byte Unsigned Integer
|
||||||
case 'uint': // Unsigned Integer
|
case 'uint': // Unsigned Integer
|
||||||
return self::PROPERTY_TYPE_INTEGER;
|
return self::PROPERTY_TYPE_INTEGER;
|
||||||
break;
|
|
||||||
case 'r4': // 4-Byte Real Number
|
case 'r4': // 4-Byte Real Number
|
||||||
case 'r8': // 8-Byte Real Number
|
case 'r8': // 8-Byte Real Number
|
||||||
case 'decimal': // Decimal
|
case 'decimal': // Decimal
|
||||||
return self::PROPERTY_TYPE_FLOAT;
|
return self::PROPERTY_TYPE_FLOAT;
|
||||||
break;
|
|
||||||
case 'empty': // Empty
|
case 'empty': // Empty
|
||||||
case 'null': // Null
|
case 'null': // Null
|
||||||
case 'lpstr': // LPSTR
|
case 'lpstr': // LPSTR
|
||||||
case 'lpwstr': // LPWSTR
|
case 'lpwstr': // LPWSTR
|
||||||
case 'bstr': // Basic String
|
case 'bstr': // Basic String
|
||||||
return self::PROPERTY_TYPE_STRING;
|
return self::PROPERTY_TYPE_STRING;
|
||||||
break;
|
|
||||||
case 'date': // Date and Time
|
case 'date': // Date and Time
|
||||||
case 'filetime': // File Time
|
case 'filetime': // File Time
|
||||||
return self::PROPERTY_TYPE_DATE;
|
return self::PROPERTY_TYPE_DATE;
|
||||||
break;
|
|
||||||
case 'bool': // Boolean
|
case 'bool': // Boolean
|
||||||
return self::PROPERTY_TYPE_BOOLEAN;
|
return self::PROPERTY_TYPE_BOOLEAN;
|
||||||
break;
|
|
||||||
case 'cy': // Currency
|
case 'cy': // Currency
|
||||||
case 'error': // Error Status Code
|
case 'error': // Error Status Code
|
||||||
case 'vector': // Vector
|
case 'vector': // Vector
|
||||||
@ -576,7 +571,6 @@ class DocumentProperties
|
|||||||
case 'clsid': // Class ID
|
case 'clsid': // Class ID
|
||||||
case 'cf': // Clipboard Data
|
case 'cf': // Clipboard Data
|
||||||
return self::PROPERTY_TYPE_UNKNOWN;
|
return self::PROPERTY_TYPE_UNKNOWN;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return self::PROPERTY_TYPE_UNKNOWN;
|
return self::PROPERTY_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,14 +34,14 @@ class CheckBox
|
|||||||
/**
|
/**
|
||||||
* Text style
|
* Text style
|
||||||
*
|
*
|
||||||
* @var Font
|
* @var string|Font
|
||||||
*/
|
*/
|
||||||
private $fontStyle;
|
private $fontStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var Paragraph
|
* @var string|Paragraph
|
||||||
*/
|
*/
|
||||||
private $paragraphStyle;
|
private $paragraphStyle;
|
||||||
|
|
||||||
@ -50,8 +50,8 @@ class CheckBox
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param Font $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param Paragraph $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
*/
|
*/
|
||||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -66,9 +66,9 @@ class CheckBox
|
|||||||
/**
|
/**
|
||||||
* Set Text style
|
* Set Text style
|
||||||
*
|
*
|
||||||
* @param Font $style
|
* @param mixed $style
|
||||||
* @param Paragraph $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ class CheckBox
|
|||||||
/**
|
/**
|
||||||
* Get Text style
|
* Get Text style
|
||||||
*
|
*
|
||||||
* @return Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function getFontStyle()
|
public function getFontStyle()
|
||||||
{
|
{
|
||||||
@ -100,8 +100,8 @@ class CheckBox
|
|||||||
/**
|
/**
|
||||||
* Set Paragraph style
|
* Set Paragraph style
|
||||||
*
|
*
|
||||||
* @param Paragraph $style
|
* @param mixed $style
|
||||||
* @return Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function setParagraphStyle($style = null)
|
public function setParagraphStyle($style = null)
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ class CheckBox
|
|||||||
/**
|
/**
|
||||||
* Get Paragraph style
|
* Get Paragraph style
|
||||||
*
|
*
|
||||||
* @return Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function getParagraphStyle()
|
public function getParagraphStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,14 +41,14 @@ class Link
|
|||||||
/**
|
/**
|
||||||
* Link style
|
* Link style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Font
|
* @var string|Font
|
||||||
*/
|
*/
|
||||||
private $_styleFont;
|
private $_styleFont;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
* @var string|Paragraph
|
||||||
*/
|
*/
|
||||||
private $_styleParagraph;
|
private $_styleParagraph;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class Link
|
|||||||
/**
|
/**
|
||||||
* Get Text style
|
* Get Text style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function getFontStyle()
|
public function getFontStyle()
|
||||||
{
|
{
|
||||||
@ -150,7 +150,7 @@ class Link
|
|||||||
/**
|
/**
|
||||||
* Get Paragraph style
|
* Get Paragraph style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function getParagraphStyle()
|
public function getParagraphStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -27,14 +27,14 @@ class Text
|
|||||||
/**
|
/**
|
||||||
* Text style
|
* Text style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Font
|
* @var string|Font
|
||||||
*/
|
*/
|
||||||
private $fontStyle;
|
private $fontStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
* @var string|Paragraph
|
||||||
*/
|
*/
|
||||||
private $paragraphStyle;
|
private $paragraphStyle;
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ class Text
|
|||||||
* Create a new Text Element
|
* Create a new Text Element
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
*/
|
*/
|
||||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -55,9 +55,9 @@ class Text
|
|||||||
/**
|
/**
|
||||||
* Set Text style
|
* Set Text style
|
||||||
*
|
*
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $style
|
* @param string|array|Font $style
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
* @param string|array|Paragraph $paragraphStyle
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ class Text
|
|||||||
/**
|
/**
|
||||||
* Get Text style
|
* Get Text style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function getFontStyle()
|
public function getFontStyle()
|
||||||
{
|
{
|
||||||
@ -89,8 +89,8 @@ class Text
|
|||||||
/**
|
/**
|
||||||
* Set Paragraph style
|
* Set Paragraph style
|
||||||
*
|
*
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style
|
* @param string|array|Paragraph $style
|
||||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function setParagraphStyle($style = null)
|
public function setParagraphStyle($style = null)
|
||||||
{
|
{
|
||||||
@ -110,7 +110,7 @@ class Text
|
|||||||
/**
|
/**
|
||||||
* Get Paragraph style
|
* Get Paragraph style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function getParagraphStyle()
|
public function getParagraphStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,14 +20,14 @@ class TextBreak
|
|||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Pagaraph
|
* @var string|Paragraph
|
||||||
*/
|
*/
|
||||||
private $paragraphStyle = null;
|
private $paragraphStyle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text style
|
* Text style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Font
|
* @var string|Font
|
||||||
*/
|
*/
|
||||||
private $fontStyle = null;
|
private $fontStyle = null;
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ class TextBreak
|
|||||||
/**
|
/**
|
||||||
* Set Text style
|
* Set Text style
|
||||||
*
|
*
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $style
|
* @param mixed $style
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ class TextBreak
|
|||||||
/**
|
/**
|
||||||
* Get Text style
|
* Get Text style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Font
|
* @return string|Font
|
||||||
*/
|
*/
|
||||||
public function getFontStyle()
|
public function getFontStyle()
|
||||||
{
|
{
|
||||||
@ -82,8 +82,8 @@ class TextBreak
|
|||||||
/**
|
/**
|
||||||
* Set Paragraph style
|
* Set Paragraph style
|
||||||
*
|
*
|
||||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style
|
* @param string|array|Paragraph $style
|
||||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function setParagraphStyle($style = null)
|
public function setParagraphStyle($style = null)
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ class TextBreak
|
|||||||
/**
|
/**
|
||||||
* Get Paragraph style
|
* Get Paragraph style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function getParagraphStyle()
|
public function getParagraphStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,6 +12,7 @@ namespace PhpOffice\PhpWord\Section;
|
|||||||
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Shared\String;
|
||||||
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,7 @@ class TextRun
|
|||||||
/**
|
/**
|
||||||
* Paragraph style
|
* Paragraph style
|
||||||
*
|
*
|
||||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
* @var Paragraph
|
||||||
*/
|
*/
|
||||||
private $_styleParagraph;
|
private $_styleParagraph;
|
||||||
|
|
||||||
@ -123,8 +124,8 @@ class TextRun
|
|||||||
* Add TextBreak
|
* Add TextBreak
|
||||||
*
|
*
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle
|
* @param mixed $fontStyle
|
||||||
* @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
* @param mixed $paragraphStyle
|
||||||
*/
|
*/
|
||||||
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
|
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
|
||||||
{
|
{
|
||||||
@ -161,7 +162,7 @@ class TextRun
|
|||||||
/**
|
/**
|
||||||
* Get Paragraph style
|
* Get Paragraph style
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return string|Paragraph
|
||||||
*/
|
*/
|
||||||
public function getParagraphStyle()
|
public function getParagraphStyle()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -244,11 +244,11 @@ class Content extends WriterPart
|
|||||||
|
|
||||||
foreach ($_elements as $element) {
|
foreach ($_elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element);
|
$this->writeText($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextRun) {
|
} elseif ($element instanceof TextRun) {
|
||||||
$this->_writeTextRun($xmlWriter, $element);
|
$this->writeTextRun($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextBreak) {
|
} elseif ($element instanceof TextBreak) {
|
||||||
$this->_writeTextBreak($xmlWriter);
|
$this->writeTextBreak($xmlWriter);
|
||||||
} elseif ($element instanceof Link) {
|
} elseif ($element instanceof Link) {
|
||||||
$this->writeUnsupportedElement($xmlWriter, 'Link');
|
$this->writeUnsupportedElement($xmlWriter, 'Link');
|
||||||
} elseif ($element instanceof Title) {
|
} elseif ($element instanceof Title) {
|
||||||
@ -271,9 +271,9 @@ class Content extends WriterPart
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($pSection == $countSections) {
|
if ($pSection == $countSections) {
|
||||||
$this->_writeEndSection($xmlWriter, $section);
|
$this->writeEndSection($xmlWriter, $section);
|
||||||
} else {
|
} else {
|
||||||
$this->_writeSection($xmlWriter, $section);
|
$this->writeSection($xmlWriter, $section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ class Content extends WriterPart
|
|||||||
* @param \PhpOffice\PhpWord\Section\Text $text
|
* @param \PhpOffice\PhpWord\Section\Text $text
|
||||||
* @param bool $withoutP
|
* @param bool $withoutP
|
||||||
*/
|
*/
|
||||||
protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
|
protected function writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
|
||||||
{
|
{
|
||||||
$styleFont = $text->getFontStyle();
|
$styleFont = $text->getFontStyle();
|
||||||
$styleParagraph = $text->getParagraphStyle();
|
$styleParagraph = $text->getParagraphStyle();
|
||||||
@ -340,14 +340,14 @@ class Content extends WriterPart
|
|||||||
* @param \PhpOffice\PhpWord\Section\TextRun $textrun
|
* @param \PhpOffice\PhpWord\Section\TextRun $textrun
|
||||||
* @todo Enable all other section types
|
* @todo Enable all other section types
|
||||||
*/
|
*/
|
||||||
protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
|
protected function writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
|
||||||
{
|
{
|
||||||
$elements = $textrun->getElements();
|
$elements = $textrun->getElements();
|
||||||
$xmlWriter->startElement('text:p');
|
$xmlWriter->startElement('text:p');
|
||||||
if (count($elements) > 0) {
|
if (count($elements) > 0) {
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element, true);
|
$this->writeText($xmlWriter, $element, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ class Content extends WriterPart
|
|||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
protected function _writeTextBreak(XMLWriter $xmlWriter = null)
|
protected function writeTextBreak(XMLWriter $xmlWriter = null)
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('text:p');
|
$xmlWriter->startElement('text:p');
|
||||||
$xmlWriter->writeAttribute('text:style-name', 'Standard');
|
$xmlWriter->writeAttribute('text:style-name', 'Standard');
|
||||||
@ -373,7 +373,7 @@ class Content extends WriterPart
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Section $section
|
* @param PhpOffice\PhpWord\Section $section
|
||||||
*/
|
*/
|
||||||
private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null)
|
private function writeEndSection(XMLWriter $xmlWriter = null, Section $section = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ class Content extends WriterPart
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Section $section
|
* @param PhpOffice\PhpWord\Section $section
|
||||||
*/
|
*/
|
||||||
private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null)
|
private function writeSection(XMLWriter $xmlWriter = null, Section $section = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class Manifest extends WriterPart
|
|||||||
for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) {
|
for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) {
|
||||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||||
$mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
|
$mimeType = $this->getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
|
||||||
|
|
||||||
$xmlWriter->startElement('manifest:file-entry');
|
$xmlWriter->startElement('manifest:file-entry');
|
||||||
$xmlWriter->writeAttribute('manifest:media-type', $mimeType);
|
$xmlWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||||
@ -99,7 +99,7 @@ class Manifest extends WriterPart
|
|||||||
* @return string Mime Type
|
* @return string Mime Type
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
private function _getImageMimeType($pFile = '')
|
private function getImageMimeType($pFile = '')
|
||||||
{
|
{
|
||||||
if (file_exists($pFile)) {
|
if (file_exists($pFile)) {
|
||||||
$image = getimagesize($pFile);
|
$image = getimagesize($pFile);
|
||||||
|
|||||||
@ -179,7 +179,6 @@ class RTF extends Writer implements IWriter
|
|||||||
|
|
||||||
// Browse styles
|
// Browse styles
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
$numPStyles = 0;
|
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $styleName => $style) {
|
||||||
// PhpOffice\PhpWord\Style\Font
|
// PhpOffice\PhpWord\Style\Font
|
||||||
@ -232,7 +231,6 @@ class RTF extends Writer implements IWriter
|
|||||||
|
|
||||||
// Browse styles
|
// Browse styles
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
$numPStyles = 0;
|
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $styleName => $style) {
|
||||||
// Font
|
// Font
|
||||||
|
|||||||
@ -34,14 +34,14 @@ class Word2007 extends Writer implements IWriter
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_imageTypes = array();
|
private $imageTypes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of objects
|
* Types of objects
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_objectTypes = array();
|
private $objectTypes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new Word2007 writer
|
* Create new Word2007 writer
|
||||||
@ -167,8 +167,8 @@ class Word2007 extends Writer implements IWriter
|
|||||||
$objZip->addFromString(
|
$objZip->addFromString(
|
||||||
'[Content_Types].xml',
|
'[Content_Types].xml',
|
||||||
$this->getWriterPart('contenttypes')->writeContentTypes(
|
$this->getWriterPart('contenttypes')->writeContentTypes(
|
||||||
$this->_imageTypes,
|
$this->imageTypes,
|
||||||
$this->_objectTypes,
|
$this->objectTypes,
|
||||||
$_cHdrs,
|
$_cHdrs,
|
||||||
$footers
|
$footers
|
||||||
)
|
)
|
||||||
@ -235,12 +235,12 @@ class Word2007 extends Writer implements IWriter
|
|||||||
if ($imageExtension === 'jpeg') {
|
if ($imageExtension === 'jpeg') {
|
||||||
$imageExtension = 'jpg';
|
$imageExtension = 'jpg';
|
||||||
}
|
}
|
||||||
if (!in_array($imageType, $this->_imageTypes)) {
|
if (!in_array($imageType, $this->imageTypes)) {
|
||||||
$this->_imageTypes[$imageExtension] = $imageType;
|
$this->imageTypes[$imageExtension] = $imageType;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!in_array($extension, $this->_objectTypes)) {
|
if (!in_array($extension, $this->objectTypes)) {
|
||||||
$this->_objectTypes[] = $extension;
|
$this->objectTypes[] = $extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -19,12 +19,12 @@ class ContentTypes extends WriterPart
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write [Content_Types].xml
|
* Write [Content_Types].xml
|
||||||
* @param array $_imageTypes
|
* @param array $imageTypes
|
||||||
* @param array $_objectTypes
|
* @param array $objectTypes
|
||||||
* @param int $_cHdrs
|
* @param int $_cHdrs
|
||||||
* @param array $footers
|
* @param array $footers
|
||||||
*/
|
*/
|
||||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
|
public function writeContentTypes($imageTypes, $objectTypes, $_cHdrs, $footers)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$xmlWriter = $this->getXmlWriter();
|
$xmlWriter = $this->getXmlWriter();
|
||||||
@ -37,27 +37,27 @@ class ContentTypes extends WriterPart
|
|||||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||||
|
|
||||||
// Rels
|
// Rels
|
||||||
$this->_writeDefaultContentType(
|
$this->writeDefaultContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'rels',
|
'rels',
|
||||||
'application/vnd.openxmlformats-package.relationships+xml'
|
'application/vnd.openxmlformats-package.relationships+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// XML
|
// XML
|
||||||
$this->_writeDefaultContentType(
|
$this->writeDefaultContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'xml',
|
'xml',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add media content-types
|
// Add media content-types
|
||||||
foreach ($_imageTypes as $key => $value) {
|
foreach ($imageTypes as $key => $value) {
|
||||||
$this->_writeDefaultContentType($xmlWriter, $key, $value);
|
$this->writeDefaultContentType($xmlWriter, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add embedding content-types
|
// Add embedding content-types
|
||||||
if (count($_objectTypes) > 0) {
|
if (count($objectTypes) > 0) {
|
||||||
$this->_writeDefaultContentType(
|
$this->writeDefaultContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'bin',
|
'bin',
|
||||||
'application/vnd.openxmlformats-officedocument.oleObject'
|
'application/vnd.openxmlformats-officedocument.oleObject'
|
||||||
@ -65,76 +65,76 @@ class ContentTypes extends WriterPart
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DocProps
|
// DocProps
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/docProps/app.xml',
|
'/docProps/app.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/docProps/core.xml',
|
'/docProps/core.xml',
|
||||||
'application/vnd.openxmlformats-package.core-properties+xml'
|
'application/vnd.openxmlformats-package.core-properties+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Document
|
// Document
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/document.xml',
|
'/word/document.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/styles.xml',
|
'/word/styles.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Numbering
|
// Numbering
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/numbering.xml',
|
'/word/numbering.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/settings.xml',
|
'/word/settings.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Theme1
|
// Theme1
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/theme/theme1.xml',
|
'/word/theme/theme1.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.theme+xml'
|
'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// WebSettings
|
// WebSettings
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/webSettings.xml',
|
'/word/webSettings.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Font Table
|
// Font Table
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/fontTable.xml',
|
'/word/fontTable.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Footnotes
|
// Footnotes
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/footnotes.xml',
|
'/word/footnotes.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
for ($i = 1; $i <= $_cHdrs; $i++) {
|
for ($i = 1; $i <= $_cHdrs; $i++) {
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/header' . $i . '.xml',
|
'/word/header' . $i . '.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||||
@ -143,7 +143,7 @@ class ContentTypes extends WriterPart
|
|||||||
|
|
||||||
for ($i = 1; $i <= count($footers); $i++) {
|
for ($i = 1; $i <= count($footers); $i++) {
|
||||||
if (!is_null($footers[$i])) {
|
if (!is_null($footers[$i])) {
|
||||||
$this->_writeOverrideContentType(
|
$this->writeOverrideContentType(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
'/word/footer' . $i . '.xml',
|
'/word/footer' . $i . '.xml',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||||
@ -158,23 +158,6 @@ class ContentTypes extends WriterPart
|
|||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image mime type
|
|
||||||
*
|
|
||||||
* @param string $pFile Filename
|
|
||||||
* @return string Mime Type
|
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
|
||||||
*/
|
|
||||||
private function _getImageMimeType($pFile = '')
|
|
||||||
{
|
|
||||||
if (file_exists($pFile)) {
|
|
||||||
$image = getimagesize($pFile);
|
|
||||||
return image_type_to_mime_type($image[2]);
|
|
||||||
} else {
|
|
||||||
throw new Exception("File $pFile does not exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Default XML element
|
* Write Default XML element
|
||||||
*
|
*
|
||||||
@ -183,7 +166,7 @@ class ContentTypes extends WriterPart
|
|||||||
* @param string $pContentType Content type
|
* @param string $pContentType Content type
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
private function writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||||
{
|
{
|
||||||
if ($pPartname != '' && $pContentType != '') {
|
if ($pPartname != '' && $pContentType != '') {
|
||||||
// Write content type
|
// Write content type
|
||||||
@ -204,7 +187,7 @@ class ContentTypes extends WriterPart
|
|||||||
* @param string $pContentType Content type
|
* @param string $pContentType Content type
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
private function writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||||
{
|
{
|
||||||
if ($pPartname != '' && $pContentType != '') {
|
if ($pPartname != '' && $pContentType != '') {
|
||||||
// Write content type
|
// Write content type
|
||||||
@ -216,4 +199,21 @@ class ContentTypes extends WriterPart
|
|||||||
throw new Exception("Invalid parameters passed.");
|
throw new Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get image mime type
|
||||||
|
*
|
||||||
|
* @param string $pFile Filename
|
||||||
|
* @return string Mime Type
|
||||||
|
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||||
|
*/
|
||||||
|
private function getImageMimeType($pFile = '')
|
||||||
|
{
|
||||||
|
if (file_exists($pFile)) {
|
||||||
|
$image = getimagesize($pFile);
|
||||||
|
return image_type_to_mime_type($image[2]);
|
||||||
|
} else {
|
||||||
|
throw new Exception("File $pFile does not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,38 +72,38 @@ class Document extends Base
|
|||||||
$_elements = $section->getElements();
|
$_elements = $section->getElements();
|
||||||
foreach ($_elements as $element) {
|
foreach ($_elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element);
|
$this->writeText($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextRun) {
|
} elseif ($element instanceof TextRun) {
|
||||||
$this->_writeTextRun($xmlWriter, $element);
|
$this->writeTextRun($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Link) {
|
} elseif ($element instanceof Link) {
|
||||||
$this->_writeLink($xmlWriter, $element);
|
$this->writeLink($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Title) {
|
} elseif ($element instanceof Title) {
|
||||||
$this->_writeTitle($xmlWriter, $element);
|
$this->writeTitle($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextBreak) {
|
} elseif ($element instanceof TextBreak) {
|
||||||
$this->_writeTextBreak($xmlWriter, $element);
|
$this->writeTextBreak($xmlWriter, $element);
|
||||||
} elseif ($element instanceof PageBreak) {
|
} elseif ($element instanceof PageBreak) {
|
||||||
$this->_writePageBreak($xmlWriter);
|
$this->writePageBreak($xmlWriter);
|
||||||
} elseif ($element instanceof Table) {
|
} elseif ($element instanceof Table) {
|
||||||
$this->_writeTable($xmlWriter, $element);
|
$this->writeTable($xmlWriter, $element);
|
||||||
} elseif ($element instanceof ListItem) {
|
} elseif ($element instanceof ListItem) {
|
||||||
$this->_writeListItem($xmlWriter, $element);
|
$this->writeListItem($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Image) {
|
} elseif ($element instanceof Image) {
|
||||||
$this->_writeImage($xmlWriter, $element);
|
$this->writeImage($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Object) {
|
} elseif ($element instanceof Object) {
|
||||||
$this->_writeObject($xmlWriter, $element);
|
$this->writeObject($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TOC) {
|
} elseif ($element instanceof TOC) {
|
||||||
$this->_writeTOC($xmlWriter);
|
$this->writeTOC($xmlWriter);
|
||||||
} elseif ($element instanceof Footnote) {
|
} elseif ($element instanceof Footnote) {
|
||||||
$this->_writeFootnote($xmlWriter, $element);
|
$this->writeFootnote($xmlWriter, $element);
|
||||||
} elseif ($element instanceof CheckBox) {
|
} elseif ($element instanceof CheckBox) {
|
||||||
$this->_writeCheckBox($xmlWriter, $element);
|
$this->writeCheckBox($xmlWriter, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pSection == $countSections) {
|
if ($pSection == $countSections) {
|
||||||
$this->_writeEndSection($xmlWriter, $section);
|
$this->writeEndSection($xmlWriter, $section);
|
||||||
} else {
|
} else {
|
||||||
$this->_writeSection($xmlWriter, $section);
|
$this->writeSection($xmlWriter, $section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,11 +121,11 @@ class Document extends Base
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Section $section
|
* @param PhpOffice\PhpWord\Section $section
|
||||||
*/
|
*/
|
||||||
private function _writeSection(XMLWriter $xmlWriter, Section $section)
|
private function writeSection(XMLWriter $xmlWriter, Section $section)
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('w:p');
|
$xmlWriter->startElement('w:p');
|
||||||
$xmlWriter->startElement('w:pPr');
|
$xmlWriter->startElement('w:pPr');
|
||||||
$this->_writeEndSection($xmlWriter, $section, 3);
|
$this->writeEndSection($xmlWriter, $section, 3);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ class Document extends Base
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Section $section
|
* @param PhpOffice\PhpWord\Section $section
|
||||||
*/
|
*/
|
||||||
private function _writeEndSection(XMLWriter $xmlWriter, Section $section)
|
private function writeEndSection(XMLWriter $xmlWriter, Section $section)
|
||||||
{
|
{
|
||||||
$settings = $section->getSettings();
|
$settings = $section->getSettings();
|
||||||
$_headers = $section->getHeaders();
|
$_headers = $section->getHeaders();
|
||||||
@ -274,7 +274,7 @@ class Document extends Base
|
|||||||
*
|
*
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function _writePageBreak(XMLWriter $xmlWriter)
|
private function writePageBreak(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('w:p');
|
$xmlWriter->startElement('w:p');
|
||||||
$xmlWriter->startElement('w:r');
|
$xmlWriter->startElement('w:r');
|
||||||
@ -285,122 +285,12 @@ class Document extends Base
|
|||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write list item element
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param PhpOffice\PhpWord\Section\ListItem $listItem
|
|
||||||
*/
|
|
||||||
public function _writeListItem(XMLWriter $xmlWriter, ListItem $listItem)
|
|
||||||
{
|
|
||||||
$textObject = $listItem->getTextObject();
|
|
||||||
$text = $textObject->getText();
|
|
||||||
$styleParagraph = $textObject->getParagraphStyle();
|
|
||||||
$SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
|
|
||||||
|
|
||||||
$depth = $listItem->getDepth();
|
|
||||||
$listType = $listItem->getStyle()->getListType();
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:p');
|
|
||||||
$xmlWriter->startElement('w:pPr');
|
|
||||||
|
|
||||||
if ($SpIsObject) {
|
|
||||||
$this->_writeParagraphStyle($xmlWriter, $styleParagraph, true);
|
|
||||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
|
||||||
$xmlWriter->startElement('w:pStyle');
|
|
||||||
$xmlWriter->writeAttribute('w:val', $styleParagraph);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:numPr');
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:ilvl');
|
|
||||||
$xmlWriter->writeAttribute('w:val', $depth);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:numId');
|
|
||||||
$xmlWriter->writeAttribute('w:val', $listType);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$this->_writeText($xmlWriter, $textObject, true);
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write object element
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param PhpOffice\PhpWord\Section\Object $object
|
|
||||||
*/
|
|
||||||
protected function _writeObject(XMLWriter $xmlWriter, Object $object)
|
|
||||||
{
|
|
||||||
$rIdObject = $object->getRelationId();
|
|
||||||
$rIdImage = $object->getImageRelationId();
|
|
||||||
$shapeId = md5($rIdObject . '_' . $rIdImage);
|
|
||||||
|
|
||||||
$objectId = $object->getObjectId();
|
|
||||||
|
|
||||||
$style = $object->getStyle();
|
|
||||||
$width = $style->getWidth();
|
|
||||||
$height = $style->getHeight();
|
|
||||||
$align = $style->getAlign();
|
|
||||||
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:p');
|
|
||||||
|
|
||||||
if (!is_null($align)) {
|
|
||||||
$xmlWriter->startElement('w:pPr');
|
|
||||||
$xmlWriter->startElement('w:jc');
|
|
||||||
$xmlWriter->writeAttribute('w:val', $align);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:r');
|
|
||||||
|
|
||||||
$xmlWriter->startElement('w:object');
|
|
||||||
$xmlWriter->writeAttribute('w:dxaOrig', '249');
|
|
||||||
$xmlWriter->writeAttribute('w:dyaOrig', '160');
|
|
||||||
|
|
||||||
$xmlWriter->startElement('v:shape');
|
|
||||||
$xmlWriter->writeAttribute('id', $shapeId);
|
|
||||||
$xmlWriter->writeAttribute('type', '#_x0000_t75');
|
|
||||||
$xmlWriter->writeAttribute('style', 'width:104px;height:67px');
|
|
||||||
$xmlWriter->writeAttribute('o:ole', '');
|
|
||||||
|
|
||||||
$xmlWriter->startElement('v:imagedata');
|
|
||||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage);
|
|
||||||
$xmlWriter->writeAttribute('o:title', '');
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->startElement('o:OLEObject');
|
|
||||||
$xmlWriter->writeAttribute('Type', 'Embed');
|
|
||||||
$xmlWriter->writeAttribute('ProgID', 'Package');
|
|
||||||
$xmlWriter->writeAttribute('ShapeID', $shapeId);
|
|
||||||
$xmlWriter->writeAttribute('DrawAspect', 'Icon');
|
|
||||||
$xmlWriter->writeAttribute('ObjectID', '_' . $objectId);
|
|
||||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject);
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:r
|
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:p
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write TOC element
|
* Write TOC element
|
||||||
*
|
*
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
*/
|
*/
|
||||||
private function _writeTOC(XMLWriter $xmlWriter)
|
private function writeTOC(XMLWriter $xmlWriter)
|
||||||
{
|
{
|
||||||
$titles = TOC::getTitles();
|
$titles = TOC::getTitles();
|
||||||
$styleFont = TOC::getStyleFont();
|
$styleFont = TOC::getStyleFont();
|
||||||
@ -421,7 +311,7 @@ class Document extends Base
|
|||||||
$xmlWriter->startElement('w:pPr');
|
$xmlWriter->startElement('w:pPr');
|
||||||
|
|
||||||
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||||
$this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle());
|
$this->writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($indent > 0) {
|
if ($indent > 0) {
|
||||||
@ -479,7 +369,7 @@ class Document extends Base
|
|||||||
$xmlWriter->startElement('w:r');
|
$xmlWriter->startElement('w:r');
|
||||||
|
|
||||||
if ($isObject) {
|
if ($isObject) {
|
||||||
$this->_writeTextStyle($xmlWriter, $styleFont);
|
$this->writeFontStyle($xmlWriter, $styleFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->startElement('w:t');
|
$xmlWriter->startElement('w:t');
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||||||
/**
|
/**
|
||||||
* Word2007 document rels part writer
|
* Word2007 document rels part writer
|
||||||
*/
|
*/
|
||||||
class DocumentRels extends WriterPart
|
class DocumentRels extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write word/_rels/document.xml.rels
|
* Write word/_rels/document.xml.rels
|
||||||
@ -35,7 +35,7 @@ class DocumentRels extends WriterPart
|
|||||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
// Relationship word/document.xml
|
// Relationship word/document.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
1,
|
1,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||||
@ -43,7 +43,7 @@ class DocumentRels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship word/numbering.xml
|
// Relationship word/numbering.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
2,
|
2,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
||||||
@ -51,7 +51,7 @@ class DocumentRels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship word/settings.xml
|
// Relationship word/settings.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
3,
|
3,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
||||||
@ -59,7 +59,7 @@ class DocumentRels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship word/settings.xml
|
// Relationship word/settings.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
4,
|
4,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||||
@ -67,7 +67,7 @@ class DocumentRels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship word/settings.xml
|
// Relationship word/settings.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
5,
|
5,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
||||||
@ -75,7 +75,7 @@ class DocumentRels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship word/settings.xml
|
// Relationship word/settings.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
6,
|
6,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
||||||
@ -89,7 +89,7 @@ class DocumentRels extends WriterPart
|
|||||||
$relationId = $relation['rID'];
|
$relationId = $relation['rID'];
|
||||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||||
|
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
$relationId,
|
$relationId,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||||
@ -128,7 +128,7 @@ class DocumentRels extends WriterPart
|
|||||||
$relationName = $relation['target'];
|
$relationName = $relation['target'];
|
||||||
$relationId = $relation['rID'];
|
$relationId = $relation['rID'];
|
||||||
|
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
$relationId,
|
$relationId,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||||
@ -142,36 +142,4 @@ class DocumentRels extends WriterPart
|
|||||||
// Return
|
// Return
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write individual rels entry
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param int $pId Relationship ID
|
|
||||||
* @param string $pType Relationship type
|
|
||||||
* @param string $pTarget Relationship target
|
|
||||||
* @param string $pTargetMode Relationship target mode
|
|
||||||
*/
|
|
||||||
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
|
||||||
{
|
|
||||||
if ($pType != '' && $pTarget != '') {
|
|
||||||
if (strpos($pId, 'rId') === false) {
|
|
||||||
$pId = 'rId' . $pId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write relationship
|
|
||||||
$xmlWriter->startElement('Relationship');
|
|
||||||
$xmlWriter->writeAttribute('Id', $pId);
|
|
||||||
$xmlWriter->writeAttribute('Type', $pType);
|
|
||||||
$xmlWriter->writeAttribute('Target', $pTarget);
|
|
||||||
|
|
||||||
if ($pTargetMode != '') {
|
|
||||||
$xmlWriter->writeAttribute('TargetMode', $pTargetMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
} else {
|
|
||||||
throw new Exception("Invalid parameters passed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,17 +50,17 @@ class Footer extends Base
|
|||||||
|
|
||||||
foreach ($_elements as $element) {
|
foreach ($_elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element);
|
$this->writeText($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextRun) {
|
} elseif ($element instanceof TextRun) {
|
||||||
$this->_writeTextRun($xmlWriter, $element);
|
$this->writeTextRun($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextBreak) {
|
} elseif ($element instanceof TextBreak) {
|
||||||
$this->_writeTextBreak($xmlWriter, $element);
|
$this->writeTextBreak($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Table) {
|
} elseif ($element instanceof Table) {
|
||||||
$this->_writeTable($xmlWriter, $element);
|
$this->writeTable($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Image) {
|
} elseif ($element instanceof Image) {
|
||||||
$this->_writeImage($xmlWriter, $element);
|
$this->writeImage($xmlWriter, $element);
|
||||||
} elseif ($element instanceof PreserveText) {
|
} elseif ($element instanceof PreserveText) {
|
||||||
$this->_writePreserveText($xmlWriter, $element);
|
$this->writePreserveText($xmlWriter, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class Footnotes extends Base
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param PhpOffice\PhpWord\Section\Footnote $footnote
|
* @param PhpOffice\PhpWord\Section\Footnote $footnote
|
||||||
*/
|
*/
|
||||||
private function writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
|
protected function writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
|
||||||
{
|
{
|
||||||
$xmlWriter->startElement('w:footnote');
|
$xmlWriter->startElement('w:footnote');
|
||||||
$xmlWriter->writeAttribute('w:id', $footnote->getReferenceId());
|
$xmlWriter->writeAttribute('w:id', $footnote->getReferenceId());
|
||||||
@ -89,7 +89,7 @@ class Footnotes extends Base
|
|||||||
$paragraphStyle = $footnote->getParagraphStyle();
|
$paragraphStyle = $footnote->getParagraphStyle();
|
||||||
$spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false;
|
$spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false;
|
||||||
if ($spIsObject) {
|
if ($spIsObject) {
|
||||||
$this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
|
$this->writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||||
} elseif (!$spIsObject && !is_null($paragraphStyle)) {
|
} elseif (!$spIsObject && !is_null($paragraphStyle)) {
|
||||||
$xmlWriter->startElement('w:pPr');
|
$xmlWriter->startElement('w:pPr');
|
||||||
$xmlWriter->startElement('w:pStyle');
|
$xmlWriter->startElement('w:pStyle');
|
||||||
@ -118,9 +118,9 @@ class Footnotes extends Base
|
|||||||
if (count($elements) > 0) {
|
if (count($elements) > 0) {
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element, true);
|
$this->writeText($xmlWriter, $element, true);
|
||||||
} elseif ($element instanceof Link) {
|
} elseif ($element instanceof Link) {
|
||||||
$this->_writeLink($xmlWriter, $element, true);
|
$this->writeLink($xmlWriter, $element, true);
|
||||||
} elseif ($element instanceof TextBreak) {
|
} elseif ($element instanceof TextBreak) {
|
||||||
$xmlWriter->writeElement('w:br');
|
$xmlWriter->writeElement('w:br');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||||||
/**
|
/**
|
||||||
* Word2007 footnotes rel part writer
|
* Word2007 footnotes rel part writer
|
||||||
*/
|
*/
|
||||||
class FootnotesRels extends WriterPart
|
class FootnotesRels extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write word/_rels/footnotes.xml.rels
|
* Write word/_rels/footnotes.xml.rels
|
||||||
@ -41,7 +41,7 @@ class FootnotesRels extends WriterPart
|
|||||||
$relationId = $relation['rID'];
|
$relationId = $relation['rID'];
|
||||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||||
|
|
||||||
$this->_writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode);
|
$this->writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
@ -49,36 +49,4 @@ class FootnotesRels extends WriterPart
|
|||||||
// Return
|
// Return
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write individual rels entry
|
|
||||||
*
|
|
||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param int $pId Relationship ID
|
|
||||||
* @param string $pType Relationship type
|
|
||||||
* @param string $pTarget Relationship target
|
|
||||||
* @param string $pTargetMode Relationship target mode
|
|
||||||
*/
|
|
||||||
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
|
||||||
{
|
|
||||||
if ($pType != '' && $pTarget != '') {
|
|
||||||
if (strpos($pId, 'rId') === false) {
|
|
||||||
$pId = 'rId' . $pId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write relationship
|
|
||||||
$xmlWriter->startElement('Relationship');
|
|
||||||
$xmlWriter->writeAttribute('Id', $pId);
|
|
||||||
$xmlWriter->writeAttribute('Type', $pType);
|
|
||||||
$xmlWriter->writeAttribute('Target', $pTarget);
|
|
||||||
|
|
||||||
if ($pTargetMode != '') {
|
|
||||||
$xmlWriter->writeAttribute('TargetMode', $pTargetMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
} else {
|
|
||||||
throw new Exception("Invalid parameters passed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,21 +51,21 @@ class Header extends Base
|
|||||||
|
|
||||||
foreach ($_elements as $element) {
|
foreach ($_elements as $element) {
|
||||||
if ($element instanceof Text) {
|
if ($element instanceof Text) {
|
||||||
$this->_writeText($xmlWriter, $element);
|
$this->writeText($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextRun) {
|
} elseif ($element instanceof TextRun) {
|
||||||
$this->_writeTextRun($xmlWriter, $element);
|
$this->writeTextRun($xmlWriter, $element);
|
||||||
} elseif ($element instanceof TextBreak) {
|
} elseif ($element instanceof TextBreak) {
|
||||||
$this->_writeTextBreak($xmlWriter, $element);
|
$this->writeTextBreak($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Table) {
|
} elseif ($element instanceof Table) {
|
||||||
$this->_writeTable($xmlWriter, $element);
|
$this->writeTable($xmlWriter, $element);
|
||||||
} elseif ($element instanceof Image) {
|
} elseif ($element instanceof Image) {
|
||||||
if (!$element->getIsWatermark()) {
|
if (!$element->getIsWatermark()) {
|
||||||
$this->_writeImage($xmlWriter, $element);
|
$this->writeImage($xmlWriter, $element);
|
||||||
} else {
|
} else {
|
||||||
$this->_writeWatermark($xmlWriter, $element);
|
$this->writeWatermark($xmlWriter, $element);
|
||||||
}
|
}
|
||||||
} elseif ($element instanceof PreserveText) {
|
} elseif ($element instanceof PreserveText) {
|
||||||
$this->_writePreserveText($xmlWriter, $element);
|
$this->writePreserveText($xmlWriter, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||||||
/**
|
/**
|
||||||
* Word2007 rels part writer
|
* Word2007 rels part writer
|
||||||
*/
|
*/
|
||||||
class Rels extends WriterPart
|
class Rels extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write _rels/.rels
|
* Write _rels/.rels
|
||||||
@ -38,7 +38,7 @@ class Rels extends WriterPart
|
|||||||
$relationId = 1;
|
$relationId = 1;
|
||||||
|
|
||||||
// Relationship word/document.xml
|
// Relationship word/document.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
$relationId,
|
$relationId,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||||
@ -46,7 +46,7 @@ class Rels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship docProps/core.xml
|
// Relationship docProps/core.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
++$relationId,
|
++$relationId,
|
||||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||||
@ -54,7 +54,7 @@ class Rels extends WriterPart
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Relationship docProps/app.xml
|
// Relationship docProps/app.xml
|
||||||
$this->_writeRelationship(
|
$this->writeRelationship(
|
||||||
$xmlWriter,
|
$xmlWriter,
|
||||||
++$relationId,
|
++$relationId,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||||
@ -65,37 +65,4 @@ class Rels extends WriterPart
|
|||||||
|
|
||||||
return $xmlWriter->getData();
|
return $xmlWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write Override content type
|
|
||||||
*
|
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
||||||
* @param int $pId Relationship ID. rId will be prepended!
|
|
||||||
* @param string $pType Relationship type
|
|
||||||
* @param string $pTarget Relationship target
|
|
||||||
* @param string $pTargetMode Relationship target mode
|
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
|
||||||
*/
|
|
||||||
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
|
||||||
{
|
|
||||||
if ($pType != '' && $pTarget != '') {
|
|
||||||
if (strpos($pId, 'rId') === false) {
|
|
||||||
$pId = 'rId' . $pId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write relationship
|
|
||||||
$xmlWriter->startElement('Relationship');
|
|
||||||
$xmlWriter->writeAttribute('Id', $pId);
|
|
||||||
$xmlWriter->writeAttribute('Type', $pType);
|
|
||||||
$xmlWriter->writeAttribute('Target', $pTarget);
|
|
||||||
|
|
||||||
if ($pTargetMode != '') {
|
|
||||||
$xmlWriter->writeAttribute('TargetMode', $pTargetMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
} else {
|
|
||||||
throw new Exception("Invalid parameters passed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,6 @@ use PhpOffice\PhpWord\Style\Paragraph;
|
|||||||
*/
|
*/
|
||||||
class Styles extends Base
|
class Styles extends Base
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* PhpWord object
|
|
||||||
*
|
|
||||||
* @var PhpWord
|
|
||||||
*/
|
|
||||||
private $phpWord;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write word/styles.xml
|
* Write word/styles.xml
|
||||||
*
|
*
|
||||||
@ -34,8 +27,6 @@ class Styles extends Base
|
|||||||
*/
|
*/
|
||||||
public function writeStyles(PhpWord $phpWord = null)
|
public function writeStyles(PhpWord $phpWord = null)
|
||||||
{
|
{
|
||||||
$this->phpWord = $phpWord;
|
|
||||||
|
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$xmlWriter = $this->getXmlWriter();
|
$xmlWriter = $this->getXmlWriter();
|
||||||
|
|
||||||
@ -52,7 +43,7 @@ class Styles extends Base
|
|||||||
);
|
);
|
||||||
// Write default styles
|
// Write default styles
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
$this->writeDefaultStyles($xmlWriter, $styles);
|
$this->writeDefaultStyles($xmlWriter, $phpWord, $styles);
|
||||||
// Write other styles
|
// Write other styles
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $styleName => $style) {
|
||||||
@ -94,10 +85,10 @@ class Styles extends Base
|
|||||||
$xmlWriter->startElement('w:basedOn');
|
$xmlWriter->startElement('w:basedOn');
|
||||||
$xmlWriter->writeAttribute('w:val', 'Normal');
|
$xmlWriter->writeAttribute('w:val', 'Normal');
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
$this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
|
$this->writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_writeTextStyle($xmlWriter, $style);
|
$this->writeFontStyle($xmlWriter, $style);
|
||||||
|
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
@ -127,7 +118,7 @@ class Styles extends Base
|
|||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_writeParagraphStyle($xmlWriter, $style);
|
$this->writeParagraphStyle($xmlWriter, $style);
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
} elseif ($style instanceof \PhpOffice\PhpWord\Style\Table) {
|
} elseif ($style instanceof \PhpOffice\PhpWord\Style\Table) {
|
||||||
@ -144,7 +135,7 @@ class Styles extends Base
|
|||||||
$xmlWriter->writeAttribute('w:val', '99');
|
$xmlWriter->writeAttribute('w:val', '99');
|
||||||
$xmlWriter->endElement();
|
$xmlWriter->endElement();
|
||||||
|
|
||||||
$this->_writeTableStyle($xmlWriter, $style);
|
$this->writeTableStyle($xmlWriter, $style);
|
||||||
|
|
||||||
$xmlWriter->endElement(); // w:style
|
$xmlWriter->endElement(); // w:style
|
||||||
}
|
}
|
||||||
@ -163,10 +154,10 @@ class Styles extends Base
|
|||||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param array $styles
|
* @param array $styles
|
||||||
*/
|
*/
|
||||||
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
|
private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
|
||||||
{
|
{
|
||||||
$fontName = $this->phpWord->getDefaultFontName();
|
$fontName = $phpWord->getDefaultFontName();
|
||||||
$fontSize = $this->phpWord->getDefaultFontSize();
|
$fontSize = $phpWord->getDefaultFontSize();
|
||||||
|
|
||||||
// Default font
|
// Default font
|
||||||
$xmlWriter->startElement('w:docDefaults');
|
$xmlWriter->startElement('w:docDefaults');
|
||||||
@ -197,7 +188,7 @@ class Styles extends Base
|
|||||||
$xmlWriter->writeAttribute('w:val', 'Normal');
|
$xmlWriter->writeAttribute('w:val', 'Normal');
|
||||||
$xmlWriter->endElement(); // w:name
|
$xmlWriter->endElement(); // w:name
|
||||||
if (array_key_exists('Normal', $styles)) {
|
if (array_key_exists('Normal', $styles)) {
|
||||||
$this->_writeParagraphStyle($xmlWriter, $styles['Normal']);
|
$this->writeParagraphStyle($xmlWriter, $styles['Normal']);
|
||||||
}
|
}
|
||||||
$xmlWriter->endElement(); // w:style
|
$xmlWriter->endElement(); // w:style
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user