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
|
||||
*
|
||||
* @var datetime
|
||||
* @var datetime|int
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
* @var datetime|int
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
@ -102,7 +102,7 @@ class DocumentProperties
|
||||
/**
|
||||
* Custom Properties
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
private $_customProperties = array();
|
||||
|
||||
@ -542,26 +542,21 @@ class DocumentProperties
|
||||
case 'ui8': // 8-Byte Unsigned Integer
|
||||
case 'uint': // Unsigned Integer
|
||||
return self::PROPERTY_TYPE_INTEGER;
|
||||
break;
|
||||
case 'r4': // 4-Byte Real Number
|
||||
case 'r8': // 8-Byte Real Number
|
||||
case 'decimal': // Decimal
|
||||
return self::PROPERTY_TYPE_FLOAT;
|
||||
break;
|
||||
case 'empty': // Empty
|
||||
case 'null': // Null
|
||||
case 'lpstr': // LPSTR
|
||||
case 'lpwstr': // LPWSTR
|
||||
case 'bstr': // Basic String
|
||||
return self::PROPERTY_TYPE_STRING;
|
||||
break;
|
||||
case 'date': // Date and Time
|
||||
case 'filetime': // File Time
|
||||
return self::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'bool': // Boolean
|
||||
return self::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'cy': // Currency
|
||||
case 'error': // Error Status Code
|
||||
case 'vector': // Vector
|
||||
@ -576,7 +571,6 @@ class DocumentProperties
|
||||
case 'clsid': // Class ID
|
||||
case 'cf': // Clipboard Data
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
@ -34,14 +34,14 @@ class CheckBox
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var Font
|
||||
* @var string|Font
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var Paragraph
|
||||
* @var string|Paragraph
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
@ -50,8 +50,8 @@ class CheckBox
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $text
|
||||
* @param Font $fontStyle
|
||||
* @param Paragraph $paragraphStyle
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($name = null, $text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -66,9 +66,9 @@ class CheckBox
|
||||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @param Font $style
|
||||
* @param Paragraph $paragraphStyle
|
||||
* @return Font
|
||||
* @param mixed $style
|
||||
* @param mixed $paragraphStyle
|
||||
* @return string|Font
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -90,7 +90,7 @@ class CheckBox
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return Font
|
||||
* @return string|Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@ -100,8 +100,8 @@ class CheckBox
|
||||
/**
|
||||
* Set Paragraph style
|
||||
*
|
||||
* @param Paragraph $style
|
||||
* @return Paragraph
|
||||
* @param mixed $style
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
@ -121,7 +121,7 @@ class CheckBox
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return Paragraph
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@ -41,14 +41,14 @@ class Link
|
||||
/**
|
||||
* Link style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
* @var string|Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @var string|Paragraph
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
@ -140,7 +140,7 @@ class Link
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @return string|Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@ -150,7 +150,7 @@ class Link
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@ -27,14 +27,14 @@ class Text
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
* @var string|Font
|
||||
*/
|
||||
private $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @var string|Paragraph
|
||||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
@ -42,8 +42,8 @@ class Text
|
||||
* Create a new Text Element
|
||||
*
|
||||
* @param string $text
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $fontStyle
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -55,9 +55,9 @@ class Text
|
||||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $style
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @param string|array|Font $style
|
||||
* @param string|array|Paragraph $paragraphStyle
|
||||
* @return string|Font
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -79,7 +79,7 @@ class Text
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @return string|Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@ -89,8 +89,8 @@ class Text
|
||||
/**
|
||||
* Set Paragraph style
|
||||
*
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph
|
||||
* @param string|array|Paragraph $style
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
@ -110,7 +110,7 @@ class Text
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@ -20,14 +20,14 @@ class TextBreak
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Pagaraph
|
||||
* @var string|Paragraph
|
||||
*/
|
||||
private $paragraphStyle = null;
|
||||
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
* @var string|Font
|
||||
*/
|
||||
private $fontStyle = null;
|
||||
|
||||
@ -50,9 +50,9 @@ class TextBreak
|
||||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Font $style
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @param mixed $style
|
||||
* @param mixed $paragraphStyle
|
||||
* @return string|Font
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -72,7 +72,7 @@ class TextBreak
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Font
|
||||
* @return string|Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
@ -82,8 +82,8 @@ class TextBreak
|
||||
/**
|
||||
* Set Paragraph style
|
||||
*
|
||||
* @param null|array|\PhpOffice\PhpWord\Style\Paragraph $style
|
||||
* @return null|\PhpOffice\PhpWord\Style\Paragraph
|
||||
* @param string|array|Paragraph $style
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
@ -101,7 +101,7 @@ class TextBreak
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@ -12,6 +12,7 @@ namespace PhpOffice\PhpWord\Section;
|
||||
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\Shared\String;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
||||
/**
|
||||
@ -22,7 +23,7 @@ class TextRun
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @var Paragraph
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
@ -123,8 +124,8 @@ class TextRun
|
||||
* Add TextBreak
|
||||
*
|
||||
* @param int $count
|
||||
* @param null|string|array|\PhpOffice\PhpWord\Style\Font $fontStyle
|
||||
* @param null|string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
@ -161,7 +162,7 @@ class TextRun
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
||||
* @return string|Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
|
||||
@ -244,11 +244,11 @@ class Content extends WriterPart
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->_writeText($xmlWriter, $element);
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->_writeTextRun($xmlWriter, $element);
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->_writeTextBreak($xmlWriter);
|
||||
$this->writeTextBreak($xmlWriter);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeUnsupportedElement($xmlWriter, 'Link');
|
||||
} elseif ($element instanceof Title) {
|
||||
@ -271,9 +271,9 @@ class Content extends WriterPart
|
||||
}
|
||||
|
||||
if ($pSection == $countSections) {
|
||||
$this->_writeEndSection($xmlWriter, $section);
|
||||
$this->writeEndSection($xmlWriter, $section);
|
||||
} else {
|
||||
$this->_writeSection($xmlWriter, $section);
|
||||
$this->writeSection($xmlWriter, $section);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,7 +292,7 @@ class Content extends WriterPart
|
||||
* @param \PhpOffice\PhpWord\Section\Text $text
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
|
||||
protected function writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
|
||||
{
|
||||
$styleFont = $text->getFontStyle();
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
@ -340,14 +340,14 @@ class Content extends WriterPart
|
||||
* @param \PhpOffice\PhpWord\Section\TextRun $textrun
|
||||
* @todo Enable all other section types
|
||||
*/
|
||||
protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
|
||||
protected function writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
|
||||
{
|
||||
$elements = $textrun->getElements();
|
||||
$xmlWriter->startElement('text:p');
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
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
|
||||
*/
|
||||
protected function _writeTextBreak(XMLWriter $xmlWriter = null)
|
||||
protected function writeTextBreak(XMLWriter $xmlWriter = null)
|
||||
{
|
||||
$xmlWriter->startElement('text:p');
|
||||
$xmlWriter->writeAttribute('text:style-name', 'Standard');
|
||||
@ -373,7 +373,7 @@ class Content extends WriterPart
|
||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @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\Section $section
|
||||
*/
|
||||
private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null)
|
||||
private function writeSection(XMLWriter $xmlWriter = null, Section $section = null)
|
||||
{
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
@ -64,7 +64,7 @@ class Manifest extends WriterPart
|
||||
for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||
$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->writeAttribute('manifest:media-type', $mimeType);
|
||||
@ -99,7 +99,7 @@ class Manifest extends WriterPart
|
||||
* @return string Mime Type
|
||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
private function getImageMimeType($pFile = '')
|
||||
{
|
||||
if (file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
|
||||
@ -179,7 +179,6 @@ class RTF extends Writer implements IWriter
|
||||
|
||||
// Browse styles
|
||||
$styles = Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PhpOffice\PhpWord\Style\Font
|
||||
@ -232,7 +231,6 @@ class RTF extends Writer implements IWriter
|
||||
|
||||
// Browse styles
|
||||
$styles = Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// Font
|
||||
|
||||
@ -34,14 +34,14 @@ class Word2007 extends Writer implements IWriter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_imageTypes = array();
|
||||
private $imageTypes = array();
|
||||
|
||||
/**
|
||||
* Types of objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_objectTypes = array();
|
||||
private $objectTypes = array();
|
||||
|
||||
/**
|
||||
* Create new Word2007 writer
|
||||
@ -167,8 +167,8 @@ class Word2007 extends Writer implements IWriter
|
||||
$objZip->addFromString(
|
||||
'[Content_Types].xml',
|
||||
$this->getWriterPart('contenttypes')->writeContentTypes(
|
||||
$this->_imageTypes,
|
||||
$this->_objectTypes,
|
||||
$this->imageTypes,
|
||||
$this->objectTypes,
|
||||
$_cHdrs,
|
||||
$footers
|
||||
)
|
||||
@ -235,12 +235,12 @@ class Word2007 extends Writer implements IWriter
|
||||
if ($imageExtension === 'jpeg') {
|
||||
$imageExtension = 'jpg';
|
||||
}
|
||||
if (!in_array($imageType, $this->_imageTypes)) {
|
||||
$this->_imageTypes[$imageExtension] = $imageType;
|
||||
if (!in_array($imageType, $this->imageTypes)) {
|
||||
$this->imageTypes[$imageExtension] = $imageType;
|
||||
}
|
||||
} else {
|
||||
if (!in_array($extension, $this->_objectTypes)) {
|
||||
$this->_objectTypes[] = $extension;
|
||||
if (!in_array($extension, $this->objectTypes)) {
|
||||
$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
|
||||
* @param array $_imageTypes
|
||||
* @param array $_objectTypes
|
||||
* @param array $imageTypes
|
||||
* @param array $objectTypes
|
||||
* @param int $_cHdrs
|
||||
* @param array $footers
|
||||
*/
|
||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
|
||||
public function writeContentTypes($imageTypes, $objectTypes, $_cHdrs, $footers)
|
||||
{
|
||||
// Create XML writer
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
@ -37,27 +37,27 @@ class ContentTypes extends WriterPart
|
||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$this->writeDefaultContentType(
|
||||
$xmlWriter,
|
||||
'rels',
|
||||
'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$this->writeDefaultContentType(
|
||||
$xmlWriter,
|
||||
'xml',
|
||||
'application/xml'
|
||||
);
|
||||
|
||||
// Add media content-types
|
||||
foreach ($_imageTypes as $key => $value) {
|
||||
$this->_writeDefaultContentType($xmlWriter, $key, $value);
|
||||
foreach ($imageTypes as $key => $value) {
|
||||
$this->writeDefaultContentType($xmlWriter, $key, $value);
|
||||
}
|
||||
|
||||
// Add embedding content-types
|
||||
if (count($_objectTypes) > 0) {
|
||||
$this->_writeDefaultContentType(
|
||||
if (count($objectTypes) > 0) {
|
||||
$this->writeDefaultContentType(
|
||||
$xmlWriter,
|
||||
'bin',
|
||||
'application/vnd.openxmlformats-officedocument.oleObject'
|
||||
@ -65,76 +65,76 @@ class ContentTypes extends WriterPart
|
||||
}
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/docProps/app.xml',
|
||||
'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/docProps/core.xml',
|
||||
'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
// Document
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/document.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||
);
|
||||
|
||||
// Styles
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/styles.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||
);
|
||||
|
||||
// Numbering
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/numbering.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||
);
|
||||
|
||||
// Settings
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/settings.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||
);
|
||||
|
||||
// Theme1
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/theme/theme1.xml',
|
||||
'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// WebSettings
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/webSettings.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||
);
|
||||
|
||||
// Font Table
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/fontTable.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
);
|
||||
|
||||
// Footnotes
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/footnotes.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml'
|
||||
);
|
||||
|
||||
for ($i = 1; $i <= $_cHdrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/header' . $i . '.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
@ -143,7 +143,7 @@ class ContentTypes extends WriterPart
|
||||
|
||||
for ($i = 1; $i <= count($footers); $i++) {
|
||||
if (!is_null($footers[$i])) {
|
||||
$this->_writeOverrideContentType(
|
||||
$this->writeOverrideContentType(
|
||||
$xmlWriter,
|
||||
'/word/footer' . $i . '.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
@ -158,23 +158,6 @@ class ContentTypes extends WriterPart
|
||||
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
|
||||
*
|
||||
@ -183,7 +166,7 @@ class ContentTypes extends WriterPart
|
||||
* @param string $pContentType Content type
|
||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||
private function writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
@ -204,7 +187,7 @@ class ContentTypes extends WriterPart
|
||||
* @param string $pContentType Content type
|
||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||
private function writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
@ -216,4 +199,21 @@ class ContentTypes extends WriterPart
|
||||
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();
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->_writeText($xmlWriter, $element);
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->_writeTextRun($xmlWriter, $element);
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->_writeLink($xmlWriter, $element);
|
||||
$this->writeLink($xmlWriter, $element);
|
||||
} elseif ($element instanceof Title) {
|
||||
$this->_writeTitle($xmlWriter, $element);
|
||||
$this->writeTitle($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->_writeTextBreak($xmlWriter, $element);
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof PageBreak) {
|
||||
$this->_writePageBreak($xmlWriter);
|
||||
$this->writePageBreak($xmlWriter);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->_writeTable($xmlWriter, $element);
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof ListItem) {
|
||||
$this->_writeListItem($xmlWriter, $element);
|
||||
$this->writeListItem($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->_writeImage($xmlWriter, $element);
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} elseif ($element instanceof Object) {
|
||||
$this->_writeObject($xmlWriter, $element);
|
||||
$this->writeObject($xmlWriter, $element);
|
||||
} elseif ($element instanceof TOC) {
|
||||
$this->_writeTOC($xmlWriter);
|
||||
$this->writeTOC($xmlWriter);
|
||||
} elseif ($element instanceof Footnote) {
|
||||
$this->_writeFootnote($xmlWriter, $element);
|
||||
$this->writeFootnote($xmlWriter, $element);
|
||||
} elseif ($element instanceof CheckBox) {
|
||||
$this->_writeCheckBox($xmlWriter, $element);
|
||||
$this->writeCheckBox($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
if ($pSection == $countSections) {
|
||||
$this->_writeEndSection($xmlWriter, $section);
|
||||
$this->writeEndSection($xmlWriter, $section);
|
||||
} 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\Section $section
|
||||
*/
|
||||
private function _writeSection(XMLWriter $xmlWriter, Section $section)
|
||||
private function writeSection(XMLWriter $xmlWriter, Section $section)
|
||||
{
|
||||
$xmlWriter->startElement('w:p');
|
||||
$xmlWriter->startElement('w:pPr');
|
||||
$this->_writeEndSection($xmlWriter, $section, 3);
|
||||
$this->writeEndSection($xmlWriter, $section, 3);
|
||||
$xmlWriter->endElement();
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
@ -136,7 +136,7 @@ class Document extends Base
|
||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param PhpOffice\PhpWord\Section $section
|
||||
*/
|
||||
private function _writeEndSection(XMLWriter $xmlWriter, Section $section)
|
||||
private function writeEndSection(XMLWriter $xmlWriter, Section $section)
|
||||
{
|
||||
$settings = $section->getSettings();
|
||||
$_headers = $section->getHeaders();
|
||||
@ -274,7 +274,7 @@ class Document extends Base
|
||||
*
|
||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
*/
|
||||
private function _writePageBreak(XMLWriter $xmlWriter)
|
||||
private function writePageBreak(XMLWriter $xmlWriter)
|
||||
{
|
||||
$xmlWriter->startElement('w:p');
|
||||
$xmlWriter->startElement('w:r');
|
||||
@ -285,122 +285,12 @@ class Document extends Base
|
||||
$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
|
||||
*
|
||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
*/
|
||||
private function _writeTOC(XMLWriter $xmlWriter)
|
||||
private function writeTOC(XMLWriter $xmlWriter)
|
||||
{
|
||||
$titles = TOC::getTitles();
|
||||
$styleFont = TOC::getStyleFont();
|
||||
@ -421,7 +311,7 @@ class Document extends Base
|
||||
$xmlWriter->startElement('w:pPr');
|
||||
|
||||
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||
$this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle());
|
||||
$this->writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle());
|
||||
}
|
||||
|
||||
if ($indent > 0) {
|
||||
@ -479,7 +369,7 @@ class Document extends Base
|
||||
$xmlWriter->startElement('w:r');
|
||||
|
||||
if ($isObject) {
|
||||
$this->_writeTextStyle($xmlWriter, $styleFont);
|
||||
$this->writeFontStyle($xmlWriter, $styleFont);
|
||||
}
|
||||
|
||||
$xmlWriter->startElement('w:t');
|
||||
|
||||
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
/**
|
||||
* Word2007 document rels part writer
|
||||
*/
|
||||
class DocumentRels extends WriterPart
|
||||
class DocumentRels extends Base
|
||||
{
|
||||
/**
|
||||
* Write word/_rels/document.xml.rels
|
||||
@ -35,7 +35,7 @@ class DocumentRels extends WriterPart
|
||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||
@ -43,7 +43,7 @@ class DocumentRels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship word/numbering.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
||||
@ -51,7 +51,7 @@ class DocumentRels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
||||
@ -59,7 +59,7 @@ class DocumentRels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
4,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
@ -67,7 +67,7 @@ class DocumentRels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
5,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
||||
@ -75,7 +75,7 @@ class DocumentRels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
6,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
||||
@ -89,7 +89,7 @@ class DocumentRels extends WriterPart
|
||||
$relationId = $relation['rID'];
|
||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
@ -128,7 +128,7 @@ class DocumentRels extends WriterPart
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
@ -142,36 +142,4 @@ class DocumentRels extends WriterPart
|
||||
// Return
|
||||
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) {
|
||||
if ($element instanceof Text) {
|
||||
$this->_writeText($xmlWriter, $element);
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->_writeTextRun($xmlWriter, $element);
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->_writeTextBreak($xmlWriter, $element);
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->_writeTable($xmlWriter, $element);
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->_writeImage($xmlWriter, $element);
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} 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\Section\Footnote $footnote
|
||||
*/
|
||||
private function writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
|
||||
protected function writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
|
||||
{
|
||||
$xmlWriter->startElement('w:footnote');
|
||||
$xmlWriter->writeAttribute('w:id', $footnote->getReferenceId());
|
||||
@ -89,7 +89,7 @@ class Footnotes extends Base
|
||||
$paragraphStyle = $footnote->getParagraphStyle();
|
||||
$spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false;
|
||||
if ($spIsObject) {
|
||||
$this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||
$this->writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||
} elseif (!$spIsObject && !is_null($paragraphStyle)) {
|
||||
$xmlWriter->startElement('w:pPr');
|
||||
$xmlWriter->startElement('w:pStyle');
|
||||
@ -118,9 +118,9 @@ class Footnotes extends Base
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->_writeText($xmlWriter, $element, true);
|
||||
$this->writeText($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->_writeLink($xmlWriter, $element, true);
|
||||
$this->writeLink($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$xmlWriter->writeElement('w:br');
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
/**
|
||||
* Word2007 footnotes rel part writer
|
||||
*/
|
||||
class FootnotesRels extends WriterPart
|
||||
class FootnotesRels extends Base
|
||||
{
|
||||
/**
|
||||
* Write word/_rels/footnotes.xml.rels
|
||||
@ -41,7 +41,7 @@ class FootnotesRels extends WriterPart
|
||||
$relationId = $relation['rID'];
|
||||
$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();
|
||||
@ -49,36 +49,4 @@ class FootnotesRels extends WriterPart
|
||||
// Return
|
||||
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) {
|
||||
if ($element instanceof Text) {
|
||||
$this->_writeText($xmlWriter, $element);
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->_writeTextRun($xmlWriter, $element);
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->_writeTextBreak($xmlWriter, $element);
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->_writeTable($xmlWriter, $element);
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
if (!$element->getIsWatermark()) {
|
||||
$this->_writeImage($xmlWriter, $element);
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} else {
|
||||
$this->_writeWatermark($xmlWriter, $element);
|
||||
$this->writeWatermark($xmlWriter, $element);
|
||||
}
|
||||
} 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
|
||||
*/
|
||||
class Rels extends WriterPart
|
||||
class Rels extends Base
|
||||
{
|
||||
/**
|
||||
* Write _rels/.rels
|
||||
@ -38,7 +38,7 @@ class Rels extends WriterPart
|
||||
$relationId = 1;
|
||||
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
@ -46,7 +46,7 @@ class Rels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
@ -54,7 +54,7 @@ class Rels extends WriterPart
|
||||
);
|
||||
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$this->writeRelationship(
|
||||
$xmlWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
@ -65,37 +65,4 @@ class Rels extends WriterPart
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* PhpWord object
|
||||
*
|
||||
* @var PhpWord
|
||||
*/
|
||||
private $phpWord;
|
||||
|
||||
/**
|
||||
* Write word/styles.xml
|
||||
*
|
||||
@ -34,8 +27,6 @@ class Styles extends Base
|
||||
*/
|
||||
public function writeStyles(PhpWord $phpWord = null)
|
||||
{
|
||||
$this->phpWord = $phpWord;
|
||||
|
||||
// Create XML writer
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
@ -52,7 +43,7 @@ class Styles extends Base
|
||||
);
|
||||
// Write default styles
|
||||
$styles = Style::getStyles();
|
||||
$this->writeDefaultStyles($xmlWriter, $styles);
|
||||
$this->writeDefaultStyles($xmlWriter, $phpWord, $styles);
|
||||
// Write other styles
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
@ -94,10 +85,10 @@ class Styles extends Base
|
||||
$xmlWriter->startElement('w:basedOn');
|
||||
$xmlWriter->writeAttribute('w:val', 'Normal');
|
||||
$xmlWriter->endElement();
|
||||
$this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||
$this->writeParagraphStyle($xmlWriter, $paragraphStyle);
|
||||
}
|
||||
|
||||
$this->_writeTextStyle($xmlWriter, $style);
|
||||
$this->writeFontStyle($xmlWriter, $style);
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
@ -127,7 +118,7 @@ class Styles extends Base
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
$this->_writeParagraphStyle($xmlWriter, $style);
|
||||
$this->writeParagraphStyle($xmlWriter, $style);
|
||||
$xmlWriter->endElement();
|
||||
|
||||
} elseif ($style instanceof \PhpOffice\PhpWord\Style\Table) {
|
||||
@ -144,7 +135,7 @@ class Styles extends Base
|
||||
$xmlWriter->writeAttribute('w:val', '99');
|
||||
$xmlWriter->endElement();
|
||||
|
||||
$this->_writeTableStyle($xmlWriter, $style);
|
||||
$this->writeTableStyle($xmlWriter, $style);
|
||||
|
||||
$xmlWriter->endElement(); // w:style
|
||||
}
|
||||
@ -163,10 +154,10 @@ class Styles extends Base
|
||||
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param array $styles
|
||||
*/
|
||||
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
|
||||
private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
|
||||
{
|
||||
$fontName = $this->phpWord->getDefaultFontName();
|
||||
$fontSize = $this->phpWord->getDefaultFontSize();
|
||||
$fontName = $phpWord->getDefaultFontName();
|
||||
$fontSize = $phpWord->getDefaultFontSize();
|
||||
|
||||
// Default font
|
||||
$xmlWriter->startElement('w:docDefaults');
|
||||
@ -197,7 +188,7 @@ class Styles extends Base
|
||||
$xmlWriter->writeAttribute('w:val', 'Normal');
|
||||
$xmlWriter->endElement(); // w:name
|
||||
if (array_key_exists('Normal', $styles)) {
|
||||
$this->_writeParagraphStyle($xmlWriter, $styles['Normal']);
|
||||
$this->writeParagraphStyle($xmlWriter, $styles['Normal']);
|
||||
}
|
||||
$xmlWriter->endElement(); // w:style
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user