Merge remote-tracking branch 'remotes/upstream/develop' into develop
Conflicts: Classes/PHPWord/Section/Settings.php Classes/PHPWord/Section/TextRun.php Classes/PHPWord/Writer/Word2007/Base.php README.md
This commit is contained in:
commit
d3f62567e9
|
|
@ -1,6 +1,5 @@
|
|||
language: php
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
|
@ -13,7 +12,7 @@ matrix:
|
|||
before_script:
|
||||
## Composer
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- php composer.phar install
|
||||
- php composer.phar install --prefer-source
|
||||
## PHP_CodeSniffer
|
||||
- pyrus install pear/PHP_CodeSniffer
|
||||
- phpenv rehash
|
||||
|
|
@ -36,9 +35,11 @@ script:
|
|||
## PHP Copy/Paste Detector
|
||||
- php phpcpd.phar --verbose Classes/
|
||||
## PHP Mess Detector
|
||||
- phpmd Classes/ text codesize,unusedcode,naming,design
|
||||
- phpmd Classes/ text unusedcode,naming,design
|
||||
## PHPLOC
|
||||
- php phploc.phar Classes/
|
||||
## PHPUnit
|
||||
- phpunit -c ./ --coverage-text
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -31,9 +31,13 @@ if (!defined('PHPWORD_BASE_PATH')) {
|
|||
|
||||
/**
|
||||
* Class PHPWord_Autoloader
|
||||
*
|
||||
* TODO: remove legacy autoloader once everything is moved to namespaces
|
||||
*/
|
||||
class PHPWord_Autoloader
|
||||
{
|
||||
const PREFIX = 'PHPWord';
|
||||
|
||||
/**
|
||||
* Register the autoloader
|
||||
*
|
||||
|
|
@ -41,7 +45,8 @@ class PHPWord_Autoloader
|
|||
*/
|
||||
public static function register()
|
||||
{
|
||||
spl_autoload_register(array('PHPWord_Autoloader', 'load'));
|
||||
spl_autoload_register(array('PHPWord_Autoloader', 'load')); // Legacy
|
||||
spl_autoload_register(array(new self, 'autoload')); // PSR-4
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,4 +65,21 @@ class PHPWord_Autoloader
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoloader
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
$prefixLength = strlen(self::PREFIX);
|
||||
if (0 === strncmp(self::PREFIX, $class, $prefixLength)) {
|
||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
||||
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -150,26 +150,23 @@ class PHPWord_Section_Settings
|
|||
*/
|
||||
private $_borderBottomColor;
|
||||
|
||||
|
||||
/**
|
||||
* Section Columns Count
|
||||
* Page Numbering Start
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_colsNum;
|
||||
private $pageNumberingStart;
|
||||
|
||||
/**
|
||||
* Section Spacing Between Columns
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_colsSpace;
|
||||
private $headerHeight;
|
||||
|
||||
/**
|
||||
* Section Break Type
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
private $_breakType;
|
||||
private $footerHeight;
|
||||
|
||||
/**
|
||||
* Create new Section Settings
|
||||
|
|
@ -191,9 +188,8 @@ class PHPWord_Section_Settings
|
|||
$this->_borderRightColor = null;
|
||||
$this->_borderBottomSize = null;
|
||||
$this->_borderBottomColor = null;
|
||||
$this->_colsNum = 1;
|
||||
$this->_colsSpace = 720;
|
||||
$this->_breakType = null;
|
||||
$this->headerHeight = 720; // set default header and footer to 720 twips (.5 inches)
|
||||
$this->footerHeight = 720;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -568,59 +564,58 @@ class PHPWord_Section_Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* Set Section Columns Count
|
||||
*
|
||||
* @param in $pValue
|
||||
* @param null|int $pageNumberingStart
|
||||
* @return $this
|
||||
*/
|
||||
public function setColsNum($pValue = '') {
|
||||
$this->_colsNum = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function setPageNumberingStart($pageNumberingStart = null)
|
||||
{
|
||||
$this->pageNumberingStart = $pageNumberingStart;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Columns Count
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPageNumberingStart()
|
||||
{
|
||||
return $this->pageNumberingStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColsNum() {
|
||||
return $this->_colsNum;
|
||||
}
|
||||
public function getHeaderHeight() {
|
||||
return $this->headerHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Section Space Between Columns
|
||||
* Set Header Height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setColsSpace($pValue = '') {
|
||||
$this->_colsSpace = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function setHeaderHeight($pValue = '') {
|
||||
$this->headerHeight = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Section Space Between Columns
|
||||
* Get Footer Height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColsSpace() {
|
||||
return $this->_colsSpace;
|
||||
}
|
||||
public function getFooterHeight() {
|
||||
return $this->footerHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Break Type
|
||||
* Set Footer Height
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBreakType($pValue = null) {
|
||||
$this->_breakType = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Break Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBreakType() {
|
||||
return $this->_breakType;
|
||||
}
|
||||
public function setFooterHeight($pValue = '') {
|
||||
$this->footerHeight = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -80,11 +80,10 @@ class PHPWord_Section_Table_Cell
|
|||
$this->_insideOf = $insideOf;
|
||||
$this->_pCount = $pCount;
|
||||
$this->_width = $width;
|
||||
$this->_style = new PHPWord_Style_Cell;
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -110,15 +110,26 @@ class PHPWord_Section_TextRun
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
* Add a Image Element
|
||||
*
|
||||
* @param string $imageSrc
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($imageSrc, $style = null) {
|
||||
$image = new PHPWord_Section_Image($imageSrc, $style);
|
||||
|
||||
if (!is_null($image->getSource())) {
|
||||
$rID = PHPWord_Media::addSectionMediaElement($imageSrc, 'image');
|
||||
$image->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $image;
|
||||
return $image;
|
||||
} else {
|
||||
trigger_error('Source does not exist or unsupported image type.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TextRun content
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -81,8 +81,9 @@ class PHPWord_Template
|
|||
*
|
||||
* @param mixed $search
|
||||
* @param mixed $replace
|
||||
* @param integer $limit
|
||||
*/
|
||||
public function setValue($search, $replace)
|
||||
public function setValue($search, $replace, $limit = -1)
|
||||
{
|
||||
$pattern = '|\$\{([^\}]+)\}|U';
|
||||
preg_match_all($pattern, $this->_documentXML, $matches);
|
||||
|
|
@ -102,7 +103,12 @@ class PHPWord_Template
|
|||
}
|
||||
}
|
||||
|
||||
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
||||
$regExpDelim = '/';
|
||||
$escapedSearch = preg_quote($search, $regExpDelim);
|
||||
$this->_documentXML = preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u",
|
||||
$replace,
|
||||
$this->_documentXML,
|
||||
$limit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,14 +123,9 @@ class PHPWord_Template
|
|||
/**
|
||||
* Save Template
|
||||
*
|
||||
* @param string $strFilename
|
||||
* @return string
|
||||
*/
|
||||
public function save($strFilename)
|
||||
{
|
||||
if (file_exists($strFilename)) {
|
||||
unlink($strFilename);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
||||
|
||||
// Close zip file
|
||||
|
|
@ -132,6 +133,21 @@ class PHPWord_Template
|
|||
throw new Exception('Could not close zip file.');
|
||||
}
|
||||
|
||||
rename($this->_tempFileName, $strFilename);
|
||||
return $this->_tempFileName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Template As...
|
||||
*
|
||||
* @param string $strFilename
|
||||
*/
|
||||
public function saveAs($strFilename) {
|
||||
$tempFilename = $this->save();
|
||||
|
||||
if (file_exists($strFilename)) {
|
||||
unlink($strFilename);
|
||||
}
|
||||
|
||||
rename($tempFilename, $strFilename);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -106,8 +106,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$this->_writeText($objWriter, $element, true);
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element, true);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
$objWriter->writeElement('w:br');
|
||||
} elseif ($element instanceof PHPWord_Section_Image) {
|
||||
$this->_writeImage($objWriter, $element, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,6 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$spaceAfter = $style->getSpaceAfter();
|
||||
$spacing = $style->getSpacing();
|
||||
$indent = $style->getIndent();
|
||||
$hanging = $style->getHanging();
|
||||
$tabs = $style->getTabs();
|
||||
|
||||
if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) {
|
||||
|
|
@ -136,15 +135,10 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($indent) || !is_null($hanging)) {
|
||||
if (!is_null($indent)) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:firstLine', 0);
|
||||
if (!is_null($indent)) {
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
}
|
||||
if (!is_null($hanging)) {
|
||||
$objWriter->writeAttribute('w:hanging', $hanging);
|
||||
}
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -328,13 +322,11 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$fgColor = $style->getFgColor();
|
||||
$striketrough = $style->getStrikethrough();
|
||||
$underline = $style->getUnderline();
|
||||
$superscript = $style->getSuperScript();
|
||||
$subscript = $style->getSubScript();
|
||||
|
||||
$objWriter->startElement('w:rPr');
|
||||
|
||||
// Font
|
||||
if ($font != PHPWord::DEFAULT_FONT_NAME) {
|
||||
if ($font != 'Arial') {
|
||||
$objWriter->startElement('w:rFonts');
|
||||
$objWriter->writeAttribute('w:ascii', $font);
|
||||
$objWriter->writeAttribute('w:hAnsi', $font);
|
||||
|
|
@ -350,7 +342,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
}
|
||||
|
||||
// Size
|
||||
if ($size != PHPWord::DEFAULT_FONT_SIZE) {
|
||||
if ($size != 20) {
|
||||
$objWriter->startElement('w:sz');
|
||||
$objWriter->writeAttribute('w:val', $size);
|
||||
$objWriter->endElement();
|
||||
|
|
@ -389,13 +381,6 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Superscript/subscript
|
||||
if ($superscript || $subscript) {
|
||||
$objWriter->startElement('w:vertAlign');
|
||||
$objWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +397,6 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
if ($_cRows > 0) {
|
||||
$objWriter->startElement('w:tbl');
|
||||
$tblStyle = $table->getStyle();
|
||||
$tblWidth = $table->getWidth();
|
||||
if ($tblStyle instanceof PHPWord_Style_Table) {
|
||||
$this->_writeTableStyle($objWriter, $tblStyle);
|
||||
} else {
|
||||
|
|
@ -421,46 +405,26 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->startElement('w:tblStyle');
|
||||
$objWriter->writeAttribute('w:val', $tblStyle);
|
||||
$objWriter->endElement();
|
||||
if (!is_null($tblWidth)) {
|
||||
$objWriter->startElement('w:tblW');
|
||||
$objWriter->writeAttribute('w:w', $tblWidth);
|
||||
$objWriter->writeAttribute('w:type', 'pct');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$_heights = $table->getRowHeights();
|
||||
for ($i = 0; $i < $_cRows; $i++) {
|
||||
$row = $_rows[$i];
|
||||
$height = $row->getHeight();
|
||||
$rowStyle = $row->getStyle();
|
||||
$tblHeader = $rowStyle->getTblHeader();
|
||||
$cantSplit = $rowStyle->getCantSplit();
|
||||
$height = $_heights[$i];
|
||||
|
||||
$objWriter->startElement('w:tr');
|
||||
|
||||
if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) {
|
||||
if (!is_null($height)) {
|
||||
$objWriter->startElement('w:trPr');
|
||||
if (!is_null($height)) {
|
||||
$objWriter->startElement('w:trHeight');
|
||||
$objWriter->writeAttribute('w:val', $height);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if (!is_null($tblHeader)) {
|
||||
$objWriter->startElement('w:tblHeader');
|
||||
$objWriter->writeAttribute('w:val', $tblHeader);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
if (!is_null($cantSplit)) {
|
||||
$objWriter->startElement('w:cantSplit');
|
||||
$objWriter->writeAttribute('w:val', $cantSplit);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
$objWriter->startElement('w:trHeight');
|
||||
$objWriter->writeAttribute('w:val', $height);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
foreach ($row->getCells() as $cell) {
|
||||
foreach ($row as $cell) {
|
||||
$objWriter->startElement('w:tc');
|
||||
|
||||
$cellStyle = $cell->getStyle();
|
||||
|
|
@ -469,7 +433,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->startElement('w:tcPr');
|
||||
$objWriter->startElement('w:tcW');
|
||||
$objWriter->writeAttribute('w:w', $width);
|
||||
$objWriter->writeAttribute('w:type', 'pct');
|
||||
$objWriter->writeAttribute('w:type', 'dxa');
|
||||
$objWriter->endElement();
|
||||
|
||||
if ($cellStyle instanceof PHPWord_Style_Cell) {
|
||||
|
|
@ -665,7 +629,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
* @param \PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param \PHPWord_Section_Image $image
|
||||
*/
|
||||
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image)
|
||||
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Image $image, $withoutP = false)
|
||||
{
|
||||
$rId = $image->getRelationId();
|
||||
|
||||
|
|
@ -677,14 +641,16 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$marginLeft = $style->getMarginLeft();
|
||||
$wrappingStyle = $style->getWrappingStyle();
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
if (!$withoutP) {
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
if (!is_null($align)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:jc');
|
||||
$objWriter->writeAttribute('w:val', $align);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:r');
|
||||
|
|
@ -735,7 +701,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
if (!$withoutP) {
|
||||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
}
|
||||
|
||||
protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
@ -123,19 +123,22 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
$_settings = $section->getSettings();
|
||||
$settings = $section->getSettings();
|
||||
$_headers = $section->getHeaders();
|
||||
$_footer = $section->getFooter();
|
||||
$pgSzW = $_settings->getPageSizeW();
|
||||
$pgSzH = $_settings->getPageSizeH();
|
||||
$orientation = $_settings->getOrientation();
|
||||
$pgSzW = $settings->getPageSizeW();
|
||||
$pgSzH = $settings->getPageSizeH();
|
||||
$orientation = $settings->getOrientation();
|
||||
|
||||
$marginTop = $_settings->getMarginTop();
|
||||
$marginLeft = $_settings->getMarginLeft();
|
||||
$marginRight = $_settings->getMarginRight();
|
||||
$marginBottom = $_settings->getMarginBottom();
|
||||
$marginTop = $settings->getMarginTop();
|
||||
$marginLeft = $settings->getMarginLeft();
|
||||
$marginRight = $settings->getMarginRight();
|
||||
$marginBottom = $settings->getMarginBottom();
|
||||
|
||||
$borders = $_settings->getBorderSize();
|
||||
$headerHeight = $settings->getHeaderHeight();
|
||||
$footerHeight = $settings->getFooterHeight();
|
||||
|
||||
$borders = $settings->getBorderSize();
|
||||
|
||||
$colsNum = $_settings->getColsNum();
|
||||
$colsSpace = $_settings->getColsSpace();
|
||||
|
|
@ -186,14 +189,14 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->writeAttribute('w:right', $marginRight);
|
||||
$objWriter->writeAttribute('w:bottom', $marginBottom);
|
||||
$objWriter->writeAttribute('w:left', $marginLeft);
|
||||
$objWriter->writeAttribute('w:header', '720');
|
||||
$objWriter->writeAttribute('w:footer', '720');
|
||||
$objWriter->writeAttribute('w:header', $headerHeight);
|
||||
$objWriter->writeAttribute('w:footer', $footerHeight);
|
||||
$objWriter->writeAttribute('w:gutter', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
|
||||
$borderColor = $_settings->getBorderColor();
|
||||
$borderColor = $settings->getBorderColor();
|
||||
|
||||
$objWriter->startElement('w:pgBorders');
|
||||
$objWriter->writeAttribute('w:offsetFrom', 'page');
|
||||
|
|
@ -236,6 +239,12 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Page numbering
|
||||
if (null !== $settings->getPageNumberingStart()) {
|
||||
$objWriter->startElement('w:pgNumType');
|
||||
$objWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->startElement('w:cols');
|
||||
if($colsNum > 1){
|
||||
|
|
@ -261,7 +270,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
|
||||
public function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
|
||||
{
|
||||
$textObject = $listItem->getTextObject();
|
||||
$text = $textObject->getText();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2013 PHPWord
|
||||
* Copyright (c) 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2013 PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.7.0
|
||||
*/
|
||||
|
|
|
|||
87
README.md
87
README.md
|
|
@ -1,21 +1,21 @@
|
|||
# PHPWord - OpenXML - Read, Write and Create Word documents in PHP
|
||||
# PHPWord
|
||||
|
||||
[](https://travis-ci.org/PHPOffice/PHPWord)
|
||||
[](https://packagist.org/packages/phpoffice/phpword) [](https://packagist.org/packages/phpoffice/phpword) [](https://packagist.org/packages/phpoffice/phpword) [](https://packagist.org/packages/phpoffice/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.
|
||||
|
||||
Test patch branch
|
||||
|
||||
## Want to contribute?
|
||||
Fork us!
|
||||
__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
|
||||
|
|
@ -29,7 +29,19 @@ the following lines to your ``composer.json``.
|
|||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Documentation
|
||||
|
||||
### Table of contents
|
||||
|
||||
1. [Basic usage](#basic-usage)
|
||||
2. [Sections](#sections)
|
||||
* [Change Section Page Numbering](#sections-page-numbering)
|
||||
3. [Tables](#tables)
|
||||
* [Cell Style](#tables-cell-style)
|
||||
4. [Images](#images)
|
||||
|
||||
<a name="basic-usage"></a>
|
||||
#### Basic usage
|
||||
|
||||
The following is a basic example of the PHPWord library.
|
||||
|
||||
|
|
@ -61,7 +73,44 @@ $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
|||
$objWriter->save('helloWorld.docx');
|
||||
```
|
||||
|
||||
## Images
|
||||
<a name="sections"></a>
|
||||
#### Sections
|
||||
|
||||
<a name="sections-page-numbering"></a>
|
||||
##### Change Section Page Numbering
|
||||
|
||||
You can change a section page numbering.
|
||||
|
||||
```php
|
||||
$section = $PHPWord->createSection();
|
||||
$section->getSettings()->setPageNumberingStart(1);
|
||||
```
|
||||
|
||||
<a name="tables"></a>
|
||||
#### Tables
|
||||
|
||||
The following illustrates how to create a table.
|
||||
|
||||
```php
|
||||
$table = $section->addTable();
|
||||
$table->addRow();
|
||||
$table->addCell();
|
||||
```
|
||||
|
||||
<a name="tables-cell-style"></a>
|
||||
##### Cell Style
|
||||
|
||||
###### Cell Span
|
||||
|
||||
You can span a cell on multiple columms.
|
||||
|
||||
```php
|
||||
$cell = $table->addCell(200);
|
||||
$cell->getStyle()->setGridSpan(5);
|
||||
```
|
||||
|
||||
<a name="images"></a>
|
||||
#### Images
|
||||
|
||||
You can add images easily using the following example.
|
||||
|
||||
|
|
@ -71,16 +120,16 @@ $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__
|
||||
* ``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.
|
||||
To add an image with settings, consider the following example.
|
||||
|
||||
```php
|
||||
```php
|
||||
$section->addImage(
|
||||
'mars.jpg',
|
||||
array(
|
||||
|
|
@ -88,7 +137,7 @@ $section->addImage(
|
|||
'height' => 100,
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => -1,
|
||||
wrappingStyle => 'behind'
|
||||
'wrappingStyle' => 'behind'
|
||||
)
|
||||
);
|
||||
```
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord_Autoloader;
|
||||
use PHPWord_Autoloader as Autoloader;
|
||||
|
||||
class AutoloaderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testRegister()
|
||||
{
|
||||
PHPWord_Autoloader::register();
|
||||
$this->assertContains(array('PHPWord_Autoloader', 'load'), spl_autoload_functions());
|
||||
$this->assertContains(array('PHPWord_Autoloader', 'autoload'), spl_autoload_functions());
|
||||
}
|
||||
|
||||
public function testAutoloadLegacy()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
||||
public function testAutoload()
|
||||
{
|
||||
$declared = get_declared_classes();
|
||||
$declaredCount = count($declared);
|
||||
Autoloader::autoload('Foo');
|
||||
$this->assertEquals($declaredCount, count(get_declared_classes()), 'PHPWord\\Autoloader::autoload() is trying to load classes outside of the PHPWord namespace');
|
||||
Autoloader::autoload('PHPWord\\Exceptions\\InvalidStyleException'); // TODO change this class to the main PHPWord class when it is namespaced
|
||||
$this->assertTrue(in_array('PHPWord\\Exceptions\\InvalidStyleException', get_declared_classes()), 'PHPWord\\Autoloader::autoload() failed to autoload the PHPWord\\Exceptions\\InvalidStyleException class');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord;
|
||||
use PHPWord_IOFactory;
|
||||
use PHPWord_Writer_Word2007;
|
||||
|
||||
/**
|
||||
* Class PHPWord_IOFactoryTest
|
||||
* @package PHPWord\Tests
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class PHPWord_IOFactoryTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testGetSearchLocations()
|
||||
{
|
||||
$this->assertAttributeEquals(PHPWord_IOFactory::getSearchLocations(), '_searchLocations','PHPWord_IOFactory');
|
||||
}
|
||||
|
||||
public function testSetSearchLocationsWithArray()
|
||||
{
|
||||
PHPWord_IOFactory::setSearchLocations(array());
|
||||
$this->assertAttributeEquals(array(), '_searchLocations','PHPWord_IOFactory');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid parameter passed.
|
||||
*/
|
||||
public function testSetSearchLocationsWithNotArray()
|
||||
{
|
||||
PHPWord_IOFactory::setSearchLocations('String');
|
||||
}
|
||||
|
||||
public function testAddSearchLocation()
|
||||
{
|
||||
PHPWord_IOFactory::setSearchLocations(array());
|
||||
PHPWord_IOFactory::addSearchLocation('type', 'location', 'classname');
|
||||
$this->assertAttributeEquals(array(array('type' => 'type', 'path' => 'location', 'class' => 'classname')), '_searchLocations','PHPWord_IOFactory');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage No IWriter found for type
|
||||
*/
|
||||
public function testCreateWriterException(){
|
||||
$oPHPWord = new PHPWord();
|
||||
|
||||
PHPWord_IOFactory::setSearchLocations(array());
|
||||
PHPWord_IOFactory::createWriter($oPHPWord);
|
||||
}
|
||||
|
||||
public function testCreateWriter(){
|
||||
$oPHPWord = new PHPWord();
|
||||
|
||||
$this->assertEquals(PHPWord_IOFactory::createWriter($oPHPWord, 'Word2007'), new PHPWord_Writer_Word2007($oPHPWord));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord_Media;
|
||||
|
||||
class PHPWord_MediaTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testGetSectionMediaElementsWithNull()
|
||||
{
|
||||
$this->assertEquals(PHPWord_Media::getSectionMediaElements(), array());
|
||||
}
|
||||
|
||||
public function testCountSectionMediaElementsWithNull()
|
||||
{
|
||||
$this->assertEquals(PHPWord_Media::countSectionMediaElements(), 0);
|
||||
}
|
||||
|
||||
public function testGetHeaderMediaElements()
|
||||
{
|
||||
$this->assertAttributeEquals(PHPWord_Media::getHeaderMediaElements(), '_headerMedia','PHPWord_Media');
|
||||
}
|
||||
|
||||
public function testGetFooterMediaElements()
|
||||
{
|
||||
$this->assertAttributeEquals(PHPWord_Media::getFooterMediaElements(), '_footerMedia','PHPWord_Media');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord_Section;
|
||||
|
||||
class PHPWord_SectionTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testGetSettings()
|
||||
{
|
||||
$oSection = new PHPWord_Section(0);
|
||||
$this->assertAttributeEquals($oSection->getSettings(), '_settings', new PHPWord_Section(0));
|
||||
}
|
||||
|
||||
public function testGetElementss()
|
||||
{
|
||||
$oSection = new PHPWord_Section(0);
|
||||
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection',new PHPWord_Section(0));
|
||||
}
|
||||
|
||||
public function testGetFooter()
|
||||
{
|
||||
$oSection = new PHPWord_Section(0);
|
||||
$this->assertAttributeEquals($oSection->getFooter(), '_footer',new PHPWord_Section(0));
|
||||
}
|
||||
|
||||
public function testGetHeaders()
|
||||
{
|
||||
$oSection = new PHPWord_Section(0);
|
||||
$this->assertAttributeEquals($oSection->getHeaders(), '_headers',new PHPWord_Section(0));
|
||||
}
|
||||
|
||||
public function testGetElements()
|
||||
{
|
||||
$oSection = new PHPWord_Section(0);
|
||||
$this->assertAttributeEquals($oSection->getElements(), '_elementCollection',new PHPWord_Section(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord;
|
||||
use PHPWord_Writer_Word2007;
|
||||
use PHPWord_Writer_Word2007_Base;
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_BaseTest
|
||||
* @package PHPWord\Tests
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Executed before each method of the class
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
public function testWriteImage_Position()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
$section->addImage(
|
||||
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
|
||||
array(
|
||||
'marginTop' => -1,
|
||||
'marginLeft' => -1,
|
||||
'wrappingStyle' => 'behind'
|
||||
)
|
||||
);
|
||||
|
||||
$doc = TestHelperDOCX::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);
|
||||
}
|
||||
|
||||
public function testWriteParagraphStyle_Align()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
$section->addText('This is my text', null, array('align' => 'right'));
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
|
||||
|
||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
}
|
||||
|
||||
public function testWriteCellStyle_CellGridSpan()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
$table = $section->addTable();
|
||||
|
||||
$table->addRow();
|
||||
$cell = $table->addCell(200);
|
||||
$cell->getStyle()->setGridSpan(5);
|
||||
|
||||
$table->addRow();
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
$table->addCell(40);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
|
||||
|
||||
$this->assertEquals(5, $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPWord;
|
||||
use PHPWord_Writer_Word2007;
|
||||
use PHPWord_Writer_Word2007_Document;
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_DocumentTest
|
||||
* @package PHPWord\Tests
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Executed before each method of the class
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
public function testWriteEndSection_PageNumbering()
|
||||
{
|
||||
$PHPWord = new PHPWord();
|
||||
$section = $PHPWord->createSection();
|
||||
$section->getSettings()->setPageNumberingStart(2);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
||||
|
||||
$this->assertEquals(2, $element->getAttribute('w:start'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
|
@ -4,31 +4,42 @@ namespace PHPWord\Tests;
|
|||
use PHPWord;
|
||||
use DOMDocument;
|
||||
|
||||
class TestHelper
|
||||
class TestHelperDOCX
|
||||
{
|
||||
static protected $file;
|
||||
|
||||
/**
|
||||
* @param \PHPWord $PHPWord
|
||||
* @return \PHPWord\Tests\Doc
|
||||
* @return \PHPWord\Tests\Xml_Document
|
||||
*/
|
||||
public static function getDocument(PHPWord $PHPWord)
|
||||
{
|
||||
self::$file = tempnam(sys_get_temp_dir(), 'PHPWord');
|
||||
if(!is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
||||
mkdir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
}
|
||||
|
||||
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save(__DIR__ . '/Tests/_files/test.docx');
|
||||
$objWriter->save(self::$file);
|
||||
|
||||
$zip = new \ZipArchive;
|
||||
$res = $zip->open(__DIR__ . '/Tests/_files/test.docx');
|
||||
$res = $zip->open(self::$file);
|
||||
if ($res === true) {
|
||||
$zip->extractTo(__DIR__ . '/Tests/_files/test/');
|
||||
$zip->extractTo(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return new Doc(__DIR__ . '/Tests/_files/test/');
|
||||
return new Xml_Document(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
}
|
||||
|
||||
public static function clear()
|
||||
{
|
||||
unlink(__DIR__ . '/Tests/_files/test.docx');
|
||||
self::deleteDir(__DIR__ . '/Tests/_files/test/');
|
||||
if(file_exists(self::$file)){
|
||||
unlink(self::$file);
|
||||
}
|
||||
if(is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
||||
self::deleteDir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +61,7 @@ class TestHelper
|
|||
}
|
||||
}
|
||||
|
||||
class Doc
|
||||
class Xml_Document
|
||||
{
|
||||
/** @var string $path */
|
||||
private $path;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Constantes
|
||||
if(!defined('PHPWORD_TESTS_DIR_ROOT')){
|
||||
define('PHPWORD_TESTS_DIR_ROOT', __DIR__);
|
||||
}
|
||||
|
||||
// Includes
|
||||
require_once __DIR__ . '/../Classes/PHPWord/Autoloader.php';
|
||||
PHPWord_Autoloader::Register();
|
||||
|
||||
require_once __DIR__ . '/_inc/TestHelperDOCX.php';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
**************************************************************************************
|
||||
* PHPWord
|
||||
*
|
||||
* Copyright (c) 2011 - 2013 PHPWord
|
||||
* Copyright (c) 2011 - 2014 PHPWord
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -17,12 +17,23 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @copyright Copyright (c) 2011 - 2013 PHPWord (https://github.com/PHPOffice/PHPWord/)
|
||||
* @copyright Copyright (c) 2011 - 2014 PHPWord (https://github.com/PHPOffice/PHPWord/)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
**************************************************************************************
|
||||
|
||||
Fixed in branch for release 0.7.0 :
|
||||
Changes in branch for release 0.7.1 :
|
||||
- Bugfix: (gabrielbull) - Fixed bug with cell styling
|
||||
- Bugfix: (gabrielbull) - Fixed bug list items inside of cells
|
||||
- Feature: (RomanSyroeshko) GH-56 GH-57 - Template : Permit to save a template generated as a file (PHPWord_Template::saveAs())
|
||||
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
|
||||
- Feature: (gabrielbull) - Word2007 : Added support for line height
|
||||
- Feature: (JillElaine) GH-5 - Word2007 : Added support for page header & page footer height
|
||||
- Feature: (bskrtich) GH-6 GH-66 GH-84 - General : Add ability to manage line breaks after image insertion
|
||||
- Feature: (RomanSyroeshko) GH-52 GH-53 GH-85 - Template : Ability to limit number of replacements performed by setValue() method of Template class
|
||||
- QA: (Progi1984) - UnitTests
|
||||
|
||||
Changes 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
|
||||
|
|
@ -31,7 +42,7 @@ Fixed in branch for release 0.7.0 :
|
|||
- Feature: (kaystrobach) - Word2007 : Add rowspan and colspan to cells
|
||||
- Feature: (RLovelett) - Word2007 : Support for tab stops
|
||||
- Feature: (RLovelett) - Word2007 : Support Multiple headers
|
||||
- Feature: (gavroche) - Word2007 : Wrapping Styles to Images
|
||||
- Feature: (gabrielbull) - Word2007 : Wrapping Styles to Images
|
||||
- General: (MarkBaker) - Add superscript/subscript styling in Excel2007 Writer
|
||||
- General: (deds) - add indentation support to paragraphs
|
||||
- General: (Progi1984) GH-27 - Support for Composer
|
||||
|
|
@ -39,4 +50,4 @@ Fixed in branch for release 0.7.0 :
|
|||
- 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
|
||||
- Feature: (gabrielbull) - Added support for image wrapping style
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@
|
|||
},
|
||||
{
|
||||
"name": "Gabriel Bull",
|
||||
"email": "gavroche.bull@gmail.com"
|
||||
"email": "me@gabrielbull.com",
|
||||
"homepage": "http://gabrielbull.com/"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
|
|
@ -22,6 +23,9 @@
|
|||
"php": ">=5.3.0",
|
||||
"ext-xml": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.28"
|
||||
},
|
||||
"recommend": {
|
||||
"ext-zip": "*",
|
||||
"ext-gd2": "*"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="test/bootstrap.php"
|
||||
bootstrap="./Tests/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
|
|
@ -9,8 +9,13 @@
|
|||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
<testsuites>
|
||||
<testsuite name="PHPWord Test Suite">
|
||||
<directory>./test/PHPWord/</directory>
|
||||
<testsuite name="PHPWord Unit Test Suite">
|
||||
<directory>./Tests/PHPWord/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../Classes</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
||||
define('EOL', PHP_EOL);
|
||||
} else {
|
||||
define('EOL', '<br />');
|
||||
}
|
||||
|
||||
require_once '../Classes/PHPWord.php';
|
||||
|
||||
// New Word Document
|
||||
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
|
||||
$PHPWord = new PHPWord();
|
||||
|
||||
// New portrait section
|
||||
$section = $PHPWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12));
|
||||
$section->addText('I am placed on a default section.');
|
||||
|
||||
// New landscape section
|
||||
$section = $PHPWord->createSection(array('orientation' => 'landscape'));
|
||||
$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
|
||||
$section->addPageBreak();
|
||||
$section->addPageBreak();
|
||||
|
||||
// New portrait section
|
||||
$section = $PHPWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
|
||||
$section->addText('This section uses other margins.');
|
||||
|
||||
// New portrait section with Header & Footer
|
||||
$section = $PHPWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,));
|
||||
$section->addText('This section and we play with header/footer height.');
|
||||
$section->createHeader()->addText('Header');
|
||||
$section->createFooter()->addText('Footer');
|
||||
|
||||
// Save File
|
||||
echo date('H:i:s') , ' Write to Word2007 format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save(str_replace('.php', '.docx', __FILE__));
|
||||
|
||||
/*echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText');
|
||||
$objWriter->save(str_replace('.php', '.odt', __FILE__));
|
||||
|
||||
echo date('H:i:s') , ' Write to RTF format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF');
|
||||
$objWriter->save(str_replace('.php', '.rtf', __FILE__));*/
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , ' Done writing file' , EOL;
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
||||
define('EOL', PHP_EOL);
|
||||
}
|
||||
else {
|
||||
define('EOL', '<br />');
|
||||
}
|
||||
|
||||
require_once '../Classes/PHPWord.php';
|
||||
|
||||
// New Word Document
|
||||
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
|
||||
$PHPWord = new PHPWord();
|
||||
|
||||
|
||||
// Ads styles
|
||||
$PHPWord->addParagraphStyle('pStyle', array('spacing'=>100));
|
||||
$PHPWord->addFontStyle('BoldText', array('bold'=>true));
|
||||
$PHPWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
|
||||
$PHPWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE));
|
||||
|
||||
// New portrait section
|
||||
$section = $PHPWord->createSection();
|
||||
|
||||
// Add text run
|
||||
$textrun = $section->createTextRun('pStyle');
|
||||
|
||||
$textrun->addText('Each textrun can contain native text, link elements or an image.');
|
||||
$textrun->addText(' No break is placed after adding an element.', 'BoldText');
|
||||
$textrun->addText(' All elements are placed inside a paragraph with the optionally given p-Style.', 'ColoredText');
|
||||
$textrun->addText(' Sample Link: ');
|
||||
$textrun->addLink('http://www.google.com', null, 'NLink');
|
||||
$textrun->addText(' Sample Image: ');
|
||||
$textrun->addImage('old/_earth.jpg', array('width'=>18, 'height'=>18));
|
||||
$textrun->addText(' Here is some more text. ');
|
||||
|
||||
// Save File
|
||||
echo date('H:i:s') , ' Write to Word2007 format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||
$objWriter->save(str_replace('.php', '.docx', __FILE__));
|
||||
|
||||
/* Text Run is not currently supported for ODText
|
||||
echo date('H:i:s') , ' Write to OpenDocumentText format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText');
|
||||
$objWriter->save(str_replace('.php', '.odt', __FILE__));
|
||||
*/
|
||||
|
||||
/* Text Run is not currently supported for RTF
|
||||
echo date('H:i:s') , ' Write to RTF format' , EOL;
|
||||
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF');
|
||||
$objWriter->save(str_replace('.php', '.rtf', __FILE__));
|
||||
*/
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , ' MB' , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , ' Done writing file' , EOL;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?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');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?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