Fixed some merge issues
This commit is contained in:
parent
39e4dd2259
commit
d09f0958c6
377
Classes/PHPWord.php
Normal file → Executable file
377
Classes/PHPWord.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,13 +20,13 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** PHPWORD_BASE_PATH */
|
/** PHPWORD_BASE_PATH */
|
||||||
if(!defined('PHPWORD_BASE_PATH')) {
|
if (!defined('PHPWORD_BASE_PATH')) {
|
||||||
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
|
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
|
||||||
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
|
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
|
||||||
PHPWord_Autoloader::Register();
|
PHPWord_Autoloader::Register();
|
||||||
@ -35,195 +35,208 @@ if(!defined('PHPWORD_BASE_PATH')) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord {
|
class PHPWord
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Document properties
|
|
||||||
*
|
|
||||||
* @var PHPWord_DocumentProperties
|
|
||||||
*/
|
|
||||||
private $_properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default Font Name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_defaultFontName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default Font Size
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_defaultFontSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collection of section elements
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $_sectionCollection = array();
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Document properties
|
||||||
* Create a new PHPWord Document
|
*
|
||||||
*/
|
* @var PHPWord_DocumentProperties
|
||||||
public function __construct() {
|
*/
|
||||||
$this->_properties = new PHPWord_DocumentProperties();
|
private $_properties;
|
||||||
$this->_defaultFontName = 'Arial';
|
|
||||||
$this->_defaultFontSize = 20;
|
/**
|
||||||
}
|
* Default Font Name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_defaultFontName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Font Size
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_defaultFontSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of section elements
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_sectionCollection = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new PHPWord Document
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_properties = new PHPWord_DocumentProperties();
|
||||||
|
$this->_defaultFontName = 'Arial';
|
||||||
|
$this->_defaultFontSize = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get properties
|
||||||
|
* @return PHPWord_DocumentProperties
|
||||||
|
*/
|
||||||
|
public function getProperties()
|
||||||
|
{
|
||||||
|
return $this->_properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set properties
|
||||||
|
*
|
||||||
|
* @param PHPWord_DocumentProperties $value
|
||||||
|
* @return PHPWord
|
||||||
|
*/
|
||||||
|
public function setProperties(PHPWord_DocumentProperties $value)
|
||||||
|
{
|
||||||
|
$this->_properties = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Section
|
||||||
|
*
|
||||||
|
* @param PHPWord_Section_Settings $settings
|
||||||
|
* @return PHPWord_Section
|
||||||
|
*/
|
||||||
|
public function createSection($settings = null)
|
||||||
|
{
|
||||||
|
$sectionCount = $this->_countSections() + 1;
|
||||||
|
|
||||||
|
$section = new PHPWord_Section($sectionCount, $settings);
|
||||||
|
$this->_sectionCollection[] = $section;
|
||||||
|
return $section;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default Font name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDefaultFontName()
|
||||||
|
{
|
||||||
|
return $this->_defaultFontName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default Font name
|
||||||
|
* @param string $pValue
|
||||||
|
*/
|
||||||
|
public function setDefaultFontName($pValue)
|
||||||
|
{
|
||||||
|
$this->_defaultFontName = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default Font size
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDefaultFontSize()
|
||||||
|
{
|
||||||
|
return $this->_defaultFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default Font size
|
||||||
|
* @param int $pValue
|
||||||
|
*/
|
||||||
|
public function setDefaultFontSize($pValue)
|
||||||
|
{
|
||||||
|
$pValue = $pValue * 2;
|
||||||
|
$this->_defaultFontSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a paragraph style definition to styles.xml
|
||||||
|
*
|
||||||
|
* @param $styleName string
|
||||||
|
* @param $styles array
|
||||||
|
*/
|
||||||
|
public function addParagraphStyle($styleName, $styles)
|
||||||
|
{
|
||||||
|
PHPWord_Style::addParagraphStyle($styleName, $styles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a font style definition to styles.xml
|
||||||
|
*
|
||||||
|
* @param $styleName string
|
||||||
|
* @param $styles array
|
||||||
|
*/
|
||||||
|
public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a table style definition to styles.xml
|
||||||
|
*
|
||||||
|
* @param $styleName string
|
||||||
|
* @param $styles array
|
||||||
|
*/
|
||||||
|
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||||
|
{
|
||||||
|
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a heading style definition to styles.xml
|
||||||
|
*
|
||||||
|
* @param $titleCount int
|
||||||
|
* @param $styles array
|
||||||
|
*/
|
||||||
|
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a hyperlink style to styles.xml
|
||||||
|
*
|
||||||
|
* @param $styleName string
|
||||||
|
* @param $styles array
|
||||||
|
*/
|
||||||
|
public function addLinkStyle($styleName, $styles)
|
||||||
|
{
|
||||||
|
PHPWord_Style::addLinkStyle($styleName, $styles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get sections
|
||||||
|
* @return PHPWord_Section[]
|
||||||
|
*/
|
||||||
|
public function getSections()
|
||||||
|
{
|
||||||
|
return $this->_sectionCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get section count
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function _countSections()
|
||||||
|
{
|
||||||
|
return count($this->_sectionCollection);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get properties
|
|
||||||
* @return PHPWord_DocumentProperties
|
|
||||||
*/
|
|
||||||
public function getProperties() {
|
|
||||||
return $this->_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set properties
|
|
||||||
*
|
|
||||||
* @param PHPWord_DocumentProperties $value
|
|
||||||
* @return PHPWord
|
|
||||||
*/
|
|
||||||
public function setProperties(PHPWord_DocumentProperties $value) {
|
|
||||||
$this->_properties = $value;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Section
|
|
||||||
*
|
|
||||||
* @param PHPWord_Section_Settings $settings
|
|
||||||
* @return PHPWord_Section
|
|
||||||
*/
|
|
||||||
public function createSection($settings = null) {
|
|
||||||
$sectionCount = $this->_countSections() + 1;
|
|
||||||
|
|
||||||
$section = new PHPWord_Section($sectionCount, $settings);
|
|
||||||
$this->_sectionCollection[] = $section;
|
|
||||||
return $section;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get default Font name
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDefaultFontName() {
|
|
||||||
return $this->_defaultFontName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set default Font name
|
|
||||||
* @param string $pValue
|
|
||||||
*/
|
|
||||||
public function setDefaultFontName($pValue) {
|
|
||||||
$this->_defaultFontName = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get default Font size
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDefaultFontSize() {
|
|
||||||
return $this->_defaultFontSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set default Font size
|
|
||||||
* @param int $pValue
|
|
||||||
*/
|
|
||||||
public function setDefaultFontSize($pValue) {
|
|
||||||
$pValue = $pValue * 2;
|
|
||||||
$this->_defaultFontSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a paragraph style definition to styles.xml
|
|
||||||
*
|
|
||||||
* @param $styleName string
|
|
||||||
* @param $styles array
|
|
||||||
*/
|
|
||||||
public function addParagraphStyle($styleName, $styles) {
|
|
||||||
PHPWord_Style::addParagraphStyle($styleName, $styles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a font style definition to styles.xml
|
|
||||||
*
|
|
||||||
* @param $styleName string
|
|
||||||
* @param $styles array
|
|
||||||
*/
|
|
||||||
public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
|
|
||||||
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a table style definition to styles.xml
|
|
||||||
*
|
|
||||||
* @param $styleName string
|
|
||||||
* @param $styles array
|
|
||||||
*/
|
|
||||||
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
|
|
||||||
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a heading style definition to styles.xml
|
|
||||||
*
|
|
||||||
* @param $titleCount int
|
|
||||||
* @param $styles array
|
|
||||||
*/
|
|
||||||
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
|
|
||||||
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a hyperlink style to styles.xml
|
|
||||||
*
|
|
||||||
* @param $styleName string
|
|
||||||
* @param $styles array
|
|
||||||
*/
|
|
||||||
public function addLinkStyle($styleName, $styles) {
|
|
||||||
PHPWord_Style::addLinkStyle($styleName, $styles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sections
|
|
||||||
* @return PHPWord_Section[]
|
|
||||||
*/
|
|
||||||
public function getSections() {
|
|
||||||
return $this->_sectionCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get section count
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private function _countSections() {
|
|
||||||
return count($this->_sectionCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a Template File
|
* Load a Template File
|
||||||
*
|
*
|
||||||
* @param string $strFilename
|
* @param string $strFilename
|
||||||
* @return PHPWord_Template
|
* @return PHPWord_Template
|
||||||
*/
|
*/
|
||||||
public function loadTemplate($strFilename) {
|
public function loadTemplate($strFilename)
|
||||||
if(file_exists($strFilename)) {
|
{
|
||||||
|
if (file_exists($strFilename)) {
|
||||||
$template = new PHPWord_Template($strFilename);
|
$template = new PHPWord_Template($strFilename);
|
||||||
return $template;
|
return $template;
|
||||||
} else {
|
} else {
|
||||||
trigger_error('Template file '.$strFilename.' not found.', E_USER_ERROR);
|
trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
5
Classes/PHPWord/DocumentProperties.php
Normal file → Executable file
5
Classes/PHPWord/DocumentProperties.php
Normal file → Executable file
@ -20,14 +20,13 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_DocumentProperties
|
* Class PHPWord_DocumentProperties
|
||||||
*/
|
*/
|
||||||
class PHPWord_DocumentProperties
|
class PHPWord_DocumentProperties
|
||||||
{
|
{
|
||||||
|
|||||||
45
Classes/PHPWord/Exception.php
Normal file → Executable file
45
Classes/PHPWord/Exception.php
Normal file → Executable file
@ -20,33 +20,30 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Exception
|
* Class PHPWord_Exception
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord
|
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Exception extends Exception {
|
class PHPWord_Exception extends Exception
|
||||||
/**
|
{
|
||||||
* Error handler callback
|
/**
|
||||||
*
|
* Error handler callback
|
||||||
* @param mixed $code
|
*
|
||||||
* @param mixed $string
|
* @param mixed $code
|
||||||
* @param mixed $file
|
* @param mixed $string
|
||||||
* @param mixed $line
|
* @param mixed $file
|
||||||
* @param mixed $context
|
* @param mixed $line
|
||||||
*/
|
* @param mixed $context
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
*/
|
||||||
$e = new self($string, $code);
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
$e->line = $line;
|
{
|
||||||
$e->file = $file;
|
$e = new self($string, $code);
|
||||||
throw $e;
|
$e->line = $line;
|
||||||
}
|
$e->file = $file;
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
3
Classes/PHPWord/HashTable.php
Normal file → Executable file
3
Classes/PHPWord/HashTable.php
Normal file → Executable file
@ -20,12 +20,11 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_HashTable
|
* PHPWord_HashTable
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/IOFactory.php
Normal file → Executable file
2
Classes/PHPWord/IOFactory.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Media.php
Normal file → Executable file
2
Classes/PHPWord/Media.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
755
Classes/PHPWord/Section.php
Normal file → Executable file
755
Classes/PHPWord/Section.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,378 +20,393 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Section
|
* Class PHPWord_Section
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Section
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Section {
|
class PHPWord_Section
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Section count
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_sectionCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section settings
|
|
||||||
*
|
|
||||||
* @var PHPWord_Section_Settings
|
|
||||||
*/
|
|
||||||
private $_settings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section Element Collection
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $_elementCollection = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section Headers
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $_headers = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section Footer
|
|
||||||
*
|
|
||||||
* @var PHPWord_Section_Footer
|
|
||||||
*/
|
|
||||||
private $_footer = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Section
|
|
||||||
*
|
|
||||||
* @param int $sectionCount
|
|
||||||
* @param mixed $settings
|
|
||||||
*/
|
|
||||||
public function __construct($sectionCount, $settings = null) {
|
|
||||||
$this->_sectionCount = $sectionCount;
|
|
||||||
$this->_settings = new PHPWord_Section_Settings();
|
|
||||||
|
|
||||||
if(!is_null($settings) && is_array($settings)) {
|
|
||||||
foreach($settings as $key => $value) {
|
|
||||||
if(substr($key, 0, 1) != '_') {
|
|
||||||
$key = '_'.$key;
|
|
||||||
}
|
|
||||||
$this->_settings->setSettingValue($key, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Section Settings
|
|
||||||
*
|
|
||||||
* @return PHPWord_Section_Settings
|
|
||||||
*/
|
|
||||||
public function getSettings() {
|
|
||||||
return $this->_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Text Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_Text
|
|
||||||
*/
|
|
||||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
|
||||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $text;
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Link Element
|
|
||||||
*
|
|
||||||
* @param string $linkSrc
|
|
||||||
* @param string $linkName
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_Link
|
|
||||||
*/
|
|
||||||
public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($linkSrc)){
|
|
||||||
$linkSrc = utf8_encode($linkSrc);
|
|
||||||
}
|
|
||||||
if(!is_null($linkName)) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($linkName)){
|
|
||||||
$linkName = utf8_encode($linkName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph);
|
|
||||||
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
|
||||||
$link->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $link;
|
|
||||||
return $link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a TextBreak Element
|
|
||||||
*
|
|
||||||
* @param int $count
|
|
||||||
*/
|
|
||||||
public function addTextBreak($count = 1) {
|
|
||||||
for($i=1; $i<=$count; $i++) {
|
|
||||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a PageBreak Element
|
|
||||||
*/
|
|
||||||
public function addPageBreak() {
|
|
||||||
$this->_elementCollection[] = new PHPWord_Section_PageBreak();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Table Element
|
|
||||||
*
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Table
|
|
||||||
*/
|
|
||||||
public function addTable($style = null) {
|
|
||||||
$table = new PHPWord_Section_Table('section', $this->_sectionCount, $style);
|
|
||||||
$this->_elementCollection[] = $table;
|
|
||||||
return $table;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a ListItem Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param int $depth
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleList
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_ListItem
|
|
||||||
*/
|
|
||||||
public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
|
||||||
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $listItem;
|
|
||||||
return $listItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a OLE-Object Element
|
|
||||||
*
|
|
||||||
* @param string $src
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Object
|
|
||||||
*/
|
|
||||||
public function addObject($src, $style = null) {
|
|
||||||
$object = new PHPWord_Section_Object($src, $style);
|
|
||||||
|
|
||||||
if(!is_null($object->getSource())) {
|
|
||||||
$inf = pathinfo($src);
|
|
||||||
$ext = $inf['extension'];
|
|
||||||
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
|
||||||
$ext = substr($ext, 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
|
|
||||||
if(!file_exists($iconSrc.'_'.$ext.'.png')) {
|
|
||||||
$iconSrc = $iconSrc.'_default.png';
|
|
||||||
} else {
|
|
||||||
$iconSrc .= '_'.$ext.'.png';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
|
||||||
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
|
|
||||||
$rID = $data[0];
|
|
||||||
$objectId = $data[1];
|
|
||||||
|
|
||||||
$object->setRelationId($rID);
|
|
||||||
$object->setObjectId($objectId);
|
|
||||||
$object->setImageRelationId($rIDimg);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $object;
|
|
||||||
return $object;
|
|
||||||
} else {
|
|
||||||
trigger_error('Source does not exist or unsupported object type.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Image Element
|
|
||||||
*
|
|
||||||
* @param string $src
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Image
|
|
||||||
*/
|
|
||||||
public function addImage($src, $style = null) {
|
|
||||||
$image = new PHPWord_Section_Image($src, $style);
|
|
||||||
|
|
||||||
if(!is_null($image->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
|
||||||
$image->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $image;
|
|
||||||
return $image;
|
|
||||||
} else {
|
|
||||||
trigger_error('Source does not exist or unsupported image type.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a by PHP created Image Element
|
|
||||||
*
|
|
||||||
* @param string $link
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_MemoryImage
|
|
||||||
*/
|
|
||||||
public function addMemoryImage($link, $style = null) {
|
|
||||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
|
||||||
if(!is_null($memoryImage->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
|
||||||
$memoryImage->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $memoryImage;
|
|
||||||
return $memoryImage;
|
|
||||||
} else {
|
|
||||||
trigger_error('Unsupported image type.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Table-of-Contents Element
|
|
||||||
*
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleTOC
|
|
||||||
* @return PHPWord_TOC
|
|
||||||
*/
|
|
||||||
public function addTOC($styleFont = null, $styleTOC = null) {
|
|
||||||
$toc = new PHPWord_TOC($styleFont, $styleTOC);
|
|
||||||
$this->_elementCollection[] = $toc;
|
|
||||||
return $toc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Title Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param int $depth
|
|
||||||
* @return PHPWord_Section_Title
|
|
||||||
*/
|
|
||||||
public function addTitle($text, $depth = 1) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
|
||||||
$styles = PHPWord_Style::getStyles();
|
|
||||||
if(array_key_exists('Heading_'.$depth, $styles)) {
|
|
||||||
$style = 'Heading'.$depth;
|
|
||||||
} else {
|
|
||||||
$style = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = new PHPWord_Section_Title($text, $depth, $style);
|
|
||||||
|
|
||||||
$data = PHPWord_TOC::addTitle($text, $depth);
|
|
||||||
$anchor = $data[0];
|
|
||||||
$bookmarkId = $data[1];
|
|
||||||
|
|
||||||
$title->setAnchor($anchor);
|
|
||||||
$title->setBookmarkId($bookmarkId);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $title;
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new TextRun
|
|
||||||
*
|
|
||||||
* @return PHPWord_Section_TextRun
|
|
||||||
*/
|
|
||||||
public function createTextRun($styleParagraph = null) {
|
|
||||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
|
||||||
$this->_elementCollection[] = $textRun;
|
|
||||||
return $textRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all Elements
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getElements() {
|
|
||||||
return $this->_elementCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Header
|
|
||||||
*
|
|
||||||
* @return PHPWord_Section_Header
|
|
||||||
*/
|
|
||||||
public function createHeader() {
|
|
||||||
$header = new PHPWord_Section_Header($this->_sectionCount);
|
|
||||||
$this->_headers[] = $header;
|
|
||||||
return $header;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Headers
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getHeaders() {
|
|
||||||
return $this->_headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is there a header for this section that is for the first page only?
|
* Section count
|
||||||
*
|
*
|
||||||
* If any of the PHPWord_Section_Header instances have a type of
|
* @var int
|
||||||
* PHPWord_Section_Header::FIRST then this method returns true. False
|
*/
|
||||||
* otherwise.
|
private $_sectionCount;
|
||||||
*
|
|
||||||
* @return Boolean
|
/**
|
||||||
*/
|
* Section settings
|
||||||
public function hasDifferentFirstPage() {
|
*
|
||||||
$value = array_filter($this->_headers, function(PHPWord_Section_Header &$header) {
|
* @var PHPWord_Section_Settings
|
||||||
return $header->getType() == PHPWord_Section_Header::FIRST;
|
*/
|
||||||
});
|
private $_settings;
|
||||||
return count($value) > 0;
|
|
||||||
}
|
/**
|
||||||
|
* Section Element Collection
|
||||||
/**
|
*
|
||||||
* Create a new Footer
|
* @var array
|
||||||
*
|
*/
|
||||||
* @return PHPWord_Section_Footer
|
private $_elementCollection = array();
|
||||||
*/
|
|
||||||
public function createFooter() {
|
/**
|
||||||
$footer = new PHPWord_Section_Footer($this->_sectionCount);
|
* Section Headers
|
||||||
$this->_footer = $footer;
|
*
|
||||||
return $footer;
|
* @var array
|
||||||
}
|
*/
|
||||||
|
private $_headers = array();
|
||||||
/**
|
|
||||||
* Get Footer
|
/**
|
||||||
*
|
* Section Footer
|
||||||
* @return PHPWord_Section_Footer
|
*
|
||||||
*/
|
* @var PHPWord_Section_Footer
|
||||||
public function getFooter() {
|
*/
|
||||||
return $this->_footer;
|
private $_footer = null;
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
/**
|
||||||
|
* Create a new Section
|
||||||
|
*
|
||||||
|
* @param int $sectionCount
|
||||||
|
* @param mixed $settings
|
||||||
|
*/
|
||||||
|
public function __construct($sectionCount, $settings = null)
|
||||||
|
{
|
||||||
|
$this->_sectionCount = $sectionCount;
|
||||||
|
$this->_settings = new PHPWord_Section_Settings();
|
||||||
|
|
||||||
|
if (!is_null($settings) && is_array($settings)) {
|
||||||
|
foreach ($settings as $key => $value) {
|
||||||
|
if (substr($key, 0, 1) != '_') {
|
||||||
|
$key = '_' . $key;
|
||||||
|
}
|
||||||
|
$this->_settings->setSettingValue($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Section Settings
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_Settings
|
||||||
|
*/
|
||||||
|
public function getSettings()
|
||||||
|
{
|
||||||
|
return $this->_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Text Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_Text
|
||||||
|
*/
|
||||||
|
public function addText($text, $styleFont = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $text;
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Link Element
|
||||||
|
*
|
||||||
|
* @param string $linkSrc
|
||||||
|
* @param string $linkName
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_Link
|
||||||
|
*/
|
||||||
|
public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($linkSrc)) {
|
||||||
|
$linkSrc = utf8_encode($linkSrc);
|
||||||
|
}
|
||||||
|
if (!is_null($linkName)) {
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($linkName)) {
|
||||||
|
$linkName = utf8_encode($linkName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph);
|
||||||
|
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
||||||
|
$link->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $link;
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a TextBreak Element
|
||||||
|
*
|
||||||
|
* @param int $count
|
||||||
|
*/
|
||||||
|
public function addTextBreak($count = 1)
|
||||||
|
{
|
||||||
|
for ($i = 1; $i <= $count; $i++) {
|
||||||
|
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a PageBreak Element
|
||||||
|
*/
|
||||||
|
public function addPageBreak()
|
||||||
|
{
|
||||||
|
$this->_elementCollection[] = new PHPWord_Section_PageBreak();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Table Element
|
||||||
|
*
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Table
|
||||||
|
*/
|
||||||
|
public function addTable($style = null)
|
||||||
|
{
|
||||||
|
$table = new PHPWord_Section_Table('section', $this->_sectionCount, $style);
|
||||||
|
$this->_elementCollection[] = $table;
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a ListItem Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param int $depth
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleList
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_ListItem
|
||||||
|
*/
|
||||||
|
public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleFont, $styleList, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $listItem;
|
||||||
|
return $listItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a OLE-Object Element
|
||||||
|
*
|
||||||
|
* @param string $src
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Object
|
||||||
|
*/
|
||||||
|
public function addObject($src, $style = null)
|
||||||
|
{
|
||||||
|
$object = new PHPWord_Section_Object($src, $style);
|
||||||
|
|
||||||
|
if (!is_null($object->getSource())) {
|
||||||
|
$inf = pathinfo($src);
|
||||||
|
$ext = $inf['extension'];
|
||||||
|
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||||
|
$ext = substr($ext, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
|
||||||
|
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
|
||||||
|
$iconSrc = $iconSrc . '_default.png';
|
||||||
|
} else {
|
||||||
|
$iconSrc .= '_' . $ext . '.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
||||||
|
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
|
||||||
|
$rID = $data[0];
|
||||||
|
$objectId = $data[1];
|
||||||
|
|
||||||
|
$object->setRelationId($rID);
|
||||||
|
$object->setObjectId($objectId);
|
||||||
|
$object->setImageRelationId($rIDimg);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $object;
|
||||||
|
return $object;
|
||||||
|
} else {
|
||||||
|
trigger_error('Source does not exist or unsupported object type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Image Element
|
||||||
|
*
|
||||||
|
* @param string $src
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Image
|
||||||
|
*/
|
||||||
|
public function addImage($src, $style = null)
|
||||||
|
{
|
||||||
|
$image = new PHPWord_Section_Image($src, $style);
|
||||||
|
|
||||||
|
if (!is_null($image->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||||
|
$image->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $image;
|
||||||
|
return $image;
|
||||||
|
} else {
|
||||||
|
trigger_error('Source does not exist or unsupported image type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a by PHP created Image Element
|
||||||
|
*
|
||||||
|
* @param string $link
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_MemoryImage
|
||||||
|
*/
|
||||||
|
public function addMemoryImage($link, $style = null)
|
||||||
|
{
|
||||||
|
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||||
|
if (!is_null($memoryImage->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||||
|
$memoryImage->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $memoryImage;
|
||||||
|
return $memoryImage;
|
||||||
|
} else {
|
||||||
|
trigger_error('Unsupported image type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Table-of-Contents Element
|
||||||
|
*
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleTOC
|
||||||
|
* @return PHPWord_TOC
|
||||||
|
*/
|
||||||
|
public function addTOC($styleFont = null, $styleTOC = null)
|
||||||
|
{
|
||||||
|
$toc = new PHPWord_TOC($styleFont, $styleTOC);
|
||||||
|
$this->_elementCollection[] = $toc;
|
||||||
|
return $toc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Title Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param int $depth
|
||||||
|
* @return PHPWord_Section_Title
|
||||||
|
*/
|
||||||
|
public function addTitle($text, $depth = 1)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$styles = PHPWord_Style::getStyles();
|
||||||
|
if (array_key_exists('Heading_' . $depth, $styles)) {
|
||||||
|
$style = 'Heading' . $depth;
|
||||||
|
} else {
|
||||||
|
$style = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = new PHPWord_Section_Title($text, $depth, $style);
|
||||||
|
|
||||||
|
$data = PHPWord_TOC::addTitle($text, $depth);
|
||||||
|
$anchor = $data[0];
|
||||||
|
$bookmarkId = $data[1];
|
||||||
|
|
||||||
|
$title->setAnchor($anchor);
|
||||||
|
$title->setBookmarkId($bookmarkId);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $title;
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new TextRun
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_TextRun
|
||||||
|
*/
|
||||||
|
public function createTextRun($styleParagraph = null)
|
||||||
|
{
|
||||||
|
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||||
|
$this->_elementCollection[] = $textRun;
|
||||||
|
return $textRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Elements
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getElements()
|
||||||
|
{
|
||||||
|
return $this->_elementCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Header
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_Header
|
||||||
|
*/
|
||||||
|
public function createHeader()
|
||||||
|
{
|
||||||
|
$header = new PHPWord_Section_Header($this->_sectionCount);
|
||||||
|
$this->_headers[] = $header;
|
||||||
|
return $header;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Headers
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getHeaders()
|
||||||
|
{
|
||||||
|
return $this->_headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there a header for this section that is for the first page only?
|
||||||
|
*
|
||||||
|
* If any of the PHPWord_Section_Header instances have a type of
|
||||||
|
* PHPWord_Section_Header::FIRST then this method returns true. False
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
public function hasDifferentFirstPage()
|
||||||
|
{
|
||||||
|
$value = array_filter($this->_headers, function (PHPWord_Section_Header &$header) {
|
||||||
|
return $header->getType() == PHPWord_Section_Header::FIRST;
|
||||||
|
});
|
||||||
|
return count($value) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Footer
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_Footer
|
||||||
|
*/
|
||||||
|
public function createFooter()
|
||||||
|
{
|
||||||
|
$footer = new PHPWord_Section_Footer($this->_sectionCount);
|
||||||
|
$this->_footer = $footer;
|
||||||
|
return $footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Footer
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_Footer
|
||||||
|
*/
|
||||||
|
public function getFooter()
|
||||||
|
{
|
||||||
|
return $this->_footer;
|
||||||
|
}
|
||||||
|
}
|
||||||
359
Classes/PHPWord/Section/Footer.php
Normal file → Executable file
359
Classes/PHPWord/Section/Footer.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,186 +20,193 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Section_Footer
|
* PHPWord_Section_Footer
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Section
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Section_Footer {
|
class PHPWord_Section_Footer
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Footer Count
|
/**
|
||||||
*
|
* Footer Count
|
||||||
* @var int
|
*
|
||||||
*/
|
* @var int
|
||||||
private $_footerCount;
|
*/
|
||||||
|
private $_footerCount;
|
||||||
/**
|
|
||||||
* Footer Relation ID
|
/**
|
||||||
*
|
* Footer Relation ID
|
||||||
* @var int
|
*
|
||||||
*/
|
* @var int
|
||||||
private $_rId;
|
*/
|
||||||
|
private $_rId;
|
||||||
/**
|
|
||||||
* Footer Element Collection
|
/**
|
||||||
*
|
* Footer Element Collection
|
||||||
* @var int
|
*
|
||||||
*/
|
* @var int
|
||||||
private $_elementCollection = array();
|
*/
|
||||||
|
private $_elementCollection = array();
|
||||||
/**
|
|
||||||
* Create a new Footer
|
/**
|
||||||
*/
|
* Create a new Footer
|
||||||
public function __construct($sectionCount) {
|
*/
|
||||||
$this->_footerCount = $sectionCount;
|
public function __construct($sectionCount)
|
||||||
}
|
{
|
||||||
|
$this->_footerCount = $sectionCount;
|
||||||
/**
|
|
||||||
* Add a Text Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_Text
|
|
||||||
*/
|
|
||||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
}
|
||||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $text;
|
/**
|
||||||
return $text;
|
* Add a Text Element
|
||||||
}
|
*
|
||||||
|
* @param string $text
|
||||||
/**
|
* @param mixed $styleFont
|
||||||
* Add a TextBreak Element
|
* @param mixed $styleParagraph
|
||||||
*
|
* @return PHPWord_Section_Text
|
||||||
* @param int $count
|
*/
|
||||||
*/
|
public function addText($text, $styleFont = null, $styleParagraph = null)
|
||||||
public function addTextBreak($count = 1) {
|
{
|
||||||
for($i=1; $i<=$count; $i++) {
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
$text = utf8_encode($text);
|
||||||
}
|
}
|
||||||
}
|
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $text;
|
||||||
/**
|
return $text;
|
||||||
* Create a new TextRun
|
|
||||||
*
|
|
||||||
* @return PHPWord_Section_TextRun
|
|
||||||
*/
|
|
||||||
public function createTextRun($styleParagraph = null) {
|
|
||||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
|
||||||
$this->_elementCollection[] = $textRun;
|
|
||||||
return $textRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Table Element
|
|
||||||
*
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Table
|
|
||||||
*/
|
|
||||||
public function addTable($style = null) {
|
|
||||||
$table = new PHPWord_Section_Table('footer', $this->_footerCount, $style);
|
|
||||||
$this->_elementCollection[] = $table;
|
|
||||||
return $table;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Image Element
|
|
||||||
*
|
|
||||||
* @param string $src
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Image
|
|
||||||
*/
|
|
||||||
public function addImage($src, $style = null) {
|
|
||||||
$image = new PHPWord_Section_Image($src, $style);
|
|
||||||
|
|
||||||
if(!is_null($image->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src);
|
|
||||||
$image->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $image;
|
|
||||||
return $image;
|
|
||||||
} else {
|
|
||||||
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a by PHP created Image Element
|
|
||||||
*
|
|
||||||
* @param string $link
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_MemoryImage
|
|
||||||
*/
|
|
||||||
public function addMemoryImage($link, $style = null) {
|
|
||||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
|
||||||
if(!is_null($memoryImage->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage);
|
|
||||||
$memoryImage->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $memoryImage;
|
|
||||||
return $memoryImage;
|
|
||||||
} else {
|
|
||||||
trigger_error('Unsupported image type.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a PreserveText Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_Footer_PreserveText
|
|
||||||
*/
|
|
||||||
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
}
|
||||||
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $ptext;
|
/**
|
||||||
return $ptext;
|
* Add a TextBreak Element
|
||||||
}
|
*
|
||||||
|
* @param int $count
|
||||||
/**
|
*/
|
||||||
* Get Footer Relation ID
|
public function addTextBreak($count = 1)
|
||||||
*/
|
{
|
||||||
public function getRelationId() {
|
for ($i = 1; $i <= $count; $i++) {
|
||||||
return $this->_rId;
|
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Set Footer Relation ID
|
/**
|
||||||
*
|
* Create a new TextRun
|
||||||
* @param int $rId
|
*
|
||||||
*/
|
* @return PHPWord_Section_TextRun
|
||||||
public function setRelationId($rId) {
|
*/
|
||||||
$this->_rId = $rId;
|
public function createTextRun($styleParagraph = null)
|
||||||
}
|
{
|
||||||
|
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||||
/**
|
$this->_elementCollection[] = $textRun;
|
||||||
* Get all Footer Elements
|
return $textRun;
|
||||||
*/
|
}
|
||||||
public function getElements() {
|
|
||||||
return $this->_elementCollection;
|
/**
|
||||||
}
|
* Add a Table Element
|
||||||
|
*
|
||||||
/**
|
* @param mixed $style
|
||||||
* Get Footer Count
|
* @return PHPWord_Section_Table
|
||||||
*/
|
*/
|
||||||
public function getFooterCount() {
|
public function addTable($style = null)
|
||||||
return $this->_footerCount;
|
{
|
||||||
}
|
$table = new PHPWord_Section_Table('footer', $this->_footerCount, $style);
|
||||||
}
|
$this->_elementCollection[] = $table;
|
||||||
?>
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Image Element
|
||||||
|
*
|
||||||
|
* @param string $src
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Image
|
||||||
|
*/
|
||||||
|
public function addImage($src, $style = null)
|
||||||
|
{
|
||||||
|
$image = new PHPWord_Section_Image($src, $style);
|
||||||
|
|
||||||
|
if (!is_null($image->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src);
|
||||||
|
$image->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $image;
|
||||||
|
return $image;
|
||||||
|
} else {
|
||||||
|
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a by PHP created Image Element
|
||||||
|
*
|
||||||
|
* @param string $link
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_MemoryImage
|
||||||
|
*/
|
||||||
|
public function addMemoryImage($link, $style = null)
|
||||||
|
{
|
||||||
|
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||||
|
if (!is_null($memoryImage->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage);
|
||||||
|
$memoryImage->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $memoryImage;
|
||||||
|
return $memoryImage;
|
||||||
|
} else {
|
||||||
|
trigger_error('Unsupported image type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a PreserveText Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_Footer_PreserveText
|
||||||
|
*/
|
||||||
|
public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $ptext;
|
||||||
|
return $ptext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Footer Relation ID
|
||||||
|
*/
|
||||||
|
public function getRelationId()
|
||||||
|
{
|
||||||
|
return $this->_rId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Footer Relation ID
|
||||||
|
*
|
||||||
|
* @param int $rId
|
||||||
|
*/
|
||||||
|
public function setRelationId($rId)
|
||||||
|
{
|
||||||
|
$this->_rId = $rId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Footer Elements
|
||||||
|
*/
|
||||||
|
public function getElements()
|
||||||
|
{
|
||||||
|
return $this->_elementCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Footer Count
|
||||||
|
*/
|
||||||
|
public function getFooterCount()
|
||||||
|
{
|
||||||
|
return $this->_footerCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Section/Footer/PreserveText.php
Normal file → Executable file
2
Classes/PHPWord/Section/Footer/PreserveText.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
504
Classes/PHPWord/Section/Header.php
Normal file → Executable file
504
Classes/PHPWord/Section/Header.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,265 +20,277 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Section_Header
|
* PHPWord_Section_Header
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Section
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Section_Header {
|
class PHPWord_Section_Header
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Header Count
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_headerCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Header Relation ID
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_rId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header type
|
* Header Count
|
||||||
*
|
*
|
||||||
* @var string
|
* @var int
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
*/
|
||||||
*/
|
private $_headerCount;
|
||||||
private $_type = PHPWord_Section_Header::AUTO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Even Numbered Pages Only
|
* Header Relation ID
|
||||||
* @var string
|
*
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
* @var int
|
||||||
*/
|
*/
|
||||||
const EVEN = 'even';
|
private $_rId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Header or Footer
|
* Header type
|
||||||
* @var string
|
*
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
* @var string
|
||||||
*/
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||||
const AUTO = 'default'; // Did not use DEFAULT because it is a PHP keyword
|
*/
|
||||||
|
private $_type = PHPWord_Section_Header::AUTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First Page Only
|
* Even Numbered Pages Only
|
||||||
* @var string
|
* @var string
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||||
*/
|
*/
|
||||||
const FIRST = 'first';
|
const EVEN = 'even';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header Element Collection
|
* Default Header or Footer
|
||||||
*
|
* @var string
|
||||||
* @var int
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||||
*/
|
*/
|
||||||
private $_elementCollection = array();
|
const AUTO = 'default'; // Did not use DEFAULT because it is a PHP keyword
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Header
|
* First Page Only
|
||||||
*/
|
* @var string
|
||||||
public function __construct($sectionCount) {
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||||
$this->_headerCount = $sectionCount;
|
*/
|
||||||
}
|
const FIRST = 'first';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a Text Element
|
* Header Element Collection
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @var int
|
||||||
* @param mixed $styleFont
|
*/
|
||||||
* @param mixed $styleParagraph
|
private $_elementCollection = array();
|
||||||
* @return PHPWord_Section_Text
|
|
||||||
*/
|
/**
|
||||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
* Create a new Header
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
*/
|
||||||
$text = utf8_encode($text);
|
public function __construct($sectionCount)
|
||||||
|
{
|
||||||
|
$this->_headerCount = $sectionCount;
|
||||||
}
|
}
|
||||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $text;
|
/**
|
||||||
return $text;
|
* Add a Text Element
|
||||||
}
|
*
|
||||||
|
* @param string $text
|
||||||
/**
|
* @param mixed $styleFont
|
||||||
* Add a TextBreak Element
|
* @param mixed $styleParagraph
|
||||||
*
|
* @return PHPWord_Section_Text
|
||||||
* @param int $count
|
*/
|
||||||
*/
|
public function addText($text, $styleFont = null, $styleParagraph = null)
|
||||||
public function addTextBreak($count = 1) {
|
{
|
||||||
for($i=1; $i<=$count; $i++) {
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
$text = utf8_encode($text);
|
||||||
}
|
}
|
||||||
}
|
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $text;
|
||||||
/**
|
return $text;
|
||||||
* Create a new TextRun
|
|
||||||
*
|
|
||||||
* @return PHPWord_Section_TextRun
|
|
||||||
*/
|
|
||||||
public function createTextRun($styleParagraph = null) {
|
|
||||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
|
||||||
$this->_elementCollection[] = $textRun;
|
|
||||||
return $textRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Table Element
|
|
||||||
*
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Table
|
|
||||||
*/
|
|
||||||
public function addTable($style = null) {
|
|
||||||
$table = new PHPWord_Section_Table('header', $this->_headerCount, $style);
|
|
||||||
$this->_elementCollection[] = $table;
|
|
||||||
return $table;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Image Element
|
|
||||||
*
|
|
||||||
* @param string $src
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Image
|
|
||||||
*/
|
|
||||||
public function addImage($src, $style = null) {
|
|
||||||
$image = new PHPWord_Section_Image($src, $style);
|
|
||||||
|
|
||||||
if(!is_null($image->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
|
||||||
$image->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $image;
|
|
||||||
return $image;
|
|
||||||
} else {
|
|
||||||
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a by PHP created Image Element
|
|
||||||
*
|
|
||||||
* @param string $link
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_MemoryImage
|
|
||||||
*/
|
|
||||||
public function addMemoryImage($link, $style = null) {
|
|
||||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
|
||||||
if(!is_null($memoryImage->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage);
|
|
||||||
$memoryImage->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $memoryImage;
|
|
||||||
return $memoryImage;
|
|
||||||
} else {
|
|
||||||
trigger_error('Unsupported image type.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a PreserveText Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param mixed $styleFont
|
|
||||||
* @param mixed $styleParagraph
|
|
||||||
* @return PHPWord_Section_Footer_PreserveText
|
|
||||||
*/
|
|
||||||
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
}
|
||||||
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $ptext;
|
|
||||||
return $ptext;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Watermark Element
|
|
||||||
*
|
|
||||||
* @param string $src
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Image
|
|
||||||
*/
|
|
||||||
public function addWatermark($src, $style = null) {
|
|
||||||
$image = new PHPWord_Section_Image($src, $style, true);
|
|
||||||
|
|
||||||
if(!is_null($image->getSource())) {
|
|
||||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
|
||||||
$image->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $image;
|
|
||||||
return $image;
|
|
||||||
} else {
|
|
||||||
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Header Relation ID
|
|
||||||
*/
|
|
||||||
public function getRelationId() {
|
|
||||||
return $this->_rId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Header Relation ID
|
|
||||||
*
|
|
||||||
* @param int $rId
|
|
||||||
*/
|
|
||||||
public function setRelationId($rId) {
|
|
||||||
$this->_rId = $rId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all Header Elements
|
|
||||||
*/
|
|
||||||
public function getElements() {
|
|
||||||
return $this->_elementCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Header Count
|
|
||||||
*/
|
|
||||||
public function getHeaderCount() {
|
|
||||||
return $this->_headerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Header Type
|
* Add a TextBreak Element
|
||||||
*/
|
*
|
||||||
public function getType() {
|
* @param int $count
|
||||||
return $this->_type;
|
*/
|
||||||
}
|
public function addTextBreak($count = 1)
|
||||||
|
{
|
||||||
|
for ($i = 1; $i <= $count; $i++) {
|
||||||
|
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset back to default
|
* Create a new TextRun
|
||||||
*/
|
*
|
||||||
public function resetType() {
|
* @return PHPWord_Section_TextRun
|
||||||
return $this->_type = PHPWord_Section_Header::AUTO;
|
*/
|
||||||
}
|
public function createTextRun($styleParagraph = null)
|
||||||
|
{
|
||||||
|
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||||
|
$this->_elementCollection[] = $textRun;
|
||||||
|
return $textRun;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First page only header
|
* Add a Table Element
|
||||||
*/
|
*
|
||||||
public function firstPage() {
|
* @param mixed $style
|
||||||
return $this->_type = PHPWord_Section_Header::FIRST;
|
* @return PHPWord_Section_Table
|
||||||
}
|
*/
|
||||||
|
public function addTable($style = null)
|
||||||
|
{
|
||||||
|
$table = new PHPWord_Section_Table('header', $this->_headerCount, $style);
|
||||||
|
$this->_elementCollection[] = $table;
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Even numbered Pages only
|
* Add a Image Element
|
||||||
*/
|
*
|
||||||
public function evenPage() {
|
* @param string $src
|
||||||
return $this->_type = PHPWord_Section_Header::EVEN;
|
* @param mixed $style
|
||||||
}
|
* @return PHPWord_Section_Image
|
||||||
|
*/
|
||||||
|
public function addImage($src, $style = null)
|
||||||
|
{
|
||||||
|
$image = new PHPWord_Section_Image($src, $style);
|
||||||
|
|
||||||
}
|
if (!is_null($image->getSource())) {
|
||||||
?>
|
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
||||||
|
$image->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $image;
|
||||||
|
return $image;
|
||||||
|
} else {
|
||||||
|
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a by PHP created Image Element
|
||||||
|
*
|
||||||
|
* @param string $link
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_MemoryImage
|
||||||
|
*/
|
||||||
|
public function addMemoryImage($link, $style = null)
|
||||||
|
{
|
||||||
|
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||||
|
if (!is_null($memoryImage->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage);
|
||||||
|
$memoryImage->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $memoryImage;
|
||||||
|
return $memoryImage;
|
||||||
|
} else {
|
||||||
|
trigger_error('Unsupported image type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a PreserveText Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_Footer_PreserveText
|
||||||
|
*/
|
||||||
|
public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $ptext;
|
||||||
|
return $ptext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Watermark Element
|
||||||
|
*
|
||||||
|
* @param string $src
|
||||||
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Image
|
||||||
|
*/
|
||||||
|
public function addWatermark($src, $style = null)
|
||||||
|
{
|
||||||
|
$image = new PHPWord_Section_Image($src, $style, true);
|
||||||
|
|
||||||
|
if (!is_null($image->getSource())) {
|
||||||
|
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
||||||
|
$image->setRelationId($rID);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $image;
|
||||||
|
return $image;
|
||||||
|
} else {
|
||||||
|
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Header Relation ID
|
||||||
|
*/
|
||||||
|
public function getRelationId()
|
||||||
|
{
|
||||||
|
return $this->_rId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Header Relation ID
|
||||||
|
*
|
||||||
|
* @param int $rId
|
||||||
|
*/
|
||||||
|
public function setRelationId($rId)
|
||||||
|
{
|
||||||
|
$this->_rId = $rId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Header Elements
|
||||||
|
*/
|
||||||
|
public function getElements()
|
||||||
|
{
|
||||||
|
return $this->_elementCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Header Count
|
||||||
|
*/
|
||||||
|
public function getHeaderCount()
|
||||||
|
{
|
||||||
|
return $this->_headerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Header Type
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset back to default
|
||||||
|
*/
|
||||||
|
public function resetType()
|
||||||
|
{
|
||||||
|
return $this->_type = PHPWord_Section_Header::AUTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First page only header
|
||||||
|
*/
|
||||||
|
public function firstPage()
|
||||||
|
{
|
||||||
|
return $this->_type = PHPWord_Section_Header::FIRST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Even numbered Pages only
|
||||||
|
*/
|
||||||
|
public function evenPage()
|
||||||
|
{
|
||||||
|
return $this->_type = PHPWord_Section_Header::EVEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Section/Image.php
Normal file → Executable file
2
Classes/PHPWord/Section/Image.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/Link.php
Normal file → Executable file
2
Classes/PHPWord/Section/Link.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/ListItem.php
Normal file → Executable file
2
Classes/PHPWord/Section/ListItem.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/MemoryImage.php
Normal file → Executable file
2
Classes/PHPWord/Section/MemoryImage.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/Object.php
Normal file → Executable file
2
Classes/PHPWord/Section/Object.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/PageBreak.php
Normal file → Executable file
2
Classes/PHPWord/Section/PageBreak.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/Settings.php
Normal file → Executable file
2
Classes/PHPWord/Section/Settings.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/Table.php
Normal file → Executable file
2
Classes/PHPWord/Section/Table.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
608
Classes/PHPWord/Section/Table/Cell.php
Normal file → Executable file
608
Classes/PHPWord/Section/Table/Cell.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,310 +20,318 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Section_Table_Cell
|
* PHPWord_Section_Table_Cell
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Section_Table
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Section_Table_Cell {
|
class PHPWord_Section_Table_Cell
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Cell Width
|
/**
|
||||||
*
|
* Cell Width
|
||||||
* @var int
|
*
|
||||||
*/
|
* @var int
|
||||||
private $_width = null;
|
*/
|
||||||
|
private $_width = null;
|
||||||
/**
|
|
||||||
* Cell Style
|
/**
|
||||||
*
|
* Cell Style
|
||||||
* @var PHPWord_Style_Cell
|
*
|
||||||
*/
|
* @var PHPWord_Style_Cell
|
||||||
private $_style;
|
*/
|
||||||
|
private $_style;
|
||||||
/**
|
|
||||||
* Cell Element Collection
|
/**
|
||||||
*
|
* Cell Element Collection
|
||||||
* @var array
|
*
|
||||||
*/
|
* @var array
|
||||||
private $_elementCollection = array();
|
*/
|
||||||
|
private $_elementCollection = array();
|
||||||
/**
|
|
||||||
* Table holder
|
/**
|
||||||
*
|
* Table holder
|
||||||
* @var string
|
*
|
||||||
*/
|
* @var string
|
||||||
private $_insideOf;
|
*/
|
||||||
|
private $_insideOf;
|
||||||
/**
|
|
||||||
* Section/Header/Footer count
|
/**
|
||||||
*
|
* Section/Header/Footer count
|
||||||
* @var int
|
*
|
||||||
*/
|
* @var int
|
||||||
private $_pCount;
|
*/
|
||||||
|
private $_pCount;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Table Cell
|
/**
|
||||||
*
|
* Create a new Table Cell
|
||||||
* @param string $insideOf
|
*
|
||||||
* @param int $pCount
|
* @param string $insideOf
|
||||||
* @param int $width
|
* @param int $pCount
|
||||||
* @param mixed $style
|
* @param int $width
|
||||||
*/
|
* @param mixed $style
|
||||||
public function __construct($insideOf, $pCount, $width = null, $style = null) {
|
*/
|
||||||
$this->_insideOf = $insideOf;
|
public function __construct($insideOf, $pCount, $width = null, $style = null)
|
||||||
$this->_pCount = $pCount;
|
{
|
||||||
$this->_width = $width;
|
$this->_insideOf = $insideOf;
|
||||||
|
$this->_pCount = $pCount;
|
||||||
if(!is_null($style)) {
|
$this->_width = $width;
|
||||||
if(is_array($style)) {
|
|
||||||
$this->_style = new PHPWord_Style_Cell();
|
if (!is_null($style)) {
|
||||||
|
if (is_array($style)) {
|
||||||
foreach($style as $key => $value) {
|
$this->_style = new PHPWord_Style_Cell();
|
||||||
if(substr($key, 0, 1) != '_') {
|
|
||||||
$key = '_'.$key;
|
foreach ($style as $key => $value) {
|
||||||
}
|
if (substr($key, 0, 1) != '_') {
|
||||||
$this->_style->setStyleValue($key, $value);
|
$key = '_' . $key;
|
||||||
}
|
}
|
||||||
} else {
|
$this->_style->setStyleValue($key, $value);
|
||||||
$this->_style = $style;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
$this->_style = $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Text Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Text
|
|
||||||
*/
|
|
||||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
|
||||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
|
||||||
$this->_elementCollection[] = $text;
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Link Element
|
|
||||||
*
|
|
||||||
* @param string $linkSrc
|
|
||||||
* @param string $linkName
|
|
||||||
* @param mixed $style
|
|
||||||
* @return PHPWord_Section_Link
|
|
||||||
*/
|
|
||||||
public function addLink($linkSrc, $linkName = null, $style = null) {
|
|
||||||
if($this->_insideOf == 'section') {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($linkSrc)){
|
|
||||||
$linkSrc = utf8_encode($linkSrc);
|
|
||||||
}
|
|
||||||
if(!is_null($linkName)) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($linkName)){
|
|
||||||
$linkName = utf8_encode($linkName);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $style);
|
|
||||||
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
|
||||||
$link->setRelationId($rID);
|
|
||||||
|
|
||||||
$this->_elementCollection[] = $link;
|
|
||||||
return $link;
|
|
||||||
} else {
|
|
||||||
trigger_error('Unsupported Link header / footer reference');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a TextBreak Element
|
|
||||||
*
|
|
||||||
* @param int $count
|
|
||||||
*/
|
|
||||||
public function addTextBreak() {
|
|
||||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a ListItem Element
|
|
||||||
*
|
|
||||||
* @param string $text
|
|
||||||
* @param int $depth
|
|
||||||
* @param mixed $styleText
|
|
||||||
* @param mixed $styleList
|
|
||||||
* @return PHPWord_Section_ListItem
|
|
||||||
*/
|
|
||||||
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
}
|
||||||
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList);
|
|
||||||
$this->_elementCollection[] = $listItem;
|
/**
|
||||||
return $listItem;
|
* Add a Text Element
|
||||||
}
|
*
|
||||||
|
* @param string $text
|
||||||
/**
|
* @param mixed $style
|
||||||
* Add a Image Element
|
* @return PHPWord_Section_Text
|
||||||
*
|
*/
|
||||||
* @param string $src
|
public function addText($text, $styleFont = null, $styleParagraph = null)
|
||||||
* @param mixed $style
|
{
|
||||||
* @return PHPWord_Section_Image
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
*/
|
$text = utf8_encode($text);
|
||||||
public function addImage($src, $style = null) {
|
}
|
||||||
$image = new PHPWord_Section_Image($src, $style);
|
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $text;
|
||||||
if(!is_null($image->getSource())) {
|
return $text;
|
||||||
if($this->_insideOf == 'section') {
|
}
|
||||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
|
||||||
} elseif($this->_insideOf == 'header') {
|
/**
|
||||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src);
|
* Add a Link Element
|
||||||
} elseif($this->_insideOf == 'footer') {
|
*
|
||||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src);
|
* @param string $linkSrc
|
||||||
}
|
* @param string $linkName
|
||||||
$image->setRelationId($rID);
|
* @param mixed $style
|
||||||
|
* @return PHPWord_Section_Link
|
||||||
$this->_elementCollection[] = $image;
|
*/
|
||||||
return $image;
|
public function addLink($linkSrc, $linkName = null, $style = null)
|
||||||
} else {
|
{
|
||||||
trigger_error('Source does not exist or unsupported image type.');
|
if ($this->_insideOf == 'section') {
|
||||||
}
|
if (!PHPWord_Shared_String::IsUTF8($linkSrc)) {
|
||||||
}
|
$linkSrc = utf8_encode($linkSrc);
|
||||||
|
}
|
||||||
/**
|
if (!is_null($linkName)) {
|
||||||
* Add a by PHP created Image Element
|
if (!PHPWord_Shared_String::IsUTF8($linkName)) {
|
||||||
*
|
$linkName = utf8_encode($linkName);
|
||||||
* @param string $link
|
}
|
||||||
* @param mixed $style
|
}
|
||||||
* @return PHPWord_Section_MemoryImage
|
|
||||||
*/
|
$link = new PHPWord_Section_Link($linkSrc, $linkName, $style);
|
||||||
public function addMemoryImage($link, $style = null) {
|
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
||||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
$link->setRelationId($rID);
|
||||||
if(!is_null($memoryImage->getSource())) {
|
|
||||||
if($this->_insideOf == 'section') {
|
$this->_elementCollection[] = $link;
|
||||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
return $link;
|
||||||
} elseif($this->_insideOf == 'header') {
|
} else {
|
||||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
|
trigger_error('Unsupported Link header / footer reference');
|
||||||
} elseif($this->_insideOf == 'footer') {
|
return false;
|
||||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
|
}
|
||||||
}
|
}
|
||||||
$memoryImage->setRelationId($rID);
|
|
||||||
|
/**
|
||||||
$this->_elementCollection[] = $memoryImage;
|
* Add a TextBreak Element
|
||||||
return $memoryImage;
|
*
|
||||||
} else {
|
* @param int $count
|
||||||
trigger_error('Unsupported image type.');
|
*/
|
||||||
}
|
public function addTextBreak()
|
||||||
}
|
{
|
||||||
|
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||||
/**
|
}
|
||||||
* Add a OLE-Object Element
|
|
||||||
*
|
/**
|
||||||
* @param string $src
|
* Add a ListItem Element
|
||||||
* @param mixed $style
|
*
|
||||||
* @return PHPWord_Section_Object
|
* @param string $text
|
||||||
*/
|
* @param int $depth
|
||||||
public function addObject($src, $style = null) {
|
* @param mixed $styleText
|
||||||
$object = new PHPWord_Section_Object($src, $style);
|
* @param mixed $styleList
|
||||||
|
* @return PHPWord_Section_ListItem
|
||||||
if(!is_null($object->getSource())) {
|
*/
|
||||||
$inf = pathinfo($src);
|
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null)
|
||||||
$ext = $inf['extension'];
|
{
|
||||||
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
$ext = substr($ext, 0, -1);
|
$text = utf8_encode($text);
|
||||||
}
|
}
|
||||||
|
$listItem = new PHPWord_Section_ListItem($text, $depth, $styleText, $styleList);
|
||||||
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
|
$this->_elementCollection[] = $listItem;
|
||||||
if(!file_exists($iconSrc.'_'.$ext.'.png')) {
|
return $listItem;
|
||||||
$iconSrc = $iconSrc.'_default.png';
|
}
|
||||||
} else {
|
|
||||||
$iconSrc .= '_'.$ext.'.png';
|
/**
|
||||||
}
|
* Add a Image Element
|
||||||
|
*
|
||||||
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
* @param string $src
|
||||||
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
|
* @param mixed $style
|
||||||
$rID = $data[0];
|
* @return PHPWord_Section_Image
|
||||||
$objectId = $data[1];
|
*/
|
||||||
|
public function addImage($src, $style = null)
|
||||||
$object->setRelationId($rID);
|
{
|
||||||
$object->setObjectId($objectId);
|
$image = new PHPWord_Section_Image($src, $style);
|
||||||
$object->setImageRelationId($rIDimg);
|
|
||||||
|
if (!is_null($image->getSource())) {
|
||||||
$this->_elementCollection[] = $object;
|
if ($this->_insideOf == 'section') {
|
||||||
return $object;
|
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||||
} else {
|
} elseif ($this->_insideOf == 'header') {
|
||||||
trigger_error('Source does not exist or unsupported object type.');
|
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src);
|
||||||
}
|
} elseif ($this->_insideOf == 'footer') {
|
||||||
}
|
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src);
|
||||||
|
}
|
||||||
/**
|
$image->setRelationId($rID);
|
||||||
* Add a PreserveText Element
|
|
||||||
*
|
$this->_elementCollection[] = $image;
|
||||||
* @param string $text
|
return $image;
|
||||||
* @param mixed $styleFont
|
} else {
|
||||||
* @param mixed $styleParagraph
|
trigger_error('Source does not exist or unsupported image type.');
|
||||||
* @return PHPWord_Section_Footer_PreserveText
|
}
|
||||||
*/
|
}
|
||||||
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
|
|
||||||
if($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
|
/**
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
* Add a by PHP created Image Element
|
||||||
$text = utf8_encode($text);
|
*
|
||||||
}
|
* @param string $link
|
||||||
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
* @param mixed $style
|
||||||
$this->_elementCollection[] = $ptext;
|
* @return PHPWord_Section_MemoryImage
|
||||||
return $ptext;
|
*/
|
||||||
} else {
|
public function addMemoryImage($link, $style = null)
|
||||||
trigger_error('addPreserveText only supported in footer/header.');
|
{
|
||||||
}
|
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||||
}
|
if (!is_null($memoryImage->getSource())) {
|
||||||
|
if ($this->_insideOf == 'section') {
|
||||||
/**
|
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||||
* Create a new TextRun
|
} elseif ($this->_insideOf == 'header') {
|
||||||
*
|
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
|
||||||
* @return PHPWord_Section_TextRun
|
} elseif ($this->_insideOf == 'footer') {
|
||||||
*/
|
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
|
||||||
public function createTextRun($styleParagraph = null) {
|
}
|
||||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
$memoryImage->setRelationId($rID);
|
||||||
$this->_elementCollection[] = $textRun;
|
|
||||||
return $textRun;
|
$this->_elementCollection[] = $memoryImage;
|
||||||
}
|
return $memoryImage;
|
||||||
|
} else {
|
||||||
/**
|
trigger_error('Unsupported image type.');
|
||||||
* Get all Elements
|
}
|
||||||
*
|
}
|
||||||
* @return array
|
|
||||||
*/
|
/**
|
||||||
public function getElements() {
|
* Add a OLE-Object Element
|
||||||
return $this->_elementCollection;
|
*
|
||||||
}
|
* @param string $src
|
||||||
|
* @param mixed $style
|
||||||
/**
|
* @return PHPWord_Section_Object
|
||||||
* Get Cell Style
|
*/
|
||||||
*
|
public function addObject($src, $style = null)
|
||||||
* @return PHPWord_Style_Cell
|
{
|
||||||
*/
|
$object = new PHPWord_Section_Object($src, $style);
|
||||||
public function getStyle() {
|
|
||||||
return $this->_style;
|
if (!is_null($object->getSource())) {
|
||||||
}
|
$inf = pathinfo($src);
|
||||||
|
$ext = $inf['extension'];
|
||||||
/**
|
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||||
* Get Cell width
|
$ext = substr($ext, 0, -1);
|
||||||
*
|
}
|
||||||
* @return int
|
|
||||||
*/
|
$iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/';
|
||||||
public function getWidth() {
|
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
|
||||||
return $this->_width;
|
$iconSrc = $iconSrc . '_default.png';
|
||||||
}
|
} else {
|
||||||
}
|
$iconSrc .= '_' . $ext . '.png';
|
||||||
?>
|
}
|
||||||
|
|
||||||
|
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
||||||
|
$data = PHPWord_Media::addSectionMediaElement($src, 'oleObject');
|
||||||
|
$rID = $data[0];
|
||||||
|
$objectId = $data[1];
|
||||||
|
|
||||||
|
$object->setRelationId($rID);
|
||||||
|
$object->setObjectId($objectId);
|
||||||
|
$object->setImageRelationId($rIDimg);
|
||||||
|
|
||||||
|
$this->_elementCollection[] = $object;
|
||||||
|
return $object;
|
||||||
|
} else {
|
||||||
|
trigger_error('Source does not exist or unsupported object type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a PreserveText Element
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @param mixed $styleFont
|
||||||
|
* @param mixed $styleParagraph
|
||||||
|
* @return PHPWord_Section_Footer_PreserveText
|
||||||
|
*/
|
||||||
|
public function addPreserveText($text, $styleFont = null, $styleParagraph = null)
|
||||||
|
{
|
||||||
|
if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') {
|
||||||
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
|
$text = utf8_encode($text);
|
||||||
|
}
|
||||||
|
$ptext = new PHPWord_Section_Footer_PreserveText($text, $styleFont, $styleParagraph);
|
||||||
|
$this->_elementCollection[] = $ptext;
|
||||||
|
return $ptext;
|
||||||
|
} else {
|
||||||
|
trigger_error('addPreserveText only supported in footer/header.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new TextRun
|
||||||
|
*
|
||||||
|
* @return PHPWord_Section_TextRun
|
||||||
|
*/
|
||||||
|
public function createTextRun($styleParagraph = null)
|
||||||
|
{
|
||||||
|
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||||
|
$this->_elementCollection[] = $textRun;
|
||||||
|
return $textRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Elements
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getElements()
|
||||||
|
{
|
||||||
|
return $this->_elementCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Cell Style
|
||||||
|
*
|
||||||
|
* @return PHPWord_Style_Cell
|
||||||
|
*/
|
||||||
|
public function getStyle()
|
||||||
|
{
|
||||||
|
return $this->_style;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Cell width
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getWidth()
|
||||||
|
{
|
||||||
|
return $this->_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Section/Text.php
Normal file → Executable file
2
Classes/PHPWord/Section/Text.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Section/TextBreak.php
Normal file → Executable file
2
Classes/PHPWord/Section/TextBreak.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
206
Classes/PHPWord/Section/TextRun.php
Normal file → Executable file
206
Classes/PHPWord/Section/TextRun.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,112 +20,112 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Section_TextRun
|
* PHPWord_Section_TextRun
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Section
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Section_TextRun {
|
class PHPWord_Section_TextRun
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Paragraph style
|
/**
|
||||||
*
|
* Paragraph style
|
||||||
* @var PHPWord_Style_Font
|
*
|
||||||
*/
|
* @var PHPWord_Style_Font
|
||||||
private $_styleParagraph;
|
*/
|
||||||
|
private $_styleParagraph;
|
||||||
/**
|
|
||||||
* Text collection
|
/**
|
||||||
*
|
* Text collection
|
||||||
* @var array
|
*
|
||||||
*/
|
* @var array
|
||||||
private $_elementCollection;
|
*/
|
||||||
|
private $_elementCollection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new TextRun Element
|
/**
|
||||||
*/
|
* Create a new TextRun Element
|
||||||
public function __construct($styleParagraph = null) {
|
*/
|
||||||
$this->_elementCollection = array();
|
public function __construct($styleParagraph = null)
|
||||||
|
{
|
||||||
// Set paragraph style
|
$this->_elementCollection = array();
|
||||||
if(is_array($styleParagraph)) {
|
|
||||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
// Set paragraph style
|
||||||
|
if (is_array($styleParagraph)) {
|
||||||
foreach($styleParagraph as $key => $value) {
|
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||||
if(substr($key, 0, 1) != '_') {
|
|
||||||
$key = '_'.$key;
|
foreach ($styleParagraph as $key => $value) {
|
||||||
}
|
if (substr($key, 0, 1) != '_') {
|
||||||
$this->_styleParagraph->setStyleValue($key, $value);
|
$key = '_' . $key;
|
||||||
}
|
}
|
||||||
} else {
|
$this->_styleParagraph->setStyleValue($key, $value);
|
||||||
$this->_styleParagraph = $styleParagraph;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
$this->_styleParagraph = $styleParagraph;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Text Element
|
|
||||||
*
|
|
||||||
* @var string $text
|
|
||||||
* @var mixed $styleFont
|
|
||||||
* @return PHPWord_Section_Text
|
|
||||||
*/
|
|
||||||
public function addText($text = null, $styleFont = null) {
|
|
||||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
|
||||||
$text = utf8_encode($text);
|
|
||||||
}
|
}
|
||||||
$text = new PHPWord_Section_Text($text, $styleFont);
|
|
||||||
$this->_elementCollection[] = $text;
|
|
||||||
return $text;
|
/**
|
||||||
}
|
* Add a Text Element
|
||||||
|
*
|
||||||
/**
|
* @var string $text
|
||||||
* Add a Link Element
|
* @var mixed $styleFont
|
||||||
*
|
* @return PHPWord_Section_Text
|
||||||
* @param string $linkSrc
|
*/
|
||||||
* @param string $linkName
|
public function addText($text = null, $styleFont = null)
|
||||||
* @param mixed $styleFont
|
{
|
||||||
* @return PHPWord_Section_Link
|
if (!PHPWord_Shared_String::IsUTF8($text)) {
|
||||||
*/
|
$text = utf8_encode($text);
|
||||||
public function addLink($linkSrc, $linkName = null, $styleFont = null) {
|
}
|
||||||
$linkSrc = utf8_encode($linkSrc);
|
$text = new PHPWord_Section_Text($text, $styleFont);
|
||||||
if(!is_null($linkName)) {
|
$this->_elementCollection[] = $text;
|
||||||
$linkName = utf8_encode($linkName);
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
/**
|
||||||
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
* Add a Link Element
|
||||||
$link->setRelationId($rID);
|
*
|
||||||
|
* @param string $linkSrc
|
||||||
$this->_elementCollection[] = $link;
|
* @param string $linkName
|
||||||
return $link;
|
* @param mixed $styleFont
|
||||||
}
|
* @return PHPWord_Section_Link
|
||||||
|
*/
|
||||||
/**
|
public function addLink($linkSrc, $linkName = null, $styleFont = null)
|
||||||
* Get TextRun content
|
{
|
||||||
*
|
$linkSrc = utf8_encode($linkSrc);
|
||||||
* @return string
|
if (!is_null($linkName)) {
|
||||||
*/
|
$linkName = utf8_encode($linkName);
|
||||||
public function getElements() {
|
}
|
||||||
return $this->_elementCollection;
|
|
||||||
}
|
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
||||||
|
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
||||||
/**
|
$link->setRelationId($rID);
|
||||||
* Get Paragraph style
|
|
||||||
*
|
$this->_elementCollection[] = $link;
|
||||||
* @return PHPWord_Style_Paragraph
|
return $link;
|
||||||
*/
|
}
|
||||||
public function getParagraphStyle() {
|
|
||||||
return $this->_styleParagraph;
|
/**
|
||||||
}
|
* Get TextRun content
|
||||||
}
|
*
|
||||||
?>
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getElements()
|
||||||
|
{
|
||||||
|
return $this->_elementCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Paragraph style
|
||||||
|
*
|
||||||
|
* @return PHPWord_Style_Paragraph
|
||||||
|
*/
|
||||||
|
public function getParagraphStyle()
|
||||||
|
{
|
||||||
|
return $this->_styleParagraph;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Section/Title.php
Normal file → Executable file
2
Classes/PHPWord/Section/Title.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Shared/Drawing.php
Normal file → Executable file
2
Classes/PHPWord/Shared/Drawing.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Shared/File.php
Normal file → Executable file
2
Classes/PHPWord/Shared/File.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Shared/Font.php
Normal file → Executable file
2
Classes/PHPWord/Shared/Font.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
421
Classes/PHPWord/Shared/String.php
Normal file → Executable file
421
Classes/PHPWord/Shared/String.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,244 +20,251 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PHPWord_Shared_String
|
||||||
|
*/
|
||||||
class PHPWord_Shared_String
|
class PHPWord_Shared_String
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Control characters array
|
* Control characters array
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private static $_controlCharacters = array();
|
private static $_controlCharacters = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is mbstring extension avalable?
|
* Is mbstring extension avalable?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private static $_isMbstringEnabled;
|
private static $_isMbstringEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is iconv extension avalable?
|
* Is iconv extension avalable?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private static $_isIconvEnabled;
|
private static $_isIconvEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build control characters array
|
* Build control characters array
|
||||||
*/
|
*/
|
||||||
private static function _buildControlCharacters() {
|
private static function _buildControlCharacters()
|
||||||
for ($i = 0; $i <= 19; ++$i) {
|
{
|
||||||
if ($i != 9 && $i != 10 && $i != 13) {
|
for ($i = 0; $i <= 19; ++$i) {
|
||||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
if ($i != 9 && $i != 10 && $i != 13) {
|
||||||
$replace = chr($i);
|
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||||
self::$_controlCharacters[$find] = $replace;
|
$replace = chr($i);
|
||||||
}
|
self::$_controlCharacters[$find] = $replace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether mbstring extension is available
|
* Get whether mbstring extension is available
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function getIsMbstringEnabled()
|
public static function getIsMbstringEnabled()
|
||||||
{
|
{
|
||||||
if (isset(self::$_isMbstringEnabled)) {
|
if (isset(self::$_isMbstringEnabled)) {
|
||||||
return self::$_isMbstringEnabled;
|
return self::$_isMbstringEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
||||||
true : false;
|
true : false;
|
||||||
|
|
||||||
return self::$_isMbstringEnabled;
|
return self::$_isMbstringEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether iconv extension is available
|
* Get whether iconv extension is available
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function getIsIconvEnabled()
|
public static function getIsIconvEnabled()
|
||||||
{
|
{
|
||||||
if (isset(self::$_isIconvEnabled)) {
|
if (isset(self::$_isIconvEnabled)) {
|
||||||
return self::$_isIconvEnabled;
|
return self::$_isIconvEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_isIconvEnabled = function_exists('iconv') ?
|
self::$_isIconvEnabled = function_exists('iconv') ?
|
||||||
true : false;
|
true : false;
|
||||||
|
|
||||||
return self::$_isIconvEnabled;
|
return self::$_isIconvEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from OpenXML escaped control character to PHP control character
|
* Convert from OpenXML escaped control character to PHP control character
|
||||||
*
|
*
|
||||||
* Excel 2007 team:
|
* Excel 2007 team:
|
||||||
* ----------------
|
* ----------------
|
||||||
* That's correct, control characters are stored directly in the shared-strings table.
|
* That's correct, control characters are stored directly in the shared-strings table.
|
||||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||||
* element or in the shared string <t> element.
|
* element or in the shared string <t> element.
|
||||||
*
|
*
|
||||||
* @param string $value Value to unescape
|
* @param string $value Value to unescape
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
public static function ControlCharacterOOXML2PHP($value = '')
|
||||||
if(empty(self::$_controlCharacters)) {
|
{
|
||||||
self::_buildControlCharacters();
|
if (empty(self::$_controlCharacters)) {
|
||||||
}
|
self::_buildControlCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
|
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from PHP control character to OpenXML escaped control character
|
* Convert from PHP control character to OpenXML escaped control character
|
||||||
*
|
*
|
||||||
* Excel 2007 team:
|
* Excel 2007 team:
|
||||||
* ----------------
|
* ----------------
|
||||||
* That's correct, control characters are stored directly in the shared-strings table.
|
* That's correct, control characters are stored directly in the shared-strings table.
|
||||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||||
* element or in the shared string <t> element.
|
* element or in the shared string <t> element.
|
||||||
*
|
*
|
||||||
* @param string $value Value to escape
|
* @param string $value Value to escape
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
public static function ControlCharacterPHP2OOXML($value = '')
|
||||||
if(empty(self::$_controlCharacters)) {
|
{
|
||||||
self::_buildControlCharacters();
|
if (empty(self::$_controlCharacters)) {
|
||||||
}
|
self::_buildControlCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
|
return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a string contains UTF-8 data
|
* Check if a string contains UTF-8 data
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IsUTF8($value = '') {
|
public static function IsUTF8($value = '')
|
||||||
return $value === '' || preg_match('/^./su', $value) === 1;
|
{
|
||||||
}
|
return $value === '' || preg_match('/^./su', $value) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a numeric value as a string for output in various output writers
|
* Formats a numeric value as a string for output in various output writers
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function FormatNumber($value) {
|
public static function FormatNumber($value)
|
||||||
return number_format($value, 2, '.', '');
|
{
|
||||||
}
|
return number_format($value, 2, '.', '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
|
* Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
|
||||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||||
* although this will give wrong results for non-ASCII strings
|
* although this will give wrong results for non-ASCII strings
|
||||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||||
*
|
*
|
||||||
* @param string $value UTF-8 encoded string
|
* @param string $value UTF-8 encoded string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function UTF8toBIFF8UnicodeShort($value)
|
public static function UTF8toBIFF8UnicodeShort($value)
|
||||||
{
|
{
|
||||||
// character count
|
// character count
|
||||||
$ln = self::CountCharacters($value, 'UTF-8');
|
$ln = self::CountCharacters($value, 'UTF-8');
|
||||||
|
|
||||||
// option flags
|
// option flags
|
||||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||||
0x0001 : 0x0000;
|
0x0001 : 0x0000;
|
||||||
|
|
||||||
// characters
|
// characters
|
||||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||||
|
|
||||||
$data = pack('CC', $ln, $opt) . $chars;
|
$data = pack('CC', $ln, $opt) . $chars;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
|
* Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
|
||||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||||
* although this will give wrong results for non-ASCII strings
|
* although this will give wrong results for non-ASCII strings
|
||||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||||
*
|
*
|
||||||
* @param string $value UTF-8 encoded string
|
* @param string $value UTF-8 encoded string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function UTF8toBIFF8UnicodeLong($value)
|
public static function UTF8toBIFF8UnicodeLong($value)
|
||||||
{
|
{
|
||||||
// character count
|
// character count
|
||||||
$ln = self::CountCharacters($value, 'UTF-8');
|
$ln = self::CountCharacters($value, 'UTF-8');
|
||||||
|
|
||||||
// option flags
|
// option flags
|
||||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||||
0x0001 : 0x0000;
|
0x0001 : 0x0000;
|
||||||
|
|
||||||
// characters
|
// characters
|
||||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||||
|
|
||||||
$data = pack('vC', $ln, $opt) . $chars;
|
$data = pack('vC', $ln, $opt) . $chars;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||||
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ConvertEncoding($value, $to, $from)
|
public static function ConvertEncoding($value, $to, $from)
|
||||||
{
|
{
|
||||||
if (self::getIsMbstringEnabled()) {
|
if (self::getIsMbstringEnabled()) {
|
||||||
$value = mb_convert_encoding($value, $to, $from);
|
$value = mb_convert_encoding($value, $to, $from);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::getIsIconvEnabled()) {
|
if (self::getIsIconvEnabled()) {
|
||||||
$value = iconv($from, $to, $value);
|
$value = iconv($from, $to, $value);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// else, no conversion
|
// else, no conversion
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get character count. First try mbstring, then iconv, finally strlen
|
|
||||||
*
|
|
||||||
* @param string $value
|
|
||||||
* @param string $enc Encoding
|
|
||||||
* @return int Character count
|
|
||||||
*/
|
|
||||||
public static function CountCharacters($value, $enc = 'UTF-8')
|
|
||||||
{
|
|
||||||
if (self::getIsMbstringEnabled()) {
|
|
||||||
$count = mb_strlen($value, $enc);
|
|
||||||
return $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::getIsIconvEnabled()) {
|
/**
|
||||||
$count = iconv_strlen($value, $enc);
|
* Get character count. First try mbstring, then iconv, finally strlen
|
||||||
return $count;
|
*
|
||||||
}
|
* @param string $value
|
||||||
|
* @param string $enc Encoding
|
||||||
|
* @return int Character count
|
||||||
|
*/
|
||||||
|
public static function CountCharacters($value, $enc = 'UTF-8')
|
||||||
|
{
|
||||||
|
if (self::getIsMbstringEnabled()) {
|
||||||
|
$count = mb_strlen($value, $enc);
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
// else strlen
|
if (self::getIsIconvEnabled()) {
|
||||||
$count = strlen($value);
|
$count = iconv_strlen($value, $enc);
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// else strlen
|
||||||
|
$count = strlen($value);
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
Classes/PHPWord/Shared/XMLWriter.php
Normal file → Executable file
2
Classes/PHPWord/Shared/XMLWriter.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Shared/ZipStreamWrapper.php
Normal file → Executable file
2
Classes/PHPWord/Shared/ZipStreamWrapper.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Style.php
Normal file → Executable file
2
Classes/PHPWord/Style.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
591
Classes/PHPWord/Style/Cell.php
Normal file → Executable file
591
Classes/PHPWord/Style/Cell.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,299 +20,328 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Style_Cell
|
* PHPWord_Style_Cell
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Style
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Cell {
|
class PHPWord_Style_Cell
|
||||||
|
{
|
||||||
const TEXT_DIR_BTLR = 'btLr';
|
|
||||||
const TEXT_DIR_TBRL = 'tbRl';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vertical align
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_valign;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Text Direction
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_textDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Background-Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_bgColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Top Size
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderTopSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Top Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderTopColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Left Size
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderLeftSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Left Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderLeftColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Right Size
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderRightSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Right Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderRightColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Bottom Size
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_borderBottomSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Bottom Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_borderBottomColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Border Default Color
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_defaultBorderColor;
|
|
||||||
|
|
||||||
/**
|
const TEXT_DIR_BTLR = 'btLr';
|
||||||
* colspan
|
const TEXT_DIR_TBRL = 'tbRl';
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
private $_gridSpan = NULL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rowspan
|
* Vertical align
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_vMerge = NULL;
|
private $_valign;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Cell Style
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->_valign = null;
|
|
||||||
$this->_textDirection = null;
|
|
||||||
$this->_bgColor = null;
|
|
||||||
$this->_borderTopSize = null;
|
|
||||||
$this->_borderTopColor = null;
|
|
||||||
$this->_borderLeftSize = null;
|
|
||||||
$this->_borderLeftColor = null;
|
|
||||||
$this->_borderRightSize = null;
|
|
||||||
$this->_borderRightColor = null;
|
|
||||||
$this->_borderBottomSize = null;
|
|
||||||
$this->_borderBottomColor = null;
|
|
||||||
$this->_defaultBorderColor = '000000';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set style value
|
|
||||||
*
|
|
||||||
* @var string $key
|
|
||||||
* @var mixed $value
|
|
||||||
*/
|
|
||||||
public function setStyleValue($key, $value) {
|
|
||||||
if($key == '_borderSize') {
|
|
||||||
$this->setBorderSize($value);
|
|
||||||
} elseif($key == '_borderColor') {
|
|
||||||
$this->setBorderColor($value);
|
|
||||||
} else {
|
|
||||||
$this->$key = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVAlign() {
|
|
||||||
return $this->_valign;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setVAlign($pValue = null) {
|
|
||||||
$this->_valign = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTextDirection() {
|
|
||||||
return $this->_textDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTextDirection($pValue = null) {
|
|
||||||
$this->_textDirection = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBgColor() {
|
|
||||||
return $this->_bgColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBgColor($pValue = null) {
|
/**
|
||||||
$this->_bgColor = $pValue;
|
* Text Direction
|
||||||
}
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_textDirection;
|
||||||
|
|
||||||
public function setHeight($pValue = null) {
|
/**
|
||||||
$this->_height = $pValue;
|
* Background-Color
|
||||||
}
|
*
|
||||||
|
* @var string
|
||||||
public function setBorderSize($pValue = null) {
|
*/
|
||||||
$this->_borderTopSize = $pValue;
|
private $_bgColor;
|
||||||
$this->_borderLeftSize = $pValue;
|
|
||||||
$this->_borderRightSize = $pValue;
|
|
||||||
$this->_borderBottomSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderSize() {
|
|
||||||
$t = $this->getBorderTopSize();
|
|
||||||
$l = $this->getBorderLeftSize();
|
|
||||||
$r = $this->getBorderRightSize();
|
|
||||||
$b = $this->getBorderBottomSize();
|
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderColor($pValue = null) {
|
|
||||||
$this->_borderTopColor = $pValue;
|
|
||||||
$this->_borderLeftColor = $pValue;
|
|
||||||
$this->_borderRightColor = $pValue;
|
|
||||||
$this->_borderBottomColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderColor() {
|
|
||||||
$t = $this->getBorderTopColor();
|
|
||||||
$l = $this->getBorderLeftColor();
|
|
||||||
$r = $this->getBorderRightColor();
|
|
||||||
$b = $this->getBorderBottomColor();
|
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderTopSize($pValue = null) {
|
|
||||||
$this->_borderTopSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderTopSize() {
|
|
||||||
return $this->_borderTopSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderTopColor($pValue = null) {
|
|
||||||
$this->_borderTopColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderTopColor() {
|
|
||||||
return $this->_borderTopColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderLeftSize($pValue = null) {
|
/**
|
||||||
$this->_borderLeftSize = $pValue;
|
* Border Top Size
|
||||||
}
|
*
|
||||||
|
* @var int
|
||||||
public function getBorderLeftSize() {
|
*/
|
||||||
return $this->_borderLeftSize;
|
private $_borderTopSize;
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderLeftColor($pValue = null) {
|
|
||||||
$this->_borderLeftColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderLeftColor() {
|
|
||||||
return $this->_borderLeftColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderRightSize($pValue = null) {
|
/**
|
||||||
$this->_borderRightSize = $pValue;
|
* Border Top Color
|
||||||
}
|
*
|
||||||
|
* @var string
|
||||||
public function getBorderRightSize() {
|
*/
|
||||||
return $this->_borderRightSize;
|
private $_borderTopColor;
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderRightColor($pValue = null) {
|
|
||||||
$this->_borderRightColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderRightColor() {
|
|
||||||
return $this->_borderRightColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function setBorderBottomSize($pValue = null) {
|
|
||||||
$this->_borderBottomSize = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderBottomSize() {
|
|
||||||
return $this->_borderBottomSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBorderBottomColor($pValue = null) {
|
|
||||||
$this->_borderBottomColor = $pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBorderBottomColor() {
|
|
||||||
return $this->_borderBottomColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDefaultBorderColor() {
|
|
||||||
return $this->_defaultBorderColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setGridSpan($pValue = null) {
|
/**
|
||||||
$this->_gridSpan = $pValue;
|
* Border Left Size
|
||||||
}
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderLeftSize;
|
||||||
|
|
||||||
public function getGridSpan() {
|
/**
|
||||||
return $this->_gridSpan;
|
* Border Left Color
|
||||||
}
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderLeftColor;
|
||||||
|
|
||||||
public function setVMerge($pValue = null) {
|
/**
|
||||||
$this->_vMerge = $pValue;
|
* Border Right Size
|
||||||
}
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderRightSize;
|
||||||
|
|
||||||
public function getVMerge() {
|
/**
|
||||||
return $this->_vMerge;
|
* Border Right Color
|
||||||
}
|
*
|
||||||
}
|
* @var string
|
||||||
?>
|
*/
|
||||||
|
private $_borderRightColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border Bottom Size
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_borderBottomSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border Bottom Color
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_borderBottomColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border Default Color
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_defaultBorderColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* colspan
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $_gridSpan = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rowspan
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $_vMerge = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Cell Style
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_valign = null;
|
||||||
|
$this->_textDirection = null;
|
||||||
|
$this->_bgColor = null;
|
||||||
|
$this->_borderTopSize = null;
|
||||||
|
$this->_borderTopColor = null;
|
||||||
|
$this->_borderLeftSize = null;
|
||||||
|
$this->_borderLeftColor = null;
|
||||||
|
$this->_borderRightSize = null;
|
||||||
|
$this->_borderRightColor = null;
|
||||||
|
$this->_borderBottomSize = null;
|
||||||
|
$this->_borderBottomColor = null;
|
||||||
|
$this->_defaultBorderColor = '000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set style value
|
||||||
|
*
|
||||||
|
* @var string $key
|
||||||
|
* @var mixed $value
|
||||||
|
*/
|
||||||
|
public function setStyleValue($key, $value)
|
||||||
|
{
|
||||||
|
if ($key == '_borderSize') {
|
||||||
|
$this->setBorderSize($value);
|
||||||
|
} elseif ($key == '_borderColor') {
|
||||||
|
$this->setBorderColor($value);
|
||||||
|
} else {
|
||||||
|
$this->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVAlign()
|
||||||
|
{
|
||||||
|
return $this->_valign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVAlign($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_valign = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTextDirection()
|
||||||
|
{
|
||||||
|
return $this->_textDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTextDirection($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_textDirection = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBgColor()
|
||||||
|
{
|
||||||
|
return $this->_bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBgColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_bgColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeight($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_height = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopSize = $pValue;
|
||||||
|
$this->_borderLeftSize = $pValue;
|
||||||
|
$this->_borderRightSize = $pValue;
|
||||||
|
$this->_borderBottomSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderSize()
|
||||||
|
{
|
||||||
|
$t = $this->getBorderTopSize();
|
||||||
|
$l = $this->getBorderLeftSize();
|
||||||
|
$r = $this->getBorderRightSize();
|
||||||
|
$b = $this->getBorderBottomSize();
|
||||||
|
|
||||||
|
return array($t, $l, $r, $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopColor = $pValue;
|
||||||
|
$this->_borderLeftColor = $pValue;
|
||||||
|
$this->_borderRightColor = $pValue;
|
||||||
|
$this->_borderBottomColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderColor()
|
||||||
|
{
|
||||||
|
$t = $this->getBorderTopColor();
|
||||||
|
$l = $this->getBorderLeftColor();
|
||||||
|
$r = $this->getBorderRightColor();
|
||||||
|
$b = $this->getBorderBottomColor();
|
||||||
|
|
||||||
|
return array($t, $l, $r, $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderTopSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderTopSize()
|
||||||
|
{
|
||||||
|
return $this->_borderTopSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderTopColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderTopColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderTopColor()
|
||||||
|
{
|
||||||
|
return $this->_borderTopColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderLeftSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderLeftSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderLeftSize()
|
||||||
|
{
|
||||||
|
return $this->_borderLeftSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderLeftColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderLeftColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderLeftColor()
|
||||||
|
{
|
||||||
|
return $this->_borderLeftColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderRightSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderRightSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderRightSize()
|
||||||
|
{
|
||||||
|
return $this->_borderRightSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderRightColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderRightColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderRightColor()
|
||||||
|
{
|
||||||
|
return $this->_borderRightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setBorderBottomSize($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderBottomSize = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderBottomSize()
|
||||||
|
{
|
||||||
|
return $this->_borderBottomSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBorderBottomColor($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_borderBottomColor = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBorderBottomColor()
|
||||||
|
{
|
||||||
|
return $this->_borderBottomColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultBorderColor()
|
||||||
|
{
|
||||||
|
return $this->_defaultBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGridSpan($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_gridSpan = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGridSpan()
|
||||||
|
{
|
||||||
|
return $this->_gridSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVMerge($pValue = null)
|
||||||
|
{
|
||||||
|
$this->_vMerge = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVMerge()
|
||||||
|
{
|
||||||
|
return $this->_vMerge;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Style/Font.php
Normal file → Executable file
2
Classes/PHPWord/Style/Font.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Style/Image.php
Normal file → Executable file
2
Classes/PHPWord/Style/Image.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Style/ListItem.php
Normal file → Executable file
2
Classes/PHPWord/Style/ListItem.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
374
Classes/PHPWord/Style/Paragraph.php
Normal file → Executable file
374
Classes/PHPWord/Style/Paragraph.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,206 +20,214 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Style_Paragraph
|
* PHPWord_Style_Paragraph
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Style
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Paragraph {
|
class PHPWord_Style_Paragraph
|
||||||
|
{
|
||||||
/**
|
|
||||||
* Paragraph alignment
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_align;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Space before Paragraph
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_spaceBefore;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Space after Paragraph
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_spaceAfter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spacing between breaks
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $_spacing;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of Custom Tab Stops
|
* Paragraph alignment
|
||||||
*
|
*
|
||||||
* @var array
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_tabs;
|
private $_align;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indent by how much
|
* Space before Paragraph
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_indent;
|
private $_spaceBefore;
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Space after Paragraph
|
||||||
* New Paragraph Style
|
*
|
||||||
*/
|
* @var int
|
||||||
public function __construct() {
|
*/
|
||||||
$this->_align = null;
|
private $_spaceAfter;
|
||||||
$this->_spaceBefore = null;
|
|
||||||
$this->_spaceAfter = null;
|
/**
|
||||||
$this->_spacing = null;
|
* Spacing between breaks
|
||||||
$this->_tabs = null;
|
*
|
||||||
$this->_indent = null;
|
* @var int
|
||||||
}
|
*/
|
||||||
|
private $_spacing;
|
||||||
/**
|
|
||||||
* Set Style value
|
/**
|
||||||
*
|
* Set of Custom Tab Stops
|
||||||
* @param string $key
|
*
|
||||||
* @param mixed $value
|
* @var array
|
||||||
*/
|
*/
|
||||||
public function setStyleValue($key, $value) {
|
private $_tabs;
|
||||||
if($key == '_indent') {
|
|
||||||
$value = (int)$value * 720; // 720 twips per indent
|
/**
|
||||||
}
|
* Indent by how much
|
||||||
if($key == '_spacing') {
|
*
|
||||||
$value += 240; // because line height of 1 matches 240 twips
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_indent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New Paragraph Style
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_align = null;
|
||||||
|
$this->_spaceBefore = null;
|
||||||
|
$this->_spaceAfter = null;
|
||||||
|
$this->_spacing = null;
|
||||||
|
$this->_tabs = null;
|
||||||
|
$this->_indent = null;
|
||||||
}
|
}
|
||||||
if($key === '_tabs') {
|
|
||||||
$value = new PHPWord_Style_Tabs($value);
|
/**
|
||||||
|
* Set Style value
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function setStyleValue($key, $value)
|
||||||
|
{
|
||||||
|
if ($key == '_indent') {
|
||||||
|
$value = (int)$value * 720; // 720 twips per indent
|
||||||
|
}
|
||||||
|
if ($key == '_spacing') {
|
||||||
|
$value += 240; // because line height of 1 matches 240 twips
|
||||||
|
}
|
||||||
|
if ($key === '_tabs') {
|
||||||
|
$value = new PHPWord_Style_Tabs($value);
|
||||||
|
}
|
||||||
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
$this->$key = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Paragraph Alignment
|
* Get Paragraph Alignment
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAlign() {
|
public function getAlign()
|
||||||
return $this->_align;
|
{
|
||||||
}
|
return $this->_align;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Paragraph Alignment
|
* Set Paragraph Alignment
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setAlign($pValue = null) {
|
public function setAlign($pValue = null)
|
||||||
if(strtolower($pValue) == 'justify') {
|
{
|
||||||
// justify becames both
|
if (strtolower($pValue) == 'justify') {
|
||||||
$pValue = 'both';
|
// justify becames both
|
||||||
}
|
$pValue = 'both';
|
||||||
$this->_align = $pValue;
|
}
|
||||||
return $this;
|
$this->_align = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Space before Paragraph
|
* Get Space before Paragraph
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSpaceBefore() {
|
public function getSpaceBefore()
|
||||||
return $this->_spaceBefore;
|
{
|
||||||
}
|
return $this->_spaceBefore;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Space before Paragraph
|
* Set Space before Paragraph
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setSpaceBefore($pValue = null) {
|
public function setSpaceBefore($pValue = null)
|
||||||
$this->_spaceBefore = $pValue;
|
{
|
||||||
return $this;
|
$this->_spaceBefore = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Space after Paragraph
|
* Get Space after Paragraph
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSpaceAfter() {
|
public function getSpaceAfter()
|
||||||
return $this->_spaceAfter;
|
{
|
||||||
}
|
return $this->_spaceAfter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Space after Paragraph
|
* Set Space after Paragraph
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setSpaceAfter($pValue = null) {
|
public function setSpaceAfter($pValue = null)
|
||||||
$this->_spaceAfter = $pValue;
|
{
|
||||||
return $this;
|
$this->_spaceAfter = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Spacing between breaks
|
* Get Spacing between breaks
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSpacing() {
|
public function getSpacing()
|
||||||
return $this->_spacing;
|
{
|
||||||
}
|
return $this->_spacing;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Spacing between breaks
|
* Set Spacing between breaks
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setSpacing($pValue = null) {
|
public function setSpacing($pValue = null)
|
||||||
$this->_spacing = $pValue;
|
{
|
||||||
return $this;
|
$this->_spacing = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get indentation
|
* Get indentation
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getIndent() {
|
public function getIndent()
|
||||||
return $this->_indent;
|
{
|
||||||
}
|
return $this->_indent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set indentation
|
* Set indentation
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return PHPWord_Style_Paragraph
|
* @return PHPWord_Style_Paragraph
|
||||||
*/
|
*/
|
||||||
public function setIndent($pValue = null) {
|
public function setIndent($pValue = null)
|
||||||
$this->_indent = $pValue;
|
{
|
||||||
return $this;
|
$this->_indent = $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tabs
|
* Get tabs
|
||||||
*
|
*
|
||||||
* @return PHPWord_Style_Tabs
|
* @return PHPWord_Style_Tabs
|
||||||
*/
|
*/
|
||||||
public function getTabs() {
|
public function getTabs()
|
||||||
return $this->_tabs;
|
{
|
||||||
}
|
return $this->_tabs;
|
||||||
}
|
}
|
||||||
?>
|
}
|
||||||
2
Classes/PHPWord/Style/TOC.php
Normal file → Executable file
2
Classes/PHPWord/Style/TOC.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
217
Classes/PHPWord/Style/Tab.php
Normal file → Executable file
217
Classes/PHPWord/Style/Tab.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,128 +20,127 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version {something}
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Style_Tabs
|
* PHPWord_Style_Tabs
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Style_Paragraph
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/e-w_tab-1.html w:tab
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Tab {
|
class PHPWord_Style_Tab
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Stop Type
|
* Tab Stop Type
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_val;
|
private $_val;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Leader Character
|
* Tab Leader Character
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_leader;
|
private $_leader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Stop Position
|
* Tab Stop Position
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_position;
|
private $_position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Stop Type
|
* Tab Stop Type
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type
|
||||||
*/
|
*/
|
||||||
private static $_possibleStopTypes = array(
|
private static $_possibleStopTypes = array(
|
||||||
'clear', // No Tab Stop
|
'clear', // No Tab Stop
|
||||||
'left', // Left Tab Stop
|
'left', // Left Tab Stop
|
||||||
'center', // Center Tab Stop
|
'center', // Center Tab Stop
|
||||||
'right', // Right Tab Stop
|
'right', // Right Tab Stop
|
||||||
'decimal', // Decimal Tab
|
'decimal', // Decimal Tab
|
||||||
'bar', // Bar Tab
|
'bar', // Bar Tab
|
||||||
'num' // List tab
|
'num' // List tab
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Leader Character
|
* Tab Leader Character
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character
|
* @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character
|
||||||
*/
|
*/
|
||||||
private static $_possibleLeaders = array(
|
private static $_possibleLeaders = array(
|
||||||
'none', // No tab stop leader
|
'none', // No tab stop leader
|
||||||
'dot', // Dotted leader line
|
'dot', // Dotted leader line
|
||||||
'hyphen', // Dashed tab stop leader line
|
'hyphen', // Dashed tab stop leader line
|
||||||
'underscore', // Solid leader line
|
'underscore', // Solid leader line
|
||||||
'heavy', // Heavy solid leader line
|
'heavy', // Heavy solid leader line
|
||||||
'middleDot' // Middle dot leader line
|
'middleDot' // Middle dot leader line
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of PHPWord_Style_Tab. Both $val and $leader
|
* Create a new instance of PHPWord_Style_Tab. Both $val and $leader
|
||||||
* must conform to the values put forth in the schema. If they do not
|
* must conform to the values put forth in the schema. If they do not
|
||||||
* they will be changed to default values.
|
* they will be changed to default values.
|
||||||
*
|
*
|
||||||
* @param string $val Defaults to 'clear' if value is not possible.
|
* @param string $val Defaults to 'clear' if value is not possible.
|
||||||
* @param int $position Must be an integer; otherwise defaults to 0.
|
* @param int $position Must be an integer; otherwise defaults to 0.
|
||||||
* @param string $leader Defaults to NULL if value is not possible.
|
* @param string $leader Defaults to NULL if value is not possible.
|
||||||
*/
|
*/
|
||||||
public function __construct($val = NULL, $position = 0, $leader = NULL) {
|
public function __construct($val = NULL, $position = 0, $leader = NULL)
|
||||||
// Default to clear if the stop type is not matched
|
{
|
||||||
$this->_val = (self::isStopType($val)) ? $val : 'clear';
|
// Default to clear if the stop type is not matched
|
||||||
|
$this->_val = (self::isStopType($val)) ? $val : 'clear';
|
||||||
|
|
||||||
// Default to 0 if the position is non-numeric
|
// Default to 0 if the position is non-numeric
|
||||||
$this->_position = (is_numeric($position)) ? intval($position) : 0;
|
$this->_position = (is_numeric($position)) ? intval($position) : 0;
|
||||||
|
|
||||||
// Default to NULL if no tab leader
|
// Default to NULL if no tab leader
|
||||||
$this->_leader = (self::isLeaderType($leader)) ? $leader : NULL;
|
$this->_leader = (self::isLeaderType($leader)) ? $leader : NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the XML DOM for the instance of PHPWord_Style_Tab.
|
|
||||||
*
|
|
||||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
|
||||||
*/
|
|
||||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) {
|
|
||||||
if(isset($objWriter)) {
|
|
||||||
$objWriter->startElement("w:tab");
|
|
||||||
$objWriter->writeAttribute("w:val", $this->_val);
|
|
||||||
if(!is_null($this->_leader)) {
|
|
||||||
$objWriter->writeAttribute("w:leader", $this->_leader);
|
|
||||||
}
|
|
||||||
$objWriter->writeAttribute("w:pos", $this->_position);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if attribute is a valid stop type.
|
* Creates the XML DOM for the instance of PHPWord_Style_Tab.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||||
* @return bool True if it is; false otherwise.
|
*/
|
||||||
*/
|
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL)
|
||||||
private static function isStopType($attribute) {
|
{
|
||||||
return in_array($attribute, self::$_possibleStopTypes);
|
if (isset($objWriter)) {
|
||||||
}
|
$objWriter->startElement("w:tab");
|
||||||
|
$objWriter->writeAttribute("w:val", $this->_val);
|
||||||
|
if (!is_null($this->_leader)) {
|
||||||
|
$objWriter->writeAttribute("w:leader", $this->_leader);
|
||||||
|
}
|
||||||
|
$objWriter->writeAttribute("w:pos", $this->_position);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if attribute is a valid leader type.
|
* Test if attribute is a valid stop type.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @return bool True if it is; false otherwise.
|
* @return bool True if it is; false otherwise.
|
||||||
*/
|
*/
|
||||||
private static function isLeaderType($attribute) {
|
private static function isStopType($attribute)
|
||||||
return in_array($attribute, self::$_possibleLeaders);
|
{
|
||||||
}
|
return in_array($attribute, self::$_possibleStopTypes);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
/**
|
||||||
|
* Test if attribute is a valid leader type.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @return bool True if it is; false otherwise.
|
||||||
|
*/
|
||||||
|
private static function isLeaderType($attribute)
|
||||||
|
{
|
||||||
|
return in_array($attribute, self::$_possibleLeaders);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/Style/Table.php
Normal file → Executable file
2
Classes/PHPWord/Style/Table.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Style/TableFull.php
Normal file → Executable file
2
Classes/PHPWord/Style/TableFull.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
71
Classes/PHPWord/Style/Tabs.php
Normal file → Executable file
71
Classes/PHPWord/Style/Tabs.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,48 +20,45 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version {something}
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_Style_Tabs
|
* PHPWord_Style_Tabs
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord_Style_Paragraph
|
|
||||||
* @copyright Copyright (c) 2011 PHPWord
|
|
||||||
* @link http://www.schemacentral.com/sc/ooxml/e-w_tabs-1.html w:tabs
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Tabs {
|
class PHPWord_Style_Tabs
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tabs
|
* Tabs
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_tabs;
|
private $_tabs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param array $tabs
|
* @param array $tabs
|
||||||
*/
|
*/
|
||||||
public function __construct(array $tabs) {
|
public function __construct(array $tabs)
|
||||||
$this->_tabs = $tabs;
|
{
|
||||||
}
|
$this->_tabs = $tabs;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
|
||||||
*/
|
|
||||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) {
|
|
||||||
if(isset($objWriter)) {
|
|
||||||
$objWriter->startElement("w:tabs");
|
|
||||||
foreach ($this->_tabs as &$tab) {
|
|
||||||
$tab->toXml($objWriter);
|
|
||||||
}
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
?>
|
*
|
||||||
|
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||||
|
*/
|
||||||
|
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL)
|
||||||
|
{
|
||||||
|
if (isset($objWriter)) {
|
||||||
|
$objWriter->startElement("w:tabs");
|
||||||
|
foreach ($this->_tabs as &$tab) {
|
||||||
|
$tab->toXml($objWriter);
|
||||||
|
}
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Classes/PHPWord/TOC.php
Normal file → Executable file
2
Classes/PHPWord/TOC.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
96
Classes/PHPWord/Template.php
Normal file → Executable file
96
Classes/PHPWord/Template.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,90 +20,88 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPWord_DocumentProperties
|
* PHPWord_DocumentProperties
|
||||||
*
|
|
||||||
* @category PHPWord
|
|
||||||
* @package PHPWord
|
|
||||||
* @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord)
|
|
||||||
*/
|
*/
|
||||||
class PHPWord_Template {
|
class PHPWord_Template
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ZipArchive
|
* ZipArchive
|
||||||
*
|
*
|
||||||
* @var ZipArchive
|
* @var ZipArchive
|
||||||
*/
|
*/
|
||||||
private $_objZip;
|
private $_objZip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary Filename
|
* Temporary Filename
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_tempFileName;
|
private $_tempFileName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document XML
|
* Document XML
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_documentXML;
|
private $_documentXML;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Template Object
|
* Create a new Template Object
|
||||||
*
|
*
|
||||||
* @param string $strFilename
|
* @param string $strFilename
|
||||||
*/
|
*/
|
||||||
public function __construct($strFilename) {
|
public function __construct($strFilename)
|
||||||
|
{
|
||||||
$this->_tempFileName = tempnam(sys_get_temp_dir(), '');
|
$this->_tempFileName = tempnam(sys_get_temp_dir(), '');
|
||||||
if ($this->_tempFileName !== false) {
|
if ($this->_tempFileName !== false) {
|
||||||
// Copy the source File to the temp File
|
// Copy the source File to the temp File
|
||||||
if(!copy($strFilename, $this->_tempFileName)){
|
if (!copy($strFilename, $this->_tempFileName)) {
|
||||||
throw new PHPWord_Exception('Could not copy the template from '.$strFilename.' to '.$this->_tempFileName.'.');
|
throw new PHPWord_Exception('Could not copy the template from ' . $strFilename . ' to ' . $this->_tempFileName . '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_objZip = new ZipArchive();
|
$this->_objZip = new ZipArchive();
|
||||||
$this->_objZip->open($this->_tempFileName);
|
$this->_objZip->open($this->_tempFileName);
|
||||||
|
|
||||||
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
||||||
} else {
|
} else {
|
||||||
throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.');
|
throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a Template value
|
* Set a Template value
|
||||||
*
|
*
|
||||||
* @param mixed $search
|
* @param mixed $search
|
||||||
* @param mixed $replace
|
* @param mixed $replace
|
||||||
*/
|
*/
|
||||||
public function setValue($search, $replace) {
|
public function setValue($search, $replace)
|
||||||
|
{
|
||||||
$pattern = '|\$\{([^\}]+)\}|U';
|
$pattern = '|\$\{([^\}]+)\}|U';
|
||||||
preg_match_all($pattern, $this->_documentXML, $matches);
|
preg_match_all($pattern, $this->_documentXML, $matches);
|
||||||
foreach ($matches[0] as $value) {
|
foreach ($matches[0] as $value) {
|
||||||
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
|
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
|
||||||
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
|
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
|
||||||
$this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML);
|
$this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
||||||
$search = '${'.$search.'}';
|
$search = '${' . $search . '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_array($replace)) {
|
if (!is_array($replace)) {
|
||||||
if(!PHPWord_Shared_String::IsUTF8($replace)){
|
if (!PHPWord_Shared_String::IsUTF8($replace)) {
|
||||||
$replace = utf8_encode($replace);
|
$replace = utf8_encode($replace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,22 +116,22 @@ class PHPWord_Template {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Template
|
* Save Template
|
||||||
*
|
*
|
||||||
* @param string $strFilename
|
* @param string $strFilename
|
||||||
*/
|
*/
|
||||||
public function save($strFilename) {
|
public function save($strFilename)
|
||||||
if(file_exists($strFilename)) {
|
{
|
||||||
|
if (file_exists($strFilename)) {
|
||||||
unlink($strFilename);
|
unlink($strFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
||||||
|
|
||||||
// Close zip file
|
// Close zip file
|
||||||
if($this->_objZip->close() === false) {
|
if ($this->_objZip->close() === false) {
|
||||||
throw new Exception('Could not close zip file.');
|
throw new Exception('Could not close zip file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
rename($this->_tempFileName, $strFilename);
|
rename($this->_tempFileName, $strFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
2
Classes/PHPWord/Writer/IWriter.php
Normal file → Executable file
2
Classes/PHPWord/Writer/IWriter.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
4
Classes/PHPWord/Writer/ODText.php
Normal file → Executable file
4
Classes/PHPWord/Writer/ODText.php
Normal file → Executable file
@ -19,8 +19,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord_Writer_PowerPoint2007
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/Content.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/Content.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/Manifest.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/Manifest.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/Meta.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/Meta.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/Mimetype.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/Mimetype.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/Styles.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/Styles.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/ODText/WriterPart.php
Normal file → Executable file
2
Classes/PHPWord/Writer/ODText/WriterPart.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
4
Classes/PHPWord/Writer/RTF.php
Normal file → Executable file
4
Classes/PHPWord/Writer/RTF.php
Normal file → Executable file
@ -19,8 +19,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord_Writer_RTF
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
430
Classes/PHPWord/Writer/Word2007.php
Normal file → Executable file
430
Classes/PHPWord/Writer/Word2007.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,221 +20,229 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PHPWord_Writer_Word2007
|
||||||
|
*/
|
||||||
|
class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||||
|
{
|
||||||
|
|
||||||
class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
private $_document;
|
||||||
|
private $_writerParts;
|
||||||
private $_document;
|
private $_diskCachingDirectory;
|
||||||
private $_writerParts;
|
private $_useDiskCaching = false;
|
||||||
private $_diskCachingDirectory;
|
private $_imageTypes = array();
|
||||||
private $_useDiskCaching = false;
|
private $_objectTypes = array();
|
||||||
private $_imageTypes = array();
|
|
||||||
private $_objectTypes = array();
|
public function __construct(PHPWord $PHPWord = null)
|
||||||
|
{
|
||||||
public function __construct(PHPWord $PHPWord = null) {
|
$this->_document = $PHPWord;
|
||||||
$this->_document = $PHPWord;
|
|
||||||
|
$this->_diskCachingDirectory = './';
|
||||||
$this->_diskCachingDirectory = './';
|
|
||||||
|
$this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes();
|
||||||
$this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes();
|
$this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels();
|
||||||
$this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels();
|
$this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps();
|
||||||
$this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps();
|
$this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels();
|
||||||
$this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels();
|
$this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document();
|
||||||
$this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document();
|
$this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles();
|
||||||
$this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles();
|
$this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
|
||||||
$this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
|
$this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
|
||||||
$this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
|
|
||||||
|
foreach ($this->_writerParts as $writer) {
|
||||||
foreach($this->_writerParts as $writer) {
|
$writer->setParentWriter($this);
|
||||||
$writer->setParentWriter($this);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public function save($pFilename = null)
|
||||||
public function save($pFilename = null) {
|
{
|
||||||
if(!is_null($this->_document)) {
|
if (!is_null($this->_document)) {
|
||||||
|
|
||||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||||
$originalFilename = $pFilename;
|
$originalFilename = $pFilename;
|
||||||
if(strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||||
$pFilename = @tempnam('./', 'phppttmp');
|
$pFilename = @tempnam('./', 'phppttmp');
|
||||||
if($pFilename == '') {
|
if ($pFilename == '') {
|
||||||
$pFilename = $originalFilename;
|
$pFilename = $originalFilename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new ZIP file and open it for writing
|
// Create new ZIP file and open it for writing
|
||||||
$objZip = new ZipArchive();
|
$objZip = new ZipArchive();
|
||||||
|
|
||||||
// Try opening the ZIP file
|
// Try opening the ZIP file
|
||||||
if($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||||
if($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sectionElements = array();
|
$sectionElements = array();
|
||||||
$_secElements = PHPWord_Media::getSectionMediaElements();
|
$_secElements = PHPWord_Media::getSectionMediaElements();
|
||||||
foreach($_secElements as $element) { // loop through section media elements
|
foreach ($_secElements as $element) { // loop through section media elements
|
||||||
if($element['type'] != 'hyperlink') {
|
if ($element['type'] != 'hyperlink') {
|
||||||
$this->_addFileToPackage($objZip, $element);
|
$this->_addFileToPackage($objZip, $element);
|
||||||
}
|
}
|
||||||
$sectionElements[] = $element;
|
$sectionElements[] = $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_hdrElements = PHPWord_Media::getHeaderMediaElements();
|
$_hdrElements = PHPWord_Media::getHeaderMediaElements();
|
||||||
foreach($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers
|
foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers
|
||||||
if(count($_hdrMedia) > 0) {
|
if (count($_hdrMedia) > 0) {
|
||||||
$objZip->addFromString('word/_rels/'.$_headerFile.'.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia));
|
$objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia));
|
||||||
foreach($_hdrMedia as $element) { // loop through header media elements
|
foreach ($_hdrMedia as $element) { // loop through header media elements
|
||||||
$this->_addFileToPackage($objZip, $element);
|
$this->_addFileToPackage($objZip, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_ftrElements = PHPWord_Media::getFooterMediaElements();
|
$_ftrElements = PHPWord_Media::getFooterMediaElements();
|
||||||
foreach($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers
|
foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers
|
||||||
if(count($_ftrMedia) > 0) {
|
if (count($_ftrMedia) > 0) {
|
||||||
$objZip->addFromString('word/_rels/'.$_footerFile.'.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia));
|
$objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia));
|
||||||
foreach($_ftrMedia as $element) { // loop through footers media elements
|
foreach ($_ftrMedia as $element) { // loop through footers media elements
|
||||||
$this->_addFileToPackage($objZip, $element);
|
$this->_addFileToPackage($objZip, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$_cHdrs = 0;
|
||||||
$_cHdrs = 0;
|
$_cFtrs = 0;
|
||||||
$_cFtrs = 0;
|
$rID = PHPWord_Media::countSectionMediaElements() + 6;
|
||||||
$rID = PHPWord_Media::countSectionMediaElements() + 6;
|
$_sections = $this->_document->getSections();
|
||||||
$_sections = $this->_document->getSections();
|
|
||||||
|
foreach ($_sections as $section) {
|
||||||
foreach($_sections as $section) {
|
$_headers = $section->getHeaders();
|
||||||
$_headers = $section->getHeaders();
|
foreach ($_headers as $index => &$_header) {
|
||||||
foreach ($_headers as $index => &$_header) {
|
$_cHdrs++;
|
||||||
$_cHdrs++;
|
$_header->setRelationId(++$rID);
|
||||||
$_header->setRelationId(++$rID);
|
$_headerFile = 'header' . $_cHdrs . '.xml';
|
||||||
$_headerFile = 'header'.$_cHdrs.'.xml';
|
$sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID);
|
||||||
$sectionElements[] = array('target'=>$_headerFile, 'type'=>'header', 'rID'=>$rID);
|
$objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header));
|
||||||
$objZip->addFromString('word/'.$_headerFile, $this->getWriterPart('header')->writeHeader($_header));
|
}
|
||||||
}
|
|
||||||
|
$_footer = $section->getFooter();
|
||||||
$_footer = $section->getFooter();
|
if (!is_null($_footer)) {
|
||||||
if(!is_null($_footer)) {
|
$_cFtrs++;
|
||||||
$_cFtrs++;
|
$_footer->setRelationId(++$rID);
|
||||||
$_footer->setRelationId(++$rID);
|
$_footerCount = $_footer->getFooterCount();
|
||||||
$_footerCount = $_footer->getFooterCount();
|
$_footerFile = 'footer' . $_footerCount . '.xml';
|
||||||
$_footerFile = 'footer'.$_footerCount.'.xml';
|
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
|
||||||
$sectionElements[] = array('target'=>$_footerFile, 'type'=>'footer', 'rID'=>$rID);
|
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
|
||||||
$objZip->addFromString('word/'.$_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// build docx file
|
||||||
// build docx file
|
// Write dynamic files
|
||||||
// Write dynamic files
|
|
||||||
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->_imageTypes, $this->_objectTypes, $_cHdrs, $_cFtrs));
|
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->_imageTypes, $this->_objectTypes, $_cHdrs, $_cFtrs));
|
||||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeRelationships($this->_document));
|
$objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeRelationships($this->_document));
|
||||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->_document));
|
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->_document));
|
||||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->_document));
|
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->_document));
|
||||||
$objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->_document));
|
$objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->_document));
|
||||||
$objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements));
|
$objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements));
|
||||||
$objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
|
$objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
|
||||||
|
|
||||||
// Write static files
|
// Write static files
|
||||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
|
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
|
||||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml');
|
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml');
|
||||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
|
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
|
||||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
|
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
|
||||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
|
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
|
||||||
|
|
||||||
|
|
||||||
// Close file
|
|
||||||
if($objZip->close() === false) {
|
|
||||||
throw new Exception("Could not close zip file $pFilename.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a temporary file was used, copy it to the correct file stream
|
|
||||||
if($originalFilename != $pFilename) {
|
|
||||||
if (copy($pFilename, $originalFilename) === false) {
|
|
||||||
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
|
||||||
}
|
|
||||||
@unlink($pFilename);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Exception("PHPWord object unassigned.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _chkContentTypes($src) {
|
|
||||||
$srcInfo = pathinfo($src);
|
|
||||||
$extension = strtolower($srcInfo['extension']);
|
|
||||||
if(substr($extension, 0, 3) == 'php') {
|
|
||||||
$extension = 'php';
|
|
||||||
}
|
|
||||||
$_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php');
|
|
||||||
|
|
||||||
if(in_array($extension, $_supportedImageTypes)) {
|
|
||||||
$imagedata = getimagesize($src);
|
|
||||||
$imagetype = image_type_to_mime_type($imagedata[2]);
|
|
||||||
$imageext = image_type_to_extension($imagedata[2]);
|
|
||||||
$imageext = str_replace('.', '', $imageext);
|
|
||||||
if($imageext == 'jpeg') $imageext = 'jpg';
|
|
||||||
|
|
||||||
if(!in_array($imagetype, $this->_imageTypes)) {
|
|
||||||
$this->_imageTypes[$imageext] = $imagetype;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(!in_array($extension, $this->_objectTypes)) {
|
|
||||||
$this->_objectTypes[] = $extension;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWriterPart($pPartName = '') {
|
|
||||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
|
||||||
return $this->_writerParts[strtolower($pPartName)];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUseDiskCaching() {
|
|
||||||
return $this->_useDiskCaching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
// Close file
|
||||||
$this->_useDiskCaching = $pValue;
|
if ($objZip->close() === false) {
|
||||||
|
throw new Exception("Could not close zip file $pFilename.");
|
||||||
if (!is_null($pDirectory)) {
|
}
|
||||||
if (is_dir($pDirectory)) {
|
|
||||||
$this->_diskCachingDirectory = $pDirectory;
|
// If a temporary file was used, copy it to the correct file stream
|
||||||
} else {
|
if ($originalFilename != $pFilename) {
|
||||||
throw new Exception("Directory does not exist: $pDirectory");
|
if (copy($pFilename, $originalFilename) === false) {
|
||||||
}
|
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||||
}
|
}
|
||||||
|
@unlink($pFilename);
|
||||||
return $this;
|
}
|
||||||
}
|
} else {
|
||||||
|
throw new Exception("PHPWord object unassigned.");
|
||||||
private function _addFileToPackage($objZip, $element) {
|
}
|
||||||
if(isset($element['isMemImage']) && $element['isMemImage']) {
|
}
|
||||||
$image = call_user_func($element['createfunction'], $element['source']);
|
|
||||||
ob_start();
|
private function _chkContentTypes($src)
|
||||||
call_user_func($element['imagefunction'], $image);
|
{
|
||||||
$imageContents = ob_get_contents();
|
$srcInfo = pathinfo($src);
|
||||||
ob_end_clean();
|
$extension = strtolower($srcInfo['extension']);
|
||||||
$objZip->addFromString('word/'.$element['target'], $imageContents);
|
if (substr($extension, 0, 3) == 'php') {
|
||||||
imagedestroy($image);
|
$extension = 'php';
|
||||||
|
}
|
||||||
$this->_chkContentTypes($element['source']);
|
$_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php');
|
||||||
} else {
|
|
||||||
$objZip->addFile($element['source'], 'word/'.$element['target']);
|
if (in_array($extension, $_supportedImageTypes)) {
|
||||||
$this->_chkContentTypes($element['source']);
|
$imagedata = getimagesize($src);
|
||||||
}
|
$imagetype = image_type_to_mime_type($imagedata[2]);
|
||||||
}
|
$imageext = image_type_to_extension($imagedata[2]);
|
||||||
}
|
$imageext = str_replace('.', '', $imageext);
|
||||||
?>
|
if ($imageext == 'jpeg') $imageext = 'jpg';
|
||||||
|
|
||||||
|
if (!in_array($imagetype, $this->_imageTypes)) {
|
||||||
|
$this->_imageTypes[$imageext] = $imagetype;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!in_array($extension, $this->_objectTypes)) {
|
||||||
|
$this->_objectTypes[] = $extension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWriterPart($pPartName = '')
|
||||||
|
{
|
||||||
|
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||||
|
return $this->_writerParts[strtolower($pPartName)];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUseDiskCaching()
|
||||||
|
{
|
||||||
|
return $this->_useDiskCaching;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||||
|
{
|
||||||
|
$this->_useDiskCaching = $pValue;
|
||||||
|
|
||||||
|
if (!is_null($pDirectory)) {
|
||||||
|
if (is_dir($pDirectory)) {
|
||||||
|
$this->_diskCachingDirectory = $pDirectory;
|
||||||
|
} else {
|
||||||
|
throw new Exception("Directory does not exist: $pDirectory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _addFileToPackage($objZip, $element)
|
||||||
|
{
|
||||||
|
if (isset($element['isMemImage']) && $element['isMemImage']) {
|
||||||
|
$image = call_user_func($element['createfunction'], $element['source']);
|
||||||
|
ob_start();
|
||||||
|
call_user_func($element['imagefunction'], $image);
|
||||||
|
$imageContents = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
$objZip->addFromString('word/' . $element['target'], $imageContents);
|
||||||
|
imagedestroy($image);
|
||||||
|
|
||||||
|
$this->_chkContentTypes($element['source']);
|
||||||
|
} else {
|
||||||
|
$objZip->addFile($element['source'], 'word/' . $element['target']);
|
||||||
|
$this->_chkContentTypes($element['source']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1451
Classes/PHPWord/Writer/Word2007/Base.php
Normal file → Executable file
1451
Classes/PHPWord/Writer/Word2007/Base.php
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
2
Classes/PHPWord/Writer/Word2007/ContentTypes.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/ContentTypes.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/DocProps.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/DocProps.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
867
Classes/PHPWord/Writer/Word2007/Document.php
Normal file → Executable file
867
Classes/PHPWord/Writer/Word2007/Document.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* PHPWord
|
* PHPWord
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 PHPWord
|
* Copyright (c) 2013 PHPWord
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,439 +20,450 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 010 PHPWord
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version Beta 0.6.3, 08.07.2011
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PHPWord_Writer_Word2007_Document
|
||||||
|
*/
|
||||||
|
class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
||||||
|
{
|
||||||
|
|
||||||
class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
public function writeDocument(PHPWord $pPHPWord = null)
|
||||||
|
{
|
||||||
public function writeDocument(PHPWord $pPHPWord = null) {
|
// Create XML writer
|
||||||
// Create XML writer
|
|
||||||
|
|
||||||
if($this->getParentWriter()->getUseDiskCaching()) {
|
|
||||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
|
||||||
} else {
|
|
||||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// XML header
|
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
|
||||||
|
|
||||||
// w:document
|
|
||||||
$objWriter->startElement('w:document');
|
|
||||||
|
|
||||||
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
|
|
||||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
|
||||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
|
||||||
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
|
|
||||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
|
||||||
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
|
||||||
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
|
|
||||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
|
||||||
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
|
||||||
|
|
||||||
$objWriter->startElement('w:body');
|
|
||||||
|
|
||||||
$_sections = $pPHPWord->getSections();
|
|
||||||
$countSections = count($_sections);
|
|
||||||
$pSection = 0;
|
|
||||||
|
|
||||||
if($countSections > 0) {
|
|
||||||
foreach($_sections as $section) {
|
|
||||||
$pSection++;
|
|
||||||
|
|
||||||
$_elements = $section->getElements();
|
|
||||||
|
|
||||||
foreach($_elements as $element) {
|
|
||||||
if($element instanceof PHPWord_Section_Text) {
|
|
||||||
$this->_writeText($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
|
||||||
$this->_writeTextRun($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_Link) {
|
|
||||||
$this->_writeLink($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_Title) {
|
|
||||||
$this->_writeTitle($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
|
||||||
$this->_writeTextBreak($objWriter);
|
|
||||||
} elseif($element instanceof PHPWord_Section_PageBreak) {
|
|
||||||
$this->_writePageBreak($objWriter);
|
|
||||||
} elseif($element instanceof PHPWord_Section_Table) {
|
|
||||||
$this->_writeTable($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_ListItem) {
|
|
||||||
$this->_writeListItem($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_Image ||
|
|
||||||
$element instanceof PHPWord_Section_MemoryImage) {
|
|
||||||
$this->_writeImage($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_Section_Object) {
|
|
||||||
$this->_writeObject($objWriter, $element);
|
|
||||||
} elseif($element instanceof PHPWord_TOC) {
|
|
||||||
$this->_writeTOC($objWriter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($pSection == $countSections) {
|
|
||||||
$this->_writeEndSection($objWriter, $section);
|
|
||||||
} else {
|
|
||||||
$this->_writeSection($objWriter, $section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$objWriter->endElement(); // End w:body
|
|
||||||
$objWriter->endElement(); // End w:document
|
|
||||||
|
|
||||||
// Return
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
return $objWriter->getData();
|
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
}
|
} else {
|
||||||
|
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) {
|
}
|
||||||
$objWriter->startElement('w:p');
|
|
||||||
$objWriter->startElement('w:pPr');
|
|
||||||
$this->_writeEndSection($objWriter, $section, 3);
|
|
||||||
$objWriter->endElement();
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) {
|
|
||||||
$_settings = $section->getSettings();
|
|
||||||
$_headers = $section->getHeaders();
|
|
||||||
$_footer = $section->getFooter();
|
|
||||||
$pgSzW = $_settings->getPageSizeW();
|
|
||||||
$pgSzH = $_settings->getPageSizeH();
|
|
||||||
$orientation = $_settings->getOrientation();
|
|
||||||
|
|
||||||
$marginTop = $_settings->getMarginTop();
|
|
||||||
$marginLeft = $_settings->getMarginLeft();
|
|
||||||
$marginRight = $_settings->getMarginRight();
|
|
||||||
$marginBottom = $_settings->getMarginBottom();
|
|
||||||
|
|
||||||
$borders = $_settings->getBorderSize();
|
|
||||||
|
|
||||||
$objWriter->startElement('w:sectPr');
|
|
||||||
|
|
||||||
foreach ($_headers as &$_header) {
|
|
||||||
$rId = $_header->getRelationId();
|
|
||||||
$objWriter->startElement('w:headerReference');
|
|
||||||
$objWriter->writeAttribute('w:type', $_header->getType());
|
|
||||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if($section->hasDifferentFirstPage()) {
|
|
||||||
$objWriter->startElement('w:titlePg');
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($_footer)) {
|
|
||||||
$rId = $_footer->getRelationId();
|
|
||||||
$objWriter->startElement('w:footerReference');
|
|
||||||
$objWriter->writeAttribute('w:type', 'default');
|
|
||||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
$objWriter->startElement('w:pgSz');
|
|
||||||
$objWriter->writeAttribute('w:w', $pgSzW);
|
|
||||||
$objWriter->writeAttribute('w:h', $pgSzH);
|
|
||||||
|
|
||||||
if(!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
|
||||||
$objWriter->writeAttribute('w:orient', $orientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
$objWriter->endElement();
|
|
||||||
|
|
||||||
$objWriter->startElement('w:pgMar');
|
|
||||||
$objWriter->writeAttribute('w:top', $marginTop);
|
|
||||||
$objWriter->writeAttribute('w:right', $marginRight);
|
|
||||||
$objWriter->writeAttribute('w:bottom', $marginBottom);
|
|
||||||
$objWriter->writeAttribute('w:left', $marginLeft);
|
|
||||||
$objWriter->writeAttribute('w:header', '720');
|
|
||||||
$objWriter->writeAttribute('w:footer', '720');
|
|
||||||
$objWriter->writeAttribute('w:gutter', '0');
|
|
||||||
$objWriter->endElement();
|
|
||||||
|
|
||||||
|
|
||||||
if(!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
|
|
||||||
$borderColor = $_settings->getBorderColor();
|
|
||||||
|
|
||||||
$objWriter->startElement('w:pgBorders');
|
|
||||||
$objWriter->writeAttribute('w:offsetFrom', 'page');
|
|
||||||
|
|
||||||
if(!is_null($borders[0])) {
|
|
||||||
$objWriter->startElement('w:top');
|
|
||||||
$objWriter->writeAttribute('w:val', 'single');
|
|
||||||
$objWriter->writeAttribute('w:sz', $borders[0]);
|
|
||||||
$objWriter->writeAttribute('w:space', '24');
|
|
||||||
$objWriter->writeAttribute('w:color', $borderColor[0]);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($borders[1])) {
|
|
||||||
$objWriter->startElement('w:left');
|
|
||||||
$objWriter->writeAttribute('w:val', 'single');
|
|
||||||
$objWriter->writeAttribute('w:sz', $borders[1]);
|
|
||||||
$objWriter->writeAttribute('w:space', '24');
|
|
||||||
$objWriter->writeAttribute('w:color', $borderColor[1]);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($borders[2])) {
|
|
||||||
$objWriter->startElement('w:right');
|
|
||||||
$objWriter->writeAttribute('w:val', 'single');
|
|
||||||
$objWriter->writeAttribute('w:sz', $borders[2]);
|
|
||||||
$objWriter->writeAttribute('w:space', '24');
|
|
||||||
$objWriter->writeAttribute('w:color', $borderColor[2]);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($borders[3])) {
|
|
||||||
$objWriter->startElement('w:bottom');
|
|
||||||
$objWriter->writeAttribute('w:val', 'single');
|
|
||||||
$objWriter->writeAttribute('w:sz', $borders[3]);
|
|
||||||
$objWriter->writeAttribute('w:space', '24');
|
|
||||||
$objWriter->writeAttribute('w:color', $borderColor[3]);
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
$objWriter->endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// XML header
|
||||||
$objWriter->startElement('w:cols');
|
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||||
$objWriter->writeAttribute('w:space', '720');
|
|
||||||
$objWriter->endElement();
|
// w:document
|
||||||
|
$objWriter->startElement('w:document');
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||||
}
|
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||||
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||||
private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
|
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
|
||||||
$objWriter->startElement('w:p');
|
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
||||||
$objWriter->startElement('w:br');
|
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
|
||||||
$objWriter->writeAttribute('w:type', 'page');
|
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||||
$objWriter->endElement();
|
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:body');
|
||||||
}
|
|
||||||
|
$_sections = $pPHPWord->getSections();
|
||||||
private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) {
|
$countSections = count($_sections);
|
||||||
$textObject = $listItem->getTextObject();
|
$pSection = 0;
|
||||||
$text = $textObject->getText();
|
|
||||||
|
if ($countSections > 0) {
|
||||||
|
foreach ($_sections as $section) {
|
||||||
|
$pSection++;
|
||||||
|
|
||||||
|
$_elements = $section->getElements();
|
||||||
|
|
||||||
|
foreach ($_elements as $element) {
|
||||||
|
if ($element instanceof PHPWord_Section_Text) {
|
||||||
|
$this->_writeText($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||||
|
$this->_writeTextRun($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||||
|
$this->_writeLink($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_Title) {
|
||||||
|
$this->_writeTitle($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||||
|
$this->_writeTextBreak($objWriter);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_PageBreak) {
|
||||||
|
$this->_writePageBreak($objWriter);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||||
|
$this->_writeTable($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_ListItem) {
|
||||||
|
$this->_writeListItem($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||||
|
$element instanceof PHPWord_Section_MemoryImage
|
||||||
|
) {
|
||||||
|
$this->_writeImage($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_Section_Object) {
|
||||||
|
$this->_writeObject($objWriter, $element);
|
||||||
|
} elseif ($element instanceof PHPWord_TOC) {
|
||||||
|
$this->_writeTOC($objWriter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pSection == $countSections) {
|
||||||
|
$this->_writeEndSection($objWriter, $section);
|
||||||
|
} else {
|
||||||
|
$this->_writeSection($objWriter, $section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$objWriter->endElement(); // End w:body
|
||||||
|
$objWriter->endElement(); // End w:document
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return $objWriter->getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||||
|
{
|
||||||
|
$objWriter->startElement('w:p');
|
||||||
|
$objWriter->startElement('w:pPr');
|
||||||
|
$this->_writeEndSection($objWriter, $section, 3);
|
||||||
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||||
|
{
|
||||||
|
$_settings = $section->getSettings();
|
||||||
|
$_headers = $section->getHeaders();
|
||||||
|
$_footer = $section->getFooter();
|
||||||
|
$pgSzW = $_settings->getPageSizeW();
|
||||||
|
$pgSzH = $_settings->getPageSizeH();
|
||||||
|
$orientation = $_settings->getOrientation();
|
||||||
|
|
||||||
|
$marginTop = $_settings->getMarginTop();
|
||||||
|
$marginLeft = $_settings->getMarginLeft();
|
||||||
|
$marginRight = $_settings->getMarginRight();
|
||||||
|
$marginBottom = $_settings->getMarginBottom();
|
||||||
|
|
||||||
|
$borders = $_settings->getBorderSize();
|
||||||
|
|
||||||
|
$objWriter->startElement('w:sectPr');
|
||||||
|
|
||||||
|
foreach ($_headers as &$_header) {
|
||||||
|
$rId = $_header->getRelationId();
|
||||||
|
$objWriter->startElement('w:headerReference');
|
||||||
|
$objWriter->writeAttribute('w:type', $_header->getType());
|
||||||
|
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($section->hasDifferentFirstPage()) {
|
||||||
|
$objWriter->startElement('w:titlePg');
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($_footer)) {
|
||||||
|
$rId = $_footer->getRelationId();
|
||||||
|
$objWriter->startElement('w:footerReference');
|
||||||
|
$objWriter->writeAttribute('w:type', 'default');
|
||||||
|
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
$objWriter->startElement('w:pgSz');
|
||||||
|
$objWriter->writeAttribute('w:w', $pgSzW);
|
||||||
|
$objWriter->writeAttribute('w:h', $pgSzH);
|
||||||
|
|
||||||
|
if (!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
||||||
|
$objWriter->writeAttribute('w:orient', $orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
$objWriter->startElement('w:pgMar');
|
||||||
|
$objWriter->writeAttribute('w:top', $marginTop);
|
||||||
|
$objWriter->writeAttribute('w:right', $marginRight);
|
||||||
|
$objWriter->writeAttribute('w:bottom', $marginBottom);
|
||||||
|
$objWriter->writeAttribute('w:left', $marginLeft);
|
||||||
|
$objWriter->writeAttribute('w:header', '720');
|
||||||
|
$objWriter->writeAttribute('w:footer', '720');
|
||||||
|
$objWriter->writeAttribute('w:gutter', '0');
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
|
||||||
|
if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
|
||||||
|
$borderColor = $_settings->getBorderColor();
|
||||||
|
|
||||||
|
$objWriter->startElement('w:pgBorders');
|
||||||
|
$objWriter->writeAttribute('w:offsetFrom', 'page');
|
||||||
|
|
||||||
|
if (!is_null($borders[0])) {
|
||||||
|
$objWriter->startElement('w:top');
|
||||||
|
$objWriter->writeAttribute('w:val', 'single');
|
||||||
|
$objWriter->writeAttribute('w:sz', $borders[0]);
|
||||||
|
$objWriter->writeAttribute('w:space', '24');
|
||||||
|
$objWriter->writeAttribute('w:color', $borderColor[0]);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($borders[1])) {
|
||||||
|
$objWriter->startElement('w:left');
|
||||||
|
$objWriter->writeAttribute('w:val', 'single');
|
||||||
|
$objWriter->writeAttribute('w:sz', $borders[1]);
|
||||||
|
$objWriter->writeAttribute('w:space', '24');
|
||||||
|
$objWriter->writeAttribute('w:color', $borderColor[1]);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($borders[2])) {
|
||||||
|
$objWriter->startElement('w:right');
|
||||||
|
$objWriter->writeAttribute('w:val', 'single');
|
||||||
|
$objWriter->writeAttribute('w:sz', $borders[2]);
|
||||||
|
$objWriter->writeAttribute('w:space', '24');
|
||||||
|
$objWriter->writeAttribute('w:color', $borderColor[2]);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($borders[3])) {
|
||||||
|
$objWriter->startElement('w:bottom');
|
||||||
|
$objWriter->writeAttribute('w:val', 'single');
|
||||||
|
$objWriter->writeAttribute('w:sz', $borders[3]);
|
||||||
|
$objWriter->writeAttribute('w:space', '24');
|
||||||
|
$objWriter->writeAttribute('w:color', $borderColor[3]);
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$objWriter->startElement('w:cols');
|
||||||
|
$objWriter->writeAttribute('w:space', '720');
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||||
|
{
|
||||||
|
$objWriter->startElement('w:p');
|
||||||
|
$objWriter->startElement('w:r');
|
||||||
|
$objWriter->startElement('w:br');
|
||||||
|
$objWriter->writeAttribute('w:type', 'page');
|
||||||
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
|
||||||
|
{
|
||||||
|
$textObject = $listItem->getTextObject();
|
||||||
|
$text = $textObject->getText();
|
||||||
$styleParagraph = $textObject->getParagraphStyle();
|
$styleParagraph = $textObject->getParagraphStyle();
|
||||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||||
|
|
||||||
$depth = $listItem->getDepth();
|
$depth = $listItem->getDepth();
|
||||||
$listType = $listItem->getStyle()->getListType();
|
$listType = $listItem->getStyle()->getListType();
|
||||||
|
|
||||||
$objWriter->startElement('w:p');
|
$objWriter->startElement('w:p');
|
||||||
$objWriter->startElement('w:pPr');
|
$objWriter->startElement('w:pPr');
|
||||||
|
|
||||||
if($SpIsObject) {
|
if ($SpIsObject) {
|
||||||
$this->_writeParagraphStyle($objWriter, $styleParagraph, true);
|
$this->_writeParagraphStyle($objWriter, $styleParagraph, true);
|
||||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||||
$objWriter->startElement('w:pStyle');
|
$objWriter->startElement('w:pStyle');
|
||||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->startElement('w:numPr');
|
$objWriter->startElement('w:numPr');
|
||||||
|
|
||||||
$objWriter->startElement('w:ilvl');
|
$objWriter->startElement('w:ilvl');
|
||||||
$objWriter->writeAttribute('w:val', $depth);
|
$objWriter->writeAttribute('w:val', $depth);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->startElement('w:numId');
|
$objWriter->startElement('w:numId');
|
||||||
$objWriter->writeAttribute('w:val', $listType);
|
$objWriter->writeAttribute('w:val', $listType);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$this->_writeText($objWriter, $textObject, true);
|
$this->_writeText($objWriter, $textObject, true);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object) {
|
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object)
|
||||||
$rIdObject = $object->getRelationId();
|
{
|
||||||
$rIdImage = $object->getImageRelationId();
|
$rIdObject = $object->getRelationId();
|
||||||
$shapeId = md5($rIdObject.'_'.$rIdImage);
|
$rIdImage = $object->getImageRelationId();
|
||||||
|
$shapeId = md5($rIdObject . '_' . $rIdImage);
|
||||||
$objectId = $object->getObjectId();
|
|
||||||
|
$objectId = $object->getObjectId();
|
||||||
$style = $object->getStyle();
|
|
||||||
$width = $style->getWidth();
|
$style = $object->getStyle();
|
||||||
$height = $style->getHeight();
|
$width = $style->getWidth();
|
||||||
$align = $style->getAlign();
|
$height = $style->getHeight();
|
||||||
|
$align = $style->getAlign();
|
||||||
|
|
||||||
$objWriter->startElement('w:p');
|
|
||||||
|
$objWriter->startElement('w:p');
|
||||||
if(!is_null($align)) {
|
|
||||||
$objWriter->startElement('w:pPr');
|
if (!is_null($align)) {
|
||||||
$objWriter->startElement('w:jc');
|
$objWriter->startElement('w:pPr');
|
||||||
$objWriter->writeAttribute('w:val', $align);
|
$objWriter->startElement('w:jc');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:val', $align);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
$objWriter->startElement('w:r');
|
|
||||||
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->startElement('w:object');
|
|
||||||
$objWriter->writeAttribute('w:dxaOrig', '249');
|
$objWriter->startElement('w:object');
|
||||||
$objWriter->writeAttribute('w:dyaOrig', '160');
|
$objWriter->writeAttribute('w:dxaOrig', '249');
|
||||||
|
$objWriter->writeAttribute('w:dyaOrig', '160');
|
||||||
$objWriter->startElement('v:shape');
|
|
||||||
$objWriter->writeAttribute('id', $shapeId);
|
$objWriter->startElement('v:shape');
|
||||||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
$objWriter->writeAttribute('id', $shapeId);
|
||||||
$objWriter->writeAttribute('style', 'width:104px;height:67px');
|
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||||
$objWriter->writeAttribute('o:ole', '');
|
$objWriter->writeAttribute('style', 'width:104px;height:67px');
|
||||||
|
$objWriter->writeAttribute('o:ole', '');
|
||||||
$objWriter->startElement('v:imagedata');
|
|
||||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdImage);
|
$objWriter->startElement('v:imagedata');
|
||||||
$objWriter->writeAttribute('o:title', '');
|
$objWriter->writeAttribute('r:id', 'rId' . $rIdImage);
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('o:title', '');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->endElement();
|
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('o:OLEObject');
|
|
||||||
$objWriter->writeAttribute('Type', 'Embed');
|
$objWriter->startElement('o:OLEObject');
|
||||||
$objWriter->writeAttribute('ProgID', 'Package');
|
$objWriter->writeAttribute('Type', 'Embed');
|
||||||
$objWriter->writeAttribute('ShapeID', $shapeId);
|
$objWriter->writeAttribute('ProgID', 'Package');
|
||||||
$objWriter->writeAttribute('DrawAspect', 'Icon');
|
$objWriter->writeAttribute('ShapeID', $shapeId);
|
||||||
$objWriter->writeAttribute('ObjectID', '_'.$objectId);
|
$objWriter->writeAttribute('DrawAspect', 'Icon');
|
||||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdObject);
|
$objWriter->writeAttribute('ObjectID', '_' . $objectId);
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('r:id', 'rId' . $rIdObject);
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->endElement();
|
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->endElement(); // w:r
|
|
||||||
|
$objWriter->endElement(); // w:r
|
||||||
$objWriter->endElement(); // w:p
|
|
||||||
}
|
$objWriter->endElement(); // w:p
|
||||||
|
}
|
||||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) {
|
|
||||||
$titles = PHPWord_TOC::getTitles();
|
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||||
$styleFont = PHPWord_TOC::getStyleFont();
|
{
|
||||||
|
$titles = PHPWord_TOC::getTitles();
|
||||||
$styleTOC = PHPWord_TOC::getStyleTOC();
|
$styleFont = PHPWord_TOC::getStyleFont();
|
||||||
$fIndent = $styleTOC->getIndent();
|
|
||||||
$tabLeader = $styleTOC->getTabLeader();
|
$styleTOC = PHPWord_TOC::getStyleTOC();
|
||||||
$tabPos = $styleTOC->getTabPos();
|
$fIndent = $styleTOC->getIndent();
|
||||||
|
$tabLeader = $styleTOC->getTabLeader();
|
||||||
$isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
$tabPos = $styleTOC->getTabPos();
|
||||||
|
|
||||||
for($i=0; $i<count($titles); $i++) {
|
$isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||||
$title = $titles[$i];
|
|
||||||
$indent = ($title['depth'] - 1) * $fIndent;
|
for ($i = 0; $i < count($titles); $i++) {
|
||||||
|
$title = $titles[$i];
|
||||||
$objWriter->startElement('w:p');
|
$indent = ($title['depth'] - 1) * $fIndent;
|
||||||
|
|
||||||
$objWriter->startElement('w:pPr');
|
$objWriter->startElement('w:p');
|
||||||
|
|
||||||
if($isObject && !is_null($styleFont->getParagraphStyle())) {
|
$objWriter->startElement('w:pPr');
|
||||||
$this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
|
|
||||||
}
|
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||||
|
$this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
|
||||||
if($indent > 0) {
|
}
|
||||||
$objWriter->startElement('w:ind');
|
|
||||||
$objWriter->writeAttribute('w:left', $indent);
|
if ($indent > 0) {
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:ind');
|
||||||
}
|
$objWriter->writeAttribute('w:left', $indent);
|
||||||
|
$objWriter->endElement();
|
||||||
if(!empty($styleFont) && !$isObject) {
|
}
|
||||||
$objWriter->startElement('w:pPr');
|
|
||||||
$objWriter->startElement('w:pStyle');
|
if (!empty($styleFont) && !$isObject) {
|
||||||
$objWriter->writeAttribute('w:val', $styleFont);
|
$objWriter->startElement('w:pPr');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:pStyle');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:val', $styleFont);
|
||||||
}
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:tabs');
|
}
|
||||||
$objWriter->startElement('w:tab');
|
|
||||||
$objWriter->writeAttribute('w:val', 'right');
|
$objWriter->startElement('w:tabs');
|
||||||
if(!empty($tabLeader)) {
|
$objWriter->startElement('w:tab');
|
||||||
$objWriter->writeAttribute('w:leader', $tabLeader);
|
$objWriter->writeAttribute('w:val', 'right');
|
||||||
}
|
if (!empty($tabLeader)) {
|
||||||
$objWriter->writeAttribute('w:pos', $tabPos);
|
$objWriter->writeAttribute('w:leader', $tabLeader);
|
||||||
$objWriter->endElement();
|
}
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:pos', $tabPos);
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->endElement(); // w:pPr
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
$objWriter->endElement(); // w:pPr
|
||||||
if($i == 0) {
|
|
||||||
$objWriter->startElement('w:r');
|
|
||||||
$objWriter->startElement('w:fldChar');
|
if ($i == 0) {
|
||||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:fldChar');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:instrText');
|
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->writeRaw('TOC \o "1-9" \h \z \u');
|
$objWriter->startElement('w:instrText');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->endElement();
|
$objWriter->writeRaw('TOC \o "1-9" \h \z \u');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:fldChar');
|
|
||||||
$objWriter->writeAttribute('w:fldCharType', 'separate');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:fldChar');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:fldCharType', 'separate');
|
||||||
}
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:hyperlink');
|
}
|
||||||
$objWriter->writeAttribute('w:anchor', $title['anchor']);
|
|
||||||
$objWriter->writeAttribute('w:history', '1');
|
$objWriter->startElement('w:hyperlink');
|
||||||
|
$objWriter->writeAttribute('w:anchor', $title['anchor']);
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->writeAttribute('w:history', '1');
|
||||||
|
|
||||||
if($isObject) {
|
$objWriter->startElement('w:r');
|
||||||
$this->_writeTextStyle($objWriter, $styleFont);
|
|
||||||
}
|
if ($isObject) {
|
||||||
|
$this->_writeTextStyle($objWriter, $styleFont);
|
||||||
$objWriter->startElement('w:t');
|
}
|
||||||
$objWriter->writeRaw($title['text']);
|
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:t');
|
||||||
$objWriter->endElement();
|
$objWriter->writeRaw($title['text']);
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->writeElement('w:tab', null);
|
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:r');
|
||||||
|
$objWriter->writeElement('w:tab', null);
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:fldChar');
|
|
||||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:fldChar');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:instrText');
|
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->writeRaw('PAGEREF '.$title['anchor'].' \h');
|
$objWriter->startElement('w:instrText');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->endElement();
|
$objWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:r');
|
$objWriter->endElement();
|
||||||
$objWriter->startElement('w:fldChar');
|
|
||||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:fldChar');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||||
|
$objWriter->endElement();
|
||||||
$objWriter->endElement(); // w:hyperlink
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement(); // w:p
|
$objWriter->endElement(); // w:hyperlink
|
||||||
}
|
|
||||||
|
$objWriter->endElement(); // w:p
|
||||||
$objWriter->startElement('w:p');
|
}
|
||||||
$objWriter->startElement('w:r');
|
|
||||||
$objWriter->startElement('w:fldChar');
|
$objWriter->startElement('w:p');
|
||||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
$objWriter->startElement('w:r');
|
||||||
$objWriter->endElement();
|
$objWriter->startElement('w:fldChar');
|
||||||
$objWriter->endElement();
|
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
$objWriter->endElement();
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/DocumentRels.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/DocumentRels.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/Footer.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/Footer.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/Header.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/Header.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/Rels.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/Rels.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/Styles.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/Styles.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
Classes/PHPWord/Writer/Word2007/WriterPart.php
Normal file → Executable file
2
Classes/PHPWord/Writer/Word2007/WriterPart.php
Normal file → Executable file
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* @category PHPWord
|
* @category PHPWord
|
||||||
* @package PHPWord
|
* @package PHPWord
|
||||||
* @copyright Copyright (c) 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
* @copyright Copyright (c) 2013 PHPWord
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version 0.7.0
|
* @version 0.7.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
README.md
Normal file → Executable file
2
README.md
Normal file → Executable file
@ -59,7 +59,7 @@ $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
|||||||
$objWriter->save('helloWorld.docx');
|
$objWriter->save('helloWorld.docx');
|
||||||
```
|
```
|
||||||
|
|
||||||
## Image
|
## Images
|
||||||
|
|
||||||
You can add images easily using the following example.
|
You can add images easily using the following example.
|
||||||
|
|
||||||
|
|||||||
5
changelog.txt
Normal file → Executable file
5
changelog.txt
Normal file → Executable file
@ -22,7 +22,7 @@
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
|
|
||||||
Fixed in branch for release 0.7 :
|
Fixed in branch for release 0.7.0 :
|
||||||
- Bugfix: (RomanSyroeshko) GH-32 - "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found
|
- Bugfix: (RomanSyroeshko) GH-32 - "Warning: Invalid error type specified in ...\PHPWord.php on line 226" is thrown when the specified template file is not found
|
||||||
- Bugfix: (RomanSyroeshko) GH-34 - PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input
|
- Bugfix: (RomanSyroeshko) GH-34 - PHPWord_Shared_String.IsUTF8 returns FALSE for Cyrillic UTF-8 input
|
||||||
- Bugfix: (RomanSyroeshko) GH-38 - Temporary files naming logic in PHPWord_Template can lead to a collision
|
- Bugfix: (RomanSyroeshko) GH-38 - Temporary files naming logic in PHPWord_Template can lead to a collision
|
||||||
@ -38,5 +38,4 @@ Fixed in branch for release 0.7 :
|
|||||||
- General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template
|
- General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template
|
||||||
- General: (Progi1984) - IMPROVED : Moved examples out of Classes directory
|
- General: (Progi1984) - IMPROVED : Moved examples out of Classes directory
|
||||||
- General: (Esmeraldo) CP-49 - IMPROVED : Advanced string replace in setValue for Template
|
- General: (Esmeraldo) CP-49 - IMPROVED : Advanced string replace in setValue for Template
|
||||||
- Feature: (gavroche) Added composer file
|
- Feature: (gavroche) - Added support for image wrapping style
|
||||||
- Feature: (gavroche) Added support for image wrapping style
|
|
||||||
|
|||||||
1
samples/Sample_01_SimpleText.php
Normal file → Executable file
1
samples/Sample_01_SimpleText.php
Normal file → Executable file
@ -49,4 +49,3 @@ echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 102
|
|||||||
|
|
||||||
// Echo done
|
// Echo done
|
||||||
echo date('H:i:s') , " Done writing file" , EOL;
|
echo date('H:i:s') , " Done writing file" , EOL;
|
||||||
?>
|
|
||||||
3
samples/Sample_02_TabStops.php
Normal file → Executable file
3
samples/Sample_02_TabStops.php
Normal file → Executable file
@ -60,5 +60,4 @@ $objWriter->save(str_replace('.php', '.rtf', __FILE__));
|
|||||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL;
|
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL;
|
||||||
|
|
||||||
// Echo done
|
// Echo done
|
||||||
echo date('H:i:s') , ' Done writing file' , EOL;
|
echo date('H:i:s') , ' Done writing file' , EOL;
|
||||||
?>
|
|
||||||
1
samples/old/AdvancedTable.php
Normal file → Executable file
1
samples/old/AdvancedTable.php
Normal file → Executable file
@ -50,4 +50,3 @@ for($i = 1; $i <= 10; $i++) {
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('AdvancedTable.docx');
|
$objWriter->save('AdvancedTable.docx');
|
||||||
?>
|
|
||||||
1
samples/old/BasicTable.php
Normal file → Executable file
1
samples/old/BasicTable.php
Normal file → Executable file
@ -23,4 +23,3 @@ for($r = 1; $r <= 10; $r++) { // Loop through rows
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('BasicTable.docx');
|
$objWriter->save('BasicTable.docx');
|
||||||
?>
|
|
||||||
1
samples/old/HeaderFooter.php
Normal file → Executable file
1
samples/old/HeaderFooter.php
Normal file → Executable file
@ -54,4 +54,3 @@ $section2->addText('Some text...');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('HeaderFooter.docx');
|
$objWriter->save('HeaderFooter.docx');
|
||||||
?>
|
|
||||||
1
samples/old/Image.php
Normal file → Executable file
1
samples/old/Image.php
Normal file → Executable file
@ -21,4 +21,3 @@ $section->addImage('_mars.jpg', array('width'=>100, 'height'=>100, 'align'=>'rig
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Image.docx');
|
$objWriter->save('Image.docx');
|
||||||
?>
|
|
||||||
1
samples/old/Link.php
Normal file → Executable file
1
samples/old/Link.php
Normal file → Executable file
@ -21,4 +21,3 @@ $section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Link.docx');
|
$objWriter->save('Link.docx');
|
||||||
?>
|
|
||||||
1
samples/old/ListItem.php
Normal file → Executable file
1
samples/old/ListItem.php
Normal file → Executable file
@ -44,4 +44,3 @@ $section->addListItem('List Item 7', 0, 'myOwnStyle', $listStyle, 'P-Style');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('ListItem.docx');
|
$objWriter->save('ListItem.docx');
|
||||||
?>
|
|
||||||
1
samples/old/Object.php
Normal file → Executable file
1
samples/old/Object.php
Normal file → Executable file
@ -17,4 +17,3 @@ $section->addObject('_sheet.xls');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Object.docx');
|
$objWriter->save('Object.docx');
|
||||||
?>
|
|
||||||
|
|||||||
1
samples/old/Section.php
Normal file → Executable file
1
samples/old/Section.php
Normal file → Executable file
@ -23,4 +23,3 @@ $section->addText('This section uses other margins.');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Section.docx');
|
$objWriter->save('Section.docx');
|
||||||
?>
|
|
||||||
1
samples/old/Template.php
Normal file → Executable file
1
samples/old/Template.php
Normal file → Executable file
@ -20,4 +20,3 @@ $document->setValue('weekday', date('l'));
|
|||||||
$document->setValue('time', date('H:i'));
|
$document->setValue('time', date('H:i'));
|
||||||
|
|
||||||
$document->save('Solarsystem.docx');
|
$document->save('Solarsystem.docx');
|
||||||
?>
|
|
||||||
1
samples/old/Textrun.php
Normal file → Executable file
1
samples/old/Textrun.php
Normal file → Executable file
@ -29,4 +29,3 @@ $textrun->addLink('http://www.bing.com', null, 'NLink');
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Textrun.docx');
|
$objWriter->save('Textrun.docx');
|
||||||
?>
|
|
||||||
1
samples/old/TitleTOC.php
Normal file → Executable file
1
samples/old/TitleTOC.php
Normal file → Executable file
@ -46,4 +46,3 @@ echo 'Note: The pagenumbers in the TOC doesnt refresh automatically.';
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('TitleTOC.docx');
|
$objWriter->save('TitleTOC.docx');
|
||||||
?>
|
|
||||||
|
|||||||
1
samples/old/Watermark.php
Normal file → Executable file
1
samples/old/Watermark.php
Normal file → Executable file
@ -18,4 +18,3 @@ $section->addText('The header reference to the current section includes a waterm
|
|||||||
// Save File
|
// Save File
|
||||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
$objWriter->save('Watermark.docx');
|
$objWriter->save('Watermark.docx');
|
||||||
?>
|
|
||||||
2
test/PHPWord/Tests/ImageTest.php
Normal file → Executable file
2
test/PHPWord/Tests/ImageTest.php
Normal file → Executable file
@ -4,8 +4,6 @@ namespace PHPWord\Tests;
|
|||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/PHPWord.php';
|
|
||||||
|
|
||||||
class ImageTest extends PHPUnit_Framework_TestCase
|
class ImageTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
|
|||||||
2
test/bootstrap.php
Normal file → Executable file
2
test/bootstrap.php
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
require_once __DIR__ . "/../src/PHPWord/Autoloader.php";
|
require_once __DIR__ . "/../Classes/PHPWord/Autoloader.php";
|
||||||
PHPWord_Autoloader::Register();
|
PHPWord_Autoloader::Register();
|
||||||
|
|
||||||
require_once __DIR__ . "/PHPWord/TestHelper.php";
|
require_once __DIR__ . "/PHPWord/TestHelper.php";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user