Method name & code format for PSR/phpdoc compliance

This commit is contained in:
Ivan Lanin 2014-03-24 00:26:10 +07:00
parent d7a66ca15e
commit aff112a13b
85 changed files with 1162 additions and 71 deletions

View File

@ -8,7 +8,7 @@ This release marked the transformation to namespaces (PHP 5.3+).
### Features ### Features
None yet None yet.
### Bugfixes ### Bugfixes
@ -16,7 +16,11 @@ None yet
### Miscellaneous ### Miscellaneous
- Documentation - @Progi1984 - Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82
- Reorganize and redesign samples folder - @ivanlanin GH-137
- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58
- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull
- Compliance to phpDocumentor - @ivanlanin
## 0.8.1 - 17 Mar 2014 ## 0.8.1 - 17 Mar 2014

View File

@ -47,11 +47,13 @@ Manual install
To install manually, `download PHPWord package from To install manually, `download PHPWord package from
github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__. github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__.
Extract the package and put the contents to your machine. To use the Extract the package and put the contents to your machine. To use the
library, include ``src/PhpWord/PhpWord.php`` in your script like below. library, include ``src/PhpWord/Autoloader.php`` in your script and
invoke ``Autoloader::register``.
.. code-block:: php .. code-block:: php
require_once '/path/to/src/PhpWord/PhpWord.php'; require_once '/path/to/src/PhpWord/Autoloader.php';
PhpOffice\PhpWord\Autoloader::register();
Using samples Using samples
------------- -------------

View File

@ -53,7 +53,7 @@ $document->setValue('userFirstName#3', 'Michael');
$document->setValue('userName#3', 'Ray'); $document->setValue('userName#3', 'Ray');
$document->setValue('userPhone#3', '+1 428 889 775'); $document->setValue('userPhone#3', '+1 428 889 775');
$name = 'Sample_07_TemplateCloneRow_result.docx'; $name = 'Sample_07_TemplateCloneRow.docx';
echo date('H:i:s'), " Write to Word2007 format", \EOL; echo date('H:i:s'), " Write to Word2007 format", \EOL;
$document->saveAs($name); $document->saveAs($name);
rename($name, "results/{$name}"); rename($name, "results/{$name}");

View File

@ -5,7 +5,10 @@
error_reporting(E_ALL); error_reporting(E_ALL);
define('CLI', (PHP_SAPI == 'cli') ? true : false); define('CLI', (PHP_SAPI == 'cli') ? true : false);
define('EOL', CLI ? PHP_EOL : '<br />'); define('EOL', CLI ? PHP_EOL : '<br />');
require_once '../src/PhpWord/PhpWord.php';
require_once '../src/PhpWord/Autoloader.php';
PhpOffice\PhpWord\Autoloader::register();
// Return to the caller script when runs by CLI // Return to the caller script when runs by CLI
if (CLI) { if (CLI) {
return; return;

View File

@ -25,11 +25,16 @@
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
/**
* Autoloader
*/
class Autoloader class Autoloader
{ {
const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\'; const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\';
/** /**
* Register
*
* @return void * @return void
*/ */
public static function register() public static function register()
@ -38,6 +43,8 @@ class Autoloader
} }
/** /**
* Autoload
*
* @param string $class * @param string $class
*/ */
public static function autoload($class) public static function autoload($class)

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
/**
* Document properties
*/
class DocumentProperties class DocumentProperties
{ {
/** Constants */ /** Constants */

View File

@ -26,6 +26,9 @@
*/ */
namespace PhpOffice\PhpWord\Exceptions; namespace PhpOffice\PhpWord\Exceptions;
/**
* General exception
*/
class Exception extends \Exception class Exception extends \Exception
{ {
} }

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
/**
* Footnote
*/
class Footnote class Footnote
{ {
/** /**

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/** /**
* Hash table
*
* @codeCoverageIgnore Legacy from PHPExcel * @codeCoverageIgnore Legacy from PHPExcel
*/ */
class HashTable class HashTable
@ -47,6 +49,8 @@ class HashTable
public $_keyMap = array(); public $_keyMap = array();
/** /**
* Create new
*
* @param \PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from * @param \PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from
*/ */
public function __construct($pSource = null) public function __construct($pSource = null)
@ -140,6 +144,8 @@ class HashTable
} }
/** /**
* Get item count
*
* @return int * @return int
*/ */
public function count() public function count()
@ -148,6 +154,8 @@ class HashTable
} }
/** /**
* Get hash code index
*
* @param string $pHashCode * @param string $pHashCode
* @return int Index * @return int Index
*/ */
@ -157,6 +165,8 @@ class HashTable
} }
/** /**
* Get by index
*
* @param int $pIndex * @param int $pIndex
* @return \PhpOffice\PhpWord\IComparable * @return \PhpOffice\PhpWord\IComparable
*/ */
@ -170,6 +180,7 @@ class HashTable
} }
/** /**
* Get by hashcode
* @param string $pHashCode * @param string $pHashCode
* @return \PhpOffice\PhpWord\IComparable * @return \PhpOffice\PhpWord\IComparable
* *
@ -184,6 +195,8 @@ class HashTable
} }
/** /**
* Convert to array
*
* @return \PhpOffice\PhpWord\IComparable[] * @return \PhpOffice\PhpWord\IComparable[]
*/ */
public function toArray() public function toArray()

View File

