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,9 +1,18 @@
|
|||
|
||||
.DS_Store
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Thumbs.db
|
||||
Desktop.ini
|
||||
.idea
|
||||
phpunit.xml
|
||||
composer.lock
|
||||
composer.phar
|
||||
vendor
|
||||
/.settings
|
||||
/.buildpath
|
||||
/.project
|
||||
/docs
|
||||
|
||||
*.odt
|
||||
*.docx
|
||||
*.rtf
|
||||
|
|
|
|||
|
|
@ -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,12 +35,9 @@ if(!defined('PHPWORD_BASE_PATH')) {
|
|||
|
||||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord {
|
||||
class PHPWord
|
||||
{
|
||||
|
||||
/**
|
||||
* Document properties
|
||||
|
|
@ -74,7 +71,8 @@ class PHPWord {
|
|||
/**
|
||||
* Create a new PHPWord Document
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_properties = new PHPWord_DocumentProperties();
|
||||
$this->_defaultFontName = 'Arial';
|
||||
$this->_defaultFontSize = 20;
|
||||
|
|
@ -84,7 +82,8 @@ class PHPWord {
|
|||
* Get properties
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function getProperties() {
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->_properties;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +93,8 @@ class PHPWord {
|
|||
* @param PHPWord_DocumentProperties $value
|
||||
* @return PHPWord
|
||||
*/
|
||||
public function setProperties(PHPWord_DocumentProperties $value) {
|
||||
public function setProperties(PHPWord_DocumentProperties $value)
|
||||
{
|
||||
$this->_properties = $value;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -105,7 +105,8 @@ class PHPWord {
|
|||
* @param PHPWord_Section_Settings $settings
|
||||
* @return PHPWord_Section
|
||||
*/
|
||||
public function createSection($settings = null) {
|
||||
public function createSection($settings = null)
|
||||
{
|
||||
$sectionCount = $this->_countSections() + 1;
|
||||
|
||||
$section = new PHPWord_Section($sectionCount, $settings);
|
||||
|
|
@ -117,7 +118,8 @@ class PHPWord {
|
|||
* Get default Font name
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultFontName() {
|
||||
public function getDefaultFontName()
|
||||
{
|
||||
return $this->_defaultFontName;
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +127,8 @@ class PHPWord {
|
|||
* Set default Font name
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setDefaultFontName($pValue) {
|
||||
public function setDefaultFontName($pValue)
|
||||
{
|
||||
$this->_defaultFontName = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +136,8 @@ class PHPWord {
|
|||
* Get default Font size
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultFontSize() {
|
||||
public function getDefaultFontSize()
|
||||
{
|
||||
return $this->_defaultFontSize;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +145,8 @@ class PHPWord {
|
|||
* Set default Font size
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDefaultFontSize($pValue) {
|
||||
public function setDefaultFontSize($pValue)
|
||||
{
|
||||
$pValue = $pValue * 2;
|
||||
$this->_defaultFontSize = $pValue;
|
||||
}
|
||||
|
|
@ -152,7 +157,8 @@ class PHPWord {
|
|||
* @param $styleName string
|
||||
* @param $styles array
|
||||
*/
|
||||
public function addParagraphStyle($styleName, $styles) {
|
||||
public function addParagraphStyle($styleName, $styles)
|
||||
{
|
||||
PHPWord_Style::addParagraphStyle($styleName, $styles);
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +168,8 @@ class PHPWord {
|
|||
* @param $styleName string
|
||||
* @param $styles array
|
||||
*/
|
||||
public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
|
||||
public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +179,8 @@ class PHPWord {
|
|||
* @param $styleName string
|
||||
* @param $styles array
|
||||
*/
|
||||
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
|
||||
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||
{
|
||||
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +190,8 @@ class PHPWord {
|
|||
* @param $titleCount int
|
||||
* @param $styles array
|
||||
*/
|
||||
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
|
||||
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +201,8 @@ class PHPWord {
|
|||
* @param $styleName string
|
||||
* @param $styles array
|
||||
*/
|
||||
public function addLinkStyle($styleName, $styles) {
|
||||
public function addLinkStyle($styleName, $styles)
|
||||
{
|
||||
PHPWord_Style::addLinkStyle($styleName, $styles);
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +210,8 @@ class PHPWord {
|
|||
* Get sections
|
||||
* @return PHPWord_Section[]
|
||||
*/
|
||||
public function getSections() {
|
||||
public function getSections()
|
||||
{
|
||||
return $this->_sectionCollection;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +219,8 @@ class PHPWord {
|
|||
* Get section count
|
||||
* @return int
|
||||
*/
|
||||
private function _countSections() {
|
||||
private function _countSections()
|
||||
{
|
||||
return count($this->_sectionCollection);
|
||||
}
|
||||
|
||||
|
|
@ -218,13 +230,13 @@ class PHPWord {
|
|||
* @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,20 +20,16 @@
|
|||
*
|
||||
* @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
|
||||
|
|
@ -108,7 +104,8 @@ class PHPWord_DocumentProperties {
|
|||
/**
|
||||
* Create new PHPWord_DocumentProperties
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_creator = '';
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
|
|
@ -126,7 +123,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
public function getCreator()
|
||||
{
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +134,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
public function setCreator($pValue = '')
|
||||
{
|
||||
$this->_creator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -146,7 +145,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
public function getLastModifiedBy()
|
||||
{
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
public function setLastModifiedBy($pValue = '')
|
||||
{
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -166,7 +167,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
public function getCreated()
|
||||
{
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +178,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
public function setCreated($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
|
|
@ -189,7 +192,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
public function getModified()
|
||||
{
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +203,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param datetime $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
public function setModified($pValue = null)
|
||||
{
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
|
|
@ -212,7 +217,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +228,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
public function setTitle($pValue = '')
|
||||
{
|
||||
$this->_title = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -232,7 +239,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +250,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
public function setDescription($pValue = '')
|
||||
{
|
||||
$this->_description = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -252,7 +261,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +272,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
public function setSubject($pValue = '')
|
||||
{
|
||||
$this->_subject = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -272,7 +283,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
public function getKeywords()
|
||||
{
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +294,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
public function setKeywords($pValue = '')
|
||||
{
|
||||
$this->_keywords = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -292,7 +305,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +316,8 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
public function setCategory($pValue = '')
|
||||
{
|
||||
$this->_category = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -312,7 +327,8 @@ class PHPWord_DocumentProperties {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany() {
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->_company;
|
||||
}
|
||||
|
||||
|
|
@ -322,9 +338,9 @@ class PHPWord_DocumentProperties {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '') {
|
||||
public function setCompany($pValue = '')
|
||||
{
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
|
|
@ -43,7 +39,8 @@ class PHPWord_Exception extends Exception {
|
|||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -69,7 +64,8 @@ class PHPWord_HashTable
|
|||
* @param PHPWord_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
public function addFromSource($pSource = null)
|
||||
{
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
|
|
@ -88,26 +84,27 @@ class PHPWord_HashTable
|
|||
* @param PHPWord_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPWord_IComparable $pSource = null) {
|
||||
public function add(PHPWord_IComparable $pSource = null)
|
||||
{
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if ( is_null ( $hashIndex ) ) {
|
||||
if (is_null($hashIndex)) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if ( isset ( $this->_keyMap[$hashIndex] ) ) {
|
||||
} 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;
|
||||
if (!isset($this->_items[$hashCode])) {
|
||||
$this->_items[$hashCode] = $pSource;
|
||||
$index = count($this->_items) - 1;
|
||||
$this->_keyMap[ $index ] = $hashCode;
|
||||
$pSource->setHashIndex( $index );
|
||||
$this->_keyMap[$index] = $hashCode;
|
||||
$pSource->setHashIndex($index);
|
||||
} else {
|
||||
$pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() );
|
||||
$pSource->setHashIndex($this->_items[$hashCode]->getHashIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,9 +114,10 @@ class PHPWord_HashTable
|
|||
* @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) {
|
||||
|
|
@ -131,7 +129,7 @@ class PHPWord_HashTable
|
|||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +137,8 @@ class PHPWord_HashTable
|
|||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
public function clear()
|
||||
{
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
|
@ -149,7 +148,8 @@ class PHPWord_HashTable
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +159,8 @@ class PHPWord_HashTable
|
|||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
public function getIndexForHashCode($pHashCode = '')
|
||||
{
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
|
|
@ -170,9 +171,10 @@ class PHPWord_HashTable
|
|||
* @return PHPWord_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
public function getByIndex($pIndex = 0)
|
||||
{
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
return $this->getByHashCode($this->_keyMap[$pIndex]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -185,7 +187,8 @@ class PHPWord_HashTable
|
|||
* @return PHPWord_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
public function getByHashCode($pHashCode = '')
|
||||
{
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
|
@ -198,14 +201,16 @@ class PHPWord_HashTable
|
|||
*
|
||||
* @return PHPWord_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
public function toArray()
|
||||
{
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_IOFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* Search locations
|
||||
|
|
@ -56,14 +52,17 @@ class PHPWord_IOFactory {
|
|||
/**
|
||||
* Private constructor for PHPWord_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
public static function getSearchLocations()
|
||||
{
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +72,8 @@ class PHPWord_IOFactory {
|
|||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
public static function setSearchLocations($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
|
|
@ -88,8 +88,9 @@ class PHPWord_IOFactory {
|
|||
* @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 );
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '')
|
||||
{
|
||||
self::$_searchLocations[] = array('type' => $type, 'path' => $location, 'class' => $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -99,7 +100,8 @@ class PHPWord_IOFactory {
|
|||
* @param string $writerType Example: Word2007
|
||||
* @return PHPWord_Writer_IWriter
|
||||
*/
|
||||
public static function createWriter(PHPWord $PHPWord, $writerType = '') {
|
||||
public static function createWriter(PHPWord $PHPWord, $writerType = '')
|
||||
{
|
||||
$searchType = 'IWriter';
|
||||
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
|
|
@ -108,7 +110,7 @@ class PHPWord_IOFactory {
|
|||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
$instance = new $className($PHPWord);
|
||||
if(!is_null($instance)) {
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
@ -117,4 +119,3 @@ class PHPWord_IOFactory {
|
|||
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,29 +20,25 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Media
|
||||
{
|
||||
|
||||
/**
|
||||
* Section Media Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_sectionMedia = array('images'=>array(),
|
||||
'embeddings'=>array(),
|
||||
'links'=>array());
|
||||
private static $_sectionMedia = array('images' => array(),
|
||||
'embeddings' => array(),
|
||||
'links' => array());
|
||||
|
||||
/**
|
||||
* Header Media Elements
|
||||
|
|
@ -71,43 +67,43 @@ class PHPWord_Media {
|
|||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
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])) {
|
||||
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') {
|
||||
if ($type == 'image') {
|
||||
$cImg++;
|
||||
$inf = pathinfo($src);
|
||||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
|
||||
|
||||
if($isMemImage) {
|
||||
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
|
||||
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') {
|
||||
$file = $type . $cImg . '.' . strtolower($ext);
|
||||
} elseif ($type == 'oleObject') {
|
||||
$cObj++;
|
||||
$folder = 'embedding';
|
||||
$file = $type.$cObj.'.bin';
|
||||
$file = $type . $cObj . '.bin';
|
||||
}
|
||||
|
||||
$media['source'] = $src;
|
||||
|
|
@ -117,13 +113,13 @@ class PHPWord_Media {
|
|||
|
||||
self::$_sectionMedia[$key][$mediaId] = $media;
|
||||
|
||||
if($type == 'oleObject') {
|
||||
if ($type == 'oleObject') {
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
return $rID;
|
||||
}
|
||||
} else {
|
||||
if($type == 'oleObject') {
|
||||
if ($type == 'oleObject') {
|
||||
$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
|
||||
return array($rID, ++self::$_objectId);
|
||||
} else {
|
||||
|
|
@ -140,7 +136,8 @@ class PHPWord_Media {
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addSectionLinkElement($linkSrc) {
|
||||
public static function addSectionLinkElement($linkSrc)
|
||||
{
|
||||
$rID = self::countSectionMediaElements() + 7;
|
||||
|
||||
$link = array();
|
||||
|
|
@ -159,8 +156,9 @@ class PHPWord_Media {
|
|||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public static function getSectionMediaElements($key = null) {
|
||||
if(!is_null($key)) {
|
||||
public static function getSectionMediaElements($key = null)
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return self::$_sectionMedia[$key];
|
||||
} else {
|
||||
$arrImages = self::$_sectionMedia['images'];
|
||||
|
|
@ -176,8 +174,9 @@ class PHPWord_Media {
|
|||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countSectionMediaElements($key = null) {
|
||||
if(!is_null($key)) {
|
||||
public static function countSectionMediaElements($key = null)
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return count(self::$_sectionMedia[$key]);
|
||||
} else {
|
||||
$cImages = count(self::$_sectionMedia['images']);
|
||||
|
|
@ -194,15 +193,16 @@ class PHPWord_Media {
|
|||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null)
|
||||
{
|
||||
$mediaId = md5($src);
|
||||
$key = 'header'.$headerCount;
|
||||
$key = 'header' . $headerCount;
|
||||
|
||||
if(!array_key_exists($key, self::$_headerMedia)) {
|
||||
if (!array_key_exists($key, self::$_headerMedia)) {
|
||||
self::$_headerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
|
||||
if (!array_key_exists($mediaId, self::$_headerMedia[$key])) {
|
||||
$cImg = self::countHeaderMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
|
|
@ -211,21 +211,21 @@ class PHPWord_Media {
|
|||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if($isMemImage) {
|
||||
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
|
||||
if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image'.$cImg.'.'.strtolower($ext);
|
||||
$file = 'image' . $cImg . '.' . strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/'.$key.'_'.$file;
|
||||
$media['target'] = 'media/' . $key . '_' . $file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
|
|
@ -243,7 +243,8 @@ class PHPWord_Media {
|
|||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countHeaderMediaElements($key) {
|
||||
public static function countHeaderMediaElements($key)
|
||||
{
|
||||
return count(self::$_headerMedia[$key]);
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +253,8 @@ class PHPWord_Media {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getHeaderMediaElements() {
|
||||
public static function getHeaderMediaElements()
|
||||
{
|
||||
return self::$_headerMedia;
|
||||
}
|
||||
|
||||
|
|
@ -263,15 +265,16 @@ class PHPWord_Media {
|
|||
* @param string $src
|
||||
* @return int
|
||||
*/
|
||||
public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
|
||||
public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null)
|
||||
{
|
||||
$mediaId = md5($src);
|
||||
$key = 'footer'.$footerCount;
|
||||
$key = 'footer' . $footerCount;
|
||||
|
||||
if(!array_key_exists($key, self::$_footerMedia)) {
|
||||
if (!array_key_exists($key, self::$_footerMedia)) {
|
||||
self::$_footerMedia[$key] = array();
|
||||
}
|
||||
|
||||
if(!array_key_exists($mediaId, self::$_footerMedia[$key])) {
|
||||
if (!array_key_exists($mediaId, self::$_footerMedia[$key])) {
|
||||
$cImg = self::countFooterMediaElements($key);
|
||||
$rID = $cImg + 1;
|
||||
|
||||
|
|
@ -280,21 +283,21 @@ class PHPWord_Media {
|
|||
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
|
||||
|
||||
$media = array();
|
||||
if($isMemImage) {
|
||||
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
|
||||
if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
|
||||
$ext = 'jpg';
|
||||
}
|
||||
}
|
||||
$file = 'image'.$cImg.'.'.strtolower($ext);
|
||||
$file = 'image' . $cImg . '.' . strtolower($ext);
|
||||
|
||||
$media['source'] = $src;
|
||||
$media['target'] = 'media/'.$key.'_'.$file;
|
||||
$media['target'] = 'media/' . $key . '_' . $file;
|
||||
$media['type'] = 'image';
|
||||
$media['rID'] = $rID;
|
||||
|
||||
|
|
@ -312,7 +315,8 @@ class PHPWord_Media {
|
|||
* @param string $key
|
||||
* @return int
|
||||
*/
|
||||
public static function countFooterMediaElements($key) {
|
||||
public static function countFooterMediaElements($key)
|
||||
{
|
||||
return count(self::$_footerMedia[$key]);
|
||||
}
|
||||
|
||||
|
|
@ -321,8 +325,9 @@ class PHPWord_Media {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getFooterMediaElements() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section
|
||||
{
|
||||
|
||||
/**
|
||||
* Section count
|
||||
|
|
@ -77,14 +73,15 @@ class PHPWord_Section {
|
|||
* @param int $sectionCount
|
||||
* @param mixed $settings
|
||||
*/
|
||||
public function __construct($sectionCount, $settings = null) {
|
||||
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;
|
||||
if (!is_null($settings) && is_array($settings)) {
|
||||
foreach ($settings as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_settings->setSettingValue($key, $value);
|
||||
}
|
||||
|
|
@ -96,7 +93,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return PHPWord_Section_Settings
|
||||
*/
|
||||
public function getSettings() {
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->_settings;
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +106,9 @@ class PHPWord_Section {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($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);
|
||||
|
|
@ -126,12 +125,13 @@ class PHPWord_Section {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($linkSrc)){
|
||||
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)){
|
||||
if (!is_null($linkName)) {
|
||||
if (!PHPWord_Shared_String::IsUTF8($linkName)) {
|
||||
$linkName = utf8_encode($linkName);
|
||||
}
|
||||
}
|
||||
|
|
@ -149,8 +149,9 @@ class PHPWord_Section {
|
|||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
public function addTextBreak($count = 1)
|
||||
{
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +159,8 @@ class PHPWord_Section {
|
|||
/**
|
||||
* Add a PageBreak Element
|
||||
*/
|
||||
public function addPageBreak() {
|
||||
public function addPageBreak()
|
||||
{
|
||||
$this->_elementCollection[] = new PHPWord_Section_PageBreak();
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +170,8 @@ class PHPWord_Section {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table
|
||||
*/
|
||||
public function addTable($style = null) {
|
||||
public function addTable($style = null)
|
||||
{
|
||||
$table = new PHPWord_Section_Table('section', $this->_sectionCount, $style);
|
||||
$this->_elementCollection[] = $table;
|
||||
return $table;
|
||||
|
|
@ -184,8 +187,9 @@ class PHPWord_Section {
|
|||
* @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)){
|
||||
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);
|
||||
|
|
@ -200,21 +204,22 @@ class PHPWord_Section {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Object
|
||||
*/
|
||||
public function addObject($src, $style = null) {
|
||||
public function addObject($src, $style = null)
|
||||
{
|
||||
$object = new PHPWord_Section_Object($src, $style);
|
||||
|
||||
if(!is_null($object->getSource())) {
|
||||
if (!is_null($object->getSource())) {
|
||||
$inf = pathinfo($src);
|
||||
$ext = $inf['extension'];
|
||||
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||
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';
|
||||
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
|
||||
$iconSrc = $iconSrc . '_default.png';
|
||||
} else {
|
||||
$iconSrc .= '_'.$ext.'.png';
|
||||
$iconSrc .= '_' . $ext . '.png';
|
||||
}
|
||||
|
||||
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
||||
|
|
@ -240,10 +245,11 @@ class PHPWord_Section {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($src, $style = null) {
|
||||
public function addImage($src, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($src, $style);
|
||||
|
||||
if(!is_null($image->getSource())) {
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||
$image->setRelationId($rID);
|
||||
|
||||
|
|
@ -261,9 +267,10 @@ class PHPWord_Section {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_MemoryImage
|
||||
*/
|
||||
public function addMemoryImage($link, $style = null) {
|
||||
public function addMemoryImage($link, $style = null)
|
||||
{
|
||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||
if(!is_null($memoryImage->getSource())) {
|
||||
if (!is_null($memoryImage->getSource())) {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
||||
|
|
@ -281,7 +288,8 @@ class PHPWord_Section {
|
|||
* @param mixed $styleTOC
|
||||
* @return PHPWord_TOC
|
||||
*/
|
||||
public function addTOC($styleFont = null, $styleTOC = null) {
|
||||
public function addTOC($styleFont = null, $styleTOC = null)
|
||||
{
|
||||
$toc = new PHPWord_TOC($styleFont, $styleTOC);
|
||||
$this->_elementCollection[] = $toc;
|
||||
return $toc;
|
||||
|
|
@ -294,13 +302,14 @@ class PHPWord_Section {
|
|||
* @param int $depth
|
||||
* @return PHPWord_Section_Title
|
||||
*/
|
||||
public function addTitle($text, $depth = 1) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
||||
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;
|
||||
if (array_key_exists('Heading_' . $depth, $styles)) {
|
||||
$style = 'Heading' . $depth;
|
||||
} else {
|
||||
$style = null;
|
||||
}
|
||||
|
|
@ -323,7 +332,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null) {
|
||||
public function createTextRun($styleParagraph = null)
|
||||
{
|
||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||
$this->_elementCollection[] = $textRun;
|
||||
return $textRun;
|
||||
|
|
@ -334,7 +344,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements() {
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +354,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return PHPWord_Section_Header
|
||||
*/
|
||||
public function createHeader() {
|
||||
public function createHeader()
|
||||
{
|
||||
$header = new PHPWord_Section_Header($this->_sectionCount);
|
||||
$this->_headers[] = $header;
|
||||
return $header;
|
||||
|
|
@ -354,7 +366,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders() {
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
|
|
@ -367,8 +380,9 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasDifferentFirstPage() {
|
||||
$value = array_filter($this->_headers, function(PHPWord_Section_Header &$header) {
|
||||
public function hasDifferentFirstPage()
|
||||
{
|
||||
$value = array_filter($this->_headers, function (PHPWord_Section_Header &$header) {
|
||||
return $header->getType() == PHPWord_Section_Header::FIRST;
|
||||
});
|
||||
return count($value) > 0;
|
||||
|
|
@ -379,7 +393,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return PHPWord_Section_Footer
|
||||
*/
|
||||
public function createFooter() {
|
||||
public function createFooter()
|
||||
{
|
||||
$footer = new PHPWord_Section_Footer($this->_sectionCount);
|
||||
$this->_footer = $footer;
|
||||
return $footer;
|
||||
|
|
@ -390,8 +405,8 @@ class PHPWord_Section {
|
|||
*
|
||||
* @return PHPWord_Section_Footer
|
||||
*/
|
||||
public function getFooter() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Footer
|
||||
{
|
||||
|
||||
/**
|
||||
* Footer Count
|
||||
|
|
@ -59,7 +55,8 @@ class PHPWord_Section_Footer {
|
|||
/**
|
||||
* Create a new Footer
|
||||
*/
|
||||
public function __construct($sectionCount) {
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
$this->_footerCount = $sectionCount;
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +68,9 @@ class PHPWord_Section_Footer {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($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);
|
||||
|
|
@ -85,8 +83,9 @@ class PHPWord_Section_Footer {
|
|||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
public function addTextBreak($count = 1)
|
||||
{
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +95,8 @@ class PHPWord_Section_Footer {
|
|||
*
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null) {
|
||||
public function createTextRun($styleParagraph = null)
|
||||
{
|
||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||
$this->_elementCollection[] = $textRun;
|
||||
return $textRun;
|
||||
|
|
@ -108,7 +108,8 @@ class PHPWord_Section_Footer {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table
|
||||
*/
|
||||
public function addTable($style = null) {
|
||||
public function addTable($style = null)
|
||||
{
|
||||
$table = new PHPWord_Section_Table('footer', $this->_footerCount, $style);
|
||||
$this->_elementCollection[] = $table;
|
||||
return $table;
|
||||
|
|
@ -121,10 +122,11 @@ class PHPWord_Section_Footer {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($src, $style = null) {
|
||||
public function addImage($src, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($src, $style);
|
||||
|
||||
if(!is_null($image->getSource())) {
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $src);
|
||||
$image->setRelationId($rID);
|
||||
|
||||
|
|
@ -142,9 +144,10 @@ class PHPWord_Section_Footer {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_MemoryImage
|
||||
*/
|
||||
public function addMemoryImage($link, $style = null) {
|
||||
public function addMemoryImage($link, $style = null)
|
||||
{
|
||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||
if(!is_null($memoryImage->getSource())) {
|
||||
if (!is_null($memoryImage->getSource())) {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage);
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
||||
|
|
@ -163,8 +166,9 @@ class PHPWord_Section_Footer {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Footer_PreserveText
|
||||
*/
|
||||
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
||||
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);
|
||||
|
|
@ -175,7 +179,8 @@ class PHPWord_Section_Footer {
|
|||
/**
|
||||
* Get Footer Relation ID
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -184,22 +189,24 @@ class PHPWord_Section_Footer {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Footer Elements
|
||||
*/
|
||||
public function getElements() {
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footer Count
|
||||
*/
|
||||
public function getFooterCount() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Footer_PreserveText
|
||||
{
|
||||
|
||||
/**
|
||||
* Text content
|
||||
|
|
@ -63,14 +59,15 @@ class PHPWord_Section_Footer_PreserveText {
|
|||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null) {
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
// Set font style
|
||||
if(is_array($styleFont)) {
|
||||
if (is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -79,12 +76,12 @@ class PHPWord_Section_Footer_PreserveText {
|
|||
}
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -103,7 +100,8 @@ class PHPWord_Section_Footer_PreserveText {
|
|||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +110,8 @@ class PHPWord_Section_Footer_PreserveText {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
|
|
@ -121,8 +120,8 @@ class PHPWord_Section_Footer_PreserveText {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Header
|
||||
{
|
||||
|
||||
/**
|
||||
* Header Count
|
||||
|
|
@ -88,7 +84,8 @@ class PHPWord_Section_Header {
|
|||
/**
|
||||
* Create a new Header
|
||||
*/
|
||||
public function __construct($sectionCount) {
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
$this->_headerCount = $sectionCount;
|
||||
}
|
||||
|
||||
|
|
@ -100,8 +97,9 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($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);
|
||||
|
|
@ -114,8 +112,9 @@ class PHPWord_Section_Header {
|
|||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
public function addTextBreak($count = 1)
|
||||
{
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
|
|
@ -125,7 +124,8 @@ class PHPWord_Section_Header {
|
|||
*
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null) {
|
||||
public function createTextRun($styleParagraph = null)
|
||||
{
|
||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||
$this->_elementCollection[] = $textRun;
|
||||
return $textRun;
|
||||
|
|
@ -137,7 +137,8 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table
|
||||
*/
|
||||
public function addTable($style = null) {
|
||||
public function addTable($style = null)
|
||||
{
|
||||
$table = new PHPWord_Section_Table('header', $this->_headerCount, $style);
|
||||
$this->_elementCollection[] = $table;
|
||||
return $table;
|
||||
|
|
@ -150,10 +151,11 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($src, $style = null) {
|
||||
public function addImage($src, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($src, $style);
|
||||
|
||||
if(!is_null($image->getSource())) {
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
||||
$image->setRelationId($rID);
|
||||
|
||||
|
|
@ -171,9 +173,10 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_MemoryImage
|
||||
*/
|
||||
public function addMemoryImage($link, $style = null) {
|
||||
public function addMemoryImage($link, $style = null)
|
||||
{
|
||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||
if(!is_null($memoryImage->getSource())) {
|
||||
if (!is_null($memoryImage->getSource())) {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage);
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
||||
|
|
@ -192,8 +195,9 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Footer_PreserveText
|
||||
*/
|
||||
public function addPreserveText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
||||
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);
|
||||
|
|
@ -208,10 +212,11 @@ class PHPWord_Section_Header {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addWatermark($src, $style = null) {
|
||||
public function addWatermark($src, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($src, $style, true);
|
||||
|
||||
if(!is_null($image->getSource())) {
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_headerCount, $src);
|
||||
$image->setRelationId($rID);
|
||||
|
||||
|
|
@ -225,7 +230,8 @@ class PHPWord_Section_Header {
|
|||
/**
|
||||
* Get Header Relation ID
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -234,51 +240,57 @@ class PHPWord_Section_Header {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Header Elements
|
||||
*/
|
||||
public function getElements() {
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Count
|
||||
*/
|
||||
public function getHeaderCount() {
|
||||
public function getHeaderCount()
|
||||
{
|
||||
return $this->_headerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Type
|
||||
*/
|
||||
public function getType() {
|
||||
public function getType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset back to default
|
||||
*/
|
||||
public function resetType() {
|
||||
public function resetType()
|
||||
{
|
||||
return $this->_type = PHPWord_Section_Header::AUTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* First page only header
|
||||
*/
|
||||
public function firstPage() {
|
||||
public function firstPage()
|
||||
{
|
||||
return $this->_type = PHPWord_Section_Header::FIRST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Even numbered Pages only
|
||||
*/
|
||||
public function evenPage() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Image
|
||||
{
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
|
|
@ -70,27 +66,32 @@ class PHPWord_Section_Image {
|
|||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null, $isWatermark = false) {
|
||||
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)) {
|
||||
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;
|
||||
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) {
|
||||
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]);
|
||||
|
|
@ -107,7 +108,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +118,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +128,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +138,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +148,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId() {
|
||||
public function getMediaId()
|
||||
{
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +158,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIsWatermark() {
|
||||
public function getIsWatermark()
|
||||
{
|
||||
return $this->_isWatermark;
|
||||
}
|
||||
|
||||
|
|
@ -161,8 +168,8 @@ class PHPWord_Section_Image {
|
|||
*
|
||||
* @param bool $pValue
|
||||
*/
|
||||
public function setIsWatermark($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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Link
|
||||
{
|
||||
|
||||
/**
|
||||
* Link source
|
||||
|
|
@ -79,17 +75,18 @@ class PHPWord_Section_Link {
|
|||
* @var mixed $styleFont
|
||||
* @var mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
|
||||
public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
$this->_linkSrc = $linkSrc;
|
||||
$this->_linkName = $linkName;
|
||||
|
||||
// Set font style
|
||||
if(is_array($styleFont)) {
|
||||
if (is_array($styleFont)) {
|
||||
$this->_styleFont = new PHPWord_Style_Font('text');
|
||||
|
||||
foreach($styleFont as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -98,12 +95,12 @@ class PHPWord_Section_Link {
|
|||
}
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -119,7 +116,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +126,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +136,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkSrc() {
|
||||
public function getLinkSrc()
|
||||
{
|
||||
return $this->_linkSrc;
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkName() {
|
||||
public function getLinkName()
|
||||
{
|
||||
return $this->_linkName;
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +156,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
|
|
@ -164,8 +166,8 @@ class PHPWord_Section_Link {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_ListItem
|
||||
{
|
||||
|
||||
/**
|
||||
* ListItem Style
|
||||
|
|
@ -65,15 +61,16 @@ class PHPWord_Section_ListItem {
|
|||
* @param mixed $styleText
|
||||
* @param mixed $styleList
|
||||
*/
|
||||
public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) {
|
||||
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;
|
||||
if (!is_null($styleList) && is_array($styleList)) {
|
||||
foreach ($styleList as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -83,22 +80,24 @@ class PHPWord_Section_ListItem {
|
|||
/**
|
||||
* Get ListItem style
|
||||
*/
|
||||
public function getStyle() {
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem TextRun
|
||||
*/
|
||||
public function getTextObject() {
|
||||
public function getTextObject()
|
||||
{
|
||||
return $this->_textObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ListItem depth
|
||||
*/
|
||||
public function getDepth() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_MemoryImage
|
||||
{
|
||||
|
||||
/**
|
||||
* Image Src
|
||||
|
|
@ -91,26 +87,27 @@ class PHPWord_Section_MemoryImage {
|
|||
* @param string $src
|
||||
* @param mixed style
|
||||
*/
|
||||
public function __construct($src, $style = null) {
|
||||
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)) {
|
||||
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;
|
||||
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) {
|
||||
if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) {
|
||||
$this->_style->setWidth($imgData[0]);
|
||||
$this->_style->setHeight($imgData[1]);
|
||||
}
|
||||
|
|
@ -126,8 +123,9 @@ class PHPWord_Section_MemoryImage {
|
|||
/**
|
||||
* Set Functions
|
||||
*/
|
||||
private function _setFunctions() {
|
||||
switch($this->_imageType) {
|
||||
private function _setFunctions()
|
||||
{
|
||||
switch ($this->_imageType) {
|
||||
case 'image/png':
|
||||
$this->_imageCreateFunc = 'imagecreatefrompng';
|
||||
$this->_imageFunc = 'imagepng';
|
||||
|
|
@ -138,7 +136,8 @@ class PHPWord_Section_MemoryImage {
|
|||
$this->_imageFunc = 'imagegif';
|
||||
$this->_imageExtension = 'gif';
|
||||
break;
|
||||
case 'image/jpeg': case 'image/jpg':
|
||||
case 'image/jpeg':
|
||||
case 'image/jpg':
|
||||
$this->_imageCreateFunc = 'imagecreatefromjpeg';
|
||||
$this->_imageFunc = 'imagejpeg';
|
||||
$this->_imageExtension = 'jpg';
|
||||
|
|
@ -152,7 +151,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +161,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +171,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +181,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +191,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaId() {
|
||||
public function getMediaId()
|
||||
{
|
||||
return md5($this->_src);
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +201,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType() {
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->_imageType;
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +211,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageCreateFunction() {
|
||||
public function getImageCreateFunction()
|
||||
{
|
||||
return $this->_imageCreateFunc;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +221,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageFunction() {
|
||||
public function getImageFunction()
|
||||
{
|
||||
return $this->_imageFunc;
|
||||
}
|
||||
|
||||
|
|
@ -224,8 +231,8 @@ class PHPWord_Section_MemoryImage {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageExtension() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Object
|
||||
{
|
||||
|
||||
/**
|
||||
* Ole-Object Src
|
||||
|
|
@ -77,18 +73,19 @@ class PHPWord_Section_Object {
|
|||
* @param string $src
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($src, $style = null) {
|
||||
public function __construct($src, $style = null)
|
||||
{
|
||||
$_supportedObjectTypes = array('xls', 'doc', 'ppt');
|
||||
$inf = pathinfo($src);
|
||||
|
||||
if(file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
||||
if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
|
||||
$this->_src = $src;
|
||||
$this->_style = new PHPWord_Style_Image();
|
||||
|
||||
if(!is_null($style) && is_array($style)) {
|
||||
foreach($style as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
if (!is_null($style) && is_array($style)) {
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -105,7 +102,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @return PHPWord_Style_Image
|
||||
*/
|
||||
public function getStyle() {
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +112,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource() {
|
||||
public function getSource()
|
||||
{
|
||||
return $this->_src;
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +122,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRelationId() {
|
||||
public function getRelationId()
|
||||
{
|
||||
return $this->_rId;
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setRelationId($rId) {
|
||||
public function setRelationId($rId)
|
||||
{
|
||||
$this->_rId = $rId;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +142,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageRelationId() {
|
||||
public function getImageRelationId()
|
||||
{
|
||||
return $this->_rIdImg;
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +152,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @param int $rId
|
||||
*/
|
||||
public function setImageRelationId($rId) {
|
||||
public function setImageRelationId($rId)
|
||||
{
|
||||
$this->_rIdImg = $rId;
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +162,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectId() {
|
||||
public function getObjectId()
|
||||
{
|
||||
return $this->_objId;
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +172,8 @@ class PHPWord_Section_Object {
|
|||
*
|
||||
* @param int $objId
|
||||
*/
|
||||
public function setObjectId($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() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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_Settings
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
* Class PHPWord_Section_Settings
|
||||
*/
|
||||
class PHPWord_Section_Settings {
|
||||
class PHPWord_Section_Settings
|
||||
{
|
||||
|
||||
/**
|
||||
* Default Page Size Width
|
||||
|
|
@ -157,7 +153,8 @@ class PHPWord_Section_Settings {
|
|||
/**
|
||||
* Create new Section Settings
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_orientation = null;
|
||||
$this->_marginTop = 1418;
|
||||
$this->_marginLeft = 1418;
|
||||
|
|
@ -181,14 +178,15 @@ class PHPWord_Section_Settings {
|
|||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setSettingValue($key, $value) {
|
||||
if($key == '_orientation' && $value == 'landscape') {
|
||||
public function setSettingValue($key, $value)
|
||||
{
|
||||
if ($key == '_orientation' && $value == 'landscape') {
|
||||
$this->setLandscape();
|
||||
} elseif($key == '_orientation' && is_null($value)) {
|
||||
} elseif ($key == '_orientation' && is_null($value)) {
|
||||
$this->setPortrait();
|
||||
} elseif($key == '_borderSize') {
|
||||
} elseif ($key == '_borderSize') {
|
||||
$this->setBorderSize($value);
|
||||
} elseif($key == '_borderColor') {
|
||||
} elseif ($key == '_borderColor') {
|
||||
$this->setBorderColor($value);
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
|
|
@ -200,7 +198,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +208,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginTop($pValue = '') {
|
||||
public function setMarginTop($pValue = '')
|
||||
{
|
||||
$this->_marginTop = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -219,7 +219,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +229,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginLeft($pValue = '') {
|
||||
public function setMarginLeft($pValue = '')
|
||||
{
|
||||
$this->_marginLeft = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -238,7 +240,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginRight() {
|
||||
public function getMarginRight()
|
||||
{
|
||||
return $this->_marginRight;
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +250,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginRight($pValue = '') {
|
||||
public function setMarginRight($pValue = '')
|
||||
{
|
||||
$this->_marginRight = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -257,7 +261,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginBottom() {
|
||||
public function getMarginBottom()
|
||||
{
|
||||
return $this->_marginBottom;
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +271,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setMarginBottom($pValue = '') {
|
||||
public function setMarginBottom($pValue = '')
|
||||
{
|
||||
$this->_marginBottom = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -274,7 +280,8 @@ class PHPWord_Section_Settings {
|
|||
/**
|
||||
* Set Landscape Orientation
|
||||
*/
|
||||
public function setLandscape() {
|
||||
public function setLandscape()
|
||||
{
|
||||
$this->_orientation = 'landscape';
|
||||
$this->_pageSizeW = $this->_defaultPageSizeH;
|
||||
$this->_pageSizeH = $this->_defaultPageSizeW;
|
||||
|
|
@ -283,7 +290,8 @@ class PHPWord_Section_Settings {
|
|||
/**
|
||||
* Set Portrait Orientation
|
||||
*/
|
||||
public function setPortrait() {
|
||||
public function setPortrait()
|
||||
{
|
||||
$this->_orientation = null;
|
||||
$this->_pageSizeW = $this->_defaultPageSizeW;
|
||||
$this->_pageSizeH = $this->_defaultPageSizeH;
|
||||
|
|
@ -294,7 +302,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPageSizeW() {
|
||||
public function getPageSizeW()
|
||||
{
|
||||
return $this->_pageSizeW;
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +312,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPageSizeH() {
|
||||
public function getPageSizeH()
|
||||
{
|
||||
return $this->_pageSizeH;
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +322,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOrientation() {
|
||||
public function getOrientation()
|
||||
{
|
||||
return $this->_orientation;
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +332,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderSize($pValue = null) {
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
$this->_borderLeftSize = $pValue;
|
||||
$this->_borderRightSize = $pValue;
|
||||
|
|
@ -333,7 +345,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderSize() {
|
||||
public function getBorderSize()
|
||||
{
|
||||
$t = $this->getBorderTopSize();
|
||||
$l = $this->getBorderLeftSize();
|
||||
$r = $this->getBorderRightSize();
|
||||
|
|
@ -347,7 +360,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderColor($pValue = null) {
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
$this->_borderLeftColor = $pValue;
|
||||
$this->_borderRightColor = $pValue;
|
||||
|
|
@ -359,7 +373,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderColor() {
|
||||
public function getBorderColor()
|
||||
{
|
||||
$t = $this->getBorderTopColor();
|
||||
$l = $this->getBorderLeftColor();
|
||||
$r = $this->getBorderRightColor();
|
||||
|
|
@ -373,7 +388,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderTopSize($pValue = null) {
|
||||
public function setBorderTopSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +398,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBorderTopSize() {
|
||||
public function getBorderTopSize()
|
||||
{
|
||||
return $this->_borderTopSize;
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +408,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderTopColor($pValue = null) {
|
||||
public function setBorderTopColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -400,7 +418,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderTopColor() {
|
||||
public function getBorderTopColor()
|
||||
{
|
||||
return $this->_borderTopColor;
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +428,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderLeftSize($pValue = null) {
|
||||
public function setBorderLeftSize($pValue = null)
|
||||
{
|
||||
$this->_borderLeftSize = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +438,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBorderLeftSize() {
|
||||
public function getBorderLeftSize()
|
||||
{
|
||||
return $this->_borderLeftSize;
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +448,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderLeftColor($pValue = null) {
|
||||
public function setBorderLeftColor($pValue = null)
|
||||
{
|
||||
$this->_borderLeftColor = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -436,7 +458,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderLeftColor() {
|
||||
public function getBorderLeftColor()
|
||||
{
|
||||
return $this->_borderLeftColor;
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +468,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderRightSize($pValue = null) {
|
||||
public function setBorderRightSize($pValue = null)
|
||||
{
|
||||
$this->_borderRightSize = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +478,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBorderRightSize() {
|
||||
public function getBorderRightSize()
|
||||
{
|
||||
return $this->_borderRightSize;
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +488,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderRightColor($pValue = null) {
|
||||
public function setBorderRightColor($pValue = null)
|
||||
{
|
||||
$this->_borderRightColor = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -472,7 +498,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderRightColor() {
|
||||
public function getBorderRightColor()
|
||||
{
|
||||
return $this->_borderRightColor;
|
||||
}
|
||||
|
||||
|
|
@ -481,7 +508,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderBottomSize($pValue = null) {
|
||||
public function setBorderBottomSize($pValue = null)
|
||||
{
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -490,7 +518,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBorderBottomSize() {
|
||||
public function getBorderBottomSize()
|
||||
{
|
||||
return $this->_borderBottomSize;
|
||||
}
|
||||
|
||||
|
|
@ -499,7 +528,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderBottomColor($pValue = null) {
|
||||
public function setBorderBottomColor($pValue = null)
|
||||
{
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -508,8 +538,8 @@ class PHPWord_Section_Settings {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderBottomColor() {
|
||||
public function getBorderBottomColor()
|
||||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Table
|
||||
{
|
||||
|
||||
/**
|
||||
* Table style
|
||||
|
|
@ -78,17 +74,18 @@ class PHPWord_Section_Table {
|
|||
* @param int $pCount
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $style = null) {
|
||||
public function __construct($insideOf, $pCount, $style = null)
|
||||
{
|
||||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
|
||||
if(!is_null($style)) {
|
||||
if(is_array($style)) {
|
||||
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;
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -103,7 +100,8 @@ class PHPWord_Section_Table {
|
|||
*
|
||||
* @param int $height
|
||||
*/
|
||||
public function addRow($height = null) {
|
||||
public function addRow($height = null)
|
||||
{
|
||||
$this->_rows[] = array();
|
||||
$this->_rowHeights[] = $height;
|
||||
}
|
||||
|
|
@ -115,7 +113,8 @@ class PHPWord_Section_Table {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Table_Cell
|
||||
*/
|
||||
public function addCell($width, $style = null) {
|
||||
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;
|
||||
|
|
@ -127,7 +126,8 @@ class PHPWord_Section_Table {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRows() {
|
||||
public function getRows()
|
||||
{
|
||||
return $this->_rows;
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,8 @@ class PHPWord_Section_Table {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRowHeights() {
|
||||
public function getRowHeights()
|
||||
{
|
||||
return $this->_rowHeights;
|
||||
}
|
||||
|
||||
|
|
@ -145,8 +146,8 @@ class PHPWord_Section_Table {
|
|||
*
|
||||
* @return PHPWord_Style_Table
|
||||
*/
|
||||
public function getStyle() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Table_Cell
|
||||
{
|
||||
|
||||
/**
|
||||
* Cell Width
|
||||
|
|
@ -79,18 +75,19 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param int $width
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($insideOf, $pCount, $width = null, $style = null) {
|
||||
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)) {
|
||||
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;
|
||||
foreach ($style as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -107,8 +104,9 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text, $styleFont = null, $styleParagraph = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($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);
|
||||
|
|
@ -124,13 +122,14 @@ class PHPWord_Section_Table_Cell {
|
|||
* @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)){
|
||||
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)){
|
||||
if (!is_null($linkName)) {
|
||||
if (!PHPWord_Shared_String::IsUTF8($linkName)) {
|
||||
$linkName = utf8_encode($linkName);
|
||||
}
|
||||
}
|
||||
|
|
@ -152,7 +151,8 @@ class PHPWord_Section_Table_Cell {
|
|||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak() {
|
||||
public function addTextBreak()
|
||||
{
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
|
||||
|
|
@ -165,8 +165,9 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param mixed $styleList
|
||||
* @return PHPWord_Section_ListItem
|
||||
*/
|
||||
public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($text)){
|
||||
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);
|
||||
|
|
@ -181,15 +182,16 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($src, $style = null) {
|
||||
public function addImage($src, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($src, $style);
|
||||
|
||||
if(!is_null($image->getSource())) {
|
||||
if($this->_insideOf == 'section') {
|
||||
if (!is_null($image->getSource())) {
|
||||
if ($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
|
||||
} elseif($this->_insideOf == 'header') {
|
||||
} elseif ($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $src);
|
||||
} elseif($this->_insideOf == 'footer') {
|
||||
} elseif ($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $src);
|
||||
}
|
||||
$image->setRelationId($rID);
|
||||
|
|
@ -208,14 +210,15 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_MemoryImage
|
||||
*/
|
||||
public function addMemoryImage($link, $style = null) {
|
||||
public function addMemoryImage($link, $style = null)
|
||||
{
|
||||
$memoryImage = new PHPWord_Section_MemoryImage($link, $style);
|
||||
if(!is_null($memoryImage->getSource())) {
|
||||
if($this->_insideOf == 'section') {
|
||||
if (!is_null($memoryImage->getSource())) {
|
||||
if ($this->_insideOf == 'section') {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($link, 'image', $memoryImage);
|
||||
} elseif($this->_insideOf == 'header') {
|
||||
} elseif ($this->_insideOf == 'header') {
|
||||
$rID = PHPWord_Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage);
|
||||
} elseif($this->_insideOf == 'footer') {
|
||||
} elseif ($this->_insideOf == 'footer') {
|
||||
$rID = PHPWord_Media::addFooterMediaElement($this->_pCount, $link, $memoryImage);
|
||||
}
|
||||
$memoryImage->setRelationId($rID);
|
||||
|
|
@ -234,21 +237,22 @@ class PHPWord_Section_Table_Cell {
|
|||
* @param mixed $style
|
||||
* @return PHPWord_Section_Object
|
||||
*/
|
||||
public function addObject($src, $style = null) {
|
||||
public function addObject($src, $style = null)
|
||||
{
|
||||
$object = new PHPWord_Section_Object($src, $style);
|
||||
|
||||
if(!is_null($object->getSource())) {
|
||||
if (!is_null($object->getSource())) {
|
||||
$inf = pathinfo($src);
|
||||
$ext = $inf['extension'];
|
||||
if(strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||
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';
|
||||
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
|
||||
$iconSrc = $iconSrc . '_default.png';
|
||||
} else {
|
||||
$iconSrc .= '_'.$ext.'.png';
|
||||
$iconSrc .= '_' . $ext . '.png';
|
||||
}
|
||||
|
||||
$rIDimg = PHPWord_Media::addSectionMediaElement($iconSrc, 'image');
|
||||
|
|
@ -275,9 +279,10 @@ class PHPWord_Section_Table_Cell {
|
|||
* @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)){
|
||||
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);
|
||||
|
|
@ -293,7 +298,8 @@ class PHPWord_Section_Table_Cell {
|
|||
*
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null) {
|
||||
public function createTextRun($styleParagraph = null)
|
||||
{
|
||||
$textRun = new PHPWord_Section_TextRun($styleParagraph);
|
||||
$this->_elementCollection[] = $textRun;
|
||||
return $textRun;
|
||||
|
|
@ -304,7 +310,8 @@ class PHPWord_Section_Table_Cell {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements() {
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +320,8 @@ class PHPWord_Section_Table_Cell {
|
|||
*
|
||||
* @return PHPWord_Style_Cell
|
||||
*/
|
||||
public function getStyle() {
|
||||
public function getStyle()
|
||||
{
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
|
|
@ -322,8 +330,8 @@ class PHPWord_Section_Table_Cell {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Text
|
||||
{
|
||||
|
||||
/**
|
||||
* Text content
|
||||
|
|
@ -63,7 +59,8 @@ class PHPWord_Section_Text {
|
|||
* @var string $text
|
||||
* @var mixed $style
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null) {
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
// Set font style
|
||||
$this->setFontStyle($styleFont);
|
||||
|
||||
|
|
@ -80,7 +77,8 @@ class PHPWord_Section_Text {
|
|||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function getFontStyle() {
|
||||
public function getFontStyle()
|
||||
{
|
||||
return $this->_styleFont;
|
||||
}
|
||||
|
||||
|
|
@ -89,13 +87,14 @@ class PHPWord_Section_Text {
|
|||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function setFontStyle($styleFont) {
|
||||
if(is_array($styleFont)) {
|
||||
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;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -109,7 +108,8 @@ class PHPWord_Section_Text {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
|
|
@ -118,13 +118,14 @@ class PHPWord_Section_Text {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setParagraphStyle($styleParagraph) {
|
||||
if(is_array($styleParagraph)) {
|
||||
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;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -138,8 +139,8 @@ class PHPWord_Section_Text {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
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 {
|
||||
class PHPWord_Section_TextBreak
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new TextBreak Element
|
||||
*/
|
||||
public function __construct() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_TextRun
|
||||
{
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
|
|
@ -53,16 +49,17 @@ class PHPWord_Section_TextRun {
|
|||
/**
|
||||
* Create a new TextRun Element
|
||||
*/
|
||||
public function __construct($styleParagraph = null) {
|
||||
public function __construct($styleParagraph = null)
|
||||
{
|
||||
$this->_elementCollection = array();
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -79,8 +76,9 @@ class PHPWord_Section_TextRun {
|
|||
* @var mixed $styleFont
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text = null, $styleFont = null) {
|
||||
if(!PHPWord_Shared_String::IsUTF8($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);
|
||||
|
|
@ -96,9 +94,10 @@ class PHPWord_Section_TextRun {
|
|||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null) {
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null)
|
||||
{
|
||||
$linkSrc = utf8_encode($linkSrc);
|
||||
if(!is_null($linkName)) {
|
||||
if (!is_null($linkName)) {
|
||||
$linkName = utf8_encode($linkName);
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +114,8 @@ class PHPWord_Section_TextRun {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getElements() {
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
|
|
@ -124,8 +124,8 @@ class PHPWord_Section_TextRun {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Section_Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Text content
|
||||
|
|
@ -77,8 +73,9 @@ class PHPWord_Section_Title {
|
|||
* @var string $text
|
||||
* @var int $depth
|
||||
*/
|
||||
public function __construct($text, $depth = 1, $style = null) {
|
||||
if(!is_null($style)) {
|
||||
public function __construct($text, $depth = 1, $style = null)
|
||||
{
|
||||
if (!is_null($style)) {
|
||||
$this->_style = $style;
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +90,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @var int $anchor
|
||||
*/
|
||||
public function setAnchor($anchor) {
|
||||
public function setAnchor($anchor)
|
||||
{
|
||||
$this->_anchor = $anchor;
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +100,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAnchor() {
|
||||
public function getAnchor()
|
||||
{
|
||||
return $this->_anchor;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +110,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @var int $bookmarkId
|
||||
*/
|
||||
public function setBookmarkId($bookmarkId) {
|
||||
public function setBookmarkId($bookmarkId)
|
||||
{
|
||||
$this->_bookmarkId = $bookmarkId;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBookmarkId() {
|
||||
public function getBookmarkId()
|
||||
{
|
||||
return $this->_bookmarkId;
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +130,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText() {
|
||||
public function getText()
|
||||
{
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
|
|
@ -138,8 +140,8 @@ class PHPWord_Section_Title {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStyle() {
|
||||
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,12 +20,14 @@
|
|||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
|
|
@ -34,7 +36,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
public static function pixelsToEMU($pValue = 0)
|
||||
{
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +47,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
public static function EMUToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
|
|
@ -58,7 +62,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
public static function pixelsToPoints($pValue = 0)
|
||||
{
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +73,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
public static function pointsToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 1.333333333;
|
||||
} else {
|
||||
|
|
@ -82,7 +88,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
public static function degreesToAngle($pValue = 0)
|
||||
{
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +99,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
public static function angleToDegrees($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
|
|
@ -106,7 +114,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in pixels
|
||||
* @return int Value in centimeters
|
||||
*/
|
||||
public static function pixelsToCentimeters($pValue = 0) {
|
||||
public static function pixelsToCentimeters($pValue = 0)
|
||||
{
|
||||
return $pValue * 0.028;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +125,8 @@ class PHPWord_Shared_Drawing
|
|||
* @param int $pValue Value in centimeters
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function centimetersToPixels($pValue = 0) {
|
||||
public static function centimetersToPixels($pValue = 0)
|
||||
{
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 0.028;
|
||||
} else {
|
||||
|
|
@ -130,18 +140,17 @@ class PHPWord_Shared_Drawing
|
|||
* @param str $pValue HTML Color in hexadecimal
|
||||
* @return array Value in RGB
|
||||
*/
|
||||
public static function htmlToRGB($pValue) {
|
||||
if ($pValue[0] == '#'){
|
||||
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{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,12 +20,14 @@
|
|||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
|
|
@ -34,11 +36,12 @@ class PHPWord_Shared_File
|
|||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename) {
|
||||
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' ) {
|
||||
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);
|
||||
|
|
@ -63,7 +66,8 @@ class PHPWord_Shared_File
|
|||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename) {
|
||||
public static function realpath($pFilename)
|
||||
{
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
|
|
@ -72,8 +76,8 @@ class PHPWord_Shared_File
|
|||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
$pathArray = split('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
|
|
|
|||
|
|
@ -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,12 +20,14 @@
|
|||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
|
|
@ -34,7 +36,8 @@ class PHPWord_Shared_Font
|
|||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12)
|
||||
{
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +47,8 @@ class PHPWord_Shared_Font
|
|||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1) {
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
{
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
|
|
@ -54,19 +58,23 @@ class PHPWord_Shared_Font
|
|||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1) {
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1) {
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 565.217);
|
||||
}
|
||||
|
||||
public static function inchSizeToTwips($sizeInInch = 1) {
|
||||
public static function inchSizeToTwips($sizeInInch = 1)
|
||||
{
|
||||
return self::centimeterSizeToTwips($sizeInInch * 2.54);
|
||||
}
|
||||
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1) {
|
||||
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,12 +20,14 @@
|
|||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
|
|
@ -52,10 +54,11 @@ class PHPWord_Shared_String
|
|||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
private static function _buildControlCharacters()
|
||||
{
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$_controlCharacters[$find] = $replace;
|
||||
}
|
||||
|
|
@ -110,12 +113,13 @@ class PHPWord_Shared_String
|
|||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,12 +136,13 @@ class PHPWord_Shared_String
|
|||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,7 +151,8 @@ class PHPWord_Shared_String
|
|||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsUTF8($value = '') {
|
||||
public static function IsUTF8($value = '')
|
||||
{
|
||||
return $value === '' || preg_match('/^./su', $value) === 1;
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +162,8 @@ class PHPWord_Shared_String
|
|||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function FormatNumber($value) {
|
||||
public static function FormatNumber($value)
|
||||
{
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,18 +20,24 @@
|
|||
*
|
||||
* @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')) {
|
||||
if (!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
}
|
||||
|
||||
|
||||
class PHPWord_Shared_XMLWriter {
|
||||
/**
|
||||
* 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;
|
||||
|
|
@ -56,7 +62,8 @@ class PHPWord_Shared_XMLWriter {
|
|||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './')
|
||||
{
|
||||
// Create internal XMLWriter
|
||||
$this->_xmlWriter = new XMLWriter();
|
||||
|
||||
|
|
@ -88,7 +95,8 @@ class PHPWord_Shared_XMLWriter {
|
|||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
public function __destruct()
|
||||
{
|
||||
// Desctruct XMLWriter
|
||||
unset($this->_xmlWriter);
|
||||
|
||||
|
|
@ -103,7 +111,8 @@ class PHPWord_Shared_XMLWriter {
|
|||
*
|
||||
* @return $data
|
||||
*/
|
||||
public function getData() {
|
||||
public function getData()
|
||||
{
|
||||
if ($this->_tempFileName == '') {
|
||||
return $this->_xmlWriter->outputMemory(true);
|
||||
} else {
|
||||
|
|
@ -118,7 +127,8 @@ class PHPWord_Shared_XMLWriter {
|
|||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
public function __call($function, $args) {
|
||||
public function __call($function, $args)
|
||||
{
|
||||
try {
|
||||
@call_user_func_array(array($this->_xmlWriter, $function), $args);
|
||||
} catch (Exception $ex) {
|
||||
|
|
|
|||
|
|
@ -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,17 +20,19 @@
|
|||
*
|
||||
* @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
|
||||
*/
|
||||
class PHPWord_Shared_ZipStreamWrapper
|
||||
{
|
||||
/**
|
||||
* Internal ZipAcrhive
|
||||
*
|
||||
|
|
@ -62,7 +64,8 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
/**
|
||||
* Register wrapper
|
||||
*/
|
||||
public static function register() {
|
||||
public static function register()
|
||||
{
|
||||
@stream_wrapper_unregister("zip");
|
||||
@stream_wrapper_register("zip", __CLASS__);
|
||||
}
|
||||
|
|
@ -70,7 +73,8 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
/**
|
||||
* Open stream
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
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.');
|
||||
|
|
@ -101,7 +105,7 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
|
||||
$this->_fileNameInArchive = $url['fragment'];
|
||||
$this->_position = 0;
|
||||
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
|
||||
$this->_data = $this->_archive->getFromName($this->_fileNameInArchive);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -109,14 +113,16 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
/**
|
||||
* Stat stream
|
||||
*/
|
||||
public function stream_stat() {
|
||||
return $this->_archive->statName( $this->_fileNameInArchive );
|
||||
public function stream_stat()
|
||||
{
|
||||
return $this->_archive->statName($this->_fileNameInArchive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count) {
|
||||
function stream_read($count)
|
||||
{
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
return $ret;
|
||||
|
|
@ -125,21 +131,24 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
/**
|
||||
* Tell stream
|
||||
*/
|
||||
public function stream_tell() {
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* EOF stream
|
||||
*/
|
||||
public function stream_eof() {
|
||||
public function stream_eof()
|
||||
{
|
||||
return $this->_position >= strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek stream
|
||||
*/
|
||||
public function stream_seek($offset, $whence) {
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < strlen($this->_data) && $offset >= 0) {
|
||||
|
|
@ -173,4 +182,3 @@ class PHPWord_Shared_ZipStreamWrapper {
|
|||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style
|
||||
{
|
||||
|
||||
/**
|
||||
* Style Elements
|
||||
|
|
@ -49,12 +45,13 @@ class PHPWord_Style {
|
|||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addParagraphStyle($styleName, $styles) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
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;
|
||||
foreach ($styles as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -70,12 +67,13 @@ class PHPWord_Style {
|
|||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
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;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -89,12 +87,13 @@ class PHPWord_Style {
|
|||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addLinkStyle($styleName, $styles) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
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;
|
||||
foreach ($styles as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$style->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -109,8 +108,9 @@ class PHPWord_Style {
|
|||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null) {
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
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;
|
||||
|
|
@ -124,13 +124,14 @@ class PHPWord_Style {
|
|||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
|
||||
$styleName = 'Heading_'.$titleCount;
|
||||
if(!array_key_exists($styleName, self::$_styleElements)) {
|
||||
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;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$font->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -144,7 +145,8 @@ class PHPWord_Style {
|
|||
*
|
||||
* @return PHPWord_Style_Font[]
|
||||
*/
|
||||
public static function getStyles() {
|
||||
public static function getStyles()
|
||||
{
|
||||
return self::$_styleElements;
|
||||
}
|
||||
|
||||
|
|
@ -154,12 +156,13 @@ class PHPWord_Style {
|
|||
* @param string
|
||||
* @return PHPWord_Style
|
||||
*/
|
||||
public static function getStyle($styleName) {
|
||||
if(array_key_exists($styleName, self::$_styleElements)){
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_Cell
|
||||
{
|
||||
|
||||
const TEXT_DIR_BTLR = 'btLr';
|
||||
const TEXT_DIR_TBRL = 'tbRl';
|
||||
|
|
@ -139,7 +135,8 @@ class PHPWord_Style_Cell {
|
|||
/**
|
||||
* Create a new Cell Style
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_valign = null;
|
||||
$this->_textDirection = null;
|
||||
$this->_bgColor = null;
|
||||
|
|
@ -160,52 +157,62 @@ class PHPWord_Style_Cell {
|
|||
* @var string $key
|
||||
* @var mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_borderSize') {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_borderSize') {
|
||||
$this->setBorderSize($value);
|
||||
} elseif($key == '_borderColor') {
|
||||
} elseif ($key == '_borderColor') {
|
||||
$this->setBorderColor($value);
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getVAlign() {
|
||||
public function getVAlign()
|
||||
{
|
||||
return $this->_valign;
|
||||
}
|
||||
|
||||
public function setVAlign($pValue = null) {
|
||||
public function setVAlign($pValue = null)
|
||||
{
|
||||
$this->_valign = $pValue;
|
||||
}
|
||||
|
||||
public function getTextDirection() {
|
||||
public function getTextDirection()
|
||||
{
|
||||
return $this->_textDirection;
|
||||
}
|
||||
|
||||
public function setTextDirection($pValue = null) {
|
||||
public function setTextDirection($pValue = null)
|
||||
{
|
||||
$this->_textDirection = $pValue;
|
||||
}
|
||||
|
||||
public function getBgColor() {
|
||||
public function getBgColor()
|
||||
{
|
||||
return $this->_bgColor;
|
||||
}
|
||||
|
||||
public function setBgColor($pValue = null) {
|
||||
public function setBgColor($pValue = null)
|
||||
{
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
|
||||
public function setHeight($pValue = null) {
|
||||
public function setHeight($pValue = null)
|
||||
{
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
public function setBorderSize($pValue = null) {
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
$this->_borderLeftSize = $pValue;
|
||||
$this->_borderRightSize = $pValue;
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderSize() {
|
||||
public function getBorderSize()
|
||||
{
|
||||
$t = $this->getBorderTopSize();
|
||||
$l = $this->getBorderLeftSize();
|
||||
$r = $this->getBorderRightSize();
|
||||
|
|
@ -214,14 +221,16 @@ class PHPWord_Style_Cell {
|
|||
return array($t, $l, $r, $b);
|
||||
}
|
||||
|
||||
public function setBorderColor($pValue = null) {
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
$this->_borderLeftColor = $pValue;
|
||||
$this->_borderRightColor = $pValue;
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderColor() {
|
||||
public function getBorderColor()
|
||||
{
|
||||
$t = $this->getBorderTopColor();
|
||||
$l = $this->getBorderLeftColor();
|
||||
$r = $this->getBorderRightColor();
|
||||
|
|
@ -230,89 +239,109 @@ class PHPWord_Style_Cell {
|
|||
return array($t, $l, $r, $b);
|
||||
}
|
||||
|
||||
public function setBorderTopSize($pValue = null) {
|
||||
public function setBorderTopSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderTopSize() {
|
||||
public function getBorderTopSize()
|
||||
{
|
||||
return $this->_borderTopSize;
|
||||
}
|
||||
|
||||
public function setBorderTopColor($pValue = null) {
|
||||
public function setBorderTopColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderTopColor() {
|
||||
public function getBorderTopColor()
|
||||
{
|
||||
return $this->_borderTopColor;
|
||||
}
|
||||
|
||||
public function setBorderLeftSize($pValue = null) {
|
||||
public function setBorderLeftSize($pValue = null)
|
||||
{
|
||||
$this->_borderLeftSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderLeftSize() {
|
||||
public function getBorderLeftSize()
|
||||
{
|
||||
return $this->_borderLeftSize;
|
||||
}
|
||||
|
||||
public function setBorderLeftColor($pValue = null) {
|
||||
public function setBorderLeftColor($pValue = null)
|
||||
{
|
||||
$this->_borderLeftColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderLeftColor() {
|
||||
public function getBorderLeftColor()
|
||||
{
|
||||
return $this->_borderLeftColor;
|
||||
}
|
||||
|
||||
public function setBorderRightSize($pValue = null) {
|
||||
public function setBorderRightSize($pValue = null)
|
||||
{
|
||||
$this->_borderRightSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderRightSize() {
|
||||
public function getBorderRightSize()
|
||||
{
|
||||
return $this->_borderRightSize;
|
||||
}
|
||||
|
||||
public function setBorderRightColor($pValue = null) {
|
||||
public function setBorderRightColor($pValue = null)
|
||||
{
|
||||
$this->_borderRightColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderRightColor() {
|
||||
public function getBorderRightColor()
|
||||
{
|
||||
return $this->_borderRightColor;
|
||||
}
|
||||
|
||||
|
||||
public function setBorderBottomSize($pValue = null) {
|
||||
public function setBorderBottomSize($pValue = null)
|
||||
{
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderBottomSize() {
|
||||
public function getBorderBottomSize()
|
||||
{
|
||||
return $this->_borderBottomSize;
|
||||
}
|
||||
|
||||
public function setBorderBottomColor($pValue = null) {
|
||||
public function setBorderBottomColor($pValue = null)
|
||||
{
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderBottomColor() {
|
||||
public function getBorderBottomColor()
|
||||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
|
||||
public function getDefaultBorderColor() {
|
||||
public function getDefaultBorderColor()
|
||||
{
|
||||
return $this->_defaultBorderColor;
|
||||
}
|
||||
|
||||
public function setGridSpan($pValue = null) {
|
||||
public function setGridSpan($pValue = null)
|
||||
{
|
||||
$this->_gridSpan = $pValue;
|
||||
}
|
||||
|
||||
public function getGridSpan() {
|
||||
public function getGridSpan()
|
||||
{
|
||||
return $this->_gridSpan;
|
||||
}
|
||||
|
||||
public function setVMerge($pValue = null) {
|
||||
public function setVMerge($pValue = null)
|
||||
{
|
||||
$this->_vMerge = $pValue;
|
||||
}
|
||||
|
||||
public function getVMerge() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_Font
|
||||
{
|
||||
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
|
|
@ -95,7 +91,8 @@ class PHPWord_Style_Font {
|
|||
private $_color;
|
||||
private $_fgColor;
|
||||
|
||||
public function __construct($type = 'text', $styleParagraph = null) {
|
||||
public function __construct($type = 'text', $styleParagraph = null)
|
||||
{
|
||||
$this->_type = $type;
|
||||
$this->_name = 'Arial';
|
||||
$this->_size = 20;
|
||||
|
|
@ -108,11 +105,11 @@ class PHPWord_Style_Font {
|
|||
$this->_color = '000000';
|
||||
$this->_fgColor = null;
|
||||
|
||||
if(!is_null($styleParagraph)) {
|
||||
if (!is_null($styleParagraph)) {
|
||||
$paragraph = new PHPWord_Style_Paragraph();
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$paragraph->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -122,67 +119,78 @@ class PHPWord_Style_Font {
|
|||
}
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_size') {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_size') {
|
||||
$value *= 2;
|
||||
}
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setName($pValue = 'Arial') {
|
||||
if($pValue == '') {
|
||||
public function setName($pValue = 'Arial')
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Arial';
|
||||
}
|
||||
$this->_name = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
public function getSize()
|
||||
{
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
public function setSize($pValue = 20) {
|
||||
if($pValue == '') {
|
||||
public function setSize($pValue = 20)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = 20;
|
||||
}
|
||||
$this->_size = ($pValue*2);
|
||||
$this->_size = ($pValue * 2);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBold() {
|
||||
public function getBold()
|
||||
{
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
public function setBold($pValue = false) {
|
||||
if($pValue == '') {
|
||||
public function setBold($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_bold = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItalic() {
|
||||
public function getItalic()
|
||||
{
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
public function setItalic($pValue = false) {
|
||||
if($pValue == '') {
|
||||
public function setItalic($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_italic = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSuperScript() {
|
||||
public function getSuperScript()
|
||||
{
|
||||
return $this->_superScript;
|
||||
}
|
||||
|
||||
public function setSuperScript($pValue = false) {
|
||||
if($pValue == '') {
|
||||
public function setSuperScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_superScript = $pValue;
|
||||
|
|
@ -190,12 +198,14 @@ class PHPWord_Style_Font {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getSubScript() {
|
||||
public function getSubScript()
|
||||
{
|
||||
return $this->_subScript;
|
||||
}
|
||||
|
||||
public function setSubScript($pValue = false) {
|
||||
if($pValue == '') {
|
||||
public function setSubScript($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_subScript = $pValue;
|
||||
|
|
@ -203,11 +213,13 @@ class PHPWord_Style_Font {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getUnderline() {
|
||||
public function getUnderline()
|
||||
{
|
||||
return $this->_underline;
|
||||
}
|
||||
|
||||
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) {
|
||||
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPWord_Style_Font::UNDERLINE_NONE;
|
||||
}
|
||||
|
|
@ -215,37 +227,44 @@ class PHPWord_Style_Font {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getStrikethrough() {
|
||||
public function getStrikethrough()
|
||||
{
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
|
||||
public function setStrikethrough($pValue = false) {
|
||||
if($pValue == '') {
|
||||
public function setStrikethrough($pValue = false)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_strikethrough = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
public function getColor()
|
||||
{
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
public function setColor($pValue = '000000') {
|
||||
public function setColor($pValue = '000000')
|
||||
{
|
||||
$this->_color = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFgColor() {
|
||||
public function getFgColor()
|
||||
{
|
||||
return $this->_fgColor;
|
||||
}
|
||||
|
||||
public function setFgColor($pValue = null) {
|
||||
public function setFgColor($pValue = null)
|
||||
{
|
||||
$this->_fgColor = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStyleType() {
|
||||
public function getStyleType()
|
||||
{
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
|
|
@ -254,8 +273,8 @@ class PHPWord_Style_Font {
|
|||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
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,24 +20,26 @@
|
|||
*
|
||||
* @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 {
|
||||
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';
|
||||
|
||||
private $_width;
|
||||
private $_height;
|
||||
private $_align;
|
||||
private $wrappingStyle;
|
||||
|
||||
/**
|
||||
* Margin Top
|
||||
|
|
@ -53,39 +55,48 @@ class PHPWord_Style_Image {
|
|||
*/
|
||||
private $_marginLeft;
|
||||
|
||||
public function __construct() {
|
||||
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) {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function getWidth() {
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
public function setWidth($pValue = null) {
|
||||
public function setWidth($pValue = null)
|
||||
{
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
public function getHeight() {
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
public function setHeight($pValue = null) {
|
||||
public function setHeight($pValue = null)
|
||||
{
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
public function getAlign() {
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
public function setAlign($pValue = null) {
|
||||
public function setAlign($pValue = null)
|
||||
{
|
||||
$this->_align = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +105,8 @@ class PHPWord_Style_Image {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +114,10 @@ class PHPWord_Style_Image {
|
|||
* Set Margin Top
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setMarginTop($pValue = null) {
|
||||
public function setMarginTop($pValue = null)
|
||||
{
|
||||
$this->_marginTop = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -113,7 +127,8 @@ class PHPWord_Style_Image {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
|
|
@ -121,10 +136,41 @@ class PHPWord_Style_Image {
|
|||
* Set Margin Left
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return $this
|
||||
*/
|
||||
public function setMarginLeft($pValue = null) {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_ListItem
|
||||
{
|
||||
|
||||
const TYPE_NUMBER = 7;
|
||||
const TYPE_NUMBER_NESTED = 8;
|
||||
|
|
@ -50,7 +46,8 @@ class PHPWord_Style_ListItem {
|
|||
/**
|
||||
* Create a new ListItem Style
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_listType = PHPWord_Style_ListItem::TYPE_BULLET_FILLED;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +57,8 @@ class PHPWord_Style_ListItem {
|
|||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
|
|
@ -69,15 +67,16 @@ class PHPWord_Style_ListItem {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED) {
|
||||
public function setListType($pValue = PHPWord_Style_ListItem::TYPE_BULLET_FILLED)
|
||||
{
|
||||
$this->_listType = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List Type
|
||||
*/
|
||||
public function getListType() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_Paragraph
|
||||
{
|
||||
|
||||
/**
|
||||
* Paragraph alignment
|
||||
|
|
@ -81,7 +77,8 @@ class PHPWord_Style_Paragraph {
|
|||
/**
|
||||
* New Paragraph Style
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_align = null;
|
||||
$this->_spaceBefore = null;
|
||||
$this->_spaceAfter = null;
|
||||
|
|
@ -96,14 +93,15 @@ class PHPWord_Style_Paragraph {
|
|||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_indent') {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_indent') {
|
||||
$value = (int)$value * 720; // 720 twips per indent
|
||||
}
|
||||
if($key == '_spacing') {
|
||||
if ($key == '_spacing') {
|
||||
$value += 240; // because line height of 1 matches 240 twips
|
||||
}
|
||||
if($key === '_tabs') {
|
||||
if ($key === '_tabs') {
|
||||
$value = new PHPWord_Style_Tabs($value);
|
||||
}
|
||||
$this->$key = $value;
|
||||
|
|
@ -114,7 +112,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlign() {
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
|
|
@ -124,8 +123,9 @@ class PHPWord_Style_Paragraph {
|
|||
* @param string $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setAlign($pValue = null) {
|
||||
if(strtolower($pValue) == 'justify') {
|
||||
public function setAlign($pValue = null)
|
||||
{
|
||||
if (strtolower($pValue) == 'justify') {
|
||||
// justify becames both
|
||||
$pValue = 'both';
|
||||
}
|
||||
|
|
@ -138,7 +138,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceBefore() {
|
||||
public function getSpaceBefore()
|
||||
{
|
||||
return $this->_spaceBefore;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +149,8 @@ class PHPWord_Style_Paragraph {
|
|||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceBefore($pValue = null) {
|
||||
public function setSpaceBefore($pValue = null)
|
||||
{
|
||||
$this->_spaceBefore = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -158,7 +160,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpaceAfter() {
|
||||
public function getSpaceAfter()
|
||||
{
|
||||
return $this->_spaceAfter;
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +171,8 @@ class PHPWord_Style_Paragraph {
|
|||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpaceAfter($pValue = null) {
|
||||
public function setSpaceAfter($pValue = null)
|
||||
{
|
||||
$this->_spaceAfter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -178,7 +182,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpacing() {
|
||||
public function getSpacing()
|
||||
{
|
||||
return $this->_spacing;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +193,8 @@ class PHPWord_Style_Paragraph {
|
|||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setSpacing($pValue = null) {
|
||||
public function setSpacing($pValue = null)
|
||||
{
|
||||
$this->_spacing = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -198,7 +204,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +215,8 @@ class PHPWord_Style_Paragraph {
|
|||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setIndent($pValue = null) {
|
||||
public function setIndent($pValue = null)
|
||||
{
|
||||
$this->_indent = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -218,8 +226,8 @@ class PHPWord_Style_Paragraph {
|
|||
*
|
||||
* @return PHPWord_Style_Tabs
|
||||
*/
|
||||
public function getTabs() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_TOC
|
||||
{
|
||||
|
||||
const TABLEADER_DOT = 'dot';
|
||||
const TABLEADER_UNDERSCORE = 'underscore';
|
||||
|
|
@ -65,7 +61,8 @@ class PHPWord_Style_TOC {
|
|||
/**
|
||||
* Create a new TOC Style
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_tabPos = 9062;
|
||||
$this->_tabLeader = PHPWord_Style_TOC::TABLEADER_DOT;
|
||||
$this->_indent = 200;
|
||||
|
|
@ -76,7 +73,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTabPos() {
|
||||
public function getTabPos()
|
||||
{
|
||||
return $this->_tabPos;
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +83,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setTabPos($pValue) {
|
||||
public function setTabPos($pValue)
|
||||
{
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +93,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLeader() {
|
||||
public function getTabLeader()
|
||||
{
|
||||
return $this->_tabLeader;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT) {
|
||||
public function setTabLeader($pValue = PHPWord_Style_TOC::TABLEADER_DOT)
|
||||
{
|
||||
$this->_tabLeader = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +113,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
public function getIndent()
|
||||
{
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +123,8 @@ class PHPWord_Style_TOC {
|
|||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setIndent($pValue) {
|
||||
public function setIndent($pValue)
|
||||
{
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -131,8 +134,8 @@ class PHPWord_Style_TOC {
|
|||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStyleValue($key, $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,20 +20,16 @@
|
|||
*
|
||||
* @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
|
||||
|
|
@ -96,7 +92,8 @@ class PHPWord_Style_Tab {
|
|||
* @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) {
|
||||
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';
|
||||
|
||||
|
|
@ -112,11 +109,12 @@ class PHPWord_Style_Tab {
|
|||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) {
|
||||
if(isset($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)) {
|
||||
if (!is_null($this->_leader)) {
|
||||
$objWriter->writeAttribute("w:leader", $this->_leader);
|
||||
}
|
||||
$objWriter->writeAttribute("w:pos", $this->_position);
|
||||
|
|
@ -130,7 +128,8 @@ class PHPWord_Style_Tab {
|
|||
* @param string $attribute
|
||||
* @return bool True if it is; false otherwise.
|
||||
*/
|
||||
private static function isStopType($attribute) {
|
||||
private static function isStopType($attribute)
|
||||
{
|
||||
return in_array($attribute, self::$_possibleStopTypes);
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +139,8 @@ class PHPWord_Style_Tab {
|
|||
* @param string $attribute
|
||||
* @return bool True if it is; false otherwise.
|
||||
*/
|
||||
private static function isLeaderType($attribute) {
|
||||
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() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_cellMarginTop = null;
|
||||
$this->_cellMarginLeft = null;
|
||||
$this->_cellMarginRight = null;
|
||||
$this->_cellMarginBottom = null;
|
||||
}
|
||||
|
||||
public function setStyleValue($key, $value) {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null) {
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop() {
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null) {
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft() {
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null) {
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight() {
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null) {
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom() {
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function getCellMargin() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_Style_TableFull
|
||||
{
|
||||
|
||||
/**
|
||||
* Style for first row
|
||||
|
|
@ -165,9 +161,10 @@ class PHPWord_Style_TableFull {
|
|||
/**
|
||||
* Create a new TableFull Font
|
||||
*/
|
||||
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null) {
|
||||
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null)
|
||||
{
|
||||
|
||||
if(!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
||||
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
|
||||
$this->_firstRow = clone $this;
|
||||
|
||||
unset($this->_firstRow->_firstRow);
|
||||
|
|
@ -179,19 +176,19 @@ class PHPWord_Style_TableFull {
|
|||
unset($this->_firstRow->_borderInsideVSize);
|
||||
unset($this->_firstRow->_borderInsideHColor);
|
||||
unset($this->_firstRow->_borderInsideHSize);
|
||||
foreach($styleFirstRow as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
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;
|
||||
if (!is_null($styleTable) && is_array($styleTable)) {
|
||||
foreach ($styleTable as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -204,12 +201,13 @@ class PHPWord_Style_TableFull {
|
|||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value) {
|
||||
if($key == '_borderSize') {
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_borderSize') {
|
||||
$this->setBorderSize($value);
|
||||
} elseif($key == '_borderColor') {
|
||||
} elseif ($key == '_borderColor') {
|
||||
$this->setBorderColor($value);
|
||||
} elseif($key == '_cellMargin') {
|
||||
} elseif ($key == '_cellMargin') {
|
||||
$this->setCellMargin($value);
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
|
|
@ -221,7 +219,8 @@ class PHPWord_Style_TableFull {
|
|||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getFirstRow() {
|
||||
public function getFirstRow()
|
||||
{
|
||||
return $this->_firstRow;
|
||||
}
|
||||
|
||||
|
|
@ -230,15 +229,18 @@ class PHPWord_Style_TableFull {
|
|||
*
|
||||
* @return PHPWord_Style_TableFull
|
||||
*/
|
||||
public function getLastRow() {
|
||||
public function getLastRow()
|
||||
{
|
||||
return $this->_lastRow;
|
||||
}
|
||||
|
||||
public function getBgColor() {
|
||||
public function getBgColor()
|
||||
{
|
||||
return $this->_bgColor;
|
||||
}
|
||||
|
||||
public function setBgColor($pValue = null) {
|
||||
public function setBgColor($pValue = null)
|
||||
{
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +249,8 @@ class PHPWord_Style_TableFull {
|
|||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderSize($pValue = null) {
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
$this->_borderLeftSize = $pValue;
|
||||
$this->_borderRightSize = $pValue;
|
||||
|
|
@ -261,7 +264,8 @@ class PHPWord_Style_TableFull {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderSize() {
|
||||
public function getBorderSize()
|
||||
{
|
||||
$t = $this->getBorderTopSize();
|
||||
$l = $this->getBorderLeftSize();
|
||||
$r = $this->getBorderRightSize();
|
||||
|
|
@ -275,7 +279,8 @@ class PHPWord_Style_TableFull {
|
|||
/**
|
||||
* Set TLRBVH Border Color
|
||||
*/
|
||||
public function setBorderColor($pValue = null) {
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
$this->_borderLeftColor = $pValue;
|
||||
$this->_borderRightColor = $pValue;
|
||||
|
|
@ -289,7 +294,8 @@ class PHPWord_Style_TableFull {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBorderColor() {
|
||||
public function getBorderColor()
|
||||
{
|
||||
$t = $this->getBorderTopColor();
|
||||
$l = $this->getBorderLeftColor();
|
||||
$r = $this->getBorderRightColor();
|
||||
|
|
@ -300,143 +306,176 @@ class PHPWord_Style_TableFull {
|
|||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
public function setBorderTopSize($pValue = null) {
|
||||
public function setBorderTopSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderTopSize() {
|
||||
public function getBorderTopSize()
|
||||
{
|
||||
return $this->_borderTopSize;
|
||||
}
|
||||
|
||||
public function setBorderTopColor($pValue = null) {
|
||||
public function setBorderTopColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderTopColor() {
|
||||
public function getBorderTopColor()
|
||||
{
|
||||
return $this->_borderTopColor;
|
||||
}
|
||||
|
||||
public function setBorderLeftSize($pValue = null) {
|
||||
public function setBorderLeftSize($pValue = null)
|
||||
{
|
||||
$this->_borderLeftSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderLeftSize() {
|
||||
public function getBorderLeftSize()
|
||||
{
|
||||
return $this->_borderLeftSize;
|
||||
}
|
||||
|
||||
public function setBorderLeftColor($pValue = null) {
|
||||
public function setBorderLeftColor($pValue = null)
|
||||
{
|
||||
$this->_borderLeftColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderLeftColor() {
|
||||
public function getBorderLeftColor()
|
||||
{
|
||||
return $this->_borderLeftColor;
|
||||
}
|
||||
|
||||
public function setBorderRightSize($pValue = null) {
|
||||
public function setBorderRightSize($pValue = null)
|
||||
{
|
||||
$this->_borderRightSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderRightSize() {
|
||||
public function getBorderRightSize()
|
||||
{
|
||||
return $this->_borderRightSize;
|
||||
}
|
||||
|
||||
public function setBorderRightColor($pValue = null) {
|
||||
public function setBorderRightColor($pValue = null)
|
||||
{
|
||||
$this->_borderRightColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderRightColor() {
|
||||
public function getBorderRightColor()
|
||||
{
|
||||
return $this->_borderRightColor;
|
||||
}
|
||||
|
||||
public function setBorderBottomSize($pValue = null) {
|
||||
public function setBorderBottomSize($pValue = null)
|
||||
{
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderBottomSize() {
|
||||
public function getBorderBottomSize()
|
||||
{
|
||||
return $this->_borderBottomSize;
|
||||
}
|
||||
|
||||
public function setBorderBottomColor($pValue = null) {
|
||||
public function setBorderBottomColor($pValue = null)
|
||||
{
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderBottomColor() {
|
||||
public function getBorderBottomColor()
|
||||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
|
||||
public function setBorderInsideHColor($pValue = null) {
|
||||
public function setBorderInsideHColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHColor() {
|
||||
public function getBorderInsideHColor()
|
||||
{
|
||||
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVColor($pValue = null) {
|
||||
public function setBorderInsideVColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVColor() {
|
||||
public function getBorderInsideVColor()
|
||||
{
|
||||
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideHSize($pValue = null) {
|
||||
public function setBorderInsideHSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideHSize() {
|
||||
public function getBorderInsideHSize()
|
||||
{
|
||||
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
||||
}
|
||||
|
||||
public function setBorderInsideVSize($pValue = null) {
|
||||
public function setBorderInsideVSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
public function getBorderInsideVSize() {
|
||||
public function getBorderInsideVSize()
|
||||
{
|
||||
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
||||
}
|
||||
|
||||
public function setCellMarginTop($pValue = null) {
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginTop() {
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
public function setCellMarginLeft($pValue = null) {
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginLeft() {
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
public function setCellMarginRight($pValue = null) {
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginRight() {
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
public function setCellMarginBottom($pValue = null) {
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMarginBottom() {
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
public function setCellMargin($pValue = null) {
|
||||
public function setCellMargin($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
$this->_cellMarginRight = $pValue;
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
public function getCellMargin() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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
|
||||
|
|
@ -46,7 +42,8 @@ class PHPWord_Style_Tabs {
|
|||
*
|
||||
* @param array $tabs
|
||||
*/
|
||||
public function __construct(array $tabs) {
|
||||
public function __construct(array $tabs)
|
||||
{
|
||||
$this->_tabs = $tabs;
|
||||
}
|
||||
|
||||
|
|
@ -54,8 +51,9 @@ class PHPWord_Style_Tabs {
|
|||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL) {
|
||||
if(isset($objWriter)) {
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL)
|
||||
{
|
||||
if (isset($objWriter)) {
|
||||
$objWriter->startElement("w:tabs");
|
||||
foreach ($this->_tabs as &$tab) {
|
||||
$tab->toXml($objWriter);
|
||||
|
|
@ -64,4 +62,3 @@ class PHPWord_Style_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,20 +20,16 @@
|
|||
*
|
||||
* @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 {
|
||||
class PHPWord_TOC
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Elements
|
||||
|
|
@ -77,25 +73,26 @@ class PHPWord_TOC {
|
|||
* @param array $styleFont
|
||||
* @param array $styleTOC
|
||||
*/
|
||||
public function __construct($styleFont = null, $styleTOC = null) {
|
||||
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;
|
||||
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)) {
|
||||
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;
|
||||
foreach ($styleFont as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
self::$_styleFont->setStyleValue($key, $value);
|
||||
}
|
||||
|
|
@ -110,8 +107,9 @@ class PHPWord_TOC {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function addTitle($text, $depth = 0) {
|
||||
$anchor = '_Toc'.++self::$_anchor;
|
||||
public static function addTitle($text, $depth = 0)
|
||||
{
|
||||
$anchor = '_Toc' . ++self::$_anchor;
|
||||
$bookmarkId = self::$_bookmarkId++;
|
||||
|
||||
$title = array();
|
||||
|
|
@ -130,7 +128,8 @@ class PHPWord_TOC {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTitles() {
|
||||
public static function getTitles()
|
||||
{
|
||||
return self::$_titles;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +138,8 @@ class PHPWord_TOC {
|
|||
*
|
||||
* @return PHPWord_Style_TOC
|
||||
*/
|
||||
public static function getStyleTOC() {
|
||||
public static function getStyleTOC()
|
||||
{
|
||||
return self::$_styleTOC;
|
||||
}
|
||||
|
||||
|
|
@ -148,8 +148,8 @@ class PHPWord_TOC {
|
|||
*
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public static function getStyleFont() {
|
||||
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,20 +20,16 @@
|
|||
*
|
||||
* @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
|
||||
|
|
@ -62,12 +58,13 @@ class PHPWord_Template {
|
|||
*
|
||||
* @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.'.');
|
||||
if (!copy($strFilename, $this->_tempFileName)) {
|
||||
throw new PHPWord_Exception('Could not copy the template from ' . $strFilename . ' to ' . $this->_tempFileName . '.');
|
||||
}
|
||||
|
||||
$this->_objZip = new ZipArchive();
|
||||
|
|
@ -85,7 +82,8 @@ class PHPWord_Template {
|
|||
* @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) {
|
||||
|
|
@ -94,12 +92,12 @@ class PHPWord_Template {
|
|||
$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)){
|
||||
if (!is_array($replace)) {
|
||||
if (!PHPWord_Shared_String::IsUTF8($replace)) {
|
||||
$replace = utf8_encode($replace);
|
||||
}
|
||||
}
|
||||
|
|
@ -121,19 +119,19 @@ class PHPWord_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,12 +20,14 @@
|
|||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
|
|
@ -36,4 +38,3 @@ interface PHPWord_Writer_IWriter
|
|||
*/
|
||||
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,12 +19,15 @@
|
|||
* 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
|
||||
{
|
||||
/**
|
||||
|
|
@ -195,7 +198,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord() {
|
||||
public function getPHPWord()
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
|
|
@ -210,7 +214,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null) {
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
{
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -220,7 +225,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +236,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '') {
|
||||
function getWriterPart($pPartName = '')
|
||||
{
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
|
|
@ -243,7 +250,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching() {
|
||||
public function getUseDiskCaching()
|
||||
{
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +263,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
* @throws Exception Exception when directory does not exist
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
{
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($pDirectory)) {
|
||||
|
|
@ -274,7 +283,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory() {
|
||||
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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
@ -53,7 +48,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8');
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// office:document-content
|
||||
$objWriter->startElement('office:document-content');
|
||||
|
|
@ -93,35 +88,34 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
// We firstly search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
$numPStyles = 0;
|
||||
$numFStyles = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$fStyle = $element->getFontStyle();
|
||||
$pStyle = $element->getParagraphStyle();
|
||||
|
||||
if($fStyle instanceof PHPWord_Style_Font){
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
$numFStyles++;
|
||||
|
||||
$arrStyle = array(
|
||||
'color'=>$fStyle->getColor(),
|
||||
'name' =>$fStyle->getName()
|
||||
'color' => $fStyle->getColor(),
|
||||
'name' => $fStyle->getName()
|
||||
);
|
||||
$pPHPWord->addFontStyle('T'.$numFStyles, $arrStyle);
|
||||
$element->setFontStyle('T'.$numFStyles);
|
||||
}
|
||||
elseif($pStyle instanceof PHPWord_Style_Paragraph){
|
||||
$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);
|
||||
$pPHPWord->addParagraphStyle('P' . $numPStyles, array());
|
||||
$element->setParagraph('P' . $numPStyles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -134,13 +128,13 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if(!in_array($name, $arrFonts)){
|
||||
if (!in_array($name, $arrFonts)) {
|
||||
$arrFonts[] = $name;
|
||||
|
||||
// style:font-face
|
||||
|
|
@ -151,7 +145,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!in_array('Arial', $arrFonts)){
|
||||
if (!in_array('Arial', $arrFonts)) {
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
|
|
@ -163,24 +157,25 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
$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){
|
||||
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) {
|
||||
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('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){
|
||||
if ($style instanceof PHPWord_Style_Paragraph) {
|
||||
$numPStyles++;
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
|
|
@ -197,7 +192,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
}
|
||||
|
||||
if($numPStyles == 0){
|
||||
if ($numPStyles == 0) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', 'P1');
|
||||
|
|
@ -245,24 +240,24 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
$countSections = count($_sections);
|
||||
$pSection = 0;
|
||||
|
||||
if($countSections > 0) {
|
||||
foreach($_sections as $section) {
|
||||
if ($countSections > 0) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
}/* elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} /* 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) {
|
||||
}*/ elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
}/* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
} /* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
$this->_writePageBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
|
|
@ -282,7 +277,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
}
|
||||
|
||||
if($pSection == $countSections) {
|
||||
if ($pSection == $countSections) {
|
||||
$this->_writeEndSection($objWriter, $section);
|
||||
} else {
|
||||
$this->_writeSection($objWriter, $section);
|
||||
|
|
@ -297,33 +292,30 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) {
|
||||
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) {
|
||||
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 {
|
||||
} else {
|
||||
// text:p
|
||||
$objWriter->startElement('text:p');
|
||||
if(empty($styleFont)){
|
||||
if(empty($styleParagraph)){
|
||||
if (empty($styleFont)) {
|
||||
if (empty($styleParagraph)) {
|
||||
$objWriter->writeAttribute('text:style-name', 'P1');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
$objWriter->writeRaw($text->getText());
|
||||
}
|
||||
else {
|
||||
if(empty($styleParagraph)){
|
||||
} else {
|
||||
if (empty($styleParagraph)) {
|
||||
$objWriter->writeAttribute('text:style-name', 'Standard');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$objWriter->writeAttribute('text:style-name', $text->getParagraphStyle());
|
||||
}
|
||||
// text:span
|
||||
|
|
@ -335,11 +327,15 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
|
||||
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) {
|
||||
|
||||
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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
@ -53,7 +48,7 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8');
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// manifest:manifest
|
||||
$objWriter->startElement('manifest:manifest');
|
||||
|
|
@ -85,7 +80,7 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
|
|||
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() );
|
||||
$mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath());
|
||||
|
||||
$objWriter->startElement('manifest:file-entry');
|
||||
$objWriter->writeAttribute('manifest:media-type', $mimeType);
|
||||
|
|
|
|||
|
|
@ -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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
@ -42,7 +37,8 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
|
|||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeMeta(PHPWord $pPHPWord = null) {
|
||||
public function writeMeta(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -52,7 +48,7 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8');
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// office:document-meta
|
||||
$objWriter->startElement('office:document-meta');
|
||||
|
|
@ -70,7 +66,7 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
|
|||
// 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()));
|
||||
$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
|
||||
|
|
@ -78,7 +74,7 @@ class PHPWord_Writer_ODText_Meta extends PHPWord_Writer_ODText_WriterPart
|
|||
// 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()));
|
||||
$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
|
||||
|
|
|
|||
|
|
@ -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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
@ -53,7 +48,7 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8');
|
||||
$objWriter->startDocument('1.0', 'UTF-8');
|
||||
|
||||
// Styles:Styles
|
||||
$objWriter->startElement('office:document-styles');
|
||||
|
|
@ -91,13 +86,13 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
$arrFonts = array();
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numFonts = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$numFonts++;
|
||||
$name = $style->getName();
|
||||
if(!in_array($name, $arrFonts)){
|
||||
if (!in_array($name, $arrFonts)) {
|
||||
$arrFonts[] = $name;
|
||||
|
||||
// style:font-face
|
||||
|
|
@ -109,7 +104,7 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!in_array('Arial', $arrFonts)){
|
||||
if (!in_array('Arial', $arrFonts)) {
|
||||
$objWriter->startElement('style:font-face');
|
||||
$objWriter->writeAttribute('style:name', 'Arial');
|
||||
$objWriter->writeAttribute('svg:font-family', 'Arial');
|
||||
|
|
@ -159,12 +154,13 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
|
||||
// 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){
|
||||
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) {
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
|
|
@ -172,23 +168,22 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
|
||||
// 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-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()) {
|
||||
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) {
|
||||
} // PHPWord_Style_Paragraph
|
||||
elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
|
|
@ -196,16 +191,15 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
|
||||
//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: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) {
|
||||
} // PHPWord_Style_TableFull
|
||||
elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -220,32 +214,32 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
|||
// 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');
|
||||
$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->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
|
||||
|
|
|
|||
|
|
@ -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,19 +19,14 @@
|
|||
* 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
|
||||
{
|
||||
|
|
@ -48,7 +43,8 @@ abstract class PHPWord_Writer_ODText_WriterPart
|
|||
* @param PHPWord_Writer_IWriter $pWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) {
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
|
||||
{
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +54,8 @@ abstract class PHPWord_Writer_ODText_WriterPart
|
|||
* @return PHPWord_Writer_IWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getParentWriter() {
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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,12 +19,15 @@
|
|||
* 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
|
||||
{
|
||||
/**
|
||||
|
|
@ -100,7 +103,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
* @return PHPWord
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPWord() {
|
||||
public function getPHPWord()
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
return $this->_document;
|
||||
} else {
|
||||
|
|
@ -115,7 +119,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
* @throws Exception
|
||||
* @return PHPWord_Writer_PowerPoint2007
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null) {
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
{
|
||||
$this->_document = $pPHPWord;
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -125,11 +130,13 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
*
|
||||
* @return PHPWord_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
private function _getData(){
|
||||
private function _getData()
|
||||
{
|
||||
// PHPWord object : $this->_document
|
||||
$this->_fontTable = $this->_getDataFont();
|
||||
$this->_colorTable = $this->_getDataColor();
|
||||
|
|
@ -143,17 +150,17 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
$sRTFContent .= '\deftab720';
|
||||
// Set the font tbl group
|
||||
$sRTFContent .= '{\fonttbl';
|
||||
foreach ($this->_fontTable as $idx => $font){
|
||||
$sRTFContent .= '{\f'.$idx.'\fnil\fcharset0 '.$font.';}';
|
||||
foreach ($this->_fontTable as $idx => $font) {
|
||||
$sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}';
|
||||
}
|
||||
$sRTFContent .= '}'.PHP_EOL;
|
||||
$sRTFContent .= '}' . PHP_EOL;
|
||||
// Set the color tbl group
|
||||
$sRTFContent .= '{\colortbl ';
|
||||
foreach ($this->_colorTable as $idx => $color){
|
||||
foreach ($this->_colorTable as $idx => $color) {
|
||||
$arrColor = PHPWord_Shared_Drawing::htmlToRGB($color);
|
||||
$sRTFContent .= ';\red'.$arrColor[0].'\green'.$arrColor[1].'\blue'.$arrColor[2].'';
|
||||
$sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . '';
|
||||
}
|
||||
$sRTFContent .= ';}'.PHP_EOL;
|
||||
$sRTFContent .= ';}' . PHP_EOL;
|
||||
// Set the generator
|
||||
$sRTFContent .= '{\*\generator PHPWord;}';
|
||||
// Set the view mode of the document
|
||||
|
|
@ -178,7 +185,9 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
|
||||
return $sRTFContent;
|
||||
}
|
||||
private function _getDataFont(){
|
||||
|
||||
private function _getDataFont()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrFonts = array();
|
||||
|
|
@ -189,11 +198,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
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){
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
if (in_array($style->getName(), $arrFonts) == FALSE) {
|
||||
$arrFonts[] = $style->getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -203,19 +212,19 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
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){
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getName(), $arrFonts) == FALSE) {
|
||||
$arrFonts[] = $fStyle->getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -226,7 +235,9 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
|
||||
return $arrFonts;
|
||||
}
|
||||
private function _getDataColor(){
|
||||
|
||||
private function _getDataColor()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
$arrColors = array();
|
||||
|
|
@ -235,16 +246,16 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
// Browse styles
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
$numPStyles = 0;
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if (count($styles) > 0) {
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if($style instanceof 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)){
|
||||
if (in_array($color, $arrColors) == FALSE && $color != '000000' && !empty($color)) {
|
||||
$arrColors[] = $color;
|
||||
}
|
||||
if(in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)){
|
||||
if (in_array($fgcolor, $arrColors) == FALSE && $fgcolor != '000000' && !empty($fgcolor)) {
|
||||
$arrColors[] = $fgcolor;
|
||||
}
|
||||
}
|
||||
|
|
@ -254,22 +265,22 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
// Search all fonts used
|
||||
$_sections = $pPHPWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
if($countSections > 0) {
|
||||
if ($countSections > 0) {
|
||||
$pSection = 0;
|
||||
|
||||
foreach($_sections as $section) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
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){
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getColor(), $arrColors) == FALSE) {
|
||||
$arrColors[] = $fStyle->getColor();
|
||||
}
|
||||
if(in_array($fStyle->getFgColor(), $arrColors) == FALSE){
|
||||
if (in_array($fStyle->getFgColor(), $arrColors) == FALSE) {
|
||||
$arrColors[] = $fStyle->getFgColor();
|
||||
}
|
||||
}
|
||||
|
|
@ -280,7 +291,9 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
|
||||
return $arrColors;
|
||||
}
|
||||
private function _getDataContent(){
|
||||
|
||||
private function _getDataContent()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
$sRTFBody = '';
|
||||
|
||||
|
|
@ -288,23 +301,23 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
$countSections = count($_sections);
|
||||
$pSection = 0;
|
||||
|
||||
if($countSections > 0) {
|
||||
foreach($_sections as $section) {
|
||||
if ($countSections > 0) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
$_elements = $section->getElements();
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$sRTFBody .= $this->_getDataContent_writeText($element);
|
||||
}/* elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} /* 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) {
|
||||
elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$sRTFBody .= $this->_getDataContent_writeTextBreak();
|
||||
}/* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
} /* elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
$this->_writePageBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
|
|
@ -327,96 +340,98 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
}
|
||||
return $sRTFBody;
|
||||
}
|
||||
private function _getDataContent_writeText(PHPWord_Section_Text $text){
|
||||
|
||||
private function _getDataContent_writeText(PHPWord_Section_Text $text)
|
||||
{
|
||||
$sRTFText = '';
|
||||
|
||||
$styleFont = $text->getFontStyle();
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
if(!$SfIsObject) {
|
||||
if (!$SfIsObject) {
|
||||
$styleFont = PHPWord_Style::getStyle($styleFont);
|
||||
}
|
||||
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
if(!$SpIsObject) {
|
||||
if (!$SpIsObject) {
|
||||
$styleParagraph = PHPWord_Style::getStyle($styleParagraph);
|
||||
}
|
||||
|
||||
if($styleParagraph){
|
||||
if($this->_lastParagraphStyle != $text->getParagraphStyle()){
|
||||
if ($styleParagraph) {
|
||||
if ($this->_lastParagraphStyle != $text->getParagraphStyle()) {
|
||||
$sRTFText .= '\pard\nowidctlpar';
|
||||
if($styleParagraph->getSpaceAfter() != null){
|
||||
$sRTFText .= '\sa'.$styleParagraph->getSpaceAfter();
|
||||
if ($styleParagraph->getSpaceAfter() != null) {
|
||||
$sRTFText .= '\sa' . $styleParagraph->getSpaceAfter();
|
||||
}
|
||||
if($styleParagraph->getAlign() != null){
|
||||
if($styleParagraph->getAlign() == 'center'){
|
||||
if ($styleParagraph->getAlign() != null) {
|
||||
if ($styleParagraph->getAlign() == 'center') {
|
||||
$sRTFText .= '\qc';
|
||||
}
|
||||
}
|
||||
$this->_lastParagraphStyle = $text->getParagraphStyle();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->_lastParagraphStyle = '';
|
||||
}
|
||||
|
||||
if($styleFont){
|
||||
if($styleFont->getColor() != null){
|
||||
if ($styleFont) {
|
||||
if ($styleFont->getColor() != null) {
|
||||
$idxColor = array_search($styleFont->getColor(), $this->_colorTable);
|
||||
if($idxColor !== FALSE){
|
||||
$sRTFText .= '\cf'.($idxColor+1);
|
||||
if ($idxColor !== FALSE) {
|
||||
$sRTFText .= '\cf' . ($idxColor + 1);
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\cf0';
|
||||
}
|
||||
if($styleFont->getName() != null){
|
||||
if ($styleFont->getName() != null) {
|
||||
$idxFont = array_search($styleFont->getName(), $this->_fontTable);
|
||||
if($idxFont !== FALSE){
|
||||
$sRTFText .= '\f'.$idxFont;
|
||||
if ($idxFont !== FALSE) {
|
||||
$sRTFText .= '\f' . $idxFont;
|
||||
}
|
||||
} else {
|
||||
$sRTFText .= '\f0';
|
||||
}
|
||||
if($styleFont->getBold()){
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\b';
|
||||
}
|
||||
if($styleFont->getBold()){
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\i';
|
||||
}
|
||||
if($styleFont->getSize()){
|
||||
$sRTFText .= '\fs'.$styleFont->getSize();
|
||||
if ($styleFont->getSize()) {
|
||||
$sRTFText .= '\fs' . $styleFont->getSize();
|
||||
}
|
||||
}
|
||||
if($this->_lastParagraphStyle != '' || $styleFont){
|
||||
if ($this->_lastParagraphStyle != '' || $styleFont) {
|
||||
$sRTFText .= ' ';
|
||||
}
|
||||
$sRTFText .= $text->getText();
|
||||
|
||||
if($styleFont){
|
||||
if ($styleFont) {
|
||||
$sRTFText .= '\cf0';
|
||||
$sRTFText .= '\f0';
|
||||
|
||||
if($styleFont->getBold()){
|
||||
if ($styleFont->getBold()) {
|
||||
$sRTFText .= '\b0';
|
||||
}
|
||||
if($styleFont->getItalic()){
|
||||
if ($styleFont->getItalic()) {
|
||||
$sRTFText .= '\i0';
|
||||
}
|
||||
if($styleFont->getSize()){
|
||||
if ($styleFont->getSize()) {
|
||||
$sRTFText .= '\fs20';
|
||||
}
|
||||
}
|
||||
|
||||
$sRTFText .= '\par'.PHP_EOL;
|
||||
$sRTFText .= '\par' . PHP_EOL;
|
||||
return $sRTFText;
|
||||
}
|
||||
private function _getDataContent_writeTextBreak(){
|
||||
|
||||
private function _getDataContent_writeTextBreak()
|
||||
{
|
||||
$this->_lastParagraphStyle = '';
|
||||
|
||||
return '\par'.PHP_EOL;
|
||||
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,13 +20,16 @@
|
|||
*
|
||||
* @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 implements PHPWord_Writer_IWriter {
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007
|
||||
*/
|
||||
class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||
{
|
||||
|
||||
private $_document;
|
||||
private $_writerParts;
|
||||
|
|
@ -35,7 +38,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
private $_imageTypes = array();
|
||||
private $_objectTypes = array();
|
||||
|
||||
public function __construct(PHPWord $PHPWord = null) {
|
||||
public function __construct(PHPWord $PHPWord = null)
|
||||
{
|
||||
$this->_document = $PHPWord;
|
||||
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
|
@ -49,19 +53,20 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
$this->_writerParts['header'] = new PHPWord_Writer_Word2007_Header();
|
||||
$this->_writerParts['footer'] = new PHPWord_Writer_Word2007_Footer();
|
||||
|
||||
foreach($this->_writerParts as $writer) {
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pFilename = null) {
|
||||
if(!is_null($this->_document)) {
|
||||
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') {
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if($pFilename == '') {
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
|
@ -70,8 +75,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
|
@ -79,58 +84,57 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
|
||||
$sectionElements = array();
|
||||
$_secElements = PHPWord_Media::getSectionMediaElements();
|
||||
foreach($_secElements as $element) { // loop through section media elements
|
||||
if($element['type'] != 'hyperlink') {
|
||||
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
|
||||
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
|
||||
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) {
|
||||
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));
|
||||
$_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)) {
|
||||
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));
|
||||
$_footerFile = 'footer' . $_footerCount . '.xml';
|
||||
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
|
||||
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,12 +157,12 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
|
||||
|
||||
// Close file
|
||||
if($objZip->close() === false) {
|
||||
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 ($originalFilename != $pFilename) {
|
||||
if (copy($pFilename, $originalFilename) === false) {
|
||||
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||
}
|
||||
|
|
@ -169,32 +173,34 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private function _chkContentTypes($src) {
|
||||
private function _chkContentTypes($src)
|
||||
{
|
||||
$srcInfo = pathinfo($src);
|
||||
$extension = strtolower($srcInfo['extension']);
|
||||
if(substr($extension, 0, 3) == 'php') {
|
||||
if (substr($extension, 0, 3) == 'php') {
|
||||
$extension = 'php';
|
||||
}
|
||||
$_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff', 'php');
|
||||
|
||||
if(in_array($extension, $_supportedImageTypes)) {
|
||||
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 ($imageext == 'jpeg') $imageext = 'jpg';
|
||||
|
||||
if(!in_array($imagetype, $this->_imageTypes)) {
|
||||
if (!in_array($imagetype, $this->_imageTypes)) {
|
||||
$this->_imageTypes[$imageext] = $imagetype;
|
||||
}
|
||||
} else {
|
||||
if(!in_array($extension, $this->_objectTypes)) {
|
||||
if (!in_array($extension, $this->_objectTypes)) {
|
||||
$this->_objectTypes[] = $extension;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getWriterPart($pPartName = '') {
|
||||
public function getWriterPart($pPartName = '')
|
||||
{
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
|
|
@ -202,11 +208,13 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
}
|
||||
}
|
||||
|
||||
public function getUseDiskCaching() {
|
||||
public function getUseDiskCaching()
|
||||
{
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
{
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($pDirectory)) {
|
||||
|
|
@ -220,21 +228,21 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter {
|
|||
return $this;
|
||||
}
|
||||
|
||||
private function _addFileToPackage($objZip, $element) {
|
||||
if(isset($element['isMemImage']) && $element['isMemImage']) {
|
||||
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);
|
||||
$objZip->addFromString('word/' . $element['target'], $imageContents);
|
||||
imagedestroy($image);
|
||||
|
||||
$this->_chkContentTypes($element['source']);
|
||||
} else {
|
||||
$objZip->addFile($element['source'], 'word/'.$element['target']);
|
||||
$objZip->addFile($element['source'], 'word/' . $element['target']);
|
||||
$this->_chkContentTypes($element['source']);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -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,28 +20,32 @@
|
|||
*
|
||||
* @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_Base
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
||||
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false) {
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false)
|
||||
{
|
||||
$styleFont = $text->getFontStyle();
|
||||
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
if(!$withoutP) {
|
||||
if (!$withoutP) {
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
|
|
@ -55,9 +59,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
if($SfIsObject) {
|
||||
if ($SfIsObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
} elseif(!$SfIsObject && !is_null($styleFont)) {
|
||||
} elseif (!$SfIsObject && !is_null($styleFont)) {
|
||||
$objWriter->startElement('w:rPr');
|
||||
$objWriter->startElement('w:rStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
|
|
@ -72,12 +76,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->endElement(); // w:r
|
||||
|
||||
if(!$withoutP) {
|
||||
if (!$withoutP) {
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun) {
|
||||
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun)
|
||||
{
|
||||
$elements = $textrun->getElements();
|
||||
$styleParagraph = $textrun->getParagraphStyle();
|
||||
|
||||
|
|
@ -85,9 +90,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
|
|
@ -95,11 +100,11 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(count($elements) > 0) {
|
||||
foreach($elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element, true);
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -108,7 +113,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false) {
|
||||
protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false)
|
||||
{
|
||||
$align = $style->getAlign();
|
||||
$spaceBefore = $style->getSpaceBefore();
|
||||
$spaceAfter = $style->getSpaceAfter();
|
||||
|
|
@ -116,68 +122,69 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$indent = $style->getIndent();
|
||||
$tabs = $style->getTabs();
|
||||
|
||||
if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) {
|
||||
if(!$withoutPPR) {
|
||||
if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) {
|
||||
if (!$withoutPPR) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
}
|
||||
|
||||
if(!is_null($align)) {
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($indent)) {
|
||||
if (!is_null($indent)) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:firstLine', 0);
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) {
|
||||
if (!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) {
|
||||
$objWriter->startElement('w:spacing');
|
||||
if(!is_null($spaceBefore)) {
|
||||
if (!is_null($spaceBefore)) {
|
||||
$objWriter->writeAttribute('w:before', $spaceBefore);
|
||||
}
|
||||
if(!is_null($spaceAfter)) {
|
||||
if (!is_null($spaceAfter)) {
|
||||
$objWriter->writeAttribute('w:after', $spaceAfter);
|
||||
}
|
||||
if(!is_null($spacing)) {
|
||||
if (!is_null($spacing)) {
|
||||
$objWriter->writeAttribute('w:line', $spacing);
|
||||
$objWriter->writeAttribute('w:lineRule', 'auto');
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($tabs)) {
|
||||
if (!is_null($tabs)) {
|
||||
$tabs->toXml($objWriter);
|
||||
}
|
||||
|
||||
if(!$withoutPPR) {
|
||||
if (!$withoutPPR) {
|
||||
$objWriter->endElement(); // w:pPr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false) {
|
||||
protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false)
|
||||
{
|
||||
$rID = $link->getRelationId();
|
||||
$linkName = $link->getLinkName();
|
||||
if(is_null($linkName)) {
|
||||
if (is_null($linkName)) {
|
||||
$linkName = $link->getLinkSrc();
|
||||
}
|
||||
|
||||
$styleFont = $link->getFontStyle();
|
||||
$SfIsObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
if(!$withoutP) {
|
||||
if (!$withoutP) {
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
$styleParagraph = $link->getParagraphStyle();
|
||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
|
|
@ -187,13 +194,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
|
||||
$objWriter->startElement('w:hyperlink');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rID);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rID);
|
||||
$objWriter->writeAttribute('w:history', '1');
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
if($SfIsObject) {
|
||||
if ($SfIsObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
} elseif(!$SfIsObject && !is_null($styleFont)) {
|
||||
} elseif (!$SfIsObject && !is_null($styleFont)) {
|
||||
$objWriter->startElement('w:rPr');
|
||||
$objWriter->startElement('w:rStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
|
|
@ -209,12 +216,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->endElement();
|
||||
|
||||
if(!$withoutP) {
|
||||
if (!$withoutP) {
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun) {
|
||||
protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footer_PreserveText $textrun)
|
||||
{
|
||||
$styleFont = $textrun->getFontStyle();
|
||||
$styleParagraph = $textrun->getParagraphStyle();
|
||||
|
||||
|
|
@ -225,9 +233,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
|
|
@ -235,9 +243,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
foreach($arrText as $text) {
|
||||
foreach ($arrText as $text) {
|
||||
|
||||
if(substr($text, 0, 1) == '{') {
|
||||
if (substr($text, 0, 1) == '{') {
|
||||
$text = substr($text, 1, -1);
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
|
|
@ -248,9 +256,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
if($SfIsObject) {
|
||||
if ($SfIsObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
} elseif(!$SfIsObject && !is_null($styleFont)) {
|
||||
} elseif (!$SfIsObject && !is_null($styleFont)) {
|
||||
$objWriter->startElement('w:rPr');
|
||||
$objWriter->startElement('w:rStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
|
|
@ -281,9 +289,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
if($SfIsObject) {
|
||||
if ($SfIsObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
} elseif(!$SfIsObject && !is_null($styleFont)) {
|
||||
} elseif (!$SfIsObject && !is_null($styleFont)) {
|
||||
$objWriter->startElement('w:rPr');
|
||||
$objWriter->startElement('w:rStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
|
|
@ -302,7 +310,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement(); // p
|
||||
}
|
||||
|
||||
protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style) {
|
||||
protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Font $style)
|
||||
{
|
||||
$font = $style->getName();
|
||||
$bold = $style->getBold();
|
||||
$italic = $style->getItalic();
|
||||
|
|
@ -315,7 +324,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->startElement('w:rPr');
|
||||
|
||||
// Font
|
||||
if($font != 'Arial') {
|
||||
if ($font != 'Arial') {
|
||||
$objWriter->startElement('w:rFonts');
|
||||
$objWriter->writeAttribute('w:ascii', $font);
|
||||
$objWriter->writeAttribute('w:hAnsi', $font);
|
||||
|
|
@ -324,14 +333,14 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
|
||||
// Color
|
||||
if($color != '000000') {
|
||||
if ($color != '000000') {
|
||||
$objWriter->startElement('w:color');
|
||||
$objWriter->writeAttribute('w:val', $color);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Size
|
||||
if($size != 20) {
|
||||
if ($size != 20) {
|
||||
$objWriter->startElement('w:sz');
|
||||
$objWriter->writeAttribute('w:val', $size);
|
||||
$objWriter->endElement();
|
||||
|
|
@ -341,30 +350,30 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
|
||||
// Bold
|
||||
if($bold) {
|
||||
if ($bold) {
|
||||
$objWriter->writeElement('w:b', null);
|
||||
}
|
||||
|
||||
// Italic
|
||||
if($italic) {
|
||||
if ($italic) {
|
||||
$objWriter->writeElement('w:i', null);
|
||||
$objWriter->writeElement('w:iCs', null);
|
||||
}
|
||||
|
||||
// Underline
|
||||
if(!is_null($underline) && $underline != 'none') {
|
||||
if (!is_null($underline) && $underline != 'none') {
|
||||
$objWriter->startElement('w:u');
|
||||
$objWriter->writeAttribute('w:val', $underline);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Striketrough
|
||||
if($striketrough) {
|
||||
if ($striketrough) {
|
||||
$objWriter->writeElement('w:strike', null);
|
||||
}
|
||||
|
||||
// Foreground-Color
|
||||
if(!is_null($fgColor)) {
|
||||
if (!is_null($fgColor)) {
|
||||
$objWriter->startElement('w:highlight');
|
||||
$objWriter->writeAttribute('w:val', $fgColor);
|
||||
$objWriter->endElement();
|
||||
|
|
@ -373,21 +382,23 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->writeElement('w:p', null);
|
||||
}
|
||||
|
||||
protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table) {
|
||||
protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Table $table)
|
||||
{
|
||||
$_rows = $table->getRows();
|
||||
$_cRows = count($_rows);
|
||||
|
||||
if($_cRows > 0) {
|
||||
if ($_cRows > 0) {
|
||||
$objWriter->startElement('w:tbl');
|
||||
$tblStyle = $table->getStyle();
|
||||
if($tblStyle instanceof PHPWord_Style_Table) {
|
||||
if ($tblStyle instanceof PHPWord_Style_Table) {
|
||||
$this->_writeTableStyle($objWriter, $tblStyle);
|
||||
} else {
|
||||
if(!empty($tblStyle)) {
|
||||
if (!empty($tblStyle)) {
|
||||
$objWriter->startElement('w:tblPr');
|
||||
$objWriter->startElement('w:tblStyle');
|
||||
$objWriter->writeAttribute('w:val', $tblStyle);
|
||||
|
|
@ -397,13 +408,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
|
||||
$_heights = $table->getRowHeights();
|
||||
for($i=0; $i<$_cRows; $i++) {
|
||||
for ($i = 0; $i < $_cRows; $i++) {
|
||||
$row = $_rows[$i];
|
||||
$height = $_heights[$i];
|
||||
|
||||
$objWriter->startElement('w:tr');
|
||||
|
||||
if(!is_null($height)) {
|
||||
if (!is_null($height)) {
|
||||
$objWriter->startElement('w:trPr');
|
||||
$objWriter->startElement('w:trHeight');
|
||||
$objWriter->writeAttribute('w:val', $height);
|
||||
|
|
@ -411,7 +422,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
foreach($row as $cell) {
|
||||
foreach ($row as $cell) {
|
||||
$objWriter->startElement('w:tc');
|
||||
|
||||
$cellStyle = $cell->getStyle();
|
||||
|
|
@ -423,31 +434,32 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
|
||||
if($cellStyle instanceof PHPWord_Style_Cell) {
|
||||
if ($cellStyle instanceof PHPWord_Style_Cell) {
|
||||
$this->_writeCellStyle($objWriter, $cellStyle);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$_elements = $cell->getElements();
|
||||
if(count($_elements) > 0) {
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
if (count($_elements) > 0) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_ListItem) {
|
||||
} elseif ($element instanceof PHPWord_Section_ListItem) {
|
||||
$this->_writeListItem($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage
|
||||
) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Object) {
|
||||
} elseif ($element instanceof PHPWord_Section_Object) {
|
||||
$this->_writeObject($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
} elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
|
@ -463,39 +475,40 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
}
|
||||
|
||||
protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null) {
|
||||
protected function _writeTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Table $style = null)
|
||||
{
|
||||
$margins = $style->getCellMargin();
|
||||
$mTop = (!is_null($margins[0])) ? true : false;
|
||||
$mLeft = (!is_null($margins[1])) ? true : false;
|
||||
$mRight = (!is_null($margins[2])) ? true : false;
|
||||
$mBottom = (!is_null($margins[3])) ? true : false;
|
||||
|
||||
if($mTop || $mLeft || $mRight || $mBottom) {
|
||||
if ($mTop || $mLeft || $mRight || $mBottom) {
|
||||
$objWriter->startElement('w:tblPr');
|
||||
$objWriter->startElement('w:tblCellMar');
|
||||
|
||||
if($mTop) {
|
||||
if ($mTop) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:w', $margins[0]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($mLeft) {
|
||||
if ($mLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:w', $margins[1]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($mRight) {
|
||||
if ($mRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:w', $margins[2]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($mBottom) {
|
||||
if ($mBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:w', $margins[3]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
|
|
@ -507,7 +520,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
}
|
||||
|
||||
protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null) {
|
||||
protected function _writeCellStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Cell $style = null)
|
||||
{
|
||||
$bgColor = $style->getBgColor();
|
||||
$valign = $style->getVAlign();
|
||||
$textDir = $style->getTextDirection();
|
||||
|
|
@ -522,14 +536,14 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $borders) ? true : false;
|
||||
|
||||
if($styles) {
|
||||
if(!is_null($textDir)) {
|
||||
if ($styles) {
|
||||
if (!is_null($textDir)) {
|
||||
$objWriter->startElement('w:textDirection');
|
||||
$objWriter->writeAttribute('w:val', $textDir);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($bgColor)) {
|
||||
if (!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
|
|
@ -537,18 +551,20 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($valign)) {
|
||||
if (!is_null($valign)) {
|
||||
$objWriter->startElement('w:vAlign');
|
||||
$objWriter->writeAttribute('w:val', $valign);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($borders) {
|
||||
if ($borders) {
|
||||
$_defaultColor = $style->getDefaultBorderColor();
|
||||
|
||||
$objWriter->startElement('w:tcBorders');
|
||||
if($bTop) {
|
||||
if(is_null($brdCol[0])) { $brdCol[0] = $_defaultColor; }
|
||||
if ($bTop) {
|
||||
if (is_null($brdCol[0])) {
|
||||
$brdCol[0] = $_defaultColor;
|
||||
}
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
|
|
@ -556,8 +572,10 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($bLeft) {
|
||||
if(is_null($brdCol[1])) { $brdCol[1] = $_defaultColor; }
|
||||
if ($bLeft) {
|
||||
if (is_null($brdCol[1])) {
|
||||
$brdCol[1] = $_defaultColor;
|
||||
}
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
|
|
@ -565,8 +583,10 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($bRight) {
|
||||
if(is_null($brdCol[2])) { $brdCol[2] = $_defaultColor; }
|
||||
if ($bRight) {
|
||||
if (is_null($brdCol[2])) {
|
||||
$brdCol[2] = $_defaultColor;
|
||||
}
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
|
|
@ -574,8 +594,10 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($bBottom) {
|
||||
if(is_null($brdCol[3])) { $brdCol[3] = $_defaultColor; }
|
||||
if ($bBottom) {
|
||||
if (is_null($brdCol[3])) {
|
||||
$brdCol[3] = $_defaultColor;
|
||||
}
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
|
|
@ -587,31 +609,39 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
}
|
||||
$gridSpan = $style->getGridSpan();
|
||||
if(!is_null($gridSpan)) {
|
||||
if (!is_null($gridSpan)) {
|
||||
$objWriter->startElement('w:gridSpan');
|
||||
$objWriter->writeAttribute('w:val', $gridSpan);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$vMerge = $style->getVMerge();
|
||||
if(!is_null($vMerge)) {
|
||||
if (!is_null($vMerge)) {
|
||||
$objWriter->startElement('w:vMerge');
|
||||
$objWriter->writeAttribute('w:val', $vMerge);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image) {
|
||||
/**
|
||||
* @param \PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param \PHPWord_Section_Image $image
|
||||
*/
|
||||
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image)
|
||||
{
|
||||
$rId = $image->getRelationId();
|
||||
|
||||
$style = $image->getStyle();
|
||||
$width = $style->getWidth();
|
||||
$height = $style->getHeight();
|
||||
$align = $style->getAlign();
|
||||
$marginTop = $style->getMarginTop();
|
||||
$marginLeft = $style->getMarginLeft();
|
||||
$wrappingStyle = $style->getWrappingStyle();
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if(!is_null($align)) {
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
|
|
@ -625,10 +655,40 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('v:shape');
|
||||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||
$objWriter->writeAttribute('style', 'width:'.$width.'px;height:'.$height.'px');
|
||||
|
||||
$imgStyle = '';
|
||||
if (null !== $width) {
|
||||
$imgStyle .= 'width:' . $width . 'px;';
|
||||
}
|
||||
if (null !== $height) {
|
||||
$imgStyle .= 'height:' . $height . 'px;';
|
||||
}
|
||||
if (null !== $marginTop) {
|
||||
$imgStyle .= 'margin-top:' . $marginTop . 'in;';
|
||||
}
|
||||
if (null !== $marginLeft) {
|
||||
$imgStyle .= 'margin-left:' . $marginLeft . 'in;';
|
||||
}
|
||||
|
||||
switch ($wrappingStyle) {
|
||||
case PHPWord_Style_Image::WRAPPING_STYLE_BEHIND:
|
||||
$imgStyle .= 'position:absolute;z-index:-251658752;';
|
||||
break;
|
||||
case PHPWord_Style_Image::WRAPPING_STYLE_SQUARE:
|
||||
$imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;';
|
||||
break;
|
||||
case PHPWord_Style_Image::WRAPPING_STYLE_TIGHT:
|
||||
$imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute';
|
||||
break;
|
||||
case PHPWord_Style_Image::WRAPPING_STYLE_INFRONT:
|
||||
$imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;';
|
||||
break;
|
||||
}
|
||||
|
||||
$objWriter->writeAttribute('style', $imgStyle);
|
||||
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$objWriter->writeAttribute('o:title', '');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
|
@ -640,7 +700,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image) {
|
||||
protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image)
|
||||
{
|
||||
$rId = $image->getRelationId();
|
||||
|
||||
$style = $image->getStyle();
|
||||
|
|
@ -659,19 +720,19 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||
|
||||
$strStyle = 'position:absolute;';
|
||||
$strStyle .= ' width:'.$width.'px;';
|
||||
$strStyle .= ' height:'.$height.'px;';
|
||||
if(!is_null($marginTop)) {
|
||||
$strStyle .= ' margin-top:'.$marginTop.'px;';
|
||||
$strStyle .= ' width:' . $width . 'px;';
|
||||
$strStyle .= ' height:' . $height . 'px;';
|
||||
if (!is_null($marginTop)) {
|
||||
$strStyle .= ' margin-top:' . $marginTop . 'px;';
|
||||
}
|
||||
if(!is_null($marginLeft)) {
|
||||
$strStyle .= ' margin-left:'.$marginLeft.'px;';
|
||||
if (!is_null($marginLeft)) {
|
||||
$strStyle .= ' margin-left:' . $marginLeft . 'px;';
|
||||
}
|
||||
|
||||
$objWriter->writeAttribute('style', $strStyle);
|
||||
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$objWriter->writeAttribute('o:title', '');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
|
@ -683,7 +744,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title) {
|
||||
protected function _writeTitle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Title $title)
|
||||
{
|
||||
$text = htmlspecialchars($title->getText());
|
||||
$text = PHPWord_Shared_String::ControlCharacterPHP2OOXML($text);
|
||||
$anchor = $title->getAnchor();
|
||||
|
|
@ -692,7 +754,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if(!empty($style)) {
|
||||
if (!empty($style)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $style);
|
||||
|
|
@ -724,4 +786,3 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -55,12 +59,12 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
);
|
||||
|
||||
// Add media content-types
|
||||
foreach($_imageTypes as $key => $value) {
|
||||
foreach ($_imageTypes as $key => $value) {
|
||||
$this->_writeDefaultContentType($objWriter, $key, $value);
|
||||
}
|
||||
|
||||
// Add embedding content-types
|
||||
if(count($_objectTypes) > 0) {
|
||||
if (count($_objectTypes) > 0) {
|
||||
$this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject');
|
||||
}
|
||||
|
||||
|
|
@ -108,15 +112,15 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
$objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
);
|
||||
|
||||
for($i=1; $i<=$_cHdrs; $i++) {
|
||||
for ($i = 1; $i <= $_cHdrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/header'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
$objWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
);
|
||||
}
|
||||
|
||||
for($i=1; $i<=$_cFtrs; $i++) {
|
||||
for ($i = 1; $i <= $_cFtrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/footer'.$i.'.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
$objWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -134,8 +138,9 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '') {
|
||||
if(PHPWord_Shared_File::file_exists($pFile)) {
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPWord_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
|
|
@ -151,8 +156,9 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') {
|
||||
if($pPartname != '' && $pContentType != '') {
|
||||
private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
|
|
@ -171,8 +177,9 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') {
|
||||
if($pPartname != '' && $pContentType != '') {
|
||||
private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
|
|
|
|||
|
|
@ -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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
public function writeDocPropsApp(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -38,7 +42,7 @@ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPar
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
|
|
@ -119,7 +123,8 @@ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPar
|
|||
}
|
||||
|
||||
|
||||
public function writeDocPropsCore(PHPWord $pPHPWord = null) {
|
||||
public function writeDocPropsCore(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -129,7 +134,7 @@ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPar
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
|
|
|
|||
|
|
@ -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,25 +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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Document
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
||||
|
||||
public function writeDocument(PHPWord $pPHPWord = null) {
|
||||
public function writeDocument(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
||||
if($this->getParentWriter()->getUseDiskCaching()) {
|
||||
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->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// w:document
|
||||
$objWriter->startElement('w:document');
|
||||
|
|
@ -59,40 +63,41 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$countSections = count($_sections);
|
||||
$pSection = 0;
|
||||
|
||||
if($countSections > 0) {
|
||||
foreach($_sections as $section) {
|
||||
if ($countSections > 0) {
|
||||
foreach ($_sections as $section) {
|
||||
$pSection++;
|
||||
|
||||
$_elements = $section->getElements();
|
||||
|
||||
foreach($_elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Title) {
|
||||
} elseif ($element instanceof PHPWord_Section_Title) {
|
||||
$this->_writeTitle($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_PageBreak) {
|
||||
$this->_writePageBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_ListItem) {
|
||||
} elseif ($element instanceof PHPWord_Section_ListItem) {
|
||||
$this->_writeListItem($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage
|
||||
) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Object) {
|
||||
} elseif ($element instanceof PHPWord_Section_Object) {
|
||||
$this->_writeObject($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_TOC) {
|
||||
} elseif ($element instanceof PHPWord_TOC) {
|
||||
$this->_writeTOC($objWriter);
|
||||
}
|
||||
}
|
||||
|
||||
if($pSection == $countSections) {
|
||||
if ($pSection == $countSections) {
|
||||
$this->_writeEndSection($objWriter, $section);
|
||||
} else {
|
||||
$this->_writeSection($objWriter, $section);
|
||||
|
|
@ -107,7 +112,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) {
|
||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:pPr');
|
||||
$this->_writeEndSection($objWriter, $section, 3);
|
||||
|
|
@ -115,7 +121,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section) {
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
$_settings = $section->getSettings();
|
||||
$_headers = $section->getHeaders();
|
||||
$_footer = $section->getFooter();
|
||||
|
|
@ -136,20 +143,20 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$rId = $_header->getRelationId();
|
||||
$objWriter->startElement('w:headerReference');
|
||||
$objWriter->writeAttribute('w:type', $_header->getType());
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($section->hasDifferentFirstPage()) {
|
||||
if ($section->hasDifferentFirstPage()) {
|
||||
$objWriter->startElement('w:titlePg');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($_footer)) {
|
||||
if (!is_null($_footer)) {
|
||||
$rId = $_footer->getRelationId();
|
||||
$objWriter->startElement('w:footerReference');
|
||||
$objWriter->writeAttribute('w:type', 'default');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +164,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->writeAttribute('w:w', $pgSzW);
|
||||
$objWriter->writeAttribute('w:h', $pgSzH);
|
||||
|
||||
if(!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
||||
if (!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
||||
$objWriter->writeAttribute('w:orient', $orientation);
|
||||
}
|
||||
|
||||
|
|
@ -174,13 +181,13 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
|
||||
|
||||
if(!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
|
||||
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])) {
|
||||
if (!is_null($borders[0])) {
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $borders[0]);
|
||||
|
|
@ -189,7 +196,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($borders[1])) {
|
||||
if (!is_null($borders[1])) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $borders[1]);
|
||||
|
|
@ -198,7 +205,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($borders[2])) {
|
||||
if (!is_null($borders[2])) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $borders[2]);
|
||||
|
|
@ -207,7 +214,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($borders[3])) {
|
||||
if (!is_null($borders[3])) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $borders[3]);
|
||||
|
|
@ -227,7 +234,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:br');
|
||||
|
|
@ -237,7 +245,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem) {
|
||||
private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
|
||||
{
|
||||
$textObject = $listItem->getTextObject();
|
||||
$text = $textObject->getText();
|
||||
$styleParagraph = $textObject->getParagraphStyle();
|
||||
|
|
@ -249,9 +258,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->startElement('w:p');
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph, true);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
$objWriter->endElement();
|
||||
|
|
@ -275,10 +284,11 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object) {
|
||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object)
|
||||
{
|
||||
$rIdObject = $object->getRelationId();
|
||||
$rIdImage = $object->getImageRelationId();
|
||||
$shapeId = md5($rIdObject.'_'.$rIdImage);
|
||||
$shapeId = md5($rIdObject . '_' . $rIdImage);
|
||||
|
||||
$objectId = $object->getObjectId();
|
||||
|
||||
|
|
@ -290,7 +300,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if(!is_null($align)) {
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
|
|
@ -311,7 +321,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->writeAttribute('o:ole', '');
|
||||
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdImage);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rIdImage);
|
||||
$objWriter->writeAttribute('o:title', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
|
|
@ -322,8 +332,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->writeAttribute('ProgID', 'Package');
|
||||
$objWriter->writeAttribute('ShapeID', $shapeId);
|
||||
$objWriter->writeAttribute('DrawAspect', 'Icon');
|
||||
$objWriter->writeAttribute('ObjectID', '_'.$objectId);
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$rIdObject);
|
||||
$objWriter->writeAttribute('ObjectID', '_' . $objectId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $rIdObject);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
|
@ -333,7 +343,8 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$titles = PHPWord_TOC::getTitles();
|
||||
$styleFont = PHPWord_TOC::getStyleFont();
|
||||
|
||||
|
|
@ -344,7 +355,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$isObject = ($styleFont instanceof PHPWord_Style_Font) ? true : false;
|
||||
|
||||
for($i=0; $i<count($titles); $i++) {
|
||||
for ($i = 0; $i < count($titles); $i++) {
|
||||
$title = $titles[$i];
|
||||
$indent = ($title['depth'] - 1) * $fIndent;
|
||||
|
||||
|
|
@ -352,17 +363,17 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
||||
if($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||
if ($isObject && !is_null($styleFont->getParagraphStyle())) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleFont->getParagraphStyle());
|
||||
}
|
||||
|
||||
if($indent > 0) {
|
||||
if ($indent > 0) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!empty($styleFont) && !$isObject) {
|
||||
if (!empty($styleFont) && !$isObject) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleFont);
|
||||
|
|
@ -373,7 +384,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->startElement('w:tabs');
|
||||
$objWriter->startElement('w:tab');
|
||||
$objWriter->writeAttribute('w:val', 'right');
|
||||
if(!empty($tabLeader)) {
|
||||
if (!empty($tabLeader)) {
|
||||
$objWriter->writeAttribute('w:leader', $tabLeader);
|
||||
}
|
||||
$objWriter->writeAttribute('w:pos', $tabPos);
|
||||
|
|
@ -383,7 +394,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement(); // w:pPr
|
||||
|
||||
|
||||
if($i == 0) {
|
||||
if ($i == 0) {
|
||||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:fldChar');
|
||||
$objWriter->writeAttribute('w:fldCharType', 'begin');
|
||||
|
|
@ -410,7 +421,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->startElement('w:r');
|
||||
|
||||
if($isObject) {
|
||||
if ($isObject) {
|
||||
$this->_writeTextStyle($objWriter, $styleFont);
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +443,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->startElement('w:r');
|
||||
$objWriter->startElement('w:instrText');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRaw('PAGEREF '.$title['anchor'].' \h');
|
||||
$objWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h');
|
||||
$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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
public function writeDocumentRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -38,7 +42,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
|
|
@ -93,7 +97,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
);
|
||||
|
||||
// Relationships to Images / Embeddings / Headers / Footers
|
||||
foreach($_relsCollection as $relation) {
|
||||
foreach ($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
|
|
@ -102,7 +106,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
$relationName,
|
||||
$targetMode
|
||||
);
|
||||
|
|
@ -115,7 +119,8 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
public function writeHeaderFooterRels($_relsCollection) {
|
||||
public function writeHeaderFooterRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -125,14 +130,14 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$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) {
|
||||
foreach ($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
|
|
@ -140,7 +145,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType,
|
||||
$relationName
|
||||
);
|
||||
}
|
||||
|
|
@ -152,9 +157,10 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') {
|
||||
if($pType != '' && $pTarget != '') {
|
||||
if(strpos($pId, 'rId') === false) {
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
if (strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +170,7 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if($pTargetMode != '') {
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
|
|
@ -174,4 +180,3 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
public function writeFooter(PHPWord_Section_Footer $footer)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -41,31 +45,32 @@ class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base {
|
|||
$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');
|
||||
$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) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage
|
||||
) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
} elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
|
@ -76,4 +81,3 @@ class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base {
|
|||
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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
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());
|
||||
|
|
@ -40,36 +44,37 @@ class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base {
|
|||
$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');
|
||||
$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) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
if(!$element->getIsWatermark()) {
|
||||
} 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) {
|
||||
} elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
|
||||
$this->_writePreserveText($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
|
@ -80,4 +85,3 @@ class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base {
|
|||
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,15 +20,19 @@
|
|||
*
|
||||
* @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) {
|
||||
public function writeRelationships(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
|
|
@ -38,7 +42,7 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart {
|
|||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
|
|
@ -86,9 +90,10 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart {
|
|||
* @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) {
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
if (strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +103,7 @@ class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if($pTargetMode != '') {
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,24 @@
|
|||
*
|
||||
* @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 extends PHPWord_Writer_Word2007_Base {
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Styles
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
private $_document;
|
||||
|
||||
public function writeStyles(PHPWord $pPHPWord = null) {
|
||||
public function writeStyles(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if($this->getParentWriter()->getUseDiskCaching()) {
|
||||
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);
|
||||
|
|
@ -42,7 +46,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$this->_document = $pPHPWord;
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
$objWriter->startElement('w:styles');
|
||||
|
||||
|
|
@ -55,27 +59,27 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
if(count($styles) > 0) {
|
||||
foreach($styles as $styleName => $style) {
|
||||
if($style instanceof PHPWord_Style_Font) {
|
||||
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)) {
|
||||
if (!is_null($paragraphStyle)) {
|
||||
$type = 'paragraph';
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
if($styleType == 'title') {
|
||||
if ($styleType == 'title') {
|
||||
$arrStyle = explode('_', $styleName);
|
||||
$styleId = 'Heading'.$arrStyle[1];
|
||||
$styleName = 'heading '.$arrStyle[1];
|
||||
$styleLink = 'Heading'.$arrStyle[1].'Char';
|
||||
$styleId = 'Heading' . $arrStyle[1];
|
||||
$styleName = 'heading ' . $arrStyle[1];
|
||||
$styleLink = 'Heading' . $arrStyle[1] . 'Char';
|
||||
$objWriter->writeAttribute('w:styleId', $styleId);
|
||||
|
||||
$objWriter->startElement('w:link');
|
||||
|
|
@ -87,7 +91,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
if(!is_null($paragraphStyle)) {
|
||||
if (!is_null($paragraphStyle)) {
|
||||
$this->_writeParagraphStyle($objWriter, $paragraphStyle);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +99,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif($style instanceof PHPWord_Style_Paragraph) {
|
||||
} elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'paragraph');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
|
|
@ -108,7 +112,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$this->_writeParagraphStyle($objWriter, $style);
|
||||
$objWriter->endElement();
|
||||
|
||||
} elseif($style instanceof PHPWord_Style_TableFull) {
|
||||
} elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'table');
|
||||
$objWriter->writeAttribute('w:customStyle', '1');
|
||||
|
|
@ -135,7 +139,8 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style) {
|
||||
private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
|
|
@ -158,28 +163,28 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->startElement('w:tblPr');
|
||||
|
||||
if($margins) {
|
||||
if ($margins) {
|
||||
$objWriter->startElement('w:tblCellMar');
|
||||
if($mTop) {
|
||||
if ($mTop) {
|
||||
echo $margins[0];
|
||||
$objWriter->startElement('w:top');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[0]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mLeft) {
|
||||
if ($mLeft) {
|
||||
$objWriter->startElement('w:left');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[1]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mRight) {
|
||||
if ($mRight) {
|
||||
$objWriter->startElement('w:right');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[2]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if($mBottom) {
|
||||
if ($mBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:w', $cellMargin[3]);
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
|
|
@ -188,44 +193,44 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if($borders) {
|
||||
if ($borders) {
|
||||
$objWriter->startElement('w:tblBorders');
|
||||
if($bTop) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
if ($bInsV) {
|
||||
$objWriter->startElement('w:insideV');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[5]);
|
||||
|
|
@ -237,7 +242,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
$objWriter->endElement();
|
||||
|
||||
if(!is_null($bgColor)) {
|
||||
if (!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:tcPr');
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
|
|
@ -250,12 +255,13 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
|
||||
// First Row
|
||||
$firstRow = $style->getFirstRow();
|
||||
if(!is_null($firstRow)) {
|
||||
if (!is_null($firstRow)) {
|
||||
$this->_writeRowStyle($objWriter, 'firstRow', $firstRow);
|
||||
}
|
||||
}
|
||||
|
||||
private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style) {
|
||||
private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
|
|
@ -270,7 +276,7 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$objWriter->writeAttribute('w:type', $type);
|
||||
|
||||
$objWriter->startElement('w:tcPr');
|
||||
if(!is_null($bgColor)) {
|
||||
if (!is_null($bgColor)) {
|
||||
$objWriter->startElement('w:shd');
|
||||
$objWriter->writeAttribute('w:val', 'clear');
|
||||
$objWriter->writeAttribute('w:color', 'auto');
|
||||
|
|
@ -279,28 +285,28 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
}
|
||||
|
||||
$objWriter->startElement('w:tcBorders');
|
||||
if($bTop) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
if ($bBottom) {
|
||||
$objWriter->startElement('w:bottom');
|
||||
$objWriter->writeAttribute('w:val', 'single');
|
||||
$objWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
|
|
@ -315,7 +321,8 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
}
|
||||
|
||||
|
||||
private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null) {
|
||||
private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$fontName = $this->_document->getDefaultFontName();
|
||||
$fontSize = $this->_document->getDefaultFontSize();
|
||||
|
||||
|
|
@ -343,4 +350,3 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base {
|
|||
$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,20 +20,25 @@
|
|||
*
|
||||
* @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
|
||||
*/
|
||||
abstract class PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
private $_parentWriter;
|
||||
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null) {
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
|
||||
{
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
public function getParentWriter() {
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
## 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
|
||||
|
|
@ -38,3 +38,4 @@ Fixed in branch for release 0.7 :
|
|||
- 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
|
||||
- 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;
|
||||
?>
|
||||
|
|
@ -61,4 +61,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;
|
||||
?>
|
||||
|
|
@ -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