Merge branch 'develop' into fancy-samples
This commit is contained in:
commit
cec16ce1f3
|
|
@ -188,8 +188,8 @@ class PHPWord
|
|||
/**
|
||||
* Adds a paragraph style definition to styles.xml
|
||||
*
|
||||
* @param $styleName string
|
||||
* @param $styles array
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public function addParagraphStyle($styleName, $styles)
|
||||
{
|
||||
|
|
@ -199,8 +199,9 @@ class PHPWord
|
|||
/**
|
||||
* Adds a font style definition to styles.xml
|
||||
*
|
||||
* @param $styleName string
|
||||
* @param $styles array
|
||||
* @param string $styleName
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
|
|
@ -210,8 +211,9 @@ class PHPWord
|
|||
/**
|
||||
* Adds a table style definition to styles.xml
|
||||
*
|
||||
* @param $styleName string
|
||||
* @param $styles array
|
||||
* @param string $styleName
|
||||
* @param array $styleTable
|
||||
* @param array $styleFirstRow
|
||||
*/
|
||||
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
|
||||
{
|
||||
|
|
@ -221,8 +223,9 @@ class PHPWord
|
|||
/**
|
||||
* Adds a heading style definition to styles.xml
|
||||
*
|
||||
* @param $titleCount int
|
||||
* @param $styles array
|
||||
* @param int $titleCount
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
*/
|
||||
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
|
|
@ -232,8 +235,8 @@ class PHPWord
|
|||
/**
|
||||
* Adds a hyperlink style to styles.xml
|
||||
*
|
||||
* @param $styleName string
|
||||
* @param $styles array
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
*/
|
||||
public function addLinkStyle($styleName, $styles)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class PHPWord_Autoloader
|
|||
/**
|
||||
* Autoloader
|
||||
*
|
||||
* @param string
|
||||
* @param string $class
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.8.0
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Exceptions;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.8.0
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Exceptions;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.8.0
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Exceptions;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* 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
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPWord
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.8.0
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Exceptions;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ class PHPWord_Footnote
|
|||
/**
|
||||
* Add new Footnote Link Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
* @param string $linkSrc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -94,25 +94,13 @@ class PHPWord_Media
|
|||
if (!$isMemImage) {
|
||||
$isMemImage = (filter_var($src, FILTER_VALIDATE_URL) !== false);
|
||||
}
|
||||
$extension = '';
|
||||
if ($isMemImage) {
|
||||
$extension = $memoryImage->getImageExtension();
|
||||
$media['isMemImage'] = true;
|
||||
$media['createfunction'] = $memoryImage->getImageCreateFunction();
|
||||
$media['imagefunction'] = $memoryImage->getImageFunction();
|
||||
} else {
|
||||
$imageType = exif_imagetype($src);
|
||||
if ($imageType === IMAGETYPE_JPEG) {
|
||||
$extension = 'jpg';
|
||||
} elseif ($imageType === IMAGETYPE_GIF) {
|
||||
$extension = 'gif';
|
||||
} elseif ($imageType === IMAGETYPE_PNG) {
|
||||
$extension = 'png';
|
||||
} elseif ($imageType === IMAGETYPE_BMP) {
|
||||
$extension = 'bmp';
|
||||
} elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) {
|
||||
$extension = 'tif';
|
||||
}
|
||||
$extension = PHPWord_Shared_File::imagetype($src);
|
||||
}
|
||||
|
||||
$folder = 'media';
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
|||
protected $readDataOnly = true;
|
||||
|
||||
/**
|
||||
* File pointer
|
||||
*
|
||||
* @var bool|resource
|
||||
*/
|
||||
protected $fileHandle = true;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ class PHPWord_Section_Footer
|
|||
|
||||
/**
|
||||
* Create a new Footer
|
||||
*
|
||||
* @param int $sectionCount
|
||||
*/
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
|
|
@ -95,6 +97,7 @@ class PHPWord_Section_Footer
|
|||
/**
|
||||
* Create a new TextRun
|
||||
*
|
||||
* @param null|string|array|PHPWord_Style_Paragraph $styleParagraph
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null)
|
||||
|
|
|
|||
|
|
@ -56,8 +56,10 @@ class PHPWord_Section_Footer_PreserveText
|
|||
/**
|
||||
* Create a new Preserve Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $style
|
||||
* @param string $text
|
||||
* @param mixed $styleFont
|
||||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Footer_PreserveText
|
||||
*/
|
||||
public function __construct($text = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ class PHPWord_Section_Footnote
|
|||
|
||||
/**
|
||||
* Create a new Footnote Element
|
||||
*
|
||||
* @param mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($styleParagraph = null)
|
||||
{
|
||||
|
|
@ -78,8 +80,8 @@ class PHPWord_Section_Footnote
|
|||
/**
|
||||
* Add a Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $styleFont
|
||||
* @param null|string $text
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text = null, $styleFont = null)
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ class PHPWord_Section_Header
|
|||
|
||||
/**
|
||||
* Create a new Header
|
||||
*
|
||||
* @param int $sectionCount
|
||||
*/
|
||||
public function __construct($sectionCount)
|
||||
{
|
||||
|
|
@ -124,6 +126,7 @@ class PHPWord_Section_Header
|
|||
/**
|
||||
* Create a new TextRun
|
||||
*
|
||||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class PHPWord_Section_Image
|
|||
*/
|
||||
private $_isWatermark;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Image
|
||||
*
|
||||
|
|
@ -72,13 +71,11 @@ class PHPWord_Section_Image
|
|||
*/
|
||||
public function __construct($src, $style = null, $isWatermark = false)
|
||||
{
|
||||
$supportedImageTypes = array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM);
|
||||
|
||||
if (!file_exists($src)) {
|
||||
throw new InvalidImageException;
|
||||
}
|
||||
|
||||
if (!in_array(exif_imagetype($src), $supportedImageTypes)) {
|
||||
if (!PHPWord_Shared_File::imagetype($src)) {
|
||||
throw new UnsupportedImageTypeException;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ class PHPWord_Section_Link
|
|||
/**
|
||||
* Create a new Link Element
|
||||
*
|
||||
* @var string $linkSrc
|
||||
* @var string $linkName
|
||||
* @var mixed $styleFont
|
||||
* @var mixed $styleParagraph
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
* @param mixed $styleFont
|
||||
* @param mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@ class PHPWord_Section_ListItem
|
|||
*
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @param mixed $styleText
|
||||
* @param mixed $styleFont
|
||||
* @param mixed $styleList
|
||||
* @param mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,11 +158,15 @@ class PHPWord_Section_Settings
|
|||
private $pageNumberingStart;
|
||||
|
||||
/**
|
||||
* Header height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $headerHeight;
|
||||
|
||||
/**
|
||||
* Footer height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $footerHeight;
|
||||
|
|
@ -594,6 +598,8 @@ class PHPWord_Section_Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* Set page numbering start
|
||||
*
|
||||
* @param null|int $pageNumberingStart
|
||||
* @return $this
|
||||
*/
|
||||
|
|
@ -604,6 +610,8 @@ class PHPWord_Section_Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* Get page numbering start
|
||||
*
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPageNumberingStart()
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class PHPWord_Section_Table
|
|||
* Add a row
|
||||
*
|
||||
* @param int $height
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function addRow($height = null, $style = null)
|
||||
{
|
||||
|
|
@ -144,7 +145,7 @@ class PHPWord_Section_Table
|
|||
/**
|
||||
* Set table width
|
||||
*
|
||||
* @var int $width
|
||||
* @param int $width
|
||||
*/
|
||||
public function setWidth($width)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ class PHPWord_Section_Table_Cell
|
|||
* Add a Text Element
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $style
|
||||
* @param mixed $styleFont
|
||||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text, $styleFont = null, $styleParagraph = null)
|
||||
|
|
@ -299,6 +300,7 @@ class PHPWord_Section_Table_Cell
|
|||
/**
|
||||
* Create a new TextRun
|
||||
*
|
||||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_TextRun
|
||||
*/
|
||||
public function createTextRun($styleParagraph = null)
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ class PHPWord_Section_Text
|
|||
}
|
||||
|
||||
/**
|
||||
* Set text content
|
||||
*
|
||||
* @param string $text
|
||||
* @return $this
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class PHPWord_Section_TextBreak
|
|||
|
||||
/**
|
||||
* Create a new TextBreak Element
|
||||
*
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function __construct($fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
|
|
@ -60,8 +63,8 @@ class PHPWord_Section_TextBreak
|
|||
/**
|
||||
* Set Text style
|
||||
*
|
||||
* @param null|array|\PHPWord_Style_Font $style
|
||||
* @param null|array|\PHPWord_Style_Paragraph $paragraphStyle
|
||||
* @param mixed $style
|
||||
* @param mixed $paragraphStyle
|
||||
* @return PHPWord_Style_Font
|
||||
*/
|
||||
public function setFontStyle($style = null, $paragraphStyle = null)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ class PHPWord_Section_TextRun
|
|||
|
||||
/**
|
||||
* Create a new TextRun Element
|
||||
*
|
||||
* @param mixed $styleParagraph
|
||||
*/
|
||||
public function __construct($styleParagraph = null)
|
||||
{
|
||||
|
|
@ -72,8 +74,8 @@ class PHPWord_Section_TextRun
|
|||
/**
|
||||
* Add a Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $styleFont
|
||||
* @param string $text
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text = null, $styleFont = null)
|
||||
|
|
@ -113,7 +115,7 @@ class PHPWord_Section_TextRun
|
|||
* Add a Image Element
|
||||
*
|
||||
* @param string $imageSrc
|
||||
* @param mixed $styleFont
|
||||
* @param mixed $style
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($imageSrc, $style = null)
|
||||
|
|
@ -134,9 +136,9 @@ class PHPWord_Section_TextRun
|
|||
/**
|
||||
* Add TextBreak
|
||||
*
|
||||
* @param int $count
|
||||
* @param null|string|array|PHPWord_Style_Font $fontStyle
|
||||
* @param null|string|array|PHPWord_Style_Paragraph $paragraphStyle
|
||||
* @param int $count
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
*/
|
||||
public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null)
|
||||
{
|
||||
|
|
@ -148,7 +150,7 @@ class PHPWord_Section_TextRun
|
|||
/**
|
||||
* Create a new Footnote Element
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $styleParagraph
|
||||
* @return PHPWord_Section_Footnote
|
||||
*/
|
||||
public function createFootnote($styleParagraph = null)
|
||||
|
|
|
|||
|
|
@ -70,8 +70,9 @@ class PHPWord_Section_Title
|
|||
/**
|
||||
* Create a new Title Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var int $depth
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @param mixed $style
|
||||
*/
|
||||
public function __construct($text, $depth = 1, $style = null)
|
||||
{
|
||||
|
|
@ -88,7 +89,7 @@ class PHPWord_Section_Title
|
|||
/**
|
||||
* Set Anchor
|
||||
*
|
||||
* @var int $anchor
|
||||
* @param int $anchor
|
||||
*/
|
||||
public function setAnchor($anchor)
|
||||
{
|
||||
|
|
@ -108,7 +109,7 @@ class PHPWord_Section_Title
|
|||
/**
|
||||
* Set Bookmark ID
|
||||
*
|
||||
* @var int $bookmarkId
|
||||
* @param int $bookmarkId
|
||||
*/
|
||||
public function setBookmarkId($bookmarkId)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,15 +30,20 @@
|
|||
*/
|
||||
class PHPWord_Shared_File
|
||||
{
|
||||
const IMAGETYPE_JPEG = 'jpg';
|
||||
const IMAGETYPE_GIF = 'gif';
|
||||
const IMAGETYPE_PNG = 'png';
|
||||
const IMAGETYPE_BMP = 'bmp';
|
||||
const IMAGETYPE_TIFF = 'tif';
|
||||
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename)
|
||||
{
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
|
||||
|
|
@ -50,18 +55,13 @@ class PHPWord_Shared_File
|
|||
*/
|
||||
public static function realpath($pFilename)
|
||||
{
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
if (!$returnValue) {
|
||||
$pathArray = explode('/', $pFilename);
|
||||
while (in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
while (in_array('..', $pathArray) && $pathArray[0] !== '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
if ($pathArray[$i] === '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
|
|
@ -71,7 +71,58 @@ class PHPWord_Shared_File
|
|||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP Words version of exif_imagetype to return the Image Type from a file
|
||||
*
|
||||
* @param string $filename
|
||||
* @return int|bool
|
||||
*/
|
||||
private static function fallbackImagetype($filename)
|
||||
{
|
||||
if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) {
|
||||
if ($type === 2) {
|
||||
return self::IMAGETYPE_JPEG;
|
||||
} elseif ($type === 1) {
|
||||
return self::IMAGETYPE_GIF;
|
||||
} elseif ($type === 3) {
|
||||
return self::IMAGETYPE_PNG;
|
||||
} elseif ($type === 6) {
|
||||
return self::IMAGETYPE_BMP;
|
||||
} elseif ($type === 7 || $type === 8) {
|
||||
return self::IMAGETYPE_TIFF;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Image Type from a file
|
||||
*
|
||||
* @param string $filename
|
||||
* @param bool $userFallbackFunction
|
||||
* @return int|bool
|
||||
*/
|
||||
public static function imagetype($filename, $userFallbackFunction = false)
|
||||
{
|
||||
if ($userFallbackFunction || !function_exists('exif_imagetype')) {
|
||||
return self::fallbackImagetype($filename);
|
||||
}
|
||||
|
||||
$imagetype = exif_imagetype($filename);
|
||||
if ($imagetype === IMAGETYPE_JPEG) {
|
||||
return self::IMAGETYPE_JPEG;
|
||||
} elseif ($imagetype === IMAGETYPE_GIF) {
|
||||
return self::IMAGETYPE_GIF;
|
||||
} elseif ($imagetype === IMAGETYPE_PNG) {
|
||||
return self::IMAGETYPE_PNG;
|
||||
} elseif ($imagetype === IMAGETYPE_BMP) {
|
||||
return self::IMAGETYPE_BMP;
|
||||
} elseif ($imagetype === IMAGETYPE_TIFF_II || $imagetype === IMAGETYPE_TIFF_MM) {
|
||||
return self::IMAGETYPE_TIFF;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,8 +44,8 @@ class PHPWord_Shared_Font
|
|||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1)
|
||||
{
|
||||
|
|
@ -55,24 +55,42 @@ class PHPWord_Shared_Font
|
|||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert centimeter to twip
|
||||
*
|
||||
* @param int $sizeInCm
|
||||
* @return int
|
||||
*/
|
||||
public static function centimeterSizeToTwips($sizeInCm = 1)
|
||||
{
|
||||
return ($sizeInCm * 565.217);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert inch to twip
|
||||
*
|
||||
* @param int $sizeInInch
|
||||
* @return int
|
||||
*/
|
||||
public static function inchSizeToTwips($sizeInInch = 1)
|
||||
{
|
||||
return self::centimeterSizeToTwips($sizeInInch * 2.54);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixel to twip
|
||||
*
|
||||
* @param int $sizeInPixel
|
||||
* @return int
|
||||
*/
|
||||
public static function pixelSizeToTwips($sizeInPixel = 1)
|
||||
{
|
||||
return self::centimeterSizeToTwips($sizeInPixel / 37.795275591);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class PHPWord_Shared_XMLWriter
|
|||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return $data
|
||||
* @return string XML data
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
|
|
@ -124,8 +124,8 @@ class PHPWord_Shared_XMLWriter
|
|||
/**
|
||||
* Catch function calls (and pass them to internal XMLWriter)
|
||||
*
|
||||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,6 +71,11 @@ class PHPWord_Shared_ZipStreamWrapper
|
|||
|
||||
/**
|
||||
* Open stream
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $mode
|
||||
* @param string $options
|
||||
* @param string $opened_path
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
|
|
@ -119,6 +124,8 @@ class PHPWord_Shared_ZipStreamWrapper
|
|||
|
||||
/**
|
||||
* Read stream
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function stream_read($count)
|
||||
{
|
||||
|
|
@ -145,6 +152,9 @@ class PHPWord_Shared_ZipStreamWrapper
|
|||
|
||||
/**
|
||||
* Seek stream
|
||||
*
|
||||
* @param int $offset
|
||||
* @param mixed $whence
|
||||
*/
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ class PHPWord_Style
|
|||
* Add a table style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param array $styles
|
||||
* @param array $styleTable
|
||||
* @param null|array $styleFirstRow
|
||||
* @param null|array $styleLastRow
|
||||
*/
|
||||
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null, $styleLastRow = null)
|
||||
{
|
||||
|
|
@ -120,9 +122,9 @@ class PHPWord_Style
|
|||
/**
|
||||
* Add a title style
|
||||
*
|
||||
* @param string $styleName
|
||||
* @param int $titleCount
|
||||
* @param array $styleFont
|
||||
* @param array $styleParagraph
|
||||
* @param nullarray $styleParagraph
|
||||
*/
|
||||
public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
|
||||
{
|
||||
|
|
@ -143,7 +145,7 @@ class PHPWord_Style
|
|||
/**
|
||||
* Set default paragraph style
|
||||
*
|
||||
* @param array $styles Paragraph style definition
|
||||
* @param array $styles Paragraph style definition
|
||||
*/
|
||||
public static function setDefaultParagraphStyle($styles)
|
||||
{
|
||||
|
|
@ -153,7 +155,7 @@ class PHPWord_Style
|
|||
/**
|
||||
* Get all styles
|
||||
*
|
||||
* @return PHPWord_Style_Font[]
|
||||
* @return array
|
||||
*/
|
||||
public static function getStyles()
|
||||
{
|
||||
|
|
@ -163,8 +165,8 @@ class PHPWord_Style
|
|||
/**
|
||||
* Get style
|
||||
*
|
||||
* @param string
|
||||
* @return PHPWord_Style
|
||||
* @param string $styleName
|
||||
* @return null|PHPWord_Style
|
||||
*/
|
||||
public static function getStyle($styleName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,8 +157,8 @@ class PHPWord_Style_Cell
|
|||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @var string $key
|
||||
* @var mixed $value
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
|
|
@ -171,36 +171,65 @@ class PHPWord_Style_Cell
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical align
|
||||
*/
|
||||
public function getVAlign()
|
||||
{
|
||||
return $this->_valign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical align
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setVAlign($pValue = null)
|
||||
{
|
||||
$this->_valign = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text direction
|
||||
*/
|
||||
public function getTextDirection()
|
||||
{
|
||||
return $this->_textDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text direction
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTextDirection($pValue = null)
|
||||
{
|
||||
$this->_textDirection = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background color
|
||||
*/
|
||||
public function getBgColor()
|
||||
{
|
||||
return $this->_bgColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set background color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBgColor($pValue = null)
|
||||
{
|
||||
$this->_bgColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
|
|
@ -209,6 +238,9 @@ class PHPWord_Style_Cell
|
|||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border size
|
||||
*/
|
||||
public function getBorderSize()
|
||||
{
|
||||
$t = $this->getBorderTopSize();
|
||||
|
|
@ -219,6 +251,11 @@ class PHPWord_Style_Cell
|
|||
return array($t, $l, $r, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
|
|
@ -227,6 +264,9 @@ class PHPWord_Style_Cell
|
|||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border color
|
||||
*/
|
||||
public function getBorderColor()
|
||||
{
|
||||
$t = $this->getBorderTopColor();
|
||||
|
|
@ -237,107 +277,189 @@ class PHPWord_Style_Cell
|
|||
return array($t, $l, $r, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border top size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderTopSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border top size
|
||||
*/
|
||||
public function getBorderTopSize()
|
||||
{
|
||||
return $this->_borderTopSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border top color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderTopColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border top color
|
||||
*/
|
||||
public function getBorderTopColor()
|
||||
{
|
||||
return $this->_borderTopColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border left size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderLeftSize($pValue = null)
|
||||
{
|
||||
$this->_borderLeftSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border left size
|
||||
*/
|
||||
public function getBorderLeftSize()
|
||||
{
|
||||
return $this->_borderLeftSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border left color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderLeftColor($pValue = null)
|
||||
{
|
||||
$this->_borderLeftColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border left color
|
||||
*/
|
||||
public function getBorderLeftColor()
|
||||
{
|
||||
return $this->_borderLeftColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border right size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderRightSize($pValue = null)
|
||||
{
|
||||
$this->_borderRightSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border right size
|
||||
*/
|
||||
public function getBorderRightSize()
|
||||
{
|
||||
return $this->_borderRightSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border right color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderRightColor($pValue = null)
|
||||
{
|
||||
$this->_borderRightColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border right color
|
||||
*/
|
||||
public function getBorderRightColor()
|
||||
{
|
||||
return $this->_borderRightColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set border bottom size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderBottomSize($pValue = null)
|
||||
{
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border bottom size
|
||||
*/
|
||||
public function getBorderBottomSize()
|
||||
{
|
||||
return $this->_borderBottomSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border bottom color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderBottomColor($pValue = null)
|
||||
{
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border bottom color
|
||||
*/
|
||||
public function getBorderBottomColor()
|
||||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default border color
|
||||
*/
|
||||
public function getDefaultBorderColor()
|
||||
{
|
||||
return $this->_defaultBorderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid span (colspan)
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setGridSpan($pValue = null)
|
||||
{
|
||||
$this->_gridSpan = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get grid span (colspan)
|
||||
*/
|
||||
public function getGridSpan()
|
||||
{
|
||||
return $this->_gridSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical merge (rowspan)
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setVMerge($pValue = null)
|
||||
{
|
||||
$this->_vMerge = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical merge (rowspan)
|
||||
*/
|
||||
public function getVMerge()
|
||||
{
|
||||
return $this->_vMerge;
|
||||
|
|
|
|||
|
|
@ -185,6 +185,8 @@ class PHPWord_Style_Font
|
|||
}
|
||||
|
||||
/**
|
||||
* Set style using associative array
|
||||
*
|
||||
* @param array $style
|
||||
* @return $this
|
||||
*/
|
||||
|
|
@ -510,6 +512,8 @@ class PHPWord_Style_Font
|
|||
}
|
||||
|
||||
/**
|
||||
* Get line height
|
||||
*
|
||||
* @return int|float
|
||||
*/
|
||||
public function getLineHeight()
|
||||
|
|
|
|||
|
|
@ -36,9 +36,32 @@ class PHPWord_Style_Image
|
|||
const WRAPPING_STYLE_BEHIND = 'behind';
|
||||
const WRAPPING_STYLE_INFRONT = 'infront';
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_width;
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_height;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_align;
|
||||
|
||||
/**
|
||||
* Wrapping style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $wrappingStyle;
|
||||
|
||||
/**
|
||||
|
|
@ -55,6 +78,9 @@ class PHPWord_Style_Image
|
|||
*/
|
||||
private $_marginLeft;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_width = null;
|
||||
|
|
@ -65,36 +91,66 @@ class PHPWord_Style_Image
|
|||
$this->setWrappingStyle(self::WRAPPING_STYLE_INLINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setWidth($pValue = null)
|
||||
{
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeight($pValue = null)
|
||||
{
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*/
|
||||
public function getAlign()
|
||||
{
|
||||
return $this->_align;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setAlign($pValue = null)
|
||||
{
|
||||
$this->_align = $pValue;
|
||||
|
|
@ -145,6 +201,8 @@ class PHPWord_Style_Image
|
|||
}
|
||||
|
||||
/**
|
||||
* Set wrapping style
|
||||
*
|
||||
* @param string $wrappingStyle
|
||||
* @throws InvalidArgumentException
|
||||
* @return $this
|
||||
|
|
@ -167,6 +225,8 @@ class PHPWord_Style_Image
|
|||
}
|
||||
|
||||
/**
|
||||
* Get wrapping style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWrappingStyle()
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ class PHPWord_Style_Paragraph
|
|||
private $_pageBreakBefore = false;
|
||||
|
||||
/**
|
||||
* Set style using associative array
|
||||
*
|
||||
* @param array $style
|
||||
* @return $this
|
||||
*/
|
||||
|
|
@ -319,11 +321,11 @@ class PHPWord_Style_Paragraph
|
|||
return $this->_tabs;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Set tabs
|
||||
*
|
||||
* @param array $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
* @param array $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setTabs($pValue = null)
|
||||
{
|
||||
|
|
@ -500,6 +502,8 @@ class PHPWord_Style_Paragraph
|
|||
}
|
||||
|
||||
/**
|
||||
* Get line height
|
||||
*
|
||||
* @return int|float
|
||||
*/
|
||||
public function getLineHeight()
|
||||
|
|
|
|||
|
|
@ -54,12 +54,21 @@ class PHPWord_Style_Row
|
|||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tblHeader
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPWord_Style_Row
|
||||
*/
|
||||
public function setTblHeader($pValue = false)
|
||||
{
|
||||
if (!is_bool($pValue)) {
|
||||
|
|
@ -69,11 +78,22 @@ class PHPWord_Style_Row
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tblHeader
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getTblHeader()
|
||||
{
|
||||
return $this->_tblHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cantSplit
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPWord_Style_Row
|
||||
*/
|
||||
public function setCantSplit($pValue = false)
|
||||
{
|
||||
if (!is_bool($pValue)) {
|
||||
|
|
@ -83,6 +103,11 @@ class PHPWord_Style_Row
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cantSplit
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getCantSplit()
|
||||
{
|
||||
return $this->_cantSplit;
|
||||
|
|
|
|||
|
|
@ -30,12 +30,37 @@
|
|||
*/
|
||||
class PHPWord_Style_Table
|
||||
{
|
||||
|
||||
/**
|
||||
* Cell margin top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginTop;
|
||||
|
||||
/**
|
||||
* Cell margin left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginLeft;
|
||||
|
||||
/**
|
||||
* Cell margin right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginRight;
|
||||
|
||||
/**
|
||||
* Cell margin bottom
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cellMarginBottom;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_cellMarginTop = null;
|
||||
|
|
@ -44,51 +69,92 @@ class PHPWord_Style_Table
|
|||
$this->_cellMarginBottom = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style value
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setStyleValue($key, $value)
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin top
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin top
|
||||
*/
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin left
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin left
|
||||
*/
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin right
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin right
|
||||
*/
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin bottom
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin bottom
|
||||
*/
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin
|
||||
*/
|
||||
public function getCellMargin()
|
||||
{
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
*/
|
||||
class PHPWord_Style_TableFull
|
||||
{
|
||||
|
||||
/**
|
||||
* Style for first row
|
||||
*
|
||||
|
|
@ -160,6 +159,10 @@ class PHPWord_Style_TableFull
|
|||
|
||||
/**
|
||||
* Create a new TableFull Font
|
||||
*
|
||||
* @param null|array $styleTable
|
||||
* @param null|array $styleFirstRow
|
||||
* @param null|array $styleLastRow
|
||||
*/
|
||||
public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null)
|
||||
{
|
||||
|
|
@ -234,11 +237,19 @@ class PHPWord_Style_TableFull
|
|||
return $this->_lastRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background color
|
||||
*/
|
||||
public function getBgColor()
|
||||
{
|
||||
return $this->_bgColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set background color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBgColor($pValue = null)
|
||||
{
|
||||
$this->_bgColor = $pValue;
|
||||
|
|
@ -247,7 +258,7 @@ class PHPWord_Style_TableFull
|
|||
/**
|
||||
* Set TLRBVH Border Size
|
||||
*
|
||||
* @param int $pValue Border size in eighths of a point (1/8 point)
|
||||
* @param int $pValue Border size in eighths of a point (1/8 point)
|
||||
*/
|
||||
public function setBorderSize($pValue = null)
|
||||
{
|
||||
|
|
@ -278,6 +289,8 @@ class PHPWord_Style_TableFull
|
|||
|
||||
/**
|
||||
* Set TLRBVH Border Color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderColor($pValue = null)
|
||||
{
|
||||
|
|
@ -306,161 +319,293 @@ class PHPWord_Style_TableFull
|
|||
return array($t, $l, $r, $b, $h, $v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border top size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderTopSize($pValue = null)
|
||||
{
|
||||
$this->_borderTopSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border top size
|
||||
*/
|
||||
public function getBorderTopSize()
|
||||
{
|
||||
return $this->_borderTopSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border top color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderTopColor($pValue = null)
|
||||
{
|
||||
$this->_borderTopColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border top color
|
||||
*/
|
||||
public function getBorderTopColor()
|
||||
{
|
||||
return $this->_borderTopColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border left size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderLeftSize($pValue = null)
|
||||
{
|
||||
$this->_borderLeftSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border left size
|
||||
*/
|
||||
public function getBorderLeftSize()
|
||||
{
|
||||
return $this->_borderLeftSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border left color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderLeftColor($pValue = null)
|
||||
{
|
||||
$this->_borderLeftColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border left color
|
||||
*/
|
||||
public function getBorderLeftColor()
|
||||
{
|
||||
return $this->_borderLeftColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border right size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderRightSize($pValue = null)
|
||||
{
|
||||
$this->_borderRightSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border right size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function getBorderRightSize()
|
||||
{
|
||||
return $this->_borderRightSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border right color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderRightColor($pValue = null)
|
||||
{
|
||||
$this->_borderRightColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border right color
|
||||
*/
|
||||
public function getBorderRightColor()
|
||||
{
|
||||
return $this->_borderRightColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border bottom size
|
||||
*
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderBottomSize($pValue = null)
|
||||
{
|
||||
$this->_borderBottomSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border bottom size
|
||||
*/
|
||||
public function getBorderBottomSize()
|
||||
{
|
||||
return $this->_borderBottomSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border bottom color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderBottomColor($pValue = null)
|
||||
{
|
||||
$this->_borderBottomColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border bottom color
|
||||
*/
|
||||
public function getBorderBottomColor()
|
||||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border inside horizontal color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderInsideHColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border inside horizontal color
|
||||
*/
|
||||
public function getBorderInsideHColor()
|
||||
{
|
||||
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border inside vertical color
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderInsideVColor($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border inside vertical color
|
||||
*/
|
||||
public function getBorderInsideVColor()
|
||||
{
|
||||
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border inside horizontal size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderInsideHSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideHSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border inside horizontal size
|
||||
*/
|
||||
public function getBorderInsideHSize()
|
||||
{
|
||||
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border inside vertical size
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBorderInsideVSize($pValue = null)
|
||||
{
|
||||
$this->_borderInsideVSize = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border inside vertical size
|
||||
*/
|
||||
public function getBorderInsideVSize()
|
||||
{
|
||||
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin top
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginTop($pValue = null)
|
||||
{
|
||||
$this->_cellMarginTop = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin top
|
||||
*/
|
||||
public function getCellMarginTop()
|
||||
{
|
||||
return $this->_cellMarginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin left
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginLeft($pValue = null)
|
||||
{
|
||||
$this->_cellMarginLeft = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin left
|
||||
*/
|
||||
public function getCellMarginLeft()
|
||||
{
|
||||
return $this->_cellMarginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin right
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginRight($pValue = null)
|
||||
{
|
||||
$this->_cellMarginRight = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin right
|
||||
*/
|
||||
public function getCellMarginRight()
|
||||
{
|
||||
return $this->_cellMarginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell margin bottom
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setCellMarginBottom($pValue = null)
|
||||
{
|
||||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin bottom
|
||||
*/
|
||||
public function getCellMarginBottom()
|
||||
{
|
||||
return $this->_cellMarginBottom;
|
||||
|
|
@ -479,6 +624,9 @@ class PHPWord_Style_TableFull
|
|||
$this->_cellMarginBottom = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell margin
|
||||
*/
|
||||
public function getCellMargin()
|
||||
{
|
||||
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class PHPWord_Style_Tabs
|
|||
private $_tabs;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $tabs
|
||||
*/
|
||||
|
|
@ -48,6 +49,7 @@ class PHPWord_Style_Tabs
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert to XML
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ class PHPWord_TOC
|
|||
/**
|
||||
* Add a Title
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $depth
|
||||
* @return array
|
||||
*/
|
||||
public static function addTitle($text, $depth = 0)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ interface PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
|
|
@ -98,8 +98,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
|
|
@ -212,8 +212,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_ODText
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
|
|
@ -226,6 +226,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
|
|
@ -235,8 +236,8 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
public function getWriterPart($pPartName = '')
|
||||
{
|
||||
|
|
@ -260,9 +261,9 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
* @return PHPWord_Writer_ODText
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
/**
|
||||
* Write content file to XML format
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeContent(PHPWord $pPHPWord = null)
|
||||
{
|
||||
|
|
@ -344,9 +344,9 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
/**
|
||||
* Write TextRun section
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param PHPWord_Section_TextRun $textrun
|
||||
* @todo Enable all other section types
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param PHPWord_Section_TextRun $textrun
|
||||
* @todo Enable all other section types
|
||||
*/
|
||||
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun)
|
||||
{
|
||||
|
|
@ -364,6 +364,8 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
|
||||
/**
|
||||
* Write TextBreak
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
|
|
@ -373,10 +375,22 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
|||
}
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
/**
|
||||
* Write end section
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param PHPWord_Section $section
|
||||
*/
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Write section
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param PHPWord_Section $section
|
||||
*/
|
||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,9 +113,10 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart
|
|||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
* @codeCoverageIgnore Image is not yet handled by ODText
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,14 +44,31 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Color table
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_colorTable;
|
||||
|
||||
/**
|
||||
* Font table
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_fontTable;
|
||||
|
||||
/**
|
||||
* Last paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Paragraph
|
||||
*/
|
||||
private $_lastParagraphStyle;
|
||||
|
||||
/**
|
||||
* Create a new PHPWord_Writer_ODText
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $pPHPWord = null)
|
||||
{
|
||||
|
|
@ -65,8 +82,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Save PHPWord to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
|
|
@ -115,8 +132,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
/**
|
||||
* Get PHPWord object
|
||||
*
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @param PHPWord $pPHPWord PHPWord object
|
||||
* @throws Exception
|
||||
* @return PHPWord_Writer_RTF
|
||||
*/
|
||||
public function setPHPWord(PHPWord $pPHPWord = null)
|
||||
|
|
@ -129,12 +146,18 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
* Get PHPWord_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPWord_HashTable
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getDrawingHashTable()
|
||||
{
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get document data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getData()
|
||||
{
|
||||
// PHPWord object : $this->_document
|
||||
|
|
@ -188,6 +211,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
return $sRTFContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDataFont()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
|
@ -238,6 +266,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
return $arrFonts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getDataColor()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
|
@ -294,6 +327,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
return $arrColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDataContent()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
|
@ -342,6 +380,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @param PHPWord_Section_Text $text
|
||||
* @param boolean $withoutP
|
||||
* @return string
|
||||
*/
|
||||
private function getDataContentText(PHPWord_Section_Text $text, $withoutP = false)
|
||||
{
|
||||
|
|
@ -428,11 +470,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
if (!$withoutP) {
|
||||
$sRTFText .= '\par' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $sRTFText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text run content
|
||||
*
|
||||
* @param PHPWord_Section_TextRun $textrun
|
||||
* @return string
|
||||
*/
|
||||
private function getDataContentTextRun(PHPWord_Section_TextRun $textrun)
|
||||
{
|
||||
|
|
@ -449,9 +495,15 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
}
|
||||
$sRTFText .= '\par' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $sRTFText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text break
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDataContentTextBreak()
|
||||
{
|
||||
$this->_lastParagraphStyle = '';
|
||||
|
|
@ -463,6 +515,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
|||
* Write unsupported element
|
||||
*
|
||||
* @param string $element
|
||||
* @return string
|
||||
*/
|
||||
private function getDataContentUnsupportedElement($element)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.8.0
|
||||
*/
|
||||
|
||||
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||
use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
|
||||
|
||||
|
|
@ -33,15 +32,54 @@ use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
|
|||
*/
|
||||
class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||
{
|
||||
|
||||
/**
|
||||
* PHPWord object
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
/**
|
||||
* Writer parts
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_writerParts;
|
||||
|
||||
/**
|
||||
* Directory for caching
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Use disk caching
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Image types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_imageTypes = array();
|
||||
|
||||
/**
|
||||
* Object types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_objectTypes = array();
|
||||
|
||||
public function __construct(PHPWord $PHPWord = null)
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param PHPWord $PHPWord
|
||||
*/
|
||||
public function __construct(PHPWord $PHPWord = null)
|
||||
{
|
||||
$this->_document = $PHPWord;
|
||||
|
||||
|
|
@ -63,6 +101,11 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save
|
||||
*
|
||||
* @param string $pFilename
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_document)) {
|
||||
|
|
@ -204,6 +247,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
}
|
||||
|
||||
/**
|
||||
* Check content types
|
||||
*
|
||||
* @param string $src
|
||||
*/
|
||||
private function checkContentTypes($src)
|
||||
|
|
@ -212,21 +257,10 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
if (stripos(strrev($src), strrev('.php')) === 0) {
|
||||
$extension = 'php';
|
||||
} else {
|
||||
$imageType = exif_imagetype($src);
|
||||
if ($imageType === IMAGETYPE_JPEG) {
|
||||
$extension = 'jpg';
|
||||
} elseif ($imageType === IMAGETYPE_GIF) {
|
||||
$extension = 'gif';
|
||||
} elseif ($imageType === IMAGETYPE_PNG) {
|
||||
$extension = 'png';
|
||||
} elseif ($imageType === IMAGETYPE_BMP) {
|
||||
$extension = 'bmp';
|
||||
} elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) {
|
||||
$extension = 'tif';
|
||||
}
|
||||
$extension = PHPWord_Shared_File::imagetype($src);
|
||||
}
|
||||
|
||||
if (isset($extension)) {
|
||||
if (isset($extension) && $extension) {
|
||||
$imageData = getimagesize($src);
|
||||
$imageType = image_type_to_mime_type($imageData[2]);
|
||||
$imageExtension = str_replace('.', '', image_type_to_extension($imageData[2]));
|
||||
|
|
@ -236,13 +270,16 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
if (!in_array($imageType, $this->_imageTypes)) {
|
||||
$this->_imageTypes[$imageExtension] = $imageType;
|
||||
}
|
||||
} else {
|
||||
if (!in_array($extension, $this->_objectTypes)) {
|
||||
$this->_objectTypes[] = $extension;
|
||||
}
|
||||
} elseif (!in_array($extension, $this->_objectTypes)) {
|
||||
$this->_objectTypes[] = $extension;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName
|
||||
*/
|
||||
public function getWriterPart($pPartName = '')
|
||||
{
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
|
|
@ -252,11 +289,20 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk catching setting
|
||||
*/
|
||||
public function getUseDiskCaching()
|
||||
{
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk catching setting
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null)
|
||||
{
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
|
@ -272,6 +318,12 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add file to package
|
||||
*
|
||||
* @param mixed $objZip
|
||||
* @param array $element
|
||||
*/
|
||||
private function _addFileToPackage($objZip, $element)
|
||||
{
|
||||
if (isset($element['isMemImage']) && $element['isMemImage']) {
|
||||
|
|
@ -289,4 +341,14 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
|||
$this->checkContentTypes($element['source']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory()
|
||||
{
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
/**
|
||||
* Write text
|
||||
*
|
||||
* @param boolean $withoutP
|
||||
*/
|
||||
protected function _writeText(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Text $text, $withoutP = false)
|
||||
{
|
||||
|
|
@ -232,6 +233,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
|
||||
/**
|
||||
* Write link
|
||||
*
|
||||
* @param boolean $withoutP
|
||||
*/
|
||||
protected function _writeLink(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Link $link, $withoutP = false)
|
||||
{
|
||||
|
|
@ -791,8 +794,11 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
}
|
||||
|
||||
/**
|
||||
* Write image
|
||||
*
|
||||
* @param \PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param \PHPWord_Section_Image|\PHPWord_Section_MemoryImage $image
|
||||
* @param boolean $withoutP
|
||||
*/
|
||||
protected function _writeImage(PHPWord_Shared_XMLWriter $objWriter = null, $image, $withoutP = false)
|
||||
{
|
||||
|
|
@ -873,6 +879,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
|
||||
/**
|
||||
* Write watermark
|
||||
*
|
||||
* @param PHP_Section_Image|PHP_Section_MemoryImage $image
|
||||
*/
|
||||
protected function _writeWatermark(PHPWord_Shared_XMLWriter $objWriter = null, $image)
|
||||
{
|
||||
|
|
@ -1003,6 +1011,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
|
||||
/**
|
||||
* Write footnote reference
|
||||
*
|
||||
* @param boolean $withoutP
|
||||
*/
|
||||
protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,15 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
/**
|
||||
* Write contenttypes.xml
|
||||
*
|
||||
* @param array $_imageTypes
|
||||
* @param array $_objectTypes
|
||||
* @param int $_cHdrs
|
||||
* @param array $footers
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -163,7 +171,6 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
|
|
@ -173,9 +180,9 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
|
|
@ -190,10 +197,10 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
|
|
@ -211,10 +218,10 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
|||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPWord_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
/**
|
||||
* Write app.xml
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeDocPropsApp(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -122,7 +127,12 @@ class PHPWord_Writer_Word2007_DocProps extends PHPWord_Writer_Word2007_WriterPar
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write core.xml
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeDocPropsCore(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* Write document.xml
|
||||
*/
|
||||
public function writeDocument(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -114,6 +116,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write section start
|
||||
*/
|
||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
$objWriter->startElement('w:p');
|
||||
|
|
@ -123,6 +128,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write section end
|
||||
*/
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
{
|
||||
$settings = $section->getSettings();
|
||||
|
|
@ -256,6 +264,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write page break element
|
||||
*/
|
||||
private function _writePageBreak(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->startElement('w:p');
|
||||
|
|
@ -267,6 +278,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write list item element
|
||||
*/
|
||||
public function _writeListItem(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_ListItem $listItem)
|
||||
{
|
||||
$textObject = $listItem->getTextObject();
|
||||
|
|
@ -306,6 +320,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object element
|
||||
*/
|
||||
protected function _writeObject(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Object $object)
|
||||
{
|
||||
$rIdObject = $object->getRelationId();
|
||||
|
|
@ -365,6 +382,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
/**
|
||||
* Write TOC element
|
||||
*/
|
||||
private function _writeTOC(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$titles = PHPWord_TOC::getTitles();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
/**
|
||||
* Write word/_rels/document.xml.rels
|
||||
*
|
||||
* @param array $_relsCollection
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeDocumentRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -119,6 +124,12 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write word/_rels/(header|footer)(\d).xml.rels
|
||||
*
|
||||
* @param array $_relsCollection
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeHeaderFooterRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -150,13 +161,21 @@ class PHPWord_Writer_Word2007_DocumentRels extends PHPWord_Writer_Word2007_Write
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write individual relations
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param int $pId
|
||||
* @param string $pType
|
||||
* @param string $pTarget
|
||||
* @param string $pTargetMode
|
||||
*/
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Footer extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* Write footer
|
||||
*
|
||||
* @param PHPWord_Section_Footer $footer
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeFooter(PHPWord_Section_Footer $footer)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
|
|||
|
|
@ -25,9 +25,17 @@
|
|||
* @version 0.8.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_Footnotes
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
/**
|
||||
* Write footnotes.xml
|
||||
*
|
||||
* @param array $allFootnotesCollection
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeFootnotes($allFootnotesCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
|
|||
|
|
@ -25,9 +25,16 @@
|
|||
* @version 0.8.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class PHPWord_Writer_Word2007_FootnotesRels
|
||||
*/
|
||||
class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write footnotes relationships
|
||||
*
|
||||
* @param array $_relsCollection
|
||||
*/
|
||||
public function writeFootnotesRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -61,6 +68,15 @@ class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_Writ
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write individual relations
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param int $pId
|
||||
* @param string $pType
|
||||
* @param string $pTarget
|
||||
* @param string $pTargetMode
|
||||
*/
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Header extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* Write header
|
||||
*
|
||||
* @param PHPWord_Section_Header $header
|
||||
* @return string XML data
|
||||
*/
|
||||
public function writeHeader(PHPWord_Section_Header $header)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Rels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
|
||||
/**
|
||||
* Write _rels/.rels
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function writeRelationships(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
|
|||
|
|
@ -30,9 +30,18 @@
|
|||
*/
|
||||
class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* PHPWord object
|
||||
*
|
||||
* @var PHPWord
|
||||
*/
|
||||
private $_document;
|
||||
|
||||
/**
|
||||
* Write styles
|
||||
*
|
||||
* @param PHPWord $pPHPWord
|
||||
*/
|
||||
public function writeStyles(PHPWord $pPHPWord = null)
|
||||
{
|
||||
// Create XML writer
|
||||
|
|
@ -181,6 +190,12 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write style
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param PHPWord_Style_TableFull $style
|
||||
*/
|
||||
private function _writeFullTableStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
|
||||
|
|
@ -302,6 +317,13 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write row style
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
* @param string $type
|
||||
* @param PHPWord_Style_TableFull $style
|
||||
*/
|
||||
private function _writeRowStyle(PHPWord_Shared_XMLWriter $objWriter = null, $type, PHPWord_Style_TableFull $style)
|
||||
{
|
||||
$brdSz = $style->getBorderSize();
|
||||
|
|
@ -362,7 +384,11 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write doc defaults
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
private function _writeDocDefaults(PHPWord_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$fontName = $this->_document->getDefaultFontName();
|
||||
|
|
|
|||
|
|
@ -30,13 +30,28 @@
|
|||
*/
|
||||
abstract class PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Parent writer object
|
||||
*
|
||||
* @var PHPWord_Writer_Word2007
|
||||
*/
|
||||
private $_parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent writer
|
||||
*
|
||||
* @param PHPWord_Writer_IWriter
|
||||
*/
|
||||
public function setParentWriter(PHPWord_Writer_IWriter $pWriter = null)
|
||||
{
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent writer
|
||||
*
|
||||
* @return PHPWord_Writer_IWriter
|
||||
*/
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
|
|
|
|||
|
|
@ -54,4 +54,39 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||
$expected = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
$this->assertEquals($expected, PHPWord_Shared_File::realpath($file));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPWord_Shared_File::imagetype
|
||||
* @covers PHPWord_Shared_File::fallbackImagetype
|
||||
*/
|
||||
public function testImagetype()
|
||||
{
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars_noext_jpg";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mars.jpg";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_JPEG, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/mario.gif";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_GIF, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/firefox.png";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_PNG, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/duke_nukem.bmp";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_BMP, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/angela_merkel.tif";
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertEquals(PHPWord_Shared_File::IMAGETYPE_TIFF, PHPWord_Shared_File::imagetype($filename));
|
||||
|
||||
$filename = PHPWORD_TESTS_DIR_ROOT . "/_files/images/alexz-johnson.pcx";
|
||||
$this->assertFalse(PHPWord_Shared_File::imagetype($filename, true));
|
||||
$this->assertFalse(PHPWord_Shared_File::imagetype($filename));
|
||||
}
|
||||
}
|
||||
|
|
@ -145,17 +145,43 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
|
|||
@$template->applyXslStyleSheet($xslDOMDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHPWord_Template
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$template = \join(
|
||||
\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx')
|
||||
);
|
||||
$expectedVar = array('tableHeader', 'userId', 'userName');
|
||||
$document = new PHPWord_Template($template);
|
||||
$actualVar = $document->getVariables();
|
||||
$document->cloneRow('userId', 9);
|
||||
$document->setValue('userId#1', utf8_decode('ééé'));
|
||||
$document->setValue('userId#2', 'a');
|
||||
$document->setValue('userId#3', 'a');
|
||||
$document->setValue('userId#3', 'a');
|
||||
$document->setValue('userId#4', 'a');
|
||||
$document->setValue('userId#5', 'a');
|
||||
$document->setValue('userId#6', 'a');
|
||||
$document->setValue('userId#7', 'a');
|
||||
$document->setValue('userId#8', 'a');
|
||||
$document->cloneRow('userId#9', 'a');
|
||||
$this->assertEquals($expectedVar, $actualVar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setValue
|
||||
* @covers ::getVariables
|
||||
* @covers ::cloneRow
|
||||
* @covers ::saveAs
|
||||
*/
|
||||
public function testCloneRow()
|
||||
public function testCloneMergedRow()
|
||||
{
|
||||
$template = \join(
|
||||
\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-row.docx')
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'templates', 'clone-merge.docx')
|
||||
);
|
||||
$expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation');
|
||||
$docName = 'clone-test-result.docx';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests\Writer\ODText;
|
||||
|
||||
use PHPWord_Writer_ODText_WriterPart;
|
||||
use PHPWord_Writer_ODText;
|
||||
use PHPWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Class WriterPartTest
|
||||
*
|
||||
* @package PHPWord\Tests
|
||||
* @coversDefaultClass PHPWord_Writer_ODText_WriterPart
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class WriterPartTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* covers ::setParentWriter
|
||||
* covers ::getParentWriter
|
||||
*/
|
||||
public function testSetGetParentWriter()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PHPWord_Writer_Word2007_WriterPart'
|
||||
);
|
||||
$object->setParentWriter(new PHPWord_Writer_ODText());
|
||||
$this->assertEquals(
|
||||
new PHPWord_Writer_ODText(),
|
||||
$object->getParentWriter()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* covers ::getParentWriter
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned.
|
||||
*/
|
||||
public function testSetGetParentWriterNull()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PHPWord_Writer_Word2007_WriterPart'
|
||||
);
|
||||
$object->getParentWriter();
|
||||
}
|
||||
}
|
||||
|
|
@ -92,19 +92,6 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
|
|||
unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::save
|
||||
* @todo Haven't got any method to test this
|
||||
*/
|
||||
public function testSavePhpOutput()
|
||||
{
|
||||
$phpWord = new PHPWord();
|
||||
$section = $phpWord->createSection();
|
||||
$section->addText('Test');
|
||||
$writer = new PHPWord_Writer_ODText($phpWord);
|
||||
$writer->save('php://output');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::save
|
||||
* @expectedException Exception
|
||||
|
|
|
|||
|
|
@ -35,19 +35,6 @@ class RTFTest extends \PHPUnit_Framework_TestCase
|
|||
$object->getPHPWord();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::save
|
||||
* @todo Haven't got any method to test this
|
||||
*/
|
||||
public function testSavePhpOutput()
|
||||
{
|
||||
$phpWord = new PHPWord();
|
||||
$section = $phpWord->createSection();
|
||||
$section->addText('Test');
|
||||
$writer = new PHPWord_Writer_RTF($phpWord);
|
||||
$writer->save('php://output');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::save
|
||||
* @expectedException Exception
|
||||
|
|
@ -78,13 +65,15 @@ class RTFTest extends \PHPUnit_Framework_TestCase
|
|||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf')
|
||||
);
|
||||
|
||||
$fontStyle = array('name' => 'Verdana', 'size' => 11, 'bold' => true, 'italic' => true, 'color' => 'F29101', 'fgColor' => '123456');
|
||||
$paragraphStyle = array('align' => 'center', 'spaceAfter' => 120);
|
||||
$phpWord = new PHPWord();
|
||||
$phpWord->addFontStyle('Font', array('size' => 11));
|
||||
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
|
||||
$phpWord->addFontStyle('Font', $fontStyle);
|
||||
$phpWord->addParagraphStyle('Paragraph', $paragraphStyle);
|
||||
$section = $phpWord->createSection();
|
||||
$section->addText('Test 1', 'Font');
|
||||
$section->addText('Test 2', array('name' => 'Tahoma'), 'Paragraph');
|
||||
$section->addTextBreak();
|
||||
$section->addText('Test 2', null, 'Paragraph');
|
||||
$section->addLink('http://test.com');
|
||||
$section->addTitle('Test', 1);
|
||||
$section->addPageBreak();
|
||||
|
|
|
|||
|
|
@ -84,4 +84,4 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
|
|||
$element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
|
||||
$this->assertEquals('Embed', $element->getAttribute('Type'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests\Writer\Word2007;
|
||||
|
||||
use PHPWord_Writer_Word2007_Footer;
|
||||
use PHPWord_Writer_Word2007;
|
||||
use PHPWord_Section_Footer;
|
||||
use PHPWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Class FooterTest
|
||||
*
|
||||
* @package PHPWord\Tests
|
||||
* @coversDefaultClass PHPWord_Writer_Word2007_Footer
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class FooterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::writeFooter
|
||||
*/
|
||||
public function testWriteFooter()
|
||||
{
|
||||
$imageSrc = \join(
|
||||
\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
|
||||
);
|
||||
$container = new PHPWord_Section_Footer(1);
|
||||
$container->addText('');
|
||||
$container->addPreserveText('');
|
||||
$container->addTextBreak();
|
||||
$container->createTextRun();
|
||||
$container->addTable()->addRow()->addCell()->addText('');
|
||||
$container->addImage($imageSrc);
|
||||
|
||||
$writer = new PHPWord_Writer_Word2007();
|
||||
$object = new PHPWord_Writer_Word2007_Footer();
|
||||
$object->setParentWriter($writer);
|
||||
$object->writeFooter($container);
|
||||
$writer->setUseDiskCaching(true);
|
||||
$xml = simplexml_load_string($object->writeFooter($container));
|
||||
|
||||
$this->assertInstanceOf('SimpleXMLElement', $xml);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests\Writer\Word2007;
|
||||
|
||||
use PHPWord_Writer_Word2007_Header;
|
||||
use PHPWord_Writer_Word2007;
|
||||
use PHPWord_Section_Header;
|
||||
use PHPWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Class HeaderTest
|
||||
*
|
||||
* @package PHPWord\Tests
|
||||
* @coversDefaultClass PHPWord_Writer_Word2007_Header
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class HeaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::writeHeader
|
||||
*/
|
||||
public function testWriteHeader()
|
||||
{
|
||||
$imageSrc = \join(
|
||||
\DIRECTORY_SEPARATOR,
|
||||
array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'images', 'PHPWord.png')
|
||||
);
|
||||
|
||||
$container = new PHPWord_Section_Header(1);
|
||||
$container->addText('Test');
|
||||
$container->addPreserveText('');
|
||||
$container->addTextBreak();
|
||||
$container->createTextRun();
|
||||
$container->addTable()->addRow()->addCell()->addText('');
|
||||
$container->addImage($imageSrc);
|
||||
$container->addWatermark($imageSrc);
|
||||
|
||||
$writer = new PHPWord_Writer_Word2007();
|
||||
$object = new PHPWord_Writer_Word2007_Header();
|
||||
$object->setParentWriter($writer);
|
||||
$object->writeHeader($container);
|
||||
$writer->setUseDiskCaching(true);
|
||||
$xml = simplexml_load_string($object->writeHeader($container));
|
||||
|
||||
$this->assertInstanceOf('SimpleXMLElement', $xml);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace PHPWord\Tests\Writer\Word2007;
|
||||
|
||||
use PHPWord_Writer_Word2007_WriterPart;
|
||||
use PHPWord_Writer_Word2007;
|
||||
use PHPWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Class WriterPartTest
|
||||
*
|
||||
* @package PHPWord\Tests
|
||||
* @coversDefaultClass PHPWord_Writer_Word2007_WriterPart
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class WriterPartTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* covers ::setParentWriter
|
||||
* covers ::getParentWriter
|
||||
*/
|
||||
public function testSetGetParentWriter()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PHPWord_Writer_Word2007_WriterPart'
|
||||
);
|
||||
$object->setParentWriter(new PHPWord_Writer_Word2007());
|
||||
$this->assertEquals(
|
||||
new PHPWord_Writer_Word2007(),
|
||||
$object->getParentWriter()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* covers ::getParentWriter
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned.
|
||||
*/
|
||||
public function testSetGetParentWriterNull()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PHPWord_Writer_Word2007_WriterPart'
|
||||
);
|
||||
$object->getParentWriter();
|
||||
}
|
||||
}
|
||||
|
|
@ -67,6 +67,26 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
|
|||
unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::save
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage PHPWord object unassigned.
|
||||
*/
|
||||
public function testSaveException()
|
||||
{
|
||||
$writer = new PHPWord_Writer_Word2007();
|
||||
$writer->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getWriterPart
|
||||
*/
|
||||
public function testGetWriterPartNull()
|
||||
{
|
||||
$object = new PHPWord_Writer_Word2007();
|
||||
$this->assertNull($object->getWriterPart('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::checkContentTypes
|
||||
*/
|
||||
|
|
@ -100,13 +120,14 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @covers ::setUseDiskCaching
|
||||
* @covers ::getUseDiskCaching
|
||||
* @covers ::getDiskCachingDirectory
|
||||
*/
|
||||
public function testSetGetUseDiskCaching()
|
||||
{
|
||||
$object = new PHPWord_Writer_Word2007();
|
||||
$object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT);
|
||||
|
||||
$this->assertTrue($object->getUseDiskCaching());
|
||||
$this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class PHPWordTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @covers PHPWord::loadTemplate
|
||||
* @expectedException PHPWord_Exception
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testLoadTemplateException()
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -5,11 +5,14 @@ use PHPWord;
|
|||
|
||||
class TestHelperDOCX
|
||||
{
|
||||
/** @var string $file */
|
||||
static protected $file;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $file;
|
||||
|
||||
/**
|
||||
* @param \PHPWord $PHPWord
|
||||
* @param string $writer
|
||||
* @return \PHPWord\Tests\XmlDocument
|
||||
*/
|
||||
public static function getDocument(PHPWord $PHPWord, $writer = 'Word2007')
|
||||
|
|
@ -67,4 +70,4 @@ class TestHelperDOCX
|
|||
{
|
||||
return self::$file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
* @version ##VERSION##, ##DATE##
|
||||
**************************************************************************************
|
||||
|
||||
Changes in branch for release 0.9.0 :
|
||||
- QA: (Progi1984) - Documentation
|
||||
Changes in branch for release 0.8.1 :
|
||||
- Feature: (bskrtich, gabrielbull) - Added fallback for computers that do not have exif_imagetype
|
||||
|
||||
Changes in branch for release 0.8.0 :
|
||||
- Bugfix: (gabrielbull) - Fixed bug with cell styling
|
||||
|
|
|
|||
Loading…
Reference in New Issue