diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php
index edc4e93a..c2986a70 100755
--- a/Classes/PHPWord.php
+++ b/Classes/PHPWord.php
@@ -1,8 +1,8 @@
_properties = new DocumentProperties();
- $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
- $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
+ $this->_documentProperties = new DocumentProperties();
+ $this->_defaultFontName = self::DEFAULT_FONT_NAME;
+ $this->_defaultFontSize = self::DEFAULT_FONT_SIZE;
}
/**
- * Get properties
* @return PhpOffice\PhpWord\DocumentProperties
*/
- public function getProperties()
+ public function getDocumentProperties()
{
- return $this->_properties;
+ return $this->_documentProperties;
}
/**
- * Set properties
- *
- * @param PhpOffice\PhpWord\DocumentProperties $value
- * @return PhpOffice\PHPWord
+ * @param PhpOffice\PhpWord\DocumentProperties $documentProperties
+ * @return PhpOffice\PhpWord
*/
- public function setProperties(DocumentProperties $value)
+ public function setDocumentProperties(DocumentProperties $documentProperties)
{
- $this->_properties = $value;
+ $this->_documentProperties = $documentProperties;
+
return $this;
}
/**
- * Create a new Section
- *
- * @param PhpOffice\PhpWord\Section\Settings $settings
+ * @param PhpOffice\PhpWord\Section\Settings $settings
* @return PhpOffice\PhpWord\Section
*/
public function createSection($settings = null)
{
- $sectionCount = $this->_countSections() + 1;
+ $section = new Section(\count($this->_sections) + 1, $settings);
+ $this->_sections[] = $section;
- $section = new Section($sectionCount, $settings);
- $this->_sectionCollection[] = $section;
return $section;
}
/**
- * Get default Font name
* @return string
*/
public function getDefaultFontName()
@@ -152,16 +122,14 @@ class PhpWord
}
/**
- * Set default Font name
- * @param string $pValue
+ * @param string $fontName
*/
- public function setDefaultFontName($pValue)
+ public function setDefaultFontName($fontName)
{
- $this->_defaultFontName = $pValue;
+ $this->_defaultFontName = $fontName;
}
/**
- * Get default Font size (in points)
* @return string
*/
public function getDefaultFontSize()
@@ -170,18 +138,17 @@ class PhpWord
}
/**
- * Set default Font size (in points)
- * @param int $pValue
+ * @param int $fontSize
*/
- public function setDefaultFontSize($pValue)
+ public function setDefaultFontSize($fontSize)
{
- $this->_defaultFontSize = $pValue;
+ $this->_defaultFontSize = $fontSize;
}
/**
* Set default paragraph style definition to styles.xml
*
- * @param array $styles Paragraph style definition
+ * @param array $styles Paragraph style definition
*/
public function setDefaultParagraphStyle($styles)
{
@@ -244,35 +211,24 @@ class PhpWord
}
/**
- * Get sections
* @return PhpOffice\PhpWord\Section[]
*/
public function getSections()
{
- return $this->_sectionCollection;
+ return $this->_sections;
}
/**
- * Load a Template File
- *
- * @param string $strFilename
+ * @param string $filename Fully qualified filename.
* @return PhpOffice\PhpWord\Template
- * @throws Exception
+ * @throws PhpOffice\PhpWord\Exceptions\Exception
*/
- public function loadTemplate($strFilename)
+ public function loadTemplate($filename)
{
- if (file_exists($strFilename)) {
- return new Template($strFilename);
+ if (\file_exists($filename)) {
+ return new Template($filename);
+ } else {
+ throw new Exception("Template file {$filename} not found.");
}
- throw new Exception("Template file {$strFilename} not found.");
}
-
- /**
- * Get section count
- * @return int
- */
- private function _countSections()
- {
- return count($this->_sectionCollection);
- }
-}
+}
\ No newline at end of file
diff --git a/Classes/PHPWord/Autoloader.php b/Classes/PHPWord/Autoloader.php
index aa36efc8..1a4aa3b3 100755
--- a/Classes/PHPWord/Autoloader.php
+++ b/Classes/PHPWord/Autoloader.php
@@ -1,8 +1,8 @@
open($pFilename) === true) {
// check if it is an OOXML archive
$rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels"));
@@ -78,8 +79,6 @@ class Word2007 extends AbstractReader implements IReader
}
/**
- * Get from zip archive
- *
* @param ZipArchive $archive
* @param string $fileName
* @param bool $removeNamespace
@@ -108,10 +107,10 @@ class Word2007 extends AbstractReader implements IReader
}
/**
- * Loads PHPWord from file
+ * Loads PhpWord from file
*
* @param string $pFilename
- * @return PHPWord|null
+ * @return PhpOffice\PhpWord|null
*/
public function load($pFilename)
{
@@ -121,8 +120,8 @@ class Word2007 extends AbstractReader implements IReader
}
// Initialisations
- $word = new PHPWord;
- $zip = new ZipArchive;
+ $word = new PhpWord();
+ $zip = new ZipArchive();
$zip->open($pFilename);
// Read properties and documents
@@ -136,7 +135,7 @@ class Word2007 extends AbstractReader implements IReader
$xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/");
$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/");
$xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
- $docProps = $word->getProperties();
+ $docProps = $word->getDocumentProperties();
$docProps->setCreator((string)self::arrayItem($xmlCore->xpath("dc:creator")));
$docProps->setLastModifiedBy((string)self::arrayItem($xmlCore->xpath("cp:lastModifiedBy")));
$docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created"))));
@@ -152,7 +151,7 @@ class Word2007 extends AbstractReader implements IReader
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties":
$xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}"));
if (is_object($xmlCore)) {
- $docProps = $word->getProperties();
+ $docProps = $word->getDocumentProperties();
if (isset($xmlCore->Company)) {
$docProps->setCompany((string)$xmlCore->Company);
}
@@ -165,7 +164,7 @@ class Word2007 extends AbstractReader implements IReader
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties":
$xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}"));
if (is_object($xmlCore)) {
- $docProps = $word->getProperties();
+ $docProps = $word->getDocumentProperties();
foreach ($xmlCore as $xmlProperty) {
$cellDataOfficeAttributes = $xmlProperty->attributes();
if (isset($cellDataOfficeAttributes['name'])) {
@@ -276,7 +275,7 @@ class Word2007 extends AbstractReader implements IReader
* @param SimpleXMLElement $elm
* @return array|string|null
*
- * @todo Implement gutter
+ * @todo Implement gutter
*/
private function loadSectionSettings($elm)
{
@@ -443,8 +442,6 @@ class Word2007 extends AbstractReader implements IReader
}
/**
- * Get array item
- *
* @param array $array
* @param mixed $key
* @return mixed|null
diff --git a/Classes/PHPWord/Section.php b/Classes/PHPWord/Section.php
index 17887d6b..0b12f9ef 100755
--- a/Classes/PHPWord/Section.php
+++ b/Classes/PHPWord/Section.php
@@ -1,8 +1,8 @@
_name = $pValue;
return $this;
@@ -258,10 +259,10 @@ class Font
* @param int|float $pValue
* @return PhpOffice\PhpWord\Style\Font
*/
- public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
+ public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE)
{
if (!is_numeric($pValue)) {
- $pValue = PHPWord::DEFAULT_FONT_SIZE;
+ $pValue = PhpWord::DEFAULT_FONT_SIZE;
}
$this->_size = $pValue;
return $this;
@@ -435,10 +436,10 @@ class Font
* @param string $pValue
* @return PhpOffice\PhpWord\Style\Font
*/
- public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
+ public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR)
{
if (is_null($pValue) || $pValue == '') {
- $pValue = PHPWord::DEFAULT_FONT_COLOR;
+ $pValue = PhpWord::DEFAULT_FONT_COLOR;
}
$this->_color = $pValue;
return $this;
@@ -532,10 +533,10 @@ class Font
* @param string $pValue
* @return PhpOffice\PhpWord\Style\Font
*/
- public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE)
+ public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE)
{
if (is_null($pValue) || $pValue == '') {
- $pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE;
+ $pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE;
}
$this->_hint = $pValue;
return $this;
diff --git a/Classes/PHPWord/Style/Image.php b/Classes/PHPWord/Style/Image.php
index c78c6087..fbc074be 100755
--- a/Classes/PHPWord/Style/Image.php
+++ b/Classes/PHPWord/Style/Image.php
@@ -1,8 +1,8 @@
setPHPWord($phpWord);
+ // Assign PhpWord
+ $this->setPhpWord($phpWord);
// Set up disk caching location
$this->_diskCachingDirectory = './';
@@ -100,10 +95,10 @@ class ODText implements IWriter
}
/**
- * Save PHPWord to file
+ * Save PhpWord to file
*
- * @param string $pFileName
- * @throws Exception
+ * @param string $pFileName
+ * @throws \Exception
*/
public function save($pFilename = null)
{
@@ -125,7 +120,7 @@ class ODText implements IWriter
// Try opening the ZIP file
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
- throw new Exception("Could not open " . $pFilename . " for writing.");
+ throw new \Exception("Could not open " . $pFilename . " for writing.");
}
}
@@ -182,45 +177,40 @@ class ODText implements IWriter
// Close file
if ($objZip->close() === false) {
- throw new Exception("Could not close zip file $pFilename.");
+ throw new \Exception("Could not close zip file $pFilename.");
}
// If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) {
if (copy($pFilename, $originalFilename) === false) {
- throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
+ throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
}
@unlink($pFilename);
}
} else {
- throw new Exception("PHPWord object unassigned.");
+ throw new \Exception("PhpWord object unassigned.");
}
}
/**
- * Get PHPWord object
- *
- * @return PHPWord
- * @throws Exception
+ * @return PhpOffice\PhpWord
+ * @throws \Exception
*/
- public function getPHPWord()
+ public function getPhpWord()
{
if (!is_null($this->_document)) {
return $this->_document;
} else {
- throw new Exception("No PHPWord assigned.");
+ throw new \Exception("No PhpWord assigned.");
}
}
/**
- * Get PHPWord object
- *
- * @param PHPWord $phpWord PHPWord object
- * @throws Exception
+ * @param PhpOffice\PhpWord $phpWord
* @return PhpOffice\PhpWord\Writer\ODText
*/
- public function setPHPWord(PHPWord $phpWord = null)
+ public function setPhpWord(PhpWord $phpWord = null)
{
$this->_document = $phpWord;
return $this;
@@ -237,8 +227,6 @@ class ODText implements IWriter
}
/**
- * Get writer part
- *
* @param string $pPartName Writer part name
* @return PhpOffice\PhpWord\Writer\ODText\WriterPart
*/
@@ -266,7 +254,7 @@ class ODText implements IWriter
*
* @param boolean $pValue
* @param string $pDirectory Disk caching directory
- * @throws Exception Exception when directory does not exist
+ * @throws \Exception Exception when directory does not exist
* @return PhpOffice\PhpWord\Writer\ODText
*/
public function setUseDiskCaching($pValue = false, $pDirectory = null)
@@ -277,7 +265,7 @@ class ODText implements IWriter
if (is_dir($pDirectory)) {
$this->_diskCachingDirectory = $pDirectory;
} else {
- throw new Exception("Directory does not exist: $pDirectory");
+ throw new \Exception("Directory does not exist: $pDirectory");
}
}
@@ -285,12 +273,10 @@ class ODText implements IWriter
}
/**
- * Get disk caching directory
- *
* @return string
*/
public function getDiskCachingDirectory()
{
return $this->_diskCachingDirectory;
}
-}
+}
\ No newline at end of file
diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php
index 5526d06c..d4f4d2eb 100755
--- a/Classes/PHPWord/Writer/ODText/Content.php
+++ b/Classes/PHPWord/Writer/ODText/Content.php
@@ -1,8 +1,8 @@
startElement('style:font-face');
- $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
- $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
+ $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME);
+ $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME);
$xmlWriter->endElement();
}
}
@@ -325,7 +326,7 @@ class Content extends WriterPart
if ($SfIsObject) {
// Don't never be the case, because I browse all sections for cleaning all styles not declared
- die('PHPWord : $SfIsObject wouldn\'t be an object');
+ die('PhpWord : $SfIsObject wouldn\'t be an object');
} else {
if (!$withoutP) {
$xmlWriter->startElement('text:p'); // text:p
diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php
index b39662f0..1169249d 100755
--- a/Classes/PHPWord/Writer/ODText/Manifest.php
+++ b/Classes/PHPWord/Writer/ODText/Manifest.php
@@ -1,8 +1,8 @@
startElement('office:meta');
// dc:creator
- $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getLastModifiedBy());
+ $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy());
// dc:date
- $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getModified()));
+ $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified()));
// dc:description
- $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription());
+ $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription());
// dc:subject
- $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject());
+ $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject());
// dc:title
- $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle());
+ $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle());
// meta:creation-date
- $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getProperties()->getCreated()));
+ $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated()));
// meta:initial-creator
- $xmlWriter->writeElement('meta:initial-creator', $phpWord->getProperties()->getCreator());
+ $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator());
// meta:keyword
- $xmlWriter->writeElement('meta:keyword', $phpWord->getProperties()->getKeywords());
+ $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords());
// @todo : Where these properties are written ?
- // $phpWord->getProperties()->getCategory()
- // $phpWord->getProperties()->getCompany()
+ // $phpWord->getDocumentProperties()->getCategory()
+ // $phpWord->getDocumentProperties()->getCompany()
$xmlWriter->endElement();
diff --git a/Classes/PHPWord/Writer/ODText/Mimetype.php b/Classes/PHPWord/Writer/ODText/Mimetype.php
index 7f3d0e77..570f1855 100755
--- a/Classes/PHPWord/Writer/ODText/Mimetype.php
+++ b/Classes/PHPWord/Writer/ODText/Mimetype.php
@@ -1,8 +1,8 @@
startElement('style:font-face');
- $xmlWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
- $xmlWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
+ $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME);
+ $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME);
$xmlWriter->endElement();
}
$xmlWriter->endElement();
@@ -137,17 +138,17 @@ class Styles extends WriterPart
// style:text-properties
$xmlWriter->startElement('style:text-properties');
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
- $xmlWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME);
- $xmlWriter->writeAttribute('fo:font-size', PHPWord::DEFAULT_FONT_SIZE . 'pt');
+ $xmlWriter->writeAttribute('style:font-name', PhpWord::DEFAULT_FONT_NAME);
+ $xmlWriter->writeAttribute('fo:font-size', PhpWord::DEFAULT_FONT_SIZE . 'pt');
$xmlWriter->writeAttribute('fo:language', 'fr');
$xmlWriter->writeAttribute('fo:country', 'FR');
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
- $xmlWriter->writeAttribute('style:font-name-asian', PHPWord::DEFAULT_FONT_NAME . '2');
- $xmlWriter->writeAttribute('style:font-size-asian', PHPWord::DEFAULT_FONT_SIZE . 'pt');
+ $xmlWriter->writeAttribute('style:font-name-asian', PhpWord::DEFAULT_FONT_NAME . '2');
+ $xmlWriter->writeAttribute('style:font-size-asian', PhpWord::DEFAULT_FONT_SIZE . 'pt');
$xmlWriter->writeAttribute('style:language-asian', 'zh');
$xmlWriter->writeAttribute('style:country-asian', 'CN');
- $xmlWriter->writeAttribute('style:font-name-complex', PHPWord::DEFAULT_FONT_NAME . '2');
- $xmlWriter->writeAttribute('style:font-size-complex', PHPWord::DEFAULT_FONT_SIZE . 'pt');
+ $xmlWriter->writeAttribute('style:font-name-complex', PhpWord::DEFAULT_FONT_NAME . '2');
+ $xmlWriter->writeAttribute('style:font-size-complex', PhpWord::DEFAULT_FONT_SIZE . 'pt');
$xmlWriter->writeAttribute('style:language-complex', 'hi');
$xmlWriter->writeAttribute('style:country-complex', 'IN');
$xmlWriter->writeAttribute('fo:hyphenate', 'false');
diff --git a/Classes/PHPWord/Writer/ODText/WriterPart.php b/Classes/PHPWord/Writer/ODText/WriterPart.php
index ccaecfa3..06e4a404 100755
--- a/Classes/PHPWord/Writer/ODText/WriterPart.php
+++ b/Classes/PHPWord/Writer/ODText/WriterPart.php
@@ -1,8 +1,8 @@
setPHPWord($phpWord);
+ // Assign PhpWord
+ $this->setPhpWord($phpWord);
// Set HashTable variables
$this->_drawingHashTable = new HashTable();
}
/**
- * Save PHPWord to file
+ * Save PhpWord to file
*
- * @param string $pFileName
- * @throws Exception
+ * @param string $pFileName
+ * @throws \Exception
*/
public function save($pFilename = null)
{
@@ -102,37 +103,35 @@ class RTF implements IWriter
// If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) {
if (copy($pFilename, $originalFilename) === false) {
- throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
+ throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
}
@unlink($pFilename);
}
} else {
- throw new Exception("PHPWord object unassigned.");
+ throw new \Exception("PhpWord object unassigned.");
}
}
/**
- * Get PHPWord object
- *
- * @return PHPWord
- * @throws Exception
+ * @return PhpOffice\PhpWord
+ * @throws \Exception
*/
- public function getPHPWord()
+ public function getPhpWord()
{
if (!is_null($this->_document)) {
return $this->_document;
} else {
- throw new Exception("No PHPWord assigned.");
+ throw new \Exception("No PhpWord assigned.");
}
}
/**
- * @param PHPWord $phpWord PHPWord object
- * @throws Exception
+ * @param PhpOffice\PhpWord $phpWord
+ * @throws \Exception
* @return PhpOffice\PhpWord\Writer\RTF
*/
- public function setPHPWord(PHPWord $phpWord = null)
+ public function setPhpWord(PhpWord $phpWord = null)
{
$this->_document = $phpWord;
return $this;
@@ -150,7 +149,7 @@ class RTF implements IWriter
private function getData()
{
- // PHPWord object : $this->_document
+ // PhpWord object : $this->_document
$this->_fontTable = $this->getDataFont();
$this->_colorTable = $this->getDataColor();
@@ -176,7 +175,7 @@ class RTF implements IWriter
}
$sRTFContent .= ';}' . PHP_EOL;
// Set the generator
- $sRTFContent .= '{\*\generator PHPWord;}' . PHP_EOL;
+ $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL;
// Set the view mode of the document
$sRTFContent .= '\viewkind4';
// Set the numberof bytes that follows a unicode character
@@ -190,7 +189,7 @@ class RTF implements IWriter
// Point size (in half-points) above which to kern character pairs
$sRTFContent .= '\kerning1';
// Set the font size in half-points
- $sRTFContent .= '\fs' . (PHPWord::DEFAULT_FONT_SIZE * 2);
+ $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2);
$sRTFContent .= PHP_EOL;
// Body
$sRTFContent .= $this->getDataContent();
@@ -206,9 +205,9 @@ class RTF implements IWriter
$phpWord = $this->_document;
$arrFonts = array();
- // Default font : PHPWord::DEFAULT_FONT_NAME
- $arrFonts[] = PHPWord::DEFAULT_FONT_NAME;
- // PHPWord object : $this->_document
+ // Default font : PhpWord::DEFAULT_FONT_NAME
+ $arrFonts[] = PhpWord::DEFAULT_FONT_NAME;
+ // PhpWord object : $this->_document
// Browse styles
$styles = Style::getStyles();
@@ -256,7 +255,7 @@ class RTF implements IWriter
$phpWord = $this->_document;
$arrColors = array();
- // PHPWord object : $this->_document
+ // PhpWord object : $this->_document
// Browse styles
$styles = Style::getStyles();
@@ -267,10 +266,10 @@ class RTF implements IWriter
if ($style instanceof Font) {
$color = $style->getColor();
$fgcolor = $style->getFgColor();
- if (in_array($color, $arrColors) == false && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) {
+ if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) {
$arrColors[] = $color;
}
- if (in_array($fgcolor, $arrColors) == false && $fgcolor != PHPWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) {
+ if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) {
$arrColors[] = $fgcolor;
}
}
@@ -353,9 +352,6 @@ class RTF implements IWriter
return $sRTFBody;
}
- /**
- * Get text
- */
private function getDataContentText(Text $text, $withoutP = false)
{
$sRTFText = '';
@@ -434,7 +430,7 @@ class RTF implements IWriter
$sRTFText .= '\i0';
}
if ($styleFont->getSize()) {
- $sRTFText .= '\fs' . (PHPWord::DEFAULT_FONT_SIZE * 2);
+ $sRTFText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2);
}
}
@@ -444,9 +440,6 @@ class RTF implements IWriter
return $sRTFText;
}
- /**
- * Get text run content
- */
private function getDataContentTextRun(TextRun $textrun)
{
$sRTFText = '';
@@ -486,4 +479,4 @@ class RTF implements IWriter
return $sRTFText;
}
-}
+}
\ No newline at end of file
diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php
index 0aa8e057..7e356d97 100755
--- a/Classes/PHPWord/Writer/Word2007.php
+++ b/Classes/PHPWord/Writer/Word2007.php
@@ -1,8 +1,8 @@
_document = $PHPWord;
+ $this->_document = $phpWord;
$this->_diskCachingDirectory = './';
@@ -187,11 +188,11 @@ class Word2007 implements IWriter
$objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
// Write static files
- $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
- $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml');
- $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
- $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
- $objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
+ $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
+ $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/settings.xml', 'word/settings.xml');
+ $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
+ $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
+ $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
// Close file
@@ -207,7 +208,7 @@ class Word2007 implements IWriter
@unlink($pFilename);
}
} else {
- throw new Exception("PHPWord object unassigned.");
+ throw new Exception("PhpWord object unassigned.");
}
}
diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php
index a02b0081..902e8e49 100755
--- a/Classes/PHPWord/Writer/Word2007/Base.php
+++ b/Classes/PHPWord/Writer/Word2007/Base.php
@@ -1,8 +1,8 @@
startElement('w:rPr');
// Font
- if ($font != PHPWord::DEFAULT_FONT_NAME) {
+ if ($font != PhpWord::DEFAULT_FONT_NAME) {
$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) {
+ if ($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE) {
$xmlWriter->writeAttribute('w:hint', $hint);
}
$xmlWriter->endElement();
@@ -417,14 +418,14 @@ class Base extends WriterPart
// Color
- if ($color != PHPWord::DEFAULT_FONT_COLOR) {
+ if ($color != PhpWord::DEFAULT_FONT_COLOR) {
$xmlWriter->startElement('w:color');
$xmlWriter->writeAttribute('w:val', $color);
$xmlWriter->endElement();
}
// Size
- if ($size != PHPWord::DEFAULT_FONT_SIZE) {
+ if ($size != PhpWord::DEFAULT_FONT_SIZE) {
$xmlWriter->startElement('w:sz');
$xmlWriter->writeAttribute('w:val', $size * 2);
$xmlWriter->endElement();
diff --git a/Classes/PHPWord/Writer/Word2007/ContentTypes.php b/Classes/PHPWord/Writer/Word2007/ContentTypes.php
index 27d3cefa..2d84070d 100755
--- a/Classes/PHPWord/Writer/Word2007/ContentTypes.php
+++ b/Classes/PHPWord/Writer/Word2007/ContentTypes.php
@@ -1,8 +1,8 @@
endElement();
// Company
- $xmlWriter->writeElement('Company', $phpWord->getProperties()->getCompany());
+ $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany());
// LinksUpToDate
$xmlWriter->writeElement('LinksUpToDate', 'false');
@@ -123,7 +124,7 @@ class DocProps extends WriterPart
}
- public function writeDocPropsCore(PHPWord $phpWord = null)
+ public function writeDocPropsCore(PhpWord $phpWord = null)
{
// Create XML writer
$xmlWriter = null;
@@ -145,37 +146,37 @@ class DocProps extends WriterPart
$xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
// dc:creator
- $xmlWriter->writeElement('dc:creator', $phpWord->getProperties()->getCreator());
+ $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator());
// cp:lastModifiedBy
- $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getProperties()->getLastModifiedBy());
+ $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy());
// dcterms:created
$xmlWriter->startElement('dcterms:created');
$xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getCreated()));
+ $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getCreated()));
$xmlWriter->endElement();
// dcterms:modified
$xmlWriter->startElement('dcterms:modified');
$xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
- $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getProperties()->getModified()));
+ $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getModified()));
$xmlWriter->endElement();
// dc:title
- $xmlWriter->writeElement('dc:title', $phpWord->getProperties()->getTitle());
+ $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle());
// dc:description
- $xmlWriter->writeElement('dc:description', $phpWord->getProperties()->getDescription());
+ $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription());
// dc:subject
- $xmlWriter->writeElement('dc:subject', $phpWord->getProperties()->getSubject());
+ $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject());
// cp:keywords
- $xmlWriter->writeElement('cp:keywords', $phpWord->getProperties()->getKeywords());
+ $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords());
// cp:category
- $xmlWriter->writeElement('cp:category', $phpWord->getProperties()->getCategory());
+ $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory());
$xmlWriter->endElement();
diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php
index 691e723e..f4cd15ea 100755
--- a/Classes/PHPWord/Writer/Word2007/Document.php
+++ b/Classes/PHPWord/Writer/Word2007/Document.php
@@ -1,8 +1,8 @@
getParentWriter()->getUseDiskCaching()) {
diff --git a/Classes/PHPWord/Writer/Word2007/DocumentRels.php b/Classes/PHPWord/Writer/Word2007/DocumentRels.php
index d8e3396b..176dd055 100755
--- a/Classes/PHPWord/Writer/Word2007/DocumentRels.php
+++ b/Classes/PHPWord/Writer/Word2007/DocumentRels.php
@@ -1,8 +1,8 @@
#### Basic usage
-The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/).
+The following is a basic example of the PhpWord library. More examples are provided in the [samples folder](samples/).
```php
-$PHPWord = new PHPWord();
+$phpWord = new PhpOffice\PhpWord();
// Every element you want to append to the word document is placed in a section.
// To create a basic section:
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// After creating a section, you can append elements:
$section->addText('Hello world!');
@@ -97,7 +97,7 @@ $section->addText('Hello world! I am formatted.',
// If you often need the same style again you can create a user defined style
// to the word document and give the addText function the name of the style:
-$PHPWord->addFontStyle('myOwnStyle',
+$phpWord->addFontStyle('myOwnStyle',
array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
$section->addText('Hello world! I am formatted by a user defined style',
'myOwnStyle');
@@ -111,7 +111,7 @@ $myTextElement = $section->addText('Hello World!');
$myTextElement->setFontStyle($fontStyle);
// Finally, write the document:
-$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
+$xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$xmlWriter->save('helloWorld.docx');
```
@@ -120,15 +120,15 @@ $xmlWriter->save('helloWorld.docx');
The base length unit in Open Office XML is twip. Twip means "TWentieth of an Inch Point", i.e. 1 twip = 1/1440 inch.
-You can use PHPWord helper functions to convert inches, centimeters, or points to twips.
+You can use PhpWord helper functions to convert inches, centimeters, or points to twips.
```php
// Paragraph with 6 points space after
-$PHPWord->addParagraphStyle('My Style', array(
+$phpWord->addParagraphStyle('My Style', array(
'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6))
);
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$sectionStyle = $section->getSettings();
// half inch left margin
$sectionStyle->setMarginLeft(PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));
@@ -142,7 +142,7 @@ $sectionStyle->setMarginRight(PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwi
Every visible element in word is placed inside of a section. To create a section, use the following code:
```php
-$section = $PHPWord->createSection($sectionSettings);
+$section = $phpWord->createSection($sectionSettings);
```
The `$sectionSettings` is an optional associative array that sets the section. Example:
@@ -188,7 +188,7 @@ The following two settings are automatically set by the use of the `orientation`
You can change a section page numbering.
```php
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->getSettings()->setPageNumberingStart(1);
```
@@ -271,7 +271,7 @@ $cell->getStyle()->setGridSpan(5);
You can add images easily using the following example.
```php
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addImage('mars.jpg');
```
diff --git a/Tests/PHPWord/AutoloaderTest.php b/Tests/PHPWord/AutoloaderTest.php
index d33d8ab5..cc244688 100644
--- a/Tests/PHPWord/AutoloaderTest.php
+++ b/Tests/PHPWord/AutoloaderTest.php
@@ -1,5 +1,5 @@
assertNull(
PHPWord_Autoloader::load('Foo'),
- 'PHPWord_Autoloader::load() is trying to load classes outside of the PHPWord namespace'
+ 'PHPWord_Autoloader::load() is trying to load classes outside of the PhpWord namespace'
);
$this->assertTrue(
- PHPWord_Autoloader::load('PHPWord'),
- 'PHPWord_Autoloader::load() failed to autoload the PHPWord class'
+ PHPWord_Autoloader::load('PhpWord'),
+ 'PHPWord_Autoloader::load() failed to autoload the PhpWord class'
);
}
@@ -36,7 +36,7 @@ class AutoloaderTest extends \PHPUnit_Framework_TestCase
'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load classes ' .
'outside of the PhpOffice\\PhpWord namespace'
);
- // TODO change this class to the main PHPWord class when it is namespaced
+ // TODO change this class to the main PhpWord class when it is namespaced
Autoloader::autoload(
'PhpOffice\\PhpWord\\Exceptions\\InvalidStyleException'
);
diff --git a/Tests/PHPWord/DocumentPropertiesTest.php b/Tests/PHPWord/DocumentPropertiesTest.php
index 250f1b3e..b8ad9374 100644
--- a/Tests/PHPWord/DocumentPropertiesTest.php
+++ b/Tests/PHPWord/DocumentPropertiesTest.php
@@ -1,10 +1,10 @@
assertInstanceOf(
'PhpOffice\\PhpWord\\Writer\\Word2007',
- IOFactory::createWriter(new PHPWord(), 'Word2007')
+ IOFactory::createWriter(new PhpWord(), 'Word2007')
);
}
@@ -29,7 +29,7 @@ final class IOFactoryTest extends \PHPUnit_Framework_TestCase
*/
final public function testNonexistentWriterCanNotBeCreated()
{
- IOFactory::createWriter(new PHPWord(), 'Word2006');
+ IOFactory::createWriter(new PhpWord(), 'Word2006');
}
/**
diff --git a/Tests/PHPWord/MediaTest.php b/Tests/PHPWord/MediaTest.php
index 6515e36b..310a7a11 100644
--- a/Tests/PHPWord/MediaTest.php
+++ b/Tests/PHPWord/MediaTest.php
@@ -1,5 +1,5 @@
assertInstanceOf('PhpOffice\\PHPWord', $object);
+ $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 5cf7ca16..3e355b42 100644
--- a/Tests/PHPWord/Section/Footer/PreserveTextTest.php
+++ b/Tests/PHPWord/Section/Footer/PreserveTextTest.php
@@ -1,5 +1,5 @@
PHPWord::DEFAULT_FONT_NAME,
- 'size' => PHPWord::DEFAULT_FONT_SIZE,
+ 'name' => PhpWord::DEFAULT_FONT_NAME,
+ 'size' => PhpWord::DEFAULT_FONT_SIZE,
'bold' => false,
'italic' => false,
'superScript' => false,
'subScript' => false,
'underline' => Font::UNDERLINE_NONE,
'strikethrough' => false,
- 'color' => PHPWord::DEFAULT_FONT_COLOR,
+ 'color' => PhpWord::DEFAULT_FONT_COLOR,
'fgColor' => null,
);
foreach ($attributes as $key => $default) {
@@ -83,15 +83,15 @@ class FontTest extends \PHPUnit_Framework_TestCase
public function testLineHeight()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
// Test style array
$text = $section->addText('This is a test', array(
'line-height' => 2.0
));
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
$lineHeight = $element->getAttribute('w:line');
@@ -102,7 +102,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
// Test setter
$text->getFontStyle()->setLineHeight(3.0);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
$lineHeight = $element->getAttribute('w:line');
diff --git a/Tests/PHPWord/Style/ImageTest.php b/Tests/PHPWord/Style/ImageTest.php
index 2ed15f4f..c06bba2e 100644
--- a/Tests/PHPWord/Style/ImageTest.php
+++ b/Tests/PHPWord/Style/ImageTest.php
@@ -1,10 +1,10 @@
createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
// Test style array
$text = $section->addText('This is a test', array(), array(
'line-height' => 2.0
));
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
$lineHeight = $element->getAttribute('w:line');
@@ -108,7 +108,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
// Test setter
$text->getParagraphStyle()->setLineHeight(3.0);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:spacing');
$lineHeight = $element->getAttribute('w:line');
diff --git a/Tests/PHPWord/Style/RowTest.php b/Tests/PHPWord/Style/RowTest.php
index 97131509..ca5f6a63 100644
--- a/Tests/PHPWord/Style/RowTest.php
+++ b/Tests/PHPWord/Style/RowTest.php
@@ -1,10 +1,10 @@
addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot'))));
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $phpWord = new PhpWord();
+ $phpWord->addParagraphStyle('tabbed', array('tabs' => array(new Tab('left', 1440, 'dot'))));
+ $doc = TestHelperDOCX::getDocument($phpWord);
$file = 'word/styles.xml';
$path = '/w:styles/w:style[@w:styleId="tabbed"]/w:pPr/w:tabs/w:tab[1]';
$element = $doc->getElement($path, $file);
diff --git a/Tests/PHPWord/StyleTest.php b/Tests/PHPWord/StyleTest.php
index bdca8ea7..226387d0 100644
--- a/Tests/PHPWord/StyleTest.php
+++ b/Tests/PHPWord/StyleTest.php
@@ -1,10 +1,10 @@
loadTemplate($template);
+ $phpWord = new PhpWord();
+ $document = $phpWord->loadTemplate($template);
$actualVar = $document->getVariables();
$document->cloneRow('userId', 1);
$document->setValue('userId#1', 'Test');
diff --git a/Tests/PHPWord/Writer/ODText/ContentTest.php b/Tests/PHPWord/Writer/ODText/ContentTest.php
index 31659d32..7ebff776 100644
--- a/Tests/PHPWord/Writer/ODText/ContentTest.php
+++ b/Tests/PHPWord/Writer/ODText/ContentTest.php
@@ -1,11 +1,11 @@
setDefaultFontName('Verdana');
- $PHPWord->addFontStyle('Font', array('size' => 11));
- $PHPWord->addParagraphStyle('Paragraph', array('align' => 'center'));
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $phpWord->setDefaultFontName('Verdana');
+ $phpWord->addFontStyle('Font', array('size' => 11));
+ $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
+ $section = $phpWord->createSection();
$section->addText($expected);
$section->addText('Test font style', 'Font');
$section->addText('Test paragraph style', null, 'Paragraph');
@@ -54,7 +54,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$section->addTOC();
$textrun = $section->createTextRun();
$textrun->addText('Test text run');
- $doc = TestHelperDOCX::getDocument($PHPWord, 'ODText');
+ $doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
$element = "/office:document-content/office:body/office:text/text:p";
$this->assertEquals($expected, $doc->getElement($element, 'content.xml')->nodeValue);
diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php
index f1cc7213..bbbfe990 100644
--- a/Tests/PHPWord/Writer/ODTextTest.php
+++ b/Tests/PHPWord/Writer/ODTextTest.php
@@ -1,11 +1,11 @@
assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord());
+ $this->assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord());
$this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable());
$this->assertEquals('./', $object->getDiskCachingDirectory());
@@ -35,14 +35,14 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
}
/**
- * @covers ::getPHPWord
+ * @covers ::getPhpWord
* @expectedException Exception
- * @expectedExceptionMessage No PHPWord assigned.
+ * @expectedExceptionMessage No PhpWord assigned.
*/
public function testConstructWithNull()
{
$object = new ODText();
- $object->getPHPWord();
+ $object->getPhpWord();
}
/**
@@ -52,7 +52,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
{
$imageSrc = \join(
\DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
+ array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png')
);
$objectSrc = \join(
\DIRECTORY_SEPARATOR,
@@ -63,7 +63,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.odt')
);
- $phpWord = new PHPWord();
+ $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection();
@@ -95,7 +95,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
*/
public function testSavePhpOutput()
{
- $phpWord = new PHPWord();
+ $phpWord = new PhpWord();
$section = $phpWord->createSection();
$section->addText('Test');
$writer = new ODText($phpWord);
@@ -105,7 +105,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
/**
* @covers ::save
* @expectedException Exception
- * @expectedExceptionMessage PHPWord object unassigned.
+ * @expectedExceptionMessage PhpWord object unassigned.
*/
public function testSaveException()
{
diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php
index 6a7c0780..ecce8732 100644
--- a/Tests/PHPWord/Writer/RTFTest.php
+++ b/Tests/PHPWord/Writer/RTFTest.php
@@ -1,11 +1,11 @@
assertInstanceOf('PhpOffice\\PHPWord', $object->getPHPWord());
+ $this->assertInstanceOf('PhpOffice\\PhpWord', $object->getPhpWord());
$this->assertInstanceOf('PhpOffice\\PhpWord\\HashTable', $object->getDrawingHashTable());
}
/**
* covers ::__construct
* @expectedException Exception
- * @expectedExceptionMessage No PHPWord assigned.
+ * @expectedExceptionMessage No PhpWord assigned.
*/
public function testConstructWithNull()
{
$object = new RTF();
- $object->getPHPWord();
+ $object->getPhpWord();
}
/**
@@ -39,7 +39,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
*/
public function testSavePhpOutput()
{
- $phpWord = new PHPWord();
+ $phpWord = new PhpWord();
$section = $phpWord->createSection();
$section->addText('Test');
$writer = new RTF($phpWord);
@@ -49,7 +49,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
/**
* @covers ::save
* @expectedException Exception
- * @expectedExceptionMessage PHPWord object unassigned.
+ * @expectedExceptionMessage PhpWord object unassigned.
*/
public function testSaveException()
{
@@ -65,7 +65,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
{
$imageSrc = \join(
\DIRECTORY_SEPARATOR,
- array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
+ array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PhpWord.png')
);
$objectSrc = \join(
\DIRECTORY_SEPARATOR,
@@ -76,7 +76,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf')
);
- $phpWord = new PHPWord();
+ $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection();
diff --git a/Tests/PHPWord/Writer/Word2007/BaseTest.php b/Tests/PHPWord/Writer/Word2007/BaseTest.php
index c66ce9ce..c62ba3ac 100644
--- a/Tests/PHPWord/Writer/Word2007/BaseTest.php
+++ b/Tests/PHPWord/Writer/Word2007/BaseTest.php
@@ -1,11 +1,11 @@
addFontStyle($rStyle, array('bold' => true));
- $PHPWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $phpWord->addFontStyle($rStyle, array('bold' => true));
+ $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
+ $section = $phpWord->createSection();
$section->addText('Test', $rStyle, $pStyle);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = "/w:document/w:body/w:p/w:r/w:rPr/w:rStyle";
$this->assertEquals($rStyle, $doc->getElementAttribute($element, 'w:val'));
@@ -52,16 +52,16 @@ class BaseTest extends \PHPUnit_Framework_TestCase
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $PHPWord = new PHPWord();
- $PHPWord->addParagraphStyle($pStyle, $aStyle);
- $section = $PHPWord->createSection('Test');
+ $phpWord = new PhpWord();
+ $phpWord->addParagraphStyle($pStyle, $aStyle);
+ $section = $phpWord->createSection('Test');
$textrun = $section->createTextRun($pStyle);
$textrun->addText('Test');
$textrun->addTextBreak();
$textrun = $section->createTextRun($aStyle);
$textrun->addLink('http://test.com');
$textrun->addImage($imageSrc);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$parent = "/w:document/w:body/w:p";
$this->assertTrue($doc->elementExists("{$parent}/w:pPr/w:pStyle[@w:val='{$pStyle}']"));
@@ -72,13 +72,13 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteLink()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
- $expected = 'PHPWord';
+ $expected = 'PhpWord';
$section->addLink('http://github.com/phpoffice/phpword', $expected);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:hyperlink/w:r/w:t');
$this->assertEquals($expected, $element->nodeValue);
@@ -89,13 +89,13 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWritePreserveText()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$footer = $section->createFooter();
$footer->addPreserveText('{PAGE}');
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml');
$this->assertEquals('PAGE', $preserve->nodeValue);
@@ -112,14 +112,14 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$fName = 'fStyle';
$pName = 'pStyle';
- $PHPWord = new PHPWord();
- $PHPWord->addFontStyle($fName, $fArray);
- $PHPWord->addParagraphStyle($pName, $pArray);
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $phpWord->addFontStyle($fName, $fArray);
+ $phpWord->addParagraphStyle($pName, $pArray);
+ $section = $phpWord->createSection();
$section->addTextBreak();
$section->addTextBreak(1, $fArray, $pArray);
$section->addTextBreak(1, $fName, $pName);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:rPr/w:rStyle');
$this->assertEquals($fName, $element->getAttribute('w:val'));
@@ -132,12 +132,12 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteParagraphStyleAlign()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$section->addText('This is my text', null, array('align' => 'right'));
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
$this->assertEquals('right', $element->getAttribute('w:val'));
@@ -149,8 +149,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWriteParagraphStylePagination()
{
// Create the doc
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$attributes = array(
'widowControl' => false,
'keepNext' => true,
@@ -160,7 +160,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
foreach ($attributes as $attribute => $value) {
$section->addText('Test', null, array($attribute => $value));
}
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
// Test the attributes
$i = 0;
@@ -178,7 +178,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteFontStyle()
{
- $PHPWord = new PHPWord();
+ $phpWord = new PhpWord();
$styles['name'] = 'Verdana';
$styles['size'] = 14;
$styles['bold'] = true;
@@ -189,9 +189,9 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$styles['color'] = 'FF0000';
$styles['fgColor'] = 'yellow';
- $section = $PHPWord->createSection();
+ $section = $phpWord->createSection();
$section->addText('Test', $styles);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$parent = '/w:document/w:body/w:p/w:r/w:rPr';
$this->assertEquals($styles['name'], $doc->getElementAttribute("{$parent}/w:rFonts", 'w:ascii'));
@@ -210,7 +210,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteTableStyle()
{
- $PHPWord = new PHPWord();
+ $phpWord = new PhpWord();
$tWidth = 120;
$rHeight = 120;
$cWidth = 120;
@@ -232,7 +232,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$cStyles["borderLeftColor"] = 'FF0000';
$cStyles["borderRightColor"] = 'FF0000';
- $section = $PHPWord->createSection();
+ $section = $phpWord->createSection();
$table = $section->addTable($tStyles);
$table->setWidth = 100;
$table->addRow($rHeight, $rStyles);
@@ -244,7 +244,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$textrun = $cell->createTextRun();
$textrun->addText('Test');
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$parent = '/w:document/w:body/w:tbl/w:tblPr/w:tblCellMar';
$this->assertEquals($tStyles['cellMarginTop'], $doc->getElementAttribute("{$parent}/w:top", 'w:w'));
@@ -268,8 +268,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteCellStyleCellGridSpan()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$table = $section->addTable();
@@ -284,7 +284,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$table->addCell(40);
$table->addCell(40);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
$this->assertEquals(5, $element->getAttribute('w:val'));
@@ -295,8 +295,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteImagePosition()
{
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$section->addImage(
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
array(
@@ -306,7 +306,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
)
);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape');
$style = $element->getAttribute('style');
@@ -325,11 +325,11 @@ class BaseTest extends \PHPUnit_Framework_TestCase
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'earth.jpg')
);
- $PHPWord = new PHPWord();
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$header = $section->createHeader();
$header->addWatermark($imageSrc);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement("/w:document/w:body/w:sectPr/w:headerReference");
$this->assertStringStartsWith("rId", $element->getAttribute('r:id'));
@@ -340,10 +340,10 @@ class BaseTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteTitle()
{
- $PHPWord = new PHPWord();
- $PHPWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
- $PHPWord->createSection()->addTitle('Test', 1);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $phpWord = new PhpWord();
+ $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
+ $phpWord->createSection()->addTitle('Test', 1);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = "/w:document/w:body/w:p/w:pPr/w:pStyle";
$this->assertEquals('Heading1', $doc->getElementAttribute($element, 'w:val'));
diff --git a/Tests/PHPWord/Writer/Word2007/DocumentTest.php b/Tests/PHPWord/Writer/Word2007/DocumentTest.php
index 70a16dc0..da54a7f4 100644
--- a/Tests/PHPWord/Writer/Word2007/DocumentTest.php
+++ b/Tests/PHPWord/Writer/Word2007/DocumentTest.php
@@ -1,11 +1,11 @@
createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$section->getSettings()->setPageNumberingStart(2);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
$this->assertEquals(2, $element->getAttribute('w:start'));
@@ -44,20 +44,20 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'documents', 'sheet.xls')
);
- $PHPWord = new PHPWord();
- $PHPWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
- $PHPWord->addTitleStyle(2, array('color'=>'666666'));
- $section = $PHPWord->createSection();
+ $phpWord = new PhpWord();
+ $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
+ $phpWord->addTitleStyle(2, array('color'=>'666666'));
+ $section = $phpWord->createSection();
$section->addTOC();
$section->addPageBreak();
$section->addTitle('Title 1', 1);
$section->addListItem('List Item 1', 0);
$section->addListItem('List Item 2', 0);
$section->addListItem('List Item 3', 0);
- $section = $PHPWord->createSection();
+ $section = $phpWord->createSection();
$section->addTitle('Title 2', 2);
$section->addObject($objectSrc);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
// TOC
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab');
diff --git a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php
index 5ad4b8c7..18c9caec 100644
--- a/Tests/PHPWord/Writer/Word2007/FootnotesTest.php
+++ b/Tests/PHPWord/Writer/Word2007/FootnotesTest.php
@@ -1,11 +1,11 @@
createSection();
+ $phpWord = new PhpWord();
+ $section = $phpWord->createSection();
$section->addText('Text');
$footnote = $section->createFootnote();
$footnote->addText('Footnote');
$footnote->addLink('http://google.com');
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference"));
}
diff --git a/Tests/PHPWord/Writer/Word2007/StylesTest.php b/Tests/PHPWord/Writer/Word2007/StylesTest.php
index 026b5eaa..e3c633a7 100644
--- a/Tests/PHPWord/Writer/Word2007/StylesTest.php
+++ b/Tests/PHPWord/Writer/Word2007/StylesTest.php
@@ -1,11 +1,11 @@
'both');
$pBase = array('basedOn' => 'Normal');
@@ -42,13 +42,13 @@ class StylesTest extends \PHPUnit_Framework_TestCase
'borderInsideHSize' => 120,
'borderInsideVSize' => 120,
);
- $PHPWord->setDefaultParagraphStyle($pStyle);
- $PHPWord->addParagraphStyle('Base Style', $pBase);
- $PHPWord->addParagraphStyle('New Style', $pNew);
- $PHPWord->addFontStyle('New Style', $rStyle, $pStyle);
- $PHPWord->addTableStyle('Table Style', $tStyle, $tStyle);
- $PHPWord->addTitleStyle(1, $rStyle, $pStyle);
- $doc = TestHelperDOCX::getDocument($PHPWord);
+ $phpWord->setDefaultParagraphStyle($pStyle);
+ $phpWord->addParagraphStyle('Base Style', $pBase);
+ $phpWord->addParagraphStyle('New Style', $pNew);
+ $phpWord->addFontStyle('New Style', $rStyle, $pStyle);
+ $phpWord->addTableStyle('Table Style', $tStyle, $tStyle);
+ $phpWord->addTitleStyle(1, $rStyle, $pStyle);
+ $doc = TestHelperDOCX::getDocument($phpWord);
$file = 'word/styles.xml';
diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php
index 34e025d8..1c04901d 100644
--- a/Tests/PHPWord/Writer/Word2007Test.php
+++ b/Tests/PHPWord/Writer/Word2007Test.php
@@ -1,12 +1,12 @@
addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection();
@@ -87,7 +87,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
'duke_nukem.bmp' => '5.bmp',
'angela_merkel.tif' => '6.tif',
);
- $phpWord = new PHPWord();
+ $phpWord = new PhpWord();
$section = $phpWord->createSection();
foreach ($images as $source => $target) {
$section->addImage(PHPWORD_TESTS_DIR_ROOT . "/_files/images/{$source}");
diff --git a/Tests/PHPWordTest.php b/Tests/PHPWordTest.php
index 4ab63075..ca0dded1 100644
--- a/Tests/PHPWordTest.php
+++ b/Tests/PHPWordTest.php
@@ -1,55 +1,44 @@
assertEquals(new DocumentProperties(), $object->getProperties());
- $this->assertEquals(
- PHPWord::DEFAULT_FONT_NAME,
- $object->getDefaultFontName()
- );
- $this->assertEquals(
- PHPWord::DEFAULT_FONT_SIZE,
- $object->getDefaultFontSize()
- );
+ $phpWord = new PhpWord();
+ $this->assertEquals(new DocumentProperties(), $phpWord->getDocumentProperties());
+ $this->assertEquals(PhpWord::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName());
+ $this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
}
/**
- * @covers ::setProperties
- * @covers ::getProperties
+ * @covers ::setDocumentProperties
+ * @covers ::getDocumentProperties
*/
- public function testSetGetProperties()
+ public function testSetGetDocumentProperties()
{
- $object = new PHPWord();
- $creator = 'PHPWord';
- $properties = $object->getProperties();
+ $phpWord = new PhpWord();
+ $creator = 'PhpWord';
+ $properties = $phpWord->getDocumentProperties();
$properties->setCreator($creator);
- $object->setProperties($properties);
- $this->assertEquals($creator, $object->getProperties()->getCreator());
+ $phpWord->setDocumentProperties($properties);
+ $this->assertEquals($creator, $phpWord->getDocumentProperties()->getCreator());
}
/**
@@ -58,10 +47,10 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateGetSections()
{
- $object = new PHPWord();
- $this->assertEquals(new Section(1), $object->createSection());
- $object->createSection();
- $this->assertEquals(2, count($object->getSections()));
+ $phpWord = new PhpWord();
+ $this->assertEquals(new Section(1), $phpWord->createSection());
+ $phpWord->createSection();
+ $this->assertEquals(2, \count($phpWord->getSections()));
}
/**
@@ -70,14 +59,11 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testSetGetDefaultFontName()
{
- $object = new PHPWord();
+ $phpWord = new PhpWord();
$fontName = 'Times New Roman';
- $this->assertEquals(
- PHPWord::DEFAULT_FONT_NAME,
- $object->getDefaultFontName()
- );
- $object->setDefaultFontName($fontName);
- $this->assertEquals($fontName, $object->getDefaultFontName());
+ $this->assertEquals(PhpWord::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName());
+ $phpWord->setDefaultFontName($fontName);
+ $this->assertEquals($fontName, $phpWord->getDefaultFontName());
}
/**
@@ -86,14 +72,11 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testSetGetDefaultFontSize()
{
- $object = new PHPWord();
+ $phpWord = new PhpWord();
$fontSize = 16;
- $this->assertEquals(
- PHPWord::DEFAULT_FONT_SIZE,
- $object->getDefaultFontSize()
- );
- $object->setDefaultFontSize($fontSize);
- $this->assertEquals($fontSize, $object->getDefaultFontSize());
+ $this->assertEquals(PhpWord::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
+ $phpWord->setDefaultFontSize($fontSize);
+ $this->assertEquals($fontSize, $phpWord->getDefaultFontSize());
}
/**
@@ -102,8 +85,8 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testSetDefaultParagraphStyle()
{
- $object = new PHPWord();
- $object->setDefaultParagraphStyle(array());
+ $phpWord = new PhpWord();
+ $phpWord->setDefaultParagraphStyle(array());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', Style::getStyle('Normal'));
}
@@ -115,17 +98,17 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testAddStyles()
{
- $object = new PHPWord();
+ $phpWord = new PhpWord();
$styles = array(
'Paragraph' => 'Paragraph',
- 'Font' => 'Font',
- 'Table' => 'TableFull',
- 'Link' => 'Font',
+ 'Font' => 'Font',
+ 'Table' => 'TableFull',
+ 'Link' => 'Font',
);
foreach ($styles as $key => $value) {
$method = "add{$key}Style";
$styleId = "{$key} Style";
- $object->$method($styleId, array());
+ $phpWord->$method($styleId, array());
$this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId));
}
@@ -136,10 +119,10 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testAddTitleStyle()
{
- $object = new PHPWord();
+ $phpWord = new PhpWord();
$titleLevel = 1;
$titleName = "Heading_{$titleLevel}";
- $object->addTitleStyle($titleLevel, array());
+ $phpWord->addTitleStyle($titleLevel, array());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName));
}
@@ -148,12 +131,15 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadTemplate()
{
- $file = join(
- DIRECTORY_SEPARATOR,
+ $templateFqfn = \join(
+ \DIRECTORY_SEPARATOR,
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blank.docx')
);
- $object = new PHPWord();
- $this->assertInstanceOf('PhpOffice\\PhpWord\\Template', $object->loadTemplate($file));
+ $phpWord = new PhpWord();
+ $this->assertInstanceOf(
+ 'PhpOffice\\PhpWord\\Template',
+ $phpWord->loadTemplate($templateFqfn)
+ );
}
/**
@@ -162,11 +148,11 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadTemplateException()
{
- $file = join(
- DIRECTORY_SEPARATOR,
+ $templateFqfn = \join(
+ \DIRECTORY_SEPARATOR,
array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'blanks.docx')
);
- $object = new PHPWord();
- $object->loadTemplate($file);
+ $phpWord = new PhpWord();
+ $phpWord->loadTemplate($templateFqfn);
}
}
\ No newline at end of file
diff --git a/Tests/_inc/TestHelperDOCX.php b/Tests/_inc/TestHelperDOCX.php
index 28975050..5345c4eb 100644
--- a/Tests/_inc/TestHelperDOCX.php
+++ b/Tests/_inc/TestHelperDOCX.php
@@ -1,7 +1,7 @@
save(self::$file);
$zip = new \ZipArchive;
$res = $zip->open(self::$file);
if ($res === true) {
- $zip->extractTo(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
+ $zip->extractTo(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
$zip->close();
}
- return new XmlDocument(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
+ return new XmlDocument(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
}
public static function clear()
@@ -38,8 +38,8 @@ class TestHelperDOCX
if (file_exists(self::$file)) {
unlink(self::$file);
}
- if (is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
- self::deleteDir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
+ if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) {
+ self::deleteDir(sys_get_temp_dir() . '/PhpWord_Unit_Test/');
}
}
diff --git a/Tests/_inc/XmlDocument.php b/Tests/_inc/XmlDocument.php
index 4d3d0034..3a6c182d 100644
--- a/Tests/_inc/XmlDocument.php
+++ b/Tests/_inc/XmlDocument.php
@@ -1,5 +1,5 @@
-
- ./Tests/PHPWord/
+
+ ./Tests/PhpWord/
diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php
index f9e08794..a1aafea9 100755
--- a/samples/Sample_01_SimpleText.php
+++ b/samples/Sample_01_SimpleText.php
@@ -2,20 +2,20 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
-$PHPWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16));
-$PHPWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
-$PHPWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
+$phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16));
+$phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
+$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Simple text
-$section->addTitle('Welcome to PHPWord', 1);
+$section->addTitle('Welcome to PhpWord', 1);
$section->addText('Hello World!');
// Two text break
@@ -52,7 +52,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php
index 6bbbe0bb..9d3ef32f 100755
--- a/samples/Sample_02_TabStops.php
+++ b/samples/Sample_02_TabStops.php
@@ -2,33 +2,33 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , ' Create new PHPWord object' , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , ' Create new PhpWord object' , EOL;
+$phpWord = new PhpOffice\PhpWord();
// Ads styles
-$PHPWord->addParagraphStyle('multipleTab', array(
+$phpWord->addParagraphStyle('multipleTab', array(
'tabs' => array(
new PhpOffice\PhpWord\Style\Tab('left', 1550),
new PhpOffice\PhpWord\Style\Tab('center', 3200),
new PhpOffice\PhpWord\Style\Tab('right', 5300)
)
));
-$PHPWord->addParagraphStyle('rightTab', array(
+$phpWord->addParagraphStyle('rightTab', array(
'tabs' => array(
new PhpOffice\PhpWord\Style\Tab('right', 9090)
)
));
-$PHPWord->addParagraphStyle('centerTab', array(
+$phpWord->addParagraphStyle('centerTab', array(
'tabs' => array(
new PhpOffice\PhpWord\Style\Tab('center', 4680)
)
));
// New portrait section
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add listitem elements
$section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab');
@@ -40,7 +40,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php
index 9c23e981..542b2d5c 100755
--- a/samples/Sample_03_Sections.php
+++ b/samples/Sample_03_Sections.php
@@ -2,28 +2,28 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , ' Create new PHPWord object' , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , ' Create new PhpWord object' , EOL;
+$phpWord = new PhpOffice\PhpWord();
// New portrait section
-$section = $PHPWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12));
+$section = $phpWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12));
$section->addText('I am placed on a default section.');
// New landscape section
-$section = $PHPWord->createSection(array('orientation' => 'landscape'));
+$section = $phpWord->createSection(array('orientation' => 'landscape'));
$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak();
$section->addPageBreak();
// New portrait section
-$section = $PHPWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
+$section = $phpWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
$section->addText('This section uses other margins.');
// New portrait section with Header & Footer
-$section = $PHPWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,));
+$section = $phpWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,));
$section->addText('This section and we play with header/footer height.');
$section->createHeader()->addText('Header');
$section->createFooter()->addText('Footer');
@@ -33,7 +33,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php
index 64625ac5..c7b8c354 100644
--- a/samples/Sample_04_Textrun.php
+++ b/samples/Sample_04_Textrun.php
@@ -2,20 +2,20 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , ' Create new PHPWord object' , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , ' Create new PhpWord object' , EOL;
+$phpWord = new PhpOffice\PhpWord();
// Ads styles
-$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100));
-$PHPWord->addFontStyle('BoldText', array('bold'=>true));
-$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
-$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
+$phpWord->addParagraphStyle('pStyle', array('spacing'=>100));
+$phpWord->addFontStyle('BoldText', array('bold'=>true));
+$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
+$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add text run
$textrun = $section->createTextRun('pStyle');
@@ -39,7 +39,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php
index 1fdae0cf..942d851d 100644
--- a/samples/Sample_05_Multicolumn.php
+++ b/samples/Sample_05_Multicolumn.php
@@ -2,40 +2,40 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
$filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' .
'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' .
'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' .
'Suspendisse congue congue leo sed pellentesque.';
// Normal
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addText('Normal paragraph. ' . $filler);
// Two columns
-$section = $PHPWord->createSection(array(
+$section = $phpWord->createSection(array(
'colsNum' => 2,
'colsSpace' => 1440,
'breakType' => 'continuous'));
$section->addText('Three columns, one inch (1440 twips) spacing. ' . $filler);
// Normal
-$section = $PHPWord->createSection(array('breakType' => 'continuous'));
+$section = $phpWord->createSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again. ' . $filler);
// Three columns
-$section = $PHPWord->createSection(array(
+$section = $phpWord->createSection(array(
'colsNum' => 3,
'colsSpace' => 720,
'breakType' => 'continuous'));
$section->addText('Three columns, half inch (720 twips) spacing. ' . $filler);
// Normal
-$section = $PHPWord->createSection(array('breakType' => 'continuous'));
+$section = $phpWord->createSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again.');
// Save file
@@ -43,7 +43,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php
index a0b33545..73555a44 100755
--- a/samples/Sample_06_Footnote.php
+++ b/samples/Sample_06_Footnote.php
@@ -2,20 +2,20 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
// New portrait section
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add style definitions
-$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100));
-$PHPWord->addFontStyle('BoldText', array('bold'=>true));
-$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
-$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
+$phpWord->addParagraphStyle('pStyle', array('spacing'=>100));
+$phpWord->addFontStyle('BoldText', array('bold'=>true));
+$phpWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
+$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// Add text elements
$textrun = $section->createTextRun('pStyle');
@@ -41,7 +41,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php
index f797b986..e41bffbd 100755
--- a/samples/Sample_07_TemplateCloneRow.php
+++ b/samples/Sample_07_TemplateCloneRow.php
@@ -2,13 +2,13 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
-$document = $PHPWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx');
+$document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx');
// Simple table
$document->cloneRow('rowValue', 10);
diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php
index c29c18a8..757a9aa7 100644
--- a/samples/Sample_08_ParagraphPagination.php
+++ b/samples/Sample_08_ParagraphPagination.php
@@ -2,19 +2,19 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
-$PHPWord->setDefaultParagraphStyle(array(
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
+$phpWord->setDefaultParagraphStyle(array(
'align' => 'both',
'spaceAfter' => PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12),
'spacing' => 120,
));
// Sample
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addText('Below are the samples on how to control your paragraph ' .
'pagination. See "Line and Page Break" tab on paragraph properties ' .
@@ -53,7 +53,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php
index 338e1fa4..0750f35e 100644
--- a/samples/Sample_09_Tables.php
+++ b/samples/Sample_09_Tables.php
@@ -2,12 +2,12 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , ' Create new PHPWord object' , EOL;
-$PHPWord = new PHPWord();
-$section = $PHPWord->createSection();
+echo date('H:i:s') , ' Create new PhpWord object' , EOL;
+$phpWord = new PhpOffice\PhpWord();
+$section = $phpWord->createSection();
$header = array('size' => 16, 'bold' => true);
// 1. Basic table
@@ -34,7 +34,7 @@ $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF'
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center');
-$PHPWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
+$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$table = $section->addTable('Fancy Table');
$table->addRow(900);
$table->addCell(2000, $styleCell)->addText('Row 1', $fontStyle);
@@ -64,7 +64,7 @@ $cellColSpan = array('gridSpan' => 2, 'valign' => 'center');
$cellHCentered = array('align' => 'center');
$cellVCentered = array('valign' => 'center');
-$PHPWord->addTableStyle('Colspan Rowspan', $styleTable);
+$phpWord->addTableStyle('Colspan Rowspan', $styleTable);
$table = $section->addTable('Colspan Rowspan');
$table->addRow();
$table->addCell(2000, $cellRowSpan)->addText('A', null, $cellHCentered);
@@ -81,7 +81,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php
index f6227005..506406a1 100644
--- a/samples/Sample_10_EastAsianFontStyle.php
+++ b/samples/Sample_10_EastAsianFontStyle.php
@@ -2,12 +2,12 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word Document
-echo date('H:i:s') , ' Create new PHPWord object' , EOL;
-$PHPWord = new PHPWord();
-$section = $PHPWord->createSection();
+echo date('H:i:s') , ' Create new PhpWord object' , EOL;
+$phpWord = new PhpOffice\PhpWord();
+$section = $phpWord->createSection();
$header = array('size' => 16, 'bold' => true);
//1.Use EastAisa FontStyle
$section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
@@ -17,7 +17,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php
index e5a54253..b5ff7cf0 100644
--- a/samples/Sample_11_ReadWord2007.php
+++ b/samples/Sample_11_ReadWord2007.php
@@ -2,19 +2,19 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// Read contents
$name = basename(__FILE__, '.php');
$source = "resources/{$name}.docx";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
-$PHPWord = PhpOffice\PhpWord\IOFactory::load($source);
+$phpWord = PhpOffice\PhpWord\IOFactory::load($source);
// (Re)write contents
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php
index 7cfbad8e..d410f76e 100644
--- a/samples/Sample_12_HeaderFooter.php
+++ b/samples/Sample_12_HeaderFooter.php
@@ -2,14 +2,14 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s') , " Create new PHPWord object" , EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s') , " Create new PhpWord object" , EOL;
+$phpWord = new PhpOffice\PhpWord();
// New portrait section
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add first page header
$header = $section->createHeader();
@@ -18,7 +18,7 @@ $table = $header->addTable();
$table->addRow();
$table->addCell(4500)->addText('This is the header.');
$table->addCell(4500)->addImage(
- 'resources/PHPWord.png',
+ 'resources/PhpWord.png',
array('width' => 80, 'height' => 80, 'align' => 'right')
);
@@ -49,7 +49,7 @@ $section->addTextBreak();
$section->addText('Some text...');
// New portrait section
-$section2 = $PHPWord->createSection();
+$section2 = $phpWord->createSection();
$sec2Header = $section2->createHeader();
$sec2Header->addText("All pages in Section 2 will Have this!");
@@ -64,7 +64,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php
index e5229c90..f406f4c0 100644
--- a/samples/Sample_13_Images.php
+++ b/samples/Sample_13_Images.php
@@ -6,14 +6,14 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addText('Local image without any styles:');
$section->addImage('resources/_mars.jpg');
$section->addTextBreak(2);
@@ -32,7 +32,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php
index 7624e150..b587ec63 100644
--- a/samples/Sample_14_ListItem.php
+++ b/samples/Sample_14_ListItem.php
@@ -6,14 +6,14 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add listitem elements
$section->addListItem('List Item 1', 0);
@@ -38,8 +38,8 @@ $section->addListItem('List Item 3', 0, null, $listStyle);
$section->addTextBreak(2);
// Add listitem elements
-$PHPWord->addFontStyle('myOwnStyle', array('color'=>'FF0000'));
-$PHPWord->addParagraphStyle('P-Style', array('spaceAfter'=>95));
+$phpWord->addFontStyle('myOwnStyle', array('color'=>'FF0000'));
+$phpWord->addParagraphStyle('P-Style', array('spaceAfter'=>95));
$listStyle = array('listType' => PhpOffice\PhpWord\Style\ListItem::TYPE_NUMBER_NESTED);
$section->addListItem('List Item 1', 0, 'myOwnStyle', $listStyle, 'P-Style');
$section->addListItem('List Item 2', 0, 'myOwnStyle', $listStyle, 'P-Style');
@@ -56,7 +56,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php
index 08ef742a..f0cc82d9 100644
--- a/samples/Sample_15_Link.php
+++ b/samples/Sample_15_Link.php
@@ -6,20 +6,20 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Add hyperlink elements
$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
$section->addTextBreak(2);
-$PHPWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000'));
+$phpWord->addLinkStyle('myOwnLinkStyle', array('bold'=>true, 'color'=>'808000'));
$section->addLink('http://www.bing.com', null, 'myOwnLinkStyle');
$section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle');
@@ -30,7 +30,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php
index d1d18fb6..40dc8c6a 100644
--- a/samples/Sample_16_Object.php
+++ b/samples/Sample_16_Object.php
@@ -6,14 +6,14 @@
// Init
error_reporting(E_ALL);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addText('You can open this OLE object by double clicking on the icon:');
$section->addTextBreak(2);
$section->addObject('resources/_sheet.xls');
@@ -25,7 +25,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php
index 0189bfce..a083770b 100644
--- a/samples/Sample_17_TitleTOC.php
+++ b/samples/Sample_17_TitleTOC.php
@@ -1,26 +1,26 @@
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
// Define the TOC font style
$fontStyle = array('spaceAfter'=>60, 'size'=>12);
// Add title styles
-$PHPWord->addTitleStyle(1, array('size'=>20, 'color'=>'333333', 'bold'=>true));
-$PHPWord->addTitleStyle(2, array('size'=>16, 'color'=>'666666'));
+$phpWord->addTitleStyle(1, array('size'=>20, 'color'=>'333333', 'bold'=>true));
+$phpWord->addTitleStyle(2, array('size'=>16, 'color'=>'666666'));
// Add text elements
$section->addText('Table of contents:');
@@ -57,7 +57,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php
index 06195567..6f5d1eee 100644
--- a/samples/Sample_18_Watermark.php
+++ b/samples/Sample_18_Watermark.php
@@ -1,20 +1,20 @@
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$header = $section->createHeader();
$header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
$section->addText('The header reference to the current section includes a watermark image.');
@@ -26,7 +26,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php
index 3863dfb9..145b8300 100644
--- a/samples/Sample_19_TextBreak.php
+++ b/samples/Sample_19_TextBreak.php
@@ -1,25 +1,25 @@
');
-require_once '../Classes/PHPWord.php';
+require_once '../Classes/PhpWord.php';
// New Word document
-echo date('H:i:s'), " Create new PHPWord object", EOL;
-$PHPWord = new PHPWord();
+echo date('H:i:s'), " Create new PhpWord object", EOL;
+$phpWord = new PhpOffice\PhpWord();
// Begin code
$fontStyle = array('size' => 24);
$paragraphStyle = array('spacing' => 240, 'size' => 24);
-$PHPWord->addFontStyle('fontStyle', array('size' => 9));
-$PHPWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
+$phpWord->addFontStyle('fontStyle', array('size' => 9));
+$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
$fontStyle = array('size' => 24);
-$section = $PHPWord->createSection();
+$section = $phpWord->createSection();
$section->addText('Text break with no style:');
$section->addTextBreak();
$section->addText('Text break with defined font style:');
@@ -39,7 +39,7 @@ $name = basename(__FILE__, '.php');
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
- $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, $writer);
+ $xmlWriter = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}