diff --git a/Classes/PHPWord/Style.php b/Classes/PHPWord/Style.php
index fdd29862..a1f45358 100755
--- a/Classes/PHPWord/Style.php
+++ b/Classes/PHPWord/Style.php
@@ -99,10 +99,10 @@ class Style
* @param string $styleName
* @param array $styles
*/
- public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null)
+ public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{
if (!array_key_exists($styleName, self::$_styleElements)) {
- $style = new TableFull($styleTable, $styleFirstRow, $styleLastRow);
+ $style = new TableFull($styleTable, $styleFirstRow);
self::$_styleElements[$styleName] = $style;
}
diff --git a/Classes/PHPWord/Writer/ODText.php b/Classes/PHPWord/Writer/ODText.php
index 10c47fb8..126446db 100755
--- a/Classes/PHPWord/Writer/ODText.php
+++ b/Classes/PHPWord/Writer/ODText.php
@@ -72,12 +72,12 @@ class ODText implements IWriter
private $_diskCachingDirectory;
/**
- * @param PHPWord $pPHPWord
+ * @param PHPWord $phpWord
*/
- public function __construct(PHPWord $pPHPWord = null)
+ public function __construct(PHPWord $phpWord = null)
{
// Assign PHPWord
- $this->setPHPWord($pPHPWord);
+ $this->setPHPWord($phpWord);
// Set up disk caching location
$this->_diskCachingDirectory = './';
@@ -216,13 +216,13 @@ class ODText implements IWriter
/**
* Get PHPWord object
*
- * @param PHPWord $pPHPWord PHPWord object
+ * @param PHPWord $phpWord PHPWord object
* @throws Exception
* @return PhpOffice\PhpWord\Writer\ODText
*/
- public function setPHPWord(PHPWord $pPHPWord = null)
+ public function setPHPWord(PHPWord $phpWord = null)
{
- $this->_document = $pPHPWord;
+ $this->_document = $phpWord;
return $this;
}
diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php
index 40401931..b39662f0 100755
--- a/Classes/PHPWord/Writer/ODText/Manifest.php
+++ b/Classes/PHPWord/Writer/ODText/Manifest.php
@@ -35,11 +35,11 @@ class Manifest extends WriterPart
/**
* Write Manifest file to XML format
*
- * @param PHPWord $pPHPWord
- * @return string XML Output
- * @throws Exception
+ * @param PHPWord $phpWord
+ * @return string XML Output
+ * @throws Exception
*/
- public function writeManifest(PHPWord $pPHPWord = null)
+ public function writeManifest(PHPWord $phpWord = null)
{
// Create XML writer
$xmlWriter = null;
diff --git a/Classes/PHPWord/Writer/ODText/Meta.php b/Classes/PHPWord/Writer/ODText/Meta.php
index 3d045949..96c0a155 100755
--- a/Classes/PHPWord/Writer/ODText/Meta.php
+++ b/Classes/PHPWord/Writer/ODText/Meta.php
@@ -34,11 +34,11 @@ class Meta extends WriterPart
/**
* Write Meta file to XML format
*
- * @param PHPWord $pPHPWord
- * @return string XML Output
- * @throws Exception
+ * @param PHPWord $phpWord
+ * @return string XML Output
+ * @throws Exception
*/
- public function writeMeta(PHPWord $pPHPWord = null)
+ public function writeMeta(PHPWord $phpWord = null)
{
// Create XML writer
$xmlWriter = null;
@@ -65,25 +65,25 @@ class Meta extends WriterPart
$xmlWriter->startElement('office:meta');
// dc:creator
- $xmlWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
+ $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getLastModifiedBy());
// dc:date
- $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified()));
+ $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getModified()));
// dc:description
- $xmlWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
+ $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription());
// dc:subject
- $xmlWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
+ $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject());
// dc:title
- $xmlWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
+ $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle());
// meta:creation-date
- $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated()));
+ $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getCreated()));
// meta:initial-creator
- $xmlWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
+ $xmlWriter->writeElement('meta:initial-creator', $phpWord->getProperties()->getCreator());
// meta:keyword
- $xmlWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
+ $xmlWriter->writeElement('meta:keyword', $phpWord->getProperties()->getKeywords());
// @todo : Where these properties are written ?
- // $pPHPWord->getProperties()->getCategory()
- // $pPHPWord->getProperties()->getCompany()
+ // $phpWord->getProperties()->getCategory()
+ // $phpWord->getProperties()->getCompany()
$xmlWriter->endElement();
diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php
index 2c0f9a76..7f3d0e77 100755
--- a/Classes/PHPWord/Writer/ODText/Mimetype.php
+++ b/Classes/PHPWord/Writer/ODText/Mimetype.php
@@ -32,11 +32,11 @@ class Mimetype extends WriterPart
/**
* Write Mimetype to Text format
*
- * @param PHPWord $pPHPWord
- * @return string Text Output
- * @throws Exception
+ * @param PHPWord $phpWord
+ * @return string Text Output
+ * @throws Exception
*/
- public function writeMimetype(PHPWord $pPHPWord = null)
+ public function writeMimetype(PHPWord $phpWord = null)
{
return 'application/vnd.oasis.opendocument.text';
diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php
index 83ec054f..6c2fdb00 100755
--- a/Classes/PHPWord/Writer/ODText/Styles.php
+++ b/Classes/PHPWord/Writer/ODText/Styles.php
@@ -38,11 +38,11 @@ class Styles extends WriterPart
/**
* Write Styles file to XML format
*
- * @param PHPWord $pPHPWord
- * @return string XML Output
- * @throws Exception
+ * @param PHPWord $phpWord
+ * @return string XML Output
+ * @throws Exception
*/
- public function writeStyles(PHPWord $pPHPWord = null)
+ public function writeStyles(PHPWord $phpWord = null)
{
// Create XML writer
$xmlWriter = null;
diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php
index a090fb17..6b5e1fe7 100755
--- a/Classes/PHPWord/Writer/RTF.php
+++ b/Classes/PHPWord/Writer/RTF.php
@@ -25,10 +25,27 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_RTF
- */
-class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
+namespace PhpOffice\PhpWord\Writer;
+
+use PhpOffice\PhpWord\HashTable;
+use PhpOffice\PhpWord\Section\Image;
+use PhpOffice\PhpWord\Section\Link;
+use PhpOffice\PhpWord\Section\ListItem;
+use PhpOffice\PhpWord\Section\MemoryImage;
+use PhpOffice\PhpWord\Section\Object;
+use PhpOffice\PhpWord\Section\PageBreak;
+use PhpOffice\PhpWord\Section\Table;
+use PhpOffice\PhpWord\Section\Text;
+use PhpOffice\PhpWord\Section\TextBreak;
+use PhpOffice\PhpWord\Section\TextRun;
+use PhpOffice\PhpWord\Section\Title;
+use PhpOffice\PhpWord\Shared\Drawing;
+use PhpOffice\PhpWord\Style;
+use PhpOffice\PhpWord\Style\Font;
+use PhpOffice\PhpWord\Style\Paragraph;
+use PhpOffice\PhpWord\TOC;
+
+class RTF implements IWriter
{
/**
* Private PHPWord
@@ -40,7 +57,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
/**
* Private unique PHPWord_Worksheet_BaseDrawing HashTable
*
- * @var PHPWord_HashTable
+ * @var PhpOffice\PhpWord\HashTable
*/
private $_drawingHashTable;
@@ -49,17 +66,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
private $_lastParagraphStyle;
/**
- * Create a new PHPWord_Writer_ODText
- *
- * @param PHPWord $pPHPWord
+ * @param PHPWord $phpWord
*/
- public function __construct(PHPWord $pPHPWord = null)
+ public function __construct(PHPWord $phpWord = null)
{
// Assign PHPWord
- $this->setPHPWord($pPHPWord);
+ $this->setPHPWord($phpWord);
// Set HashTable variables
- $this->_drawingHashTable = new PHPWord_HashTable();
+ $this->_drawingHashTable = new HashTable();
}
/**
@@ -113,22 +128,20 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
}
/**
- * Get PHPWord object
- *
- * @param PHPWord $pPHPWord PHPWord object
- * @throws Exception
- * @return PHPWord_Writer_RTF
+ * @param PHPWord $phpWord PHPWord object
+ * @throws Exception
+ * @return PhpOffice\PhpWord\Writer\RTF
*/
- public function setPHPWord(PHPWord $pPHPWord = null)
+ public function setPHPWord(PHPWord $phpWord = null)
{
- $this->_document = $pPHPWord;
+ $this->_document = $phpWord;
return $this;
}
/**
* Get PHPWord_Worksheet_BaseDrawing HashTable
*
- * @return PHPWord_HashTable
+ * @return PhpOffice\PhpWord\HashTable
*/
public function getDrawingHashTable()
{
@@ -158,7 +171,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
// Set the color tbl group
$sRTFContent .= '{\colortbl ';
foreach ($this->_colorTable as $idx => $color) {
- $arrColor = PHPWord_Shared_Drawing::htmlToRGB($color);
+ $arrColor = Drawing::htmlToRGB($color);
$sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . '';
}
$sRTFContent .= ';}' . PHP_EOL;
@@ -190,7 +203,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
private function getDataFont()
{
- $pPHPWord = $this->_document;
+ $phpWord = $this->_document;
$arrFonts = array();
// Default font : PHPWord::DEFAULT_FONT_NAME
@@ -198,12 +211,12 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
// PHPWord object : $this->_document
// Browse styles
- $styles = PHPWord_Style::getStyles();
+ $styles = Style::getStyles();
$numPStyles = 0;
if (count($styles) > 0) {
foreach ($styles as $styleName => $style) {
- // PHPWord_Style_Font
- if ($style instanceof PHPWord_Style_Font) {
+ // PhpOffice\PhpWord\Style\Font
+ if ($style instanceof Font) {
if (in_array($style->getName(), $arrFonts) == false) {
$arrFonts[] = $style->getName();
}
@@ -212,7 +225,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
}
// Search all fonts used
- $_sections = $pPHPWord->getSections();
+ $_sections = $phpWord->getSections();
$countSections = count($_sections);
if ($countSections > 0) {
$pSection = 0;
@@ -222,10 +235,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
$_elements = $section->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
+ if ($element instanceof Text) {
$fStyle = $element->getFontStyle();
- if ($fStyle instanceof PHPWord_Style_Font) {
+ if ($fStyle instanceof Font) {
if (in_array($fStyle->getName(), $arrFonts) == false) {
$arrFonts[] = $fStyle->getName();
}
@@ -240,18 +253,18 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
private function getDataColor()
{
- $pPHPWord = $this->_document;
+ $phpWord = $this->_document;
$arrColors = array();
// PHPWord object : $this->_document
// Browse styles
- $styles = PHPWord_Style::getStyles();
+ $styles = Style::getStyles();
$numPStyles = 0;
if (count($styles) > 0) {
foreach ($styles as $styleName => $style) {
- // PHPWord_Style_Font
- if ($style instanceof PHPWord_Style_Font) {
+ // Font
+ if ($style instanceof Font) {
$color = $style->getColor();
$fgcolor = $style->getFgColor();
if (in_array($color, $arrColors) == false && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) {
@@ -265,7 +278,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
}
// Search all fonts used
- $_sections = $pPHPWord->getSections();
+ $_sections = $phpWord->getSections();
$countSections = count($_sections);
if ($countSections > 0) {
$pSection = 0;
@@ -275,10 +288,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
$_elements = $section->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
+ if ($element instanceof Text) {
$fStyle = $element->getFontStyle();
- if ($fStyle instanceof PHPWord_Style_Font) {
+ if ($fStyle instanceof Font) {
if (in_array($fStyle->getColor(), $arrColors) == false) {
$arrColors[] = $fStyle->getColor();
}
@@ -296,10 +309,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
private function getDataContent()
{
- $pPHPWord = $this->_document;
+ $phpWord = $this->_document;
$sRTFBody = '';
- $_sections = $pPHPWord->getSections();
+ $_sections = $phpWord->getSections();
$countSections = count($_sections);
$pSection = 0;
@@ -308,28 +321,28 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
$pSection++;
$_elements = $section->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
+ if ($element instanceof Text) {
$sRTFBody .= $this->getDataContentText($element);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
+ } elseif ($element instanceof TextBreak) {
$sRTFBody .= $this->getDataContentTextBreak();
- } elseif ($element instanceof PHPWord_Section_TextRun) {
+ } elseif ($element instanceof TextRun) {
$sRTFBody .= $this->getDataContentTextRun($element);
- } elseif ($element instanceof PHPWord_Section_Link) {
+ } elseif ($element instanceof Link) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Link');
- } elseif ($element instanceof PHPWord_Section_Title) {
+ } elseif ($element instanceof Title) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Title');
- } elseif ($element instanceof PHPWord_Section_PageBreak) {
+ } elseif ($element instanceof PageBreak) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Page Break');
- } elseif ($element instanceof PHPWord_Section_Table) {
+ } elseif ($element instanceof Table) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Table');
- } elseif ($element instanceof PHPWord_Section_ListItem) {
+ } elseif ($element instanceof ListItem) {
$sRTFBody .= $this->getDataContentUnsupportedElement('List Item');
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage) {
+ } elseif ($element instanceof Image ||
+ $element instanceof MemoryImage) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Image');
- } elseif ($element instanceof PHPWord_Section_Object) {
+ } elseif ($element instanceof Object) {
$sRTFBody .= $this->getDataContentUnsupportedElement('Object');
- } elseif ($element instanceof PHPWord_TOC) {
+ } elseif ($element instanceof TOC) {
$sRTFBody .= $this->getDataContentUnsupportedElement('TOC');
} else {
$sRTFBody .= $this->getDataContentUnsupportedElement('Other');
@@ -343,20 +356,20 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
/**
* Get text
*/
- private function getDataContentText(PHPWord_Section_Text $text, $withoutP = false)
+ private function getDataContentText(Text $text, $withoutP = false)
{
$sRTFText = '';
$styleFont = $text->getFontStyle();
- $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
+ $SfIsObject = ($styleFont instanceof Font) ? true : false;
if (!$SfIsObject) {
- $styleFont = PHPWord_Style::getStyle($styleFont);
+ $styleFont = Style::getStyle($styleFont);
}
$styleParagraph = $text->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
if (!$SpIsObject) {
- $styleParagraph = PHPWord_Style::getStyle($styleParagraph);
+ $styleParagraph = Style::getStyle($styleParagraph);
}
if ($styleParagraph && !$withoutP) {
@@ -378,7 +391,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
$this->_lastParagraphStyle = '';
}
- if ($styleFont instanceof PHPWord_Style_Font) {
+ if ($styleFont instanceof Font) {
if ($styleFont->getColor() != null) {
$idxColor = array_search($styleFont->getColor(), $this->_colorTable);
if ($idxColor !== false) {
@@ -410,7 +423,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
}
$sRTFText .= $text->getText();
- if ($styleFont instanceof PHPWord_Style_Font) {
+ if ($styleFont instanceof Font) {
$sRTFText .= '\cf0';
$sRTFText .= '\f0';
@@ -434,14 +447,14 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
/**
* Get text run content
*/
- private function getDataContentTextRun(PHPWord_Section_TextRun $textrun)
+ private function getDataContentTextRun(TextRun $textrun)
{
$sRTFText = '';
$elements = $textrun->getElements();
if (count($elements) > 0) {
$sRTFText .= '\pard\nowidctlpar' . PHP_EOL;
foreach ($elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
+ if ($element instanceof Text) {
$sRTFText .= '{';
$sRTFText .= $this->getDataContentText($element, true);
$sRTFText .= '}' . PHP_EOL;
diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php
index e62341bf..0aa8e057 100755
--- a/Classes/PHPWord/Writer/Word2007.php
+++ b/Classes/PHPWord/Writer/Word2007.php
@@ -25,15 +25,23 @@
* @version 0.8.0
*/
-use PhpOffice\PhpWord\Exceptions\InvalidImageException;
-use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
+namespace PhpOffice\PhpWord\Writer;
-/**
- * Class PHPWord_Writer_Word2007
- */
-class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
+use PhpOffice\PhpWord\Footnote;
+use PhpOffice\PhpWord\Media;
+use PhpOffice\PhpWord\Writer\Word2007\ContentTypes;
+use PhpOffice\PhpWord\Writer\Word2007\DocProps;
+use PhpOffice\PhpWord\Writer\Word2007\Document;
+use PhpOffice\PhpWord\Writer\Word2007\DocumentRels;
+use PhpOffice\PhpWord\Writer\Word2007\Footer;
+use PhpOffice\PhpWord\Writer\Word2007\Footnotes;
+use PhpOffice\PhpWord\Writer\Word2007\FootnotesRels;
+use PhpOffice\PhpWord\Writer\Word2007\Header;
+use PhpOffice\PhpWord\Writer\Word2007\Rels;
+use PhpOffice\PhpWord\Writer\Word2007\Styles;
+
+class Word2007 implements IWriter
{
-
private $_document;
private $_writerParts;
private $_diskCachingDirectory;
@@ -47,16 +55,16 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
$this->_diskCachingDirectory = './';
- $this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes();
- $this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels();
- $this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps();
- $this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels();
- $this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document();
- $this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles();
- $this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
- $this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
- $this->_writerParts['footnotes'] = new PHPWord_Writer_Word2007_Footnotes();
- $this->_writerParts['footnotesrels'] = new PHPWord_Writer_Word2007_FootnotesRels();
+ $this->_writerParts['contenttypes'] = new ContentTypes();
+ $this->_writerParts['rels'] = new Rels();
+ $this->_writerParts['docprops'] = new DocProps();
+ $this->_writerParts['documentrels'] = new DocumentRels();
+ $this->_writerParts['document'] = new Document();
+ $this->_writerParts['styles'] = new Styles();
+ $this->_writerParts['header'] = new Header();
+ $this->_writerParts['footer'] = new Footer();
+ $this->_writerParts['footnotes'] = new Footnotes();
+ $this->_writerParts['footnotesrels'] = new FootnotesRels();
foreach ($this->_writerParts as $writer) {
$writer->setParentWriter($this);
@@ -88,7 +96,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
$sectionElements = array();
- $_secElements = PHPWord_Media::getSectionMediaElements();
+ $_secElements = Media::getSectionMediaElements();
foreach ($_secElements as $element) { // loop through section media elements
if ($element['type'] != 'hyperlink') {
$this->_addFileToPackage($objZip, $element);
@@ -96,7 +104,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
$sectionElements[] = $element;
}
- $_hdrElements = PHPWord_Media::getHeaderMediaElements();
+ $_hdrElements = Media::getHeaderMediaElements();
foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers
if (count($_hdrMedia) > 0) {
$objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia));
@@ -106,7 +114,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
}
}
- $_ftrElements = PHPWord_Media::getFooterMediaElements();
+ $_ftrElements = Media::getFooterMediaElements();
foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers
if (count($_ftrMedia) > 0) {
$objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia));
@@ -117,7 +125,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
}
$footnoteLinks = array();
- $_footnoteElements = PHPWord_Footnote::getFootnoteLinkElements();
+ $_footnoteElements = Footnote::getFootnoteLinkElements();
// loop through footnote link elements
foreach ($_footnoteElements as $element) {
$footnoteLinks[] = $element;
@@ -125,7 +133,7 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
$_cHdrs = 0;
$_cFtrs = 0;
- $rID = PHPWord_Media::countSectionMediaElements() + 6;
+ $rID = Media::countSectionMediaElements() + 6;
$_sections = $this->_document->getSections();
$footers = array();
@@ -150,8 +158,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
}
}
- if (PHPWord_Footnote::countFootnoteElements() > 0) {
- $_allFootnotesCollection = PHPWord_Footnote::getFootnoteElements();
+ if (Footnote::countFootnoteElements() > 0) {
+ $_allFootnotesCollection = Footnote::getFootnoteElements();
$_footnoteFile = 'footnotes.xml';
$sectionElements[] = array('target'=>$_footnoteFile, 'type'=>'footnotes', 'rID'=>++$rID);
$objZip->addFromString('word/'.$_footnoteFile, $this->getWriterPart('footnotes')->writeFootnotes($_allFootnotesCollection));
diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php
index e9249120..a02b0081 100755
--- a/Classes/PHPWord/Writer/Word2007/Base.php
+++ b/Classes/PHPWord/Writer/Word2007/Base.php
@@ -1,5 +1,4 @@
getFontStyle();
- $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
+ $SfIsObject = ($styleFont instanceof Font) ? true : false;
if (!$withoutP) {
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
$styleParagraph = $text->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
$strText = htmlspecialchars($text->getText());
- $strText = PHPWord_Shared_String::ControlCharacterPHP2OOXML($strText);
+ $strText = String::ControlCharacterPHP2OOXML($strText);
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
if ($SfIsObject) {
- $this->_writeTextStyle($objWriter, $styleFont);
+ $this->_writeTextStyle($xmlWriter, $styleFont);
} elseif (!$SfIsObject && !is_null($styleFont)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $styleFont);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rStyle');
+ $xmlWriter->writeAttribute('w:val', $styleFont);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:t');
- $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text
- $objWriter->writeRaw($strText);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:t');
+ $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text
+ $xmlWriter->writeRaw($strText);
+ $xmlWriter->endElement();
- $objWriter->endElement(); // w:r
+ $xmlWriter->endElement(); // w:r
if (!$withoutP) {
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
}
- /**
- * Write text run
- */
- protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun)
+ protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun)
{
$elements = $textrun->getElements();
$styleParagraph = $textrun->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
if (count($elements) > 0) {
foreach ($elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->_writeLink($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Image) {
- $this->_writeImage($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnoteReference($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $objWriter->writeElement('w:br');
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element, true);
+ } elseif ($element instanceof Link) {
+ $this->_writeLink($xmlWriter, $element, true);
+ } elseif ($element instanceof Image) {
+ $this->_writeImage($xmlWriter, $element, true);
+ } elseif ($element instanceof Footnote) {
+ $this->_writeFootnoteReference($xmlWriter, $element, true);
+ } elseif ($element instanceof TextBreak) {
+ $xmlWriter->writeElement('w:br');
}
}
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
/**
- * Write paragraph style
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Style_Paragraph $style
- * @param bool $withoutPPR
- * @return void
+ * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
+ * @param PhpOffice\PhpWord\Style\Paragraph $style
+ * @param bool $withoutPPR
+ * @return void
*/
protected function _writeParagraphStyle(
- PHPWord_Shared_XMLWriter $objWriter = null,
- PHPWord_Style_Paragraph $style,
+ XMLWriter $xmlWriter = null,
+ Paragraph $style,
$withoutPPR = false
) {
@@ -157,83 +164,80 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
!is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) ||
!is_null($keepLines) || !is_null($pageBreakBefore)) {
if (!$withoutPPR) {
- $objWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pPr');
}
// Alignment
if (!is_null($align)) {
- $objWriter->startElement('w:jc');
- $objWriter->writeAttribute('w:val', $align);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:jc');
+ $xmlWriter->writeAttribute('w:val', $align);
+ $xmlWriter->endElement();
}
// Indentation
if (!is_null($indent) || !is_null($hanging)) {
- $objWriter->startElement('w:ind');
- $objWriter->writeAttribute('w:firstLine', 0);
+ $xmlWriter->startElement('w:ind');
+ $xmlWriter->writeAttribute('w:firstLine', 0);
if (!is_null($indent)) {
- $objWriter->writeAttribute('w:left', $indent);
+ $xmlWriter->writeAttribute('w:left', $indent);
}
if (!is_null($hanging)) {
- $objWriter->writeAttribute('w:hanging', $hanging);
+ $xmlWriter->writeAttribute('w:hanging', $hanging);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
// Spacing
if (!is_null($spaceBefore) || !is_null($spaceAfter) ||
!is_null($spacing)) {
- $objWriter->startElement('w:spacing');
+ $xmlWriter->startElement('w:spacing');
if (!is_null($spaceBefore)) {
- $objWriter->writeAttribute('w:before', $spaceBefore);
+ $xmlWriter->writeAttribute('w:before', $spaceBefore);
}
if (!is_null($spaceAfter)) {
- $objWriter->writeAttribute('w:after', $spaceAfter);
+ $xmlWriter->writeAttribute('w:after', $spaceAfter);
}
if (!is_null($spacing)) {
- $objWriter->writeAttribute('w:line', $spacing);
- $objWriter->writeAttribute('w:lineRule', 'auto');
+ $xmlWriter->writeAttribute('w:line', $spacing);
+ $xmlWriter->writeAttribute('w:lineRule', 'auto');
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
// Pagination
if (!$widowControl) {
- $objWriter->startElement('w:widowControl');
- $objWriter->writeAttribute('w:val', '0');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:widowControl');
+ $xmlWriter->writeAttribute('w:val', '0');
+ $xmlWriter->endElement();
}
if ($keepNext) {
- $objWriter->startElement('w:keepNext');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:keepNext');
+ $xmlWriter->writeAttribute('w:val', '1');
+ $xmlWriter->endElement();
}
if ($keepLines) {
- $objWriter->startElement('w:keepLines');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:keepLines');
+ $xmlWriter->writeAttribute('w:val', '1');
+ $xmlWriter->endElement();
}
if ($pageBreakBefore) {
- $objWriter->startElement('w:pageBreakBefore');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pageBreakBefore');
+ $xmlWriter->writeAttribute('w:val', '1');
+ $xmlWriter->endElement();
}
// Tabs
if (!is_null($tabs)) {
- $tabs->toXml($objWriter);
+ $tabs->toXml($xmlWriter);
}
if (!$withoutPPR) {
- $objWriter->endElement(); // w:pPr
+ $xmlWriter->endElement(); // w:pPr
}
}
}
- /**
- * Write link
- */
- protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false)
+ protected function _writeLink(XMLWriter $xmlWriter = null, Link $link, $withoutP = false)
{
$rID = $link->getRelationId();
$linkName = $link->getLinkName();
@@ -242,79 +246,76 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
}
$styleFont = $link->getFontStyle();
- $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
+ $SfIsObject = ($styleFont instanceof Font) ? true : false;
if (!$withoutP) {
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
$styleParagraph = $link->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
- $objWriter->startElement('w:hyperlink');
- $objWriter->writeAttribute('r:id', 'rId' . $rID);
- $objWriter->writeAttribute('w:history', '1');
+ $xmlWriter->startElement('w:hyperlink');
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rID);
+ $xmlWriter->writeAttribute('w:history', '1');
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
if ($SfIsObject) {
- $this->_writeTextStyle($objWriter, $styleFont);
+ $this->_writeTextStyle($xmlWriter, $styleFont);
} elseif (!$SfIsObject && !is_null($styleFont)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $styleFont);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rStyle');
+ $xmlWriter->writeAttribute('w:val', $styleFont);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:t');
- $objWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text
- $objWriter->writeRaw($linkName);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:t');
+ $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text
+ $xmlWriter->writeRaw($linkName);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
if (!$withoutP) {
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
}
- /**
- * Write preserve text
- */
- protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun)
+ protected function _writePreserveText(XMLWriter $xmlWriter = null, PreserveText $textrun)
{
$styleFont = $textrun->getFontStyle();
$styleParagraph = $textrun->getParagraphStyle();
- $SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SfIsObject = ($styleFont instanceof Font) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
$arrText = $textrun->getText();
if (!is_array($arrText)) {
$arrText = array($arrText);
}
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
foreach ($arrText as $text) {
@@ -322,72 +323,69 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
if (substr($text, 0, 1) == '{') {
$text = substr($text, 1, -1);
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'begin');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'begin');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
if ($SfIsObject) {
- $this->_writeTextStyle($objWriter, $styleFont);
+ $this->_writeTextStyle($xmlWriter, $styleFont);
} elseif (!$SfIsObject && !is_null($styleFont)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $styleFont);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rStyle');
+ $xmlWriter->writeAttribute('w:val', $styleFont);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:instrText');
- $objWriter->writeAttribute('xml:space', 'preserve');
- $objWriter->writeRaw($text);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:instrText');
+ $xmlWriter->writeAttribute('xml:space', 'preserve');
+ $xmlWriter->writeRaw($text);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'separate');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'separate');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'end');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'end');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
} else {
$text = htmlspecialchars($text);
- $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
+ $text = String::ControlCharacterPHP2OOXML($text);
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
if ($SfIsObject) {
- $this->_writeTextStyle($objWriter, $styleFont);
+ $this->_writeTextStyle($xmlWriter, $styleFont);
} elseif (!$SfIsObject && !is_null($styleFont)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $styleFont);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rStyle');
+ $xmlWriter->writeAttribute('w:val', $styleFont);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:t');
- $objWriter->writeAttribute('xml:space', 'preserve');
- $objWriter->writeRaw($text);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:t');
+ $xmlWriter->writeAttribute('xml:space', 'preserve');
+ $xmlWriter->writeRaw($text);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
- $objWriter->endElement(); // p
+ $xmlWriter->endElement(); // p
}
- /**
- * Write text style
- */
- protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style)
+ protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style)
{
$font = $style->getName();
$bold = $style->getBold();
@@ -401,156 +399,151 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$subscript = $style->getSubScript();
$hint = $style->getHint();
- $objWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rPr');
// Font
if ($font != PHPWord::DEFAULT_FONT_NAME) {
- $objWriter->startElement('w:rFonts');
- $objWriter->writeAttribute('w:ascii', $font);
- $objWriter->writeAttribute('w:hAnsi', $font);
- $objWriter->writeAttribute('w:eastAsia', $font);
- $objWriter->writeAttribute('w:cs', $font);
+ $xmlWriter->startElement('w:rFonts');
+ $xmlWriter->writeAttribute('w:ascii', $font);
+ $xmlWriter->writeAttribute('w:hAnsi', $font);
+ $xmlWriter->writeAttribute('w:eastAsia', $font);
+ $xmlWriter->writeAttribute('w:cs', $font);
//Font Content Type
if ($hint != PHPWord::DEFAULT_FONT_CONTENT_TYPE) {
- $objWriter->writeAttribute('w:hint', $hint);
+ $xmlWriter->writeAttribute('w:hint', $hint);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
// Color
if ($color != PHPWord::DEFAULT_FONT_COLOR) {
- $objWriter->startElement('w:color');
- $objWriter->writeAttribute('w:val', $color);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:color');
+ $xmlWriter->writeAttribute('w:val', $color);
+ $xmlWriter->endElement();
}
// Size
if ($size != PHPWord::DEFAULT_FONT_SIZE) {
- $objWriter->startElement('w:sz');
- $objWriter->writeAttribute('w:val', $size * 2);
- $objWriter->endElement();
- $objWriter->startElement('w:szCs');
- $objWriter->writeAttribute('w:val', $size * 2);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:sz');
+ $xmlWriter->writeAttribute('w:val', $size * 2);
+ $xmlWriter->endElement();
+ $xmlWriter->startElement('w:szCs');
+ $xmlWriter->writeAttribute('w:val', $size * 2);
+ $xmlWriter->endElement();
}
// Bold
if ($bold) {
- $objWriter->writeElement('w:b', null);
+ $xmlWriter->writeElement('w:b', null);
}
// Italic
if ($italic) {
- $objWriter->writeElement('w:i', null);
- $objWriter->writeElement('w:iCs', null);
+ $xmlWriter->writeElement('w:i', null);
+ $xmlWriter->writeElement('w:iCs', null);
}
// Underline
if (!is_null($underline) && $underline != 'none') {
- $objWriter->startElement('w:u');
- $objWriter->writeAttribute('w:val', $underline);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:u');
+ $xmlWriter->writeAttribute('w:val', $underline);
+ $xmlWriter->endElement();
}
// Strikethrough
if ($strikethrough) {
- $objWriter->writeElement('w:strike', null);
+ $xmlWriter->writeElement('w:strike', null);
}
// Foreground-Color
if (!is_null($fgColor)) {
- $objWriter->startElement('w:highlight');
- $objWriter->writeAttribute('w:val', $fgColor);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:highlight');
+ $xmlWriter->writeAttribute('w:val', $fgColor);
+ $xmlWriter->endElement();
}
// Superscript/subscript
if ($superscript || $subscript) {
- $objWriter->startElement('w:vertAlign');
- $objWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:vertAlign');
+ $xmlWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript');
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
/**
- * Write text break
- *
- * @param PHPWord_Shared_XMLWriter $objWriter
- * @param PHPWord_Section_TextBreak $element
+ * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
+ * @param PhpOffice\PhpWord\Section\TextBreak $element
*/
- protected function _writeTextBreak($objWriter, $element = null)
+ protected function _writeTextBreak($xmlWriter, $element = null)
{
$hasStyle = false;
if (!is_null($element)) {
$fontStyle = $element->getFontStyle();
- $sfIsObject = ($fontStyle instanceof PHPWord_Style_Font) ? true : false;
+ $sfIsObject = ($fontStyle instanceof Font) ? true : false;
$paragraphStyle = $element->getParagraphStyle();
- $spIsObject = ($paragraphStyle instanceof PHPWord_Style_Paragraph) ? true : false;
+ $spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false;
$hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle);
}
if ($hasStyle) {
// Paragraph style
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if ($spIsObject) {
- $this->_writeParagraphStyle($objWriter, $paragraphStyle);
+ $this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
} elseif (!$spIsObject && !is_null($paragraphStyle)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $paragraphStyle);
- $objWriter->endElement(); // w:pStyle
- $objWriter->endElement(); // w:pPr
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $paragraphStyle);
+ $xmlWriter->endElement(); // w:pStyle
+ $xmlWriter->endElement(); // w:pPr
}
// Font style
if (!is_null($fontStyle)) {
- $objWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pPr');
if ($sfIsObject) {
- $this->_writeTextStyle($objWriter, $fontStyle);
+ $this->_writeTextStyle($xmlWriter, $fontStyle);
} elseif (!$sfIsObject && !is_null($fontStyle)) {
- $objWriter->startElement('w:rPr');
- $objWriter->startElement('w:rStyle');
- $objWriter->writeAttribute('w:val', $fontStyle);
- $objWriter->endElement(); // w:rStyle
- $objWriter->endElement(); // w:rPr
+ $xmlWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:rStyle');
+ $xmlWriter->writeAttribute('w:val', $fontStyle);
+ $xmlWriter->endElement(); // w:rStyle
+ $xmlWriter->endElement(); // w:rPr
}
- $objWriter->endElement(); // w:pPr
+ $xmlWriter->endElement(); // w:pPr
}
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
} else {
// Null element. No paragraph nor font style
- $objWriter->writeElement('w:p', null);
+ $xmlWriter->writeElement('w:p', null);
}
}
- /**
- * Write table
- */
- protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table)
+ protected function _writeTable(XMLWriter $xmlWriter = null, Table $table)
{
$_rows = $table->getRows();
$_cRows = count($_rows);
if ($_cRows > 0) {
- $objWriter->startElement('w:tbl');
+ $xmlWriter->startElement('w:tbl');
$tblStyle = $table->getStyle();
$tblWidth = $table->getWidth();
- if ($tblStyle instanceof PHPWord_Style_Table) {
- $this->_writeTableStyle($objWriter, $tblStyle);
+ if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) {
+ $this->_writeTableStyle($xmlWriter, $tblStyle);
} else {
if (!empty($tblStyle)) {
- $objWriter->startElement('w:tblPr');
- $objWriter->startElement('w:tblStyle');
- $objWriter->writeAttribute('w:val', $tblStyle);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:tblPr');
+ $xmlWriter->startElement('w:tblStyle');
+ $xmlWriter->writeAttribute('w:val', $tblStyle);
+ $xmlWriter->endElement();
if (!is_null($tblWidth)) {
- $objWriter->startElement('w:tblW');
- $objWriter->writeAttribute('w:w', $tblWidth);
- $objWriter->writeAttribute('w:type', 'pct');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:tblW');
+ $xmlWriter->writeAttribute('w:w', $tblWidth);
+ $xmlWriter->writeAttribute('w:type', 'pct');
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
}
@@ -561,86 +554,85 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$tblHeader = $rowStyle->getTblHeader();
$cantSplit = $rowStyle->getCantSplit();
- $objWriter->startElement('w:tr');
+ $xmlWriter->startElement('w:tr');
if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) {
- $objWriter->startElement('w:trPr');
+ $xmlWriter->startElement('w:trPr');
if (!is_null($height)) {
- $objWriter->startElement('w:trHeight');
- $objWriter->writeAttribute('w:val', $height);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:trHeight');
+ $xmlWriter->writeAttribute('w:val', $height);
+ $xmlWriter->endElement();
}
if ($tblHeader) {
- $objWriter->startElement('w:tblHeader');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:tblHeader');
+ $xmlWriter->writeAttribute('w:val', '1');
+ $xmlWriter->endElement();
}
if ($cantSplit) {
- $objWriter->startElement('w:cantSplit');
- $objWriter->writeAttribute('w:val', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:cantSplit');
+ $xmlWriter->writeAttribute('w:val', '1');
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
foreach ($row->getCells() as $cell) {
- $objWriter->startElement('w:tc');
+ $xmlWriter->startElement('w:tc');
$cellStyle = $cell->getStyle();
$width = $cell->getWidth();
- $objWriter->startElement('w:tcPr');
- $objWriter->startElement('w:tcW');
- $objWriter->writeAttribute('w:w', $width);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:tcPr');
+ $xmlWriter->startElement('w:tcW');
+ $xmlWriter->writeAttribute('w:w', $width);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
- if ($cellStyle instanceof PHPWord_Style_Cell) {
- $this->_writeCellStyle($objWriter, $cellStyle);
+ if ($cellStyle instanceof Cell) {
+ $this->_writeCellStyle($xmlWriter, $cellStyle);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
$_elements = $cell->getElements();
if (count($_elements) > 0) {
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextRun) {
- $this->_writeTextRun($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->_writeLink($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $this->_writeTextBreak($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_ListItem) {
- $this->_writeListItem($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element);
+ } elseif ($element instanceof TextRun) {
+ $this->_writeTextRun($xmlWriter, $element);
+ } elseif ($element instanceof Link) {
+ $this->_writeLink($xmlWriter, $element);
+ } elseif ($element instanceof TextBreak) {
+ $this->_writeTextBreak($xmlWriter, $element);
+ } elseif ($element instanceof ListItem) {
+ $this->_writeListItem($xmlWriter, $element);
+ } elseif ($element instanceof Image ||
+ $element instanceof MemoryImage
) {
- $this->_writeImage($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Object) {
- $this->_writeObject($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
- $this->_writePreserveText($objWriter, $element);
+ $this->_writeImage($xmlWriter, $element);
+ } elseif ($element instanceof Object) {
+ $this->_writeObject($xmlWriter, $element);
+ } elseif ($element instanceof PreserveText) {
+ $this->_writePreserveText($xmlWriter, $element);
}
}
} else {
- $this->_writeTextBreak($objWriter);
+ $this->_writeTextBreak($xmlWriter);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
}
- /**
- * Write table style
- */
- protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null)
- {
+ protected function _writeTableStyle(
+ XMLWriter $xmlWriter = null,
+ PhpOffice\PhpWord\Style\Table $style = null
+ ) {
$margins = $style->getCellMargin();
$mTop = (!is_null($margins[0])) ? true : false;
$mLeft = (!is_null($margins[1])) ? true : false;
@@ -648,46 +640,43 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$mBottom = (!is_null($margins[3])) ? true : false;
if ($mTop || $mLeft || $mRight || $mBottom) {
- $objWriter->startElement('w:tblPr');
- $objWriter->startElement('w:tblCellMar');
+ $xmlWriter->startElement('w:tblPr');
+ $xmlWriter->startElement('w:tblCellMar');
if ($mTop) {
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:w', $margins[0]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:w', $margins[0]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mLeft) {
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:w', $margins[1]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:w', $margins[1]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mRight) {
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:w', $margins[2]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:w', $margins[2]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mBottom) {
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:w', $margins[3]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:w', $margins[3]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
- /**
- * Write cell style
- */
- protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null)
+ protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = null)
{
$bgColor = $style->getBgColor();
$valign = $style->getVAlign();
@@ -705,96 +694,96 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
if ($styles) {
if (!is_null($textDir)) {
- $objWriter->startElement('w:textDirection');
- $objWriter->writeAttribute('w:val', $textDir);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:textDirection');
+ $xmlWriter->writeAttribute('w:val', $textDir);
+ $xmlWriter->endElement();
}
if (!is_null($bgColor)) {
- $objWriter->startElement('w:shd');
- $objWriter->writeAttribute('w:val', 'clear');
- $objWriter->writeAttribute('w:color', 'auto');
- $objWriter->writeAttribute('w:fill', $bgColor);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:shd');
+ $xmlWriter->writeAttribute('w:val', 'clear');
+ $xmlWriter->writeAttribute('w:color', 'auto');
+ $xmlWriter->writeAttribute('w:fill', $bgColor);
+ $xmlWriter->endElement();
}
if (!is_null($valign)) {
- $objWriter->startElement('w:vAlign');
- $objWriter->writeAttribute('w:val', $valign);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:vAlign');
+ $xmlWriter->writeAttribute('w:val', $valign);
+ $xmlWriter->endElement();
}
if ($borders) {
$_defaultColor = $style->getDefaultBorderColor();
- $objWriter->startElement('w:tcBorders');
+ $xmlWriter->startElement('w:tcBorders');
if ($bTop) {
if (is_null($brdCol[0])) {
$brdCol[0] = $_defaultColor;
}
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[0]);
- $objWriter->writeAttribute('w:color', $brdCol[0]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[0]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[0]);
+ $xmlWriter->endElement();
}
if ($bLeft) {
if (is_null($brdCol[1])) {
$brdCol[1] = $_defaultColor;
}
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[1]);
- $objWriter->writeAttribute('w:color', $brdCol[1]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[1]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[1]);
+ $xmlWriter->endElement();
}
if ($bRight) {
if (is_null($brdCol[2])) {
$brdCol[2] = $_defaultColor;
}
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[2]);
- $objWriter->writeAttribute('w:color', $brdCol[2]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[2]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[2]);
+ $xmlWriter->endElement();
}
if ($bBottom) {
if (is_null($brdCol[3])) {
$brdCol[3] = $_defaultColor;
}
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[3]);
- $objWriter->writeAttribute('w:color', $brdCol[3]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[3]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[3]);
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
}
$gridSpan = $style->getGridSpan();
if (!is_null($gridSpan)) {
- $objWriter->startElement('w:gridSpan');
- $objWriter->writeAttribute('w:val', $gridSpan);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:gridSpan');
+ $xmlWriter->writeAttribute('w:val', $gridSpan);
+ $xmlWriter->endElement();
}
$vMerge = $style->getVMerge();
if (!is_null($vMerge)) {
- $objWriter->startElement('w:vMerge');
- $objWriter->writeAttribute('w:val', $vMerge);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:vMerge');
+ $xmlWriter->writeAttribute('w:val', $vMerge);
+ $xmlWriter->endElement();
}
}
/**
- * @param \PHPWord_Shared_XMLWriter $objWriter
- * @param \PHPWord_Section_Image|\PHPWord_Section_MemoryImage $image
+ * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
+ * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image
*/
- protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image, $withoutP = false)
+ protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false)
{
$rId = $image->getRelationId();
@@ -807,23 +796,23 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$wrappingStyle = $style->getWrappingStyle();
if (!$withoutP) {
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if (!is_null($align)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:jc');
- $objWriter->writeAttribute('w:val', $align);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:jc');
+ $xmlWriter->writeAttribute('w:val', $align);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
- $objWriter->startElement('w:pict');
+ $xmlWriter->startElement('w:pict');
- $objWriter->startElement('v:shape');
- $objWriter->writeAttribute('type', '#_x0000_t75');
+ $xmlWriter->startElement('v:shape');
+ $xmlWriter->writeAttribute('type', '#_x0000_t75');
$imgStyle = '';
if (null !== $width) {
@@ -840,41 +829,38 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
}
switch ($wrappingStyle) {
- case PHPWord_Style_Image::WRAPPING_STYLE_BEHIND:
+ case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND:
$imgStyle .= 'position:absolute;z-index:-251658752;';
break;
- case PHPWord_Style_Image::WRAPPING_STYLE_SQUARE:
+ case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE:
$imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;';
break;
- case PHPWord_Style_Image::WRAPPING_STYLE_TIGHT:
+ case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT:
$imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute';
break;
- case PHPWord_Style_Image::WRAPPING_STYLE_INFRONT:
+ case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT:
$imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;';
break;
}
- $objWriter->writeAttribute('style', $imgStyle);
+ $xmlWriter->writeAttribute('style', $imgStyle);
- $objWriter->startElement('v:imagedata');
- $objWriter->writeAttribute('r:id', 'rId' . $rId);
- $objWriter->writeAttribute('o:title', '');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('v:imagedata');
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
+ $xmlWriter->writeAttribute('o:title', '');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
if (!$withoutP) {
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
}
- /**
- * Write watermark
- */
- protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image)
+ protected function _writeWatermark(XMLWriter $xmlWriter = null, $image)
{
$rId = $image->getRelationId();
@@ -884,14 +870,14 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$marginLeft = $style->getMarginLeft();
$marginTop = $style->getMarginTop();
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
- $objWriter->startElement('w:pict');
+ $xmlWriter->startElement('w:pict');
- $objWriter->startElement('v:shape');
- $objWriter->writeAttribute('type', '#_x0000_t75');
+ $xmlWriter->startElement('v:shape');
+ $xmlWriter->writeAttribute('type', '#_x0000_t75');
$strStyle = 'position:absolute;';
$strStyle .= ' width:' . $width . 'px;';
@@ -903,123 +889,114 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$strStyle .= ' margin-left:' . $marginLeft . 'px;';
}
- $objWriter->writeAttribute('style', $strStyle);
+ $xmlWriter->writeAttribute('style', $strStyle);
- $objWriter->startElement('v:imagedata');
- $objWriter->writeAttribute('r:id', 'rId' . $rId);
- $objWriter->writeAttribute('o:title', '');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('v:imagedata');
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
+ $xmlWriter->writeAttribute('o:title', '');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- /**
- * Write title
- */
- protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title)
+ protected function _writeTitle(XMLWriter $xmlWriter = null, Title $title)
{
$text = htmlspecialchars($title->getText());
- $text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
+ $text = String::ControlCharacterPHP2OOXML($text);
$anchor = $title->getAnchor();
$bookmarkId = $title->getBookmarkId();
$style = $title->getStyle();
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if (!empty($style)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $style);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $style);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'end');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'end');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:bookmarkStart');
- $objWriter->writeAttribute('w:id', $bookmarkId);
- $objWriter->writeAttribute('w:name', $anchor);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bookmarkStart');
+ $xmlWriter->writeAttribute('w:id', $bookmarkId);
+ $xmlWriter->writeAttribute('w:name', $anchor);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:t');
- $objWriter->writeRaw($text);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:t');
+ $xmlWriter->writeRaw($text);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:bookmarkEnd');
- $objWriter->writeAttribute('w:id', $bookmarkId);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bookmarkEnd');
+ $xmlWriter->writeAttribute('w:id', $bookmarkId);
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- /**
- * Write footnote
- */
- protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote)
+ protected function _writeFootnote(XMLWriter $xmlWriter = null, Footnote $footnote)
{
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', $footnote->getReferenceId());
+ $xmlWriter->startElement('w:footnote');
+ $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId());
$styleParagraph = $footnote->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
$elements = $footnote->getElements();
if (count($elements) > 0) {
foreach ($elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element, true);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->_writeLink($objWriter, $element, true);
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element, true);
+ } elseif ($element instanceof Link) {
+ $this->_writeLink($xmlWriter, $element, true);
}
}
}
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
+ $xmlWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:footnote
}
- /**
- * Write footnote reference
- */
- protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false)
+ protected function _writeFootnoteReference(XMLWriter $xmlWriter = null, Footnote $footnote, $withoutP = false)
{
if (!$withoutP) {
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
}
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
- $objWriter->startElement('w:footnoteReference');
- $objWriter->writeAttribute('w:id', $footnote->getReferenceId());
- $objWriter->endElement(); // w:footnoteReference
+ $xmlWriter->startElement('w:footnoteReference');
+ $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId());
+ $xmlWriter->endElement(); // w:footnoteReference
- $objWriter->endElement(); // w:r
+ $xmlWriter->endElement(); // w:r
if (!$withoutP) {
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php
index 8a6e39ef..27d3cefa 100755
--- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php
+++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php
@@ -25,52 +25,53 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_ContentTypes
- */
-class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
+use PhpOffice\PhpWord\Shared\File;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class ContentTypes extends WriterPart
+{
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Types
- $objWriter->startElement('Types');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
+ $xmlWriter->startElement('Types');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
// Rels
$this->_writeDefaultContentType(
- $objWriter,
+ $xmlWriter,
'rels',
'application/vnd.openxmlformats-package.relationships+xml'
);
// XML
$this->_writeDefaultContentType(
- $objWriter,
+ $xmlWriter,
'xml',
'application/xml'
);
// Add media content-types
foreach ($_imageTypes as $key => $value) {
- $this->_writeDefaultContentType($objWriter, $key, $value);
+ $this->_writeDefaultContentType($xmlWriter, $key, $value);
}
// Add embedding content-types
if (count($_objectTypes) > 0) {
$this->_writeDefaultContentType(
- $objWriter,
+ $xmlWriter,
'bin',
'application/vnd.openxmlformats-officedocument.oleObject'
);
@@ -78,76 +79,76 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
// DocProps
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/docProps/app.xml',
'application/vnd.openxmlformats-officedocument.extended-properties+xml'
);
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/docProps/core.xml',
'application/vnd.openxmlformats-package.core-properties+xml'
);
// Document
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/document.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
);
// Styles
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/styles.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
);
// Numbering
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/numbering.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
);
// Settings
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/settings.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
);
// Theme1
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/theme/theme1.xml',
'application/vnd.openxmlformats-officedocument.theme+xml'
);
// WebSettings
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/webSettings.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
);
// Font Table
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/fontTable.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
);
// Footnotes
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/footnotes.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml'
);
for ($i = 1; $i <= $_cHdrs; $i++) {
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/header' . $i . '.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
);
@@ -156,7 +157,7 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
for ($i = 1; $i <= count($footers); $i++) {
if (!is_null($footers[$i])) {
$this->_writeOverrideContentType(
- $objWriter,
+ $xmlWriter,
'/word/footer' . $i . '.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
);
@@ -164,10 +165,10 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
/**
@@ -179,7 +180,7 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
*/
private function _getImageMimeType($pFile = '')
{
- if (PHPWord_Shared_File::file_exists($pFile)) {
+ if (File::file_exists($pFile)) {
$image = getimagesize($pFile);
return image_type_to_mime_type($image[2]);
} else {
@@ -188,42 +189,38 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
}
/**
- * Write Default content type
- *
- * @param PHPWord_Shared_XMLWriter $objWriter XML Writer
- * @param string $pPartname Part name
- * @param string $pContentType Content type
- * @throws Exception
+ * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
+ * @param string $pPartname Part name
+ * @param string $pContentType Content type
+ * @throws Exception
*/
- private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
+ private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
{
if ($pPartname != '' && $pContentType != '') {
// Write content type
- $objWriter->startElement('Default');
- $objWriter->writeAttribute('Extension', $pPartname);
- $objWriter->writeAttribute('ContentType', $pContentType);
- $objWriter->endElement();
+ $xmlWriter->startElement('Default');
+ $xmlWriter->writeAttribute('Extension', $pPartname);
+ $xmlWriter->writeAttribute('ContentType', $pContentType);
+ $xmlWriter->endElement();
} else {
throw new Exception("Invalid parameters passed.");
}
}
/**
- * Write Override content type
- *
- * @param PHPWord_Shared_XMLWriter $objWriter XML Writer
- * @param string $pPartname Part name
- * @param string $pContentType Content type
- * @throws Exception
+ * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
+ * @param string $pPartname Part name
+ * @param string $pContentType Content type
+ * @throws Exception
*/
- private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
+ private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '')
{
if ($pPartname != '' && $pContentType != '') {
// Write content type
- $objWriter->startElement('Override');
- $objWriter->writeAttribute('PartName', $pPartname);
- $objWriter->writeAttribute('ContentType', $pContentType);
- $objWriter->endElement();
+ $xmlWriter->startElement('Override');
+ $xmlWriter->writeAttribute('PartName', $pPartname);
+ $xmlWriter->writeAttribute('ContentType', $pContentType);
+ $xmlWriter->endElement();
} else {
throw new Exception("Invalid parameters passed.");
}
diff --git a/Classes/PHPWord/Writer/Word2007/DocProps.php b/Classes/PHPWord/Writer/Word2007/DocProps.php
index 2e8f8b5a..05c2b869 100755
--- a/Classes/PHPWord/Writer/Word2007/DocProps.php
+++ b/Classes/PHPWord/Writer/Word2007/DocProps.php
@@ -25,161 +25,161 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_DocProps
- */
-class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
- public function writeDocPropsApp(PHPWord $pPHPWord = null)
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class DocProps extends WriterPart
+{
+ public function writeDocPropsApp(PHPWord $phpWord = null)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Properties
- $objWriter->startElement('Properties');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
- $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
+ $xmlWriter->startElement('Properties');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
+ $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
// Application
- $objWriter->writeElement('Application', 'Microsoft Office Word');
+ $xmlWriter->writeElement('Application', 'Microsoft Office Word');
// ScaleCrop
- $objWriter->writeElement('ScaleCrop', 'false');
+ $xmlWriter->writeElement('ScaleCrop', 'false');
// HeadingPairs
- $objWriter->startElement('HeadingPairs');
+ $xmlWriter->startElement('HeadingPairs');
// Vector
- $objWriter->startElement('vt:vector');
- $objWriter->writeAttribute('size', '4');
- $objWriter->writeAttribute('baseType', 'variant');
+ $xmlWriter->startElement('vt:vector');
+ $xmlWriter->writeAttribute('size', '4');
+ $xmlWriter->writeAttribute('baseType', 'variant');
// Variant
- $objWriter->startElement('vt:variant');
- $objWriter->writeElement('vt:lpstr', 'Theme');
- $objWriter->endElement();
+ $xmlWriter->startElement('vt:variant');
+ $xmlWriter->writeElement('vt:lpstr', 'Theme');
+ $xmlWriter->endElement();
// Variant
- $objWriter->startElement('vt:variant');
- $objWriter->writeElement('vt:i4', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('vt:variant');
+ $xmlWriter->writeElement('vt:i4', '1');
+ $xmlWriter->endElement();
// Variant
- $objWriter->startElement('vt:variant');
- $objWriter->writeElement('vt:lpstr', 'Slide Titles');
- $objWriter->endElement();
+ $xmlWriter->startElement('vt:variant');
+ $xmlWriter->writeElement('vt:lpstr', 'Slide Titles');
+ $xmlWriter->endElement();
// Variant
- $objWriter->startElement('vt:variant');
- $objWriter->writeElement('vt:i4', '1');
- $objWriter->endElement();
+ $xmlWriter->startElement('vt:variant');
+ $xmlWriter->writeElement('vt:i4', '1');
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
// TitlesOfParts
- $objWriter->startElement('TitlesOfParts');
+ $xmlWriter->startElement('TitlesOfParts');
// Vector
- $objWriter->startElement('vt:vector');
- $objWriter->writeAttribute('size', '1');
- $objWriter->writeAttribute('baseType', 'lpstr');
+ $xmlWriter->startElement('vt:vector');
+ $xmlWriter->writeAttribute('size', '1');
+ $xmlWriter->writeAttribute('baseType', 'lpstr');
- $objWriter->writeElement('vt:lpstr', 'Office Theme');
+ $xmlWriter->writeElement('vt:lpstr', 'Office Theme');
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Company
- $objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany());
+ $xmlWriter->writeElement('Company', $phpWord->getProperties()->getCompany());
// LinksUpToDate
- $objWriter->writeElement('LinksUpToDate', 'false');
+ $xmlWriter->writeElement('LinksUpToDate', 'false');
// SharedDoc
- $objWriter->writeElement('SharedDoc', 'false');
+ $xmlWriter->writeElement('SharedDoc', 'false');
// HyperlinksChanged
- $objWriter->writeElement('HyperlinksChanged', 'false');
+ $xmlWriter->writeElement('HyperlinksChanged', 'false');
// AppVersion
- $objWriter->writeElement('AppVersion', '12.0000');
+ $xmlWriter->writeElement('AppVersion', '12.0000');
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
- public function writeDocPropsCore(PHPWord $pPHPWord = null)
+ public function writeDocPropsCore(PHPWord $phpWord = null)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties
- $objWriter->startElement('cp:coreProperties');
- $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
- $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
- $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
- $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
- $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
+ $xmlWriter->startElement('cp:coreProperties');
+ $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
+ $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
+ $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
+ $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
+ $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
// dc:creator
- $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator());
+ $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getCreator());
// cp:lastModifiedBy
- $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy());
+ $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getProperties()->getLastModifiedBy());
// dcterms:created
- $objWriter->startElement('dcterms:created');
- $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated()));
- $objWriter->endElement();
+ $xmlWriter->startElement('dcterms:created');
+ $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
+ $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getCreated()));
+ $xmlWriter->endElement();
// dcterms:modified
- $objWriter->startElement('dcterms:modified');
- $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified()));
- $objWriter->endElement();
+ $xmlWriter->startElement('dcterms:modified');
+ $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
+ $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getModified()));
+ $xmlWriter->endElement();
// dc:title
- $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
+ $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle());
// dc:description
- $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
+ $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription());
// dc:subject
- $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
+ $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject());
// cp:keywords
- $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords());
+ $xmlWriter->writeElement('cp:keywords', $phpWord->getProperties()->getKeywords());
// cp:category
- $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory());
+ $xmlWriter->writeElement('cp:category', $phpWord->getProperties()->getCategory());
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php
index abdd92cc..691e723e 100755
--- a/Classes/PHPWord/Writer/Word2007/Document.php
+++ b/Classes/PHPWord/Writer/Word2007/Document.php
@@ -25,41 +25,55 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_Document
- */
-class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
- public function writeDocument(PHPWord $pPHPWord = null)
+use PhpOffice\PhpWord\Section\Footnote;
+use PhpOffice\PhpWord\Section\Image;
+use PhpOffice\PhpWord\Section\Link;
+use PhpOffice\PhpWord\Section\ListItem;
+use PhpOffice\PhpWord\Section\MemoryImage;
+use PhpOffice\PhpWord\Section\Object;
+use PhpOffice\PhpWord\Section\PageBreak;
+use PhpOffice\PhpWord\Section\Table;
+use PhpOffice\PhpWord\Section\Text;
+use PhpOffice\PhpWord\Section\TextBreak;
+use PhpOffice\PhpWord\Section\TextRun;
+use PhpOffice\PhpWord\Section\Title;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+use PhpOffice\PhpWord\Style\Font;
+use PhpOffice\PhpWord\Style\Paragraph;
+use PhpOffice\PhpWord\TOC;
+
+class Document extends Base
+{
+ public function writeDocument(PHPWord $phpWord = null)
{
// Create XML writer
-
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// w:document
- $objWriter->startElement('w:document');
+ $xmlWriter->startElement('w:document');
- $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
- $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
- $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
- $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
- $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
- $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
+ $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
+ $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
+ $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
+ $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
+ $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
+ $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
+ $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
+ $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
+ $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
- $objWriter->startElement('w:body');
+ $xmlWriter->startElement('w:body');
- $_sections = $pPHPWord->getSections();
+ $_sections = $phpWord->getSections();
$countSections = count($_sections);
$pSection = 0;
@@ -70,60 +84,60 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
$_elements = $section->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextRun) {
- $this->_writeTextRun($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Link) {
- $this->_writeLink($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Title) {
- $this->_writeTitle($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $this->_writeTextBreak($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_PageBreak) {
- $this->_writePageBreak($objWriter);
- } elseif ($element instanceof PHPWord_Section_Table) {
- $this->_writeTable($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_ListItem) {
- $this->_writeListItem($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element);
+ } elseif ($element instanceof TextRun) {
+ $this->_writeTextRun($xmlWriter, $element);
+ } elseif ($element instanceof Link) {
+ $this->_writeLink($xmlWriter, $element);
+ } elseif ($element instanceof Title) {
+ $this->_writeTitle($xmlWriter, $element);
+ } elseif ($element instanceof TextBreak) {
+ $this->_writeTextBreak($xmlWriter, $element);
+ } elseif ($element instanceof PageBreak) {
+ $this->_writePageBreak($xmlWriter);
+ } elseif ($element instanceof Table) {
+ $this->_writeTable($xmlWriter, $element);
+ } elseif ($element instanceof ListItem) {
+ $this->_writeListItem($xmlWriter, $element);
+ } elseif ($element instanceof Image ||
+ $element instanceof MemoryImage
) {
- $this->_writeImage($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Object) {
- $this->_writeObject($objWriter, $element);
- } elseif ($element instanceof PHPWord_TOC) {
- $this->_writeTOC($objWriter);
- } elseif ($element instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnoteReference($objWriter, $element);
+ $this->_writeImage($xmlWriter, $element);
+ } elseif ($element instanceof Object) {
+ $this->_writeObject($xmlWriter, $element);
+ } elseif ($element instanceof TOC) {
+ $this->_writeTOC($xmlWriter);
+ } elseif ($element instanceof Footnote) {
+ $this->_writeFootnoteReference($xmlWriter, $element);
}
}
if ($pSection == $countSections) {
- $this->_writeEndSection($objWriter, $section);
+ $this->_writeEndSection($xmlWriter, $section);
} else {
- $this->_writeSection($objWriter, $section);
+ $this->_writeSection($xmlWriter, $section);
}
}
}
- $objWriter->endElement(); // End w:body
- $objWriter->endElement(); // End w:document
+ $xmlWriter->endElement(); // End w:body
+ $xmlWriter->endElement(); // End w:document
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
- private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
+ private function _writeSection(XMLWriter $xmlWriter = null, Section $section)
{
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:pPr');
- $this->_writeEndSection($objWriter, $section, 3);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:pPr');
+ $this->_writeEndSection($xmlWriter, $section, 3);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
+ private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section)
{
$settings = $section->getSettings();
$_headers = $section->getHeaders();
@@ -146,167 +160,167 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
$colsSpace = $settings->getColsSpace();
$breakType = $settings->getBreakType();
- $objWriter->startElement('w:sectPr');
+ $xmlWriter->startElement('w:sectPr');
foreach ($_headers as &$_header) {
$rId = $_header->getRelationId();
- $objWriter->startElement('w:headerReference');
- $objWriter->writeAttribute('w:type', $_header->getType());
- $objWriter->writeAttribute('r:id', 'rId' . $rId);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:headerReference');
+ $xmlWriter->writeAttribute('w:type', $_header->getType());
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
+ $xmlWriter->endElement();
}
if ($section->hasDifferentFirstPage()) {
- $objWriter->startElement('w:titlePg');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:titlePg');
+ $xmlWriter->endElement();
}
if (!is_null($breakType)) {
- $objWriter->startElement('w:type');
- $objWriter->writeAttribute('w:val', $breakType);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:type');
+ $xmlWriter->writeAttribute('w:val', $breakType);
+ $xmlWriter->endElement();
}
if (!is_null($_footer)) {
$rId = $_footer->getRelationId();
- $objWriter->startElement('w:footerReference');
- $objWriter->writeAttribute('w:type', 'default');
- $objWriter->writeAttribute('r:id', 'rId' . $rId);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:footerReference');
+ $xmlWriter->writeAttribute('w:type', 'default');
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:pgSz');
- $objWriter->writeAttribute('w:w', $pgSzW);
- $objWriter->writeAttribute('w:h', $pgSzH);
+ $xmlWriter->startElement('w:pgSz');
+ $xmlWriter->writeAttribute('w:w', $pgSzW);
+ $xmlWriter->writeAttribute('w:h', $pgSzH);
if (!is_null($orientation) && strtolower($orientation) != 'portrait') {
- $objWriter->writeAttribute('w:orient', $orientation);
+ $xmlWriter->writeAttribute('w:orient', $orientation);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:pgMar');
- $objWriter->writeAttribute('w:top', $marginTop);
- $objWriter->writeAttribute('w:right', $marginRight);
- $objWriter->writeAttribute('w:bottom', $marginBottom);
- $objWriter->writeAttribute('w:left', $marginLeft);
- $objWriter->writeAttribute('w:header', $headerHeight);
- $objWriter->writeAttribute('w:footer', $footerHeight);
- $objWriter->writeAttribute('w:gutter', '0');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pgMar');
+ $xmlWriter->writeAttribute('w:top', $marginTop);
+ $xmlWriter->writeAttribute('w:right', $marginRight);
+ $xmlWriter->writeAttribute('w:bottom', $marginBottom);
+ $xmlWriter->writeAttribute('w:left', $marginLeft);
+ $xmlWriter->writeAttribute('w:header', $headerHeight);
+ $xmlWriter->writeAttribute('w:footer', $footerHeight);
+ $xmlWriter->writeAttribute('w:gutter', '0');
+ $xmlWriter->endElement();
if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
$borderColor = $settings->getBorderColor();
- $objWriter->startElement('w:pgBorders');
- $objWriter->writeAttribute('w:offsetFrom', 'page');
+ $xmlWriter->startElement('w:pgBorders');
+ $xmlWriter->writeAttribute('w:offsetFrom', 'page');
if (!is_null($borders[0])) {
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $borders[0]);
- $objWriter->writeAttribute('w:space', '24');
- $objWriter->writeAttribute('w:color', $borderColor[0]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $borders[0]);
+ $xmlWriter->writeAttribute('w:space', '24');
+ $xmlWriter->writeAttribute('w:color', $borderColor[0]);
+ $xmlWriter->endElement();
}
if (!is_null($borders[1])) {
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $borders[1]);
- $objWriter->writeAttribute('w:space', '24');
- $objWriter->writeAttribute('w:color', $borderColor[1]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $borders[1]);
+ $xmlWriter->writeAttribute('w:space', '24');
+ $xmlWriter->writeAttribute('w:color', $borderColor[1]);
+ $xmlWriter->endElement();
}
if (!is_null($borders[2])) {
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $borders[2]);
- $objWriter->writeAttribute('w:space', '24');
- $objWriter->writeAttribute('w:color', $borderColor[2]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $borders[2]);
+ $xmlWriter->writeAttribute('w:space', '24');
+ $xmlWriter->writeAttribute('w:color', $borderColor[2]);
+ $xmlWriter->endElement();
}
if (!is_null($borders[3])) {
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $borders[3]);
- $objWriter->writeAttribute('w:space', '24');
- $objWriter->writeAttribute('w:color', $borderColor[3]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $borders[3]);
+ $xmlWriter->writeAttribute('w:space', '24');
+ $xmlWriter->writeAttribute('w:color', $borderColor[3]);
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
// Page numbering
if (null !== $settings->getPageNumberingStart()) {
- $objWriter->startElement('w:pgNumType');
- $objWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart());
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pgNumType');
+ $xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart());
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:cols');
- $objWriter->writeAttribute('w:num', $colsNum);
- $objWriter->writeAttribute('w:space', $colsSpace);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:cols');
+ $xmlWriter->writeAttribute('w:num', $colsNum);
+ $xmlWriter->writeAttribute('w:space', $colsSpace);
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null)
+ private function _writePageBreak(XMLWriter $xmlWriter = null)
{
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:br');
- $objWriter->writeAttribute('w:type', 'page');
- $objWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:br');
+ $xmlWriter->writeAttribute('w:type', 'page');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- public function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
+ public function _writeListItem(XMLWriter $xmlWriter = null, ListItem $listItem)
{
$textObject = $listItem->getTextObject();
$text = $textObject->getText();
$styleParagraph = $textObject->getParagraphStyle();
- $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
+ $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false;
$depth = $listItem->getDepth();
$listType = $listItem->getStyle()->getListType();
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:pPr');
if ($SpIsObject) {
- $this->_writeParagraphStyle($objWriter, $styleParagraph, true);
+ $this->_writeParagraphStyle($xmlWriter, $styleParagraph, true);
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleParagraph);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleParagraph);
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:numPr');
+ $xmlWriter->startElement('w:numPr');
- $objWriter->startElement('w:ilvl');
- $objWriter->writeAttribute('w:val', $depth);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:ilvl');
+ $xmlWriter->writeAttribute('w:val', $depth);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:numId');
- $objWriter->writeAttribute('w:val', $listType);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:numId');
+ $xmlWriter->writeAttribute('w:val', $listType);
+ $xmlWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $this->_writeText($objWriter, $textObject, true);
+ $this->_writeText($xmlWriter, $textObject, true);
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object)
+ protected function _writeObject(XMLWriter $xmlWriter = null, Object $object)
{
$rIdObject = $object->getRelationId();
$rIdImage = $object->getImageRelationId();
@@ -320,172 +334,172 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
$align = $style->getAlign();
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
if (!is_null($align)) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:jc');
- $objWriter->writeAttribute('w:val', $align);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:jc');
+ $xmlWriter->writeAttribute('w:val', $align);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
- $objWriter->startElement('w:object');
- $objWriter->writeAttribute('w:dxaOrig', '249');
- $objWriter->writeAttribute('w:dyaOrig', '160');
+ $xmlWriter->startElement('w:object');
+ $xmlWriter->writeAttribute('w:dxaOrig', '249');
+ $xmlWriter->writeAttribute('w:dyaOrig', '160');
- $objWriter->startElement('v:shape');
- $objWriter->writeAttribute('id', $shapeId);
- $objWriter->writeAttribute('type', '#_x0000_t75');
- $objWriter->writeAttribute('style', 'width:104px;height:67px');
- $objWriter->writeAttribute('o:ole', '');
+ $xmlWriter->startElement('v:shape');
+ $xmlWriter->writeAttribute('id', $shapeId);
+ $xmlWriter->writeAttribute('type', '#_x0000_t75');
+ $xmlWriter->writeAttribute('style', 'width:104px;height:67px');
+ $xmlWriter->writeAttribute('o:ole', '');
- $objWriter->startElement('v:imagedata');
- $objWriter->writeAttribute('r:id', 'rId' . $rIdImage);
- $objWriter->writeAttribute('o:title', '');
- $objWriter->endElement();
+ $xmlWriter->startElement('v:imagedata');
+ $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage);
+ $xmlWriter->writeAttribute('o:title', '');
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('o:OLEObject');
- $objWriter->writeAttribute('Type', 'Embed');
- $objWriter->writeAttribute('ProgID', 'Package');
- $objWriter->writeAttribute('ShapeID', $shapeId);
- $objWriter->writeAttribute('DrawAspect', 'Icon');
- $objWriter->writeAttribute('ObjectID', '_' . $objectId);
- $objWriter->writeAttribute('r:id', 'rId' . $rIdObject);
- $objWriter->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();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement(); // w:r
+ $xmlWriter->endElement(); // w:r
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
- private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null)
+ private function _writeTOC(XMLWriter $xmlWriter = null)
{
- $titles = PHPWord_TOC::getTitles();
- $styleFont = PHPWord_TOC::getStyleFont();
+ $titles = TOC::getTitles();
+ $styleFont = TOC::getStyleFont();
- $styleTOC = PHPWord_TOC::getStyleTOC();
+ $styleTOC = TOC::getStyleTOC();
$fIndent = $styleTOC->getIndent();
$tabLeader = $styleTOC->getTabLeader();
$tabPos = $styleTOC->getTabPos();
- $isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
+ $isObject = ($styleFont instanceof Font) ? true : false;
for ($i = 0; $i < count($titles); $i++) {
$title = $titles[$i];
$indent = ($title['depth'] - 1) * $fIndent;
- $objWriter->startElement('w:p');
+ $xmlWriter->startElement('w:p');
- $objWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pPr');
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
- $this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
+ $this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle());
}
if ($indent > 0) {
- $objWriter->startElement('w:ind');
- $objWriter->writeAttribute('w:left', $indent);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:ind');
+ $xmlWriter->writeAttribute('w:left', $indent);
+ $xmlWriter->endElement();
}
if (!empty($styleFont) && !$isObject) {
- $objWriter->startElement('w:pPr');
- $objWriter->startElement('w:pStyle');
- $objWriter->writeAttribute('w:val', $styleFont);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:pPr');
+ $xmlWriter->startElement('w:pStyle');
+ $xmlWriter->writeAttribute('w:val', $styleFont);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:tabs');
- $objWriter->startElement('w:tab');
- $objWriter->writeAttribute('w:val', 'right');
+ $xmlWriter->startElement('w:tabs');
+ $xmlWriter->startElement('w:tab');
+ $xmlWriter->writeAttribute('w:val', 'right');
if (!empty($tabLeader)) {
- $objWriter->writeAttribute('w:leader', $tabLeader);
+ $xmlWriter->writeAttribute('w:leader', $tabLeader);
}
- $objWriter->writeAttribute('w:pos', $tabPos);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->writeAttribute('w:pos', $tabPos);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement(); // w:pPr
+ $xmlWriter->endElement(); // w:pPr
if ($i == 0) {
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'begin');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'begin');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:instrText');
- $objWriter->writeAttribute('xml:space', 'preserve');
- $objWriter->writeRaw('TOC \o "1-9" \h \z \u');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:instrText');
+ $xmlWriter->writeAttribute('xml:space', 'preserve');
+ $xmlWriter->writeRaw('TOC \o "1-9" \h \z \u');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'separate');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'separate');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:hyperlink');
- $objWriter->writeAttribute('w:anchor', $title['anchor']);
- $objWriter->writeAttribute('w:history', '1');
+ $xmlWriter->startElement('w:hyperlink');
+ $xmlWriter->writeAttribute('w:anchor', $title['anchor']);
+ $xmlWriter->writeAttribute('w:history', '1');
- $objWriter->startElement('w:r');
+ $xmlWriter->startElement('w:r');
if ($isObject) {
- $this->_writeTextStyle($objWriter, $styleFont);
+ $this->_writeTextStyle($xmlWriter, $styleFont);
}
- $objWriter->startElement('w:t');
- $objWriter->writeRaw($title['text']);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:t');
+ $xmlWriter->writeRaw($title['text']);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->writeElement('w:tab', null);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->writeElement('w:tab', null);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'begin');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'begin');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:instrText');
- $objWriter->writeAttribute('xml:space', 'preserve');
- $objWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:instrText');
+ $xmlWriter->writeAttribute('xml:space', 'preserve');
+ $xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'end');
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'end');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement(); // w:hyperlink
+ $xmlWriter->endElement(); // w:hyperlink
- $objWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:p
}
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:fldChar');
- $objWriter->writeAttribute('w:fldCharType', 'end');
- $objWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:fldChar');
+ $xmlWriter->writeAttribute('w:fldCharType', 'end');
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php
index 9817a31f..d8e3396b 100755
--- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php
+++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php
@@ -25,32 +25,32 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_DocumentRels
- */
-class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class DocumentRels extends WriterPart
+{
public function writeDocumentRels($_relsCollection)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
- $objWriter->startElement('Relationships');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
+ $xmlWriter->startElement('Relationships');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Relationship word/document.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
1,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
'styles.xml'
@@ -58,7 +58,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
// Relationship word/numbering.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
2,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
'numbering.xml'
@@ -66,7 +66,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
// Relationship word/settings.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
'settings.xml'
@@ -74,7 +74,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
// Relationship word/settings.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
4,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
'theme/theme1.xml'
@@ -82,7 +82,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
// Relationship word/settings.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
5,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
'webSettings.xml'
@@ -90,7 +90,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
// Relationship word/settings.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
6,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
'fontTable.xml'
@@ -104,7 +104,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
$relationId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
$relationName,
@@ -113,28 +113,28 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
public function writeHeaderFooterRels($_relsCollection)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
- $objWriter->startElement('Relationships');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
+ $xmlWriter->startElement('Relationships');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Relationships to Images / Embeddings / Headers / Footers
foreach ($_relsCollection as $relation) {
@@ -143,7 +143,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
$relationId = $relation['rID'];
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
$relationId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
$relationName
@@ -151,13 +151,13 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
- private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
+ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{
if ($pType != '' && $pTarget != '') {
if (strpos($pId, 'rId') === false) {
@@ -165,16 +165,16 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
}
// Write relationship
- $objWriter->startElement('Relationship');
- $objWriter->writeAttribute('Id', $pId);
- $objWriter->writeAttribute('Type', $pType);
- $objWriter->writeAttribute('Target', $pTarget);
+ $xmlWriter->startElement('Relationship');
+ $xmlWriter->writeAttribute('Id', $pId);
+ $xmlWriter->writeAttribute('Type', $pType);
+ $xmlWriter->writeAttribute('Target', $pTarget);
if ($pTargetMode != '') {
- $objWriter->writeAttribute('TargetMode', $pTargetMode);
+ $xmlWriter->writeAttribute('TargetMode', $pTargetMode);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
} else {
throw new Exception("Invalid parameters passed.");
}
diff --git a/Classes/PHPWord/Writer/Word2007/Footer.php b/Classes/PHPWord/Writer/Word2007/Footer.php
index 6ee18d66..59c24638 100755
--- a/Classes/PHPWord/Writer/Word2007/Footer.php
+++ b/Classes/PHPWord/Writer/Word2007/Footer.php
@@ -25,59 +25,66 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_Footer
- */
-class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
- public function writeFooter(PHPWord_Section_Footer $footer)
+use PhpOffice\PhpWord\Section\Footer\PreserveText;
+use PhpOffice\PhpWord\Section\Image;
+use PhpOffice\PhpWord\Section\MemoryImage;
+use PhpOffice\PhpWord\Section\Table;
+use PhpOffice\PhpWord\Section\Text;
+use PhpOffice\PhpWord\Section\TextBreak;
+use PhpOffice\PhpWord\Section\TextRun;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class Footer extends Base
+{
+ public function writeFooter(PhpOffice\PhpWord\Section\Footer $footer)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
- $objWriter->startElement('w:ftr');
- $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
- $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
- $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
- $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
- $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
- $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
+ $xmlWriter->startElement('w:ftr');
+ $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
+ $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
+ $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
+ $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
+ $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
+ $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
+ $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
+ $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
+ $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
$_elements = $footer->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextRun) {
- $this->_writeTextRun($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $this->_writeTextBreak($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Table) {
- $this->_writeTable($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element);
+ } elseif ($element instanceof TextRun) {
+ $this->_writeTextRun($xmlWriter, $element);
+ } elseif ($element instanceof TextBreak) {
+ $this->_writeTextBreak($xmlWriter, $element);
+ } elseif ($element instanceof Table) {
+ $this->_writeTable($xmlWriter, $element);
+ } elseif ($element instanceof Image ||
+ $element instanceof MemoryImage
) {
- $this->_writeImage($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
- $this->_writePreserveText($objWriter, $element);
+ $this->_writeImage($xmlWriter, $element);
+ } elseif ($element instanceof PreserveText) {
+ $this->_writePreserveText($xmlWriter, $element);
}
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/Footnotes.php b/Classes/PHPWord/Writer/Word2007/Footnotes.php
index 28d087c7..fae7641b 100644
--- a/Classes/PHPWord/Writer/Word2007/Footnotes.php
+++ b/Classes/PHPWord/Writer/Word2007/Footnotes.php
@@ -25,59 +25,63 @@
* @version 0.8.0
*/
+namespace PhpOffice\PhpWord\Writer\Word2007;
-class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base
+use PhpOffice\PhpWord\Section\Footnote;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class Footnotes extends Base
{
public function writeFootnotes($allFootnotesCollection)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
- $objWriter->startElement('w:footnotes');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
+ $xmlWriter->startElement('w:footnotes');
+ $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
+ $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
// write separator and continuation separator
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', 0);
- $objWriter->writeAttribute('w:type', 'separator');
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:separator');
- $objWriter->endElement(); // w:separator
- $objWriter->endElement(); // w:r
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
+ $xmlWriter->startElement('w:footnote');
+ $xmlWriter->writeAttribute('w:id', 0);
+ $xmlWriter->writeAttribute('w:type', 'separator');
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:separator');
+ $xmlWriter->endElement(); // w:separator
+ $xmlWriter->endElement(); // w:r
+ $xmlWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:footnote
- $objWriter->startElement('w:footnote');
- $objWriter->writeAttribute('w:id', 1);
- $objWriter->writeAttribute('w:type', 'continuationSeparator');
- $objWriter->startElement('w:p');
- $objWriter->startElement('w:r');
- $objWriter->startElement('w:continuationSeparator');
- $objWriter->endElement(); // w:continuationSeparator
- $objWriter->endElement(); // w:r
- $objWriter->endElement(); // w:p
- $objWriter->endElement(); // w:footnote
+ $xmlWriter->startElement('w:footnote');
+ $xmlWriter->writeAttribute('w:id', 1);
+ $xmlWriter->writeAttribute('w:type', 'continuationSeparator');
+ $xmlWriter->startElement('w:p');
+ $xmlWriter->startElement('w:r');
+ $xmlWriter->startElement('w:continuationSeparator');
+ $xmlWriter->endElement(); // w:continuationSeparator
+ $xmlWriter->endElement(); // w:r
+ $xmlWriter->endElement(); // w:p
+ $xmlWriter->endElement(); // w:footnote
foreach ($allFootnotesCollection as $footnote) {
- if ($footnote instanceof PHPWord_Section_Footnote) {
- $this->_writeFootnote($objWriter, $footnote);
+ if ($footnote instanceof Footnote) {
+ $this->_writeFootnote($xmlWriter, $footnote);
}
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php
index 0e562b59..29b2e701 100644
--- a/Classes/PHPWord/Writer/Word2007/FootnotesRels.php
+++ b/Classes/PHPWord/Writer/Word2007/FootnotesRels.php
@@ -25,25 +25,28 @@
* @version 0.8.0
*/
+namespace PhpOffice\PhpWord\Writer\Word2007;
-class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class FootnotesRels extends WriterPart
{
public function writeFootnotesRels($_relsCollection)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
- $objWriter->startElement('Relationships');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
+ $xmlWriter->startElement('Relationships');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Relationships to Links
foreach ($_relsCollection as $relation) {
@@ -52,16 +55,16 @@ class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_Writ
$relationId = $relation['rID'];
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
- $this->_writeRelationship($objWriter, $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);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
- private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
+ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{
if ($pType != '' && $pTarget != '') {
if (strpos($pId, 'rId') === false) {
@@ -69,16 +72,16 @@ class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_Writ
}
// Write relationship
- $objWriter->startElement('Relationship');
- $objWriter->writeAttribute('Id', $pId);
- $objWriter->writeAttribute('Type', $pType);
- $objWriter->writeAttribute('Target', $pTarget);
+ $xmlWriter->startElement('Relationship');
+ $xmlWriter->writeAttribute('Id', $pId);
+ $xmlWriter->writeAttribute('Type', $pType);
+ $xmlWriter->writeAttribute('Target', $pTarget);
if ($pTargetMode != '') {
- $objWriter->writeAttribute('TargetMode', $pTargetMode);
+ $xmlWriter->writeAttribute('TargetMode', $pTargetMode);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
} else {
throw new Exception("Invalid parameters passed.");
}
diff --git a/Classes/PHPWord/Writer/Word2007/Header.php b/Classes/PHPWord/Writer/Word2007/Header.php
index 59eebd91..23119378 100755
--- a/Classes/PHPWord/Writer/Word2007/Header.php
+++ b/Classes/PHPWord/Writer/Word2007/Header.php
@@ -25,63 +25,70 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_Header
- */
-class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
- public function writeHeader(PHPWord_Section_Header $header)
+use PhpOffice\PhpWord\Section\Footer\PreserveText;
+use PhpOffice\PhpWord\Section\Image;
+use PhpOffice\PhpWord\Section\MemoryImage;
+use PhpOffice\PhpWord\Section\Table;
+use PhpOffice\PhpWord\Section\Text;
+use PhpOffice\PhpWord\Section\TextBreak;
+use PhpOffice\PhpWord\Section\TextRun;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class Header extends Base
+{
+ public function writeHeader(PhpOffice\PhpWord\Section\Header $header)
{
// Create XML writer
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
- $objWriter->startElement('w:hdr');
- $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
- $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
- $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
- $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
- $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
- $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
+ $xmlWriter->startElement('w:hdr');
+ $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
+ $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
+ $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
+ $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
+ $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
+ $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
+ $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
+ $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
+ $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
$_elements = $header->getElements();
foreach ($_elements as $element) {
- if ($element instanceof PHPWord_Section_Text) {
- $this->_writeText($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextRun) {
- $this->_writeTextRun($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_TextBreak) {
- $this->_writeTextBreak($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Table) {
- $this->_writeTable($objWriter, $element);
- } elseif ($element instanceof PHPWord_Section_Image ||
- $element instanceof PHPWord_Section_MemoryImage
+ if ($element instanceof Text) {
+ $this->_writeText($xmlWriter, $element);
+ } elseif ($element instanceof TextRun) {
+ $this->_writeTextRun($xmlWriter, $element);
+ } elseif ($element instanceof TextBreak) {
+ $this->_writeTextBreak($xmlWriter, $element);
+ } elseif ($element instanceof Table) {
+ $this->_writeTable($xmlWriter, $element);
+ } elseif ($element instanceof Image ||
+ $element instanceof MemoryImage
) {
if (!$element->getIsWatermark()) {
- $this->_writeImage($objWriter, $element);
+ $this->_writeImage($xmlWriter, $element);
} else {
- $this->_writeWatermark($objWriter, $element);
+ $this->_writeWatermark($xmlWriter, $element);
}
- } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
- $this->_writePreserveText($objWriter, $element);
+ } elseif ($element instanceof PreserveText) {
+ $this->_writePreserveText($xmlWriter, $element);
}
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/Rels.php b/Classes/PHPWord/Writer/Word2007/Rels.php
index 06eb59cc..5afd8bdc 100755
--- a/Classes/PHPWord/Writer/Word2007/Rels.php
+++ b/Classes/PHPWord/Writer/Word2007/Rels.php
@@ -25,34 +25,34 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_Rels
- */
-class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
- public function writeRelationships(PHPWord $pPHPWord = null)
+use PhpOffice\PhpWord\Shared\XMLWriter;
+
+class Rels extends WriterPart
+{
+ public function writeRelationships(PHPWord $phpWord = null)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
- $objWriter->startElement('Relationships');
- $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
+ $xmlWriter->startElement('Relationships');
+ $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$relationId = 1;
// Relationship word/document.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
$relationId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
'word/document.xml'
@@ -60,7 +60,7 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
// Relationship docProps/core.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
++$relationId,
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
'docProps/core.xml'
@@ -68,29 +68,28 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
// Relationship docProps/app.xml
$this->_writeRelationship(
- $objWriter,
+ $xmlWriter,
++$relationId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
'docProps/app.xml'
);
- $objWriter->endElement();
+ $xmlWriter->endElement();
- // Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
/**
* Write Override content type
*
- * @param PHPWord_Shared_XMLWriter $objWriter XML Writer
+ * @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 Exception
*/
- private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
+ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{
if ($pType != '' && $pTarget != '') {
if (strpos($pId, 'rId') === false) {
@@ -98,16 +97,16 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
}
// Write relationship
- $objWriter->startElement('Relationship');
- $objWriter->writeAttribute('Id', $pId);
- $objWriter->writeAttribute('Type', $pType);
- $objWriter->writeAttribute('Target', $pTarget);
+ $xmlWriter->startElement('Relationship');
+ $xmlWriter->writeAttribute('Id', $pId);
+ $xmlWriter->writeAttribute('Type', $pType);
+ $xmlWriter->writeAttribute('Target', $pTarget);
if ($pTargetMode != '') {
- $objWriter->writeAttribute('TargetMode', $pTargetMode);
+ $xmlWriter->writeAttribute('TargetMode', $pTargetMode);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
} else {
throw new Exception("Invalid parameters passed.");
}
diff --git a/Classes/PHPWord/Writer/Word2007/Styles.php b/Classes/PHPWord/Writer/Word2007/Styles.php
index 3724323e..865e93cc 100755
--- a/Classes/PHPWord/Writer/Word2007/Styles.php
+++ b/Classes/PHPWord/Writer/Word2007/Styles.php
@@ -25,57 +25,61 @@
* @version 0.8.0
*/
-/**
- * Class PHPWord_Writer_Word2007_Styles
- */
-class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
-{
+namespace PhpOffice\PhpWord\Writer\Word2007;
+use PhpOffice\PhpWord\Shared\XMLWriter;
+use PhpOffice\PhpWord\Style;
+use PhpOffice\PhpWord\Style\Font;
+use PhpOffice\PhpWord\Style\Paragraph;
+use PhpOffice\PhpWord\Style\TableFull;
+
+class Styles extends Base
+{
private $_document;
- public function writeStyles(PHPWord $pPHPWord = null)
+ public function writeStyles(PHPWord $phpWord = null)
{
// Create XML writer
- $objWriter = null;
+ $xmlWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
- $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
+ $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
- $this->_document = $pPHPWord;
+ $this->_document = $phpWord;
// XML header
- $objWriter->startDocument('1.0', 'UTF-8', 'yes');
+ $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
- $objWriter->startElement('w:styles');
+ $xmlWriter->startElement('w:styles');
- $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
- $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
+ $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
+ $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
// Write DocDefaults
- $this->_writeDocDefaults($objWriter);
+ $this->_writeDocDefaults($xmlWriter);
// Write Style Definitions
- $styles = PHPWord_Style::getStyles();
+ $styles = Style::getStyles();
// Write normal paragraph style
$normalStyle = null;
if (array_key_exists('Normal', $styles)) {
$normalStyle = $styles['Normal'];
}
- $objWriter->startElement('w:style');
- $objWriter->writeAttribute('w:type', 'paragraph');
- $objWriter->writeAttribute('w:default', '1');
- $objWriter->writeAttribute('w:styleId', 'Normal');
- $objWriter->startElement('w:name');
- $objWriter->writeAttribute('w:val', 'Normal');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:style');
+ $xmlWriter->writeAttribute('w:type', 'paragraph');
+ $xmlWriter->writeAttribute('w:default', '1');
+ $xmlWriter->writeAttribute('w:styleId', 'Normal');
+ $xmlWriter->startElement('w:name');
+ $xmlWriter->writeAttribute('w:val', 'Normal');
+ $xmlWriter->endElement();
if (!is_null($normalStyle)) {
- $this->_writeParagraphStyle($objWriter, $normalStyle);
+ $this->_writeParagraphStyle($xmlWriter, $normalStyle);
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
// Write other styles
if (count($styles) > 0) {
@@ -83,7 +87,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
if ($styleName == 'Normal') {
continue;
}
- if ($style instanceof PHPWord_Style_Font) {
+ if ($style instanceof Font) {
$paragraphStyle = $style->getParagraphStyle();
$styleType = $style->getStyleType();
@@ -94,94 +98,94 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
$type = 'paragraph';
}
- $objWriter->startElement('w:style');
- $objWriter->writeAttribute('w:type', $type);
+ $xmlWriter->startElement('w:style');
+ $xmlWriter->writeAttribute('w:type', $type);
if ($styleType == 'title') {
$arrStyle = explode('_', $styleName);
$styleId = 'Heading' . $arrStyle[1];
$styleName = 'heading ' . $arrStyle[1];
$styleLink = 'Heading' . $arrStyle[1] . 'Char';
- $objWriter->writeAttribute('w:styleId', $styleId);
+ $xmlWriter->writeAttribute('w:styleId', $styleId);
- $objWriter->startElement('w:link');
- $objWriter->writeAttribute('w:val', $styleLink);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:link');
+ $xmlWriter->writeAttribute('w:val', $styleLink);
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:name');
- $objWriter->writeAttribute('w:val', $styleName);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:name');
+ $xmlWriter->writeAttribute('w:val', $styleName);
+ $xmlWriter->endElement();
if (!is_null($paragraphStyle)) {
// Point parent style to Normal
- $objWriter->startElement('w:basedOn');
- $objWriter->writeAttribute('w:val', 'Normal');
- $objWriter->endElement();
- $this->_writeParagraphStyle($objWriter, $paragraphStyle);
+ $xmlWriter->startElement('w:basedOn');
+ $xmlWriter->writeAttribute('w:val', 'Normal');
+ $xmlWriter->endElement();
+ $this->_writeParagraphStyle($xmlWriter, $paragraphStyle);
}
- $this->_writeTextStyle($objWriter, $style);
+ $this->_writeTextStyle($xmlWriter, $style);
- $objWriter->endElement();
+ $xmlWriter->endElement();
- } elseif ($style instanceof PHPWord_Style_Paragraph) {
- $objWriter->startElement('w:style');
- $objWriter->writeAttribute('w:type', 'paragraph');
- $objWriter->writeAttribute('w:customStyle', '1');
- $objWriter->writeAttribute('w:styleId', $styleName);
+ } elseif ($style instanceof Paragraph) {
+ $xmlWriter->startElement('w:style');
+ $xmlWriter->writeAttribute('w:type', 'paragraph');
+ $xmlWriter->writeAttribute('w:customStyle', '1');
+ $xmlWriter->writeAttribute('w:styleId', $styleName);
- $objWriter->startElement('w:name');
- $objWriter->writeAttribute('w:val', $styleName);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:name');
+ $xmlWriter->writeAttribute('w:val', $styleName);
+ $xmlWriter->endElement();
// Parent style
$basedOn = $style->getBasedOn();
if (!is_null($basedOn)) {
- $objWriter->startElement('w:basedOn');
- $objWriter->writeAttribute('w:val', $basedOn);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:basedOn');
+ $xmlWriter->writeAttribute('w:val', $basedOn);
+ $xmlWriter->endElement();
}
// Next paragraph style
$next = $style->getNext();
if (!is_null($next)) {
- $objWriter->startElement('w:next');
- $objWriter->writeAttribute('w:val', $next);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:next');
+ $xmlWriter->writeAttribute('w:val', $next);
+ $xmlWriter->endElement();
}
- $this->_writeParagraphStyle($objWriter, $style);
- $objWriter->endElement();
+ $this->_writeParagraphStyle($xmlWriter, $style);
+ $xmlWriter->endElement();
- } elseif ($style instanceof PHPWord_Style_TableFull) {
- $objWriter->startElement('w:style');
- $objWriter->writeAttribute('w:type', 'table');
- $objWriter->writeAttribute('w:customStyle', '1');
- $objWriter->writeAttribute('w:styleId', $styleName);
+ } elseif ($style instanceof TableFull) {
+ $xmlWriter->startElement('w:style');
+ $xmlWriter->writeAttribute('w:type', 'table');
+ $xmlWriter->writeAttribute('w:customStyle', '1');
+ $xmlWriter->writeAttribute('w:styleId', $styleName);
- $objWriter->startElement('w:name');
- $objWriter->writeAttribute('w:val', $styleName);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:name');
+ $xmlWriter->writeAttribute('w:val', $styleName);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:uiPriority');
- $objWriter->writeAttribute('w:val', '99');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:uiPriority');
+ $xmlWriter->writeAttribute('w:val', '99');
+ $xmlWriter->endElement();
- $this->_writeFullTableStyle($objWriter, $style);
+ $this->_writeFullTableStyle($xmlWriter, $style);
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
}
}
- $objWriter->endElement(); // w:styles
+ $xmlWriter->endElement(); // w:styles
// Return
- return $objWriter->getData();
+ return $xmlWriter->getData();
}
- private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style)
+ private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $style)
{
$brdSz = $style->getBorderSize();
@@ -203,106 +207,106 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
$mBottom = (!is_null($cellMargin[3])) ? true : false;
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
- $objWriter->startElement('w:tblPr');
+ $xmlWriter->startElement('w:tblPr');
if ($margins) {
- $objWriter->startElement('w:tblCellMar');
+ $xmlWriter->startElement('w:tblCellMar');
if ($mTop) {
echo $margins[0];
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:w', $cellMargin[0]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:w', $cellMargin[0]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mLeft) {
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:w', $cellMargin[1]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:w', $cellMargin[1]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mRight) {
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:w', $cellMargin[2]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:w', $cellMargin[2]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
if ($mBottom) {
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:w', $cellMargin[3]);
- $objWriter->writeAttribute('w:type', 'dxa');
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:w', $cellMargin[3]);
+ $xmlWriter->writeAttribute('w:type', 'dxa');
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
if ($borders) {
- $objWriter->startElement('w:tblBorders');
+ $xmlWriter->startElement('w:tblBorders');
if ($bTop) {
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[0]);
- $objWriter->writeAttribute('w:color', $brdCol[0]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[0]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[0]);
+ $xmlWriter->endElement();
}
if ($bLeft) {
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[1]);
- $objWriter->writeAttribute('w:color', $brdCol[1]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[1]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[1]);
+ $xmlWriter->endElement();
}
if ($bRight) {
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[2]);
- $objWriter->writeAttribute('w:color', $brdCol[2]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[2]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[2]);
+ $xmlWriter->endElement();
}
if ($bBottom) {
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[3]);
- $objWriter->writeAttribute('w:color', $brdCol[3]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[3]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[3]);
+ $xmlWriter->endElement();
}
if ($bInsH) {
- $objWriter->startElement('w:insideH');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[4]);
- $objWriter->writeAttribute('w:color', $brdCol[4]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:insideH');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[4]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[4]);
+ $xmlWriter->endElement();
}
if ($bInsV) {
- $objWriter->startElement('w:insideV');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[5]);
- $objWriter->writeAttribute('w:color', $brdCol[5]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:insideV');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[5]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[5]);
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
if (!is_null($bgColor)) {
- $objWriter->startElement('w:tcPr');
- $objWriter->startElement('w:shd');
- $objWriter->writeAttribute('w:val', 'clear');
- $objWriter->writeAttribute('w:color', 'auto');
- $objWriter->writeAttribute('w:fill', $bgColor);
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->startElement('w:tcPr');
+ $xmlWriter->startElement('w:shd');
+ $xmlWriter->writeAttribute('w:val', 'clear');
+ $xmlWriter->writeAttribute('w:color', 'auto');
+ $xmlWriter->writeAttribute('w:fill', $bgColor);
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
// First Row
$firstRow = $style->getFirstRow();
if (!is_null($firstRow)) {
- $this->_writeRowStyle($objWriter, 'firstRow', $firstRow);
+ $this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow);
}
}
- private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style)
+ private function _writeRowStyle(XMLWriter $xmlWriter = null, $type, TableFull $style)
{
$brdSz = $style->getBorderSize();
$brdCol = $style->getBorderColor();
@@ -314,81 +318,81 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
$bBottom = (!is_null($brdSz[3])) ? true : false;
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
- $objWriter->startElement('w:tblStylePr');
- $objWriter->writeAttribute('w:type', $type);
+ $xmlWriter->startElement('w:tblStylePr');
+ $xmlWriter->writeAttribute('w:type', $type);
- $objWriter->startElement('w:tcPr');
+ $xmlWriter->startElement('w:tcPr');
if (!is_null($bgColor)) {
- $objWriter->startElement('w:shd');
- $objWriter->writeAttribute('w:val', 'clear');
- $objWriter->writeAttribute('w:color', 'auto');
- $objWriter->writeAttribute('w:fill', $bgColor);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:shd');
+ $xmlWriter->writeAttribute('w:val', 'clear');
+ $xmlWriter->writeAttribute('w:color', 'auto');
+ $xmlWriter->writeAttribute('w:fill', $bgColor);
+ $xmlWriter->endElement();
}
- $objWriter->startElement('w:tcBorders');
+ $xmlWriter->startElement('w:tcBorders');
if ($bTop) {
- $objWriter->startElement('w:top');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[0]);
- $objWriter->writeAttribute('w:color', $brdCol[0]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:top');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[0]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[0]);
+ $xmlWriter->endElement();
}
if ($bLeft) {
- $objWriter->startElement('w:left');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[1]);
- $objWriter->writeAttribute('w:color', $brdCol[1]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:left');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[1]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[1]);
+ $xmlWriter->endElement();
}
if ($bRight) {
- $objWriter->startElement('w:right');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[2]);
- $objWriter->writeAttribute('w:color', $brdCol[2]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:right');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[2]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[2]);
+ $xmlWriter->endElement();
}
if ($bBottom) {
- $objWriter->startElement('w:bottom');
- $objWriter->writeAttribute('w:val', 'single');
- $objWriter->writeAttribute('w:sz', $brdSz[3]);
- $objWriter->writeAttribute('w:color', $brdCol[3]);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:bottom');
+ $xmlWriter->writeAttribute('w:val', 'single');
+ $xmlWriter->writeAttribute('w:sz', $brdSz[3]);
+ $xmlWriter->writeAttribute('w:color', $brdCol[3]);
+ $xmlWriter->endElement();
}
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
}
- private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null)
+ private function _writeDocDefaults(XMLWriter $xmlWriter = null)
{
$fontName = $this->_document->getDefaultFontName();
$fontSize = $this->_document->getDefaultFontSize();
- $objWriter->startElement('w:docDefaults');
- $objWriter->startElement('w:rPrDefault');
- $objWriter->startElement('w:rPr');
+ $xmlWriter->startElement('w:docDefaults');
+ $xmlWriter->startElement('w:rPrDefault');
+ $xmlWriter->startElement('w:rPr');
- $objWriter->startElement('w:rFonts');
- $objWriter->writeAttribute('w:ascii', $fontName);
- $objWriter->writeAttribute('w:hAnsi', $fontName);
- $objWriter->writeAttribute('w:eastAsia', $fontName);
- $objWriter->writeAttribute('w:cs', $fontName);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:rFonts');
+ $xmlWriter->writeAttribute('w:ascii', $fontName);
+ $xmlWriter->writeAttribute('w:hAnsi', $fontName);
+ $xmlWriter->writeAttribute('w:eastAsia', $fontName);
+ $xmlWriter->writeAttribute('w:cs', $fontName);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:sz');
- $objWriter->writeAttribute('w:val', $fontSize * 2);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:sz');
+ $xmlWriter->writeAttribute('w:val', $fontSize * 2);
+ $xmlWriter->endElement();
- $objWriter->startElement('w:szCs');
- $objWriter->writeAttribute('w:val', $fontSize * 2);
- $objWriter->endElement();
+ $xmlWriter->startElement('w:szCs');
+ $xmlWriter->writeAttribute('w:val', $fontSize * 2);
+ $xmlWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
- $objWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
+ $xmlWriter->endElement();
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/WriterPart.php b/Classes/PHPWord/Writer/Word2007/WriterPart.php
index cc004254..bdd551c2 100755
--- a/Classes/PHPWord/Writer/Word2007/WriterPart.php
+++ b/Classes/PHPWord/Writer/Word2007/WriterPart.php
@@ -25,14 +25,15 @@
* @version 0.8.0
*/
-/**
- * Abstract Class PHPWord_Writer_Word2007_WriterPart
- */
-abstract class PHPWord_Writer_Word2007_WriterPart
+namespace PhpOffice\PhpWord\Writer\Word2007;
+
+use PhpOffice\PhpWord\Writer\IWriter;
+
+abstract class WriterPart
{
private $_parentWriter;
- public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
+ public function setParentWriter(IWriter $pWriter = null)
{
$this->_parentWriter = $pWriter;
}
@@ -42,7 +43,7 @@ abstract class PHPWord_Writer_Word2007_WriterPart
if (!is_null($this->_parentWriter)) {
return $this->_parentWriter;
} else {
- throw new Exception("No parent PHPWord_Writer_IWriter assigned.");
+ throw new Exception("No parent IWriter assigned.");
}
}
}
diff --git a/README.md b/README.md
index d35603d0..925fac67 100755
--- a/README.md
+++ b/README.md
@@ -103,7 +103,7 @@ $section->addText('Hello world! I am formatted by a user defined style',
'myOwnStyle');
// You can also put the appended element to local object like this:
-$fontStyle = new PHPWord_Style_Font();
+$fontStyle = new PhpOffice\PhpWord\Style\Font();
$fontStyle->setBold(true);
$fontStyle->setName('Verdana');
$fontStyle->setSize(22);
@@ -111,8 +111,8 @@ $myTextElement = $section->addText('Hello World!');
$myTextElement->setFontStyle($fontStyle);
// Finally, write the document:
-$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
-$objWriter->save('helloWorld.docx');
+$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
+$xmlWriter->save('helloWorld.docx');
```
@@ -125,15 +125,15 @@ You can use PHPWord helper functions to convert inches, centimeters, or points t
```php
// Paragraph with 6 points space after
$PHPWord->addParagraphStyle('My Style', array(
- 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(6))
+ 'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6))
);
$section = $PHPWord->createSection();
$sectionStyle = $section->getSettings();
// half inch left margin
-$sectionStyle->setMarginLeft(PHPWord_Shared_Font::inchSizeToTwips(.5));
+$sectionStyle->setMarginLeft(PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
// 2 cm right margin
-$sectionStyle->setMarginRight(PHPWord_Shared_Font::centimeterSizeToTwips(2));
+$sectionStyle->setMarginRight(PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2));
```
diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PHPWord/AutoloaderTest.php
index 03e16db0..d33d8ab5 100644
--- a/Tests/PHPWord/AutoloaderTest.php
+++ b/Tests/PHPWord/AutoloaderTest.php
@@ -46,4 +46,4 @@ class AutoloaderTest extends \PHPUnit_Framework_TestCase
'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException class'
);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/DocumentPropertiesTest.php b/Tests/PHPWord/DocumentPropertiesTest.php
index f98a9907..250f1b3e 100644
--- a/Tests/PHPWord/DocumentPropertiesTest.php
+++ b/Tests/PHPWord/DocumentPropertiesTest.php
@@ -1,20 +1,18 @@
setCreator();
$this->assertEquals('', $oProperties->getCreator());
@@ -24,7 +22,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testLastModifiedBy()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setLastModifiedBy();
$this->assertEquals('', $oProperties->getLastModifiedBy());
@@ -34,7 +32,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testCreated()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setCreated();
$this->assertEquals(time(), $oProperties->getCreated());
@@ -45,7 +43,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testModified()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setModified();
$this->assertEquals(time(), $oProperties->getModified());
@@ -56,7 +54,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testTitle()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setTitle();
$this->assertEquals('', $oProperties->getTitle());
@@ -66,7 +64,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testDescription()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setDescription();
$this->assertEquals('', $oProperties->getDescription());
@@ -76,7 +74,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testSubject()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setSubject();
$this->assertEquals('', $oProperties->getSubject());
@@ -86,7 +84,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testKeywords()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setKeywords();
$this->assertEquals('', $oProperties->getKeywords());
@@ -96,7 +94,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testCategory()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setCategory();
$this->assertEquals('', $oProperties->getCategory());
@@ -106,7 +104,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testCompany()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setCompany();
$this->assertEquals('', $oProperties->getCompany());
@@ -116,7 +114,7 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testManager()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setManager();
$this->assertEquals('', $oProperties->getManager());
@@ -126,30 +124,30 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testCustomProperty()
{
- $oProperties = new PHPWord_DocumentProperties();
+ $oProperties = new DocumentProperties();
$oProperties->setCustomProperty('key1', null);
$oProperties->setCustomProperty('key2', true);
$oProperties->setCustomProperty('key3', 3);
$oProperties->setCustomProperty('key4', 4.4);
$oProperties->setCustomProperty('key5', 'value5');
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_STRING,
+ DocumentProperties::PROPERTY_TYPE_STRING,
$oProperties->getCustomPropertyType('key1')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_BOOLEAN,
+ DocumentProperties::PROPERTY_TYPE_BOOLEAN,
$oProperties->getCustomPropertyType('key2')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER,
+ DocumentProperties::PROPERTY_TYPE_INTEGER,
$oProperties->getCustomPropertyType('key3')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_FLOAT,
+ DocumentProperties::PROPERTY_TYPE_FLOAT,
$oProperties->getCustomPropertyType('key4')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_STRING,
+ DocumentProperties::PROPERTY_TYPE_STRING,
$oProperties->getCustomPropertyType('key5')
);
$this->assertEquals(null, $oProperties->getCustomPropertyType('key6'));
@@ -172,50 +170,50 @@ class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
public function testConvertProperty()
{
- $this->assertEquals('', PHPWord_DocumentProperties::convertProperty('a', 'empty'));
- $this->assertEquals(null, PHPWord_DocumentProperties::convertProperty('a', 'null'));
- $this->assertEquals(8, PHPWord_DocumentProperties::convertProperty('8', 'int'));
- $this->assertEquals(8, PHPWord_DocumentProperties::convertProperty('8.3', 'uint'));
- $this->assertEquals(8.3, PHPWord_DocumentProperties::convertProperty('8.3', 'decimal'));
- $this->assertEquals('8.3', PHPWord_DocumentProperties::convertProperty('8.3', 'lpstr'));
- $this->assertEquals(strtotime('10/11/2013'), PHPWord_DocumentProperties::convertProperty('10/11/2013', 'date'));
- $this->assertEquals(true, PHPWord_DocumentProperties::convertProperty('true', 'bool'));
- $this->assertEquals(false, PHPWord_DocumentProperties::convertProperty('1', 'bool'));
- $this->assertEquals('1', PHPWord_DocumentProperties::convertProperty('1', 'array'));
- $this->assertEquals('1', PHPWord_DocumentProperties::convertProperty('1', ''));
+ $this->assertEquals('', DocumentProperties::convertProperty('a', 'empty'));
+ $this->assertEquals(null, DocumentProperties::convertProperty('a', 'null'));
+ $this->assertEquals(8, DocumentProperties::convertProperty('8', 'int'));
+ $this->assertEquals(8, DocumentProperties::convertProperty('8.3', 'uint'));
+ $this->assertEquals(8.3, DocumentProperties::convertProperty('8.3', 'decimal'));
+ $this->assertEquals('8.3', DocumentProperties::convertProperty('8.3', 'lpstr'));
+ $this->assertEquals(strtotime('10/11/2013'), DocumentProperties::convertProperty('10/11/2013', 'date'));
+ $this->assertEquals(true, DocumentProperties::convertProperty('true', 'bool'));
+ $this->assertEquals(false, DocumentProperties::convertProperty('1', 'bool'));
+ $this->assertEquals('1', DocumentProperties::convertProperty('1', 'array'));
+ $this->assertEquals('1', DocumentProperties::convertProperty('1', ''));
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER,
- PHPWord_DocumentProperties::convertPropertyType('int')
+ DocumentProperties::PROPERTY_TYPE_INTEGER,
+ DocumentProperties::convertPropertyType('int')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_INTEGER,
- PHPWord_DocumentProperties::convertPropertyType('uint')
+ DocumentProperties::PROPERTY_TYPE_INTEGER,
+ DocumentProperties::convertPropertyType('uint')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_FLOAT,
- PHPWord_DocumentProperties::convertPropertyType('decimal')
+ DocumentProperties::PROPERTY_TYPE_FLOAT,
+ DocumentProperties::convertPropertyType('decimal')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_STRING,
- PHPWord_DocumentProperties::convertPropertyType('lpstr')
+ DocumentProperties::PROPERTY_TYPE_STRING,
+ DocumentProperties::convertPropertyType('lpstr')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_DATE,
- PHPWord_DocumentProperties::convertPropertyType('date')
+ DocumentProperties::PROPERTY_TYPE_DATE,
+ DocumentProperties::convertPropertyType('date')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_BOOLEAN,
- PHPWord_DocumentProperties::convertPropertyType('bool')
+ DocumentProperties::PROPERTY_TYPE_BOOLEAN,
+ DocumentProperties::convertPropertyType('bool')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_UNKNOWN,
- PHPWord_DocumentProperties::convertPropertyType('array')
+ DocumentProperties::PROPERTY_TYPE_UNKNOWN,
+ DocumentProperties::convertPropertyType('array')
);
$this->assertEquals(
- PHPWord_DocumentProperties::PROPERTY_TYPE_UNKNOWN,
- PHPWord_DocumentProperties::convertPropertyType('')
+ DocumentProperties::PROPERTY_TYPE_UNKNOWN,
+ DocumentProperties::convertPropertyType('')
);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Exceptions/ExceptionTest.php b/Tests/PHPWord/Exceptions/ExceptionTest.php
index a403aa28..75a4e3c1 100644
--- a/Tests/PHPWord/Exceptions/ExceptionTest.php
+++ b/Tests/PHPWord/Exceptions/ExceptionTest.php
@@ -6,8 +6,8 @@ use PhpOffice\PhpWord\Exceptions\Exception;
class ExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\Exception
- * @covers \PhpOffice\PhpWord\Exceptions\Exception
+ * @expectedException PhpOffice\PhpWord\Exceptions\Exception
+ * @covers PhpOffice\PhpWord\Exceptions\Exception
*/
public function testThrowException()
{
diff --git a/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php b/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php
index 44a24e05..7b2da273 100644
--- a/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php
+++ b/Tests/PHPWord/Exceptions/InvalidImageExceptionTest.php
@@ -6,8 +6,8 @@ use PhpOffice\PhpWord\Exceptions\InvalidImageException;
class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException
- * @covers \PhpOffice\PhpWord\Exceptions\InvalidImageException
+ * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException
+ * @covers PhpOffice\PhpWord\Exceptions\InvalidImageException
*/
public function testThrowException()
{
diff --git a/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php b/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php
index 2b0ed3af..b439a970 100644
--- a/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php
+++ b/Tests/PHPWord/Exceptions/InvalidStyleExceptionTest.php
@@ -6,8 +6,8 @@ use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidStyleException
- * @covers \PhpOffice\PhpWord\Exceptions\InvalidStyleException
+ * @expectedException PhpOffice\PhpWord\Exceptions\InvalidStyleException
+ * @covers PhpOffice\PhpWord\Exceptions\InvalidStyleException
*/
public function testThrowException()
{
diff --git a/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php b/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php
index a93ec280..cafb38ab 100644
--- a/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php
+++ b/Tests/PHPWord/Exceptions/UnsupportedImageTypeExceptionTest.php
@@ -6,8 +6,8 @@ use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
- * @covers \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
+ * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
+ * @covers PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
*/
public function testThrowException()
{
diff --git a/Tests/PHPWord/IOFactoryTest.php b/Tests/PHPWord/IOFactoryTest.php
index 0ed6a065..951497c6 100644
--- a/Tests/PHPWord/IOFactoryTest.php
+++ b/Tests/PHPWord/IOFactoryTest.php
@@ -2,13 +2,12 @@
namespace PHPWord\Tests;
use PHPWord;
-use PHPWord_IOFactory;
-use PHPWord_Writer_Word2007;
+use PhpOffice\PhpWord\IOFactory;
+use PhpOffice\PhpWord\Writer\Word2007;
use Exception;
/**
- * Class IOFactoryTest
- * @package PHPWord\Tests
+ * @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
class IOFactoryTest extends \PHPUnit_Framework_TestCase
@@ -16,48 +15,45 @@ class IOFactoryTest extends \PHPUnit_Framework_TestCase
public function testGetSearchLocations()
{
$this->assertAttributeEquals(
- PHPWord_IOFactory::getSearchLocations(),
+ IOFactory::getSearchLocations(),
'_searchLocations',
- 'PHPWord_IOFactory'
+ 'PhpOffice\\PhpWord\\IOFactory'
);
}
public function testSetSearchLocationsWithArray()
{
- PHPWord_IOFactory::setSearchLocations(array());
- $this->assertAttributeEquals(array(), '_searchLocations', 'PHPWord_IOFactory');
+ IOFactory::setSearchLocations(array());
+ $this->assertAttributeEquals(array(), '_searchLocations', 'PhpOffice\\PhpWord\\IOFactory');
}
public function testAddSearchLocation()
{
- PHPWord_IOFactory::setSearchLocations(array());
- PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
+ IOFactory::setSearchLocations(array());
+ IOFactory::addSearchLocation('interface', 'classname');
$this->assertAttributeEquals(
- array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')),
+ array(array('interface' => 'interface', 'class' => 'classname')),
'_searchLocations',
- 'PHPWord_IOFactory'
+ 'PhpOffice\\PhpWord\\IOFactory'
);
}
/**
- * @expectedException Exception
+ * @expectedException Exception
* @expectedExceptionMessage No IWriter found for type
*/
public function testCreateWriterException()
{
$oPHPWord = new PHPWord();
- PHPWord_IOFactory::setSearchLocations(array());
- PHPWord_IOFactory::createWriter($oPHPWord);
+ IOFactory::setSearchLocations(array());
+ IOFactory::createWriter($oPHPWord);
}
public function testCreateWriter()
{
$oPHPWord = new PHPWord();
- $this->assertEquals(
- PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'),
- new PHPWord_Writer_Word2007($oPHPWord)
- );
+ $this->assertEquals(IOFactory::createWriter($oPHPWord, 'Word2007'), new Word2007($oPHPWord));
}
}
\ No newline at end of file
diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php
index b2ebd6ae..6515e36b 100644
--- a/Tests/PHPWord/MediaTest.php
+++ b/Tests/PHPWord/MediaTest.php
@@ -1,39 +1,47 @@
assertEquals(PHPWord_Media::getSectionMediaElements(), array());
+ $this->assertEquals(Media::getSectionMediaElements(), array());
}
public function testCountSectionMediaElementsWithNull()
{
- $this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0);
+ $this->assertEquals(Media::countSectionMediaElements(), 0);
}
public function testGetHeaderMediaElements()
{
- $this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia', 'PHPWord_Media');
+ $this->assertAttributeEquals(
+ Media::getHeaderMediaElements(),
+ '_headerMedia',
+ 'PhpOffice\\PhpWord\\Media'
+ );
}
public function testGetFooterMediaElements()
{
- $this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia', 'PHPWord_Media');
+ $this->assertAttributeEquals(
+ Media::getFooterMediaElements(),
+ '_footerMedia',
+ 'PhpOffice\\PhpWord\\Media'
+ );
}
/**
* Todo: add memory image to this test
*
- * @covers PHPWord_Media::addSectionMediaElement
+ * @covers PhpOffice\PhpWord\Media::addSectionMediaElement
*/
public function testAddSectionMediaElement()
{
- $section = new PHPWord_Section(0);
+ $section = new Section(0);
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
@@ -44,7 +52,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase
$elements = $section->getElements();
$this->assertEquals(6, count($elements));
foreach ($elements as $element) {
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Reader/Word2007Test.php b/Tests/PHPWord/Reader/Word2007Test.php
index 6fb66846..c85c99f7 100644
--- a/Tests/PHPWord/Reader/Word2007Test.php
+++ b/Tests/PHPWord/Reader/Word2007Test.php
@@ -1,12 +1,10 @@
assertTrue($object->canRead($file));
}
@@ -46,10 +44,10 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
DIRECTORY_SEPARATOR,
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents')
);
- $object = new PHPWord_Reader_Word2007;
+ $object = new Word2007;
$file = $dir . DIRECTORY_SEPARATOR . 'foo.docx';
$this->assertFalse($object->canRead($file));
- $object = PHPWord_IOFactory::load($file);
+ $object = IOFactory::load($file);
}
/**
@@ -62,7 +60,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents')
);
$file = $dir . DIRECTORY_SEPARATOR . 'reader.docx';
- $object = PHPWord_IOFactory::load($file);
- $this->assertInstanceOf('PHPWord', $object);
+ $object = IOFactory::load($file);
+ $this->assertInstanceOf('PhpOffice\\PHPWord', $object);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/Footer/PreserveTextTest.php b/Tests/PHPWord/Section/Footer/PreserveTextTest.php
index 61f84ee5..5cf7ca16 100644
--- a/Tests/PHPWord/Section/Footer/PreserveTextTest.php
+++ b/Tests/PHPWord/Section/Footer/PreserveTextTest.php
@@ -1,15 +1,15 @@
assertInstanceOf('PHPWord_Section_Footer_PreserveText', $oPreserveText);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $oPreserveText);
$this->assertEquals($oPreserveText->getText(), null);
$this->assertEquals($oPreserveText->getFontStyle(), null);
$this->assertEquals($oPreserveText->getParagraphStyle(), null);
@@ -17,7 +17,7 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
public function testConstructWithString()
{
- $oPreserveText = new PHPWord_Section_Footer_PreserveText('text', 'styleFont', 'styleParagraph');
+ $oPreserveText = new PreserveText('text', 'styleFont', 'styleParagraph');
$this->assertEquals($oPreserveText->getText(), 'text');
$this->assertEquals($oPreserveText->getFontStyle(), 'styleFont');
$this->assertEquals($oPreserveText->getParagraphStyle(), 'styleParagraph');
@@ -25,12 +25,15 @@ class PreserveTextTest extends \PHPUnit_Framework_TestCase
public function testConstructWithArray()
{
- $oPreserveText = new PHPWord_Section_Footer_PreserveText(
+ $oPreserveText = new PreserveText(
'text',
array('align' => 'center'),
array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
);
- $this->assertInstanceOf('PHPWord_Style_Font', $oPreserveText->getFontStyle());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oPreserveText->getParagraphStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oPreserveText->getFontStyle());
+ $this->assertInstanceOf(
+ 'PhpOffice\\PhpWord\\Style\\Paragraph',
+ $oPreserveText->getParagraphStyle()
+ );
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/FooterTest.php b/Tests/PHPWord/Section/FooterTest.php
index 10751d0e..92439989 100644
--- a/Tests/PHPWord/Section/FooterTest.php
+++ b/Tests/PHPWord/Section/FooterTest.php
@@ -1,22 +1,22 @@
assertInstanceOf('PHPWord_Section_Footer', $oFooter);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer', $oFooter);
$this->assertEquals($oFooter->getFooterCount(), $iVal);
}
public function testRelationID()
{
- $oFooter = new PHPWord_Section_Footer(0);
+ $oFooter = new Footer(0);
$iVal = rand(1, 1000);
$oFooter->setRelationId($iVal);
@@ -25,27 +25,27 @@ class FooterTest extends \PHPUnit_Framework_TestCase
public function testAddText()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addText('text');
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
}
public function testAddTextNotUTF8()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addText(utf8_decode('ééé'));
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddTextBreak()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$iVal = rand(1, 1000);
$oFooter->addTextBreak($iVal);
@@ -54,20 +54,20 @@ class FooterTest extends \PHPUnit_Framework_TestCase
public function testCreateTextRun()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->createTextRun();
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_TextRun', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element);
}
public function testAddTable()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addTable();
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Table', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $element);
}
public function testAddImage()
@@ -76,47 +76,47 @@ class FooterTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addImage($src);
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testAddMemoryImage()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addMemoryImage(
'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
);
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element);
}
public function testAddPreserveText()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addPreserveText('text');
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
}
public function testAddPreserveTextNotUTF8()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$element = $oFooter->addPreserveText(utf8_decode('ééé'));
$this->assertCount(1, $oFooter->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
$this->assertEquals($element->getText(), 'ééé');
}
public function testGetElements()
{
- $oFooter = new PHPWord_Section_Footer(1);
+ $oFooter = new Footer(1);
$this->assertInternalType('array', $oFooter->getElements());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/FootnoteTest.php b/Tests/PHPWord/Section/FootnoteTest.php
index bd991278..0b66ccf3 100644
--- a/Tests/PHPWord/Section/FootnoteTest.php
+++ b/Tests/PHPWord/Section/FootnoteTest.php
@@ -1,54 +1,57 @@
assertInstanceOf('PHPWord_Section_Footnote', $oFootnote);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footnote', $oFootnote);
$this->assertCount(0, $oFootnote->getElements());
$this->assertEquals($oFootnote->getParagraphStyle(), null);
}
public function testConstructString()
{
- $oFootnote = new PHPWord_Section_Footnote('pStyle');
+ $oFootnote = new Footnote('pStyle');
$this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
}
public function testConstructArray()
{
- $oFootnote = new PHPWord_Section_Footnote(array('spacing' => 100));
+ $oFootnote = new Footnote(array('spacing' => 100));
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oFootnote->getParagraphStyle());
+ $this->assertInstanceOf(
+ 'PhpOffice\\PhpWord\\Style\\Paragraph',
+ $oFootnote->getParagraphStyle()
+ );
}
public function testAddText()
{
- $oFootnote = new PHPWord_Section_Footnote();
+ $oFootnote = new Footnote();
$element = $oFootnote->addText('text');
$this->assertCount(1, $oFootnote->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
}
public function testAddLink()
{
- $oFootnote = new PHPWord_Section_Footnote();
+ $oFootnote = new Footnote();
$element = $oFootnote->addLink('http://www.google.fr');
$this->assertCount(1, $oFootnote->getElements());
- $this->assertInstanceOf('PHPWord_Section_Link', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element);
}
public function testReferenceId()
{
- $oFootnote = new PHPWord_Section_Footnote();
+ $oFootnote = new Footnote();
$iVal = rand(1, 1000);
$oFootnote->setReferenceId($iVal);
@@ -57,7 +60,7 @@ class FootnoteTest extends \PHPUnit_Framework_TestCase
public function testGetElements()
{
- $oFootnote = new PHPWord_Section_Footnote();
+ $oFootnote = new Footnote();
$this->assertInternalType('array', $oFootnote->getElements());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/HeaderTest.php b/Tests/PHPWord/Section/HeaderTest.php
index 527ad3ee..90b43222 100644
--- a/Tests/PHPWord/Section/HeaderTest.php
+++ b/Tests/PHPWord/Section/HeaderTest.php
@@ -1,50 +1,50 @@
assertInstanceOf('PHPWord_Section_Header', $oHeader);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Header', $oHeader);
$this->assertEquals($oHeader->getHeaderCount(), $iVal);
- $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO);
+ $this->assertEquals($oHeader->getType(), Header::AUTO);
}
public function testAddText()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addText('text');
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertCount(1, $oHeader->getElements());
$this->assertEquals($element->getText(), 'text');
}
public function testAddTextNotUTF8()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addText(utf8_decode('ééé'));
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertCount(1, $oHeader->getElements());
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddTextBreak()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$oHeader->addTextBreak();
$this->assertCount(1, $oHeader->getElements());
}
public function testAddTextBreakWithParams()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$iVal = rand(1, 1000);
$oHeader->addTextBreak($iVal);
$this->assertCount($iVal, $oHeader->getElements());
@@ -52,17 +52,17 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
public function testCreateTextRun()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->createTextRun();
- $this->assertInstanceOf('PHPWord_Section_TextRun', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element);
$this->assertCount(1, $oHeader->getElements());
}
public function testAddTable()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addTable();
- $this->assertInstanceOf('PHPWord_Section_Table', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $element);
$this->assertCount(1, $oHeader->getElements());
}
@@ -72,40 +72,40 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addImage($src);
$this->assertCount(1, $oHeader->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testAddMemoryImage()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addMemoryImage(
'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
);
$this->assertCount(1, $oHeader->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element);
}
public function testAddPreserveText()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addPreserveText('text');
$this->assertCount(1, $oHeader->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
}
public function testAddPreserveTextNotUTF8()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addPreserveText(utf8_decode('ééé'));
$this->assertCount(1, $oHeader->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
$this->assertEquals($element->getText(), 'ééé');
}
@@ -115,23 +115,23 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$element = $oHeader->addWatermark($src);
$this->assertCount(1, $oHeader->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testGetElements()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$this->assertInternalType('array', $oHeader->getElements());
}
public function testRelationId()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$iVal = rand(1, 1000);
$oHeader->setRelationId($iVal);
@@ -140,26 +140,26 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
public function testResetType()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$oHeader->firstPage();
$oHeader->resetType();
- $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::AUTO);
+ $this->assertEquals($oHeader->getType(), Header::AUTO);
}
public function testFirstPage()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$oHeader->firstPage();
- $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::FIRST);
+ $this->assertEquals($oHeader->getType(), Header::FIRST);
}
public function testEvenPage()
{
- $oHeader = new PHPWord_Section_Header(1);
+ $oHeader = new Header(1);
$oHeader->evenPage();
- $this->assertEquals($oHeader->getType(), PHPWord_Section_Header::EVEN);
+ $this->assertEquals($oHeader->getType(), Header::EVEN);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/ImageTest.php b/Tests/PHPWord/Section/ImageTest.php
index 50cc4d2a..4f4dbde8 100644
--- a/Tests/PHPWord/Section/ImageTest.php
+++ b/Tests/PHPWord/Section/ImageTest.php
@@ -1,9 +1,11 @@
assertInstanceOf('PHPWord_Section_Image', $oImage);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $oImage);
$this->assertEquals($oImage->getSource(), $src);
$this->assertEquals($oImage->getMediaId(), md5($src));
$this->assertEquals($oImage->getIsWatermark(), false);
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
}
public function testConstructWithStyle()
@@ -27,59 +29,59 @@ class ImageTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'firefox.png')
);
- $oImage = new PHPWord_Section_Image(
+ $oImage = new Image(
$src,
array('width' => 210, 'height' => 210, 'align' => 'center',
- 'wrappingStyle' => \PHPWord_Style_Image::WRAPPING_STYLE_BEHIND)
+ 'wrappingStyle' => PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND)
);
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
}
/**
- * @covers PHPWord_Section_Image::__construct
+ * @covers ::__construct
*/
public function testValidImageTypes()
{
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp");
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif");
}
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\InvalidImageException
- * @covers PHPWord_Section_Image::__construct
+ * @expectedException PhpOffice\PhpWord\Exceptions\InvalidImageException
+ * @covers ::__construct
*/
public function testImageNotFound()
{
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/thisisnotarealimage");
}
/**
- * @expectedException \PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
- * @covers PHPWord_Section_Image::__construct
+ * @expectedException PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException
+ * @covers ::__construct
*/
public function testInvalidImageTypes()
{
- new PHPWord_Section_Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx");
+ new Image(PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx");
}
public function testStyle()
{
- $oImage = new PHPWord_Section_Image(\join(
+ $oImage = new Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
), array('width' => 210, 'height' => 210, 'align' => 'center'));
- $this->assertInstanceOf('PHPWord_Style_Image', $oImage->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
}
public function testRelationID()
{
- $oImage = new PHPWord_Section_Image(\join(
+ $oImage = new Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
));
@@ -91,7 +93,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase
public function testWatermark()
{
- $oImage = new PHPWord_Section_Image(\join(
+ $oImage = new Image(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
));
@@ -99,4 +101,4 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$oImage->setIsWatermark(true);
$this->assertEquals($oImage->getIsWatermark(), true);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/LinkTest.php b/Tests/PHPWord/Section/LinkTest.php
index 413b23fe..5e93fc1e 100644
--- a/Tests/PHPWord/Section/LinkTest.php
+++ b/Tests/PHPWord/Section/LinkTest.php
@@ -1,16 +1,16 @@
assertInstanceOf('PHPWord_Section_Link', $oLink);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $oLink);
$this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com');
$this->assertEquals($oLink->getLinkName(), null);
$this->assertEquals($oLink->getFontStyle(), null);
@@ -19,23 +19,23 @@ class LinkTest extends \PHPUnit_Framework_TestCase
public function testConstructWithParamsArray()
{
- $oLink = new PHPWord_Section_Link(
+ $oLink = new Link(
'http://www.google.com',
'Search Engine',
- array('color' => '0000FF', 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE),
+ array('color' => '0000FF', 'underline' => Font::UNDERLINE_SINGLE),
array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
);
- $this->assertInstanceOf('PHPWord_Section_Link', $oLink);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $oLink);
$this->assertEquals($oLink->getLinkSrc(), 'http://www.google.com');
$this->assertEquals($oLink->getLinkName(), 'Search Engine');
- $this->assertInstanceOf('PHPWord_Style_Font', $oLink->getFontStyle());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oLink->getParagraphStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oLink->getFontStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle());
}
public function testConstructWithParamsString()
{
- $oLink = new PHPWord_Section_Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle');
+ $oLink = new Link('http://www.google.com', null, 'fontStyle', 'paragraphStyle');
$this->assertEquals($oLink->getFontStyle(), 'fontStyle');
$this->assertEquals($oLink->getParagraphStyle(), 'paragraphStyle');
@@ -43,10 +43,10 @@ class LinkTest extends \PHPUnit_Framework_TestCase
public function testRelationId()
{
- $oLink = new PHPWord_Section_Link('http://www.google.com');
+ $oLink = new Link('http://www.google.com');
$iVal = rand(1, 1000);
$oLink->setRelationId($iVal);
$this->assertEquals($oLink->getRelationId(), $iVal);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/ListItemTest.php b/Tests/PHPWord/Section/ListItemTest.php
index a2a4d438..2719c9be 100644
--- a/Tests/PHPWord/Section/ListItemTest.php
+++ b/Tests/PHPWord/Section/ListItemTest.php
@@ -1,36 +1,38 @@
assertInstanceOf('PHPWord_Section_Text', $oListItem->getTextObject());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oListItem->getTextObject());
}
public function testStyle()
{
- $oListItem = new PHPWord_Section_ListItem(
+ $oListItem = new ListItem(
'text',
1,
null,
- array('listType' => PHPWord_Style_ListItem::TYPE_NUMBER)
+ array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER)
);
- $this->assertInstanceOf('PHPWord_Style_ListItem', $oListItem->getStyle());
- $this->assertEquals($oListItem->getStyle()->getListType(), PHPWord_Style_ListItem::TYPE_NUMBER);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\ListItem', $oListItem->getStyle());
+ $this->assertEquals(
+ $oListItem->getStyle()->getListType(),
+ PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER
+ );
}
public function testDepth()
{
$iVal = rand(1, 1000);
- $oListItem = new PHPWord_Section_ListItem('text', $iVal);
+ $oListItem = new ListItem('text', $iVal);
$this->assertEquals($oListItem->getDepth(), $iVal);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/MemoryImageTest.php b/Tests/PHPWord/Section/MemoryImageTest.php
index 3bfb39e3..d6fe8a45 100644
--- a/Tests/PHPWord/Section/MemoryImageTest.php
+++ b/Tests/PHPWord/Section/MemoryImageTest.php
@@ -1,7 +1,7 @@
assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefrompng');
@@ -28,9 +28,9 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'mario.gif')
);
- $oMemoryImage = new PHPWord_Section_MemoryImage($src);
+ $oMemoryImage = new MemoryImage($src);
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromgif');
@@ -45,9 +45,9 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oMemoryImage = new PHPWord_Section_MemoryImage($src);
+ $oMemoryImage = new MemoryImage($src);
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getSource(), $src);
$this->assertEquals($oMemoryImage->getMediaId(), md5($src));
$this->assertEquals($oMemoryImage->getImageCreateFunction(), 'imagecreatefromjpeg');
@@ -58,12 +58,12 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase
public function testBMP()
{
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
+ $oMemoryImage = new MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'duke_nukem.bmp')
));
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $oMemoryImage);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage);
$this->assertEquals($oMemoryImage->getImageCreateFunction(), null);
$this->assertEquals($oMemoryImage->getImageFunction(), null);
$this->assertEquals($oMemoryImage->getImageExtension(), null);
@@ -72,17 +72,17 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase
public function testStyle()
{
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
+ $oMemoryImage = new MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
), array('width' => 210, 'height' => 210, 'align' => 'center'));
- $this->assertInstanceOf('PHPWord_Style_Image', $oMemoryImage->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oMemoryImage->getStyle());
}
public function testRelationID()
{
- $oMemoryImage = new PHPWord_Section_MemoryImage(\join(
+ $oMemoryImage = new MemoryImage(\join(
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
));
@@ -91,4 +91,4 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase
$oMemoryImage->setRelationId($iVal);
$this->assertEquals($oMemoryImage->getRelationId(), $iVal);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/ObjectTest.php b/Tests/PHPWord/Section/ObjectTest.php
index b72f2484..df1c7461 100644
--- a/Tests/PHPWord/Section/ObjectTest.php
+++ b/Tests/PHPWord/Section/ObjectTest.php
@@ -1,7 +1,7 @@
assertInstanceOf('PHPWord_Section_Object', $oObject);
- $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle());
$this->assertEquals($oObject->getSource(), $src);
}
@@ -24,9 +24,9 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'xsl', 'passthrough.xsl')
);
- $oObject = new PHPWord_Section_Object($src);
+ $oObject = new Object($src);
- $this->assertInstanceOf('PHPWord_Section_Object', $oObject);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject);
$this->assertEquals($oObject->getSource(), null);
$this->assertEquals($oObject->getStyle(), null);
}
@@ -37,10 +37,10 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $oObject = new PHPWord_Section_Object($src, array('width' => '230px'));
+ $oObject = new Object($src, array('width' => '230px'));
- $this->assertInstanceOf('PHPWord_Section_Object', $oObject);
- $this->assertInstanceOf('PHPWord_Style_Image', $oObject->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle());
$this->assertEquals($oObject->getSource(), $src);
}
@@ -50,7 +50,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $oObject = new PHPWord_Section_Object($src);
+ $oObject = new Object($src);
$iVal = rand(1, 1000);
$oObject->setRelationId($iVal);
@@ -63,7 +63,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $oObject = new PHPWord_Section_Object($src);
+ $oObject = new Object($src);
$iVal = rand(1, 1000);
$oObject->setImageRelationId($iVal);
@@ -76,10 +76,10 @@ class ObjectTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $oObject = new PHPWord_Section_Object($src);
+ $oObject = new Object($src);
$iVal = rand(1, 1000);
$oObject->setObjectId($iVal);
$this->assertEquals($oObject->getObjectId(), $iVal);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/PageBreakTest.php b/Tests/PHPWord/Section/PageBreakTest.php
index 5efd0fe9..24bb835d 100644
--- a/Tests/PHPWord/Section/PageBreakTest.php
+++ b/Tests/PHPWord/Section/PageBreakTest.php
@@ -1,7 +1,7 @@
assertInstanceOf('PHPWord_Section_PageBreak', $oPageBreak);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\PageBreak', $oPageBreak);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/SettingsTest.php b/Tests/PHPWord/Section/SettingsTest.php
index 92e84654..4c4c557c 100644
--- a/Tests/PHPWord/Section/SettingsTest.php
+++ b/Tests/PHPWord/Section/SettingsTest.php
@@ -1,7 +1,7 @@
setSettingValue('_orientation', 'landscape');
$this->assertEquals('landscape', $oSettings->getOrientation());
@@ -46,7 +46,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testMargin()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$iVal = rand(1, 1000);
$oSettings->setMarginTop($iVal);
@@ -68,7 +68,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testOrientationLandscape()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$oSettings->setLandscape();
$this->assertEquals('landscape', $oSettings->getOrientation());
@@ -79,7 +79,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testOrientationPortrait()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$oSettings->setPortrait();
$this->assertNull($oSettings->getOrientation());
@@ -90,7 +90,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testBorderSize()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$iVal = rand(1, 1000);
$oSettings->setBorderSize($iVal);
@@ -120,7 +120,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testBorderColor()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$oSettings->setBorderColor('FF00AA');
$this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor());
@@ -145,7 +145,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testNumberingStart()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$this->assertNull($oSettings->getPageNumberingStart());
@@ -160,7 +160,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testHeader()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$this->assertEquals(720, $oSettings->getHeaderHeight());
@@ -175,7 +175,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testFooter()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$this->assertEquals(720, $oSettings->getFooterHeight());
@@ -190,7 +190,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testColumnsNum()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
// Default
$this->assertEquals(1, $oSettings->getColsNum());
@@ -206,23 +206,23 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testColumnsSpace()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
// Default
$this->assertEquals(720, $oSettings->getColsSpace());
$iVal = rand(1, 1000);
- $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace($iVal));
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Settings', $oSettings->setColsSpace($iVal));
$this->assertEquals($iVal, $oSettings->getColsSpace());
- $this->assertInstanceOf('PHPWord_Section_Settings', $oSettings->setColsSpace());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Settings', $oSettings->setColsSpace());
$this->assertEquals(720, $oSettings->getColsSpace());
}
public function testBreakType()
{
// Section Settings
- $oSettings = new PHPWord_Section_Settings();
+ $oSettings = new Settings();
$this->assertNull($oSettings->getBreakType());
@@ -232,4 +232,4 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$oSettings->setBreakType();
$this->assertNull($oSettings->getBreakType());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/Table/CellTest.php b/Tests/PHPWord/Section/Table/CellTest.php
index 30a7fcdb..3eb2bf04 100644
--- a/Tests/PHPWord/Section/Table/CellTest.php
+++ b/Tests/PHPWord/Section/Table/CellTest.php
@@ -1,67 +1,67 @@
assertInstanceOf('PHPWord_Section_Table_Cell', $oCell);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $oCell);
$this->assertEquals($oCell->getWidth(), null);
}
public function testConstructWithStyleArray()
{
$iVal = rand(1, 1000);
- $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, array('valign' => 'center'));
+ $oCell = new Cell('section', $iVal, null, array('valign' => 'center'));
- $this->assertInstanceOf('PHPWord_Style_Cell', $oCell->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Cell', $oCell->getStyle());
$this->assertEquals($oCell->getWidth(), null);
}
public function testConstructWithStyleString()
{
$iVal = rand(1, 1000);
- $oCell = new PHPWord_Section_Table_Cell('section', $iVal, null, 'cellStyle');
+ $oCell = new Cell('section', $iVal, null, 'cellStyle');
$this->assertEquals($oCell->getStyle(), 'cellStyle');
}
public function testAddText()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addText('text');
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
}
public function testAddTextNotUTF8()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addText(utf8_decode('ééé'));
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddLink()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addLink('http://www.google.fr', 'Nom');
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Link', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element);
}
public function testAddTextBreak()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$oCell->addTextBreak();
$this->assertCount(1, $oCell->getElements());
@@ -69,21 +69,21 @@ class CellTest extends \PHPUnit_Framework_TestCase
public function testAddListItem()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addListItem('text');
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_ListItem', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\ListItem', $element);
$this->assertEquals($element->getTextObject()->getText(), 'text');
}
public function testAddListItemNotUTF8()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addListItem(utf8_decode('ééé'));
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_ListItem', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\ListItem', $element);
$this->assertEquals($element->getTextObject()->getText(), 'ééé');
}
@@ -93,11 +93,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addImage($src);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testAddImageHeader()
@@ -106,11 +106,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
+ $oCell = new Cell('header', 1);
$element = $oCell->addImage($src);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testAddImageFooter()
@@ -119,44 +119,44 @@ class CellTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oCell = new PHPWord_Section_Table_Cell('footer', 1);
+ $oCell = new Cell('footer', 1);
$element = $oCell->addImage($src);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
}
public function testAddMemoryImageSection()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addMemoryImage(
'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element);
}
public function testAddMemoryImageHeader()
{
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
+ $oCell = new Cell('header', 1);
$element = $oCell->addMemoryImage(
'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element);
}
public function testAddMemoryImageFooter()
{
- $oCell = new PHPWord_Section_Table_Cell('footer', 1);
+ $oCell = new Cell('footer', 1);
$element = $oCell->addMemoryImage(
'https://assets.mozillalabs.com/Brands-Logos/Thunderbird/logo-only/thunderbird_logo-only_RGB.png'
);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_MemoryImage', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $element);
}
public function testAddObjectXLS()
@@ -165,45 +165,45 @@ class CellTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->addObject($src);
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Object', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $element);
}
public function testAddPreserveText()
{
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
+ $oCell = new Cell('header', 1);
$element = $oCell->addPreserveText('text');
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
}
public function testAddPreserveTextNotUTF8()
{
- $oCell = new PHPWord_Section_Table_Cell('header', 1);
+ $oCell = new Cell('header', 1);
$element = $oCell->addPreserveText(utf8_decode('ééé'));
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_Footer_PreserveText', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footer\\PreserveText', $element);
$this->assertEquals($element->getText(), 'ééé');
}
public function testCreateTextRun()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$element = $oCell->createTextRun();
$this->assertCount(1, $oCell->getElements());
- $this->assertInstanceOf('PHPWord_Section_TextRun', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $element);
}
public function testGetElements()
{
- $oCell = new PHPWord_Section_Table_Cell('section', 1);
+ $oCell = new Cell('section', 1);
$this->assertInternalType('array', $oCell->getElements());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/Table/RowTest.php b/Tests/PHPWord/Section/Table/RowTest.php
index e62a5bd9..8702a038 100644
--- a/Tests/PHPWord/Section/Table/RowTest.php
+++ b/Tests/PHPWord/Section/Table/RowTest.php
@@ -1,27 +1,27 @@
assertInstanceOf('PHPWord_Section_Table_Row', $oRow);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Row', $oRow);
$this->assertEquals($oRow->getHeight(), null);
$this->assertInternalType('array', $oRow->getCells());
$this->assertCount(0, $oRow->getCells());
- $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle());
}
public function testConstructWithParams()
{
$iVal = rand(1, 1000);
$iVal2 = rand(1, 1000);
- $oRow = new PHPWord_Section_Table_Row(
+ $oRow = new Row(
'section',
$iVal,
$iVal2,
@@ -29,15 +29,15 @@ class RowTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals($oRow->getHeight(), $iVal2);
- $this->assertInstanceOf('PHPWord_Style_Row', $oRow->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Row', $oRow->getStyle());
}
public function testAddCell()
{
- $oRow = new PHPWord_Section_Table_Row('section', 1);
+ $oRow = new Row('section', 1);
$element = $oRow->addCell();
- $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $element);
$this->assertCount(1, $oRow->getCells());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/TableTest.php b/Tests/PHPWord/Section/TableTest.php
index 167f1190..961031b5 100644
--- a/Tests/PHPWord/Section/TableTest.php
+++ b/Tests/PHPWord/Section/TableTest.php
@@ -1,15 +1,15 @@
assertInstanceOf('PHPWord_Section_Table', $oTable);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $oTable);
$this->assertEquals($oTable->getStyle(), null);
$this->assertEquals($oTable->getWidth(), null);
$this->assertEquals($oTable->getRows(), array());
@@ -18,25 +18,25 @@ class TableTest extends \PHPUnit_Framework_TestCase
public function testStyleText()
{
- $oTable = new PHPWord_Section_Table('section', 1, 'tableStyle');
+ $oTable = new Table('section', 1, 'tableStyle');
$this->assertEquals($oTable->getStyle(), 'tableStyle');
}
public function testStyleArray()
{
- $oTable = new PHPWord_Section_Table(
+ $oTable = new Table(
'section',
1,
array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80)
);
- $this->assertInstanceOf('PHPWord_Style_Table', $oTable->getStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $oTable->getStyle());
}
public function testWidth()
{
- $oTable = new PHPWord_Section_Table('section', 1);
+ $oTable = new Table('section', 1);
$iVal = rand(1, 1000);
$oTable->setWidth($iVal);
$this->assertEquals($oTable->getWidth(), $iVal);
@@ -44,17 +44,17 @@ class TableTest extends \PHPUnit_Framework_TestCase
public function testRow()
{
- $oTable = new PHPWord_Section_Table('section', 1);
+ $oTable = new Table('section', 1);
$element = $oTable->addRow();
- $this->assertInstanceOf('PHPWord_Section_Table_Row', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Row', $element);
$this->assertCount(1, $oTable->getRows());
}
public function testCell()
{
- $oTable = new PHPWord_Section_Table('section', 1);
+ $oTable = new Table('section', 1);
$oTable->addRow();
$element = $oTable->addCell();
- $this->assertInstanceOf('PHPWord_Section_Table_Cell', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $element);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/TextBreakTest.php b/Tests/PHPWord/Section/TextBreakTest.php
index 761c04a3..1d02c2f1 100644
--- a/Tests/PHPWord/Section/TextBreakTest.php
+++ b/Tests/PHPWord/Section/TextBreakTest.php
@@ -1,13 +1,13 @@
assertNull($object->getFontStyle());
$this->assertNull($object->getParagraphStyle());
}
@@ -27,9 +27,9 @@ class TextBreakTest extends \PHPUnit_Framework_TestCase
*/
public function testConstructWithStyleObject()
{
- $fStyle = new PHPWord_Style_Font();
- $pStyle = new PHPWord_Style_Paragraph();
- $object = new PHPWord_Section_TextBreak($fStyle, $pStyle);
+ $fStyle = new Font();
+ $pStyle = new Paragraph();
+ $object = new TextBreak($fStyle, $pStyle);
$this->assertEquals($fStyle, $object->getFontStyle());
$this->assertEquals($pStyle, $object->getParagraphStyle());
}
@@ -41,9 +41,9 @@ class TextBreakTest extends \PHPUnit_Framework_TestCase
{
$fStyle = array('size' => 12);
$pStyle = array('spacing' => 240);
- $object = new PHPWord_Section_TextBreak($fStyle, $pStyle);
- $this->assertInstanceOf('PHPWord_Style_Font', $object->getFontStyle());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $object->getParagraphStyle());
+ $object = new TextBreak($fStyle, $pStyle);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $object->getFontStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
}
/**
@@ -53,8 +53,8 @@ class TextBreakTest extends \PHPUnit_Framework_TestCase
{
$fStyle = 'fStyle';
$pStyle = 'pStyle';
- $object = new PHPWord_Section_TextBreak($fStyle, $pStyle);
+ $object = new TextBreak($fStyle, $pStyle);
$this->assertEquals($fStyle, $object->getFontStyle());
$this->assertEquals($pStyle, $object->getParagraphStyle());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/TextRunTest.php b/Tests/PHPWord/Section/TextRunTest.php
index 81402476..234e14ac 100644
--- a/Tests/PHPWord/Section/TextRunTest.php
+++ b/Tests/PHPWord/Section/TextRunTest.php
@@ -1,73 +1,73 @@
assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
$this->assertEquals($oTextRun->getParagraphStyle(), null);
}
public function testConstructString()
{
- $oTextRun = new PHPWord_Section_TextRun('pStyle');
+ $oTextRun = new TextRun('pStyle');
- $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
$this->assertEquals($oTextRun->getParagraphStyle(), 'pStyle');
}
public function testConstructArray()
{
- $oTextRun = new PHPWord_Section_TextRun(array('spacing' => 100));
+ $oTextRun = new TextRun(array('spacing' => 100));
- $this->assertInstanceOf('PHPWord_Section_TextRun', $oTextRun);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\TextRun', $oTextRun);
$this->assertCount(0, $oTextRun->getElements());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oTextRun->getParagraphStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oTextRun->getParagraphStyle());
}
public function testAddText()
{
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->addText('text');
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getText(), 'text');
}
public function testAddTextNotUTF8()
{
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->addText(utf8_decode('ééé'));
- $this->assertInstanceOf('PHPWord_Section_Text', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element);
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getText(), 'ééé');
}
public function testAddLink()
{
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->addLink('http://www.google.fr');
- $this->assertInstanceOf('PHPWord_Section_Link', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element);
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getLinkSrc(), 'http://www.google.fr');
}
public function testAddLinkWithName()
{
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->addLink('http://www.google.fr', utf8_decode('ééé'));
- $this->assertInstanceOf('PHPWord_Section_Link', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Link', $element);
$this->assertCount(1, $oTextRun->getElements());
$this->assertEquals($element->getLinkSrc(), 'http://www.google.fr');
$this->assertEquals($element->getLinkName(), 'ééé');
@@ -79,19 +79,19 @@ class TextRunTest extends \PHPUnit_Framework_TestCase
\DIRECTORY_SEPARATOR,
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->addImage($src);
- $this->assertInstanceOf('PHPWord_Section_Image', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $element);
$this->assertCount(1, $oTextRun->getElements());
}
public function testCreateFootnote()
{
- $oTextRun = new PHPWord_Section_TextRun();
+ $oTextRun = new TextRun();
$element = $oTextRun->createFootnote();
- $this->assertInstanceOf('PHPWord_Section_Footnote', $element);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Footnote', $element);
$this->assertCount(1, $oTextRun->getElements());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/TextTest.php b/Tests/PHPWord/Section/TextTest.php
index 1a33a730..0082e68e 100644
--- a/Tests/PHPWord/Section/TextTest.php
+++ b/Tests/PHPWord/Section/TextTest.php
@@ -1,42 +1,42 @@
assertInstanceOf('PHPWord_Section_Text', $oText);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $oText);
$this->assertEquals(null, $oText->getText());
- $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle());
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
}
public function testText()
{
- $oText = new PHPWord_Section_Text('text');
+ $oText = new Text('text');
$this->assertEquals($oText->getText(), 'text');
}
public function testFont()
{
- $oText = new PHPWord_Section_Text('text', 'fontStyle');
+ $oText = new Text('text', 'fontStyle');
$this->assertEquals($oText->getFontStyle(), 'fontStyle');
$oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
- $this->assertInstanceOf('PHPWord_Style_Font', $oText->getFontStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
}
public function testParagraph()
{
- $oText = new PHPWord_Section_Text('text', 'fontStyle', 'paragraphStyle');
+ $oText = new Text('text', 'fontStyle', 'paragraphStyle');
$this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle');
$oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
- $this->assertInstanceOf('PHPWord_Style_Paragraph', $oText->getParagraphStyle());
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/Section/TitleTest.php b/Tests/PHPWord/Section/TitleTest.php
index 97ce5de6..a874c6a6 100644
--- a/Tests/PHPWord/Section/TitleTest.php
+++ b/Tests/PHPWord/Section/TitleTest.php
@@ -1,35 +1,35 @@
assertInstanceOf('PHPWord_Section_Title', $oTitle);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Title', $oTitle);
$this->assertEquals($oTitle->getText(), 'text');
}
public function testStyleNull()
{
- $oTitle = new PHPWord_Section_Title('text');
+ $oTitle = new Title('text');
$this->assertEquals($oTitle->getStyle(), null);
}
public function testStyleNotNull()
{
- $oTitle = new PHPWord_Section_Title('text', 1, 'style');
+ $oTitle = new Title('text', 1, 'style');
$this->assertEquals($oTitle->getStyle(), 'style');
}
public function testAnchor()
{
- $oTitle = new PHPWord_Section_Title('text');
+ $oTitle = new Title('text');
$iVal = rand(1, 1000);
$oTitle->setAnchor($iVal);
@@ -38,10 +38,10 @@ class TitleTest extends \PHPUnit_Framework_TestCase
public function testBookmarkID()
{
- $oTitle = new PHPWord_Section_Title('text');
+ $oTitle = new Title('text');
$iVal = rand(1, 1000);
$oTitle->setBookmarkId($iVal);
$this->assertEquals($oTitle->getBookmarkId(), $iVal);
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/SectionTest.php b/Tests/PHPWord/SectionTest.php
index ac540d06..559a345e 100644
--- a/Tests/PHPWord/SectionTest.php
+++ b/Tests/PHPWord/SectionTest.php
@@ -1,78 +1,76 @@
assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0));
+ $oSection = new Section(0);
+ $this->assertAttributeEquals($oSection->getSettings(), '_settings', new Section(0));
}
/**
- * @covers PHPWord_Section::getElements
+ * @covers ::getElements
*/
public function testGetElements()
{
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new PHPWord_Section(0));
+ $oSection = new Section(0);
+ $this->assertAttributeEquals($oSection->getElements(), '_elementCollection', new Section(0));
}
/**
- * @covers PHPWord_Section::getFooter
+ * @covers ::getFooter
*/
public function testGetFooter()
{
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getFooter(), '_footer', new PHPWord_Section(0));
+ $oSection = new Section(0);
+ $this->assertAttributeEquals($oSection->getFooter(), '_footer', new Section(0));
}
/**
- * @covers PHPWord_Section::getHeaders
+ * @covers ::getHeaders
*/
public function testGetHeaders()
{
- $oSection = new PHPWord_Section(0);
- $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new PHPWord_Section(0));
+ $oSection = new Section(0);
+ $this->assertAttributeEquals($oSection->getHeaders(), '_headers', new Section(0));
}
/**
- * @covers PHPWord_Section::setSettings
+ * @covers ::setSettings
*/
public function testSetSettings()
{
$expected = 'landscape';
- $object = new PHPWord_Section(0);
+ $object = new Section(0);
$object->setSettings(array('orientation' => $expected));
$this->assertEquals($expected, $object->getSettings()->getOrientation());
}
/**
- * @covers PHPWord_Section::addText
- * @covers PHPWord_Section::addLink
- * @covers PHPWord_Section::addTextBreak
- * @covers PHPWord_Section::addPageBreak
- * @covers PHPWord_Section::addTable
- * @covers PHPWord_Section::addListItem
- * @covers PHPWord_Section::addObject
- * @covers PHPWord_Section::addImage
- * @covers PHPWord_Section::addMemoryImage
- * @covers PHPWord_Section::addTOC
- * @covers PHPWord_Section::addTitle
- * @covers PHPWord_Section::createTextRun
- * @covers PHPWord_Section::createFootnote
+ * @covers ::addText
+ * @covers ::addLink
+ * @covers ::addTextBreak
+ * @covers ::addPageBreak
+ * @covers ::addTable
+ * @covers ::addListItem
+ * @covers ::addObject
+ * @covers ::addImage
+ * @covers ::addMemoryImage
+ * @covers ::addTOC
+ * @covers ::addTitle
+ * @covers ::createTextRun
+ * @covers ::createFootnote
*/
public function testAddElements()
{
@@ -86,7 +84,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
);
$imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif';
- $section = new PHPWord_Section(0);
+ $section = new Section(0);
$section->addText(utf8_decode('ä'));
$section->addLink(utf8_decode('http://äää.com'), utf8_decode('ä'));
$section->addTextBreak();
@@ -103,8 +101,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$elementCollection = $section->getElements();
$elementType = 'Link';
- $objectType = "PHPWord_Section_{$elementType}";
- $this->assertInstanceOf($objectType, $elementCollection[1]);
+ $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[1]);
// $elementTypes = array('Text', 'Link', 'TextBreak', 'PageBreak',
// 'Table', 'ListItem', 'Object', 'Image', 'MemoryImage', 'TOC',
// 'Title', 'TextRun');
@@ -117,17 +114,16 @@ class SectionTest extends \PHPUnit_Framework_TestCase
}
/**
- * @covers PHPWord_Section::createHeader
- * @covers PHPWord_Section::createFooter
+ * @covers ::createHeader
+ * @covers ::createFooter
*/
public function testCreateHeaderFooter()
{
- $object = new PHPWord_Section(0);
+ $object = new Section(0);
$elements = array('Header', 'Footer');
foreach ($elements as $element) {
- $objectType = "PHPWord_Section_{$element}";
$method = "create{$element}";
- $this->assertInstanceOf($objectType, $object->$method());
+ $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$element}", $object->$method());
}
}
-}
+}
\ No newline at end of file
diff --git a/Tests/PHPWord/SettingsTest.php b/Tests/PHPWord/SettingsTest.php
index e61a2129..27194ca2 100644
--- a/Tests/PHPWord/SettingsTest.php
+++ b/Tests/PHPWord/SettingsTest.php
@@ -1,26 +1,24 @@
assertTrue(PHPWord_Settings::getCompatibility());
- $this->assertTrue(PHPWord_Settings::setCompatibility(false));
- $this->assertFalse(PHPWord_Settings::getCompatibility());
- $this->assertFalse(PHPWord_Settings::setCompatibility('Non boolean'));
+ $this->assertTrue(Settings::getCompatibility());
+ $this->assertTrue(Settings::setCompatibility(false));
+ $this->assertFalse(Settings::getCompatibility());
+ $this->assertFalse(Settings::setCompatibility('Non boolean'));
}
-}
+}
\ No newline at end of file