Merge pull request #40 from gavroche/master
PR40 - Added support for Composer, Images Wrapping, Unit Testing and started re-writing code to be PSR-2 compliant
This commit is contained in:
commit
a4b6b843ad
|
|
@ -1,11 +1,20 @@
|
|||
|
||||
.DS_Store
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Thumbs.db
|
||||
Desktop.ini
|
||||
.idea
|
||||
phpunit.xml
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
/.settings
|
||||
/.buildpath
|
||||
/.project
|
||||
/docs
|
||||
|
||||
*.odt
|
||||
*.docx
|
||||
*.rtf
|
||||
*.txt
|
||||
*.xml
|
||||
*.xml
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,13 +20,13 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/** PHPWORD_BASE_PATH */
|
||||
if(!defined('PHPWORD_BASE_PATH')) {
|
||||
if (!defined('PHPWORD_BASE_PATH')) {
|
||||
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
|
||||
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
|
||||
PHPWord_Autoloader::Register();
|
||||
|
|
@ -35,196 +35,208 @@ if(!defined('PHPWORD_BASE_PATH')) {
|
|||
|
||||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2011 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();
|
||||
class PHPWord
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPWord Document
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_properties = new PHPWord_DocumentProperties();
|
||||
$this->_defaultFontName = 'Arial';
|
||||
$this->_defaultFontSize = 20;
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @param string $strFilename
|
||||
* @return PHPWord_Template
|
||||
*/
|
||||
public function loadTemplate($strFilename) {
|
||||
if(file_exists($strFilename)) {
|
||||
public function loadTemplate($strFilename)
|
||||
{
|
||||
if (file_exists($strFilename)) {
|
||||
$template = new PHPWord_Template($strFilename);
|
||||
return $template;
|
||||
} else {
|
||||
trigger_error('Template file '.$strFilename.' not found.', E_USER_ERROR);
|
||||
trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,29 +20,44 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
if (!defined('PHPWORD_BASE_PATH')) {
|
||||
define('PHPWORD_BASE_PATH', realpath(__DIR__ . '/../') . '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Class PHPWord_Autoloader
|
||||
*/
|
||||
class PHPWord_Autoloader
|
||||
{
|
||||
public static function Register() {
|
||||
return spl_autoload_register(array('PHPWord_Autoloader', 'Load'));
|
||||
}
|
||||
/**
|
||||
* Register the autoloader
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
spl_autoload_register(array('PHPWord_Autoloader', 'load'));
|
||||
}
|
||||
|
||||
public static function Load($strObjectName) {
|
||||
if((class_exists($strObjectName)) || (strpos($strObjectName, 'PHPWord') === false)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Autoloader
|
||||
*
|
||||
* @param string $strObjectName
|
||||
* @return mixed
|
||||
*/
|
||||
public static function load($strObjectName)
|
||||
{
|
||||
$strObjectFilePath = __DIR__ . '/../' . str_replace('_', '/', $strObjectName) . '.php';
|
||||
if (file_exists($strObjectFilePath) && is_readable($strObjectFilePath)) {
|
||||
require_once $strObjectFilePath;
|
||||
return true;
|
||||
}
|
||||
|
||||
$strObjectFilePath = PHPWORD_BASE_PATH . str_replace('_', '/', $strObjectName) . '.php';
|
||||
|
||||
if((file_exists($strObjectFilePath) === false) || (is_readable($strObjectFilePath) === false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require($strObjectFilePath);
|
||||
}
|
||||
}
|
||||
?>
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,311 +20,327 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_DocumentProperties
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_DocumentProperties
|
||||
*/
|
||||
class PHPWord_DocumentProperties {
|
||||
class PHPWord_DocumentProperties
|
||||
{
|
||||
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator;
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Company
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_company;
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator;
|
||||
|
||||
/**
|
||||
* Create new PHPWord_DocumentProperties
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_creator = '';
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
$this->_title = '';
|
||||
$this->_subject = '';
|
||||
$this->_description = '';
|
||||
$this->_keywords = '';
|
||||
$this->_category = '';
|
||||
$this->_company = '';
|
||||
}
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
$this->_creator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_created = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_modified = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
$this->_title = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
$this->_subject = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
$this->_keywords = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
$this->_category = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany() {
|
||||
return $this->_company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '') {
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Company
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_company;
|
||||
|
||||
/**
|
||||
* Create new PHPWord_DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_creator = '';
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
$this->_title = '';
|
||||
$this->_subject = '';
|
||||
$this->_description = '';
|
||||
$this->_keywords = '';
|
||||
$this->_category = '';
|
||||
$this->_company = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator()
|
||||
{
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '')
|
||||
{
|
||||
$this->_creator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy()
|
||||
{
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '')
|
||||
{
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_created = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified()
|
||||
{
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_modified = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '')
|
||||
{
|
||||
$this->_title = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '')
|
||||
{
|
||||
$this->_description = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '')
|
||||
{
|
||||
$this->_subject = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords()
|
||||
{
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '')
|
||||
{
|
||||
$this->_keywords = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '')
|
||||
{
|
||||
$this->_category = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->_company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '')
|
||||
{
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,33 +20,30 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Exception
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2006 - 2013 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Exception
|
||||
*/
|
||||
class PHPWord_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
class PHPWord_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,18 +20,13 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_HashTable
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
*/
|
||||
class PHPWord_HashTable
|
||||
{
|
||||
|
|
@ -52,25 +47,26 @@ class PHPWord_HashTable
|
|||
/**
|
||||
* Create a new PHPWord_HashTable
|
||||
*
|
||||
* @param PHPWord_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws Exception
|
||||
* @param PHPWord_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPWord_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
* @param PHPWord_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
public function addFromSource($pSource = null)
|
||||
{
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
|
|
@ -85,63 +81,66 @@ class PHPWord_HashTable
|
|||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPWord_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
* @param PHPWord_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPWord_IComparable $pSource = null) {
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if ( is_null ( $hashIndex ) ) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if ( isset ( $this->_keyMap[$hashIndex] ) ) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
}
|
||||
public function add(PHPWord_IComparable $pSource = null)
|
||||
{
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if (is_null($hashIndex)) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if (isset ($this->_keyMap[$hashIndex])) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->_items[ $hashCode ])) {
|
||||
$this->_items[ $hashCode ] = $pSource;
|
||||
// Add value
|
||||
if (!isset($this->_items[$hashCode])) {
|
||||
$this->_items[$hashCode] = $pSource;
|
||||
$index = count($this->_items) - 1;
|
||||
$this->_keyMap[ $index ] = $hashCode;
|
||||
$pSource->setHashIndex( $index );
|
||||
} else {
|
||||
$pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() );
|
||||
}
|
||||
$this->_keyMap[$index] = $hashCode;
|
||||
$pSource->setHashIndex($index);
|
||||
} else {
|
||||
$pSource->setHashIndex($this->_items[$hashCode]->getHashIndex());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPWord_IComparable $pSource Item to remove
|
||||
* @throws Exception
|
||||
* @param PHPWord_IComparable $pSource Item to remove
|
||||
* @throws Exception
|
||||
*/
|
||||
public function remove(PHPWord_IComparable $pSource = null) {
|
||||
if (isset($this->_items[ $pSource->getHashCode() ])) {
|
||||
unset($this->_items[ $pSource->getHashCode() ]);
|
||||
public function remove(PHPWord_IComparable $pSource = null)
|
||||
{
|
||||
if (isset($this->_items[$pSource->getHashCode()])) {
|
||||
unset($this->_items[$pSource->getHashCode()]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
}
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
public function clear()
|
||||
{
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -149,48 +148,52 @@ class PHPWord_HashTable
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
public function count()
|
||||
{
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
public function getIndexForHashCode($pHashCode = '')
|
||||
{
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPWord_IComparable
|
||||
* @param int $pIndex
|
||||
* @return PHPWord_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
public function getByIndex($pIndex = 0)
|
||||
{
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode($this->_keyMap[$pIndex]);
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPWord_IComparable
|
||||
* @param string $pHashCode
|
||||
* @return PHPWord_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
public function getByHashCode($pHashCode = '')
|
||||
{
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,19 +201,21 @@ class PHPWord_HashTable
|
|||
*
|
||||
* @return PHPWord_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
public function toArray()
|
||||
{
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,101 +20,102 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_IOFactory
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_IOFactory
|
||||
*/
|
||||
class PHPWord_IOFactory {
|
||||
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}')
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Serialized'
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPWord_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPWord/Writer/{0}.php
|
||||
* @param string $classname Example: PHPWord_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPWord_Writer_IWriter
|
||||
*
|
||||
* @param PHPWord $PHPWord
|
||||
* @param string $writerType Example: Word2007
|
||||
* @return PHPWord_Writer_IWriter
|
||||
*/
|
||||
public static function createWriter(PHPWord $PHPWord, $writerType = '') {
|
||||
$searchType = 'IWriter';
|
||||
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
$instance = new $className($PHPWord);
|
||||
if(!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("No $searchType found for type $writerType");
|
||||
}
|
||||
class PHPWord_IOFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}')
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Serialized'
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPWord_IOFactory
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations()
|
||||
{
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPWord/Writer/{0}.php
|
||||
* @param string $classname Example: PHPWord_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '')
|
||||
{
|
||||
self::$_searchLocations[] = array('type' => $type, 'path' => $location, 'class' => $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPWord_Writer_IWriter
|
||||
*
|
||||
* @param PHPWord $PHPWord
|
||||
* @param string $writerType Example: Word2007
|
||||
* @return PHPWord_Writer_IWriter
|
||||
*/
|
||||
public static function createWriter(PHPWord $PHPWord, $writerType = '')
|
||||
{
|
||||
$searchType = 'IWriter';
|
||||
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
$instance = new $className($PHPWord);
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("No $searchType found for type $writerType");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,309 +20,314 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Media
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Media
|
||||
*/
|
||||
class PHPWord_Media {
|
||||
|
||||
/**
|
||||
* Section Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_sectionMedia = array('images'=>array(),
|
||||
'embeddings'=>array(),
|
||||
'links'=>array());
|
||||
|
||||
/**
|
||||
* Header Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_headerMedia = array();
|
||||
|
||||
/**
|
||||
* Footer Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footerMedia = array();
|
||||
|
||||
/**
|
||||
* ObjectID Counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_objectId = 1325353440;
|
||||
|
||||
|
||||
/**
|
||||
* Add new Section Media Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
$mediaId = md5($src);
|
||||
$key = ($type == 'image') ? 'images' : 'embeddings';
|
||||
|
||||
if(!array_key_exists($mediaId, self::$_sectionMedia[$key])) {
|
||||
$cImg = self::countSectionMediaElements('images');
|
||||
$cObj = self::countSectionMediaElements('embeddings');
|
||||
$rID = self::countSectionMediaElements() + 7;
|
||||
|
||||
$media = array();
|
||||
|
||||
if($type == 'image') {
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
|
||||
|
||||
if($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
|
||||
$folder = 'media';
|
||||
$file = $type.$cImg.'.'.strtolower($ext);
|
||||
} elseif($type == 'oleObject') {
|
||||
$cObj++;
|
||||
$folder = 'embedding';
|
||||
$file = $type.$cObj.'.bin';
|
||||
}
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = "$folder/section_$file";
|
||||
$media['type'] = $type;
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_sectionMedia[$key][$mediaId] = $media;
|
||||
|
||||
if($type == 'oleObject') {
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
return $rID;
|
||||
}
|
||||
} else {
|
||||
if($type == 'oleObject') {
|
||||
$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
return self::$_sectionMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Section Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionLinkElement($linkSrc) {
|
||||
$rID = self::countSectionMediaElements() + 7;
|
||||
|
||||
$link = array();
|
||||
$link['target'] = $linkSrc;
|
||||
$link['rID'] = $rID;
|
||||
$link['type'] = 'hyperlink';
|
||||
|
||||
self::$_sectionMedia['links'][] = $link;
|
||||
|
||||
return $rID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Media Elements
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public static function getSectionMediaElements($key = null) {
|
||||
if(!is_null($key)) {
|
||||
return self::$_sectionMedia[$key];
|
||||
} else {
|
||||
$arrImages = self::$_sectionMedia['images'];
|
||||
$arrObjects = self::$_sectionMedia['embeddings'];
|
||||
$arrLinks = self::$_sectionMedia['links'];
|
||||
return array_merge($arrImages, $arrObjects, $arrLinks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countSectionMediaElements($key = null) {
|
||||
if(!is_null($key)) {
|
||||
return count(self::$_sectionMedia[$key]);
|
||||
} else {
|
||||
$cImages = count(self::$_sectionMedia['images']);
|
||||
$cObjects = count(self::$_sectionMedia['embeddings']);
|
||||
$cLinks = count(self::$_sectionMedia['links']);
|
||||
return ($cImages + $cObjects + $cLinks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Header Media Element
|
||||
*
|
||||
* @param int $headerCount
|
||||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
$mediaId = md5($src);
|
||||
$key = 'header'.$headerCount;
|
||||
|
||||
if(!array_key_exists($key, self::$_headerMedia)) {
|
||||
self::$_headerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
|
||||
$cImg = self::countHeaderMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image'.$cImg.'.'.strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/'.$key.'_'.$file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_headerMedia[$key][$mediaId] = $media;
|
||||
|
||||
return $rID;
|
||||
} else {
|
||||
return self::$_headerMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countHeaderMediaElements($key) {
|
||||
return count(self::$_headerMedia[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Media Elements
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getHeaderMediaElements() {
|
||||
return self::$_headerMedia;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Footer Media Element
|
||||
*
|
||||
* @param int $footerCount
|
||||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
$mediaId = md5($src);
|
||||
$key = 'footer'.$footerCount;
|
||||
|
||||
if(!array_key_exists($key, self::$_footerMedia)) {
|
||||
self::$_footerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if(!array_key_exists($mediaId, self::$_footerMedia[$key])) {
|
||||
$cImg = self::countFooterMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image'.$cImg.'.'.strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/'.$key.'_'.$file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_footerMedia[$key][$mediaId] = $media;
|
||||
|
||||
return $rID;
|
||||
} else {
|
||||
return self::$_footerMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footer Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countFooterMediaElements($key) {
|
||||
return count(self::$_footerMedia[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footer Media Elements
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getFooterMediaElements() {
|
||||
return self::$_footerMedia;
|
||||
}
|
||||
class PHPWord_Media
|
||||
{
|
||||
|
||||
/**
|
||||
* Section Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_sectionMedia = array('images' => array(),
|
||||
'embeddings' => array(),
|
||||
'links' => array());
|
||||
|
||||
/**
|
||||
* Header Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_headerMedia = array();
|
||||
|
||||
/**
|
||||
* Footer Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footerMedia = array();
|
||||
|
||||
/**
|
||||
* ObjectID Counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_objectId = 1325353440;
|
||||
|
||||
|
||||
/**
|
||||
* Add new Section Media Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null)
|
||||
{
|
||||
$mediaId = md5($src);
|
||||
$key = ($type == 'image') ? 'images' : 'embeddings';
|
||||
|
||||
if (!array_key_exists($mediaId, self::$_sectionMedia[$key])) {
|
||||
$cImg = self::countSectionMediaElements('images');
|
||||
$cObj = self::countSectionMediaElements('embeddings');
|
||||
$rID = self::countSectionMediaElements() + 7;
|
||||
|
||||
$media = array();
|
||||
|
||||
if ($type == 'image') {
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
|
||||
|
||||
if ($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
|
||||
$folder = 'media';
|
||||
$file = $type . $cImg . '.' . strtolower($ext);
|
||||
} elseif ($type == 'oleObject') {
|
||||
$cObj++;
|
||||
$folder = 'embedding';
|
||||
$file = $type . $cObj . '.bin';
|
||||
}
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = "$folder/section_$file";
|
||||
$media['type'] = $type;
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_sectionMedia[$key][$mediaId] = $media;
|
||||
|
||||
if ($type == 'oleObject') {
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
return $rID;
|
||||
}
|
||||
} else {
|
||||
if ($type == 'oleObject') {
|
||||
$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
return self::$_sectionMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Section Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionLinkElement($linkSrc)
|
||||
{
|
||||
$rID = self::countSectionMediaElements() + 7;
|
||||
|
||||
$link = array();
|
||||
$link['target'] = $linkSrc;
|
||||
$link['rID'] = $rID;
|
||||
$link['type'] = 'hyperlink';
|
||||
|
||||
self::$_sectionMedia['links'][] = $link;
|
||||
|
||||
return $rID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Media Elements
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public static function getSectionMediaElements($key = null)
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return self::$_sectionMedia[$key];
|
||||
} else {
|
||||
$arrImages = self::$_sectionMedia['images'];
|
||||
$arrObjects = self::$_sectionMedia['embeddings'];
|
||||
$arrLinks = self::$_sectionMedia['links'];
|
||||
return array_merge($arrImages, $arrObjects, $arrLinks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countSectionMediaElements($key = null)
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return count(self::$_sectionMedia[$key]);
|
||||
} else {
|
||||
$cImages = count(self::$_sectionMedia['images']);
|
||||
$cObjects = count(self::$_sectionMedia['embeddings']);
|
||||
$cLinks = count(self::$_sectionMedia['links']);
|
||||
return ($cImages + $cObjects + $cLinks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Header Media Element
|
||||
*
|
||||
* @param int $headerCount
|
||||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null)
|
||||
{
|
||||
$mediaId = md5($src);
|
||||
$key = 'header' . $headerCount;
|
||||
|
||||
if (!array_key_exists($key, self::$_headerMedia)) {
|
||||
self::$_headerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if (!array_key_exists($mediaId, self::$_headerMedia[$key])) {
|
||||
$cImg = self::countHeaderMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if ($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image' . $cImg . '.' . strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/' . $key . '_' . $file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_headerMedia[$key][$mediaId] = $media;
|
||||
|
||||
return $rID;
|
||||
} else {
|
||||
return self::$_headerMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countHeaderMediaElements($key)
|
||||
{
|
||||
return count(self::$_headerMedia[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Media Elements
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getHeaderMediaElements()
|
||||
{
|
||||
return self::$_headerMedia;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Footer Media Element
|
||||
*
|
||||
* @param int $footerCount
|
||||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null)
|
||||
{
|
||||
$mediaId = md5($src);
|
||||
$key = 'footer' . $footerCount;
|
||||
|
||||
if (!array_key_exists($key, self::$_footerMedia)) {
|
||||
self::$_footerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if (!array_key_exists($mediaId, self::$_footerMedia[$key])) {
|
||||
$cImg = self::countFooterMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if ($isMemImage) {
|
||||
$ext = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$ext = $inf['extension'];
|
||||
if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image' . $cImg . '.' . strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/' . $key . '_' . $file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
self::$_footerMedia[$key][$mediaId] = $media;
|
||||
|
||||
return $rID;
|
||||
} else {
|
||||
return self::$_footerMedia[$key][$mediaId]['rID'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footer Media Elements Count
|
||||
*
|
||||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countFooterMediaElements($key)
|
||||
{
|
||||
return count(self::$_footerMedia[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footer Media Elements
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getFooterMediaElements()
|
||||
{
|
||||
return self::$_footerMedia;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,378 +20,393 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
class PHPWord_Section
|
||||
{
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* 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?
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,186 +20,193 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Footer
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Section_Footer {
|
||||
|
||||
/**
|
||||
* Footer Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_footerCount;
|
||||
|
||||
/**
|
||||
* Footer Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Footer Element Collection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Create a new Footer
|
||||
*/
|
||||
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);
|
||||
class PHPWord_Section_Footer
|
||||
{
|
||||
|
||||
/**
|
||||
* Footer Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_footerCount;
|
||||
|
||||
/**
|
||||
* Footer Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Footer Element Collection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Create a new Footer
|
||||
*/
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
$this->_footerCount = $sectionCount;
|
||||
}
|
||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||
$this->_elementCollection[] = $text;
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1)
|
||||
{
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,109 +20,108 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Footer_PreserveText
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section_Footer
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Footer_PreserveText
|
||||
*/
|
||||
class PHPWord_Section_Footer_PreserveText {
|
||||
|
||||
/**
|
||||
* Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Preserve Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null) {
|
||||
// Set font style
|
||||
if(is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
|
||||
$pattern = '/({.*?})/';
|
||||
$this->_text = preg_split($pattern, $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
class PHPWord_Section_Footer_PreserveText
|
||||
{
|
||||
|
||||
/**
|
||||
* Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Preserve Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
// Set font style
|
||||
if (is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
|
||||
// Set paragraph style
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
|
||||
$pattern = '/({.*?})/';
|
||||
$this->_text = preg_split($pattern, $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->_text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,265 +20,277 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Header
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Section_Header {
|
||||
|
||||
/**
|
||||
* Header Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_headerCount;
|
||||
|
||||
/**
|
||||
* Header Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
class PHPWord_Section_Header
|
||||
{
|
||||
|
||||
/**
|
||||
* Header type
|
||||
*
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
private $_type = PHPWord_Section_Header::AUTO;
|
||||
/**
|
||||
* Header Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_headerCount;
|
||||
|
||||
/**
|
||||
* Even Numbered Pages Only
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
const EVEN = 'even';
|
||||
/**
|
||||
* Header Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Default Header or Footer
|
||||
* @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
|
||||
/**
|
||||
* Header type
|
||||
*
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
private $_type = PHPWord_Section_Header::AUTO;
|
||||
|
||||
/**
|
||||
* First Page Only
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
const FIRST = 'first';
|
||||
|
||||
/**
|
||||
* Header Element Collection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Create a new Header
|
||||
*/
|
||||
public function __construct($sectionCount) {
|
||||
$this->_headerCount = $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);
|
||||
/**
|
||||
* Even Numbered Pages Only
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
const EVEN = 'even';
|
||||
|
||||
/**
|
||||
* Default Header or Footer
|
||||
* @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
|
||||
|
||||
/**
|
||||
* First Page Only
|
||||
* @var string
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_type-4.html Header or Footer Type
|
||||
*/
|
||||
const FIRST = 'first';
|
||||
|
||||
/**
|
||||
* Header Element Collection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Create a new Header
|
||||
*/
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
$this->_headerCount = $sectionCount;
|
||||
}
|
||||
$text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||
$this->_elementCollection[] = $text;
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
$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;
|
||||
}
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1)
|
||||
{
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset back to default
|
||||
*/
|
||||
public function resetType() {
|
||||
return $this->_type = PHPWord_Section_Header::AUTO;
|
||||
}
|
||||
/**
|
||||
* Create a new TextRun
|
||||
*
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null)
|
||||
{
|
||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||
$this->_elementCollection[] = $textRun;
|
||||
return $textRun;
|
||||
}
|
||||
|
||||
/**
|
||||
* First page only header
|
||||
*/
|
||||
public function firstPage() {
|
||||
return $this->_type = PHPWord_Section_Header::FIRST;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Even numbered Pages only
|
||||
*/
|
||||
public function evenPage() {
|
||||
return $this->_type = PHPWord_Section_Header::EVEN;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,149 +20,156 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Image
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Image
|
||||
*/
|
||||
class PHPWord_Section_Image {
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Is Watermark
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_isWatermark;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Image
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null, $isWatermark = false) {
|
||||
$_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff');
|
||||
|
||||
$inf = pathinfo($src);
|
||||
$ext = strtolower($inf['extension']);
|
||||
|
||||
if(file_exists($src) && in_array($ext, $_supportedImageTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_isWatermark = $isWatermark;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if(!is_null($style) && is_array($style)) {
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
|
||||
$imgData = getimagesize($this->_src);
|
||||
$this->_style->setWidth($imgData[0]);
|
||||
$this->_style->setHeight($imgData[1]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Media ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId() {
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IsWatermark
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIsWatermark() {
|
||||
return $this->_isWatermark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set IsWatermark
|
||||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setIsWatermark($pValue) {
|
||||
$this->_isWatermark = $pValue;
|
||||
}
|
||||
}
|
||||
?>
|
||||
class PHPWord_Section_Image
|
||||
{
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Is Watermark
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_isWatermark;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Image
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null, $isWatermark = false)
|
||||
{
|
||||
$_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff');
|
||||
|
||||
$inf = pathinfo($src);
|
||||
$ext = strtolower($inf['extension']);
|
||||
|
||||
if (file_exists($src) && in_array($ext, $_supportedImageTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_isWatermark = $isWatermark;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if (!is_null($style) && is_array($style)) {
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($style['wrappingStyle'])) {
|
||||
$this->_style->setWrappingStyle($style['wrappingStyle']);
|
||||
}
|
||||
|
||||
if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
|
||||
$imgData = getimagesize($this->_src);
|
||||
$this->_style->setWidth($imgData[0]);
|
||||
$this->_style->setHeight($imgData[1]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Media ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId()
|
||||
{
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IsWatermark
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIsWatermark()
|
||||
{
|
||||
return $this->_isWatermark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set IsWatermark
|
||||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setIsWatermark($pValue)
|
||||
{
|
||||
$this->_isWatermark = $pValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,152 +20,154 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Link
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Link
|
||||
*/
|
||||
class PHPWord_Section_Link {
|
||||
|
||||
/**
|
||||
* Link source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_linkSrc;
|
||||
|
||||
/**
|
||||
* Link name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_linkName;
|
||||
|
||||
/**
|
||||
* Link Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Link style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Link Element
|
||||
*
|
||||
* @var string $linkSrc
|
||||
* @var string $linkName
|
||||
* @var mixed $styleFont
|
||||
* @var mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
|
||||
$this->_linkSrc = $linkSrc;
|
||||
$this->_linkName = $linkName;
|
||||
|
||||
// Set font style
|
||||
if(is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Link Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkSrc() {
|
||||
return $this->_linkSrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkName() {
|
||||
return $this->_linkName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
class PHPWord_Section_Link
|
||||
{
|
||||
|
||||
/**
|
||||
* Link source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_linkSrc;
|
||||
|
||||
/**
|
||||
* Link name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_linkName;
|
||||
|
||||
/**
|
||||
* Link Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Link style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Link Element
|
||||
*
|
||||
* @var string $linkSrc
|
||||
* @var string $linkName
|
||||
* @var mixed $styleFont
|
||||
* @var mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
$this->_linkSrc = $linkSrc;
|
||||
$this->_linkName = $linkName;
|
||||
|
||||
// Set font style
|
||||
if (is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
|
||||
// Set paragraph style
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Link Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkSrc()
|
||||
{
|
||||
return $this->_linkSrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkName()
|
||||
{
|
||||
return $this->_linkName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,85 +20,84 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_ListItem
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_ListItem
|
||||
*/
|
||||
class PHPWord_Section_ListItem {
|
||||
|
||||
/**
|
||||
* ListItem Style
|
||||
*
|
||||
* @var PHPWord_Style_ListItem
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Textrun
|
||||
*
|
||||
* @var PHPWord_Section_Text
|
||||
*/
|
||||
private $_textObject;
|
||||
|
||||
/**
|
||||
* ListItem Depth
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_depth;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ListItem
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @param mixed $styleText
|
||||
* @param mixed $styleList
|
||||
*/
|
||||
public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) {
|
||||
$this->_style = new PHPWord_Style_ListItem();
|
||||
$this->_textObject = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||
$this->_depth = $depth;
|
||||
|
||||
if(!is_null($styleList) && is_array($styleList)) {
|
||||
foreach($styleList as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem style
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem TextRun
|
||||
*/
|
||||
public function getTextObject() {
|
||||
return $this->_textObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem depth
|
||||
*/
|
||||
public function getDepth() {
|
||||
return $this->_depth;
|
||||
}
|
||||
class PHPWord_Section_ListItem
|
||||
{
|
||||
|
||||
/**
|
||||
* ListItem Style
|
||||
*
|
||||
* @var PHPWord_Style_ListItem
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Textrun
|
||||
*
|
||||
* @var PHPWord_Section_Text
|
||||
*/
|
||||
private $_textObject;
|
||||
|
||||
/**
|
||||
* ListItem Depth
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_depth;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ListItem
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @param mixed $styleText
|
||||
* @param mixed $styleList
|
||||
*/
|
||||
public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null)
|
||||
{
|
||||
$this->_style = new PHPWord_Style_ListItem();
|
||||
$this->_textObject = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
|
||||
$this->_depth = $depth;
|
||||
|
||||
if (!is_null($styleList) && is_array($styleList)) {
|
||||
foreach ($styleList as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem style
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem TextRun
|
||||
*/
|
||||
public function getTextObject()
|
||||
{
|
||||
return $this->_textObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem depth
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
return $this->_depth;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,212 +20,219 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_MemoryImage
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_MemoryImage
|
||||
*/
|
||||
class PHPWord_Section_MemoryImage {
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Image Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageType;
|
||||
|
||||
/**
|
||||
* Image Create function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageCreateFunc;
|
||||
|
||||
/**
|
||||
* Image function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageFunc;
|
||||
|
||||
/**
|
||||
* Image function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageExtension;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Image
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null) {
|
||||
$imgData = getimagesize($src);
|
||||
$this->_imageType = $imgData['mime'];
|
||||
|
||||
$_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png');
|
||||
|
||||
if(in_array($this->_imageType, $_supportedImageTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if(!is_null($style) && is_array($style)) {
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
|
||||
$this->_style->setWidth($imgData[0]);
|
||||
$this->_style->setHeight($imgData[1]);
|
||||
}
|
||||
|
||||
$this->_setFunctions();
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Functions
|
||||
*/
|
||||
private function _setFunctions() {
|
||||
switch($this->_imageType) {
|
||||
case 'image/png':
|
||||
$this->_imageCreateFunc = 'imagecreatefrompng';
|
||||
$this->_imageFunc = 'imagepng';
|
||||
$this->_imageExtension = 'png';
|
||||
break;
|
||||
case 'image/gif':
|
||||
$this->_imageCreateFunc = 'imagecreatefromgif';
|
||||
$this->_imageFunc = 'imagegif';
|
||||
$this->_imageExtension = 'gif';
|
||||
break;
|
||||
case 'image/jpeg': case 'image/jpg':
|
||||
$this->_imageCreateFunc = 'imagecreatefromjpeg';
|
||||
$this->_imageFunc = 'imagejpeg';
|
||||
$this->_imageExtension = 'jpg';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Media ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId() {
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType() {
|
||||
return $this->_imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Create Function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageCreateFunction() {
|
||||
return $this->_imageCreateFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageFunction() {
|
||||
return $this->_imageFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageExtension() {
|
||||
return $this->_imageExtension;
|
||||
}
|
||||
class PHPWord_Section_MemoryImage
|
||||
{
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Image Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageType;
|
||||
|
||||
/**
|
||||
* Image Create function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageCreateFunc;
|
||||
|
||||
/**
|
||||
* Image function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageFunc;
|
||||
|
||||
/**
|
||||
* Image function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_imageExtension;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Image
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null)
|
||||
{
|
||||
$imgData = getimagesize($src);
|
||||
$this->_imageType = $imgData['mime'];
|
||||
|
||||
$_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png');
|
||||
|
||||
if (in_array($this->_imageType, $_supportedImageTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if (!is_null($style) && is_array($style)) {
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
|
||||
$this->_style->setWidth($imgData[0]);
|
||||
$this->_style->setHeight($imgData[1]);
|
||||
}
|
||||
|
||||
$this->_setFunctions();
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Functions
|
||||
*/
|
||||
private function _setFunctions()
|
||||
{
|
||||
switch ($this->_imageType) {
|
||||
case 'image/png':
|
||||
$this->_imageCreateFunc = 'imagecreatefrompng';
|
||||
$this->_imageFunc = 'imagepng';
|
||||
$this->_imageExtension = 'png';
|
||||
break;
|
||||
case 'image/gif':
|
||||
$this->_imageCreateFunc = 'imagecreatefromgif';
|
||||
$this->_imageFunc = 'imagegif';
|
||||
$this->_imageExtension = 'gif';
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
case 'image/jpg':
|
||||
$this->_imageCreateFunc = 'imagecreatefromjpeg';
|
||||
$this->_imageFunc = 'imagejpeg';
|
||||
$this->_imageExtension = 'jpg';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Media ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId()
|
||||
{
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->_imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Create Function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageCreateFunction()
|
||||
{
|
||||
return $this->_imageCreateFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageFunction()
|
||||
{
|
||||
return $this->_imageFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageExtension()
|
||||
{
|
||||
return $this->_imageExtension;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,156 +20,160 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Object
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Object
|
||||
*/
|
||||
class PHPWord_Section_Object {
|
||||
|
||||
/**
|
||||
* Ole-Object Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Object Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rIdImg;
|
||||
|
||||
/**
|
||||
* Object ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_objId;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Ole-Object Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($src, $style = null) {
|
||||
$_supportedObjectTypes = array('xls', 'doc', 'ppt');
|
||||
$inf = pathinfo($src);
|
||||
|
||||
if(file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if(!is_null($style) && is_array($style)) {
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Object Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageRelationId() {
|
||||
return $this->_rIdImg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setImageRelationId($rId) {
|
||||
$this->_rIdImg = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Object ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectId() {
|
||||
return $this->_objId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ID
|
||||
*
|
||||
* @param int $objId
|
||||
*/
|
||||
public function setObjectId($objId) {
|
||||
$this->_objId = $objId;
|
||||
}
|
||||
class PHPWord_Section_Object
|
||||
{
|
||||
|
||||
/**
|
||||
* Ole-Object Src
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_src;
|
||||
|
||||
/**
|
||||
* Image Style
|
||||
*
|
||||
* @var PHPWord_Style_Image
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Object Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rId;
|
||||
|
||||
/**
|
||||
* Image Relation ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_rIdImg;
|
||||
|
||||
/**
|
||||
* Object ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_objId;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Ole-Object Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($src, $style = null)
|
||||
{
|
||||
$_supportedObjectTypes = array('xls', 'doc', 'ppt');
|
||||
$inf = pathinfo($src);
|
||||
|
||||
if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if (!is_null($style) && is_array($style)) {
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image style
|
||||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Object Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image Relation ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageRelationId()
|
||||
{
|
||||
return $this->_rIdImg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image Relation ID
|
||||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setImageRelationId($rId)
|
||||
{
|
||||
$this->_rIdImg = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Object ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectId()
|
||||
{
|
||||
return $this->_objId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ID
|
||||
*
|
||||
* @param int $objId
|
||||
*/
|
||||
public function setObjectId($objId)
|
||||
{
|
||||
$this->_objId = $objId;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,26 +20,22 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_PageBreak
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_PageBreak
|
||||
*/
|
||||
class PHPWord_Section_PageBreak {
|
||||
class PHPWord_Section_PageBreak
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new PageBreak Element
|
||||
*/
|
||||
public function __construct() {
|
||||
// nothing
|
||||
}
|
||||
/**
|
||||
* Create a new PageBreak Element
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,133 +20,134 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Table
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Table
|
||||
*/
|
||||
class PHPWord_Section_Table {
|
||||
|
||||
/**
|
||||
* Table style
|
||||
*
|
||||
* @var PHPWord_Style_Table
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Table rows
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_rows = array();
|
||||
|
||||
/**
|
||||
* Row heights
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_rowHeights = array();
|
||||
|
||||
/**
|
||||
* Table holder
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_insideOf = null;
|
||||
|
||||
/**
|
||||
* Table holder count
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_pCount;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new table
|
||||
*
|
||||
* @param string $insideOf
|
||||
* @param int $pCount
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $style = null) {
|
||||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
|
||||
if(!is_null($style)) {
|
||||
if(is_array($style)) {
|
||||
$this->_style = new PHPWord_Style_Table();
|
||||
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_style = $style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a row
|
||||
*
|
||||
* @param int $height
|
||||
*/
|
||||
public function addRow($height = null) {
|
||||
$this->_rows[] = array();
|
||||
$this->_rowHeights[] = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cell
|
||||
*
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table_Cell
|
||||
*/
|
||||
public function addCell($width, $style = null) {
|
||||
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
|
||||
$i = count($this->_rows) - 1;
|
||||
$this->_rows[$i][] = $cell;
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all rows
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows() {
|
||||
return $this->_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all row heights
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRowHeights() {
|
||||
return $this->_rowHeights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table style
|
||||
*
|
||||
* @return PHPWord_Style_Table
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
class PHPWord_Section_Table
|
||||
{
|
||||
|
||||
/**
|
||||
* Table style
|
||||
*
|
||||
* @var PHPWord_Style_Table
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Table rows
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_rows = array();
|
||||
|
||||
/**
|
||||
* Row heights
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_rowHeights = array();
|
||||
|
||||
/**
|
||||
* Table holder
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_insideOf = null;
|
||||
|
||||
/**
|
||||
* Table holder count
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_pCount;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new table
|
||||
*
|
||||
* @param string $insideOf
|
||||
* @param int $pCount
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $style = null)
|
||||
{
|
||||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
|
||||
if (!is_null($style)) {
|
||||
if (is_array($style)) {
|
||||
$this->_style = new PHPWord_Style_Table();
|
||||
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_style = $style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a row
|
||||
*
|
||||
* @param int $height
|
||||
*/
|
||||
public function addRow($height = null)
|
||||
{
|
||||
$this->_rows[] = array();
|
||||
$this->_rowHeights[] = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cell
|
||||
*
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table_Cell
|
||||
*/
|
||||
public function addCell($width, $style = null)
|
||||
{
|
||||
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
|
||||
$i = count($this->_rows) - 1;
|
||||
$this->_rows[$i][] = $cell;
|
||||
return $cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all rows
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all row heights
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRowHeights()
|
||||
{
|
||||
return $this->_rowHeights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table style
|
||||
*
|
||||
* @return PHPWord_Style_Table
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,310 +20,318 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Table_Cell
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section_Table
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Section_Table_Cell {
|
||||
|
||||
/**
|
||||
* Cell Width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_width = null;
|
||||
|
||||
/**
|
||||
* Cell Style
|
||||
*
|
||||
* @var PHPWord_Style_Cell
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Cell Element Collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Table holder
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_insideOf;
|
||||
|
||||
/**
|
||||
* Section/Header/Footer count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_pCount;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table Cell
|
||||
*
|
||||
* @param string $insideOf
|
||||
* @param int $pCount
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $width = null, $style = null) {
|
||||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
$this->_width = $width;
|
||||
|
||||
if(!is_null($style)) {
|
||||
if(is_array($style)) {
|
||||
$this->_style = new PHPWord_Style_Cell();
|
||||
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
} 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);
|
||||
class PHPWord_Section_Table_Cell
|
||||
{
|
||||
|
||||
/**
|
||||
* Cell Width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_width = null;
|
||||
|
||||
/**
|
||||
* Cell Style
|
||||
*
|
||||
* @var PHPWord_Style_Cell
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
/**
|
||||
* Cell Element Collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection = array();
|
||||
|
||||
/**
|
||||
* Table holder
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_insideOf;
|
||||
|
||||
/**
|
||||
* Section/Header/Footer count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_pCount;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table Cell
|
||||
*
|
||||
* @param string $insideOf
|
||||
* @param int $pCount
|
||||
* @param int $width
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $width = null, $style = null)
|
||||
{
|
||||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
$this->_width = $width;
|
||||
|
||||
if (!is_null($style)) {
|
||||
if (is_array($style)) {
|
||||
$this->_style = new PHPWord_Style_Cell();
|
||||
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_style = $style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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 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())) {
|
||||
if($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||
} elseif($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src);
|
||||
} elseif($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src);
|
||||
}
|
||||
$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())) {
|
||||
if($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||
} elseif($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
|
||||
} elseif($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
|
||||
}
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $memoryImage;
|
||||
return $memoryImage;
|
||||
} else {
|
||||
trigger_error('Unsupported image type.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* 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 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())) {
|
||||
if ($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||
} elseif ($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src);
|
||||
} elseif ($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src);
|
||||
}
|
||||
$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())) {
|
||||
if ($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||
} elseif ($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
|
||||
} elseif ($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
|
||||
}
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $memoryImage;
|
||||
return $memoryImage;
|
||||
} else {
|
||||
trigger_error('Unsupported image type.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,126 +20,127 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Text
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Text
|
||||
*/
|
||||
class PHPWord_Section_Text {
|
||||
|
||||
/**
|
||||
* Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null) {
|
||||
// Set font style
|
||||
$this->setFontStyle($styleFont);
|
||||
|
||||
// Set paragraph style
|
||||
$this->setParagraphStyle($styleParagraph);
|
||||
|
||||
$this->_text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function setFontStyle($styleFont) {
|
||||
if(is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($styleParagraph) {
|
||||
if(is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
class PHPWord_Section_Text
|
||||
{
|
||||
|
||||
/**
|
||||
* Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Text style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleFont;
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
// Set font style
|
||||
$this->setFontStyle($styleFont);
|
||||
|
||||
// Set paragraph style
|
||||
$this->setParagraphStyle($styleParagraph);
|
||||
|
||||
$this->_text = $text;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function setFontStyle($styleFont)
|
||||
{
|
||||
if (is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleFont = $styleFont;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($styleParagraph)
|
||||
{
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->_text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,26 +20,22 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_TextBreak
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_TextBreak
|
||||
*/
|
||||
class PHPWord_Section_TextBreak {
|
||||
|
||||
/**
|
||||
* Create a new TextBreak Element
|
||||
*/
|
||||
public function __construct() {
|
||||
// nothing
|
||||
}
|
||||
class PHPWord_Section_TextBreak
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new TextBreak Element
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,112 +20,112 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_TextRun
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Section_TextRun {
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
/**
|
||||
* Text collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TextRun Element
|
||||
*/
|
||||
public function __construct($styleParagraph = null) {
|
||||
$this->_elementCollection = array();
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} 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);
|
||||
class PHPWord_Section_TextRun
|
||||
{
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
/**
|
||||
* Text collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TextRun Element
|
||||
*/
|
||||
public function __construct($styleParagraph = null)
|
||||
{
|
||||
$this->_elementCollection = array();
|
||||
|
||||
// Set paragraph style
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
}
|
||||
$text = new PHPWord_Section_Text($text, $styleFont);
|
||||
$this->_elementCollection[] = $text;
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null) {
|
||||
$linkSrc = utf8_encode($linkSrc);
|
||||
if(!is_null($linkName)) {
|
||||
$linkName = utf8_encode($linkName);
|
||||
}
|
||||
|
||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
||||
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
||||
$link->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $link;
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TextRun content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getElements() {
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_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 Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null)
|
||||
{
|
||||
$linkSrc = utf8_encode($linkSrc);
|
||||
if (!is_null($linkName)) {
|
||||
$linkName = utf8_encode($linkName);
|
||||
}
|
||||
|
||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
||||
$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
|
||||
$link->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $link;
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,126 +20,128 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Section_Title
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Title
|
||||
*/
|
||||
class PHPWord_Section_Title {
|
||||
|
||||
/**
|
||||
* Title Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Title depth
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_depth;
|
||||
|
||||
/**
|
||||
* Title anchor
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_anchor;
|
||||
|
||||
/**
|
||||
* Title Bookmark ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_bookmarkId;
|
||||
|
||||
/**
|
||||
* Title style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Title Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var int $depth
|
||||
*/
|
||||
public function __construct($text, $depth = 1, $style = null) {
|
||||
if(!is_null($style)) {
|
||||
$this->_style = $style;
|
||||
}
|
||||
|
||||
$this->_text = $text;
|
||||
$this->_depth = $depth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Anchor
|
||||
*
|
||||
* @var int $anchor
|
||||
*/
|
||||
public function setAnchor($anchor) {
|
||||
$this->_anchor = $anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Anchor
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAnchor() {
|
||||
return $this->_anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bookmark ID
|
||||
*
|
||||
* @var int $bookmarkId
|
||||
*/
|
||||
public function setBookmarkId($bookmarkId) {
|
||||
$this->_bookmarkId = $bookmarkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Anchor
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBookmarkId() {
|
||||
return $this->_bookmarkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
class PHPWord_Section_Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Title depth
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_depth;
|
||||
|
||||
/**
|
||||
* Title anchor
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_anchor;
|
||||
|
||||
/**
|
||||
* Title Bookmark ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_bookmarkId;
|
||||
|
||||
/**
|
||||
* Title style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Title Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var int $depth
|
||||
*/
|
||||
public function __construct($text, $depth = 1, $style = null)
|
||||
{
|
||||
if (!is_null($style)) {
|
||||
$this->_style = $style;
|
||||
}
|
||||
|
||||
$this->_text = $text;
|
||||
$this->_depth = $depth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Anchor
|
||||
*
|
||||
* @var int $anchor
|
||||
*/
|
||||
public function setAnchor($anchor)
|
||||
{
|
||||
$this->_anchor = $anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Anchor
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAnchor()
|
||||
{
|
||||
return $this->_anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bookmark ID
|
||||
*
|
||||
* @var int $bookmarkId
|
||||
*/
|
||||
public function setBookmarkId($bookmarkId)
|
||||
{
|
||||
$this->_bookmarkId = $bookmarkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Anchor
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBookmarkId()
|
||||
{
|
||||
return $this->_bookmarkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title Text content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,135 +20,144 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_Drawing
|
||||
*/
|
||||
class PHPWord_Shared_Drawing
|
||||
{
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 1.333333333;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0)
|
||||
{
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to centimeters
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in centimeters
|
||||
*/
|
||||
public static function pixelsToCentimeters($pValue = 0) {
|
||||
return $pValue * 0.028;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to pixels
|
||||
*
|
||||
* @param int $pValue Value in centimeters
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function centimetersToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 0.028;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert HTML hexadecimal to RGB
|
||||
*
|
||||
* @param str $pValue HTML Color in hexadecimal
|
||||
* @return array Value in RGB
|
||||
*/
|
||||
public static function htmlToRGB($pValue) {
|
||||
if ($pValue[0] == '#'){
|
||||
$pValue = substr($pValue, 1);
|
||||
}
|
||||
|
||||
if (strlen($pValue) == 6){
|
||||
list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[1],$pValue[2].$pValue[3],$pValue[4].$pValue[5]);
|
||||
}
|
||||
elseif (strlen($pValue) == 3){
|
||||
list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[0],$pValue[1].$pValue[1],$pValue[2].$pValue[2]);
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
|
||||
$color_R = hexdec($color_R);
|
||||
$color_G = hexdec($color_G);
|
||||
$color_B = hexdec($color_B);
|
||||
|
||||
return array($color_R, $color_G, $color_B);
|
||||
}
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0)
|
||||
{
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 1.333333333;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0)
|
||||
{
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to centimeters
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in centimeters
|
||||
*/
|
||||
public static function pixelsToCentimeters($pValue = 0)
|
||||
{
|
||||
return $pValue * 0.028;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeters width to pixels
|
||||
*
|
||||
* @param int $pValue Value in centimeters
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function centimetersToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 0.028;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert HTML hexadecimal to RGB
|
||||
*
|
||||
* @param str $pValue HTML Color in hexadecimal
|
||||
* @return array Value in RGB
|
||||
*/
|
||||
public static function htmlToRGB($pValue)
|
||||
{
|
||||
if ($pValue[0] == '#') {
|
||||
$pValue = substr($pValue, 1);
|
||||
}
|
||||
|
||||
if (strlen($pValue) == 6) {
|
||||
list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]);
|
||||
} elseif (strlen($pValue) == 3) {
|
||||
list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$color_R = hexdec($color_R);
|
||||
$color_G = hexdec($color_G);
|
||||
$color_B = hexdec($color_B);
|
||||
|
||||
return array($color_R, $color_G, $color_B);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,72 +20,76 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_File
|
||||
*/
|
||||
class PHPWord_Shared_File
|
||||
{
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename) {
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename)
|
||||
{
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
}
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename) {
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename)
|
||||
{
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,53 +20,61 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_Font
|
||||
*/
|
||||
class PHPWord_Shared_Font
|
||||
{
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1) {
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1) {
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1) {
|
||||
return ($sizeInCm * 565.217);
|
||||
}
|
||||
|
||||
public static function inchSizeToTwips($sizeInInch = 1) {
|
||||
return self::centimeterSizeToTwips($sizeInInch * 2.54);
|
||||
}
|
||||
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1) {
|
||||
return self::centimeterSizeToTwips($sizeInPixel / 37.795275591);
|
||||
}
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12)
|
||||
{
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
{
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 565.217);
|
||||
}
|
||||
|
||||
public static function inchSizeToTwips($sizeInInch = 1)
|
||||
{
|
||||
return self::centimeterSizeToTwips($sizeInInch * 2.54);
|
||||
}
|
||||
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1)
|
||||
{
|
||||
return self::centimeterSizeToTwips($sizeInPixel / 37.795275591);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,244 +20,251 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_String
|
||||
*/
|
||||
class PHPWord_Shared_String
|
||||
{
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isMbstringEnabled;
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isMbstringEnabled;
|
||||
|
||||
/**
|
||||
* Is iconv extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isIconvEnabled;
|
||||
/**
|
||||
* Is iconv extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isIconvEnabled;
|
||||
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$_controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters()
|
||||
{
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$_controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether mbstring extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsMbstringEnabled()
|
||||
{
|
||||
if (isset(self::$_isMbstringEnabled)) {
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
/**
|
||||
* Get whether mbstring extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsMbstringEnabled()
|
||||
{
|
||||
if (isset(self::$_isMbstringEnabled)) {
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
||||
true : false;
|
||||
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether iconv extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsIconvEnabled()
|
||||
{
|
||||
if (isset(self::$_isIconvEnabled)) {
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
/**
|
||||
* Get whether iconv extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsIconvEnabled()
|
||||
{
|
||||
if (isset(self::$_isIconvEnabled)) {
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
self::$_isIconvEnabled = function_exists('iconv') ?
|
||||
true : false;
|
||||
self::$_isIconvEnabled = function_exists('iconv') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* 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:
|
||||
* _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>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
/**
|
||||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* 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:
|
||||
* _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>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterOOXML2PHP($value = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* 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:
|
||||
* _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>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
/**
|
||||
* Convert from PHP control character to OpenXML escaped control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* 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:
|
||||
* _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>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterPHP2OOXML($value = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsUTF8($value = '') {
|
||||
return $value === '' || preg_match('/^./su', $value) === 1;
|
||||
}
|
||||
/**
|
||||
* Check if a string contains UTF-8 data
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsUTF8($value = '')
|
||||
{
|
||||
return $value === '' || preg_match('/^./su', $value) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a numeric value as a string for output in various output writers
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function FormatNumber($value) {
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
/**
|
||||
* Formats a numeric value as a string for output in various output writers
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function FormatNumber($value)
|
||||
{
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* 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
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeShort($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
/**
|
||||
* 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
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* 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
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeShort($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('CC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
$data = pack('CC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* 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
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeLong($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
/**
|
||||
* 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
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* 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
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeLong($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('vC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
$data = pack('vC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
||||
* @return string
|
||||
*/
|
||||
public static function ConvertEncoding($value, $to, $from)
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$value = mb_convert_encoding($value, $to, $from);
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
||||
* @return string
|
||||
*/
|
||||
public static function ConvertEncoding($value, $to, $from)
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$value = mb_convert_encoding($value, $to, $from);
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$value = iconv($from, $to, $value);
|
||||
return $value;
|
||||
}
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$value = iconv($from, $to, $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
// else, no conversion
|
||||
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;
|
||||
}
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$count = iconv_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
// else strlen
|
||||
$count = strlen($value);
|
||||
return $count;
|
||||
}
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$count = iconv_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
|
||||
// else strlen
|
||||
$count = strlen($value);
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,124 +20,134 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
if(!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
if (!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
}
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_XMLWriter
|
||||
*
|
||||
* @method bool startElement(string $name)
|
||||
* @method bool writeAttribute(string $name, string $value)
|
||||
* @method bool endElement()
|
||||
*/
|
||||
class PHPWord_Shared_XMLWriter
|
||||
{
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
|
||||
class PHPWord_Shared_XMLWriter {
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
/**
|
||||
* Internal XMLWriter
|
||||
*
|
||||
* @var XMLWriter
|
||||
*/
|
||||
private $_xmlWriter;
|
||||
|
||||
/**
|
||||
* Internal XMLWriter
|
||||
*
|
||||
* @var XMLWriter
|
||||
*/
|
||||
private $_xmlWriter;
|
||||
/**
|
||||
* Temporary filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tempFileName = '';
|
||||
|
||||
/**
|
||||
* Temporary filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tempFileName = '';
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shared_XMLWriter instance
|
||||
*
|
||||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './')
|
||||
{
|
||||
// Create internal XMLWriter
|
||||
$this->_xmlWriter = new XMLWriter();
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shared_XMLWriter instance
|
||||
*
|
||||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
|
||||
// Create internal XMLWriter
|
||||
$this->_xmlWriter = new XMLWriter();
|
||||
// Open temporary storage
|
||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->_xmlWriter->openMemory();
|
||||
} else {
|
||||
// Create temporary filename
|
||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||
|
||||
// Open temporary storage
|
||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->_xmlWriter->openMemory();
|
||||
} else {
|
||||
// Create temporary filename
|
||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||
// Open storage
|
||||
if ($this->_xmlWriter->openUri($this->_tempFileName) === false) {
|
||||
// Fallback to memory...
|
||||
$this->_xmlWriter->openMemory();
|
||||
}
|
||||
}
|
||||
|
||||
// Open storage
|
||||
if ($this->_xmlWriter->openUri($this->_tempFileName) === false) {
|
||||
// Fallback to memory...
|
||||
$this->_xmlWriter->openMemory();
|
||||
}
|
||||
}
|
||||
// Set default values
|
||||
// proposed to be false in production version
|
||||
$this->_xmlWriter->setIndent(true);
|
||||
//$this->_xmlWriter->setIndent(false);
|
||||
|
||||
// Set default values
|
||||
// proposed to be false in production version
|
||||
$this->_xmlWriter->setIndent(true);
|
||||
//$this->_xmlWriter->setIndent(false);
|
||||
|
||||
// Set indent
|
||||
// proposed to be '' in production version
|
||||
$this->_xmlWriter->setIndentString(' ');
|
||||
//$this->_xmlWriter->setIndentString('');
|
||||
}
|
||||
// Set indent
|
||||
// proposed to be '' in production version
|
||||
$this->_xmlWriter->setIndentString(' ');
|
||||
//$this->_xmlWriter->setIndentString('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
// Desctruct XMLWriter
|
||||
unset($this->_xmlWriter);
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// Desctruct XMLWriter
|
||||
unset($this->_xmlWriter);
|
||||
|
||||
// Unlink temporary files
|
||||
if ($this->_tempFileName != '') {
|
||||
@unlink($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
// Unlink temporary files
|
||||
if ($this->_tempFileName != '') {
|
||||
@unlink($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return $data
|
||||
*/
|
||||
public function getData() {
|
||||
if ($this->_tempFileName == '') {
|
||||
return $this->_xmlWriter->outputMemory(true);
|
||||
} else {
|
||||
$this->_xmlWriter->flush();
|
||||
return file_get_contents($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return $data
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
if ($this->_tempFileName == '') {
|
||||
return $this->_xmlWriter->outputMemory(true);
|
||||
} else {
|
||||
$this->_xmlWriter->flush();
|
||||
return file_get_contents($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch function calls (and pass them to internal XMLWriter)
|
||||
*
|
||||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
public function __call($function, $args) {
|
||||
try {
|
||||
@call_user_func_array(array($this->_xmlWriter, $function), $args);
|
||||
} catch (Exception $ex) {
|
||||
// Do nothing!
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Catch function calls (and pass them to internal XMLWriter)
|
||||
*
|
||||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
try {
|
||||
@call_user_func_array(array($this->_xmlWriter, $function), $args);
|
||||
} catch (Exception $ex) {
|
||||
// Do nothing!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback method for writeRaw, introduced in PHP 5.2
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function writeRaw($text)
|
||||
{
|
||||
if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) {
|
||||
return $this->_xmlWriter->writeRaw($text);
|
||||
}
|
||||
/**
|
||||
* Fallback method for writeRaw, introduced in PHP 5.2
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function writeRaw($text)
|
||||
{
|
||||
if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) {
|
||||
return $this->_xmlWriter->writeRaw($text);
|
||||
}
|
||||
|
||||
return $this->text($text);
|
||||
}
|
||||
}
|
||||
return $this->text($text);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,157 +20,165 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/** Register new zip wrapper */
|
||||
PHPWord_Shared_ZipStreamWrapper::register();
|
||||
|
||||
/**
|
||||
* Class PHPWord_Shared_ZipStreamWrapper
|
||||
*/
|
||||
class PHPWord_Shared_ZipStreamWrapper
|
||||
{
|
||||
/**
|
||||
* Internal ZipAcrhive
|
||||
*
|
||||
* @var ZipAcrhive
|
||||
*/
|
||||
private $_archive;
|
||||
|
||||
class PHPWord_Shared_ZipStreamWrapper {
|
||||
/**
|
||||
* Internal ZipAcrhive
|
||||
*
|
||||
* @var ZipAcrhive
|
||||
*/
|
||||
private $_archive;
|
||||
/**
|
||||
* Filename in ZipAcrhive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileNameInArchive = '';
|
||||
|
||||
/**
|
||||
* Filename in ZipAcrhive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileNameInArchive = '';
|
||||
/**
|
||||
* Position in file
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Position in file
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_data = '';
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_data = '';
|
||||
/**
|
||||
* Register wrapper
|
||||
*/
|
||||
public static function register()
|
||||
{
|
||||
@stream_wrapper_unregister("zip");
|
||||
@stream_wrapper_register("zip", __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register wrapper
|
||||
*/
|
||||
public static function register() {
|
||||
@stream_wrapper_unregister("zip");
|
||||
@stream_wrapper_register("zip", __CLASS__);
|
||||
}
|
||||
/**
|
||||
* Open stream
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
// Check for mode
|
||||
if ($mode{0} != 'r') {
|
||||
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Open stream
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
// Check for mode
|
||||
if ($mode{0} != 'r') {
|
||||
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
|
||||
}
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
$url['host'] = substr($path, strlen('zip://'));
|
||||
$url['path'] = '';
|
||||
}
|
||||
if (strpos($url['host'], '#') !== false) {
|
||||
if (!isset($url['fragment'])) {
|
||||
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
|
||||
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
|
||||
unset($url['path']);
|
||||
}
|
||||
} else {
|
||||
$url['host'] = $url['host'] . $url['path'];
|
||||
unset($url['path']);
|
||||
}
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
$url['host'] = substr($path, strlen('zip://'));
|
||||
$url['path'] = '';
|
||||
}
|
||||
if (strpos($url['host'], '#') !== false) {
|
||||
if (!isset($url['fragment'])) {
|
||||
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
|
||||
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
|
||||
unset($url['path']);
|
||||
}
|
||||
} else {
|
||||
$url['host'] = $url['host'] . $url['path'];
|
||||
unset($url['path']);
|
||||
}
|
||||
// Open archive
|
||||
$this->_archive = new ZipArchive();
|
||||
$this->_archive->open($url['host']);
|
||||
|
||||
// Open archive
|
||||
$this->_archive = new ZipArchive();
|
||||
$this->_archive->open($url['host']);
|
||||
$this->_fileNameInArchive = $url['fragment'];
|
||||
$this->_position = 0;
|
||||
$this->_data = $this->_archive->getFromName($this->_fileNameInArchive);
|
||||
|
||||
$this->_fileNameInArchive = $url['fragment'];
|
||||
$this->_position = 0;
|
||||
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Stat stream
|
||||
*/
|
||||
public function stream_stat()
|
||||
{
|
||||
return $this->_archive->statName($this->_fileNameInArchive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat stream
|
||||
*/
|
||||
public function stream_stat() {
|
||||
return $this->_archive->statName( $this->_fileNameInArchive );
|
||||
}
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count)
|
||||
{
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count) {
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
* Tell stream
|
||||
*/
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell stream
|
||||
*/
|
||||
public function stream_tell() {
|
||||
return $this->_position;
|
||||
}
|
||||
/**
|
||||
* EOF stream
|
||||
*/
|
||||
public function stream_eof()
|
||||
{
|
||||
return $this->_position >= strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* EOF stream
|
||||
*/
|
||||
public function stream_eof() {
|
||||
return $this->_position >= strlen($this->_data);
|
||||
}
|
||||
/**
|
||||
* Seek stream
|
||||
*/
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < strlen($this->_data) && $offset >= 0) {
|
||||
$this->_position = $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
/**
|
||||
* Seek stream
|
||||
*/
|
||||
public function stream_seek($offset, $whence) {
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < strlen($this->_data) && $offset >= 0) {
|
||||
$this->_position = $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
if ($offset >= 0) {
|
||||
$this->_position += $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
if ($offset >= 0) {
|
||||
$this->_position += $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SEEK_END:
|
||||
if (strlen($this->_data) + $offset >= 0) {
|
||||
$this->_position = strlen($this->_data) + $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if (strlen($this->_data) + $offset >= 0) {
|
||||
$this->_position = strlen($this->_data) + $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,146 +20,149 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style
|
||||
*/
|
||||
class PHPWord_Style {
|
||||
|
||||
/**
|
||||
* Style Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleElements = array();
|
||||
|
||||
|
||||
/**
|
||||
* Add a paragraph style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addParagraphStyle($styleName, $styles) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_Paragraph();
|
||||
foreach($styles as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a font style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$font = new PHPWord_Style_Font('text', $styleParagraph);
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
self::$_styleElements[$styleName] = $font;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a link style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addLinkStyle($styleName, $styles) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_Font('link');
|
||||
foreach($styles as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a table style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow);
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a title style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
|
||||
$styleName = 'Heading_'.$titleCount;
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$font = new PHPWord_Style_Font('title', $styleParagraph);
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $font;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all styles
|
||||
*
|
||||
* @return PHPWord_Style_Font[]
|
||||
*/
|
||||
public static function getStyles() {
|
||||
return self::$_styleElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style
|
||||
*
|
||||
* @param string
|
||||
* @return PHPWord_Style
|
||||
*/
|
||||
public static function getStyle($styleName) {
|
||||
if(array_key_exists($styleName, self::$_styleElements)){
|
||||
return self::$_styleElements[$styleName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class PHPWord_Style
|
||||
{
|
||||
|
||||
/**
|
||||
* Style Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleElements = array();
|
||||
|
||||
|
||||
/**
|
||||
* Add a paragraph style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addParagraphStyle($styleName, $styles)
|
||||
{
|
||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_Paragraph();
|
||||
foreach ($styles as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a font style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$font = new PHPWord_Style_Font('text', $styleParagraph);
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
self::$_styleElements[$styleName] = $font;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a link style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addLinkStyle($styleName, $styles)
|
||||
{
|
||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_Font('link');
|
||||
foreach ($styles as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a table style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null)
|
||||
{
|
||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$style = new PHPWord_Style_TableFull($styleTable, $styleFirstRow, $styleLastRow);
|
||||
|
||||
self::$_styleElements[$styleName] = $style;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a title style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
$styleName = 'Heading_' . $titleCount;
|
||||
if (!array_key_exists($styleName, self::$_styleElements)) {
|
||||
$font = new PHPWord_Style_Font('title', $styleParagraph);
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
|
||||
self::$_styleElements[$styleName] = $font;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all styles
|
||||
*
|
||||
* @return PHPWord_Style_Font[]
|
||||
*/
|
||||
public static function getStyles()
|
||||
{
|
||||
return self::$_styleElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style
|
||||
*
|
||||
* @param string
|
||||
* @return PHPWord_Style
|
||||
*/
|
||||
public static function getStyle($styleName)
|
||||
{
|
||||
if (array_key_exists($styleName, self::$_styleElements)) {
|
||||
return self::$_styleElements[$styleName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,299 +20,328 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_Cell
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
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;
|
||||
class PHPWord_Style_Cell
|
||||
{
|
||||
|
||||
/**
|
||||
* colspan
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_gridSpan = NULL;
|
||||
const TEXT_DIR_BTLR = 'btLr';
|
||||
const TEXT_DIR_TBRL = 'tbRl';
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* Vertical align
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_valign;
|
||||
|
||||
public function setBgColor($pValue = null) {
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
/**
|
||||
* Text Direction
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_textDirection;
|
||||
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Background-Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_bgColor;
|
||||
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Border Top Size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_borderTopSize;
|
||||
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Border Top Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderTopColor;
|
||||
|
||||
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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,242 +20,261 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_Font
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style_Font
|
||||
*/
|
||||
class PHPWord_Style_Font {
|
||||
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||
const UNDERLINE_DASHLONG = 'dashLong';
|
||||
const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
|
||||
const UNDERLINE_DOUBLE = 'dbl';
|
||||
const UNDERLINE_DOTHASH = 'dotDash';
|
||||
const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy';
|
||||
const UNDERLINE_DOTDOTDASH = 'dotDotDash';
|
||||
const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
|
||||
const UNDERLINE_DOTTED = 'dotted';
|
||||
const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
|
||||
const UNDERLINE_HEAVY = 'heavy';
|
||||
const UNDERLINE_SINGLE = 'single';
|
||||
const UNDERLINE_WAVY = 'wavy';
|
||||
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
|
||||
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
|
||||
const UNDERLINE_WORDS = 'words';
|
||||
|
||||
const FGCOLOR_YELLOW = 'yellow';
|
||||
const FGCOLOR_LIGHTGREEN = 'green';
|
||||
const FGCOLOR_CYAN = 'cyan';
|
||||
const FGCOLOR_MAGENTA = 'magenta';
|
||||
const FGCOLOR_BLUE = 'blue';
|
||||
const FGCOLOR_RED = 'red';
|
||||
const FGCOLOR_DARKBLUE = 'darkBlue';
|
||||
const FGCOLOR_DARKCYAN = 'darkCyan';
|
||||
const FGCOLOR_DARKGREEN = 'darkGreen';
|
||||
const FGCOLOR_DARKMAGENTA = 'darkMagenta';
|
||||
const FGCOLOR_DARKRED = 'darkRed';
|
||||
const FGCOLOR_DARKYELLOW = 'darkYellow';
|
||||
const FGCOLOR_DARKGRAY = 'darkGray';
|
||||
const FGCOLOR_LIGHTGRAY = 'lightGray';
|
||||
const FGCOLOR_BLACK = 'black';
|
||||
|
||||
/**
|
||||
* Font style type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_type;
|
||||
|
||||
/**
|
||||
* Paragraph Style
|
||||
*
|
||||
* @var PHPWord_Style_Paragraph
|
||||
*/
|
||||
private $_paragraphStyle;
|
||||
|
||||
private $_size;
|
||||
private $_name;
|
||||
private $_bold;
|
||||
private $_italic;
|
||||
private $_superScript;
|
||||
private $_subScript;
|
||||
private $_underline;
|
||||
private $_strikethrough;
|
||||
private $_color;
|
||||
private $_fgColor;
|
||||
class PHPWord_Style_Font
|
||||
{
|
||||
|
||||
public function __construct($type = 'text', $styleParagraph = null) {
|
||||
$this->_type = $type;
|
||||
$this->_name = 'Arial';
|
||||
$this->_size = 20;
|
||||
$this->_bold = false;
|
||||
$this->_italic = false;
|
||||
$this->_superScript = false;
|
||||
$this->_subScript = false;
|
||||
$this->_underline = PHPWord_Style_Font::UNDERLINE_NONE;
|
||||
$this->_strikethrough = false;
|
||||
$this->_color = '000000';
|
||||
$this->_fgColor = null;
|
||||
|
||||
if(!is_null($styleParagraph)) {
|
||||
$paragraph = new PHPWord_Style_Paragraph();
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$paragraph->setStyleValue($key, $value);
|
||||
}
|
||||
$this->_paragraphStyle = $paragraph;
|
||||
} else {
|
||||
$this->_paragraphStyle = null;
|
||||
}
|
||||
}
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||
const UNDERLINE_DASHLONG = 'dashLong';
|
||||
const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
|
||||
const UNDERLINE_DOUBLE = 'dbl';
|
||||
const UNDERLINE_DOTHASH = 'dotDash';
|
||||
const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy';
|
||||
const UNDERLINE_DOTDOTDASH = 'dotDotDash';
|
||||
const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
|
||||
const UNDERLINE_DOTTED = 'dotted';
|
||||
const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
|
||||
const UNDERLINE_HEAVY = 'heavy';
|
||||
const UNDERLINE_SINGLE = 'single';
|
||||
const UNDERLINE_WAVY = 'wavy';
|
||||
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
|
||||
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
|
||||
const UNDERLINE_WORDS = 'words';
|
||||
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_size') {
|
||||
$value *= 2;
|
||||
}
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setName($pValue = 'Arial') {
|
||||
if($pValue == '') {
|
||||
$pValue = 'Arial';
|
||||
}
|
||||
$this->_name = $pValue;
|
||||
return $this;
|
||||
}
|
||||
const FGCOLOR_YELLOW = 'yellow';
|
||||
const FGCOLOR_LIGHTGREEN = 'green';
|
||||
const FGCOLOR_CYAN = 'cyan';
|
||||
const FGCOLOR_MAGENTA = 'magenta';
|
||||
const FGCOLOR_BLUE = 'blue';
|
||||
const FGCOLOR_RED = 'red';
|
||||
const FGCOLOR_DARKBLUE = 'darkBlue';
|
||||
const FGCOLOR_DARKCYAN = 'darkCyan';
|
||||
const FGCOLOR_DARKGREEN = 'darkGreen';
|
||||
const FGCOLOR_DARKMAGENTA = 'darkMagenta';
|
||||
const FGCOLOR_DARKRED = 'darkRed';
|
||||
const FGCOLOR_DARKYELLOW = 'darkYellow';
|
||||
const FGCOLOR_DARKGRAY = 'darkGray';
|
||||
const FGCOLOR_LIGHTGRAY = 'lightGray';
|
||||
const FGCOLOR_BLACK = 'black';
|
||||
|
||||
public function getSize() {
|
||||
return $this->_size;
|
||||
}
|
||||
/**
|
||||
* Font style type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_type;
|
||||
|
||||
public function setSize($pValue = 20) {
|
||||
if($pValue == '') {
|
||||
$pValue = 20;
|
||||
}
|
||||
$this->_size = ($pValue*2);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Paragraph Style
|
||||
*
|
||||
* @var PHPWord_Style_Paragraph
|
||||
*/
|
||||
private $_paragraphStyle;
|
||||
|
||||
public function getBold() {
|
||||
return $this->_bold;
|
||||
}
|
||||
private $_size;
|
||||
private $_name;
|
||||
private $_bold;
|
||||
private $_italic;
|
||||
private $_superScript;
|
||||
private $_subScript;
|
||||
private $_underline;
|
||||
private $_strikethrough;
|
||||
private $_color;
|
||||
private $_fgColor;
|
||||
|
||||
public function setBold($pValue = false) {
|
||||
if($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_bold = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function __construct($type = 'text', $styleParagraph = null)
|
||||
{
|
||||
$this->_type = $type;
|
||||
$this->_name = 'Arial';
|
||||
$this->_size = 20;
|
||||
$this->_bold = false;
|
||||
$this->_italic = false;
|
||||
$this->_superScript = false;
|
||||
$this->_subScript = false;
|
||||
$this->_underline = PHPWord_Style_Font::UNDERLINE_NONE;
|
||||
$this->_strikethrough = false;
|
||||
$this->_color = '000000';
|
||||
$this->_fgColor = null;
|
||||
|
||||
public function getItalic() {
|
||||
return $this->_italic;
|
||||
}
|
||||
if (!is_null($styleParagraph)) {
|
||||
$paragraph = new PHPWord_Style_Paragraph();
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$paragraph->setStyleValue($key, $value);
|
||||
}
|
||||
$this->_paragraphStyle = $paragraph;
|
||||
} else {
|
||||
$this->_paragraphStyle = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setItalic($pValue = false) {
|
||||
if($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_italic = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
public function getSuperScript() {
|
||||
return $this->_superScript;
|
||||
}
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_size') {
|
||||
$value *= 2;
|
||||
}
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setSuperScript($pValue = false) {
|
||||
if($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_superScript = $pValue;
|
||||
$this->_subScript = !$pValue;
|
||||
return $this;
|
||||
}
|
||||
public function setName($pValue = 'Arial')
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Arial';
|
||||
}
|
||||
$this->_name = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubScript() {
|
||||
return $this->_subScript;
|
||||
}
|
||||
public function getSize()
|
||||
{
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
public function setSubScript($pValue = false) {
|
||||
if($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_subScript = $pValue;
|
||||
$this->_superScript = !$pValue;
|
||||
return $this;
|
||||
}
|
||||
public function setSize($pValue = 20)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 20;
|
||||
}
|
||||
$this->_size = ($pValue * 2);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUnderline() {
|
||||
return $this->_underline;
|
||||
}
|
||||
public function getBold()
|
||||
{
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPWord_Style_Font::UNDERLINE_NONE;
|
||||
}
|
||||
$this->_underline = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function setBold($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_bold = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStrikethrough() {
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
public function getItalic()
|
||||
{
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
public function setStrikethrough($pValue = false) {
|
||||
if($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_strikethrough = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
public function setItalic($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_italic = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setColor($pValue = '000000') {
|
||||
$this->_color = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function getSuperScript()
|
||||
{
|
||||
return $this->_superScript;
|
||||
}
|
||||
|
||||
public function getFgColor() {
|
||||
return $this->_fgColor;
|
||||
}
|
||||
public function setSuperScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_superScript = $pValue;
|
||||
$this->_subScript = !$pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFgColor($pValue = null) {
|
||||
$this->_fgColor = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStyleType() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_paragraphStyle;
|
||||
}
|
||||
public function getSubScript()
|
||||
{
|
||||
return $this->_subScript;
|
||||
}
|
||||
|
||||
public function setSubScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_subScript = $pValue;
|
||||
$this->_superScript = !$pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUnderline()
|
||||
{
|
||||
return $this->_underline;
|
||||
}
|
||||
|
||||
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPWord_Style_Font::UNDERLINE_NONE;
|
||||
}
|
||||
$this->_underline = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStrikethrough()
|
||||
{
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
|
||||
public function setStrikethrough($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_strikethrough = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColor()
|
||||
{
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
public function setColor($pValue = '000000')
|
||||
{
|
||||
$this->_color = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFgColor()
|
||||
{
|
||||
return $this->_fgColor;
|
||||
}
|
||||
|
||||
public function setFgColor($pValue = null)
|
||||
{
|
||||
$this->_fgColor = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStyleType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_paragraphStyle;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,111 +20,157 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_Image
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style_Image
|
||||
*/
|
||||
class PHPWord_Style_Image {
|
||||
|
||||
private $_width;
|
||||
private $_height;
|
||||
private $_align;
|
||||
|
||||
/**
|
||||
* Margin Top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_marginTop;
|
||||
|
||||
/**
|
||||
* Margin Left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_marginLeft;
|
||||
|
||||
public function __construct() {
|
||||
$this->_width = null;
|
||||
$this->_height = null;
|
||||
$this->_align = null;
|
||||
$this->_marginTop = null;
|
||||
$this->_marginLeft = null;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
public function setWidth($pValue = null) {
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
public function setHeight($pValue = null) {
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
public function getAlign() {
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
public function setAlign($pValue = null) {
|
||||
$this->_align = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Top
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
return $this->_marginTop;
|
||||
}
|
||||
class PHPWord_Style_Image
|
||||
{
|
||||
const WRAPPING_STYLE_INLINE = 'inline';
|
||||
const WRAPPING_STYLE_SQUARE = 'square';
|
||||
const WRAPPING_STYLE_TIGHT = 'tight';
|
||||
const WRAPPING_STYLE_BEHIND = 'behind';
|
||||
const WRAPPING_STYLE_INFRONT = 'infront';
|
||||
|
||||
/**
|
||||
* Set Margin Top
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginTop($pValue = null) {
|
||||
$this->_marginTop = $pValue;
|
||||
return $this;
|
||||
}
|
||||
private $_width;
|
||||
private $_height;
|
||||
private $_align;
|
||||
private $wrappingStyle;
|
||||
|
||||
/**
|
||||
* Get Margin Left
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
/**
|
||||
* Margin Top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_marginTop;
|
||||
|
||||
/**
|
||||
* Set Margin Left
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginLeft($pValue = null) {
|
||||
$this->_marginLeft = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Margin Left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_marginLeft;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_width = null;
|
||||
$this->_height = null;
|
||||
$this->_align = null;
|
||||
$this->_marginTop = null;
|
||||
$this->_marginLeft = null;
|
||||
$this->setWrappingStyle(self::WRAPPING_STYLE_INLINE);
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
public function setWidth($pValue = null)
|
||||
{
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
public function setHeight($pValue = null)
|
||||
{
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
public function setAlign($pValue = null)
|
||||
{
|
||||
$this->_align = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Top
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Top
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setMarginTop($pValue = null)
|
||||
{
|
||||
$this->_marginTop = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Left
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Left
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_marginLeft = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $wrappingStyle
|
||||
* @throws InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setWrappingStyle($wrappingStyle)
|
||||
{
|
||||
switch ($wrappingStyle) {
|
||||
case self::WRAPPING_STYLE_BEHIND:
|
||||
case self::WRAPPING_STYLE_INFRONT:
|
||||
case self::WRAPPING_STYLE_INLINE:
|
||||
case self::WRAPPING_STYLE_SQUARE:
|
||||
case self::WRAPPING_STYLE_TIGHT:
|
||||
$this->wrappingStyle = $wrappingStyle;
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('Wrapping style does not exists');
|
||||
break;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWrappingStyle()
|
||||
{
|
||||
return $this->wrappingStyle;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,64 +20,63 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_ListItem
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style_ListItem
|
||||
*/
|
||||
class PHPWord_Style_ListItem {
|
||||
|
||||
const TYPE_NUMBER = 7;
|
||||
const TYPE_NUMBER_NESTED = 8;
|
||||
const TYPE_ALPHANUM = 9;
|
||||
const TYPE_BULLET_FILLED = 3;
|
||||
const TYPE_BULLET_EMPTY = 5;
|
||||
const TYPE_SQUARE_FILLED = 1;
|
||||
|
||||
/**
|
||||
* List Type
|
||||
*/
|
||||
private $_listType;
|
||||
|
||||
/**
|
||||
* Create a new ListItem Style
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_listType = PHPWord_Style_ListItem::TYPE_BULLET_FILLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set List Type
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) {
|
||||
$this->_listType = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List Type
|
||||
*/
|
||||
public function getListType() {
|
||||
return $this->_listType;
|
||||
}
|
||||
class PHPWord_Style_ListItem
|
||||
{
|
||||
|
||||
const TYPE_NUMBER = 7;
|
||||
const TYPE_NUMBER_NESTED = 8;
|
||||
const TYPE_ALPHANUM = 9;
|
||||
const TYPE_BULLET_FILLED = 3;
|
||||
const TYPE_BULLET_EMPTY = 5;
|
||||
const TYPE_SQUARE_FILLED = 1;
|
||||
|
||||
/**
|
||||
* List Type
|
||||
*/
|
||||
private $_listType;
|
||||
|
||||
/**
|
||||
* Create a new ListItem Style
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_listType = PHPWord_Style_ListItem::TYPE_BULLET_FILLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set List Type
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED)
|
||||
{
|
||||
$this->_listType = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List Type
|
||||
*/
|
||||
public function getListType()
|
||||
{
|
||||
return $this->_listType;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,206 +20,214 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_Paragraph
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
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;
|
||||
class PHPWord_Style_Paragraph
|
||||
{
|
||||
|
||||
/**
|
||||
* Set of Custom Tab Stops
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_tabs;
|
||||
/**
|
||||
* Paragraph alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_align;
|
||||
|
||||
/**
|
||||
* Indent by how much
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_tabs;
|
||||
|
||||
/**
|
||||
* Indent by how much
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign() {
|
||||
return $this->_align;
|
||||
}
|
||||
/**
|
||||
* Get Paragraph Alignment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paragraph Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setAlign($pValue = null) {
|
||||
if(strtolower($pValue) == 'justify') {
|
||||
// justify becames both
|
||||
$pValue = 'both';
|
||||
}
|
||||
$this->_align = $pValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set Paragraph Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setAlign($pValue = null)
|
||||
{
|
||||
if (strtolower($pValue) == 'justify') {
|
||||
// justify becames both
|
||||
$pValue = 'both';
|
||||
}
|
||||
$this->_align = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Space before Paragraph
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceBefore() {
|
||||
return $this->_spaceBefore;
|
||||
}
|
||||
/**
|
||||
* Get Space before Paragraph
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceBefore()
|
||||
{
|
||||
return $this->_spaceBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Space before Paragraph
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceBefore($pValue = null) {
|
||||
$this->_spaceBefore = $pValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set Space before Paragraph
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceBefore($pValue = null)
|
||||
{
|
||||
$this->_spaceBefore = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Space after Paragraph
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceAfter() {
|
||||
return $this->_spaceAfter;
|
||||
}
|
||||
/**
|
||||
* Get Space after Paragraph
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceAfter()
|
||||
{
|
||||
return $this->_spaceAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Space after Paragraph
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceAfter($pValue = null) {
|
||||
$this->_spaceAfter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set Space after Paragraph
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceAfter($pValue = null)
|
||||
{
|
||||
$this->_spaceAfter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Spacing between breaks
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpacing() {
|
||||
return $this->_spacing;
|
||||
}
|
||||
/**
|
||||
* Get Spacing between breaks
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpacing()
|
||||
{
|
||||
return $this->_spacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Spacing between breaks
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpacing($pValue = null) {
|
||||
$this->_spacing = $pValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set Spacing between breaks
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpacing($pValue = null)
|
||||
{
|
||||
$this->_spacing = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indentation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
return $this->_indent;
|
||||
}
|
||||
/**
|
||||
* Get indentation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indentation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setIndent($pValue = null) {
|
||||
$this->_indent = $pValue;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set indentation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setIndent($pValue = null)
|
||||
{
|
||||
$this->_indent = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tabs
|
||||
*
|
||||
* @return PHPWord_Style_Tabs
|
||||
*/
|
||||
public function getTabs() {
|
||||
return $this->_tabs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Get tabs
|
||||
*
|
||||
* @return PHPWord_Style_Tabs
|
||||
*/
|
||||
public function getTabs()
|
||||
{
|
||||
return $this->_tabs;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,119 +20,122 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_TOC
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style_TOC
|
||||
*/
|
||||
class PHPWord_Style_TOC {
|
||||
|
||||
const TABLEADER_DOT = 'dot';
|
||||
const TABLEADER_UNDERSCORE = 'underscore';
|
||||
const TABLEADER_LINE = 'hyphen';
|
||||
const TABLEADER_NONE = '';
|
||||
|
||||
/**
|
||||
* Tab Leader
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tabLeader;
|
||||
|
||||
/**
|
||||
* Tab Position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_tabPos;
|
||||
|
||||
/**
|
||||
* Indent
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TOC Style
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_tabPos = 9062;
|
||||
$this->_tabLeader = PHPWord_Style_TOC::TABLEADER_DOT;
|
||||
$this->_indent = 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tab Position
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTabPos() {
|
||||
return $this->_tabPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tab Position
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setTabPos($pValue) {
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tab Leader
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLeader() {
|
||||
return $this->_tabLeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tab Leader
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT) {
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Indent
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setIndent($pValue) {
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
class PHPWord_Style_TOC
|
||||
{
|
||||
|
||||
const TABLEADER_DOT = 'dot';
|
||||
const TABLEADER_UNDERSCORE = 'underscore';
|
||||
const TABLEADER_LINE = 'hyphen';
|
||||
const TABLEADER_NONE = '';
|
||||
|
||||
/**
|
||||
* Tab Leader
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tabLeader;
|
||||
|
||||
/**
|
||||
* Tab Position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_tabPos;
|
||||
|
||||
/**
|
||||
* Indent
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TOC Style
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_tabPos = 9062;
|
||||
$this->_tabLeader = PHPWord_Style_TOC::TABLEADER_DOT;
|
||||
$this->_indent = 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tab Position
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTabPos()
|
||||
{
|
||||
return $this->_tabPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tab Position
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setTabPos($pValue)
|
||||
{
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tab Leader
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLeader()
|
||||
{
|
||||
return $this->_tabLeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Tab Leader
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT)
|
||||
{
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Indent
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setIndent($pValue)
|
||||
{
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,128 +20,127 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version {something}
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_val;
|
||||
/**
|
||||
* Tab Stop Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_val;
|
||||
|
||||
/**
|
||||
* Tab Leader Character
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_leader;
|
||||
/**
|
||||
* Tab Leader Character
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_leader;
|
||||
|
||||
/**
|
||||
* Tab Stop Position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position;
|
||||
/**
|
||||
* Tab Stop Position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position;
|
||||
|
||||
/**
|
||||
* Tab Stop Type
|
||||
*
|
||||
* @var array
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type
|
||||
*/
|
||||
private static $_possibleStopTypes = array(
|
||||
'clear', // No Tab Stop
|
||||
'left', // Left Tab Stop
|
||||
'center', // Center Tab Stop
|
||||
'right', // Right Tab Stop
|
||||
'decimal', // Decimal Tab
|
||||
'bar', // Bar Tab
|
||||
'num' // List tab
|
||||
);
|
||||
/**
|
||||
* Tab Stop Type
|
||||
*
|
||||
* @var array
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_val-26.html Tab Stop Type
|
||||
*/
|
||||
private static $_possibleStopTypes = array(
|
||||
'clear', // No Tab Stop
|
||||
'left', // Left Tab Stop
|
||||
'center', // Center Tab Stop
|
||||
'right', // Right Tab Stop
|
||||
'decimal', // Decimal Tab
|
||||
'bar', // Bar Tab
|
||||
'num' // List tab
|
||||
);
|
||||
|
||||
/**
|
||||
* Tab Leader Character
|
||||
*
|
||||
* @var array
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character
|
||||
*/
|
||||
private static $_possibleLeaders = array(
|
||||
'none', // No tab stop leader
|
||||
'dot', // Dotted leader line
|
||||
'hyphen', // Dashed tab stop leader line
|
||||
'underscore', // Solid leader line
|
||||
'heavy', // Heavy solid leader line
|
||||
'middleDot' // Middle dot leader line
|
||||
);
|
||||
/**
|
||||
* Tab Leader Character
|
||||
*
|
||||
* @var array
|
||||
* @link http://www.schemacentral.com/sc/ooxml/a-w_leader-1.html Tab Leader Character
|
||||
*/
|
||||
private static $_possibleLeaders = array(
|
||||
'none', // No tab stop leader
|
||||
'dot', // Dotted leader line
|
||||
'hyphen', // Dashed tab stop leader line
|
||||
'underscore', // Solid leader line
|
||||
'heavy', // Heavy solid leader line
|
||||
'middleDot' // Middle dot leader line
|
||||
);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* they will be changed to default values.
|
||||
*
|
||||
* @param string $val Defaults to 'clear' if value is not possible.
|
||||
* @param int $position Must be an integer; otherwise defaults to 0.
|
||||
* @param string $leader Defaults to NULL if value is not possible.
|
||||
*/
|
||||
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';
|
||||
/**
|
||||
* 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
|
||||
* they will be changed to default values.
|
||||
*
|
||||
* @param string $val Defaults to 'clear' if value is not possible.
|
||||
* @param int $position Must be an integer; otherwise defaults to 0.
|
||||
* @param string $leader Defaults to NULL if value is not possible.
|
||||
*/
|
||||
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 0 if the position is non-numeric
|
||||
$this->_position = (is_numeric($position)) ? intval($position) : 0;
|
||||
// Default to 0 if the position is non-numeric
|
||||
$this->_position = (is_numeric($position)) ? intval($position) : 0;
|
||||
|
||||
// Default to NULL if no tab leader
|
||||
$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();
|
||||
// Default to NULL if no tab leader
|
||||
$this->_leader = (self::isLeaderType($leader)) ? $leader : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if attribute is a valid stop type.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return bool True if it is; false otherwise.
|
||||
*/
|
||||
private static function isStopType($attribute) {
|
||||
return in_array($attribute, self::$_possibleStopTypes);
|
||||
}
|
||||
/**
|
||||
* 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 leader type.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return bool True if it is; false otherwise.
|
||||
*/
|
||||
private static function isLeaderType($attribute) {
|
||||
return in_array($attribute, self::$_possibleLeaders);
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Test if attribute is a valid stop type.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return bool True if it is; false otherwise.
|
||||
*/
|
||||
private static function isStopType($attribute)
|
||||
{
|
||||
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,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,64 +20,77 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Style_Table
|
||||
*/
|
||||
class PHPWord_Style_Table
|
||||
{
|
||||
|
||||
class PHPWord_Style_Table {
|
||||
|
||||
private $_cellMarginTop;
|
||||
private $_cellMarginLeft;
|
||||
private $_cellMarginRight;
|
||||
private $_cellMarginBottom;
|
||||
|
||||
public function __construct() {
|
||||
$this->_cellMarginTop = null;
|
||||
$this->_cellMarginLeft = null;
|
||||
$this->_cellMarginRight = null;
|
||||
$this->_cellMarginBottom = null;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null) {
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop() {
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null) {
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft() {
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null) {
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight() {
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null) {
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom() {
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function getCellMargin() {
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
}
|
||||
private $_cellMarginTop;
|
||||
private $_cellMarginLeft;
|
||||
private $_cellMarginRight;
|
||||
private $_cellMarginBottom;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_cellMarginTop = null;
|
||||
$this->_cellMarginLeft = null;
|
||||
$this->_cellMarginRight = null;
|
||||
$this->_cellMarginBottom = null;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function getCellMargin()
|
||||
{
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,423 +20,462 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Style_TableFull
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Style
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Style_TableFull
|
||||
*/
|
||||
class PHPWord_Style_TableFull {
|
||||
|
||||
/**
|
||||
* Style for first row
|
||||
*
|
||||
* @var PHPWord_Style_Table
|
||||
*/
|
||||
private $_firstRow = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginTop = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginLeft = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginRight = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Bottom
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginBottom = null;
|
||||
|
||||
/**
|
||||
* 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 InsideH Size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_borderInsideHSize;
|
||||
|
||||
/**
|
||||
* Border InsideH Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderInsideHColor;
|
||||
|
||||
/**
|
||||
* Border InsideV Size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_borderInsideVSize;
|
||||
|
||||
/**
|
||||
* Border InsideV Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderInsideVColor;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TableFull Font
|
||||
*/
|
||||
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null) {
|
||||
|
||||
if(!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
||||
$this->_firstRow = clone $this;
|
||||
|
||||
unset($this->_firstRow->_firstRow);
|
||||
unset($this->_firstRow->_cellMarginBottom);
|
||||
unset($this->_firstRow->_cellMarginTop);
|
||||
unset($this->_firstRow->_cellMarginLeft);
|
||||
unset($this->_firstRow->_cellMarginRight);
|
||||
unset($this->_firstRow->_borderInsideVColor);
|
||||
unset($this->_firstRow->_borderInsideVSize);
|
||||
unset($this->_firstRow->_borderInsideHColor);
|
||||
unset($this->_firstRow->_borderInsideHSize);
|
||||
foreach($styleFirstRow as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
|
||||
$this->_firstRow->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($styleTable) && is_array($styleTable)) {
|
||||
foreach($styleTable as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
$this->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_borderSize') {
|
||||
$this->setBorderSize($value);
|
||||
} elseif($key == '_borderColor') {
|
||||
$this->setBorderColor($value);
|
||||
} elseif($key == '_cellMargin') {
|
||||
$this->setCellMargin($value);
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get First Row Style
|
||||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getFirstRow() {
|
||||
return $this->_firstRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Row Style
|
||||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getLastRow() {
|
||||
return $this->_lastRow;
|
||||
}
|
||||
|
||||
public function getBgColor() {
|
||||
return $this->_bgColor;
|
||||
}
|
||||
class PHPWord_Style_TableFull
|
||||
{
|
||||
|
||||
public function setBgColor($pValue = null) {
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
/**
|
||||
* Style for first row
|
||||
*
|
||||
* @var PHPWord_Style_Table
|
||||
*/
|
||||
private $_firstRow = null;
|
||||
|
||||
/**
|
||||
* Set TLRBVH Border Size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderSize($pValue = null) {
|
||||
$this->_borderTopSize = $pValue;
|
||||
$this->_borderLeftSize = $pValue;
|
||||
$this->_borderRightSize = $pValue;
|
||||
$this->_borderBottomSize = $pValue;
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TLRBVH Border Size
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderSize() {
|
||||
$t = $this->getBorderTopSize();
|
||||
$l = $this->getBorderLeftSize();
|
||||
$r = $this->getBorderRightSize();
|
||||
$b = $this->getBorderBottomSize();
|
||||
$h = $this->getBorderInsideHSize();
|
||||
$v = $this->getBorderInsideVSize();
|
||||
|
||||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TLRBVH Border Color
|
||||
*/
|
||||
public function setBorderColor($pValue = null) {
|
||||
$this->_borderTopColor = $pValue;
|
||||
$this->_borderLeftColor = $pValue;
|
||||
$this->_borderRightColor = $pValue;
|
||||
$this->_borderBottomColor = $pValue;
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TLRB Border Color
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderColor() {
|
||||
$t = $this->getBorderTopColor();
|
||||
$l = $this->getBorderLeftColor();
|
||||
$r = $this->getBorderRightColor();
|
||||
$b = $this->getBorderBottomColor();
|
||||
$h = $this->getBorderInsideHColor();
|
||||
$v = $this->getBorderInsideVColor();
|
||||
|
||||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Cell Margin Top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginTop = null;
|
||||
|
||||
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 setBorderInsideHColor($pValue = null) {
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHColor() {
|
||||
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVColor($pValue = null) {
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVColor() {
|
||||
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideHSize($pValue = null) {
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHSize() {
|
||||
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVSize($pValue = null) {
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVSize() {
|
||||
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null) {
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop() {
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null) {
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft() {
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null) {
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight() {
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null) {
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom() {
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function setCellMargin($pValue = null) {
|
||||
$this->_cellMarginTop = $pValue;
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
$this->_cellMarginRight = $pValue;
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMargin() {
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
}
|
||||
/**
|
||||
* Cell Margin Left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginLeft = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginRight = null;
|
||||
|
||||
/**
|
||||
* Cell Margin Bottom
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginBottom = null;
|
||||
|
||||
/**
|
||||
* 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 InsideH Size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_borderInsideHSize;
|
||||
|
||||
/**
|
||||
* Border InsideH Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderInsideHColor;
|
||||
|
||||
/**
|
||||
* Border InsideV Size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_borderInsideVSize;
|
||||
|
||||
/**
|
||||
* Border InsideV Color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderInsideVColor;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TableFull Font
|
||||
*/
|
||||
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null)
|
||||
{
|
||||
|
||||
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
||||
$this->_firstRow = clone $this;
|
||||
|
||||
unset($this->_firstRow->_firstRow);
|
||||
unset($this->_firstRow->_cellMarginBottom);
|
||||
unset($this->_firstRow->_cellMarginTop);
|
||||
unset($this->_firstRow->_cellMarginLeft);
|
||||
unset($this->_firstRow->_cellMarginRight);
|
||||
unset($this->_firstRow->_borderInsideVColor);
|
||||
unset($this->_firstRow->_borderInsideVSize);
|
||||
unset($this->_firstRow->_borderInsideHColor);
|
||||
unset($this->_firstRow->_borderInsideHSize);
|
||||
foreach ($styleFirstRow as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
|
||||
$this->_firstRow->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($styleTable) && is_array($styleTable)) {
|
||||
foreach ($styleTable as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_borderSize') {
|
||||
$this->setBorderSize($value);
|
||||
} elseif ($key == '_borderColor') {
|
||||
$this->setBorderColor($value);
|
||||
} elseif ($key == '_cellMargin') {
|
||||
$this->setCellMargin($value);
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get First Row Style
|
||||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getFirstRow()
|
||||
{
|
||||
return $this->_firstRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Row Style
|
||||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getLastRow()
|
||||
{
|
||||
return $this->_lastRow;
|
||||
}
|
||||
|
||||
public function getBgColor()
|
||||
{
|
||||
return $this->_bgColor;
|
||||
}
|
||||
|
||||
public function setBgColor($pValue = null)
|
||||
{
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TLRBVH Border Size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
$this->_borderLeftSize = $pValue;
|
||||
$this->_borderRightSize = $pValue;
|
||||
$this->_borderBottomSize = $pValue;
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TLRBVH Border Size
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderSize()
|
||||
{
|
||||
$t = $this->getBorderTopSize();
|
||||
$l = $this->getBorderLeftSize();
|
||||
$r = $this->getBorderRightSize();
|
||||
$b = $this->getBorderBottomSize();
|
||||
$h = $this->getBorderInsideHSize();
|
||||
$v = $this->getBorderInsideVSize();
|
||||
|
||||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TLRBVH Border Color
|
||||
*/
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
$this->_borderLeftColor = $pValue;
|
||||
$this->_borderRightColor = $pValue;
|
||||
$this->_borderBottomColor = $pValue;
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TLRB Border Color
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderColor()
|
||||
{
|
||||
$t = $this->getBorderTopColor();
|
||||
$l = $this->getBorderLeftColor();
|
||||
$r = $this->getBorderRightColor();
|
||||
$b = $this->getBorderBottomColor();
|
||||
$h = $this->getBorderInsideHColor();
|
||||
$v = $this->getBorderInsideVColor();
|
||||
|
||||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
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 setBorderInsideHColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHColor()
|
||||
{
|
||||
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVColor()
|
||||
{
|
||||
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideHSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHSize()
|
||||
{
|
||||
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVSize()
|
||||
{
|
||||
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function setCellMargin($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
$this->_cellMarginRight = $pValue;
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMargin()
|
||||
{
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,48 +20,45 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version {something}
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_tabs;
|
||||
/**
|
||||
* Tabs
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_tabs;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $tabs
|
||||
*/
|
||||
public function __construct(array $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 array $tabs
|
||||
*/
|
||||
public function __construct(array $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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,136 +20,136 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_TOC
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_TOC
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_TOC
|
||||
*/
|
||||
class PHPWord_TOC {
|
||||
|
||||
/**
|
||||
* Title Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_titles = array();
|
||||
|
||||
/**
|
||||
* TOC Style
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleTOC;
|
||||
|
||||
/**
|
||||
* Font Style
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleFont;
|
||||
|
||||
/**
|
||||
* Title Anchor
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_anchor = 252634154;
|
||||
|
||||
/**
|
||||
* Title Bookmark
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_bookmarkId = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table-of-Contents Element
|
||||
*
|
||||
* @param array $styleFont
|
||||
* @param array $styleTOC
|
||||
*/
|
||||
public function __construct($styleFont = null, $styleTOC = null) {
|
||||
self::$_styleTOC = new PHPWord_Style_TOC();
|
||||
|
||||
if(!is_null($styleTOC) && is_array($styleTOC)) {
|
||||
foreach($styleTOC as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
self::$_styleTOC->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($styleFont)) {
|
||||
if(is_array($styleFont)) {
|
||||
self::$_styleFont = new PHPWord_Style_Font();
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
}
|
||||
self::$_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
self::$_styleFont = $styleFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Title
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function addTitle($text, $depth = 0) {
|
||||
$anchor = '_Toc'.++self::$_anchor;
|
||||
$bookmarkId = self::$_bookmarkId++;
|
||||
|
||||
$title = array();
|
||||
$title['text'] = $text;
|
||||
$title['depth'] = $depth;
|
||||
$title['anchor'] = $anchor;
|
||||
$title['bookmarkId'] = $bookmarkId;
|
||||
|
||||
self::$_titles[] = $title;
|
||||
|
||||
return array($anchor, $bookmarkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all titles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTitles() {
|
||||
return self::$_titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TOC Style
|
||||
*
|
||||
* @return PHPWord_Style_TOC
|
||||
*/
|
||||
public static function getStyleTOC() {
|
||||
return self::$_styleTOC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font Style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public static function getStyleFont() {
|
||||
return self::$_styleFont;
|
||||
}
|
||||
}
|
||||
?>
|
||||
class PHPWord_TOC
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_titles = array();
|
||||
|
||||
/**
|
||||
* TOC Style
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleTOC;
|
||||
|
||||
/**
|
||||
* Font Style
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_styleFont;
|
||||
|
||||
/**
|
||||
* Title Anchor
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_anchor = 252634154;
|
||||
|
||||
/**
|
||||
* Title Bookmark
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_bookmarkId = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table-of-Contents Element
|
||||
*
|
||||
* @param array $styleFont
|
||||
* @param array $styleTOC
|
||||
*/
|
||||
public function __construct($styleFont = null, $styleTOC = null)
|
||||
{
|
||||
self::$_styleTOC = new PHPWord_Style_TOC();
|
||||
|
||||
if (!is_null($styleTOC) && is_array($styleTOC)) {
|
||||
foreach ($styleTOC as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
self::$_styleTOC->setStyleValue($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($styleFont)) {
|
||||
if (is_array($styleFont)) {
|
||||
self::$_styleFont = new PHPWord_Style_Font();
|
||||
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
self::$_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
self::$_styleFont = $styleFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Title
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function addTitle($text, $depth = 0)
|
||||
{
|
||||
$anchor = '_Toc' . ++self::$_anchor;
|
||||
$bookmarkId = self::$_bookmarkId++;
|
||||
|
||||
$title = array();
|
||||
$title['text'] = $text;
|
||||
$title['depth'] = $depth;
|
||||
$title['anchor'] = $anchor;
|
||||
$title['bookmarkId'] = $bookmarkId;
|
||||
|
||||
self::$_titles[] = $title;
|
||||
|
||||
return array($anchor, $bookmarkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all titles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTitles()
|
||||
{
|
||||
return self::$_titles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TOC Style
|
||||
*
|
||||
* @return PHPWord_Style_TOC
|
||||
*/
|
||||
public static function getStyleTOC()
|
||||
{
|
||||
return self::$_styleTOC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font Style
|
||||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public static function getStyleFont()
|
||||
{
|
||||
return self::$_styleFont;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,90 +20,88 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_DocumentProperties
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2009 - 2011 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
*/
|
||||
class PHPWord_Template {
|
||||
|
||||
class PHPWord_Template
|
||||
{
|
||||
|
||||
/**
|
||||
* ZipArchive
|
||||
*
|
||||
*
|
||||
* @var ZipArchive
|
||||
*/
|
||||
private $_objZip;
|
||||
|
||||
|
||||
/**
|
||||
* Temporary Filename
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tempFileName;
|
||||
|
||||
|
||||
/**
|
||||
* Document XML
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_documentXML;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Template Object
|
||||
*
|
||||
*
|
||||
* @param string $strFilename
|
||||
*/
|
||||
public function __construct($strFilename) {
|
||||
public function __construct($strFilename)
|
||||
{
|
||||
$this->_tempFileName = tempnam(sys_get_temp_dir(), '');
|
||||
if ($this->_tempFileName !== false) {
|
||||
// Copy the source File to the temp File
|
||||
if(!copy($strFilename, $this->_tempFileName)){
|
||||
throw new PHPWord_Exception('Could not copy the template from '.$strFilename.' to '.$this->_tempFileName.'.');
|
||||
}
|
||||
// Copy the source File to the temp File
|
||||
if (!copy($strFilename, $this->_tempFileName)) {
|
||||
throw new PHPWord_Exception('Could not copy the template from ' . $strFilename . ' to ' . $this->_tempFileName . '.');
|
||||
}
|
||||
|
||||
$this->_objZip = new ZipArchive();
|
||||
$this->_objZip->open($this->_tempFileName);
|
||||
$this->_objZip = new ZipArchive();
|
||||
$this->_objZip->open($this->_tempFileName);
|
||||
|
||||
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
||||
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');
|
||||
} 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
|
||||
*
|
||||
*
|
||||
* @param mixed $search
|
||||
* @param mixed $replace
|
||||
*/
|
||||
public function setValue($search, $replace) {
|
||||
public function setValue($search, $replace)
|
||||
{
|
||||
$pattern = '|\$\{([^\}]+)\}|U';
|
||||
preg_match_all($pattern, $this->_documentXML, $matches);
|
||||
foreach ($matches[0] as $value) {
|
||||
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
|
||||
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
|
||||
$this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML);
|
||||
$valueCleaned = preg_replace('/<[^>]+>/', '', $value);
|
||||
$valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned);
|
||||
$this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML);
|
||||
}
|
||||
|
||||
if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
||||
$search = '${'.$search.'}';
|
||||
if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
||||
$search = '${' . $search . '}';
|
||||
}
|
||||
|
||||
if(!is_array($replace)) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($replace)){
|
||||
$replace = utf8_encode($replace);
|
||||
|
||||
if (!is_array($replace)) {
|
||||
if (!PHPWord_Shared_String::IsUTF8($replace)) {
|
||||
$replace = utf8_encode($replace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
||||
}
|
||||
|
||||
|
|
@ -118,22 +116,22 @@ class PHPWord_Template {
|
|||
|
||||
/**
|
||||
* Save Template
|
||||
*
|
||||
*
|
||||
* @param string $strFilename
|
||||
*/
|
||||
public function save($strFilename) {
|
||||
if(file_exists($strFilename)) {
|
||||
public function save($strFilename)
|
||||
{
|
||||
if (file_exists($strFilename)) {
|
||||
unlink($strFilename);
|
||||
}
|
||||
|
||||
|
||||
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
||||
|
||||
|
||||
// Close zip file
|
||||
if($this->_objZip->close() === false) {
|
||||
if ($this->_objZip->close() === false) {
|
||||
throw new Exception('Could not close zip file.');
|
||||
}
|
||||
|
||||
|
||||
rename($this->_tempFileName, $strFilename);
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,20 +20,21 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Interface PHPWord_Writer_IWriter
|
||||
*/
|
||||
interface PHPWord_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null);
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null);
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,262 +19,272 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_ODText
|
||||
*/
|
||||
class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Private PHPWord
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
/**
|
||||
* Private writer parts
|
||||
*
|
||||
* @var PHPWord_Writer_ODText_WriterPart[]
|
||||
*/
|
||||
private $_writerParts;
|
||||
|
||||
/**
|
||||
* Private unique PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPWord_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Assign PHPWord
|
||||
$this->setPHPWord($pPHPWord);
|
||||
|
||||
// Set up disk caching location
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
// Initialise writer parts
|
||||
$this->_writerParts['content'] = new PHPWord_Writer_ODText_Content();
|
||||
$this->_writerParts['manifest'] = new PHPWord_Writer_ODText_Manifest();
|
||||
$this->_writerParts['meta'] = new PHPWord_Writer_ODText_Meta();
|
||||
$this->_writerParts['mimetype'] = new PHPWord_Writer_ODText_Mimetype();
|
||||
$this->_writerParts['styles'] = new PHPWord_Writer_ODText_Styles();
|
||||
|
||||
|
||||
// Assign parent IWriter
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPWord_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create drawing dictionary
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add mimetype to ZIP file
|
||||
//@todo Not in ZIPARCHIVE::CM_STORE mode
|
||||
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document));
|
||||
|
||||
// Add content.xml to ZIP file
|
||||
$objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_document));
|
||||
/**
|
||||
* Private PHPWord
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
// Add meta.xml to ZIP file
|
||||
$objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->_document));
|
||||
|
||||
// Add styles.xml to ZIP file
|
||||
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
|
||||
|
||||
// Add META-INF/manifest.xml
|
||||
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_document));
|
||||
|
||||
// Add media
|
||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||
$imageContents = null;
|
||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||
|
||||
if (strpos($imagePath, 'zip://') !== false) {
|
||||
$imagePath = substr($imagePath, 6);
|
||||
$imagePathSplitted = explode('#', $imagePath);
|
||||
|
||||
$imageZip = new ZipArchive();
|
||||
$imageZip->open($imagePathSplitted[0]);
|
||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
} else {
|
||||
$imageContents = file_get_contents($imagePath);
|
||||
}
|
||||
|
||||
$objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
/**
|
||||
* Private writer parts
|
||||
*
|
||||
* @var PHPWord_Writer_ODText_WriterPart[]
|
||||
*/
|
||||
private $_writerParts;
|
||||
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord() {
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
throw new Exception("No PHPWord assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null) {
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '') {
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching() {
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory() {
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
/**
|
||||
* Private unique PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPWord_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Assign PHPWord
|
||||
$this->setPHPWord($pPHPWord);
|
||||
|
||||
// Set up disk caching location
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
// Initialise writer parts
|
||||
$this->_writerParts['content'] = new PHPWord_Writer_ODText_Content();
|
||||
$this->_writerParts['manifest'] = new PHPWord_Writer_ODText_Manifest();
|
||||
$this->_writerParts['meta'] = new PHPWord_Writer_ODText_Meta();
|
||||
$this->_writerParts['mimetype'] = new PHPWord_Writer_ODText_Mimetype();
|
||||
$this->_writerParts['styles'] = new PHPWord_Writer_ODText_Styles();
|
||||
|
||||
|
||||
// Assign parent IWriter
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPWord_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create drawing dictionary
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add mimetype to ZIP file
|
||||
//@todo Not in ZIPARCHIVE::CM_STORE mode
|
||||
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document));
|
||||
|
||||
// Add content.xml to ZIP file
|
||||
$objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_document));
|
||||
|
||||
// Add meta.xml to ZIP file
|
||||
$objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->_document));
|
||||
|
||||
// Add styles.xml to ZIP file
|
||||
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
|
||||
|
||||
// Add META-INF/manifest.xml
|
||||
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_document));
|
||||
|
||||
// Add media
|
||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||
$imageContents = null;
|
||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||
|
||||
if (strpos($imagePath, 'zip://') !== false) {
|
||||
$imagePath = substr($imagePath, 6);
|
||||
$imagePathSplitted = explode('#', $imagePath);
|
||||
|
||||
$imageZip = new ZipArchive();
|
||||
$imageZip->open($imagePathSplitted[0]);
|
||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
} else {
|
||||
$imageContents = file_get_contents($imagePath);
|
||||
}
|
||||
|
||||
$objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$objZip->addFromString('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
}
|
||||
}
|
||||
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord()
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
throw new Exception("No PHPWord assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
{
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '')
|
||||
{
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching()
|
||||
{
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory()
|
||||
{
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,250 +19,245 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_Content
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_Manifest
|
||||
*/
|
||||
class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write content file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeContent(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Write content file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeContent(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// office:document-content
|
||||
$objWriter->startElement('office:document-content');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
|
||||
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
|
||||
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
|
||||
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
|
||||
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
|
||||
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
|
||||
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
|
||||
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
|
||||
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
|
||||
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
|
||||
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
|
||||
$objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
|
||||
$objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
|
||||
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
|
||||
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
|
||||
$objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
|
||||
$objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
// We firstly search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
$pSection = 0;
|
||||
$numPStyles = 0;
|
||||
$numFStyles = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
$pStyle = $element->getParagraphStyle();
|
||||
|
||||
if($fStyle instanceof PHPWord_Style_Font){
|
||||
$numFStyles++;
|
||||
|
||||
$arrStyle = array(
|
||||
'color'=>$fStyle->getColor(),
|
||||
'name' =>$fStyle->getName()
|
||||
);
|
||||
$pPHPWord->addFontStyle('T'.$numFStyles, $arrStyle);
|
||||
$element->setFontStyle('T'.$numFStyles);
|
||||
}
|
||||
elseif($pStyle instanceof PHPWord_Style_Paragraph){
|
||||
$numPStyles++;
|
||||
|
||||
$pPHPWord->addParagraphStyle('P'.$numPStyles, array());
|
||||
$element->setParagraph('P'.$numPStyles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// office:font-face-decls
|
||||
$objWriter->startElement('office:font-face-decls');
|
||||
$arrFonts = array();
|
||||
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if(!in_array($name, $arrFonts)){
|
||||
$arrFonts[] = $name;
|
||||
// office:document-content
|
||||
$objWriter->startElement('office:document-content');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
|
||||
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
|
||||
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
|
||||
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
|
||||
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
|
||||
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
|
||||
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
|
||||
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
|
||||
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
|
||||
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
|
||||
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
|
||||
$objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
|
||||
$objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
|
||||
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
|
||||
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
|
||||
$objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
|
||||
$objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
// style:font-face
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', $name);
|
||||
$objWriter->writeAttribute('svg:font-family', $name);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!in_array('Arial', $arrFonts)){
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('office:automatic-styles');
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if(preg_match('#^T[0-9]+$#', $styleName) != 0
|
||||
|| preg_match('#^P[0-9]+$#', $styleName) != 0){
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'text');
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('fo:color', '#'.$style->getColor());
|
||||
$objWriter->writeAttribute('style:font-name', $style->getName());
|
||||
$objWriter->writeAttribute('style:font-name-complex', $style->getName());
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($style instanceof PHPWord_Style_Paragraph){
|
||||
$numPStyles++;
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
$objWriter->writeAttribute('style:parent-style-name', 'Standard');
|
||||
$objWriter->writeAttribute('style:master-page-name', 'Standard');
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('style:page-number', 'auto');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($numPStyles == 0){
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', 'P1');
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
$objWriter->writeAttribute('style:parent-style-name', 'Standard');
|
||||
$objWriter->writeAttribute('style:master-page-name', 'Standard');
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('style:page-number', 'auto');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:body
|
||||
$objWriter->startElement('office:body');
|
||||
// office:text
|
||||
$objWriter->startElement('office:text');
|
||||
// text:sequence-decls
|
||||
$objWriter->startElement('text:sequence-decls');
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Illustration');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Table');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Text');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Drawing');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$_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) {
|
||||
// We firstly search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
$numPStyles = 0;
|
||||
$numFStyles = 0;
|
||||
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
$pStyle = $element->getParagraphStyle();
|
||||
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
$numFStyles++;
|
||||
|
||||
$arrStyle = array(
|
||||
'color' => $fStyle->getColor(),
|
||||
'name' => $fStyle->getName()
|
||||
);
|
||||
$pPHPWord->addFontStyle('T' . $numFStyles, $arrStyle);
|
||||
$element->setFontStyle('T' . $numFStyles);
|
||||
} elseif ($pStyle instanceof PHPWord_Style_Paragraph) {
|
||||
$numPStyles++;
|
||||
|
||||
$pPHPWord->addParagraphStyle('P' . $numPStyles, array());
|
||||
$element->setParagraph('P' . $numPStyles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// office:font-face-decls
|
||||
$objWriter->startElement('office:font-face-decls');
|
||||
$arrFonts = array();
|
||||
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if (!in_array($name, $arrFonts)) {
|
||||
$arrFonts[] = $name;
|
||||
|
||||
// style:font-face
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', $name);
|
||||
$objWriter->writeAttribute('svg:font-family', $name);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array('Arial', $arrFonts)) {
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('office:automatic-styles');
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
if (preg_match('#^T[0-9]+$#', $styleName) != 0
|
||||
|| preg_match('#^P[0-9]+$#', $styleName) != 0
|
||||
) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'text');
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('fo:color', '#' . $style->getColor());
|
||||
$objWriter->writeAttribute('style:font-name', $style->getName());
|
||||
$objWriter->writeAttribute('style:font-name-complex', $style->getName());
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($style instanceof PHPWord_Style_Paragraph) {
|
||||
$numPStyles++;
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
$objWriter->writeAttribute('style:parent-style-name', 'Standard');
|
||||
$objWriter->writeAttribute('style:master-page-name', 'Standard');
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('style:page-number', 'auto');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($numPStyles == 0) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', 'P1');
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
$objWriter->writeAttribute('style:parent-style-name', 'Standard');
|
||||
$objWriter->writeAttribute('style:master-page-name', 'Standard');
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('style:page-number', 'auto');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:body
|
||||
$objWriter->startElement('office:body');
|
||||
// office:text
|
||||
$objWriter->startElement('office:text');
|
||||
// text:sequence-decls
|
||||
$objWriter->startElement('text:sequence-decls');
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Illustration');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Table');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Text');
|
||||
$objWriter->endElement();
|
||||
// text:sequence-decl
|
||||
$objWriter->startElement('text:sequence-decl');
|
||||
$objWriter->writeAttribute('text:display-outline-level', 0);
|
||||
$objWriter->writeAttribute('text:name', 'Drawing');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$_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) {
|
||||
}*/ 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);
|
||||
|
|
@ -276,70 +271,71 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
} elseif($element instanceof PHPWord_TOC) {
|
||||
$this->_writeTOC($objWriter);
|
||||
}*/
|
||||
else {
|
||||
print_r($element);
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if($pSection == $countSections) {
|
||||
$this->_writeEndSection($objWriter, $section);
|
||||
} else {
|
||||
$this->_writeSection($objWriter, $section);
|
||||
}
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
else {
|
||||
print_r($element);
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) {
|
||||
$styleFont = $text->getFontStyle();
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
if($SfIsObject) {
|
||||
// Don't never be the case, because I browse all sections for cleaning all styles not declared
|
||||
die('PHPWord : $SfIsObject wouldn\'t be an object');
|
||||
}
|
||||
else {
|
||||
// text:p
|
||||
$objWriter->startElement('text:p');
|
||||
if(empty($styleFont)){
|
||||
if(empty($styleParagraph)){
|
||||
$objWriter->writeAttribute('text:style-name', 'P1');
|
||||
}
|
||||
else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
$objWriter->writeRaw($text->getText());
|
||||
}
|
||||
else {
|
||||
if(empty($styleParagraph)){
|
||||
$objWriter->writeAttribute('text:style-name', 'Standard');
|
||||
}
|
||||
else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
// text:span
|
||||
$objWriter->startElement('text:span');
|
||||
$objWriter->writeAttribute('text:style-name', $styleFont);
|
||||
$objWriter->writeRaw($text->getText());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
$objWriter->startElement('text:p');
|
||||
$objWriter->writeAttribute('text:style-name', 'Standard');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) {
|
||||
}
|
||||
if ($pSection == $countSections) {
|
||||
$this->_writeEndSection($objWriter, $section);
|
||||
} else {
|
||||
$this->_writeSection($objWriter, $section);
|
||||
}
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false)
|
||||
{
|
||||
$styleFont = $text->getFontStyle();
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
if ($SfIsObject) {
|
||||
// Don't never be the case, because I browse all sections for cleaning all styles not declared
|
||||
die('PHPWord : $SfIsObject wouldn\'t be an object');
|
||||
} else {
|
||||
// text:p
|
||||
$objWriter->startElement('text:p');
|
||||
if (empty($styleFont)) {
|
||||
if (empty($styleParagraph)) {
|
||||
$objWriter->writeAttribute('text:style-name', 'P1');
|
||||
} else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
$objWriter->writeRaw($text->getText());
|
||||
} else {
|
||||
if (empty($styleParagraph)) {
|
||||
$objWriter->writeAttribute('text:style-name', 'Standard');
|
||||
} else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
// text:span
|
||||
$objWriter->startElement('text:span');
|
||||
$objWriter->writeAttribute('text:style-name', $styleFont);
|
||||
$objWriter->writeRaw($text->getText());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->startElement('text:p');
|
||||
$objWriter->writeAttribute('text:style-name', 'Standard');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,113 +19,108 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_Manifest
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_Manifest
|
||||
*/
|
||||
class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write Manifest file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeManifest(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Write Manifest file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeManifest(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// manifest:manifest
|
||||
$objWriter->startElement('manifest:manifest');
|
||||
$objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
|
||||
$objWriter->writeAttribute('manifest:version', '1.2');
|
||||
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text');
|
||||
$objWriter->writeAttribute('manifest:version', '1.2');
|
||||
$objWriter->writeAttribute('manifest:full-path', '/');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'content.xml');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'meta.xml');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'styles.xml');
|
||||
$objWriter->endElement();
|
||||
|
||||
for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
|
||||
$objWriter->endElement();
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
// manifest:manifest
|
||||
$objWriter->startElement('manifest:manifest');
|
||||
$objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
|
||||
$objWriter->writeAttribute('manifest:version', '1.2');
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text');
|
||||
$objWriter->writeAttribute('manifest:version', '1.2');
|
||||
$objWriter->writeAttribute('manifest:full-path', '/');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'content.xml');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'meta.xml');
|
||||
$objWriter->endElement();
|
||||
// manifest:file-entry
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
|
||||
$objWriter->writeAttribute('manifest:full-path', 'styles.xml');
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPWord_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||
$mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
|
||||
$objWriter->endElement();
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPWord_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,80 +19,76 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_Meta
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_Meta
|
||||
*/
|
||||
class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write Meta file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeMeta(PHPWord $pPHPWord = null) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Write Meta file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeMeta(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// office:document-meta
|
||||
$objWriter->startElement('office:document-meta');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
// office:meta
|
||||
$objWriter->startElement('office:meta');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
|
||||
// dc:date
|
||||
$objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000' ,$pPHPWord->getProperties()->getModified()));
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
|
||||
// meta:creation-date
|
||||
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000' ,$pPHPWord->getProperties()->getCreated()));
|
||||
// meta:initial-creator
|
||||
$objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
|
||||
// meta:keyword
|
||||
$objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
|
||||
|
||||
// @todo : Where these properties are written ?
|
||||
// $pPHPWord->getProperties()->getCategory()
|
||||
// $pPHPWord->getProperties()->getCompany()
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
// office:document-meta
|
||||
$objWriter->startElement('office:document-meta');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// office:meta
|
||||
$objWriter->startElement('office:meta');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
|
||||
// dc:date
|
||||
$objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getModified()));
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
|
||||
// meta:creation-date
|
||||
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $pPHPWord->getProperties()->getCreated()));
|
||||
// meta:initial-creator
|
||||
$objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
|
||||
// meta:keyword
|
||||
$objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
|
||||
|
||||
// @todo : Where these properties are written ?
|
||||
// $pPHPWord->getProperties()->getCategory()
|
||||
// $pPHPWord->getProperties()->getCompany()
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,33 +19,28 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_Mimetype
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_Mimetype
|
||||
*/
|
||||
class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write Mimetype to Text format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string Text Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeMimetype(PHPWord $pPHPWord = null)
|
||||
{
|
||||
|
||||
return 'application/vnd.oasis.opendocument.text';
|
||||
}
|
||||
/**
|
||||
* Write Mimetype to Text format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string Text Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeMimetype(PHPWord $pPHPWord = null)
|
||||
{
|
||||
|
||||
return 'application/vnd.oasis.opendocument.text';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,256 +19,250 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_Styles
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_Styles
|
||||
*/
|
||||
class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write Styles file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeStyles(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Write Styles file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeStyles(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// Styles:Styles
|
||||
$objWriter->startElement('office:document-styles');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
|
||||
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
|
||||
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
|
||||
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
|
||||
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
|
||||
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
|
||||
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
|
||||
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
|
||||
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
|
||||
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
|
||||
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
|
||||
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
|
||||
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
|
||||
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
|
||||
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
|
||||
// office:font-face-decls
|
||||
$objWriter->startElement('office:font-face-decls');
|
||||
$arrFonts = array();
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if(!in_array($name, $arrFonts)){
|
||||
$arrFonts[] = $name;
|
||||
|
||||
// style:font-face
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', $name);
|
||||
$objWriter->writeAttribute('svg:font-family', $name);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!in_array('Arial', $arrFonts)){
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:styles
|
||||
$objWriter->startElement('office:styles');
|
||||
// Styles:Styles
|
||||
$objWriter->startElement('office:document-styles');
|
||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
|
||||
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
|
||||
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
|
||||
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
|
||||
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
|
||||
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
|
||||
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
|
||||
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
|
||||
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
|
||||
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
|
||||
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
|
||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
|
||||
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
|
||||
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
|
||||
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
|
||||
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
|
||||
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
|
||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
|
||||
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
|
||||
$objWriter->writeAttribute('office:version', '1.2');
|
||||
|
||||
// style:default-style
|
||||
$objWriter->startElement('style:default-style');
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
|
||||
$objWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
|
||||
$objWriter->writeAttribute('style:punctuation-wrap', 'hanging');
|
||||
$objWriter->writeAttribute('style:line-break', 'strict');
|
||||
$objWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
|
||||
$objWriter->writeAttribute('style:writing-mode', 'page');
|
||||
$objWriter->endElement();
|
||||
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('style:use-window-font-color', 'true');
|
||||
$objWriter->writeAttribute('style:font-name', 'Arial');
|
||||
$objWriter->writeAttribute('fo:font-size', '10pt');
|
||||
$objWriter->writeAttribute('fo:language', 'fr');
|
||||
$objWriter->writeAttribute('fo:country', 'FR');
|
||||
$objWriter->writeAttribute('style:letter-kerning', 'true');
|
||||
$objWriter->writeAttribute('style:font-name-asian', 'Arial2');
|
||||
$objWriter->writeAttribute('style:font-size-asian', '10pt');
|
||||
$objWriter->writeAttribute('style:language-asian', 'zh');
|
||||
$objWriter->writeAttribute('style:country-asian', 'CN');
|
||||
$objWriter->writeAttribute('style:font-name-complex', 'Arial2');
|
||||
$objWriter->writeAttribute('style:font-size-complex', '10pt');
|
||||
$objWriter->writeAttribute('style:language-complex', 'hi');
|
||||
$objWriter->writeAttribute('style:country-complex', 'IN');
|
||||
$objWriter->writeAttribute('fo:hyphenate', 'false');
|
||||
$objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
||||
$objWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if(preg_match('#^T[0-9]+$#', $styleName) == 0
|
||||
&& preg_match('#^P[0-9]+$#', $styleName) == 0){
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'text');
|
||||
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('fo:font-size', ($style->getSize() / 2).'pt');
|
||||
$objWriter->writeAttribute('style:font-size-asian', ($style->getSize() / 2).'pt');
|
||||
$objWriter->writeAttribute('style:font-size-complex', ($style->getSize() / 2).'pt');
|
||||
if($style->getItalic()) {
|
||||
$objWriter->writeAttribute('fo:font-style', 'italic');
|
||||
$objWriter->writeAttribute('style:font-style-asian', 'italic');
|
||||
$objWriter->writeAttribute('style:font-style-complex', 'italic');
|
||||
}
|
||||
if($style->getBold()) {
|
||||
$objWriter->writeAttribute('fo:font-weight', 'bold');
|
||||
$objWriter->writeAttribute('style:font-weight-asian', 'bold');
|
||||
}
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
// PHPWord_Style_Paragraph
|
||||
elseif($style instanceof PHPWord_Style_Paragraph) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
|
||||
//style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)).'cm');
|
||||
$objWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)).'cm');
|
||||
$objWriter->writeAttribute('fo:text-align', $style->getAlign());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
}
|
||||
// PHPWord_Style_TableFull
|
||||
elseif($style instanceof PHPWord_Style_TableFull) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:automatic-styles
|
||||
$objWriter->startElement('office:automatic-styles');
|
||||
// style:page-layout
|
||||
$objWriter->startElement('style:page-layout');
|
||||
$objWriter->writeAttribute('style:name', 'Mpm1');
|
||||
// style:page-layout-properties
|
||||
$objWriter->startElement('style:page-layout-properties');
|
||||
$objWriter->writeAttribute('fo:page-width', "21.001cm");
|
||||
$objWriter->writeAttribute('fo:page-height','29.7cm');
|
||||
$objWriter->writeAttribute('style:num-format','1');
|
||||
$objWriter->writeAttribute('style:print-orientation','portrait');
|
||||
$objWriter->writeAttribute('fo:margin-top','2.501cm');
|
||||
$objWriter->writeAttribute('fo:margin-bottom','2cm');
|
||||
$objWriter->writeAttribute('fo:margin-left','2.501cm');
|
||||
$objWriter->writeAttribute('fo:margin-right','2.501cm');
|
||||
$objWriter->writeAttribute('style:writing-mode','lr-tb');
|
||||
$objWriter->writeAttribute('style:layout-grid-color','#c0c0c0');
|
||||
$objWriter->writeAttribute('style:layout-grid-lines','25199');
|
||||
$objWriter->writeAttribute('style:layout-grid-base-height','0.423cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-ruby-height','0cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-mode','none');
|
||||
$objWriter->writeAttribute('style:layout-grid-ruby-below','false');
|
||||
$objWriter->writeAttribute('style:layout-grid-print','false');
|
||||
$objWriter->writeAttribute('style:layout-grid-display','false');
|
||||
$objWriter->writeAttribute('style:layout-grid-base-width','0.37cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-snap-to','true');
|
||||
$objWriter->writeAttribute('style:footnote-max-height','0cm');
|
||||
//style:footnote-sep
|
||||
$objWriter->startElement('style:footnote-sep');
|
||||
$objWriter->writeAttribute('style:width', '0.018cm');
|
||||
$objWriter->writeAttribute('style:line-style','solid');
|
||||
$objWriter->writeAttribute('style:adjustment','left');
|
||||
$objWriter->writeAttribute('style:rel-width','25%');
|
||||
$objWriter->writeAttribute('style:color','#000000');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
// style:header-style
|
||||
$objWriter->startElement('style:header-style');
|
||||
$objWriter->endElement();
|
||||
// style:footer-style
|
||||
$objWriter->startElement('style:footer-style');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:master-styles
|
||||
$objWriter->startElement('office:master-styles');
|
||||
// style:master-page
|
||||
$objWriter->startElement('style:master-page');
|
||||
$objWriter->writeAttribute('style:name', 'Standard');
|
||||
$objWriter->writeAttribute('style:page-layout-name', 'Mpm1');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
// office:font-face-decls
|
||||
$objWriter->startElement('office:font-face-decls');
|
||||
$arrFonts = array();
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if (!in_array($name, $arrFonts)) {
|
||||
$arrFonts[] = $name;
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// style:font-face
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', $name);
|
||||
$objWriter->writeAttribute('svg:font-family', $name);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!in_array('Arial', $arrFonts)) {
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:styles
|
||||
$objWriter->startElement('office:styles');
|
||||
|
||||
// style:default-style
|
||||
$objWriter->startElement('style:default-style');
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
|
||||
// style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
|
||||
$objWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
|
||||
$objWriter->writeAttribute('style:punctuation-wrap', 'hanging');
|
||||
$objWriter->writeAttribute('style:line-break', 'strict');
|
||||
$objWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
|
||||
$objWriter->writeAttribute('style:writing-mode', 'page');
|
||||
$objWriter->endElement();
|
||||
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('style:use-window-font-color', 'true');
|
||||
$objWriter->writeAttribute('style:font-name', 'Arial');
|
||||
$objWriter->writeAttribute('fo:font-size', '10pt');
|
||||
$objWriter->writeAttribute('fo:language', 'fr');
|
||||
$objWriter->writeAttribute('fo:country', 'FR');
|
||||
$objWriter->writeAttribute('style:letter-kerning', 'true');
|
||||
$objWriter->writeAttribute('style:font-name-asian', 'Arial2');
|
||||
$objWriter->writeAttribute('style:font-size-asian', '10pt');
|
||||
$objWriter->writeAttribute('style:language-asian', 'zh');
|
||||
$objWriter->writeAttribute('style:country-asian', 'CN');
|
||||
$objWriter->writeAttribute('style:font-name-complex', 'Arial2');
|
||||
$objWriter->writeAttribute('style:font-size-complex', '10pt');
|
||||
$objWriter->writeAttribute('style:language-complex', 'hi');
|
||||
$objWriter->writeAttribute('style:country-complex', 'IN');
|
||||
$objWriter->writeAttribute('fo:hyphenate', 'false');
|
||||
$objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
|
||||
$objWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
if (preg_match('#^T[0-9]+$#', $styleName) == 0
|
||||
&& preg_match('#^P[0-9]+$#', $styleName) == 0
|
||||
) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'text');
|
||||
|
||||
// style:text-properties
|
||||
$objWriter->startElement('style:text-properties');
|
||||
$objWriter->writeAttribute('fo:font-size', ($style->getSize() / 2) . 'pt');
|
||||
$objWriter->writeAttribute('style:font-size-asian', ($style->getSize() / 2) . 'pt');
|
||||
$objWriter->writeAttribute('style:font-size-complex', ($style->getSize() / 2) . 'pt');
|
||||
if ($style->getItalic()) {
|
||||
$objWriter->writeAttribute('fo:font-style', 'italic');
|
||||
$objWriter->writeAttribute('style:font-style-asian', 'italic');
|
||||
$objWriter->writeAttribute('style:font-style-complex', 'italic');
|
||||
}
|
||||
if ($style->getBold()) {
|
||||
$objWriter->writeAttribute('fo:font-weight', 'bold');
|
||||
$objWriter->writeAttribute('style:font-weight-asian', 'bold');
|
||||
}
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
} // PHPWord_Style_Paragraph
|
||||
elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
$objWriter->writeAttribute('style:family', 'paragraph');
|
||||
|
||||
//style:paragraph-properties
|
||||
$objWriter->startElement('style:paragraph-properties');
|
||||
$objWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm');
|
||||
$objWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm');
|
||||
$objWriter->writeAttribute('fo:text-align', $style->getAlign());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
} // PHPWord_Style_TableFull
|
||||
elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:automatic-styles
|
||||
$objWriter->startElement('office:automatic-styles');
|
||||
// style:page-layout
|
||||
$objWriter->startElement('style:page-layout');
|
||||
$objWriter->writeAttribute('style:name', 'Mpm1');
|
||||
// style:page-layout-properties
|
||||
$objWriter->startElement('style:page-layout-properties');
|
||||
$objWriter->writeAttribute('fo:page-width', "21.001cm");
|
||||
$objWriter->writeAttribute('fo:page-height', '29.7cm');
|
||||
$objWriter->writeAttribute('style:num-format', '1');
|
||||
$objWriter->writeAttribute('style:print-orientation', 'portrait');
|
||||
$objWriter->writeAttribute('fo:margin-top', '2.501cm');
|
||||
$objWriter->writeAttribute('fo:margin-bottom', '2cm');
|
||||
$objWriter->writeAttribute('fo:margin-left', '2.501cm');
|
||||
$objWriter->writeAttribute('fo:margin-right', '2.501cm');
|
||||
$objWriter->writeAttribute('style:writing-mode', 'lr-tb');
|
||||
$objWriter->writeAttribute('style:layout-grid-color', '#c0c0c0');
|
||||
$objWriter->writeAttribute('style:layout-grid-lines', '25199');
|
||||
$objWriter->writeAttribute('style:layout-grid-base-height', '0.423cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-ruby-height', '0cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-mode', 'none');
|
||||
$objWriter->writeAttribute('style:layout-grid-ruby-below', 'false');
|
||||
$objWriter->writeAttribute('style:layout-grid-print', 'false');
|
||||
$objWriter->writeAttribute('style:layout-grid-display', 'false');
|
||||
$objWriter->writeAttribute('style:layout-grid-base-width', '0.37cm');
|
||||
$objWriter->writeAttribute('style:layout-grid-snap-to', 'true');
|
||||
$objWriter->writeAttribute('style:footnote-max-height', '0cm');
|
||||
//style:footnote-sep
|
||||
$objWriter->startElement('style:footnote-sep');
|
||||
$objWriter->writeAttribute('style:width', '0.018cm');
|
||||
$objWriter->writeAttribute('style:line-style', 'solid');
|
||||
$objWriter->writeAttribute('style:adjustment', 'left');
|
||||
$objWriter->writeAttribute('style:rel-width', '25%');
|
||||
$objWriter->writeAttribute('style:color', '#000000');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
// style:header-style
|
||||
$objWriter->startElement('style:header-style');
|
||||
$objWriter->endElement();
|
||||
// style:footer-style
|
||||
$objWriter->startElement('style:footer-style');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// office:master-styles
|
||||
$objWriter->startElement('office:master-styles');
|
||||
// style:master-page
|
||||
$objWriter->startElement('style:master-page');
|
||||
$objWriter->writeAttribute('style:name', 'Standard');
|
||||
$objWriter->writeAttribute('style:page-layout-name', 'Mpm1');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,50 +19,47 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPWord_Writer_ODText_WriterPart
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_ODText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* Class PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
abstract class PHPWord_Writer_ODText_WriterPart
|
||||
{
|
||||
/**
|
||||
* Parent IWriter object
|
||||
*
|
||||
* @var PHPWord_Writer_IWriter
|
||||
*/
|
||||
private $_parentWriter;
|
||||
/**
|
||||
* Parent IWriter object
|
||||
*
|
||||
* @var PHPWord_Writer_IWriter
|
||||
*/
|
||||
private $_parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPWord_Writer_IWriter $pWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPWord_Writer_IWriter $pWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
|
||||
{
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent IWriter object
|
||||
*
|
||||
* @return PHPWord_Writer_IWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getParentWriter() {
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPWord_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get parent IWriter object
|
||||
*
|
||||
* @return PHPWord_Writer_IWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPWord_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -19,292 +19,305 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Writer_RTF
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_RTF
|
||||
*/
|
||||
class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Private PHPWord
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
/**
|
||||
* Private unique PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPWord_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
private $_colorTable;
|
||||
private $_fontTable;
|
||||
private $_lastParagraphStyle;
|
||||
|
||||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Assign PHPWord
|
||||
$this->setPHPWord($pPHPWord);
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPWord_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Private PHPWord
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
$hFile = fopen($pFilename, 'w') or die("can't open file");
|
||||
fwrite($hFile, $this->_getData());
|
||||
fclose($hFile);
|
||||
/**
|
||||
* Private unique PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPWord_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord() {
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
throw new Exception("No PHPWord assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null) {
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
private function _getData(){
|
||||
// PHPWord object : $this->_document
|
||||
$this->_fontTable = $this->_getDataFont();
|
||||
$this->_colorTable = $this->_getDataColor();
|
||||
|
||||
$sRTFContent = '{\rtf1';
|
||||
// Set the default character set
|
||||
$sRTFContent .= '\ansi\ansicpg1252';
|
||||
// Set the default font (the first one)
|
||||
$sRTFContent .= '\deff0';
|
||||
// Set the default tab size (720 twips)
|
||||
$sRTFContent .= '\deftab720';
|
||||
// Set the font tbl group
|
||||
$sRTFContent .= '{\fonttbl';
|
||||
foreach ($this->_fontTable as $idx => $font){
|
||||
$sRTFContent .= '{\f'.$idx.'\fnil\fcharset0 '.$font.';}';
|
||||
}
|
||||
$sRTFContent .= '}'.PHP_EOL;
|
||||
// Set the color tbl group
|
||||
$sRTFContent .= '{\colortbl ';
|
||||
foreach ($this->_colorTable as $idx => $color){
|
||||
$arrColor = PHPWord_Shared_Drawing::htmlToRGB($color);
|
||||
$sRTFContent .= ';\red'.$arrColor[0].'\green'.$arrColor[1].'\blue'.$arrColor[2].'';
|
||||
}
|
||||
$sRTFContent .= ';}'.PHP_EOL;
|
||||
// Set the generator
|
||||
$sRTFContent .= '{\*\generator PHPWord;}';
|
||||
// Set the view mode of the document
|
||||
$sRTFContent .= '\viewkind4';
|
||||
// Set the numberof bytes that follows a unicode character
|
||||
$sRTFContent .= '\uc1';
|
||||
// Resets to default paragraph properties.
|
||||
$sRTFContent .= '\pard';
|
||||
// No widow/orphan control
|
||||
$sRTFContent .= '\nowidctlpar';
|
||||
// Applies a language to a text run (1036 : French (France))
|
||||
$sRTFContent .= '\lang1036';
|
||||
// Point size (in half-points) above which to kern character pairs
|
||||
$sRTFContent .= '\kerning1';
|
||||
// Set the font size in half-points
|
||||
$sRTFContent .= '\fs20';
|
||||
// Body
|
||||
$sRTFContent .= $this->_getDataContent();
|
||||
|
||||
|
||||
$sRTFContent .= '}';
|
||||
|
||||
return $sRTFContent;
|
||||
}
|
||||
private function _getDataFont(){
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrFonts = array();
|
||||
// Default font : Arial
|
||||
$arrFonts[] = 'Arial';
|
||||
// PHPWord object : $this->_document
|
||||
|
||||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
if(in_array($style->getName(), $arrFonts) == FALSE){
|
||||
$arrFonts[] = $style->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if($fStyle instanceof PHPWord_Style_Font){
|
||||
if(in_array($fStyle->getName(), $arrFonts) == FALSE){
|
||||
$arrFonts[] = $fStyle->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arrFonts;
|
||||
}
|
||||
private function _getDataColor(){
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrColors = array();
|
||||
// PHPWord object : $this->_document
|
||||
|
||||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
$color = $style->getColor();
|
||||
$fgcolor = $style->getFgColor();
|
||||
if(in_array($color, $arrColors) == FALSE && $color != '000000' && !empty($color)){
|
||||
$arrColors[] = $color;
|
||||
}
|
||||
if(in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)){
|
||||
$arrColors[] = $fgcolor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if($fStyle instanceof PHPWord_Style_Font){
|
||||
if(in_array($fStyle->getColor(), $arrColors) == FALSE){
|
||||
$arrColors[] = $fStyle->getColor();
|
||||
}
|
||||
if(in_array($fStyle->getFgColor(), $arrColors) == FALSE){
|
||||
$arrColors[] = $fStyle->getFgColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arrColors;
|
||||
}
|
||||
private function _getDataContent(){
|
||||
$pPHPWord = $this->_document;
|
||||
$sRTFBody = '';
|
||||
|
||||
$_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) {
|
||||
$sRTFBody .= $this->_getDataContent_writeText($element);
|
||||
}/* elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
private $_colorTable;
|
||||
private $_fontTable;
|
||||
private $_lastParagraphStyle;
|
||||
|
||||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Assign PHPWord
|
||||
$this->setPHPWord($pPHPWord);
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPWord_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
$hFile = fopen($pFilename, 'w') or die("can't open file");
|
||||
fwrite($hFile, $this->_getData());
|
||||
fclose($hFile);
|
||||
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord()
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
throw new Exception("No PHPWord assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
{
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
private function _getData()
|
||||
{
|
||||
// PHPWord object : $this->_document
|
||||
$this->_fontTable = $this->_getDataFont();
|
||||
$this->_colorTable = $this->_getDataColor();
|
||||
|
||||
$sRTFContent = '{\rtf1';
|
||||
// Set the default character set
|
||||
$sRTFContent .= '\ansi\ansicpg1252';
|
||||
// Set the default font (the first one)
|
||||
$sRTFContent .= '\deff0';
|
||||
// Set the default tab size (720 twips)
|
||||
$sRTFContent .= '\deftab720';
|
||||
// Set the font tbl group
|
||||
$sRTFContent .= '{\fonttbl';
|
||||
foreach ($this->_fontTable as $idx => $font) {
|
||||
$sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}';
|
||||
}
|
||||
$sRTFContent .= '}' . PHP_EOL;
|
||||
// Set the color tbl group
|
||||
$sRTFContent .= '{\colortbl ';
|
||||
foreach ($this->_colorTable as $idx => $color) {
|
||||
$arrColor = PHPWord_Shared_Drawing::htmlToRGB($color);
|
||||
$sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . '';
|
||||
}
|
||||
$sRTFContent .= ';}' . PHP_EOL;
|
||||
// Set the generator
|
||||
$sRTFContent .= '{\*\generator PHPWord;}';
|
||||
// Set the view mode of the document
|
||||
$sRTFContent .= '\viewkind4';
|
||||
// Set the numberof bytes that follows a unicode character
|
||||
$sRTFContent .= '\uc1';
|
||||
// Resets to default paragraph properties.
|
||||
$sRTFContent .= '\pard';
|
||||
// No widow/orphan control
|
||||
$sRTFContent .= '\nowidctlpar';
|
||||
// Applies a language to a text run (1036 : French (France))
|
||||
$sRTFContent .= '\lang1036';
|
||||
// Point size (in half-points) above which to kern character pairs
|
||||
$sRTFContent .= '\kerning1';
|
||||
// Set the font size in half-points
|
||||
$sRTFContent .= '\fs20';
|
||||
// Body
|
||||
$sRTFContent .= $this->_getDataContent();
|
||||
|
||||
|
||||
$sRTFContent .= '}';
|
||||
|
||||
return $sRTFContent;
|
||||
}
|
||||
|
||||
private function _getDataFont()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrFonts = array();
|
||||
// Default font : Arial
|
||||
$arrFonts[] = 'Arial';
|
||||
// PHPWord object : $this->_document
|
||||
|
||||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
if (in_array($style->getName(), $arrFonts) == FALSE) {
|
||||
$arrFonts[] = $style->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getName(), $arrFonts) == FALSE) {
|
||||
$arrFonts[] = $fStyle->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arrFonts;
|
||||
}
|
||||
|
||||
private function _getDataColor()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrColors = array();
|
||||
// PHPWord object : $this->_document
|
||||
|
||||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$color = $style->getColor();
|
||||
$fgcolor = $style->getFgColor();
|
||||
if (in_array($color, $arrColors) == FALSE && $color != '000000' && !empty($color)) {
|
||||
$arrColors[] = $color;
|
||||
}
|
||||
if (in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)) {
|
||||
$arrColors[] = $fgcolor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getColor(), $arrColors) == FALSE) {
|
||||
$arrColors[] = $fStyle->getColor();
|
||||
}
|
||||
if (in_array($fStyle->getFgColor(), $arrColors) == FALSE) {
|
||||
$arrColors[] = $fStyle->getFgColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arrColors;
|
||||
}
|
||||
|
||||
private function _getDataContent()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
$sRTFBody = '';
|
||||
|
||||
$_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) {
|
||||
$sRTFBody .= $this->_getDataContent_writeText($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) {
|
||||
$sRTFBody .= $this->_getDataContent_writeTextBreak();
|
||||
}/* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
}*/
|
||||
elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$sRTFBody .= $this->_getDataContent_writeTextBreak();
|
||||
} /* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
$this->_writePageBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
|
|
@ -318,106 +331,108 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
} elseif($element instanceof PHPWord_TOC) {
|
||||
$this->_writeTOC($objWriter);
|
||||
}*/
|
||||
else {
|
||||
print_r($element);
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sRTFBody;
|
||||
}
|
||||
private function _getDataContent_writeText(PHPWord_Section_Text $text){
|
||||
$sRTFText = '';
|
||||
|
||||
$styleFont = $text->getFontStyle();
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
if(!$SfIsObject) {
|
||||
$styleFont = PHPWord_Style::getStyle($styleFont);
|
||||
}
|
||||
else {
|
||||
print_r($element);
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sRTFBody;
|
||||
}
|
||||
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
if(!$SpIsObject) {
|
||||
$styleParagraph = PHPWord_Style::getStyle($styleParagraph);
|
||||
}
|
||||
|
||||
if($styleParagraph){
|
||||
if($this->_lastParagraphStyle != $text->getParagraphStyle()){
|
||||
$sRTFText .= '\pard\nowidctlpar';
|
||||
if($styleParagraph->getSpaceAfter() != null){
|
||||
$sRTFText .= '\sa'.$styleParagraph->getSpaceAfter();
|
||||
}
|
||||
if($styleParagraph->getAlign() != null){
|
||||
if($styleParagraph->getAlign() == 'center'){
|
||||
$sRTFText .= '\qc';
|
||||
}
|
||||
}
|
||||
$this->_lastParagraphStyle = $text->getParagraphStyle();
|
||||
}
|
||||
else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
|
||||
if($styleFont){
|
||||
if($styleFont->getColor() != null){
|
||||
$idxColor = array_search($styleFont->getColor(), $this->_colorTable);
|
||||
if($idxColor !== FALSE){
|
||||
$sRTFText .= '\cf'.($idxColor+1);
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\cf0';
|
||||
}
|
||||
if($styleFont->getName() != null){
|
||||
$idxFont = array_search($styleFont->getName(), $this->_fontTable);
|
||||
if($idxFont !== FALSE){
|
||||
$sRTFText .= '\f'.$idxFont;
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\f0';
|
||||
}
|
||||
if($styleFont->getBold()){
|
||||
$sRTFText .= '\b';
|
||||
}
|
||||
if($styleFont->getBold()){
|
||||
$sRTFText .= '\i';
|
||||
}
|
||||
if($styleFont->getSize()){
|
||||
$sRTFText .= '\fs'.$styleFont->getSize();
|
||||
}
|
||||
}
|
||||
if($this->_lastParagraphStyle != '' || $styleFont){
|
||||
$sRTFText .= ' ';
|
||||
}
|
||||
$sRTFText .= $text->getText();
|
||||
|
||||
if($styleFont){
|
||||
$sRTFText .= '\cf0';
|
||||
$sRTFText .= '\f0';
|
||||
|
||||
if($styleFont->getBold()){
|
||||
$sRTFText .= '\b0';
|
||||
}
|
||||
if($styleFont->getItalic()){
|
||||
$sRTFText .= '\i0';
|
||||
}
|
||||
if($styleFont->getSize()){
|
||||
$sRTFText .= '\fs20';
|
||||
}
|
||||
}
|
||||
|
||||
$sRTFText .= '\par'.PHP_EOL;
|
||||
return $sRTFText;
|
||||
}
|
||||
private function _getDataContent_writeTextBreak(){
|
||||
$this->_lastParagraphStyle = '';
|
||||
|
||||
return '\par'.PHP_EOL;
|
||||
}
|
||||
private function _getDataContent_writeText(PHPWord_Section_Text $text)
|
||||
{
|
||||
$sRTFText = '';
|
||||
|
||||
$styleFont = $text->getFontStyle();
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
if (!$SfIsObject) {
|
||||
$styleFont = PHPWord_Style::getStyle($styleFont);
|
||||
}
|
||||
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
if (!$SpIsObject) {
|
||||
$styleParagraph = PHPWord_Style::getStyle($styleParagraph);
|
||||
}
|
||||
|
||||
if ($styleParagraph) {
|
||||
if ($this->_lastParagraphStyle != $text->getParagraphStyle()) {
|
||||
$sRTFText .= '\pard\nowidctlpar';
|
||||
if ($styleParagraph->getSpaceAfter() != null) {
|
||||
$sRTFText .= '\sa' . $styleParagraph->getSpaceAfter();
|
||||
}
|
||||
if ($styleParagraph->getAlign() != null) {
|
||||
if ($styleParagraph->getAlign() == 'center') {
|
||||
$sRTFText .= '\qc';
|
||||
}
|
||||
}
|
||||
$this->_lastParagraphStyle = $text->getParagraphStyle();
|
||||
} else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
} else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
|
||||
if ($styleFont) {
|
||||
if ($styleFont->getColor() != null) {
|
||||
$idxColor = array_search($styleFont->getColor(), $this->_colorTable);
|
||||
if ($idxColor !== FALSE) {
|
||||
$sRTFText .= '\cf' . ($idxColor + 1);
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\cf0';
|
||||
}
|
||||
if ($styleFont->getName() != null) {
|
||||
$idxFont = array_search($styleFont->getName(), $this->_fontTable);
|
||||
if ($idxFont !== FALSE) {
|
||||
$sRTFText .= '\f' . $idxFont;
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\f0';
|
||||
}
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\b';
|
||||
}
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\i';
|
||||
}
|
||||
if ($styleFont->getSize()) {
|
||||
$sRTFText .= '\fs' . $styleFont->getSize();
|
||||
}
|
||||
}
|
||||
if ($this->_lastParagraphStyle != '' || $styleFont) {
|
||||
$sRTFText .= ' ';
|
||||
}
|
||||
$sRTFText .= $text->getText();
|
||||
|
||||
if ($styleFont) {
|
||||
$sRTFText .= '\cf0';
|
||||
$sRTFText .= '\f0';
|
||||
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\b0';
|
||||
}
|
||||
if ($styleFont->getItalic()) {
|
||||
$sRTFText .= '\i0';
|
||||
}
|
||||
if ($styleFont->getSize()) {
|
||||
$sRTFText .= '\fs20';
|
||||
}
|
||||
}
|
||||
|
||||
$sRTFText .= '\par' . PHP_EOL;
|
||||
return $sRTFText;
|
||||
}
|
||||
|
||||
private function _getDataContent_writeTextBreak()
|
||||
{
|
||||
$this->_lastParagraphStyle = '';
|
||||
|
||||
return '\par' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,221 +20,229 @@
|
|||
*
|
||||
* @category 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
|
||||
* @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 $_diskCachingDirectory;
|
||||
private $_useDiskCaching = false;
|
||||
private $_imageTypes = array();
|
||||
private $_objectTypes = array();
|
||||
|
||||
public function __construct(PHPWord $PHPWord = null) {
|
||||
$this->_document = $PHPWord;
|
||||
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
$this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes();
|
||||
$this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels();
|
||||
$this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps();
|
||||
$this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels();
|
||||
$this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document();
|
||||
$this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles();
|
||||
$this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
|
||||
$this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
|
||||
|
||||
foreach($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pFilename = null) {
|
||||
if(!is_null($this->_document)) {
|
||||
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if(strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sectionElements = array();
|
||||
$_secElements = PHPWord_Media::getSectionMediaElements();
|
||||
foreach($_secElements as $element) { // loop through section media elements
|
||||
if($element['type'] != 'hyperlink') {
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
$sectionElements[] = $element;
|
||||
}
|
||||
|
||||
$_hdrElements = PHPWord_Media::getHeaderMediaElements();
|
||||
foreach($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers
|
||||
if(count($_hdrMedia) > 0) {
|
||||
$objZip->addFromString('word/_rels/'.$_headerFile.'.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia));
|
||||
foreach($_hdrMedia as $element) { // loop through header media elements
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_ftrElements = PHPWord_Media::getFooterMediaElements();
|
||||
foreach($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers
|
||||
if(count($_ftrMedia) > 0) {
|
||||
$objZip->addFromString('word/_rels/'.$_footerFile.'.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia));
|
||||
foreach($_ftrMedia as $element) { // loop through footers media elements
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$_cHdrs = 0;
|
||||
$_cFtrs = 0;
|
||||
$rID = PHPWord_Media::countSectionMediaElements() + 6;
|
||||
$_sections = $this->_document->getSections();
|
||||
|
||||
foreach($_sections as $section) {
|
||||
$_headers = $section->getHeaders();
|
||||
foreach ($_headers as $index => &$_header) {
|
||||
$_cHdrs++;
|
||||
$_header->setRelationId(++$rID);
|
||||
$_headerFile = 'header'.$_cHdrs.'.xml';
|
||||
$sectionElements[] = array('target'=>$_headerFile, 'type'=>'header', 'rID'=>$rID);
|
||||
$objZip->addFromString('word/'.$_headerFile, $this->getWriterPart('header')->writeHeader($_header));
|
||||
}
|
||||
|
||||
$_footer = $section->getFooter();
|
||||
if(!is_null($_footer)) {
|
||||
$_cFtrs++;
|
||||
$_footer->setRelationId(++$rID);
|
||||
$_footerCount = $_footer->getFooterCount();
|
||||
$_footerFile = 'footer'.$_footerCount.'.xml';
|
||||
$sectionElements[] = array('target'=>$_footerFile, 'type'=>'footer', 'rID'=>$rID);
|
||||
$objZip->addFromString('word/'.$_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
|
||||
}
|
||||
}
|
||||
|
||||
// build docx file
|
||||
// Write dynamic files
|
||||
private $_document;
|
||||
private $_writerParts;
|
||||
private $_diskCachingDirectory;
|
||||
private $_useDiskCaching = false;
|
||||
private $_imageTypes = array();
|
||||
private $_objectTypes = array();
|
||||
|
||||
public function __construct(PHPWord $PHPWord = null)
|
||||
{
|
||||
$this->_document = $PHPWord;
|
||||
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
$this->_writerParts['contenttypes'] = new PHPWord_Writer_Word2007_ContentTypes();
|
||||
$this->_writerParts['rels'] = new PHPWord_Writer_Word2007_Rels();
|
||||
$this->_writerParts['docprops'] = new PHPWord_Writer_Word2007_DocProps();
|
||||
$this->_writerParts['documentrels'] = new PHPWord_Writer_Word2007_DocumentRels();
|
||||
$this->_writerParts['document'] = new PHPWord_Writer_Word2007_Document();
|
||||
$this->_writerParts['styles'] = new PHPWord_Writer_Word2007_Styles();
|
||||
$this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
|
||||
$this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
|
||||
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sectionElements = array();
|
||||
$_secElements = PHPWord_Media::getSectionMediaElements();
|
||||
foreach ($_secElements as $element) { // loop through section media elements
|
||||
if ($element['type'] != 'hyperlink') {
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
$sectionElements[] = $element;
|
||||
}
|
||||
|
||||
$_hdrElements = PHPWord_Media::getHeaderMediaElements();
|
||||
foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers
|
||||
if (count($_hdrMedia) > 0) {
|
||||
$objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia));
|
||||
foreach ($_hdrMedia as $element) { // loop through header media elements
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_ftrElements = PHPWord_Media::getFooterMediaElements();
|
||||
foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers
|
||||
if (count($_ftrMedia) > 0) {
|
||||
$objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia));
|
||||
foreach ($_ftrMedia as $element) { // loop through footers media elements
|
||||
$this->_addFileToPackage($objZip, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$_cHdrs = 0;
|
||||
$_cFtrs = 0;
|
||||
$rID = PHPWord_Media::countSectionMediaElements() + 6;
|
||||
$_sections = $this->_document->getSections();
|
||||
|
||||
foreach ($_sections as $section) {
|
||||
$_headers = $section->getHeaders();
|
||||
foreach ($_headers as $index => &$_header) {
|
||||
$_cHdrs++;
|
||||
$_header->setRelationId(++$rID);
|
||||
$_headerFile = 'header' . $_cHdrs . '.xml';
|
||||
$sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID);
|
||||
$objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header));
|
||||
}
|
||||
|
||||
$_footer = $section->getFooter();
|
||||
if (!is_null($_footer)) {
|
||||
$_cFtrs++;
|
||||
$_footer->setRelationId(++$rID);
|
||||
$_footerCount = $_footer->getFooterCount();
|
||||
$_footerFile = 'footer' . $_footerCount . '.xml';
|
||||
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
|
||||
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
|
||||
}
|
||||
}
|
||||
|
||||
// build docx file
|
||||
// Write dynamic files
|
||||
$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('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($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/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements));
|
||||
$objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($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/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($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/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document));
|
||||
|
||||
// Write static files
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
|
||||
|
||||
|
||||
// Close file
|
||||
if($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/numbering.xml', 'word/numbering.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/settings.xml', 'word/settings.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml');
|
||||
$objZip->addFile(PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml');
|
||||
|
||||
// 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) {
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
// 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)
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,166 +20,173 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_ContentTypes
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart {
|
||||
|
||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Types
|
||||
$objWriter->startElement('Types');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
// Types
|
||||
$objWriter->startElement('Types');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
);
|
||||
|
||||
// Add media content-types
|
||||
foreach($_imageTypes as $key => $value) {
|
||||
$this->_writeDefaultContentType($objWriter, $key, $value);
|
||||
}
|
||||
|
||||
// Add embedding content-types
|
||||
if(count($_objectTypes) > 0) {
|
||||
$this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject');
|
||||
}
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
// Document
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||
);
|
||||
|
||||
// Styles
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||
);
|
||||
|
||||
// Numbering
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||
);
|
||||
|
||||
// Settings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||
);
|
||||
|
||||
// Theme1
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// WebSettings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||
);
|
||||
|
||||
// Font Table
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
);
|
||||
// Add media content-types
|
||||
foreach ($_imageTypes as $key => $value) {
|
||||
$this->_writeDefaultContentType($objWriter, $key, $value);
|
||||
}
|
||||
|
||||
for($i=1; $i<=$_cHdrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/header'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
);
|
||||
}
|
||||
|
||||
for($i=1; $i<=$_cFtrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/footer'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
// Add embedding content-types
|
||||
if (count($_objectTypes) > 0) {
|
||||
$this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject');
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '') {
|
||||
if(PHPWord_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') {
|
||||
if($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
// Document
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') {
|
||||
if($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
// Styles
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||
);
|
||||
|
||||
// Numbering
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||
);
|
||||
|
||||
// Settings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||
);
|
||||
|
||||
// Theme1
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// WebSettings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||
);
|
||||
|
||||
// Font Table
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
);
|
||||
|
||||
for ($i = 1; $i <= $_cHdrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $_cFtrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPWord_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,161 +20,166 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_DocProps
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart {
|
||||
public function writeDocPropsApp(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
|
||||
public function writeDocPropsApp(PHPWord $pPHPWord = null) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
// Application
|
||||
$objWriter->writeElement('Application', 'Microsoft Office Word');
|
||||
|
||||
// Application
|
||||
$objWriter->writeElement('Application', 'Microsoft Office Word');
|
||||
// ScaleCrop
|
||||
$objWriter->writeElement('ScaleCrop', 'false');
|
||||
|
||||
// ScaleCrop
|
||||
$objWriter->writeElement('ScaleCrop', 'false');
|
||||
// HeadingPairs
|
||||
$objWriter->startElement('HeadingPairs');
|
||||
|
||||
// HeadingPairs
|
||||
$objWriter->startElement('HeadingPairs');
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '4');
|
||||
$objWriter->writeAttribute('baseType', 'variant');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '4');
|
||||
$objWriter->writeAttribute('baseType', 'variant');
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Theme');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Theme');
|
||||
$objWriter->endElement();
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Slide Titles');
|
||||
$objWriter->endElement();
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Slide Titles');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// TitlesOfParts
|
||||
$objWriter->startElement('TitlesOfParts');
|
||||
// TitlesOfParts
|
||||
$objWriter->startElement('TitlesOfParts');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '1');
|
||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '1');
|
||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||
|
||||
$objWriter->writeElement('vt:lpstr', 'Office Theme');
|
||||
$objWriter->writeElement('vt:lpstr', 'Office Theme');
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// Company
|
||||
$objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany());
|
||||
// Company
|
||||
$objWriter->writeElement('Company', $pPHPWord->getProperties()->getCompany());
|
||||
|
||||
// LinksUpToDate
|
||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||
// LinksUpToDate
|
||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||
|
||||
// SharedDoc
|
||||
$objWriter->writeElement('SharedDoc', 'false');
|
||||
// SharedDoc
|
||||
$objWriter->writeElement('SharedDoc', 'false');
|
||||
|
||||
// HyperlinksChanged
|
||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||
// HyperlinksChanged
|
||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||
|
||||
// AppVersion
|
||||
$objWriter->writeElement('AppVersion', '12.0000');
|
||||
// AppVersion
|
||||
$objWriter->writeElement('AppVersion', '12.0000');
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
|
||||
public function writeDocPropsCore(PHPWord $pPHPWord = null) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
public function writeDocPropsCore(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator());
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator());
|
||||
|
||||
// cp:lastModifiedBy
|
||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy());
|
||||
// cp:lastModifiedBy
|
||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy());
|
||||
|
||||
// dcterms:created
|
||||
$objWriter->startElement('dcterms:created');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated()));
|
||||
$objWriter->endElement();
|
||||
// dcterms:created
|
||||
$objWriter->startElement('dcterms:created');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dcterms:modified
|
||||
$objWriter->startElement('dcterms:modified');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified()));
|
||||
$objWriter->endElement();
|
||||
// dcterms:modified
|
||||
$objWriter->startElement('dcterms:modified');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
|
||||
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
|
||||
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
|
||||
|
||||
// cp:keywords
|
||||
$objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords());
|
||||
// cp:keywords
|
||||
$objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords());
|
||||
|
||||
// cp:category
|
||||
$objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory());
|
||||
// cp:category
|
||||
$objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory());
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,439 +20,450 @@
|
|||
*
|
||||
* @category 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
|
||||
* @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) {
|
||||
// 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
|
||||
public function writeDocument(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
||||
// 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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
$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();
|
||||
// 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
|
||||
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();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
|
||||
$depth = $listItem->getDepth();
|
||||
$listType = $listItem->getStyle()->getListType();
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph, true);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:numPr');
|
||||
|
||||
$objWriter->startElement('w:ilvl');
|
||||
$objWriter->writeAttribute('w:val', $depth);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:numId');
|
||||
$objWriter->writeAttribute('w:val', $listType);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeText($objWriter, $textObject, true);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object) {
|
||||
$rIdObject = $object->getRelationId();
|
||||
$rIdImage = $object->getImageRelationId();
|
||||
$shapeId = md5($rIdObject.'_'.$rIdImage);
|
||||
|
||||
$objectId = $object->getObjectId();
|
||||
|
||||
$style = $object->getStyle();
|
||||
$width = $style->getWidth();
|
||||
$height = $style->getHeight();
|
||||
$align = $style->getAlign();
|
||||
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if(!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
$objWriter->startElement('w:object');
|
||||
$objWriter->writeAttribute('w:dxaOrig', '249');
|
||||
$objWriter->writeAttribute('w:dyaOrig', '160');
|
||||
|
||||
$objWriter->startElement('v:shape');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||
$objWriter->writeAttribute('style', 'width:104px;height:67px');
|
||||
$objWriter->writeAttribute('o:ole', '');
|
||||
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdImage);
|
||||
$objWriter->writeAttribute('o:title', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('o:OLEObject');
|
||||
$objWriter->writeAttribute('Type', 'Embed');
|
||||
$objWriter->writeAttribute('ProgID', 'Package');
|
||||
$objWriter->writeAttribute('ShapeID', $shapeId);
|
||||
$objWriter->writeAttribute('DrawAspect', 'Icon');
|
||||
$objWriter->writeAttribute('ObjectID', '_'.$objectId);
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdObject);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:r
|
||||
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
$titles = PHPWord_TOC::getTitles();
|
||||
$styleFont = PHPWord_TOC::getStyleFont();
|
||||
|
||||
$styleTOC = PHPWord_TOC::getStyleTOC();
|
||||
$fIndent = $styleTOC->getIndent();
|
||||
$tabLeader = $styleTOC->getTabLeader();
|
||||
$tabPos = $styleTOC->getTabPos();
|
||||
|
||||
$isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
for($i=0; $i<count($titles); $i++) {
|
||||
$title = $titles[$i];
|
||||
$indent = ($title['depth'] - 1) * $fIndent;
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
|
||||
}
|
||||
|
||||
if($indent > 0) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!empty($styleFont) && !$isObject) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:tabs');
|
||||
$objWriter->startElement('w:tab');
|
||||
$objWriter->writeAttribute('w:val', 'right');
|
||||
if(!empty($tabLeader)) {
|
||||
$objWriter->writeAttribute('w:leader', $tabLeader);
|
||||
}
|
||||
$objWriter->writeAttribute('w:pos', $tabPos);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:pPr
|
||||
|
||||
|
||||
if($i == 0) {
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:instrText');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRaw('TOC \o "1-9" \h \z \u');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$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:r');
|
||||
|
||||
if($isObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:t');
|
||||
$objWriter->writeRaw($title['text']);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->writeElement('w:tab', null);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:instrText');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRaw('PAGEREF '.$title['anchor'].' \h');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:hyperlink
|
||||
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$depth = $listItem->getDepth();
|
||||
$listType = $listItem->getStyle()->getListType();
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph, true);
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:numPr');
|
||||
|
||||
$objWriter->startElement('w:ilvl');
|
||||
$objWriter->writeAttribute('w:val', $depth);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:numId');
|
||||
$objWriter->writeAttribute('w:val', $listType);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeText($objWriter, $textObject, true);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object)
|
||||
{
|
||||
$rIdObject = $object->getRelationId();
|
||||
$rIdImage = $object->getImageRelationId();
|
||||
$shapeId = md5($rIdObject . '_' . $rIdImage);
|
||||
|
||||
$objectId = $object->getObjectId();
|
||||
|
||||
$style = $object->getStyle();
|
||||
$width = $style->getWidth();
|
||||
$height = $style->getHeight();
|
||||
$align = $style->getAlign();
|
||||
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
$objWriter->startElement('w:object');
|
||||
$objWriter->writeAttribute('w:dxaOrig', '249');
|
||||
$objWriter->writeAttribute('w:dyaOrig', '160');
|
||||
|
||||
$objWriter->startElement('v:shape');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||
$objWriter->writeAttribute('style', 'width:104px;height:67px');
|
||||
$objWriter->writeAttribute('o:ole', '');
|
||||
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rIdImage);
|
||||
$objWriter->writeAttribute('o:title', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('o:OLEObject');
|
||||
$objWriter->writeAttribute('Type', 'Embed');
|
||||
$objWriter->writeAttribute('ProgID', 'Package');
|
||||
$objWriter->writeAttribute('ShapeID', $shapeId);
|
||||
$objWriter->writeAttribute('DrawAspect', 'Icon');
|
||||
$objWriter->writeAttribute('ObjectID', '_' . $objectId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rIdObject);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:r
|
||||
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$titles = PHPWord_TOC::getTitles();
|
||||
$styleFont = PHPWord_TOC::getStyleFont();
|
||||
|
||||
$styleTOC = PHPWord_TOC::getStyleTOC();
|
||||
$fIndent = $styleTOC->getIndent();
|
||||
$tabLeader = $styleTOC->getTabLeader();
|
||||
$tabPos = $styleTOC->getTabPos();
|
||||
|
||||
$isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
for ($i = 0; $i < count($titles); $i++) {
|
||||
$title = $titles[$i];
|
||||
$indent = ($title['depth'] - 1) * $fIndent;
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
|
||||
}
|
||||
|
||||
if ($indent > 0) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if (!empty($styleFont) && !$isObject) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:tabs');
|
||||
$objWriter->startElement('w:tab');
|
||||
$objWriter->writeAttribute('w:val', 'right');
|
||||
if (!empty($tabLeader)) {
|
||||
$objWriter->writeAttribute('w:leader', $tabLeader);
|
||||
}
|
||||
$objWriter->writeAttribute('w:pos', $tabPos);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:pPr
|
||||
|
||||
|
||||
if ($i == 0) {
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:instrText');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRaw('TOC \o "1-9" \h \z \u');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$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:r');
|
||||
|
||||
if ($isObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:t');
|
||||
$objWriter->writeRaw($title['text']);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->writeElement('w:tab', null);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:instrText');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement(); // w:hyperlink
|
||||
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'end');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,158 +20,163 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_DocumentRels
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart {
|
||||
|
||||
public function writeDocumentRels($_relsCollection) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||
'styles.xml'
|
||||
);
|
||||
|
||||
// Relationship word/numbering.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
||||
'numbering.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
||||
'settings.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
4,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
5,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
||||
'webSettings.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
6,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
||||
'fontTable.xml'
|
||||
);
|
||||
|
||||
// Relationships to Images / Embeddings / Headers / Footers
|
||||
foreach($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType,
|
||||
$relationName,
|
||||
$targetMode
|
||||
);
|
||||
}
|
||||
|
||||
public function writeDocumentRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
public function writeHeaderFooterRels($_relsCollection) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationships to Images / Embeddings / Headers / Footers
|
||||
foreach($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType,
|
||||
$relationName
|
||||
);
|
||||
}
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
$objWriter->endElement();
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||
'styles.xml'
|
||||
);
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') {
|
||||
if($pType != '' && $pTarget != '') {
|
||||
if(strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
// Relationship word/numbering.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
||||
'numbering.xml'
|
||||
);
|
||||
|
||||
if($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
||||
'settings.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
4,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
5,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
||||
'webSettings.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
6,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
||||
'fontTable.xml'
|
||||
);
|
||||
|
||||
// Relationships to Images / Embeddings / Headers / Footers
|
||||
foreach ($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
$relationName,
|
||||
$targetMode
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
public function writeHeaderFooterRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationships to Images / Embeddings / Headers / Footers
|
||||
foreach ($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
$relationName
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
if (strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,60 +20,64 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Footer
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base {
|
||||
|
||||
public function writeFooter(PHPWord_Section_Footer $footer) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
$objWriter->startElement('w:ftr');
|
||||
$objWriter->writeAttribute('xmlns:ve','http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||
$objWriter->writeAttribute('xmlns:o','urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:r','http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:m','http://schemas.openxmlformats.org/officeDocument/2006/math');
|
||||
$objWriter->writeAttribute('xmlns:v','urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:wp','http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
||||
$objWriter->writeAttribute('xmlns:w10','urn:schemas-microsoft-com:office:word');
|
||||
$objWriter->writeAttribute('xmlns:w','http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:wne','http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
$_elements = $footer->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
public function writeFooter(PHPWord_Section_Footer $footer)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
|
||||
$objWriter->startElement('w:ftr');
|
||||
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
|
||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
||||
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
|
||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
$_elements = $footer->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage
|
||||
) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,64 +20,68 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Header
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base {
|
||||
|
||||
public function writeHeader(PHPWord_Section_Header $header) {
|
||||
// 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');
|
||||
|
||||
$objWriter->startElement('w:hdr');
|
||||
$objWriter->writeAttribute('xmlns:ve','http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||
$objWriter->writeAttribute('xmlns:o','urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:r','http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:m','http://schemas.openxmlformats.org/officeDocument/2006/math');
|
||||
$objWriter->writeAttribute('xmlns:v','urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:wp','http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
||||
$objWriter->writeAttribute('xmlns:w10','urn:schemas-microsoft-com:office:word');
|
||||
$objWriter->writeAttribute('xmlns:w','http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:wne','http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
|
||||
$_elements = $header->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
if(!$element->getIsWatermark()) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} else {
|
||||
$this->_writeWatermark($objWriter, $element);
|
||||
}
|
||||
} elseif($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
public function writeHeader(PHPWord_Section_Header $header)
|
||||
{
|
||||
// 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');
|
||||
|
||||
$objWriter->startElement('w:hdr');
|
||||
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
|
||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
|
||||
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
|
||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
|
||||
$_elements = $header->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage
|
||||
) {
|
||||
if (!$element->getIsWatermark()) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} else {
|
||||
$this->_writeWatermark($objWriter, $element);
|
||||
}
|
||||
} elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,91 +20,96 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Rels
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart {
|
||||
|
||||
public function writeRelationships(PHPWord $pPHPWord = null) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
public function writeRelationships(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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');
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
$relationId = 1;
|
||||
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
'word/document.xml'
|
||||
);
|
||||
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
'docProps/core.xml'
|
||||
);
|
||||
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
'docProps/app.xml'
|
||||
);
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
$objWriter->endElement();
|
||||
$relationId = 1;
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
// Relationship word/document.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
'word/document.xml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pId Relationship ID. rId will be prepended!
|
||||
* @param string $pType Relationship type
|
||||
* @param string $pTarget Relationship target
|
||||
* @param string $pTargetMode Relationship target mode
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') {
|
||||
if($pType != '' && $pTarget != '') {
|
||||
if(strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
'docProps/core.xml'
|
||||
);
|
||||
|
||||
if($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
++$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
'docProps/app.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pId Relationship ID. rId will be prepended!
|
||||
* @param string $pType Relationship type
|
||||
* @param string $pTarget Relationship target
|
||||
* @param string $pTargetMode Relationship target mode
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
if (strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,327 +20,333 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Styles
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
||||
|
||||
private $_document;
|
||||
|
||||
public function writeStyles(PHPWord $pPHPWord = null) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
|
||||
$this->_document = $pPHPWord;
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
$objWriter->startElement('w:styles');
|
||||
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
|
||||
// Write DocDefaults
|
||||
$this->_writeDocDefaults($objWriter);
|
||||
private $_document;
|
||||
|
||||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
|
||||
$paragraphStyle = $style->getParagraphStyle();
|
||||
$styleType = $style->getStyleType();
|
||||
|
||||
$type = ($styleType == 'title') ? 'paragraph' : 'character';
|
||||
|
||||
if(!is_null($paragraphStyle)) {
|
||||
$type = 'paragraph';
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
if($styleType == 'title') {
|
||||
$arrStyle = explode('_', $styleName);
|
||||
$styleId = 'Heading'.$arrStyle[1];
|
||||
$styleName = 'heading '.$arrStyle[1];
|
||||
$styleLink = 'Heading'.$arrStyle[1].'Char';
|
||||
$objWriter->writeAttribute('w:styleId', $styleId);
|
||||
|
||||
$objWriter->startElement('w:link');
|
||||
$objWriter->writeAttribute('w:val', $styleLink);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
if(!is_null($paragraphStyle)) {
|
||||
$this->_writeParagraphStyle($objWriter, $paragraphStyle);
|
||||
}
|
||||
|
||||
$this->_writeTextStyle($objWriter, $style);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif($style instanceof PHPWord_Style_Paragraph) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'paragraph');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
$objWriter->writeAttribute('w:styleId', $styleName);
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeParagraphStyle($objWriter, $style);
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif($style instanceof PHPWord_Style_TableFull) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'table');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
$objWriter->writeAttribute('w:styleId', $styleName);
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:uiPriority');
|
||||
$objWriter->writeAttribute('w:val', '99');
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeFullTableStyle($objWriter, $style);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement(); // w:styles
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style) {
|
||||
public function writeStyles(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
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);
|
||||
}
|
||||
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
$cellMargin = $style->getCellMargin();
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$bInsH = (!is_null($brdSz[4])) ? true : false;
|
||||
$bInsV = (!is_null($brdSz[5])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false;
|
||||
|
||||
$mTop = (!is_null($cellMargin[0])) ? true : false;
|
||||
$mLeft = (!is_null($cellMargin[1])) ? true : false;
|
||||
$mRight = (!is_null($cellMargin[2])) ? true : false;
|
||||
$mBottom = (!is_null($cellMargin[3])) ? true : false;
|
||||
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
|
||||
|
||||
$objWriter->startElement('w:tblPr');
|
||||
|
||||
if($margins) {
|
||||
$objWriter->startElement('w:tblCellMar');
|
||||
if($mTop) {
|
||||
echo $margins[0];
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[0]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[1]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[2]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[3]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($borders) {
|
||||
$objWriter->startElement('w:tblBorders');
|
||||
if($bTop) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bInsH) {
|
||||
$objWriter->startElement('w:insideH');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[4]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[4]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bInsV) {
|
||||
$objWriter->startElement('w:insideV');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[5]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[5]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
if(!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:tcPr');
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
$objWriter->writeAttribute('w:fill', $bgColor);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
// First Row
|
||||
$firstRow = $style->getFirstRow();
|
||||
if(!is_null($firstRow)) {
|
||||
$this->_writeRowStyle($objWriter, 'firstRow', $firstRow);
|
||||
}
|
||||
}
|
||||
|
||||
private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style) {
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
|
||||
|
||||
$objWriter->startElement('w:tblStylePr');
|
||||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
$objWriter->startElement('w:tcPr');
|
||||
if(!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
$objWriter->writeAttribute('w:fill', $bgColor);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:tcBorders');
|
||||
if($bTop) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($bBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
$fontName = $this->_document->getDefaultFontName();
|
||||
$fontSize = $this->_document->getDefaultFontSize();
|
||||
|
||||
$objWriter->startElement('w:docDefaults');
|
||||
$objWriter->startElement('w:rPrDefault');
|
||||
$objWriter->startElement('w:rPr');
|
||||
|
||||
$objWriter->startElement('w:rFonts');
|
||||
$objWriter->writeAttribute('w:ascii', $fontName);
|
||||
$objWriter->writeAttribute('w:hAnsi', $fontName);
|
||||
$objWriter->writeAttribute('w:eastAsia', $fontName);
|
||||
$objWriter->writeAttribute('w:cs', $fontName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:sz');
|
||||
$objWriter->writeAttribute('w:val', $fontSize);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:szCs');
|
||||
$objWriter->writeAttribute('w:val', $fontSize);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$this->_document = $pPHPWord;
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
$objWriter->startElement('w:styles');
|
||||
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
|
||||
// Write DocDefaults
|
||||
$this->_writeDocDefaults($objWriter);
|
||||
|
||||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
|
||||
$paragraphStyle = $style->getParagraphStyle();
|
||||
$styleType = $style->getStyleType();
|
||||
|
||||
$type = ($styleType == 'title') ? 'paragraph' : 'character';
|
||||
|
||||
if (!is_null($paragraphStyle)) {
|
||||
$type = 'paragraph';
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
if ($styleType == 'title') {
|
||||
$arrStyle = explode('_', $styleName);
|
||||
$styleId = 'Heading' . $arrStyle[1];
|
||||
$styleName = 'heading ' . $arrStyle[1];
|
||||
$styleLink = 'Heading' . $arrStyle[1] . 'Char';
|
||||
$objWriter->writeAttribute('w:styleId', $styleId);
|
||||
|
||||
$objWriter->startElement('w:link');
|
||||
$objWriter->writeAttribute('w:val', $styleLink);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
if (!is_null($paragraphStyle)) {
|
||||
$this->_writeParagraphStyle($objWriter, $paragraphStyle);
|
||||
}
|
||||
|
||||
$this->_writeTextStyle($objWriter, $style);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'paragraph');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
$objWriter->writeAttribute('w:styleId', $styleName);
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeParagraphStyle($objWriter, $style);
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'table');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
$objWriter->writeAttribute('w:styleId', $styleName);
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:uiPriority');
|
||||
$objWriter->writeAttribute('w:val', '99');
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeFullTableStyle($objWriter, $style);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement(); // w:styles
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
$cellMargin = $style->getCellMargin();
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$bInsH = (!is_null($brdSz[4])) ? true : false;
|
||||
$bInsV = (!is_null($brdSz[5])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false;
|
||||
|
||||
$mTop = (!is_null($cellMargin[0])) ? true : false;
|
||||
$mLeft = (!is_null($cellMargin[1])) ? true : false;
|
||||
$mRight = (!is_null($cellMargin[2])) ? true : false;
|
||||
$mBottom = (!is_null($cellMargin[3])) ? true : false;
|
||||
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
|
||||
|
||||
$objWriter->startElement('w:tblPr');
|
||||
|
||||
if ($margins) {
|
||||
$objWriter->startElement('w:tblCellMar');
|
||||
if ($mTop) {
|
||||
echo $margins[0];
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[0]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($mLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[1]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($mRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[2]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($mBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[3]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if ($borders) {
|
||||
$objWriter->startElement('w:tblBorders');
|
||||
if ($bTop) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bInsH) {
|
||||
$objWriter->startElement('w:insideH');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[4]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[4]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bInsV) {
|
||||
$objWriter->startElement('w:insideV');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[5]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[5]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
if (!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:tcPr');
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
$objWriter->writeAttribute('w:fill', $bgColor);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
// First Row
|
||||
$firstRow = $style->getFirstRow();
|
||||
if (!is_null($firstRow)) {
|
||||
$this->_writeRowStyle($objWriter, 'firstRow', $firstRow);
|
||||
}
|
||||
}
|
||||
|
||||
private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
|
||||
|
||||
$objWriter->startElement('w:tblStylePr');
|
||||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
$objWriter->startElement('w:tcPr');
|
||||
if (!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
$objWriter->writeAttribute('w:fill', $bgColor);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:tcBorders');
|
||||
if ($bTop) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if ($bBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$objWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$fontName = $this->_document->getDefaultFontName();
|
||||
$fontSize = $this->_document->getDefaultFontSize();
|
||||
|
||||
$objWriter->startElement('w:docDefaults');
|
||||
$objWriter->startElement('w:rPrDefault');
|
||||
$objWriter->startElement('w:rPr');
|
||||
|
||||
$objWriter->startElement('w:rFonts');
|
||||
$objWriter->writeAttribute('w:ascii', $fontName);
|
||||
$objWriter->writeAttribute('w:hAnsi', $fontName);
|
||||
$objWriter->writeAttribute('w:eastAsia', $fontName);
|
||||
$objWriter->writeAttribute('w:cs', $fontName);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:sz');
|
||||
$objWriter->writeAttribute('w:val', $fontSize);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:szCs');
|
||||
$objWriter->writeAttribute('w:val', $fontSize);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 PHPWord
|
||||
* Copyright (c) 2013 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,24 +20,29 @@
|
|||
*
|
||||
* @category 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
|
||||
* @version Beta 0.6.3, 08.07.2011
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract Class PHPWord_Writer_Word2007_WriterPart
|
||||
*/
|
||||
abstract class PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
private $_parentWriter;
|
||||
|
||||
abstract class PHPWord_Writer_Word2007_WriterPart {
|
||||
private $_parentWriter;
|
||||
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
public function getParentWriter() {
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPWord_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
|
||||
{
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPWord_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,92 @@
|
|||
# PHPWord - OpenXML - Read, Write and Create Word documents in PHP
|
||||
|
||||
PHPWord is a library written in PHP that create word documents.
|
||||
No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be opened by all major office software.
|
||||
No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be
|
||||
opened by all major office software.
|
||||
|
||||
## Want to contribute?
|
||||
Fork us!
|
||||
|
||||
## Requirements
|
||||
|
||||
* PHP version 5.3.0 or higher
|
||||
|
||||
## License
|
||||
PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md)
|
||||
PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md)
|
||||
|
||||
## Installation
|
||||
|
||||
It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add
|
||||
the following lines to your ``composer.json``.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"phpoffice/phpword": "dev-master"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The following is a basic example of the PHPWord library.
|
||||
|
||||
```php
|
||||
$PHPWord = new PHPWord();
|
||||
|
||||
// Every element you want to append to the word document is placed in a section. So you need a section:
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
// After creating a section, you can append elements:
|
||||
$section->addText('Hello world!');
|
||||
|
||||
// You can directly style your text by giving the addText function an array:
|
||||
$section->addText('Hello world! I am formatted.', array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
|
||||
|
||||
// If you often need the same style again you can create a user defined style to the word document
|
||||
// and give the addText function the name of the style:
|
||||
$PHPWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
|
||||
$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle');
|
||||
|
||||
// You can also putthe appended element to local object an call functions like this:
|
||||
$myTextElement = $section->addText('Hello World!');
|
||||
$myTextElement->setBold();
|
||||
$myTextElement->setName('Verdana');
|
||||
$myTextElement->setSize(22);
|
||||
|
||||
// At least write the document to webspace:
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('helloWorld.docx');
|
||||
```
|
||||
|
||||
## Images
|
||||
|
||||
You can add images easily using the following example.
|
||||
|
||||
```php
|
||||
$section = $PHPWord->createSection();
|
||||
$section->addImage('mars.jpg');
|
||||
```
|
||||
|
||||
Images settings include:
|
||||
* ``width`` width in pixels
|
||||
* ``height`` height in pixels
|
||||
* ``align`` image alignment, __left__, __right__ or __center__
|
||||
* ``marginTop`` top margin in inches, can be negative
|
||||
* ``marginLeft`` left margin in inches, can be negative
|
||||
* ``wrappingStyle`` can be inline, __square__, __tight__, __behind__, __infront__
|
||||
|
||||
To add an image with settings, consider the following example.
|
||||
|
||||
```php
|
||||
$section->addImage(
|
||||
'mars.jpg',
|
||||
array(
|
||||
'width' => 100,
|
||||
'height' => 100,
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => -1,
|
||||
wrappingStyle => 'behind'
|
||||
)
|
||||
);
|
||||
```
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
* @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-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
|
||||
|
|
@ -37,4 +37,5 @@ Fixed in branch for release 0.7 :
|
|||
- General: (Progi1984) - Basic CI with Travis
|
||||
- General: (Progi1984) - Added PHPWord_Exception and exception when could not copy the template
|
||||
- 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 support for image wrapping style
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "phpoffice/phpword",
|
||||
"description": "PHPWord - Read, Create and Write Word documents in PHP",
|
||||
"keywords": ["PHP","Word", "Writer", "docx","doc","rtf"],
|
||||
"keywords": ["PHP", "Word", "Writer", "docx", "doc", "rtf"],
|
||||
"homepage": "http://phpoffice.github.io",
|
||||
"type": "library",
|
||||
"license": "LGPL",
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
"name": "Franck Lefevre",
|
||||
"homepage": "http://blog.rootslabs.net"
|
||||
}
|
||||
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="test/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
<testsuites>
|
||||
<testsuite name="PHPWord Test Suite">
|
||||
<directory>./test/PHPWord/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
|
@ -49,4 +49,3 @@ echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 102
|
|||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
?>
|
||||
|
|
@ -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 done
|
||||
echo date('H:i:s') , ' Done writing file' , EOL;
|
||||
?>
|
||||
echo date('H:i:s') , ' Done writing file' , EOL;
|
||||
|
|
@ -50,4 +50,3 @@ for($i = 1; $i <= 10; $i++) {
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('AdvancedTable.docx');
|
||||
?>
|
||||
|
|
@ -23,4 +23,3 @@ for($r = 1; $r <= 10; $r++) { // Loop through rows
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('BasicTable.docx');
|
||||
?>
|
||||
|
|
@ -54,4 +54,3 @@ $section2->addText('Some text...');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('HeaderFooter.docx');
|
||||
?>
|
||||
|
|
@ -21,4 +21,3 @@ $section->addImage('_mars.jpg', array('width'=>100, 'height'=>100, 'align'=>'rig
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Image.docx');
|
||||
?>
|
||||
|
|
@ -21,4 +21,3 @@ $section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Link.docx');
|
||||
?>
|
||||
|
|
@ -44,4 +44,3 @@ $section->addListItem('List Item 7', 0, 'myOwnStyle', $listStyle, 'P-Style');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('ListItem.docx');
|
||||
?>
|
||||
|
|
@ -17,4 +17,3 @@ $section->addObject('_sheet.xls');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Object.docx');
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,4 +23,3 @@ $section->addText('This section uses other margins.');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Section.docx');
|
||||
?>
|
||||
|
|
@ -20,4 +20,3 @@ $document->setValue('weekday', date('l'));
|
|||
$document->setValue('time', date('H:i'));
|
||||
|
||||
$document->save('Solarsystem.docx');
|
||||
?>
|
||||
|
|
@ -29,4 +29,3 @@ $textrun->addLink('http://www.bing.com', null, 'NLink');
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Textrun.docx');
|
||||
?>
|
||||
|
|
@ -46,4 +46,3 @@ echo 'Note: The pagenumbers in the TOC doesnt refresh automatically.';
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('TitleTOC.docx');
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,4 +18,3 @@ $section->addText('The header reference to the current section includes a waterm
|
|||
// Save File
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save('Watermark.docx');
|
||||
?>
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPWord;
|
||||
use DOMDocument;
|
||||
|
||||
class TestHelper
|
||||
{
|
||||
/**
|
||||
* @param \PHPWord $PHPWord
|
||||
* @return \PHPWord\Tests\Doc
|
||||
*/
|
||||
public static function getDocument(PHPWord $PHPWord)
|
||||
{
|
||||
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save(__DIR__ . '/Tests/_files/test.docx');
|
||||
|
||||
$zip = new \ZipArchive;
|
||||
$res = $zip->open(__DIR__ . '/Tests/_files/test.docx');
|
||||
if ($res === true) {
|
||||
$zip->extractTo(__DIR__ . '/Tests/_files/test/');
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return new Doc(__DIR__ . '/Tests/_files/test/');
|
||||
}
|
||||
|
||||
public static function clear()
|
||||
{
|
||||
unlink(__DIR__ . '/Tests/_files/test.docx');
|
||||
self::deleteDir(__DIR__ . '/Tests/_files/test/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
*/
|
||||
public static function deleteDir($dir)
|
||||
{
|
||||
foreach (scandir($dir) as $file) {
|
||||
if ($file === '.' || $file === '..') {
|
||||
continue;
|
||||
} else if (is_file($dir . "/" . $file)) {
|
||||
unlink($dir . "/" . $file);
|
||||
} else if (is_dir($dir . "/" . $file)) {
|
||||
self::deleteDir($dir . "/" . $file);
|
||||
}
|
||||
}
|
||||
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
class Doc
|
||||
{
|
||||
/** @var string $path */
|
||||
private $path;
|
||||
|
||||
/** @var \DOMDocument $dom */
|
||||
private $dom;
|
||||
|
||||
/** @var \DOMXpath $xpath */
|
||||
private $xpath;
|
||||
|
||||
/** @var string $file */
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = realpath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getFileDom($file = 'word/document.xml')
|
||||
{
|
||||
if (null !== $this->dom && $file === $this->file) {
|
||||
return $this->dom;
|
||||
}
|
||||
|
||||
$this->xpath = null;
|
||||
$this->file = $file;
|
||||
|
||||
$file = $this->path . '/' . $file;
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->load($file);
|
||||
return $this->dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $file
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function getElement($path, $file = 'word/document.xml')
|
||||
{
|
||||
if ($this->dom === null || $file !== $this->file) {
|
||||
$this->getFileDom($file);
|
||||
}
|
||||
|
||||
if (null === $this->xpath) {
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
|
||||
}
|
||||
|
||||
$elements = $this->xpath->query($path);
|
||||
return $elements->item(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord_Autoloader;
|
||||
|
||||
class AutoloaderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAutoload()
|
||||
{
|
||||
$this->assertNull(PHPWord_Autoloader::load('Foo'), 'PHPWord_Autoloader::load() is trying to load classes outside of the PHPWord namespace');
|
||||
$this->assertTrue(PHPWord_Autoloader::load('PHPWord'), 'PHPWord_Autoloader::load() failed to autoload the PHPWord class');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord;
|
||||
|
||||
class ImageTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function tearDown()
|
||||
{
|
||||
TestHelper::clear();
|
||||
}
|
||||
|
||||
public function testImageWrappingStyleBehind()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection(12240, 15840, 0, 0, 0, 0);
|
||||
|
||||
$section->addImage(
|
||||
__DIR__ . '/_files/images/earth.jpg',
|
||||
array(
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => -1,
|
||||
'wrappingStyle' => 'behind'
|
||||
)
|
||||
);
|
||||
|
||||
$doc = TestHelper::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape');
|
||||
|
||||
$style = $element->getAttribute('style');
|
||||
|
||||
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
|
||||
$this->assertRegExp('/position:absolute;/', $style);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
require_once __DIR__ . "/../Classes/PHPWord/Autoloader.php";
|
||||
PHPWord_Autoloader::Register();
|
||||
|
||||
require_once __DIR__ . "/PHPWord/TestHelper.php";
|
||||
Loading…
Reference in New Issue