@ -27,9 +27,14 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/**
* IO factory
*/
abstract class IOFactory abstract class IOFactory
{ {
/** /**
* Create new writer
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $name * @param string $name
* @return \PhpOffice\PhpWord\Writer\IWriter * @return \PhpOffice\PhpWord\Writer\IWriter
@ -46,6 +51,8 @@ abstract class IOFactory
} }
/** /**
* Create new reader
*
* @param string $name * @param string $name
* @return \PhpOffice\PhpWord\Reader\IReader * @return \PhpOffice\PhpWord\Reader\IReader
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Section\MemoryImage; use PhpOffice\PhpWord\Section\MemoryImage;
/**
* Media
*/
class Media class Media
{ {
/** /**

View File

@ -31,6 +31,9 @@ use PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Template; use PhpOffice\PhpWord\Template;
/**
* PhpWord main class
*/
class PhpWord class PhpWord
{ {
const DEFAULT_FONT_COLOR = '000000'; // HEX const DEFAULT_FONT_COLOR = '000000'; // HEX
@ -45,25 +48,35 @@ class PhpWord
const DEFAULT_FONT_SIZE = 10; const DEFAULT_FONT_SIZE = 10;
/** /**
* Document properties object
*
* @var \PhpOffice\PhpWord\DocumentProperties * @var \PhpOffice\PhpWord\DocumentProperties
*/ */
private $_documentProperties; private $_documentProperties;
/** /**
* Default font name
*
* @var string * @var string
*/ */
private $_defaultFontName; private $_defaultFontName;
/** /**
* Default font size
* @var int * @var int
*/ */
private $_defaultFontSize; private $_defaultFontSize;
/** /**
* Collection of sections
*
* @var \PhpOffice\PhpWord\Section[] * @var \PhpOffice\PhpWord\Section[]
*/ */
private $_sections = array(); private $_sections = array();
/**
* Create new
*/
public function __construct() public function __construct()
{ {
$this->_documentProperties = new DocumentProperties(); $this->_documentProperties = new DocumentProperties();
@ -72,6 +85,8 @@ class PhpWord
} }
/** /**
* Get document properties object
*
* @return \PhpOffice\PhpWord\DocumentProperties * @return \PhpOffice\PhpWord\DocumentProperties
*/ */
public function getDocumentProperties() public function getDocumentProperties()
@ -80,6 +95,8 @@ class PhpWord
} }
/** /**
* Set document properties object
*
* @param \PhpOffice\PhpWord\DocumentProperties $documentProperties * @param \PhpOffice\PhpWord\DocumentProperties $documentProperties
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
*/ */
@ -91,6 +108,8 @@ class PhpWord
} }
/** /**
* Create new section
*
* @param \PhpOffice\PhpWord\Section\Settings $settings * @param \PhpOffice\PhpWord\Section\Settings $settings
* @return \PhpOffice\PhpWord\Section * @return \PhpOffice\PhpWord\Section
*/ */
@ -103,6 +122,8 @@ class PhpWord
} }
/** /**
* Get default font name
*
* @return string * @return string
*/ */
public function getDefaultFontName() public function getDefaultFontName()
@ -111,6 +132,8 @@ class PhpWord
} }
/** /**
* Set default font name
*
* @param string $fontName * @param string $fontName
*/ */
public function setDefaultFontName($fontName) public function setDefaultFontName($fontName)
@ -119,6 +142,8 @@ class PhpWord
} }
/** /**
* Get default font size
*
* @return string * @return string
*/ */
public function getDefaultFontSize() public function getDefaultFontSize()
@ -127,6 +152,8 @@ class PhpWord
} }
/** /**
* Set default font size
*
* @param int $fontSize * @param int $fontSize
*/ */
public function setDefaultFontSize($fontSize) public function setDefaultFontSize($fontSize)
@ -159,7 +186,8 @@ class PhpWord
* Adds a font style definition to styles.xml * Adds a font style definition to styles.xml
* *
* @param $styleName string * @param $styleName string
* @param $styles array * @param mixed $styleFont
* @param mixed $styleParagraph
*/ */
public function addFontStyle($styleName, $styleFont, $styleParagraph = null) public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
{ {
@ -169,8 +197,9 @@ class PhpWord
/** /**
* Adds a table style definition to styles.xml * Adds a table style definition to styles.xml
* *
* @param $styleName string * @param string $styleName
* @param $styles array * @param mixed $styleTable
* @param mixed $styleFirstRow
*/ */
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{ {
@ -180,8 +209,9 @@ class PhpWord
/** /**
* Adds a heading style definition to styles.xml * Adds a heading style definition to styles.xml
* *
* @param $titleCount int * @param int $titleCount
* @param $styles array * @param mixed $styleFont
* @param mixed $styleParagraph
*/ */
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
{ {
@ -191,8 +221,8 @@ class PhpWord
/** /**
* Adds a hyperlink style to styles.xml * Adds a hyperlink style to styles.xml
* *
* @param $styleName string * @param string $styleName
* @param $styles array * @param mixed $styles
*/ */
public function addLinkStyle($styleName, $styles) public function addLinkStyle($styleName, $styles)
{ {
@ -200,6 +230,8 @@ class PhpWord
} }
/** /**
* Get all sections
*
* @return \PhpOffice\PhpWord\Section[] * @return \PhpOffice\PhpWord\Section[]
*/ */
public function getSections() public function getSections()
@ -208,6 +240,8 @@ class PhpWord
} }
/** /**
* Load template by filename
*
* @param string $filename Fully qualified filename. * @param string $filename Fully qualified filename.
* @return \PhpOffice\PhpWord\Template * @return \PhpOffice\PhpWord\Template
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/** /**
* Reader abstract class
*
* @codeCoverageIgnore Abstract class * @codeCoverageIgnore Abstract class
*/ */
abstract class AbstractReader implements IReader abstract class AbstractReader implements IReader
@ -79,7 +81,7 @@ abstract class AbstractReader implements IReader
protected function openFile($pFilename) protected function openFile($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) { if (!\file_exists($pFilename) || !is_readable($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
} }

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
/**
* Reader interface
*/
interface IReader interface IReader
{ {
/** /**

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\File;
/**
* Reader for Word2007
*/
class Word2007 extends AbstractReader implements IReader class Word2007 extends AbstractReader implements IReader
{ {
/** /**
@ -42,7 +45,7 @@ class Word2007 extends AbstractReader implements IReader
public function canRead($pFilename) public function canRead($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new Exception("Could not open {$pFilename} for reading! File does not exist."); throw new Exception("Could not open {$pFilename} for reading! File does not exist.");
} }
@ -71,6 +74,8 @@ class Word2007 extends AbstractReader implements IReader
} }
/** /**
* Get zip content
*
* @param \ZipArchive $archive * @param \ZipArchive $archive
* @param string $fileName * @param string $fileName
* @param bool $removeNamespace * @param bool $removeNamespace
@ -434,6 +439,8 @@ class Word2007 extends AbstractReader implements IReader
} }
/** /**
* Return item of array
*
* @param array $array * @param array $array
* @param mixed $key * @param mixed $key
* @return mixed|null * @return mixed|null

View File

@ -42,6 +42,9 @@ use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Section\Title; use PhpOffice\PhpWord\Section\Title;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
/**
* Section
*/
class Section class Section
{ {
/** /**
@ -241,7 +244,7 @@ class Section
} }
$iconSrc = __DIR__ . '/_staticDocParts/'; $iconSrc = __DIR__ . '/_staticDocParts/';
if (!file_exists($iconSrc . '_' . $ext . '.png')) { if (!\file_exists($iconSrc . '_' . $ext . '.png')) {
$iconSrc = $iconSrc . '_default.png'; $iconSrc = $iconSrc . '_default.png';
} else { } else {
$iconSrc .= '_' . $ext . '.png'; $iconSrc .= '_' . $ext . '.png';
@ -425,6 +428,8 @@ class Section
} }
/** /**
* Get footer element
*
* @return \PhpOffice\PhpWord\Section\Footer * @return \PhpOffice\PhpWord\Section\Footer
*/ */
public function getFooter() public function getFooter()

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
/**
* Footer element
*/
class Footer class Footer
{ {
/** /**
@ -55,6 +58,8 @@ class Footer
/** /**
* Create a new Footer * Create a new Footer
*
* @param int $sectionCount
*/ */
public function __construct($sectionCount) public function __construct($sectionCount)
{ {
@ -96,6 +101,7 @@ class Footer
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun * @return \PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section\Footer;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Preserve text/field element
*/
class PreserveText class PreserveText
{ {
/** /**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Footnote element
*/
class Footnote class Footnote
{ {
/** /**
@ -52,6 +55,8 @@ class Footnote
/** /**
* Create a new Footnote Element * Create a new Footnote Element
*
* @param mixed $styleParagraph
*/ */
public function __construct($styleParagraph = null) public function __construct($styleParagraph = null)
{ {
@ -76,8 +81,8 @@ class Footnote
/** /**
* Add a Text Element * Add a Text Element
* *
* @var string $text * @param string $text
* @var mixed $styleFont * @param mixed $styleFont
* @return \PhpOffice\PhpWord\Section\Text * @return \PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text = null, $styleFont = null) public function addText($text = null, $styleFont = null)
@ -118,6 +123,8 @@ class Footnote
} }
/** /**
* Get paragraph style
*
* @return \PhpOffice\PhpWord\Style\Paragraph * @return \PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
/**
* Header element
*/
class Header class Header
{ {
/** /**
@ -84,6 +87,8 @@ class Header
/** /**
* Create a new Header * Create a new Header
*
* @param int $sectionCount
*/ */
public function __construct($sectionCount) public function __construct($sectionCount)
{ {
@ -125,6 +130,7 @@ class Header
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun * @return \PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Exceptions\InvalidImageException;
use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
/**
* Image element
*/
class Image class Image
{ {
/** /**
@ -72,7 +75,7 @@ class Image
{ {
$supportedImageTypes = array(\IMAGETYPE_JPEG, \IMAGETYPE_GIF, \IMAGETYPE_PNG, \IMAGETYPE_BMP, \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM); $supportedImageTypes = array(\IMAGETYPE_JPEG, \IMAGETYPE_GIF, \IMAGETYPE_PNG, \IMAGETYPE_BMP, \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM);
if (!file_exists($src)) { if (!\file_exists($src)) {
throw new InvalidImageException; throw new InvalidImageException;
} }

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Link element
*/
class Link class Link
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* List item element
*/
class ListItem class ListItem
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* Memory image element
*/
class MemoryImage class MemoryImage
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* Object element
*/
class Object class Object
{ {
/** /**
@ -74,7 +77,7 @@ class Object
$_supportedObjectTypes = array('xls', 'doc', 'ppt'); $_supportedObjectTypes = array('xls', 'doc', 'ppt');
$inf = pathinfo($src); $inf = pathinfo($src);
if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { if (\file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
$this->_src = $src; $this->_src = $src;
$this->_style = new \PhpOffice\PhpWord\Style\Image(); $this->_style = new \PhpOffice\PhpWord\Style\Image();

View File

@ -25,8 +25,14 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* Page break element
*/
class PageBreak class PageBreak
{ {
/**
* Create new page break
*/
public function __construct() public function __construct()
{ {
} }

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* Section settings
*/
class Settings class Settings
{ {
/** /**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Section\Table\Row; use PhpOffice\PhpWord\Section\Table\Row;
/**
* Table element
*/
class Table class Table
{ {
/** /**

View File

@ -38,6 +38,9 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
/**
* Table cell element
*/
class Cell class Cell
{ {
/** /**
@ -109,7 +112,8 @@ class Cell
* Add a Text Element * Add a Text Element
* *
* @param string $text * @param string $text
* @param mixed $style * @param mixed $styleFont
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\Text * @return \PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text, $styleFont = null, $styleParagraph = null) public function addText($text, $styleFont = null, $styleParagraph = null)
@ -261,7 +265,7 @@ class Cell
} }
$iconSrc = __DIR__ . '/../../_staticDocParts/'; $iconSrc = __DIR__ . '/../../_staticDocParts/';
if (!file_exists($iconSrc . '_' . $ext . '.png')) { if (!\file_exists($iconSrc . '_' . $ext . '.png')) {
$iconSrc = $iconSrc . '_default.png'; $iconSrc = $iconSrc . '_default.png';
} else { } else {
$iconSrc .= '_' . $ext . '.png'; $iconSrc .= '_' . $ext . '.png';
@ -308,6 +312,7 @@ class Cell
/** /**
* Create a new TextRun * Create a new TextRun
* *
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun * @return \PhpOffice\PhpWord\Section\TextRun
*/ */
public function createTextRun($styleParagraph = null) public function createTextRun($styleParagraph = null)

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section\Table; namespace PhpOffice\PhpWord\Section\Table;
/**
* Table row element
*/
class Row class Row
{ {
/** /**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Text element
*/
class Text class Text
{ {
/** /**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Text break element
*/
class TextBreak class TextBreak
{ {
/** /**
@ -46,6 +49,9 @@ class TextBreak
/** /**
* Create a new TextBreak Element * Create a new TextBreak Element
*
* @param mixed $fontStyle
* @param mixed $paragraphStyle
*/ */
public function __construct($fontStyle = null, $paragraphStyle = null) public function __construct($fontStyle = null, $paragraphStyle = null)
{ {

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Textrun/paragraph element
*/
class TextRun class TextRun
{ {
/** /**
@ -49,6 +52,8 @@ class TextRun
/** /**
* Create a new TextRun Element * Create a new TextRun Element
*
* @param mixed $styleParagraph
*/ */
public function __construct($styleParagraph = null) public function __construct($styleParagraph = null)
{ {
@ -73,8 +78,8 @@ class TextRun
/** /**
* Add a Text Element * Add a Text Element
* *
* @var string $text * @param string $text
* @var mixed $styleFont * @param mixed $styleFont
* @return \PhpOffice\PhpWord\Section\Text * @return \PhpOffice\PhpWord\Section\Text
*/ */
public function addText($text = null, $styleFont = null) public function addText($text = null, $styleFont = null)
@ -114,7 +119,7 @@ class TextRun
* Add a Image Element * Add a Image Element
* *
* @param string $imageSrc * @param string $imageSrc
* @param mixed $styleFont * @param mixed $style
* @return \PhpOffice\PhpWord\Section\Image * @return \PhpOffice\PhpWord\Section\Image
*/ */
public function addImage($imageSrc, $style = null) public function addImage($imageSrc, $style = null)
@ -149,7 +154,7 @@ class TextRun
/** /**
* Create a new Footnote Element * Create a new Footnote Element
* *
* @param string $text * @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\Footnote * @return \PhpOffice\PhpWord\Section\Footnote
*/ */
public function createFootnote($styleParagraph = null) public function createFootnote($styleParagraph = null)

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section; namespace PhpOffice\PhpWord\Section;
/**
* Title element
*/
class Title class Title
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
/**
* Settings
*/
class Settings class Settings
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
/**
* Common drawing functions
*/
class Drawing class Drawing
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
/**
* Common file functions
*/
class File class File
{ {
/** /**
@ -33,10 +36,10 @@ class File
* @param string $pFilename Filename * @param string $pFilename Filename
* @return bool * @return bool
*/ */
public static function file_exists($pFilename) public static function fileExists($pFilename)
{ {
// Regular file_exists // Regular file_exists
return file_exists($pFilename); return \file_exists($pFilename);
} }
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
/**
* Common font functions
*/
class Font class Font
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
/**
* Common string functions
*/
class String class String
{ {
/** /**

View File

@ -32,6 +32,8 @@ if (!defined('DATE_W3C')) {
} }
/** /**
* XMLWriter wrapper
*
* @method bool startElement(string $name) * @method bool startElement(string $name)
* @method bool writeAttribute(string $name, string $value) * @method bool writeAttribute(string $name, string $value)
* @method bool endElement() * @method bool endElement()
@ -57,6 +59,8 @@ class XMLWriter
private $_tempFileName = ''; private $_tempFileName = '';
/** /**
* Create new XMLWriter
*
* @param int $pTemporaryStorage Temporary storage location * @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder * @param string $pTemporaryStorageFolder Temporary storage folder
*/ */

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Shared;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
/** /**
* Zip stream wrapper
*
* @codeCoverageIgnore Legacy from PHPExcel * @codeCoverageIgnore Legacy from PHPExcel
*/ */
class ZipStreamWrapper class ZipStreamWrapper
@ -77,7 +79,7 @@ class ZipStreamWrapper
* @param string $options * @param string $options
* @param string $opened_path * @param string $opened_path
*/ */
public function stream_open($path, $mode, $options, &$opened_path) public function streamOpen($path, $mode, $options, &$opened_path)
{ {
// Check for mode // Check for mode
if ($mode{0} != 'r') { if ($mode{0} != 'r') {
@ -117,7 +119,7 @@ class ZipStreamWrapper
/** /**
* Stat stream * Stat stream
*/ */
public function stream_stat() public function streamStat()
{ {
return $this->_archive->statName($this->_fileNameInArchive); return $this->_archive->statName($this->_fileNameInArchive);
} }
@ -127,7 +129,7 @@ class ZipStreamWrapper
* *
* @param int $count * @param int $count
*/ */
public function stream_read($count) public function streamRead($count)
{ {
$ret = substr($this->_data, $this->_position, $count); $ret = substr($this->_data, $this->_position, $count);
$this->_position += strlen($ret); $this->_position += strlen($ret);
@ -137,7 +139,7 @@ class ZipStreamWrapper
/** /**
* Tell stream * Tell stream
*/ */
public function stream_tell() public function streamTell()
{ {
return $this->_position; return $this->_position;
} }
@ -145,7 +147,7 @@ class ZipStreamWrapper
/** /**
* EOF stream * EOF stream
*/ */
public function stream_eof() public function streamEof()
{ {
return $this->_position >= strlen($this->_data); return $this->_position >= strlen($this->_data);
} }
@ -156,7 +158,7 @@ class ZipStreamWrapper
* @param int $offset * @param int $offset
* @param mixed $whence * @param mixed $whence
*/ */
public function stream_seek($offset, $whence) public function streamSeek($offset, $whence)
{ {
switch ($whence) { switch ($whence) {
case \SEEK_SET: case \SEEK_SET:

View File

@ -29,14 +29,21 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull; use PhpOffice\PhpWord\Style\TableFull;
/**
* Style
*/
class Style class Style
{ {
/** /**
* Style register
*
* @var array * @var array
*/ */
private static $_styleElements = array(); private static $_styleElements = array();
/** /**
* Add paragraph style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styles
*/ */
@ -56,6 +63,8 @@ class Style
} }
/** /**
* Add font style
*
* @param string $styleName * @param string $styleName
* @param array $styleFont * @param array $styleFont
* @param array $styleParagraph * @param array $styleParagraph
@ -75,6 +84,8 @@ class Style
} }
/** /**
* Add link style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styles
*/ */
@ -94,8 +105,11 @@ class Style
} }
/** /**
* Add table style
*
* @param string $styleName * @param string $styleName
* @param array $styles * @param array $styleTable
* @param array $styleFirstRow
*/ */
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{ {
@ -107,7 +121,9 @@ class Style
} }
/** /**
* @param string $styleName * Add title style
*
* @param int $titleCount
* @param array $styleFont * @param array $styleFont
* @param array $styleParagraph * @param array $styleParagraph
*/ */
@ -128,6 +144,8 @@ class Style
} }
/** /**
* Set default paragraph style
*
* @param array $styles Paragraph style definition * @param array $styles Paragraph style definition
*/ */
public static function setDefaultParagraphStyle($styles) public static function setDefaultParagraphStyle($styles)
@ -146,7 +164,9 @@ class Style
} }
/** /**
* @param string * Get style by name
*
* @param string $styleName
*/ */
public static function getStyle($styleName) public static function getStyle($styleName)
{ {

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* Table cell style
*/
class Cell class Cell
{ {
const TEXT_DIR_BTLR = 'btLr'; const TEXT_DIR_BTLR = 'btLr';

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException; use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/**
* Font style
*/
class Font class Font
{ {
const UNDERLINE_NONE = 'none'; const UNDERLINE_NONE = 'none';
@ -72,6 +75,8 @@ class Font
private $_type; private $_type;
/** /**
* Paragraph style
*
* @var \PhpOffice\PhpWord\Style\Paragraph * @var \PhpOffice\PhpWord\Style\Paragraph
*/ */
private $_paragraphStyle; private $_paragraphStyle;
@ -91,31 +96,43 @@ class Font
private $_size = PhpWord::DEFAULT_FONT_SIZE; private $_size = PhpWord::DEFAULT_FONT_SIZE;
/** /**
* Bold
*
* @var bool * @var bool
*/ */
private $_bold = false; private $_bold = false;
/** /**
* Italic
*
* @var bool * @var bool
*/ */
private $_italic = false; private $_italic = false;
/** /**
* Superscript
*
* @var bool * @var bool
*/ */
private $_superScript = false; private $_superScript = false;
/** /**
* Subscript
*
* @var bool * @var bool
*/ */
private $_subScript = false; private $_subScript = false;
/** /**
* Undeline
*
* @var string * @var string
*/ */
private $_underline = self::UNDERLINE_NONE; private $_underline = self::UNDERLINE_NONE;
/** /**
* Strikethrough
*
* @var bool * @var bool
*/ */
private $_strikethrough = false; private $_strikethrough = false;
@ -149,6 +166,8 @@ class Font
private $_hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE; private $_hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE;
/** /**
* Create new font style
*
* @param string $type Type of font * @param string $type Type of font
* @param array $paragraphStyle Paragraph styles definition * @param array $paragraphStyle Paragraph styles definition
*/ */
@ -188,6 +207,8 @@ class Font
} }
/** /**
* Set style value
*
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
@ -251,6 +272,8 @@ class Font
} }
/** /**
* Get bold
*
* @return bool * @return bool
*/ */
public function getBold() public function getBold()
@ -259,6 +282,8 @@ class Font
} }
/** /**
* Set bold
*
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -272,6 +297,8 @@ class Font
} }
/** /**
* Get italic
*
* @return bool * @return bool
*/ */
public function getItalic() public function getItalic()
@ -280,6 +307,8 @@ class Font
} }
/** /**
* Set italic
*
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -293,6 +322,8 @@ class Font
} }
/** /**
* Get superscript
*
* @return bool * @return bool
*/ */
public function getSuperScript() public function getSuperScript()
@ -301,6 +332,8 @@ class Font
} }
/** /**
* Set superscript
*
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -315,6 +348,8 @@ class Font
} }
/** /**
* Get subscript
*
* @return bool * @return bool
*/ */
public function getSubScript() public function getSubScript()
@ -323,6 +358,8 @@ class Font
} }
/** /**
* Set subscript
*
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -337,6 +374,8 @@ class Font
} }
/** /**
* Get underline
*
* @return string * @return string
*/ */
public function getUnderline() public function getUnderline()
@ -345,6 +384,8 @@ class Font
} }
/** /**
* Set underline
*
* @param string $pValue * @param string $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -358,6 +399,8 @@ class Font
} }
/** /**
* Get strikethrough
*
* @return bool * @return bool
*/ */
public function getStrikethrough() public function getStrikethrough()
@ -366,6 +409,8 @@ class Font
} }
/** /**
* Set strikethrough
*
* @param bool $pValue * @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -389,6 +434,8 @@ class Font
} }
/** /**
* Set font color
*
* @param string $pValue * @param string $pValue
* @return \PhpOffice\PhpWord\Style\Font * @return \PhpOffice\PhpWord\Style\Font
*/ */
@ -424,6 +471,8 @@ class Font
} }
/** /**
* Get style type
*
* @return string * @return string
*/ */
public function getStyleType() public function getStyleType()
@ -432,6 +481,8 @@ class Font
} }
/** /**
* Get paragraph style
*
* @return \PhpOffice\PhpWord\Style\Paragraph * @return \PhpOffice\PhpWord\Style\Paragraph
*/ */
public function getParagraphStyle() public function getParagraphStyle()
@ -440,6 +491,8 @@ class Font
} }
/** /**
* Set lineheight
*
* @param int|float|string $lineHeight * @param int|float|string $lineHeight
* @return $this * @return $this
* @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException * @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* Image and memory image style
*/
class Image class Image
{ {
const WRAPPING_STYLE_INLINE = 'inline'; const WRAPPING_STYLE_INLINE = 'inline';
@ -76,7 +79,7 @@ class Image
private $_marginLeft; private $_marginLeft;
/** /**
* Constructor * Create new image style
*/ */
public function __construct() public function __construct()
{ {

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* List item style
*/
class ListItem class ListItem
{ {
const TYPE_NUMBER = 7; const TYPE_NUMBER = 7;

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException; use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/**
* Paragraph style
*/
class Paragraph class Paragraph
{ {
const LINE_HEIGHT = 240; const LINE_HEIGHT = 240;
@ -130,6 +133,8 @@ class Paragraph
private $_pageBreakBefore = false; private $_pageBreakBefore = false;
/** /**
* Set style by array
*
* @param array $style * @param array $style
* @return $this * @return $this
*/ */
@ -316,11 +321,11 @@ class Paragraph
return $this->_tabs; return $this->_tabs;
} }
/* /**
* Set tabs * Set tabs
* *
* @param array $pValue * @param array $pValue
* @return \PhpOffice\PhpWord\Style\Paragraph * @return \PhpOffice\PhpWord\Style\Paragraph
*/ */
public function setTabs($pValue = null) public function setTabs($pValue = null)
{ {
@ -497,6 +502,8 @@ class Paragraph
} }
/** /**
* Get line height
*
* @return int|float * @return int|float
*/ */
public function getLineHeight() public function getLineHeight()

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* Table row style
*/
class Row class Row
{ {
/** /**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* TOC style
*/
class TOC class TOC
{ {
const TABLEADER_DOT = 'dot'; const TABLEADER_DOT = 'dot';

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Tab style
*/
class Tab class Tab
{ {
/** /**

View File

@ -25,13 +25,42 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* Table style
*/
class Table class Table
{ {
private $_cellMarginTop; /**
private $_cellMarginLeft; * Cell margin top
private $_cellMarginRight; *
private $_cellMarginBottom; * @var int
*/
private $_cellMarginTop = null;
/**
* Cell margin left
*
* @var int
*/
private $_cellMarginLeft = null;
/**
* Cell margin right
*
* @var int
*/
private $_cellMarginRight = null;
/**
* Cell margin bottom
*
* @var int
*/
private $_cellMarginBottom = null;
/**
* Create new table style
*/
public function __construct() public function __construct()
{ {
$this->_cellMarginTop = null; $this->_cellMarginTop = null;
@ -40,51 +69,115 @@ class Table
$this->_cellMarginBottom = null; $this->_cellMarginBottom = null;
} }
/**
* Set style value
*
* @param string $key
* @param mixed $value
*/
public function setStyleValue($key, $value) public function setStyleValue($key, $value)
{ {
$this->$key = $value; $this->$key = $value;
} }
/**
* Set cell margin top
*
* @param int $pValue
*/
public function setCellMarginTop($pValue = null) public function setCellMarginTop($pValue = null)
{ {
$this->_cellMarginTop = $pValue; $this->_cellMarginTop = $pValue;
} }
/**
* Get cell margin top
*
* @return int
*/
public function getCellMarginTop() public function getCellMarginTop()
{ {
return $this->_cellMarginTop; return $this->_cellMarginTop;
} }
/**
* Set cell margin left
*
* @param int $pValue
*/
public function setCellMarginLeft($pValue = null) public function setCellMarginLeft($pValue = null)
{ {
$this->_cellMarginLeft = $pValue; $this->_cellMarginLeft = $pValue;
} }
/**
* Get cell margin left
*
* @return int
*/
public function getCellMarginLeft() public function getCellMarginLeft()
{ {
return $this->_cellMarginLeft; return $this->_cellMarginLeft;
} }
/**
* Set cell margin right
*
* @param int $pValue
*/
public function setCellMarginRight($pValue = null) public function setCellMarginRight($pValue = null)
{ {
$this->_cellMarginRight = $pValue; $this->_cellMarginRight = $pValue;
} }
/**
* Get cell margin right
*
* @return int
*/
public function getCellMarginRight() public function getCellMarginRight()
{ {
return $this->_cellMarginRight; return $this->_cellMarginRight;
} }
/**
* Set cell margin bottom
*
* @param int $pValue
*/
public function setCellMarginBottom($pValue = null) public function setCellMarginBottom($pValue = null)
{ {
$this->_cellMarginBottom = $pValue; $this->_cellMarginBottom = $pValue;
} }
/**
* Get cell margin bottom
*
* @return int
*/
public function getCellMarginBottom() public function getCellMarginBottom()
{ {
return $this->_cellMarginBottom; return $this->_cellMarginBottom;
} }
/**
* Set TLRB cell margin
*
* @param int $pValue Margin in twips
*/
public function setCellMargin($pValue = null)
{
$this->_cellMarginTop = $pValue;
$this->_cellMarginLeft = $pValue;
$this->_cellMarginRight = $pValue;
$this->_cellMarginBottom = $pValue;
}
/**
* Get cell margin
*
* @return array
*/
public function getCellMargin() public function getCellMargin()
{ {
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
/**
* Table (full) style
*/
class TableFull class TableFull
{ {
/** /**
@ -35,90 +38,130 @@ class TableFull
private $_firstRow = null; private $_firstRow = null;
/** /**
* Cell margin top
*
* @var int * @var int
*/ */
private $_cellMarginTop = null; private $_cellMarginTop = null;
/** /**
* Cell margin left
*
* @var int * @var int
*/ */
private $_cellMarginLeft = null; private $_cellMarginLeft = null;
/** /**
* Cell margin right
*
* @var int * @var int
*/ */
private $_cellMarginRight = null; private $_cellMarginRight = null;
/** /**
* Cell margin bottom
*
* @var int * @var int
*/ */
private $_cellMarginBottom = null; private $_cellMarginBottom = null;
/** /**
* Background color
*
* @var string * @var string
*/ */
private $_bgColor; private $_bgColor;
/** /**
* Border size top
*
* @var int * @var int
*/ */
private $_borderTopSize; private $_borderTopSize;
/** /**
* @var string * Border color
*
* @var string top
*/ */
private $_borderTopColor; private $_borderTopColor;
/** /**
* Border size left
*
* @var int * @var int
*/ */
private $_borderLeftSize; private $_borderLeftSize;
/** /**
* Border color left
*
* @var string * @var string
*/ */
private $_borderLeftColor; private $_borderLeftColor;
/** /**
* Border size right
*
* @var int * @var int
*/ */
private $_borderRightSize; private $_borderRightSize;
/** /**
* Border color right
*
* @var string * @var string
*/ */
private $_borderRightColor; private $_borderRightColor;
/** /**
* Border size bottom
*
* @var int * @var int
*/ */
private $_borderBottomSize; private $_borderBottomSize;
/** /**
* Border color bottom
*
* @var string * @var string
*/ */
private $_borderBottomColor; private $_borderBottomColor;
/** /**
* Border size inside horizontal
*
* @var int * @var int
*/ */
private $_borderInsideHSize; private $_borderInsideHSize;
/** /**
* Border color inside horizontal
*
* @var string * @var string
*/ */
private $_borderInsideHColor; private $_borderInsideHColor;
/** /**
* Border size inside vertical
*
* @var int * @var int
*/ */
private $_borderInsideVSize; private $_borderInsideVSize;
/** /**
* Border color inside vertical
*
* @var string * @var string
*/ */
private $_borderInsideVColor; private $_borderInsideVColor;
/**
* Create new table style
*
* @param mixed $styleTable
* @param mixed $styleFirstRow
*/
public function __construct($styleTable = null, $styleFirstRow = null) public function __construct($styleTable = null, $styleFirstRow = null)
{ {
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
@ -153,6 +196,8 @@ class TableFull
} }
/** /**
* Set style value
*
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
@ -189,11 +234,22 @@ class TableFull
return $this->_lastRow; return $this->_lastRow;
} }
/**
* Get background
*
* @return \PhpOffice\PhpWord\Style\TableFull
*/
public function getBgColor() public function getBgColor()
{ {
return $this->_bgColor; return $this->_bgColor;
} }
/**
* Set background
*
* @param string $pValue
* @return \PhpOffice\PhpWord\Style\TableFull
*/
public function setBgColor($pValue = null) public function setBgColor($pValue = null)
{ {
$this->_bgColor = $pValue; $this->_bgColor = $pValue;
@ -202,7 +258,7 @@ class TableFull
/** /**
* Set TLRBVH Border Size * Set TLRBVH Border Size
* *
* @param int $pValue Border size in eighths of a point (1/8 point) * @param int $pValue Border size in eighths of a point (1/8 point)
*/ */
public function setBorderSize($pValue = null) public function setBorderSize($pValue = null)
{ {
@ -233,6 +289,7 @@ class TableFull
/** /**
* Set TLRBVH Border Color * Set TLRBVH Border Color
* @param string $pValue
*/ */
public function setBorderColor($pValue = null) public function setBorderColor($pValue = null)
{ {
@ -261,161 +318,321 @@ class TableFull
return array($t, $l, $r, $b, $h, $v); return array($t, $l, $r, $b, $h, $v);
} }
/**
* Set border size top
*
* @param $pValue
*/
public function setBorderTopSize($pValue = null) public function setBorderTopSize($pValue = null)
{ {
$this->_borderTopSize = $pValue; $this->_borderTopSize = $pValue;
} }
/**
* Get border size top
*
* @return
*/
public function getBorderTopSize() public function getBorderTopSize()
{ {
return $this->_borderTopSize; return $this->_borderTopSize;
} }
/**
* Set border color top
*
* @param $pValue
*/
public function setBorderTopColor($pValue = null) public function setBorderTopColor($pValue = null)
{ {
$this->_borderTopColor = $pValue; $this->_borderTopColor = $pValue;
} }
/**
* Get border color top
*
* @return
*/
public function getBorderTopColor() public function getBorderTopColor()
{ {
return $this->_borderTopColor; return $this->_borderTopColor;
} }
/**
* Set border size left
*
* @param $pValue
*/
public function setBorderLeftSize($pValue = null) public function setBorderLeftSize($pValue = null)
{ {
$this->_borderLeftSize = $pValue; $this->_borderLeftSize = $pValue;
} }
/**
* Get border size left
*
* @return
*/
public function getBorderLeftSize() public function getBorderLeftSize()
{ {
return $this->_borderLeftSize; return $this->_borderLeftSize;
} }
/**
* Set border color left
*
* @param $pValue
*/
public function setBorderLeftColor($pValue = null) public function setBorderLeftColor($pValue = null)
{ {
$this->_borderLeftColor = $pValue; $this->_borderLeftColor = $pValue;
} }
/**
* Get border color left
*
* @return
*/
public function getBorderLeftColor() public function getBorderLeftColor()
{ {
return $this->_borderLeftColor; return $this->_borderLeftColor;
} }
/**
* Set border size right
*
* @param $pValue
*/
public function setBorderRightSize($pValue = null) public function setBorderRightSize($pValue = null)
{ {
$this->_borderRightSize = $pValue; $this->_borderRightSize = $pValue;
} }
/**
* Get border size right
*
* @return
*/
public function getBorderRightSize() public function getBorderRightSize()
{ {
return $this->_borderRightSize; return $this->_borderRightSize;
} }
/**
* Set border color right
*
* @param $pValue
*/
public function setBorderRightColor($pValue = null) public function setBorderRightColor($pValue = null)
{ {
$this->_borderRightColor = $pValue; $this->_borderRightColor = $pValue;
} }
/**
* Get border color right
*
* @return
*/
public function getBorderRightColor() public function getBorderRightColor()
{ {
return $this->_borderRightColor; return $this->_borderRightColor;
} }
/**
* Set border size bottom
*
* @param $pValue
*/
public function setBorderBottomSize($pValue = null) public function setBorderBottomSize($pValue = null)
{ {
$this->_borderBottomSize = $pValue; $this->_borderBottomSize = $pValue;
} }
/**
* Get border size bottom
*
* @return
*/
public function getBorderBottomSize() public function getBorderBottomSize()
{ {
return $this->_borderBottomSize; return $this->_borderBottomSize;
} }
/**
* Set border color bottom
*
* @param $pValue
*/
public function setBorderBottomColor($pValue = null) public function setBorderBottomColor($pValue = null)
{ {
$this->_borderBottomColor = $pValue; $this->_borderBottomColor = $pValue;
} }
/**
* Get border color bottom
*
* @return
*/
public function getBorderBottomColor() public function getBorderBottomColor()
{ {
return $this->_borderBottomColor; return $this->_borderBottomColor;
} }
/**
* Set border color inside horizontal
*
* @param $pValue
*/
public function setBorderInsideHColor($pValue = null) public function setBorderInsideHColor($pValue = null)
{ {
$this->_borderInsideHColor = $pValue; $this->_borderInsideHColor = $pValue;
} }
/**
* Get border color inside horizontal
*
* @return
*/
public function getBorderInsideHColor() public function getBorderInsideHColor()
{ {
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
} }
/**
* Set border color inside vertical
*
* @param $pValue
*/
public function setBorderInsideVColor($pValue = null) public function setBorderInsideVColor($pValue = null)
{ {
$this->_borderInsideVColor = $pValue; $this->_borderInsideVColor = $pValue;
} }
/**
* Get border color inside vertical
*
* @return
*/
public function getBorderInsideVColor() public function getBorderInsideVColor()
{ {
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
} }
/**
* Set border size inside horizontal
*
* @param $pValue
*/
public function setBorderInsideHSize($pValue = null) public function setBorderInsideHSize($pValue = null)
{ {
$this->_borderInsideHSize = $pValue; $this->_borderInsideHSize = $pValue;
} }
/**
* Get border size inside horizontal
*
* @return
*/
public function getBorderInsideHSize() public function getBorderInsideHSize()
{ {
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
} }
/**
* Set border size inside vertical
*
* @param $pValue
*/
public function setBorderInsideVSize($pValue = null) public function setBorderInsideVSize($pValue = null)
{ {
$this->_borderInsideVSize = $pValue; $this->_borderInsideVSize = $pValue;
} }
/**
* Get border size inside vertical
*
* @return
*/
public function getBorderInsideVSize() public function getBorderInsideVSize()
{ {
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
} }
/**
* Set cell margin top
*
* @param int $pValue
*/
public function setCellMarginTop($pValue = null) public function setCellMarginTop($pValue = null)
{ {
$this->_cellMarginTop = $pValue; $this->_cellMarginTop = $pValue;
} }
/**
* Get cell margin top
*
* @return int
*/
public function getCellMarginTop() public function getCellMarginTop()
{ {
return $this->_cellMarginTop; return $this->_cellMarginTop;
} }
/**
* Set cell margin left
*
* @param int $pValue
*/
public function setCellMarginLeft($pValue = null) public function setCellMarginLeft($pValue = null)
{ {
$this->_cellMarginLeft = $pValue; $this->_cellMarginLeft = $pValue;
} }
/**
* Get cell margin left
*
* @return int
*/
public function getCellMarginLeft() public function getCellMarginLeft()
{ {
return $this->_cellMarginLeft; return $this->_cellMarginLeft;
} }
/**
* Set cell margin right
*
* @param int $pValue
*/
public function setCellMarginRight($pValue = null) public function setCellMarginRight($pValue = null)
{ {
$this->_cellMarginRight = $pValue; $this->_cellMarginRight = $pValue;
} }
/**
* Get cell margin right
*
* @return int
*/
public function getCellMarginRight() public function getCellMarginRight()
{ {
return $this->_cellMarginRight; return $this->_cellMarginRight;
} }
/**
* Set cell margin bottom
*
* @param int $pValue
*/
public function setCellMarginBottom($pValue = null) public function setCellMarginBottom($pValue = null)
{ {
$this->_cellMarginBottom = $pValue; $this->_cellMarginBottom = $pValue;
} }
/**
* Get cell margin bottom
*
* @return int
*/
public function getCellMarginBottom() public function getCellMarginBottom()
{ {
return $this->_cellMarginBottom; return $this->_cellMarginBottom;
@ -424,7 +641,7 @@ class TableFull
/** /**
* Set TLRB cell margin * Set TLRB cell margin
* *
* @param int $pValue Margin in twips * @param int $pValue Margin in twips
*/ */
public function setCellMargin($pValue = null) public function setCellMargin($pValue = null)
{ {
@ -434,6 +651,11 @@ class TableFull
$this->_cellMarginBottom = $pValue; $this->_cellMarginBottom = $pValue;
} }
/**
* Get cell margin
*
* @return array
*/
public function getCellMargin() public function getCellMargin()
{ {
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Tabs style
*/
class Tabs class Tabs
{ {
/** /**
@ -37,6 +40,7 @@ class Tabs
private $_tabs; private $_tabs;
/** /**
* Create new tab collection style
* *
* @param array $tabs * @param array $tabs
*/ */
@ -46,6 +50,8 @@ class Tabs
} }
/** /**
* Return XML
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
*/ */
public function toXml(XMLWriter &$xmlWriter = null) public function toXml(XMLWriter &$xmlWriter = null)

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
/**
* Table of contents
*/
class TOC class TOC
{ {
/** /**

View File

@ -28,19 +28,28 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Shared\String;
/**
* Template
*/
class Template class Template
{ {
/** /**
* ZipArchive object
*
* @var \ZipArchive * @var \ZipArchive
*/ */
private $_objZip; private $_objZip;
/** /**
* Temporary file name
*
* @var string * @var string
*/ */
private $_tempFileName; private $_tempFileName;
/** /**
* Document XML
*
* @var string * @var string
*/ */
private $_documentXML; private $_documentXML;
@ -249,6 +258,8 @@ class Template
} }
/** /**
* Save XML to temporary file
*
* @return string * @return string
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception
*/ */
@ -265,13 +276,15 @@ class Template
} }
/** /**
* Save XML to defined name
*
* @param string $strFilename * @param string $strFilename
*/ */
public function saveAs($strFilename) public function saveAs($strFilename)
{ {
$tempFilename = $this->save(); $tempFilename = $this->save();
if (file_exists($strFilename)) { if (\file_exists($strFilename)) {
unlink($strFilename); unlink($strFilename);
} }

View File

@ -25,12 +25,15 @@
namespace PhpOffice\PhpWord\Writer; namespace PhpOffice\PhpWord\Writer;
/**
* Writer interface
*/
interface IWriter interface IWriter
{ {
/** /**
* Save PhpWord to file * Save PhpWord to file
* *
* @param string $pFileName * @param string $pFilename
*/ */
public function save($pFilename = null); public function save($pFilename = null);
} }

View File

@ -34,14 +34,21 @@ use PhpOffice\PhpWord\Writer\ODText\Meta;
use PhpOffice\PhpWord\Writer\ODText\Mimetype; use PhpOffice\PhpWord\Writer\ODText\Mimetype;
use PhpOffice\PhpWord\Writer\ODText\Styles; use PhpOffice\PhpWord\Writer\ODText\Styles;
/**
* ODText writer
*/
class ODText implements IWriter class ODText implements IWriter
{ {
/** /**
* PhpWord object
*
* @var \PhpOffice\PhpWord\PhpWord * @var \PhpOffice\PhpWord\PhpWord
*/ */
private $_document; private $_document;
/** /**
* Individual writers
*
* @var \PhpOffice\PhpWord\Writer\ODText\WriterPart[] * @var \PhpOffice\PhpWord\Writer\ODText\WriterPart[]
*/ */
private $_writerParts; private $_writerParts;
@ -61,11 +68,14 @@ class ODText implements IWriter
private $_useDiskCaching = false; private $_useDiskCaching = false;
/** /**
* Disk caching directory
*
* @var string * @var string
*/ */
private $_diskCachingDirectory; private $_diskCachingDirectory;
/** /**
* Create new ODText writer
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
*/ */
public function __construct(PhpWord $phpWord = null) public function __construct(PhpWord $phpWord = null)
@ -96,7 +106,7 @@ class ODText implements IWriter
/** /**
* Save PhpWord to file * Save PhpWord to file
* *
* @param string $pFileName * @param string $pFilename
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception
*/ */
public function save($pFilename = null) public function save($pFilename = null)
@ -193,6 +203,8 @@ class ODText implements IWriter
} }
/** /**
* Get PhpWord object
*
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception
*/ */
@ -206,6 +218,8 @@ class ODText implements IWriter
} }
/** /**
* Set PhpWord object
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return \PhpOffice\PhpWord\Writer\ODText * @return \PhpOffice\PhpWord\Writer\ODText
*/ */
@ -226,6 +240,8 @@ class ODText implements IWriter
} }
/** /**
* Get writer part
*
* @param string $pPartName Writer part name * @param string $pPartName Writer part name
* @return \PhpOffice\PhpWord\Writer\ODText\WriterPart * @return \PhpOffice\PhpWord\Writer\ODText\WriterPart
*/ */
@ -272,6 +288,8 @@ class ODText implements IWriter
} }
/** /**
* Get disk caching directory
*
* @return string * @return string
*/ */
public function getDiskCachingDirectory() public function getDiskCachingDirectory()

View File

@ -44,6 +44,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC; use PhpOffice\PhpWord\TOC;
/**
* ODText content part writer
*/
class Content extends WriterPart class Content extends WriterPart
{ {
/** /**
@ -376,6 +379,8 @@ class Content extends WriterPart
/** /**
* Write TextBreak * Write TextBreak
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/ */
protected function _writeTextBreak(XMLWriter $xmlWriter = null) protected function _writeTextBreak(XMLWriter $xmlWriter = null)
{ {
@ -385,10 +390,22 @@ class Content extends WriterPart
} }
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
/**
* Write end section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null)
{ {
} }
/**
* Write section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null)
{ {
} }

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\File;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* ODText manifest part writer
*/
class Manifest extends WriterPart class Manifest extends WriterPart
{ {
/** /**
@ -120,7 +123,7 @@ class Manifest extends WriterPart
*/ */
private function _getImageMimeType($pFile = '') private function _getImageMimeType($pFile = '')
{ {
if (File::file_exists($pFile)) { if (File::fileExists($pFile)) {
$image = getimagesize($pFile); $image = getimagesize($pFile);
return image_type_to_mime_type($image[2]); return image_type_to_mime_type($image[2]);
} else { } else {

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* ODText meta part writer
*/
class Meta extends WriterPart class Meta extends WriterPart
{ {
/** /**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
/**
* ODText mimetype part writer
*/
class Mimetype extends WriterPart class Mimetype extends WriterPart
{ {
/** /**

View File

@ -32,6 +32,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull; use PhpOffice\PhpWord\Style\TableFull;
/**
* ODText styloes part writer
*/
class Styles extends WriterPart class Styles extends WriterPart
{ {
/** /**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Writer\IWriter; use PhpOffice\PhpWord\Writer\IWriter;
/**
* ODText writer part abstract
*/
abstract class WriterPart abstract class WriterPart
{ {
/** /**

View File

@ -45,6 +45,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC; use PhpOffice\PhpWord\TOC;
/**
* RTF writer
*/
class RTF implements IWriter class RTF implements IWriter
{ {
/** /**
@ -61,11 +64,29 @@ class RTF implements IWriter
*/ */
private $_drawingHashTable; private $_drawingHashTable;
/**
* Color register
*
* @var array
*/
private $_colorTable; private $_colorTable;
/**
* Font register
*
* @var array
*/
private $_fontTable; private $_fontTable;
/**
* Last paragraph style
*
* @var mixed
*/
private $_lastParagraphStyle; private $_lastParagraphStyle;
/** /**
* Create new RTF writer
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
*/ */
public function __construct(PhpWord $phpWord = null) public function __construct(PhpWord $phpWord = null)
@ -80,7 +101,7 @@ class RTF implements IWriter
/** /**
* Save PhpWord to file * Save PhpWord to file
* *
* @param string $pFileName * @param string $pFilename
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception
*/ */
public function save($pFilename = null) public function save($pFilename = null)
@ -113,6 +134,8 @@ class RTF implements IWriter
} }
/** /**
* Get PhpWord object
*
* @return \PhpOffice\PhpWord\PhpWord * @return \PhpOffice\PhpWord\PhpWord
* @throws \PhpOffice\PhpWord\Exceptions\Exception * @throws \PhpOffice\PhpWord\Exceptions\Exception
*/ */
@ -126,6 +149,8 @@ class RTF implements IWriter
} }
/** /**
* Set PhpWord object
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return \PhpOffice\PhpWord\Writer\RTF * @return \PhpOffice\PhpWord\Writer\RTF
*/ */
@ -145,6 +170,11 @@ class RTF implements IWriter
return $this->_drawingHashTable; return $this->_drawingHashTable;
} }
/**
* Get all data
*
* @return string
*/
private function getData() private function getData()
{ {
// PhpWord object : $this->_document // PhpWord object : $this->_document
@ -198,6 +228,11 @@ class RTF implements IWriter
return $sRTFContent; return $sRTFContent;
} }
/**
* Get all fonts
*
* @return array
*/
private function getDataFont() private function getDataFont()
{ {
$phpWord = $this->_document; $phpWord = $this->_document;
@ -248,6 +283,11 @@ class RTF implements IWriter
return $arrFonts; return $arrFonts;
} }
/**
* Get all colors
*
* @return array
*/
private function getDataColor() private function getDataColor()
{ {
$phpWord = $this->_document; $phpWord = $this->_document;
@ -304,6 +344,11 @@ class RTF implements IWriter
return $arrColors; return $arrColors;
} }
/**
* Get content data
*
* @return string
*/
private function getDataContent() private function getDataContent()
{ {
$phpWord = $this->_document; $phpWord = $this->_document;
@ -350,6 +395,12 @@ class RTF implements IWriter
return $sRTFBody; return $sRTFBody;
} }
/**
* Get text element content
*
* @param boolean $withoutP
* @return string
*/
private function getDataContentText(Text $text, $withoutP = false) private function getDataContentText(Text $text, $withoutP = false)
{ {
$sRTFText = ''; $sRTFText = '';
@ -438,6 +489,11 @@ class RTF implements IWriter
return $sRTFText; return $sRTFText;
} }
/**
* Get textrun content
*
* @return string
*/
private function getDataContentTextRun(TextRun $textrun) private function getDataContentTextRun(TextRun $textrun)
{ {
$sRTFText = ''; $sRTFText = '';
@ -456,6 +512,11 @@ class RTF implements IWriter
return $sRTFText; return $sRTFText;
} }
/**
* Get text break content
*
* @return string
*/
private function getDataContentTextBreak() private function getDataContentTextBreak()
{ {
$this->_lastParagraphStyle = ''; $this->_lastParagraphStyle = '';
@ -464,7 +525,7 @@ class RTF implements IWriter
} }
/** /**
* Write unsupported element * Get unsupported element content
* *
* @param string $element * @param string $element
*/ */

View File

@ -40,15 +40,58 @@ use PhpOffice\PhpWord\Writer\Word2007\Header;
use PhpOffice\PhpWord\Writer\Word2007\Rels; use PhpOffice\PhpWord\Writer\Word2007\Rels;
use PhpOffice\PhpWord\Writer\Word2007\Styles; use PhpOffice\PhpWord\Writer\Word2007\Styles;
/**
* Word2007 writer
*/
class Word2007 implements IWriter class Word2007 implements IWriter
{ {
/**
* PhpWord object
*
* @var PhpOffice\PhpWord\PhpWord
*/
private $_document; private $_document;
/**
* Individual writers
*
* @var PhpOffice\PhpWord\Writer\Word2007\WriterPart
*/
private $_writerParts; private $_writerParts;
/**
* Disk caching directory
*
* @var string
*/
private $_diskCachingDirectory; private $_diskCachingDirectory;
/**
* Use disk caching
*
* @var boolean
*/
private $_useDiskCaching = false; private $_useDiskCaching = false;
/**
* Types of images
*
* @var array
*/
private $_imageTypes = array(); private $_imageTypes = array();
/**
* Types of objects
*
* @var array
*/
private $_objectTypes = array(); private $_objectTypes = array();
/**
* Create new Word2007 writer
*
* @param PhpOffice\PhpWord\PhpWord
*/
public function __construct(PhpWord $phpWord = null) public function __construct(PhpWord $phpWord = null)
{ {
$this->_document = $phpWord; $this->_document = $phpWord;
@ -71,6 +114,11 @@ class Word2007 implements IWriter
} }
} }
/**
* Save document by name
*
* @param string $pFilename
*/
public function save($pFilename = null) public function save($pFilename = null)
{ {
if (!is_null($this->_document)) { if (!is_null($this->_document)) {
@ -212,6 +260,8 @@ class Word2007 implements IWriter
} }
/** /**
* Check content types
*
* @param string $src * @param string $src
*/ */
private function checkContentTypes($src) private function checkContentTypes($src)
@ -251,6 +301,12 @@ class Word2007 implements IWriter
} }
} }
/**
* Get writer part
*
* @param string $pPartName Writer part name
* @return \PhpOffice\PhpWord\Writer\ODText\WriterPart
*/
public function getWriterPart($pPartName = '') public function getWriterPart($pPartName = '')
{ {
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
@ -260,11 +316,22 @@ class Word2007 implements IWriter
} }
} }
/**
* Get use disk caching status
*
* @return boolean
*/
public function getUseDiskCaching() public function getUseDiskCaching()
{ {
return $this->_useDiskCaching; return $this->_useDiskCaching;
} }
/**
* Set use disk caching status
*
* @param boolean $pValue
* @param string $pDirectory
*/
public function setUseDiskCaching($pValue = false, $pDirectory = null) public function setUseDiskCaching($pValue = false, $pDirectory = null)
{ {
$this->_useDiskCaching = $pValue; $this->_useDiskCaching = $pValue;
@ -281,6 +348,8 @@ class Word2007 implements IWriter
} }
/** /**
* Get disk caching directory
*
* @return string * @return string
*/ */
public function getDiskCachingDirectory() public function getDiskCachingDirectory()
@ -288,6 +357,12 @@ class Word2007 implements IWriter
return $this->_diskCachingDirectory; return $this->_diskCachingDirectory;
} }
/**
* Check content types
*
* @param mixed $objZip
* @param mixed $element
*/
private function _addFileToPackage($objZip, $element) private function _addFileToPackage($objZip, $element)
{ {
if (isset($element['isMemImage']) && $element['isMemImage']) { if (isset($element['isMemImage']) && $element['isMemImage']) {

View File

@ -44,8 +44,20 @@ use PhpOffice\PhpWord\Style\Cell;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
/**
* Word2007 base part writer
*
* Write common parts of document.xml, headerx.xml, and footerx.xml
*/
class Base extends WriterPart class Base extends WriterPart
{ {
/**
* Write text element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Text $text
* @param boolean $withoutP
*/
protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false) protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
{ {
$styleFont = $text->getFontStyle(); $styleFont = $text->getFontStyle();
@ -96,6 +108,12 @@ class Base extends WriterPart
} }
} }
/**
* Write textrun element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun) protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
{ {
$elements = $textrun->getElements(); $elements = $textrun->getElements();
@ -135,10 +153,11 @@ class Base extends WriterPart
} }
/** /**
* Write paragraph style
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Paragraph $style * @param \PhpOffice\PhpWord\Style\Paragraph $style
* @param bool $withoutPPR * @param bool $withoutPPR
* @return void
*/ */
protected function _writeParagraphStyle( protected function _writeParagraphStyle(
XMLWriter $xmlWriter, XMLWriter $xmlWriter,
@ -236,6 +255,13 @@ class Base extends WriterPart
} }
} }
/**
* Write link element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Link $link
* @param boolean $withoutP
*/
protected function _writeLink(XMLWriter $xmlWriter, Link $link, $withoutP = false) protected function _writeLink(XMLWriter $xmlWriter, Link $link, $withoutP = false)
{ {
$rID = $link->getRelationId(); $rID = $link->getRelationId();
@ -292,6 +318,12 @@ class Base extends WriterPart
} }
} }
/**
* Write preserve text element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\TextRun $textrun
*/
protected function _writePreserveText(XMLWriter $xmlWriter, PreserveText $textrun) protected function _writePreserveText(XMLWriter $xmlWriter, PreserveText $textrun)
{ {
$styleFont = $textrun->getFontStyle(); $styleFont = $textrun->getFontStyle();
@ -384,6 +416,12 @@ class Base extends WriterPart
$xmlWriter->endElement(); // p $xmlWriter->endElement(); // p
} }
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
protected function _writeTextStyle(XMLWriter $xmlWriter, Font $style) protected function _writeTextStyle(XMLWriter $xmlWriter, Font $style)
{ {
$font = $style->getName(); $font = $style->getName();
@ -473,6 +511,8 @@ class Base extends WriterPart
} }
/** /**
* Write text break element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Section\TextBreak $element * @param \PhpOffice\PhpWord\Section\TextBreak $element
*/ */
@ -519,6 +559,12 @@ class Base extends WriterPart
} }
} }
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Table $table
*/
protected function _writeTable(XMLWriter $xmlWriter, Table $table) protected function _writeTable(XMLWriter $xmlWriter, Table $table)
{ {
$_rows = $table->getRows(); $_rows = $table->getRows();
@ -628,6 +674,12 @@ class Base extends WriterPart
} }
} }
/**
* Write table style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\Table $style
*/
protected function _writeTableStyle( protected function _writeTableStyle(
XMLWriter $xmlWriter, XMLWriter $xmlWriter,
\PhpOffice\PhpWord\Style\Table $style = null \PhpOffice\PhpWord\Style\Table $style = null
@ -675,6 +727,12 @@ class Base extends WriterPart
} }
} }
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\Cell $style
*/
protected function _writeCellStyle(XMLWriter $xmlWriter, Cell $style = null) protected function _writeCellStyle(XMLWriter $xmlWriter, Cell $style = null)
{ {
$bgColor = $style->getBgColor(); $bgColor = $style->getBgColor();
@ -779,8 +837,11 @@ class Base extends WriterPart
} }
/** /**
* Write image element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Section\Image|\PhpOffice\PhpWord\Section\MemoryImage $image * @param mixed $image
* @param boolean $withoutP
*/ */
protected function _writeImage(XMLWriter $xmlWriter, $image, $withoutP = false) protected function _writeImage(XMLWriter $xmlWriter, $image, $withoutP = false)
{ {
@ -859,6 +920,12 @@ class Base extends WriterPart
} }
} }
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param mixed $image
*/
protected function _writeWatermark(XMLWriter $xmlWriter, $image) protected function _writeWatermark(XMLWriter $xmlWriter, $image)
{ {
$rId = $image->getRelationId(); $rId = $image->getRelationId();
@ -903,6 +970,12 @@ class Base extends WriterPart
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write title element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Title $title
*/
protected function _writeTitle(XMLWriter $xmlWriter, Title $title) protected function _writeTitle(XMLWriter $xmlWriter, Title $title)
{ {
$text = htmlspecialchars($title->getText()); $text = htmlspecialchars($title->getText());
@ -945,6 +1018,12 @@ class Base extends WriterPart
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write footnote element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Footnote $footnote
*/
protected function _writeFootnote(XMLWriter $xmlWriter, Footnote $footnote) protected function _writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
{ {
$xmlWriter->startElement('w:footnote'); $xmlWriter->startElement('w:footnote');
@ -980,6 +1059,13 @@ class Base extends WriterPart
$xmlWriter->endElement(); // w:footnote $xmlWriter->endElement(); // w:footnote
} }
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Footnote $footnote
* @param boolean $withoutP
*/
protected function _writeFootnoteReference(XMLWriter $xmlWriter, Footnote $footnote, $withoutP = false) protected function _writeFootnoteReference(XMLWriter $xmlWriter, Footnote $footnote, $withoutP = false)
{ {
if (!$withoutP) { if (!$withoutP) {

View File

@ -29,8 +29,18 @@ use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\File;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 contenttypes part writer
*/
class ContentTypes extends WriterPart class ContentTypes extends WriterPart
{ {
/**
* Write [Content_Types].xml
* @param array $_imageTypes
* @param array $_objectTypes
* @param int $_cHdrs
* @param array $footers
*/
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers) public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
{ {
// Create XML writer // Create XML writer
@ -179,7 +189,7 @@ class ContentTypes extends WriterPart
*/ */
private function _getImageMimeType($pFile = '') private function _getImageMimeType($pFile = '')
{ {
if (File::file_exists($pFile)) { if (File::fileExists($pFile)) {
$image = getimagesize($pFile); $image = getimagesize($pFile);
return image_type_to_mime_type($image[2]); return image_type_to_mime_type($image[2]);
} else { } else {
@ -188,6 +198,8 @@ class ContentTypes extends WriterPart
} }
/** /**
* Write Default XML element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
* @param string $pPartname Part name * @param string $pPartname Part name
* @param string $pContentType Content type * @param string $pContentType Content type
@ -207,6 +219,8 @@ class ContentTypes extends WriterPart
} }
/** /**
* Write Override XML element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $pPartname Part name * @param string $pPartname Part name
* @param string $pContentType Content type * @param string $pContentType Content type

View File

@ -28,8 +28,14 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 contenttypes part writer
*/
class DocProps extends WriterPart class DocProps extends WriterPart
{ {
/**
* Write docProps/app.xml
*/
public function writeDocPropsApp(PhpWord $phpWord = null) public function writeDocPropsApp(PhpWord $phpWord = null)
{ {
// Create XML writer // Create XML writer
@ -122,6 +128,11 @@ class DocProps extends WriterPart
} }
/**
* Write docProps/core.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeDocPropsCore(PhpWord $phpWord = null) public function writeDocPropsCore(PhpWord $phpWord = null)
{ {
// Create XML writer // Create XML writer

View File

@ -44,8 +44,16 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC; use PhpOffice\PhpWord\TOC;
/**
* Word2007 document part writer
*/
class Document extends Base class Document extends Base
{ {
/**
* Write word/document.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeDocument(PhpWord $phpWord = null) public function writeDocument(PhpWord $phpWord = null)
{ {
// Create XML writer // Create XML writer
@ -128,6 +136,12 @@ class Document extends Base
return $xmlWriter->getData(); return $xmlWriter->getData();
} }
/**
* Write begin section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeSection(XMLWriter $xmlWriter, Section $section) private function _writeSection(XMLWriter $xmlWriter, Section $section)
{ {
$xmlWriter->startElement('w:p'); $xmlWriter->startElement('w:p');
@ -137,6 +151,12 @@ class Document extends Base
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write end section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeEndSection(XMLWriter $xmlWriter, Section $section) private function _writeEndSection(XMLWriter $xmlWriter, Section $section)
{ {
$settings = $section->getSettings(); $settings = $section->getSettings();
@ -270,6 +290,11 @@ class Document extends Base
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write page break element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writePageBreak(XMLWriter $xmlWriter) private function _writePageBreak(XMLWriter $xmlWriter)
{ {
$xmlWriter->startElement('w:p'); $xmlWriter->startElement('w:p');
@ -281,6 +306,12 @@ class Document extends Base
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write list item element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\ListItem $listItem
*/
public function _writeListItem(XMLWriter $xmlWriter, ListItem $listItem) public function _writeListItem(XMLWriter $xmlWriter, ListItem $listItem)
{ {
$textObject = $listItem->getTextObject(); $textObject = $listItem->getTextObject();
@ -320,6 +351,12 @@ class Document extends Base
$xmlWriter->endElement(); $xmlWriter->endElement();
} }
/**
* Write object element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Object $object
*/
protected function _writeObject(XMLWriter $xmlWriter, Object $object) protected function _writeObject(XMLWriter $xmlWriter, Object $object)
{ {
$rIdObject = $object->getRelationId(); $rIdObject = $object->getRelationId();
@ -379,6 +416,11 @@ class Document extends Base
$xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // w:p
} }
/**
* Write TOC element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writeTOC(XMLWriter $xmlWriter) private function _writeTOC(XMLWriter $xmlWriter)
{ {
$titles = TOC::getTitles(); $titles = TOC::getTitles();

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 document rels part writer
*/
class DocumentRels extends WriterPart class DocumentRels extends WriterPart
{ {
/**
* Write word/_rels/document.xml.rels
*
* @param array $_relsCollection
*/
public function writeDocumentRels($_relsCollection) public function writeDocumentRels($_relsCollection)
{ {
// Create XML writer // Create XML writer
@ -118,6 +126,11 @@ class DocumentRels extends WriterPart
return $xmlWriter->getData(); return $xmlWriter->getData();
} }
/**
* Write header footer rels
*
* @param array $_relsCollection
*/
public function writeHeaderFooterRels($_relsCollection) public function writeHeaderFooterRels($_relsCollection)
{ {
// Create XML writer // Create XML writer
@ -156,6 +169,15 @@ class DocumentRels extends WriterPart
return $xmlWriter->getData(); return $xmlWriter->getData();
} }
/**
* Write individual rels entry
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $pId Relationship ID
* @param string $pType Relationship type
* @param string $pTarget Relationship target
* @param string $pTargetMode Relationship target mode
*/
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{ {
if ($pType != '' && $pTarget != '') { if ($pType != '' && $pTarget != '') {

View File

@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footer part writer
*/
class Footer extends Base class Footer extends Base
{ {
/**
* Write word/footnotes.xml
*
* @param PhpOffice\PhpWord\Section\Footer $footer
*/
public function writeFooter(\PhpOffice\PhpWord\Section\Footer $footer) public function writeFooter(\PhpOffice\PhpWord\Section\Footer $footer)
{ {
// Create XML writer // Create XML writer

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Section\Footnote; use PhpOffice\PhpWord\Section\Footnote;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footnotes part writer
*/
class Footnotes extends Base class Footnotes extends Base
{ {
/**
* Write word/footnotes.xml
*
* @param array $allFootnotesCollection
*/
public function writeFootnotes($allFootnotesCollection) public function writeFootnotes($allFootnotesCollection)
{ {
// Create XML writer // Create XML writer

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footnotes rel part writer
*/
class FootnotesRels extends WriterPart class FootnotesRels extends WriterPart
{ {
/**
* Write word/_rels/footnotes.xml.rels
*
* @param mixed $_relsCollection
*/
public function writeFootnotesRels($_relsCollection) public function writeFootnotesRels($_relsCollection)
{ {
// Create XML writer // Create XML writer
@ -63,6 +71,15 @@ class FootnotesRels extends WriterPart
return $xmlWriter->getData(); return $xmlWriter->getData();
} }
/**
* Write individual rels entry
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $pId Relationship ID
* @param string $pType Relationship type
* @param string $pTarget Relationship target
* @param string $pTargetMode Relationship target mode
*/
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{ {
if ($pType != '' && $pTarget != '') { if ($pType != '' && $pTarget != '') {

View File

@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 header part writer
*/
class Header extends Base class Header extends Base
{ {
/**
* Write word/headerx.xml
*
* @param PhpOffice\PhpWord\Section\Header $header
*/
public function writeHeader(\PhpOffice\PhpWord\Section\Header $header) public function writeHeader(\PhpOffice\PhpWord\Section\Header $header)
{ {
// Create XML writer // Create XML writer

View File

@ -29,8 +29,16 @@ use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 rels part writer
*/
class Rels extends WriterPart class Rels extends WriterPart
{ {
/**
* Write _rels/.rels
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeRelationships(PhpWord $phpWord = null) public function writeRelationships(PhpWord $phpWord = null)
{ {
// Create XML writer // Create XML writer

View File

@ -32,10 +32,23 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull; use PhpOffice\PhpWord\Style\TableFull;
/**
* Word2007 styles part writer
*/
class Styles extends Base class Styles extends Base
{ {
/**
* PhpWord object
*
* @var PhpWord
*/
private $_document; private $_document;
/**
* Write word/styles.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeStyles(PhpWord $phpWord = null) public function writeStyles(PhpWord $phpWord = null)
{ {
// Create XML writer // Create XML writer
@ -184,6 +197,12 @@ class Styles extends Base
return $xmlWriter->getData(); return $xmlWriter->getData();
} }
/**
* Write table style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\TableFull $style
*/
private function _writeFullTableStyle(XMLWriter $xmlWriter, TableFull $style) private function _writeFullTableStyle(XMLWriter $xmlWriter, TableFull $style)
{ {
@ -304,6 +323,13 @@ class Styles extends Base
} }
} }
/**
* Write first row style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $type
* @param PhpOffice\PhpWord\Style\TableFull $style
*/
private function _writeRowStyle(XMLWriter $xmlWriter, $type, TableFull $style) private function _writeRowStyle(XMLWriter $xmlWriter, $type, TableFull $style)
{ {
$brdSz = $style->getBorderSize(); $brdSz = $style->getBorderSize();
@ -365,6 +391,11 @@ class Styles extends Base
} }
/**
* Write document defaults
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writeDocDefaults(XMLWriter $xmlWriter) private function _writeDocDefaults(XMLWriter $xmlWriter)
{ {
$fontName = $this->_document->getDefaultFontName(); $fontName = $this->_document->getDefaultFontName();

View File

@ -28,15 +28,33 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Writer\IWriter; use PhpOffice\PhpWord\Writer\IWriter;
/**
* Word2007 writer part abstract class
*/
abstract class WriterPart abstract class WriterPart
{ {
/**
* Parent writer
*
* @var IWriter
*/
private $_parentWriter; private $_parentWriter;
/**
* Set parent writer
*
* @param IWriter $pWriter
*/
public function setParentWriter(IWriter $pWriter = null) public function setParentWriter(IWriter $pWriter = null)
{ {
$this->_parentWriter = $pWriter; $this->_parentWriter = $pWriter;
} }
/**
* Get parent writer
*
* @return IWriter
*/
public function getParentWriter() public function getParentWriter()
{ {
if (!is_null($this->_parentWriter)) { if (!is_null($this->_parentWriter)) {

View File

@ -16,7 +16,7 @@ class FileTest extends \PHPUnit_Framework_TestCase
{ {
$dir = __DIR__ . "/../_files/templates"; $dir = __DIR__ . "/../_files/templates";
chdir($dir); chdir($dir);
$this->assertTrue(File::file_exists('blank.docx')); $this->assertTrue(File::fileExists('blank.docx'));
} }
/** /**
* Test file_exists() * Test file_exists()
@ -25,7 +25,7 @@ class FileTest extends \PHPUnit_Framework_TestCase
{ {
$dir = __DIR__ . "/../_files/templates"; $dir = __DIR__ . "/../_files/templates";
chdir($dir); chdir($dir);
$this->assertFalse(File::file_exists('404.docx')); $this->assertFalse(File::fileExists('404.docx'));
} }
/** /**

View File

@ -132,7 +132,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
$document->cloneRow('userId', 1); $document->cloneRow('userId', 1);
$document->setValue('userId#1', 'Test'); $document->setValue('userId#1', 'Test');
$document->saveAs($docName); $document->saveAs($docName);
$docFound = file_exists($docName); $docFound = \file_exists($docName);
unlink($docName); unlink($docName);
$this->assertEquals($expectedVar, $actualVar); $this->assertEquals($expectedVar, $actualVar);

View File

@ -74,7 +74,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$writer = new ODText($phpWord); $writer = new ODText($phpWord);
$writer->save($file); $writer->save($file);
$this->assertTrue(file_exists($file)); $this->assertTrue(\file_exists($file));
unlink($file); unlink($file);
} }

View File

@ -88,7 +88,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
$writer = new RTF($phpWord); $writer = new RTF($phpWord);
$writer->save($file); $writer->save($file);
$this->assertTrue(file_exists($file)); $this->assertTrue(\file_exists($file));
unlink($file); unlink($file);
} }

View File

@ -66,7 +66,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$writer = new Word2007($phpWord); $writer = new Word2007($phpWord);
$file = __DIR__ . "/../_files/temp.docx"; $file = __DIR__ . "/../_files/temp.docx";
$writer->save($file); $writer->save($file);
$this->assertTrue(file_exists($file)); $this->assertTrue(\file_exists($file));
unlink($file); unlink($file);
} }

View File

@ -36,7 +36,7 @@ class TestHelperDOCX
public static function clear() public static function clear()
{ {
if (file_exists(self::$file)) { if (\file_exists(self::$file)) {
unlink(self::$file); unlink(self::$file);
} }
if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) { if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) {

View File

@ -8,11 +8,11 @@ if (!defined('PHPWORD_TESTS_BASE_DIR')) {
$vendor = realpath(__DIR__ . '/../vendor'); $vendor = realpath(__DIR__ . '/../vendor');
if (file_exists($vendor . "/autoload.php")) { if (\file_exists($vendor . "/autoload.php")) {
require $vendor . "/autoload.php"; require $vendor . "/autoload.php";
} else { } else {
$vendor = realpath(__DIR__ . '/../../../'); $vendor = realpath(__DIR__ . '/../../../');
if (file_exists($vendor . "/autoload.php")) { if (\file_exists($vendor . "/autoload.php")) {
require $vendor . "/autoload.php"; require $vendor . "/autoload.php";
} else { } else {
throw new Exception("Unable to load dependencies"); throw new Exception("Unable to load dependencies");
@ -26,7 +26,7 @@ spl_autoload_register(function ($class) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class); $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$class = 'PhpWord' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . '_includes' . substr($class, strlen($prefix)); $class = 'PhpWord' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . '_includes' . substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
if (file_exists($file)) { if (\file_exists($file)) {
require_once $file; require_once $file;
} }
} }