Čiščenje ultra nujnih varnostnih reči:
- vklopljen TLS za vso komunikacijo - ukinjen 13 let star PHPPowerPoint, migracija na PHPOffice/Presentation (naslednik)
This commit is contained in:
parent
32f4daffd7
commit
51e8c3b651
10
Spremembe.md
Normal file
10
Spremembe.md
Normal file
@ -0,0 +1,10 @@
|
||||
# SPREMEMBE, DOPOLNITVE
|
||||
|
||||
## Nujne security zadeve
|
||||
- vklopil TLS v vseh CURLih
|
||||
- vklopil TLS pri pošiljanju emailov
|
||||
|
||||
## Varnostne posodobitve
|
||||
- migriral PHPPowerPoint (letnik 2009) na PHPOffice/PHPPresentation (letnik 2021, stable release)
|
||||
|
||||
|
@ -1,299 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_DocumentProperties
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_DocumentProperties
|
||||
{
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator;
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_creator = 'Unknown Creator';
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
$this->_title = "Untitled Presentation";
|
||||
$this->_subject = '';
|
||||
$this->_description = '';
|
||||
$this->_keywords = '';
|
||||
$this->_category = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
$this->_creator = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_created = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_modified = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
$this->_title = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
$this->_subject = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
$this->_keywords = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
$this->_category = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_HashTable
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_HashTable
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPPowerPoint_IComparable $pSource = null) {
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if ( is_null ( $hashIndex ) ) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if ( isset ( $this->_keyMap[$hashIndex] ) ) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->_items[ $hashCode ])) {
|
||||
$this->_items[ $hashCode ] = $pSource;
|
||||
$index = count($this->_items) - 1;
|
||||
$this->_keyMap[ $index ] = $hashCode;
|
||||
$pSource->setHashIndex( $index );
|
||||
} else {
|
||||
$pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable $pSource Item to remove
|
||||
* @throws Exception
|
||||
*/
|
||||
public function remove(PHPPowerPoint_IComparable $pSource = null) {
|
||||
if (isset($this->_items[ $pSource->getHashCode() ])) {
|
||||
unset($this->_items[ $pSource->getHashCode() ]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPPowerPoint_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPPowerPoint_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return PHPPowerPoint_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_IComparable
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex();
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value);
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
/** PHPPowerPoint_IReader */
|
||||
require_once 'PHPPowerPoint/Reader/IReader.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_IOFactory
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_IOFactory
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PHPPowerPoint/Writer/{0}.php', 'class' => 'PHPPowerPoint_Writer_{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PHPPowerPoint/Reader/{0}.php', 'class' => 'PHPPowerPoint_Reader_{0}' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Serialized'
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPPowerPoint_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPPowerPoint/Writer/{0}.php
|
||||
* @param string $classname Example: PHPPowerPoint_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPPowerPoint_Writer_IWriter
|
||||
*
|
||||
* @param PHPPowerPoint $PHPPowerPoint
|
||||
* @param string $writerType Example: PowerPoint2007
|
||||
* @return PHPPowerPoint_Writer_IWriter
|
||||
*/
|
||||
public static function createWriter(PHPPowerPoint $PHPPowerPoint, $writerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IWriter';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once($classFile);
|
||||
}
|
||||
|
||||
$instance = new $className($PHPPowerPoint);
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $writerType");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPPowerPoint_Reader_IReader
|
||||
*
|
||||
* @param string $readerType Example: PowerPoint2007
|
||||
* @return PHPPowerPoint_Reader_IReader
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IReader';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once($classFile);
|
||||
}
|
||||
|
||||
$instance = new $className();
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $readerType");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint from file using automatic PHPPowerPoint_Reader_IReader resolution
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
// Try loading using self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not automatically determine PHPPowerPoint_Reader_IReader for file.");
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Reader_IReader
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPPowerPoint_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint from file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Reader_IReader */
|
||||
require_once 'PHPPowerPoint/Reader/IReader.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_File */
|
||||
require_once 'PHPPowerPoint/Shared/File.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Reader_Serialized
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Reader_Serialized implements PHPPowerPoint_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPPowerPoint_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
return $this->fileSupportsUnserializePHPPowerPoint($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePHPPowerPoint($pFilename)) {
|
||||
throw new Exception("Invalid file format for PHPPowerPoint_Reader_Serialized: " . $pFilename . ".");
|
||||
}
|
||||
|
||||
return $this->_loadSerialized($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PHPPowerPoint Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPPowerPoint
|
||||
*/
|
||||
private function _loadSerialized($pFilename) {
|
||||
$xmlData = simplexml_load_string(file_get_contents("zip://$pFilename#PHPPowerPoint.xml"));
|
||||
$excel = unserialize(base64_decode((string)$xmlData->data));
|
||||
|
||||
// Update media links
|
||||
for ($i = 0; $i < $excel->getSlideCount(); ++$i) {
|
||||
for ($j = 0; $j < $excel->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($excel->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPExcl_Shape_BaseDrawing) {
|
||||
$imgTemp =& $excel->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a file support UnserializePHPPowerPoint ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function fileSupportsUnserializePHPPowerPoint($pFilename = '') {
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// File exists, does it contain PHPPowerPoint.xml?
|
||||
return PHPPowerPoint_Shared_File::file_exists("zip://$pFilename#PHPPowerPoint.xml");
|
||||
}
|
||||
}
|
@ -1,358 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Fill */
|
||||
require_once 'PHPPowerPoint/Style/Fill.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Shadow */
|
||||
require_once 'PHPPowerPoint/Shape/Shadow.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Slide
|
||||
*
|
||||
* @var PHPPowerPoint_Slide
|
||||
*/
|
||||
protected $_slide;
|
||||
|
||||
/**
|
||||
* Offset X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_offsetX;
|
||||
|
||||
/**
|
||||
* Offset Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_offsetY;
|
||||
|
||||
/**
|
||||
* Width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_width;
|
||||
|
||||
/**
|
||||
* Height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_height;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
private $_fill;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_rotation;
|
||||
|
||||
/**
|
||||
* Shadow
|
||||
*
|
||||
* @var PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
protected $_shadow;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_slide = null;
|
||||
$this->_offsetX = 0;
|
||||
$this->_offsetY = 0;
|
||||
$this->_width = 0;
|
||||
$this->_height = 0;
|
||||
$this->_rotation = 0;
|
||||
$this->_fill = new PHPPowerPoint_Style_Fill();
|
||||
$this->_shadow = new PHPPowerPoint_Shape_Shadow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Slide
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function getSlide() {
|
||||
return $this->_slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Slide
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pValue
|
||||
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setSlide(PHPPowerPoint_slide $pValue = null, $pOverrideOld = false) {
|
||||
if (is_null($this->_slide)) {
|
||||
// Add drawing to PHPPowerPoint_Slide
|
||||
$this->_slide = $pValue;
|
||||
$this->_slide->getShapeCollection()->append($this);
|
||||
} else {
|
||||
if ($pOverrideOld) {
|
||||
// Remove drawing from old PHPPowerPoint_Slide
|
||||
$iterator = $this->_slide->getShapeCollection()->getIterator();
|
||||
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
|
||||
$this->_slide->getShapeCollection()->offsetUnset( $iterator->key() );
|
||||
$this->_slide = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set new PHPPowerPoint_Slide
|
||||
$this->setSlide($pValue);
|
||||
} else {
|
||||
throw new Exception("A PHPPowerPoint_Slide has already been assigned. Shapes can only exist on one PHPPowerPoint_Slide.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX() {
|
||||
return $this->_offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setOffsetX($pValue = 0) {
|
||||
$this->_offsetX = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY() {
|
||||
return $this->_offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setOffsetY($pValue = 0) {
|
||||
$this->_offsetY = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setWidth($pValue = 0) {
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeight($pValue = 0) {
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0) {
|
||||
$this->_width = $width;
|
||||
$this->_height = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotation() {
|
||||
return $this->_rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setRotation($pValue = 0) {
|
||||
$this->_rotation = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
public function getFill() {
|
||||
return $this->_fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
public function getShadow() {
|
||||
return $this->_shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_Shadow $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setShadow(PHPPowerPoint_Shape_Shadow $pValue = null) {
|
||||
$this->_shadow = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_slide->getHashCode()
|
||||
. $this->_offsetX
|
||||
. $this->_offsetY
|
||||
. $this->_width
|
||||
. $this->_height
|
||||
. $this->_rotation
|
||||
. $this->getFill()->getHashCode()
|
||||
. $this->_shadow->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,272 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_BaseDrawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Shape_BaseDrawing extends PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Image counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_imageCounter = 0;
|
||||
|
||||
/**
|
||||
* Image index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_imageIndex = 0;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_description;
|
||||
|
||||
/**
|
||||
* Proportional resize
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_resizeProportional;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_BaseDrawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_name = '';
|
||||
$this->_description = '';
|
||||
$this->_resizeProportional = true;
|
||||
|
||||
// Set image index
|
||||
self::$_imageCounter++;
|
||||
$this->_imageIndex = self::$_imageCounter;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageIndex() {
|
||||
return $this->_imageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setName($pValue = '') {
|
||||
$this->_name = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setWidth($pValue = 0) {
|
||||
// Resize proportional?
|
||||
if ($this->_resizeProportional && $pValue != 0) {
|
||||
$ratio = $this->_height / $this->_width;
|
||||
$this->_height = round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set width
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeight($pValue = 0) {
|
||||
// Resize proportional?
|
||||
if ($this->_resizeProportional && $pValue != 0) {
|
||||
$ratio = $this->_width / $this->_height;
|
||||
$this->_width = round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set height
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
* @author Vincent@luo MSN:kele_100@hotmail.com
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setResizeProportional(true);
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0) {
|
||||
$xratio = $width / $this->_width;
|
||||
$yratio = $height / $this->_height;
|
||||
if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
|
||||
if (($xratio * $this->_height) < $height) {
|
||||
$this->_height = ceil($xratio * $this->_height);
|
||||
$this->_width = $width;
|
||||
} else {
|
||||
$this->_width = ceil($yratio * $this->_width);
|
||||
$this->_height = $height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ResizeProportional
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getResizeProportional() {
|
||||
return $this->_resizeProportional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ResizeProportional
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setResizeProportional($pValue = true) {
|
||||
$this->_resizeProportional = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_name
|
||||
. $this->_description
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape*/
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_Drawing extends PHPPowerPoint_Shape_BaseDrawing implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_path;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_Drawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_path = '';
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename() {
|
||||
return basename($this->_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename() {
|
||||
return str_replace('.' . $this->getExtension(), '', $this->getFilename()) . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension() {
|
||||
$exploded = explode(".", basename($this->_path));
|
||||
return $exploded[count($exploded) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath() {
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @param boolean $pVerifyFile Verify file
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPath($pValue = '', $pVerifyFile = true) {
|
||||
if ($pVerifyFile) {
|
||||
if (file_exists($pValue)) {
|
||||
$this->_path = $pValue;
|
||||
|
||||
if ($this->_width == 0 && $this->_height == 0) {
|
||||
// Get width/height
|
||||
list($this->_width, $this->_height) = getimagesize($pValue);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("File $pValue not found!");
|
||||
}
|
||||
} else {
|
||||
$this->_path = $pValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_path
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_MemoryDrawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_MemoryDrawing extends PHPPowerPoint_Shape_BaseDrawing implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Rendering functions */
|
||||
const RENDERING_DEFAULT = 'imagepng';
|
||||
const RENDERING_PNG = 'imagepng';
|
||||
const RENDERING_GIF = 'imagegif';
|
||||
const RENDERING_JPEG = 'imagejpeg';
|
||||
|
||||
/* MIME types */
|
||||
const MIMETYPE_DEFAULT = 'image/png';
|
||||
const MIMETYPE_PNG = 'image/png';
|
||||
const MIMETYPE_GIF = 'image/gif';
|
||||
const MIMETYPE_JPEG = 'image/jpeg';
|
||||
|
||||
/**
|
||||
* Image resource
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_imageResource;
|
||||
|
||||
/**
|
||||
* Rendering function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_renderingFunction;
|
||||
|
||||
/**
|
||||
* Mime type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_mimeType;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_uniqueName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_MemoryDrawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_imageResource = null;
|
||||
$this->_renderingFunction = self::RENDERING_DEFAULT;
|
||||
$this->_mimeType = self::MIMETYPE_DEFAULT;
|
||||
$this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image resource
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getImageResource() {
|
||||
return $this->_imageResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image resource
|
||||
*
|
||||
* @param $value resource
|
||||
*/
|
||||
public function setImageResource($value = null) {
|
||||
$this->_imageResource = $value;
|
||||
|
||||
if (!is_null($this->_imageResource)) {
|
||||
// Get width/height
|
||||
$this->_width = imagesx($this->_imageResource);
|
||||
$this->_height = imagesy($this->_imageResource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rendering function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRenderingFunction() {
|
||||
return $this->_renderingFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rendering function
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setRenderingFunction($value = PHPPowerPoint_Slide_MemoryDrawing::RENDERING_DEFAULT) {
|
||||
$this->_renderingFunction = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mime type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType() {
|
||||
return $this->_mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mime type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setMimeType($value = PHPPowerPoint_Slide_MemoryDrawing::MIMETYPE_DEFAULT) {
|
||||
$this->_mimeType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename() {
|
||||
$extension = strtolower($this->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
return $this->_uniqueName . $this->getImageIndex() . '.' . $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_renderingFunction
|
||||
. $this->_mimeType
|
||||
. $this->_uniqueName
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_TextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/TextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_Run */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/Run.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_Break */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/Break.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Alignment */
|
||||
require_once 'PHPPowerPoint/Style/Alignment.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText extends PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var PHPPowerPoint_Shape_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
$this->_alignment = new PHPPowerPoint_Style_Alignment();
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_RichText_ITextElement $pText Rich text element
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addText(PHPPowerPoint_Shape_RichText_ITextElement $pText = null)
|
||||
{
|
||||
$this->_richTextElements[] = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPPowerPoint_Shape_RichText_TextElement
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_TextElement($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText_Break
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_Break();
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPPowerPoint_Shape_RichText_Run
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_Run($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all PHPPowerPoint_Shape_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText_ITextElement[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_RichText_ITextElement[] $pElements Array of elements
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (is_array($pElements)) {
|
||||
$this->_richTextElements = $pElements;
|
||||
} else {
|
||||
throw new Exception("Invalid PHPPowerPoint_Shape_RichText_ITextElement[] array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$hashElements = '';
|
||||
foreach ($this->_richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$hashElements
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ($key == '_parent') continue;
|
||||
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_Break
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_Break implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_Break instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
__CLASS__
|
||||
);
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_ITextElement
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_TextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/TextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_Run
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_Run extends PHPPowerPoint_Shape_RichText_TextElement implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_Run instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->setText($pText);
|
||||
$this->_font = new PHPPowerPoint_Style_Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Font $pFont Font
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setFont(PHPPowerPoint_Style_Font $pFont = null) {
|
||||
$this->_font = $pFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getText()
|
||||
. $this->_font->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_TextElement
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_TextElement implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_TextElement instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '') {
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_text
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,314 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_Shadow
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_Shadow implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Shadow alignment */
|
||||
const SHADOW_BOTTOM = 'b';
|
||||
const SHADOW_BOTTOM_LEFT = 'bl';
|
||||
const SHADOW_BOTTOM_RIGHT = 'br';
|
||||
const SHADOW_CENTER = 'ctr';
|
||||
const SHADOW_LEFT = 'l';
|
||||
const SHADOW_TOP = 't';
|
||||
const SHADOW_TOP_LEFT = 'tl';
|
||||
const SHADOW_TOP_RIGHT = 'tr';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_visible;
|
||||
|
||||
/**
|
||||
* Blur radius
|
||||
*
|
||||
* Defaults to 6
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_blurRadius;
|
||||
|
||||
/**
|
||||
* Shadow distance
|
||||
*
|
||||
* Defaults to 2
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_distance;
|
||||
|
||||
/**
|
||||
* Shadow direction (in degrees)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_direction;
|
||||
|
||||
/**
|
||||
* Shadow alignment
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Alpha
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_alpha;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_visible = false;
|
||||
$this->_blurRadius = 6;
|
||||
$this->_distance = 2;
|
||||
$this->_direction = 0;
|
||||
$this->_alignment = self::SHADOW_BOTTOM_RIGHT;
|
||||
$this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
$this->_alpha = 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setVisible($pValue = false) {
|
||||
$this->_visible = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Blur radius
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlurRadius() {
|
||||
return $this->_blurRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Blur radius
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBlurRadius($pValue = 6) {
|
||||
$this->_blurRadius = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDistance() {
|
||||
return $this->_distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow distance
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDistance($pValue = 2) {
|
||||
$this->_distance = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow direction (in degrees)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDirection() {
|
||||
return $this->_direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow direction (in degrees)
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDirection($pValue = 0) {
|
||||
$this->_direction = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow alignment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow alignment
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setAlignment($pValue = 0) {
|
||||
$this->_alignment = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_color = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alpha
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlpha() {
|
||||
return $this->_alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alpha
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setAlpha($pValue = 0) {
|
||||
$this->_alpha = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
($this->_visible ? 't' : 'f')
|
||||
. $this->_blurRadius
|
||||
. $this->_distance
|
||||
. $this->_direction
|
||||
. $this->_alignment
|
||||
. $this->_color->getHashCode()
|
||||
. $this->_alpha
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_Drawing
|
||||
{
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 1.333333333;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_File
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_File
|
||||
{
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename) {
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename) {
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_Font
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_Font
|
||||
{
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1) {
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1) {
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_String
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_String
|
||||
{
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isMbstringEnabled;
|
||||
|
||||
/**
|
||||
* Is iconv extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isIconvEnabled;
|
||||
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$_controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether mbstring extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsMbstringEnabled()
|
||||
{
|
||||
if (isset(self::$_isMbstringEnabled)) {
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether iconv extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsIconvEnabled()
|
||||
{
|
||||
if (isset(self::$_isIconvEnabled)) {
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
self::$_isIconvEnabled = function_exists('iconv') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* That's correct, control characters are stored directly in the shared-strings table.
|
||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from PHP control character to OpenXML escaped control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* That's correct, control characters are stored directly in the shared-strings table.
|
||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF8 data
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsUTF8($value = '') {
|
||||
return utf8_encode(utf8_decode($value)) === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a numeric value as a string for output in various output writers
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function FormatNumber($value) {
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
|
||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* although this will give wrong results for non-ASCII strings
|
||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeShort($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('CC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
|
||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* although this will give wrong results for non-ASCII strings
|
||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeLong($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('vC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
||||
* @return string
|
||||
*/
|
||||
public static function ConvertEncoding($value, $to, $from)
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$value = mb_convert_encoding($value, $to, $from);
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$value = iconv($from, $to, $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get character count. First try mbstring, then iconv, finally strlen
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $enc Encoding
|
||||
* @return int Character count
|
||||
*/
|
||||
public static function CountCharacters($value, $enc = 'UTF-8')
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$count = mb_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$count = iconv_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
|
||||
// else strlen
|
||||
$count = strlen($value);
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
if (!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_XMLWriter
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_XMLWriter {
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
|
||||
/**
|
||||
* Internal XMLWriter
|
||||
*
|
||||
* @var XMLWriter
|
||||
*/
|
||||
private $_xmlWriter;
|
||||
|
||||
/**
|
||||
* Temporary filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tempFileName = '';
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shared_XMLWriter instance
|
||||
*
|
||||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
|
||||
// Create internal XMLWriter
|
||||
$this->_xmlWriter = new XMLWriter();
|
||||
|
||||
// Open temporary storage
|
||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->_xmlWriter->openMemory();
|
||||
} else {
|
||||
// Create temporary filename
|
||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||
|
||||
// Open storage
|
||||
if ($this->_xmlWriter->openUri($this->_tempFileName) === false) {
|
||||
// Fallback to memory...
|
||||
$this->_xmlWriter->openMemory();
|
||||
}
|
||||
}
|
||||
|
||||
// Set default values
|
||||
$this->_xmlWriter->setIndent(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
// Desctruct XMLWriter
|
||||
unset($this->_xmlWriter);
|
||||
|
||||
// Unlink temporary files
|
||||
if ($this->_tempFileName != '') {
|
||||
@unlink($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return $data
|
||||
*/
|
||||
public function getData() {
|
||||
if ($this->_tempFileName == '') {
|
||||
return $this->_xmlWriter->outputMemory(true);
|
||||
} else {
|
||||
$this->_xmlWriter->flush();
|
||||
return file_get_contents($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch function calls (and pass them to internal XMLWriter)
|
||||
*
|
||||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
public function __call($function, $args) {
|
||||
try {
|
||||
@call_user_func_array(array($this->_xmlWriter, $function), $args);
|
||||
} catch (Exception $ex) {
|
||||
// Do nothing!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback method for writeRaw, introduced in PHP 5.2
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function writeRaw($text)
|
||||
{
|
||||
if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) {
|
||||
return $this->_xmlWriter->writeRaw($text);
|
||||
}
|
||||
|
||||
return $this->text($text);
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** Register new zip wrapper */
|
||||
PHPPowerPoint_Shared_ZipStreamWrapper::register();
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_ZipStreamWrapper
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_ZipStreamWrapper {
|
||||
/**
|
||||
* Internal ZipAcrhive
|
||||
*
|
||||
* @var ZipAcrhive
|
||||
*/
|
||||
private $_archive;
|
||||
|
||||
/**
|
||||
* Filename in ZipAcrhive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileNameInArchive = '';
|
||||
|
||||
/**
|
||||
* Position in file
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_data = '';
|
||||
|
||||
/**
|
||||
* Register wrapper
|
||||
*/
|
||||
public static function register() {
|
||||
@stream_wrapper_unregister("zip");
|
||||
@stream_wrapper_register("zip", __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open stream
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
// Check for mode
|
||||
if ($mode{0} != 'r') {
|
||||
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
|
||||
}
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
$url['host'] = substr($path, strlen('zip://'));
|
||||
$url['path'] = '';
|
||||
}
|
||||
if (strpos($url['host'], '#') !== false) {
|
||||
if (!isset($url['fragment'])) {
|
||||
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
|
||||
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
|
||||
unset($url['path']);
|
||||
}
|
||||
} else {
|
||||
$url['host'] = $url['host'] . $url['path'];
|
||||
unset($url['path']);
|
||||
}
|
||||
|
||||
// Open archive
|
||||
$this->_archive = new ZipArchive();
|
||||
$this->_archive->open($url['host']);
|
||||
|
||||
$this->_fileNameInArchive = $url['fragment'];
|
||||
$this->_position = 0;
|
||||
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat stream
|
||||
*/
|
||||
public function stream_stat() {
|
||||
return $this->_archive->statName( $this->_fileNameInArchive );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count) {
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell stream
|
||||
*/
|
||||
public function stream_tell() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* EOF stream
|
||||
*/
|
||||
public function stream_eof() {
|
||||
return $this->_position >= strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek stream
|
||||
*/
|
||||
public function stream_seek($offset, $whence) {
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < strlen($this->_data) && $offset >= 0) {
|
||||
$this->_position = $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
if ($offset >= 0) {
|
||||
$this->_position += $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if (strlen($this->_data) + $offset >= 0) {
|
||||
$this->_position = strlen($this->_data) + $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,261 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide_Layout */
|
||||
require_once 'PHPPowerPoint/Slide/Layout.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText */
|
||||
require_once 'PHPPowerPoint/Shape/RichText.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Font */
|
||||
require_once 'PHPPowerPoint/Shared/Font.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_String */
|
||||
require_once 'PHPPowerPoint/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Slide
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Slide implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Parent presentation
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var PHPPowerPoint_Shape[]
|
||||
*/
|
||||
private $_shapeCollection = null;
|
||||
|
||||
/**
|
||||
* Slide identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_identifier;
|
||||
|
||||
/**
|
||||
* Slide layout
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_slideLayout = PHPPowerPoint_Slide_Layout::BLANK;
|
||||
|
||||
/**
|
||||
* Create a new slide
|
||||
*
|
||||
* @param PHPPowerPoint $pParent
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pParent = null)
|
||||
{
|
||||
// Set parent
|
||||
$this->_parent = $pParent;
|
||||
|
||||
// Shape collection
|
||||
$this->_shapeCollection = new ArrayObject();
|
||||
|
||||
// Set identifier
|
||||
$this->_identifier = md5(rand(0,9999) . time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return PHPPowerPoint_Shape[]
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->_shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param PHPPowerPoint_Shape $shape
|
||||
*/
|
||||
public function addShape(PHPPowerPoint_Shape $shape)
|
||||
{
|
||||
$shape->setSlide($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
{
|
||||
$shape = new PHPPowerPoint_Shape_RichText();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create drawing shape
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_Drawing
|
||||
*/
|
||||
public function createDrawingShape()
|
||||
{
|
||||
$shape = new PHPPowerPoint_Shape_Drawing();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-bind parent
|
||||
*
|
||||
* @param PHPPowerPoint $parent
|
||||
*/
|
||||
public function rebindParent(PHPPowerPoint $parent) {
|
||||
$this->_parent->removeSlideByIndex(
|
||||
$this->_parent->getIndex($this)
|
||||
);
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide layout
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSlideLayout() {
|
||||
return $this->_slideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide layout
|
||||
*
|
||||
* @param string $layout
|
||||
*/
|
||||
public function setSlideLayout($layout = PHPPowerPoint_Slide_Layout::BLANK) {
|
||||
$this->_slideLayout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_identifier
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy slide (!= clone!)
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function copy() {
|
||||
$copied = clone $this;
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
foreach ($this as $key => $val) {
|
||||
if (is_object($val) || (is_array($val))) {
|
||||
$this->{$key} = unserialize(serialize($val));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Slide_Layout
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Slide_Layout
|
||||
{
|
||||
/** Layout constants */
|
||||
const TITLE_SLIDE = 'Title Slide';
|
||||
const TITLE_AND_CONTENT = 'Title and Content';
|
||||
const SECTION_HEADER = 'Section Header';
|
||||
const TWO_CONTENT = 'Two Content';
|
||||
const COMPARISON = 'Comparison';
|
||||
const TITLE_ONLY = 'Title Only';
|
||||
const BLANK = 'Blank';
|
||||
const CONTENT_WITH_CAPTION = 'Content with Caption';
|
||||
const PICTURE_WITH_CAPTION = 'Picture with Caption';
|
||||
const TITLE_AND_VERTICAL_TEXT = 'Title and Vertical Text';
|
||||
const VERTICAL_TITLE_AND_TEXT = 'Vertical Title and Text';
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_SlideIterator
|
||||
*
|
||||
* Used to iterate slides in PHPPowerPoint
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_SlideIterator extends IteratorIterator
|
||||
{
|
||||
/**
|
||||
* Presentation to iterate
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Current iterator position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Create a new slide iterator
|
||||
*
|
||||
* @param PHPPowerPoint $subject
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $subject = null) {
|
||||
// Set subject
|
||||
$this->_subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
unset($this->_subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind iterator
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->_position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current PHPPowerPoint_Slide
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function current() {
|
||||
return $this->_subject->getSlide($this->_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next value
|
||||
*/
|
||||
public function next() {
|
||||
++$this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* More PHPPowerPoint_Slide instances available?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->_position < $this->_subject->getSlideCount();
|
||||
}
|
||||
}
|
@ -1,243 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Alignment
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Alignment implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Horizontal alignment styles */
|
||||
const HORIZONTAL_LEFT = 'l';
|
||||
const HORIZONTAL_RIGHT = 'r';
|
||||
const HORIZONTAL_CENTER = 'ctr';
|
||||
const HORIZONTAL_JUSTIFY = 'just';
|
||||
const HORIZONTAL_DISTRIBUTED = 'dist';
|
||||
|
||||
/* Vertical alignment styles */
|
||||
const VERTICAL_BASE = 'base';
|
||||
const VERTICAL_AUTO = 'auto';
|
||||
const VERTICAL_BOTTOM = 'b';
|
||||
const VERTICAL_TOP = 't';
|
||||
const VERTICAL_CENTER = 'ctr';
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
/**
|
||||
* Level
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_level;
|
||||
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_horizontal = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
|
||||
$this->_vertical = PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
|
||||
$this->_level = 0;
|
||||
$this->_indent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
return $this->_horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setHorizontal($pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEF) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
|
||||
}
|
||||
$this->_horizontal = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical() {
|
||||
return $this->_vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setVertical($pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
|
||||
}
|
||||
$this->_vertical = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLevel() {
|
||||
return $this->_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Level
|
||||
*
|
||||
* @param int $pValue Ranging 0 - 8
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setLevel($pValue = 0) {
|
||||
if ($pValue < 0 || $pValue > 8) {
|
||||
throw new Exception("Invalid value: shoul be range 0 - 8.");
|
||||
}
|
||||
$this->_level = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setIndent($pValue = 0) {
|
||||
if ($pValue > 0) {
|
||||
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
|
||||
$pValue = 0; // indent not supported
|
||||
}
|
||||
}
|
||||
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_horizontal
|
||||
. $this->_vertical
|
||||
. $this->_level
|
||||
. $this->_indent
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Color
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Color implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Colors */
|
||||
const COLOR_BLACK = 'FF000000';
|
||||
const COLOR_WHITE = 'FFFFFFFF';
|
||||
const COLOR_RED = 'FFFF0000';
|
||||
const COLOR_DARKRED = 'FF800000';
|
||||
const COLOR_BLUE = 'FF0000FF';
|
||||
const COLOR_DARKBLUE = 'FF000080';
|
||||
const COLOR_GREEN = 'FF00FF00';
|
||||
const COLOR_DARKGREEN = 'FF008000';
|
||||
const COLOR_YELLOW = 'FFFFFF00';
|
||||
const COLOR_DARKYELLOW = 'FF808000';
|
||||
|
||||
/**
|
||||
* ARGB - Alpha RGB
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_argb;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Color
|
||||
*
|
||||
* @param string $pARGB
|
||||
*/
|
||||
public function __construct($pARGB = PHPPowerPoint_Style_Color::COLOR_BLACK)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_argb = $pARGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ARGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getARGB() {
|
||||
return $this->_argb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ARGB
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setARGB($pValue = PHPPowerPoint_Style_Color::COLOR_BLACK) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Color::COLOR_BLACK;
|
||||
}
|
||||
$this->_argb = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRGB() {
|
||||
return substr($this->_argb, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RGB
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setRGB($pValue = '000000') {
|
||||
if ($pValue == '') {
|
||||
$pValue = '000000';
|
||||
}
|
||||
$this->_argb = 'FF' . $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_argb
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Fill
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Fill implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Fill types */
|
||||
const FILL_NONE = 'none';
|
||||
const FILL_SOLID = 'solid';
|
||||
const FILL_GRADIENT_LINEAR = 'linear';
|
||||
const FILL_GRADIENT_PATH = 'path';
|
||||
const FILL_PATTERN_DARKDOWN = 'darkDown';
|
||||
const FILL_PATTERN_DARKGRAY = 'darkGray';
|
||||
const FILL_PATTERN_DARKGRID = 'darkGrid';
|
||||
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal';
|
||||
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis';
|
||||
const FILL_PATTERN_DARKUP = 'darkUp';
|
||||
const FILL_PATTERN_DARKVERTICAL = 'darkVertical';
|
||||
const FILL_PATTERN_GRAY0625 = 'gray0625';
|
||||
const FILL_PATTERN_GRAY125 = 'gray125';
|
||||
const FILL_PATTERN_LIGHTDOWN = 'lightDown';
|
||||
const FILL_PATTERN_LIGHTGRAY = 'lightGray';
|
||||
const FILL_PATTERN_LIGHTGRID = 'lightGrid';
|
||||
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal';
|
||||
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis';
|
||||
const FILL_PATTERN_LIGHTUP = 'lightUp';
|
||||
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical';
|
||||
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
|
||||
|
||||
/**
|
||||
* Fill type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fillType;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var double
|
||||
*/
|
||||
private $_rotation;
|
||||
|
||||
/**
|
||||
* Start color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_startColor;
|
||||
|
||||
/**
|
||||
* End color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_endColor;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_fillType = PHPPowerPoint_Style_Fill::FILL_NONE;
|
||||
$this->_rotation = 0;
|
||||
$this->_startColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_WHITE);
|
||||
$this->_endColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillType() {
|
||||
$this->_fillType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Type
|
||||
*
|
||||
* @param string $pValue PHPPowerPoint_Style_Fill fill type
|
||||
*/
|
||||
public function setFillType($pValue = PHPPowerPoint_Style_Fill::FILL_NONE) {
|
||||
$this->_fillType = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getRotation() {
|
||||
return $this->_rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param double $pValue
|
||||
*/
|
||||
public function setRotation($pValue = 0) {
|
||||
$this->_rotation = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Start Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getStartColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->_startColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Start Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setStartColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_startColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get End Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getEndColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->_endColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set End Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setEndColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_endColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getFillType()
|
||||
. $this->getRotation()
|
||||
. $this->getStartColor()->getHashCode()
|
||||
. $this->getEndColor()->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,411 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Font
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Font implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Underline types */
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||
const UNDERLINE_DASHLONG = 'dashLong';
|
||||
const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
|
||||
const UNDERLINE_DOUBLE = 'dbl';
|
||||
const UNDERLINE_DOTHASH = 'dotDash';
|
||||
const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy';
|
||||
const UNDERLINE_DOTDOTDASH = 'dotDotDash';
|
||||
const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
|
||||
const UNDERLINE_DOTTED = 'dotted';
|
||||
const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
|
||||
const UNDERLINE_HEAVY = 'heavy';
|
||||
const UNDERLINE_SINGLE = 'sng';
|
||||
const UNDERLINE_WAVY = 'wavy';
|
||||
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
|
||||
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
|
||||
const UNDERLINE_WORDS = 'words';
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* Bold
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_bold;
|
||||
|
||||
/**
|
||||
* Italic
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_italic;
|
||||
|
||||
/**
|
||||
* Superscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_superScript;
|
||||
|
||||
/**
|
||||
* Subscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_subScript;
|
||||
|
||||
/**
|
||||
* Underline
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_underline;
|
||||
|
||||
/**
|
||||
* Strikethrough
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_strikethrough;
|
||||
|
||||
/**
|
||||
* Foreground color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_name = 'Calibri';
|
||||
$this->_size = 10;
|
||||
$this->_bold = false;
|
||||
$this->_italic = false;
|
||||
$this->_superScript = false;
|
||||
$this->_subScript = false;
|
||||
$this->_underline = PHPPowerPoint_Style_Font::UNDERLINE_NONE;
|
||||
$this->_strikethrough = false;
|
||||
$this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setName($pValue = 'Calibri') {
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Calibri';
|
||||
}
|
||||
$this->_name = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Size
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getSize() {
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Size
|
||||
*
|
||||
* @param double $pValue
|
||||
*/
|
||||
public function setSize($pValue = 10) {
|
||||
if ($pValue == '') {
|
||||
$pValue = 10;
|
||||
}
|
||||
$this->_size = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bold
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBold() {
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bold
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setBold($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_bold = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Italic
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getItalic() {
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Italic
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setItalic($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_italic = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SuperScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSuperScript() {
|
||||
return $this->_superScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SuperScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setSuperScript($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_superScript = $pValue;
|
||||
$this->_subScript = !$pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SubScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSubScript() {
|
||||
return $this->_subScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SubScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setSubScript($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_subScript = $pValue;
|
||||
$this->_superScript = !$pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Underline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUnderline() {
|
||||
return $this->_underline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Underline
|
||||
*
|
||||
* @param string $pValue PHPPowerPoint_Style_Font underline type
|
||||
*/
|
||||
public function setUnderline($pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE;
|
||||
}
|
||||
$this->_underline = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Striketrough
|
||||
*
|
||||
* @deprecated Use getStrikethrough() instead.
|
||||
* @return boolean
|
||||
*/
|
||||
public function getStriketrough() {
|
||||
return $this->getStrikethrough();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Striketrough
|
||||
*
|
||||
* @deprecated Use setStrikethrough() instead.
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setStriketrough($pValue = false) {
|
||||
$this->setStrikethrough($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Strikethrough
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getStrikethrough() {
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Strikethrough
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setStrikethrough($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_strikethrough = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_color = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_name
|
||||
. $this->_size
|
||||
. ($this->_bold ? 't' : 'f')
|
||||
. ($this->_italic ? 't' : 'f')
|
||||
. ($this->_superScript ? 't' : 'f')
|
||||
. ($this->_subScript ? 't' : 'f')
|
||||
. $this->_underline
|
||||
. ($this->_strikethrough ? 't' : 'f')
|
||||
. $this->_color->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,331 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Border
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Border implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Border style */
|
||||
const BORDER_NONE = 'none';
|
||||
const BORDER_DASHDOT = 'dashDot';
|
||||
const BORDER_DASHDOTDOT = 'dashDotDot';
|
||||
const BORDER_DASHED = 'dashed';
|
||||
const BORDER_DOTTED = 'dotted';
|
||||
const BORDER_DOUBLE = 'double';
|
||||
const BORDER_HAIR = 'hair';
|
||||
const BORDER_MEDIUM = 'medium';
|
||||
const BORDER_MEDIUMDASHDOT = 'mediumDashDot';
|
||||
const BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot';
|
||||
const BORDER_MEDIUMDASHED = 'mediumDashed';
|
||||
const BORDER_SLANTDASHDOT = 'slantDashDot';
|
||||
const BORDER_THICK = 'thick';
|
||||
const BORDER_THIN = 'thin';
|
||||
|
||||
/**
|
||||
* Border style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderStyle;
|
||||
|
||||
/**
|
||||
* Border color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_borderColor;
|
||||
|
||||
/**
|
||||
* Parent
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Parent Property Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_parentPropertyName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_borderStyle = PHPPowerPoint_Style_Border::BORDER_NONE;
|
||||
$this->_borderColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Prepare bind
|
||||
*
|
||||
* Configures this object for late binding as a property of a parent object
|
||||
*
|
||||
* @param $parent
|
||||
* @param $parentPropertyName
|
||||
*/
|
||||
public function propertyPrepareBind($parent, $parentPropertyName)
|
||||
{
|
||||
// Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object
|
||||
// is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references.
|
||||
$this->_parent = $parent;
|
||||
$this->_parentPropertyName = $parentPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Get Bound
|
||||
*
|
||||
* Returns the PHPPowerPoint_Style_Border that is actual bound to PHPPowerPoint_Style_Borders
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private function propertyGetBound() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
{
|
||||
switch($this->_parentPropertyName) // Another one is bound
|
||||
{
|
||||
case "_left":
|
||||
return $this->_parent->getLeft();
|
||||
|
||||
case "_right":
|
||||
return $this->_parent->getRight();
|
||||
|
||||
case "_top":
|
||||
return $this->_parent->getTop();
|
||||
|
||||
case "_bottom":
|
||||
return $this->_parent->getBottom();
|
||||
|
||||
case "_diagonal":
|
||||
return $this->_parent->getDiagonal();
|
||||
|
||||
case "_vertical":
|
||||
return $this->_parent->getVertical();
|
||||
|
||||
case "_horizontal":
|
||||
return $this->_parent->getHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
return $this; // No one is bound yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Begin Bind
|
||||
*
|
||||
* If no PHPPowerPoint_Style_Border has been bound to PHPPowerPoint_Style_Borders then bind this one. Return the actual bound one.
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private function propertyBeginBind() {
|
||||
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am already bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
{
|
||||
switch($this->_parentPropertyName) // Another one is already bound
|
||||
{
|
||||
case "_left":
|
||||
return $this->_parent->getLeft();
|
||||
|
||||
case "_right":
|
||||
return $this->_parent->getRight();
|
||||
|
||||
case "_top":
|
||||
return $this->_parent->getTop();
|
||||
|
||||
case "_bottom":
|
||||
return $this->_parent->getBottom();
|
||||
|
||||
case "_diagonal":
|
||||
return $this->_parent->getDiagonal();
|
||||
|
||||
case "_vertical":
|
||||
return $this->_parent->getVertical();
|
||||
|
||||
case "_horizontal":
|
||||
return $this->_parent->getHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
|
||||
$this->_parent = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
|
||||
* array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if (array_key_exists('style', $pStyles)) {
|
||||
$this->setBorderStyle($pStyles['style']);
|
||||
}
|
||||
if (array_key_exists('color', $pStyles)) {
|
||||
$this->getColor()->applyFromArray($pStyles['color']);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderStyle() {
|
||||
return $this->propertyGetBound()->_borderStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border style
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderStyle($pValue = PHPPowerPoint_Style_Border::BORDER_NONE) {
|
||||
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Border::BORDER_NONE;
|
||||
}
|
||||
$this->propertyBeginBind()->_borderStyle = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->propertyBeginBind()->_borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->propertyBeginBind()->_borderColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$property = $this->propertyGetBound();
|
||||
return md5(
|
||||
$property->_borderStyle
|
||||
. $property->_borderColor->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,577 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Border */
|
||||
require_once 'PHPPowerPoint/Style/Border.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Borders
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Borders implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Diagonal directions */
|
||||
const DIAGONAL_NONE = 0;
|
||||
const DIAGONAL_UP = 1;
|
||||
const DIAGONAL_DOWN = 2;
|
||||
|
||||
/**
|
||||
* Left
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_left;
|
||||
|
||||
/**
|
||||
* Right
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_right;
|
||||
|
||||
/**
|
||||
* Top
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_top;
|
||||
|
||||
/**
|
||||
* Bottom
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_bottom;
|
||||
|
||||
/**
|
||||
* Diagonal
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_diagonal;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
/**
|
||||
* DiagonalDirection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_diagonalDirection;
|
||||
|
||||
/**
|
||||
* Outline, defaults to true
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_outline;
|
||||
|
||||
/**
|
||||
* Parent
|
||||
*
|
||||
* @var PHPPowerPoint_Style
|
||||
*/
|
||||
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
* @var _parentPropertyName string
|
||||
*/
|
||||
private $_parentPropertyName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
|
||||
/**
|
||||
* The following properties are late bound. Binding is initiated by property classes when they are modified.
|
||||
*
|
||||
* _left
|
||||
* _right
|
||||
* _top
|
||||
* _bottom
|
||||
* _diagonal
|
||||
* _vertical
|
||||
* _horizontal
|
||||
*
|
||||
*/
|
||||
|
||||
$this->_diagonalDirection = PHPPowerPoint_Style_Borders::DIAGONAL_NONE;
|
||||
$this->_outline = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Prepare bind
|
||||
*
|
||||
* Configures this object for late binding as a property of a parent object
|
||||
*
|
||||
* @param $parent
|
||||
* @param $parentPropertyName
|
||||
*/
|
||||
public function propertyPrepareBind($parent, $parentPropertyName)
|
||||
{
|
||||
// Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object
|
||||
// is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references.
|
||||
$this->_parent = $parent;
|
||||
$this->_parentPropertyName = $parentPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Get Bound
|
||||
*
|
||||
* Returns the PHPPowerPoint_Style_Borders that is actual bound to PHPPowerPoint_Style
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private function propertyGetBound() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
return $this->_parent->getBorders(); // Another one is bound
|
||||
|
||||
return $this; // No one is bound yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Begin Bind
|
||||
*
|
||||
* If no PHPPowerPoint_Style_Borders has been bound to PHPPowerPoint_Style then bind this one. Return the actual bound one.
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private function propertyBeginBind() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am already bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
return $this->_parent->getBorders(); // Another one is already bound
|
||||
|
||||
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
|
||||
$this->_parent = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property Complete Bind
|
||||
*
|
||||
* Complete the binding process a child property object started
|
||||
*
|
||||
* @param $propertyObject
|
||||
* @param $propertyName Name of this property in the parent object
|
||||
*/
|
||||
public function propertyCompleteBind($propertyObject, $propertyName) {
|
||||
switch($propertyName) {
|
||||
case "_left":
|
||||
$this->propertyBeginBind()->_left = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_right":
|
||||
$this->propertyBeginBind()->_right = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_top":
|
||||
$this->propertyBeginBind()->_top = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_bottom":
|
||||
$this->propertyBeginBind()->_bottom = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_diagonal":
|
||||
$this->propertyBeginBind()->_diagonal = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_vertical":
|
||||
$this->propertyBeginBind()->_vertical = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_horizontal":
|
||||
$this->propertyBeginBind()->_horizontal = $propertyObject;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Invalid property passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Is Bound
|
||||
*
|
||||
* Determines if a child property is bound to this one
|
||||
*
|
||||
* @param $propertyName Name of this property in the parent object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function propertyIsBound($propertyName) {
|
||||
switch($propertyName) {
|
||||
case "_left":
|
||||
return isset($this->propertyGetBound()->_left);
|
||||
|
||||
case "_right":
|
||||
return isset($this->propertyGetBound()->_right);
|
||||
|
||||
case "_top":
|
||||
return isset($this->propertyGetBound()->_top);
|
||||
|
||||
case "_bottom":
|
||||
return isset($this->propertyGetBound()->_bottom);
|
||||
|
||||
case "_diagonal":
|
||||
return isset($this->propertyGetBound()->_diagonal);
|
||||
|
||||
case "_vertical":
|
||||
return isset($this->propertyGetBound()->_vertical);
|
||||
|
||||
case "_horizontal":
|
||||
return isset($this->propertyGetBound()->_horizontal);
|
||||
|
||||
default:
|
||||
throw new Exception("Invalid property passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
|
||||
* array(
|
||||
* 'bottom' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* ),
|
||||
* 'top' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
|
||||
* array(
|
||||
* 'allborders' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if (array_key_exists('allborders', $pStyles)) {
|
||||
$this->getLeft()->applyFromArray($pStyles['allborders']);
|
||||
$this->getRight()->applyFromArray($pStyles['allborders']);
|
||||
$this->getTop()->applyFromArray($pStyles['allborders']);
|
||||
$this->getBottom()->applyFromArray($pStyles['allborders']);
|
||||
}
|
||||
if (array_key_exists('left', $pStyles)) {
|
||||
$this->getLeft()->applyFromArray($pStyles['left']);
|
||||
}
|
||||
if (array_key_exists('right', $pStyles)) {
|
||||
$this->getRight()->applyFromArray($pStyles['right']);
|
||||
}
|
||||
if (array_key_exists('top', $pStyles)) {
|
||||
$this->getTop()->applyFromArray($pStyles['top']);
|
||||
}
|
||||
if (array_key_exists('bottom', $pStyles)) {
|
||||
$this->getBottom()->applyFromArray($pStyles['bottom']);
|
||||
}
|
||||
if (array_key_exists('diagonal', $pStyles)) {
|
||||
$this->getDiagonal()->applyFromArray($pStyles['diagonal']);
|
||||
}
|
||||
if (array_key_exists('vertical', $pStyles)) {
|
||||
$this->getVertical()->applyFromArray($pStyles['vertical']);
|
||||
}
|
||||
if (array_key_exists('horizontal', $pStyles)) {
|
||||
$this->getHorizontal()->applyFromArray($pStyles['horizontal']);
|
||||
}
|
||||
if (array_key_exists('diagonaldirection', $pStyles)) {
|
||||
$this->setDiagonalDirection($pStyles['diagonaldirection']);
|
||||
}
|
||||
if (array_key_exists('outline', $pStyles)) {
|
||||
$this->setOutline($pStyles['outline']);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Left
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getLeft() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_left))
|
||||
return $property->_left;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_left");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Right
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getRight() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_right))
|
||||
return $property->_right;
|
||||
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_right");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getTop() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_top))
|
||||
return $property->_top;
|
||||
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_top");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getBottom() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_bottom))
|
||||
return $property->_bottom;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_bottom");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Diagonal
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getDiagonal() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_diagonal))
|
||||
return $property->_diagonal;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_diagonal");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getVertical() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_vertical))
|
||||
return $property->_vertical;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_vertical");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_horizontal))
|
||||
return $property->_horizontal;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_horizontal");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DiagonalDirection
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiagonalDirection() {
|
||||
return $this->propertyGetBound()->_diagonalDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set DiagonalDirection
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDiagonalDirection($pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE;
|
||||
}
|
||||
$this->propertyBeginBind()->_diagonalDirection = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Outline
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOutline() {
|
||||
return $this->propertyGetBound()->_outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Outline
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setOutline($pValue = true) {
|
||||
if ($pValue == '') {
|
||||
$pValue = true;
|
||||
}
|
||||
$this->propertyBeginBind()->_outline = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$property = $this->propertyGetBound();
|
||||
return md5(
|
||||
$property->getLeft()->getHashCode()
|
||||
. $property->getRight()->getHashCode()
|
||||
. $property->getTop()->getHashCode()
|
||||
. $property->getBottom()->getHashCode()
|
||||
. $property->getDiagonal()->getHashCode()
|
||||
. $property->getVertical()->getHashCode()
|
||||
. $property->getHorizontal()->getHashCode()
|
||||
. $property->getDiagonalDirection()
|
||||
. ($property->getOutline() ? 't' : 'f')
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_IWriter
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null);
|
||||
}
|
@ -1,411 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_HashTable */
|
||||
require_once 'PHPPowerPoint/HashTable.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_ContentTypes */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_DocProps */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/DocProps.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Rels */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Rels.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Theme */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Theme.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Presentation */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Presentation.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Slide */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Drawing */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_LayoutPack */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_LayoutPack_Default */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007 implements PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Office2003 compatibility
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_office2003compatibility = false;
|
||||
|
||||
/**
|
||||
* Private writer parts
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_PowerPoint2007_WriterPart[]
|
||||
*/
|
||||
private $_writerParts;
|
||||
|
||||
/**
|
||||
* Private PHPPowerPoint
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_presentation;
|
||||
|
||||
/**
|
||||
* Private unique PHPPowerPoint_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPPowerPoint_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Layout pack to use
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*/
|
||||
private $_layoutPack;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Writer_PowerPoint2007
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Assign PHPPowerPoint
|
||||
$this->setPHPPowerPoint($pPHPPowerPoint);
|
||||
|
||||
// Set up disk caching location
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
// Set layout pack
|
||||
$this->_layoutPack = new PHPPowerPoint_Writer_PowerPoint2007_LayoutPack_Default();
|
||||
|
||||
// Initialise writer parts
|
||||
$this->_writerParts['contenttypes'] = new PHPPowerPoint_Writer_PowerPoint2007_ContentTypes();
|
||||
$this->_writerParts['docprops'] = new PHPPowerPoint_Writer_PowerPoint2007_DocProps();
|
||||
$this->_writerParts['rels'] = new PHPPowerPoint_Writer_PowerPoint2007_Rels();
|
||||
$this->_writerParts['theme'] = new PHPPowerPoint_Writer_PowerPoint2007_Theme();
|
||||
$this->_writerParts['presentation'] = new PHPPowerPoint_Writer_PowerPoint2007_Presentation();
|
||||
$this->_writerParts['slide'] = new PHPPowerPoint_Writer_PowerPoint2007_Slide();
|
||||
$this->_writerParts['drawing'] = new PHPPowerPoint_Writer_PowerPoint2007_Drawing();
|
||||
|
||||
// Assign parent IWriter
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPPowerPoint_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '') {
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_presentation)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create drawing dictionary
|
||||
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_presentation) );
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add [Content_Types].xml to ZIP file
|
||||
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_presentation));
|
||||
|
||||
// Add relationships to ZIP file
|
||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_presentation));
|
||||
$objZip->addFromString('ppt/_rels/presentation.xml.rels', $this->getWriterPart('Rels')->writePresentationRelationships($this->_presentation));
|
||||
|
||||
// Add document properties to ZIP file
|
||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_presentation));
|
||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_presentation));
|
||||
|
||||
// Add theme to ZIP file
|
||||
$objZip->addFromString('ppt/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_presentation));
|
||||
|
||||
// Add slide master to ZIP file
|
||||
$masterSlide = $this->getLayoutPack()->getMasterSlide();
|
||||
$objZip->addFromString('ppt/slideMasters/_rels/slideMaster1.xml.rels', $this->getWriterPart('Rels')->writeSlideMasterRelationships());
|
||||
$objZip->addFromString('ppt/slideMasters/slideMaster1.xml', $masterSlide['body']);
|
||||
|
||||
// Add slide layouts to ZIP file
|
||||
$slideLayouts = $this->getLayoutPack()->getLayouts();
|
||||
for ($i = 0; $i < count($slideLayouts); ++$i) {
|
||||
$objZip->addFromString('ppt/slideLayouts/_rels/slideLayout' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideLayoutRelationships());
|
||||
$objZip->addFromString('ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', $slideLayouts[$i]['body']);
|
||||
}
|
||||
|
||||
// Add presentation to ZIP file
|
||||
$objZip->addFromString('ppt/presentation.xml', $this->getWriterPart('Presentation')->writePresentation($this->_presentation));
|
||||
|
||||
// Add slides (drawings, ...)
|
||||
for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) {
|
||||
// Add slide
|
||||
$objZip->addFromString('ppt/slides/slide' . ($i + 1) . '.xml', $this->getWriterPart('Slide')->writeSlide($this->_presentation->getSlide($i)));
|
||||
}
|
||||
|
||||
// Add slide relationships (drawings, ...)
|
||||
for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) {
|
||||
// Add relationships
|
||||
$objZip->addFromString('ppt/slides/_rels/slide' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideRelationships($this->_presentation->getSlide($i), ($i + 1)));
|
||||
}
|
||||
|
||||
// Add media
|
||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) {
|
||||
$imageContents = null;
|
||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||
|
||||
if (strpos($imagePath, 'zip://') !== false) {
|
||||
$imagePath = substr($imagePath, 6);
|
||||
$imagePathSplitted = explode('#', $imagePath);
|
||||
|
||||
$imageZip = new ZipArchive();
|
||||
$imageZip->open($imagePathSplitted[0]);
|
||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
} else {
|
||||
$imageContents = file_get_contents($imagePath);
|
||||
}
|
||||
|
||||
$objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
if ($originalFilename != $pFilename) {
|
||||
if (copy($pFilename, $originalFilename) === false) {
|
||||
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||
}
|
||||
@unlink($pFilename);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("PHPPowerPoint object unassigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPPowerPoint() {
|
||||
if (!is_null($this->_presentation)) {
|
||||
return $this->_presentation;
|
||||
} else {
|
||||
throw new Exception("No PHPPowerPoint assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) {
|
||||
$this->_presentation = $pPHPPowerPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPPowerPoint_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Office2003 compatibility
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOffice2003Compatibility() {
|
||||
return $this->_office2003compatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pre-Calculate Formulas
|
||||
*
|
||||
* @param boolean $pValue Office2003 compatibility?
|
||||
*/
|
||||
public function setOffice2003Compatibility($pValue = false) {
|
||||
$this->_office2003compatibility = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching() {
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($pDirectory)) {
|
||||
if (is_dir($pDirectory)) {
|
||||
$this->_diskCachingDirectory = $pDirectory;
|
||||
} else {
|
||||
throw new Exception("Directory does not exist: $pDirectory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory() {
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout pack to use
|
||||
*
|
||||
* @return PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*/
|
||||
public function getLayoutPack() {
|
||||
return $this->_layoutPack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layout pack to use
|
||||
*
|
||||
* @param PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue
|
||||
*/
|
||||
public function setLayoutPack(PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue = null) {
|
||||
$this->_layoutPack = $pValue;
|
||||
}
|
||||
}
|
@ -1,219 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_File */
|
||||
require_once 'PHPPowerPoint/Shared/File.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_ContentTypes
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_ContentTypes extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write content types to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeContentTypes(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Types
|
||||
$objWriter->startElement('Types');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
);
|
||||
|
||||
// Theme
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// Presentation
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/presentation.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml'
|
||||
);
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
// Slide master
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slideMasters/slideMaster1.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml'
|
||||
);
|
||||
|
||||
// Slide layouts
|
||||
$slideLayouts = $this->getParentWriter()->getLayoutPack()->getLayouts();
|
||||
for ($i = 0; $i < count($slideLayouts); ++$i) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slides/slide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Add media content-types
|
||||
$aMediaContentTypes = array();
|
||||
$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
|
||||
for ($i = 0; $i < $mediaCount; ++$i) {
|
||||
$extension = '';
|
||||
$mimeType = '';
|
||||
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||
}
|
||||
|
||||
if (!isset( $aMediaContentTypes[$extension]) ) {
|
||||
$aMediaContentTypes[$extension] = $mimeType;
|
||||
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, $extension, $mimeType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPPowerPoint_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_DocProps
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_DocProps extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write docProps/app.xml to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeDocPropsApp(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
|
||||
// Application
|
||||
$objWriter->writeElement('Application', 'Microsoft Office PowerPoint');
|
||||
|
||||
// Slides
|
||||
$objWriter->writeElement('Slides', $pPHPPowerPoint->getSlideCount());
|
||||
|
||||
// ScaleCrop
|
||||
$objWriter->writeElement('ScaleCrop', 'false');
|
||||
|
||||
// HeadingPairs
|
||||
$objWriter->startElement('HeadingPairs');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '4');
|
||||
$objWriter->writeAttribute('baseType', 'variant');
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Theme');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Slide Titles');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// TitlesOfParts
|
||||
$objWriter->startElement('TitlesOfParts');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '1');
|
||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||
|
||||
$objWriter->writeElement('vt:lpstr', 'Office Theme');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Company
|
||||
$objWriter->writeElement('Company', 'Microsoft Corporation');
|
||||
|
||||
// LinksUpToDate
|
||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||
|
||||
// SharedDoc
|
||||
$objWriter->writeElement('SharedDoc', 'false');
|
||||
|
||||
// HyperlinksChanged
|
||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||
|
||||
// AppVersion
|
||||
$objWriter->writeElement('AppVersion', '12.0000');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write docProps/core.xml to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeDocPropsCore(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPPowerPoint->getProperties()->getCreator());
|
||||
|
||||
// cp:lastModifiedBy
|
||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPPowerPoint->getProperties()->getLastModifiedBy());
|
||||
|
||||
// dcterms:created
|
||||
$objWriter->startElement('dcterms:created');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getCreated()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dcterms:modified
|
||||
$objWriter->startElement('dcterms:modified');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getModified()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPPowerPoint->getProperties()->getTitle());
|
||||
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPPowerPoint->getProperties()->getDescription());
|
||||
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPPowerPoint->getProperties()->getSubject());
|
||||
|
||||
// cp:keywords
|
||||
$objWriter->writeElement('cp:keywords', $pPHPPowerPoint->getProperties()->getKeywords());
|
||||
|
||||
// cp:category
|
||||
$objWriter->writeElement('cp:category', $pPHPPowerPoint->getProperties()->getCategory());
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Drawing */
|
||||
require_once 'PHPPowerPoint/Shared/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Drawing extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Get an array of all drawings
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return PHPPowerPoint_Slide_Drawing[] All drawings in PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function allDrawings(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Get an array of all drawings
|
||||
$aDrawings = array();
|
||||
|
||||
// Loop trough PHPPowerPoint
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
// Loop trough images and add to array
|
||||
$iterator = $pPHPPowerPoint->getSlide($i)->getShapeCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current() instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$aDrawings[] = $iterator->current();
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
return $aDrawings;
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
{
|
||||
/**
|
||||
* Master slide.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_masterSlide = array();
|
||||
|
||||
/**
|
||||
* Array of slide layouts.
|
||||
*
|
||||
* These are all an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_layouts = array();
|
||||
|
||||
/**
|
||||
* Get master slide.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMasterSlide()
|
||||
{
|
||||
return $this->_masterSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of slide layouts.
|
||||
*
|
||||
* These are all an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLayouts()
|
||||
{
|
||||
return $this->_layouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find specific slide layout.
|
||||
*
|
||||
* This is an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function findLayout($name = '')
|
||||
{
|
||||
foreach ($this->_layouts as $layout)
|
||||
{
|
||||
if ($layout['name'] == $name)
|
||||
{
|
||||
return $layout;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not find slide layout $name in current layout pack.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find specific slide layout index.
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function findLayoutIndex($name = '')
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($this->_layouts as $layout)
|
||||
{
|
||||
if ($layout['name'] == $name)
|
||||
{
|
||||
return $i;
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
throw new Exception("Could not find slide layout $name in current layout pack.");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,151 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Workbook
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Presentation extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write presentation to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writePresentation(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// p:presentation
|
||||
$objWriter->startElement('p:presentation');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
|
||||
|
||||
// p:sldMasterIdLst
|
||||
$objWriter->startElement('p:sldMasterIdLst');
|
||||
|
||||
// p:sldMasterId
|
||||
$objWriter->startElement('p:sldMasterId');
|
||||
$objWriter->writeAttribute('id', '2147483648');
|
||||
$objWriter->writeAttribute('r:id', 'rId1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:sldIdLst
|
||||
$objWriter->startElement('p:sldIdLst');
|
||||
$this->_writeSlides($objWriter, $pPHPPowerPoint);
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:sldSz
|
||||
$objWriter->startElement('p:sldSz');
|
||||
$objWriter->writeAttribute('cx', '9144000');
|
||||
$objWriter->writeAttribute('cy', '6858000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:notesSz
|
||||
$objWriter->startElement('p:notesSz');
|
||||
$objWriter->writeAttribute('cx', '6858000');
|
||||
$objWriter->writeAttribute('cy', '9144000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slides
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSlides(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Write slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
// p:sldId
|
||||
$this->_writeSlide(
|
||||
$objWriter,
|
||||
($i + 256),
|
||||
($i + 1 + 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pSlideId Slide id
|
||||
* @param int $pRelId Relationship ID
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSlide(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pSlideId = 1, $pRelId = 1)
|
||||
{
|
||||
// p:sldId
|
||||
$objWriter->startElement('p:sldId');
|
||||
$objWriter->writeAttribute('id', $pSlideId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
@ -1,347 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Rels
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Rels extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write relationships to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeRelationships(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
'docProps/app.xml'
|
||||
);
|
||||
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
'docProps/core.xml'
|
||||
);
|
||||
|
||||
// Relationship ppt/presentation.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
'ppt/presentation.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write presentation relationships to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writePresentationRelationships(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship slideMasters/slideMaster1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
|
||||
'slideMasters/slideMaster1.xml'
|
||||
);
|
||||
|
||||
// Relationship theme/theme1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationships with slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
($i + 1 + 2),
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide',
|
||||
'slides/slide' . ($i + 1) . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide master relationships to XML format
|
||||
*
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideMasterRelationships()
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Write slideLayout relationships
|
||||
$layoutPack = $this->getParentWriter()->getLayoutPack();
|
||||
for ($i = 0; $i < count($layoutPack->getLayouts()); ++$i) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$i + 1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout',
|
||||
'../slideLayouts/slideLayout' . ($i + 1) . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Relationship theme/theme1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
count($layoutPack->getLayouts()) + 1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'../theme/theme1.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide layout relationships to XML format
|
||||
*
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideLayoutRelationships()
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Write slideMaster relationship
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
|
||||
'../slideMasters/slideMaster1.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide relationships to XML format
|
||||
*
|
||||
* Numbering is as follows:
|
||||
* rId1 - Drawings
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pSlide
|
||||
* @param int $pSlideId
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null, $pSlideId = 1)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Starting relation id
|
||||
$relId = 1;
|
||||
|
||||
// Write slideLayout relationship
|
||||
$layoutPack = $this->getParentWriter()->getLayoutPack();
|
||||
$layoutIndex = $layoutPack->findlayoutIndex( $pSlide->getSlideLayout() );
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relId++,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout',
|
||||
'../slideLayouts/slideLayout' . ($layoutIndex + 1) . '.xml'
|
||||
);
|
||||
|
||||
// Write drawing relationships?
|
||||
if ($pSlide->getShapeCollection()->count() > 0) {
|
||||
// Loop trough images and write relationships
|
||||
$iterator = $pSlide->getShapeCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current() instanceof PHPPowerPoint_Shape_Drawing
|
||||
|| $iterator->current() instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
// Write relationship for image drawing
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
|
||||
);
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
++$relId;
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pId Relationship ID. rId will be prepended!
|
||||
* @param string $pType Relationship type
|
||||
* @param string $pTarget Relationship target
|
||||
* @param string $pTargetMode Relationship target mode
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeRelationship(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', 'rId' . $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,520 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText */
|
||||
require_once 'PHPPowerPoint/Shape/RichText.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Font */
|
||||
require_once 'PHPPowerPoint/Shared/Font.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_String */
|
||||
require_once 'PHPPowerPoint/Shared/String.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Slide
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Slide extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write slide to XML format
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pSlide
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlide(PHPPowerPoint_Slide $pSlide = null)
|
||||
{
|
||||
// Check slide
|
||||
if (is_null($pSlide))
|
||||
throw new Exception("Invalid PHPPowerPoint_Slide object passed.");
|
||||
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// p:sld
|
||||
$objWriter->startElement('p:sld');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
|
||||
|
||||
// p:cSld
|
||||
$objWriter->startElement('p:cSld');
|
||||
|
||||
// p:spTree
|
||||
$objWriter->startElement('p:spTree');
|
||||
|
||||
// p:nvGrpSpPr
|
||||
$objWriter->startElement('p:nvGrpSpPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', '1');
|
||||
$objWriter->writeAttribute('name', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvGrpSpPr
|
||||
$objWriter->writeElement('p:cNvGrpSpPr', null);
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:grpSpPr
|
||||
$objWriter->startElement('p:grpSpPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', '0');
|
||||
$objWriter->writeAttribute('y', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', '0');
|
||||
$objWriter->writeAttribute('cy', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:chOff
|
||||
$objWriter->startElement('a:chOff');
|
||||
$objWriter->writeAttribute('x', '0');
|
||||
$objWriter->writeAttribute('y', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:chExt
|
||||
$objWriter->startElement('a:chExt');
|
||||
$objWriter->writeAttribute('cx', '0');
|
||||
$objWriter->writeAttribute('cy', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop shapes
|
||||
$shapeId = 0;
|
||||
$relationId = 1;
|
||||
$shapes = $pSlide->getShapeCollection();
|
||||
foreach ($shapes as $shape)
|
||||
{
|
||||
// Increment $shapeId
|
||||
++$shapeId;
|
||||
|
||||
// Check type
|
||||
if ($shape instanceof PHPPowerPoint_Shape_BaseDrawing)
|
||||
{
|
||||
// Picture --> $relationId
|
||||
++$relationId;
|
||||
|
||||
$this->_writePic($objWriter, $shape, $shapeId, $relationId);
|
||||
}
|
||||
else if ($shape instanceof PHPPowerPoint_Shape_RichText)
|
||||
{
|
||||
$this->_writeTxt($objWriter, $shape, $shapeId);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:clrMapOvr
|
||||
$objWriter->startElement('p:clrMapOvr');
|
||||
|
||||
// a:masterClrMapping
|
||||
$objWriter->writeElement('a:masterClrMapping', '');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write pic
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint_Shape_BaseDrawing $shape
|
||||
* @param int $shapeId
|
||||
* @param int $relationId
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writePic(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_BaseDrawing $shape = null, $shapeId, $relationId)
|
||||
{
|
||||
// p:pic
|
||||
$objWriter->startElement('p:pic');
|
||||
|
||||
// p:nvPicPr
|
||||
$objWriter->startElement('p:nvPicPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('name', $shape->getName());
|
||||
$objWriter->writeAttribute('descr', $shape->getDescription());
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvPicPr
|
||||
$objWriter->startElement('p:cNvPicPr');
|
||||
|
||||
// a:picLocks
|
||||
$objWriter->startElement('a:picLocks');
|
||||
$objWriter->writeAttribute('noChangeAspect', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:blipFill
|
||||
$objWriter->startElement('p:blipFill');
|
||||
|
||||
// a:blip
|
||||
$objWriter->startElement('a:blip');
|
||||
$objWriter->writeAttribute('r:embed', 'rId' . $relationId);
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:stretch
|
||||
$objWriter->startElement('a:stretch');
|
||||
$objWriter->writeElement('a:fillRect', null);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:spPr
|
||||
$objWriter->startElement('p:spPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
$objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation()));
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX()));
|
||||
$objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth()));
|
||||
$objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight()));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstGeom
|
||||
$objWriter->startElement('a:prstGeom');
|
||||
$objWriter->writeAttribute('prst', 'rect');
|
||||
|
||||
// a:avLst
|
||||
$objWriter->writeElement('a:avLst', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
if ($shape->getShadow()->getVisible()) {
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius()));
|
||||
$objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance()));
|
||||
$objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection()));
|
||||
$objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment());
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB());
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write txt
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint_Shape_RichText $shape
|
||||
* @param int $shapeId
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeTxt(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_RichText $shape = null, $shapeId)
|
||||
{
|
||||
// p:sp
|
||||
$objWriter->startElement('p:sp');
|
||||
|
||||
// p:nvSpPr
|
||||
$objWriter->startElement('p:nvSpPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('name', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvSpPr
|
||||
$objWriter->startElement('p:cNvSpPr');
|
||||
$objWriter->writeAttribute('txBox', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:spPr
|
||||
$objWriter->startElement('p:spPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
$objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation()));
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX()));
|
||||
$objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth()));
|
||||
$objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight()));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstGeom
|
||||
$objWriter->startElement('a:prstGeom');
|
||||
$objWriter->writeAttribute('prst', 'rect');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:noFill
|
||||
$objWriter->writeElement('a:noFill', null);
|
||||
|
||||
if ($shape->getShadow()->getVisible()) {
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius()));
|
||||
$objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance()));
|
||||
$objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection()));
|
||||
$objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment());
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB());
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:txBody
|
||||
$objWriter->startElement('p:txBody');
|
||||
|
||||
// a:bodyPr
|
||||
$objWriter->startElement('a:bodyPr');
|
||||
$objWriter->writeAttribute('wrap', 'square');
|
||||
$objWriter->writeAttribute('rtlCol', '0');
|
||||
|
||||
// a:spAutoFit
|
||||
$objWriter->writeElement('a:spAutoFit', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lstStyle
|
||||
$objWriter->writeElement('a:lstStyle', null);
|
||||
|
||||
// a:p
|
||||
$objWriter->startElement('a:p');
|
||||
|
||||
// a:pPr
|
||||
$objWriter->startElement('a:pPr');
|
||||
$objWriter->writeAttribute('algn', $shape->getAlignment()->getHorizontal());
|
||||
$objWriter->writeAttribute('fontAlgn', $shape->getAlignment()->getVertical());
|
||||
$objWriter->writeAttribute('indent', $shape->getAlignment()->getIndent());
|
||||
$objWriter->writeAttribute('lvl', $shape->getAlignment()->getLevel());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop trough rich text elements
|
||||
$elements = $shape->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPPowerPoint_Shape_RichText_Break) {
|
||||
// a:br
|
||||
$objWriter->writeElement('a:br', null);
|
||||
}
|
||||
elseif ($element instanceof PHPPowerPoint_Shape_RichText_Run
|
||||
|| $element instanceof PHPPowerPoint_Shape_RichText_TextElement)
|
||||
{
|
||||
// a:r
|
||||
$objWriter->startElement('a:r');
|
||||
|
||||
// a:rPr
|
||||
if ($element instanceof PHPPowerPoint_Shape_RichText_Run) {
|
||||
// a:rPr
|
||||
$objWriter->startElement('a:rPr');
|
||||
|
||||
// Bold
|
||||
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 'true' : 'false'));
|
||||
|
||||
// Italic
|
||||
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 'true' : 'false'));
|
||||
|
||||
// Strikethrough
|
||||
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
|
||||
|
||||
// Size
|
||||
$objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100));
|
||||
|
||||
// Underline
|
||||
$objWriter->writeAttribute('u', $element->getFont()->getUnderline());
|
||||
|
||||
// Superscript / subscript
|
||||
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||
if ($element->getFont()->getSuperScript()) {
|
||||
$objWriter->writeAttribute('baseline', '30000');
|
||||
} else if ($element->getFont()->getSubScript()) {
|
||||
$objWriter->writeAttribute('baseline', '-25000');
|
||||
}
|
||||
}
|
||||
|
||||
// Color - a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $element->getFont()->getColor()->getRGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Font - a:latin
|
||||
$objWriter->startElement('a:latin');
|
||||
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// t
|
||||
$objWriter->startElement('a:t');
|
||||
$objWriter->writeRaw(PHPPowerPoint_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($element->getText()) ));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
<a:r>
|
||||
<a:rPr lang="en-US" dirty="0" err="1" smtClean="0" />
|
||||
</a:r>
|
||||
|
||||
*/
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Parent IWriter object
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_IWriter
|
||||
*/
|
||||
private $_parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPPowerPoint_Writer_IWriter $pWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setParentWriter(PHPPowerPoint_Writer_IWriter $pWriter = null) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent IWriter object
|
||||
*
|
||||
* @return PHPPowerPoint_Writer_IWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getParentWriter() {
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPPowerPoint_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_HashTable */
|
||||
require_once 'PHPPowerPoint/HashTable.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_Serialized
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_Serialized implements PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Private PHPPowerPoint
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_presentation;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Writer_Serialized
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Assign PHPPowerPoint
|
||||
$this->setPHPPowerPoint($pPHPPowerPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_presentation)) {
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add media
|
||||
$slideCount = $this->_presentation->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
for ($j = 0; $j < $this->_presentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$imgTemp = $this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add PHPPowerPoint.xml to the document, which represents a PHP serialized PHPPowerPoint object
|
||||
$objZip->addFromString('PHPPowerPoint.xml', $this->_writeSerialized($this->_presentation, $pFilename));
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("PHPPowerPoint object unassigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPPowerPoint() {
|
||||
if (!is_null($this->_presentation)) {
|
||||
return $this->_presentation;
|
||||
} else {
|
||||
throw new Exception("No PHPPowerPoint assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) {
|
||||
$this->_presentation = $pPHPPowerPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize PHPPowerPoint object to XML
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @param string $pFilename
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSerialized(PHPPowerPoint $pPHPPowerPoint = null, $pFilename = '')
|
||||
{
|
||||
// Clone $pPHPPowerPoint
|
||||
$pPHPPowerPoint = clone $pPHPPowerPoint;
|
||||
|
||||
// Update media links
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
for ($j = 0; $j < $pPHPPowerPoint->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$imgTemp =& $pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create XML writer
|
||||
$objWriter = new xmlWriter();
|
||||
$objWriter->openMemory();
|
||||
$objWriter->setIndent(true);
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// PHPPowerPoint
|
||||
$objWriter->startElement('PHPPowerPoint');
|
||||
$objWriter->writeAttribute('version', '0.1.0');
|
||||
|
||||
// Comment
|
||||
$objWriter->writeComment('This file has been generated using PHPPowerPoint v0.1.0 (http://www.codeplex.com/PHPPowerPoint). It contains a base64 encoded serialized version of the PHPPowerPoint internal object.');
|
||||
|
||||
// Data
|
||||
$objWriter->startElement('data');
|
||||
$objWriter->writeCData( base64_encode(serialize($pPHPPowerPoint)) );
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->outputMemory(true);
|
||||
}
|
||||
}
|
@ -1,299 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_DocumentProperties
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_DocumentProperties
|
||||
{
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator;
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description;
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_creator = 'Unknown Creator';
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
$this->_title = "Untitled Presentation";
|
||||
$this->_subject = '';
|
||||
$this->_description = '';
|
||||
$this->_keywords = '';
|
||||
$this->_category = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
$this->_creator = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_created = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
$pValue = time();
|
||||
}
|
||||
$this->_modified = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
$this->_title = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
$this->_subject = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
$this->_keywords = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
$this->_category = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_HashTable
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_HashTable
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if (!is_null($pSource)) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPPowerPoint_IComparable $pSource = null) {
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if ( is_null ( $hashIndex ) ) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if ( isset ( $this->_keyMap[$hashIndex] ) ) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->_items[ $hashCode ])) {
|
||||
$this->_items[ $hashCode ] = $pSource;
|
||||
$index = count($this->_items) - 1;
|
||||
$this->_keyMap[ $index ] = $hashCode;
|
||||
$pSource->setHashIndex( $index );
|
||||
} else {
|
||||
$pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPPowerPoint_IComparable $pSource Item to remove
|
||||
* @throws Exception
|
||||
*/
|
||||
public function remove(PHPPowerPoint_IComparable $pSource = null) {
|
||||
if (isset($this->_items[ $pSource->getHashCode() ])) {
|
||||
unset($this->_items[ $pSource->getHashCode() ]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPPowerPoint_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPPowerPoint_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return PHPPowerPoint_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_IComparable
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex();
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value);
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
/** PHPPowerPoint_IReader */
|
||||
require_once 'PHPPowerPoint/Reader/IReader.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_IOFactory
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_IOFactory
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PHPPowerPoint/Writer/{0}.php', 'class' => 'PHPPowerPoint_Writer_{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PHPPowerPoint/Reader/{0}.php', 'class' => 'PHPPowerPoint_Reader_{0}' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Serialized'
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPPowerPoint_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPPowerPoint/Writer/{0}.php
|
||||
* @param string $classname Example: PHPPowerPoint_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPPowerPoint_Writer_IWriter
|
||||
*
|
||||
* @param PHPPowerPoint $PHPPowerPoint
|
||||
* @param string $writerType Example: PowerPoint2007
|
||||
* @return PHPPowerPoint_Writer_IWriter
|
||||
*/
|
||||
public static function createWriter(PHPPowerPoint $PHPPowerPoint, $writerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IWriter';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once($classFile);
|
||||
}
|
||||
|
||||
$instance = new $className($PHPPowerPoint);
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $writerType");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create PHPPowerPoint_Reader_IReader
|
||||
*
|
||||
* @param string $readerType Example: PowerPoint2007
|
||||
* @return PHPPowerPoint_Reader_IReader
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IReader';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once($classFile);
|
||||
}
|
||||
|
||||
$instance = new $className();
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $readerType");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint from file using automatic PHPPowerPoint_Reader_IReader resolution
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
// Try loading using self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not automatically determine PHPPowerPoint_Reader_IReader for file.");
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Reader_IReader
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPPowerPoint_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint from file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Reader_IReader */
|
||||
require_once 'PHPPowerPoint/Reader/IReader.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_File */
|
||||
require_once 'PHPPowerPoint/Shared/File.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Reader_Serialized
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Reader
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Reader_Serialized implements PHPPowerPoint_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPPowerPoint_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
return $this->fileSupportsUnserializePHPPowerPoint($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPPowerPoint Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Unserialize... First make sure the file supports it!
|
||||
if (!$this->fileSupportsUnserializePHPPowerPoint($pFilename)) {
|
||||
throw new Exception("Invalid file format for PHPPowerPoint_Reader_Serialized: " . $pFilename . ".");
|
||||
}
|
||||
|
||||
return $this->_loadSerialized($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PHPPowerPoint Serialized file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPPowerPoint
|
||||
*/
|
||||
private function _loadSerialized($pFilename) {
|
||||
$xmlData = simplexml_load_string(file_get_contents("zip://$pFilename#PHPPowerPoint.xml"));
|
||||
$excel = unserialize(base64_decode((string)$xmlData->data));
|
||||
|
||||
// Update media links
|
||||
for ($i = 0; $i < $excel->getSlideCount(); ++$i) {
|
||||
for ($j = 0; $j < $excel->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($excel->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPExcl_Shape_BaseDrawing) {
|
||||
$imgTemp =& $excel->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a file support UnserializePHPPowerPoint ?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function fileSupportsUnserializePHPPowerPoint($pFilename = '') {
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// File exists, does it contain PHPPowerPoint.xml?
|
||||
return PHPPowerPoint_Shared_File::file_exists("zip://$pFilename#PHPPowerPoint.xml");
|
||||
}
|
||||
}
|
@ -1,358 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Fill */
|
||||
require_once 'PHPPowerPoint/Style/Fill.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Shadow */
|
||||
require_once 'PHPPowerPoint/Shape/Shadow.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Slide
|
||||
*
|
||||
* @var PHPPowerPoint_Slide
|
||||
*/
|
||||
protected $_slide;
|
||||
|
||||
/**
|
||||
* Offset X
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_offsetX;
|
||||
|
||||
/**
|
||||
* Offset Y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_offsetY;
|
||||
|
||||
/**
|
||||
* Width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_width;
|
||||
|
||||
/**
|
||||
* Height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_height;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
private $_fill;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_rotation;
|
||||
|
||||
/**
|
||||
* Shadow
|
||||
*
|
||||
* @var PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
protected $_shadow;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_slide = null;
|
||||
$this->_offsetX = 0;
|
||||
$this->_offsetY = 0;
|
||||
$this->_width = 0;
|
||||
$this->_height = 0;
|
||||
$this->_rotation = 0;
|
||||
$this->_fill = new PHPPowerPoint_Style_Fill();
|
||||
$this->_shadow = new PHPPowerPoint_Shape_Shadow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Slide
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function getSlide() {
|
||||
return $this->_slide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Slide
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pValue
|
||||
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setSlide(PHPPowerPoint_slide $pValue = null, $pOverrideOld = false) {
|
||||
if (is_null($this->_slide)) {
|
||||
// Add drawing to PHPPowerPoint_Slide
|
||||
$this->_slide = $pValue;
|
||||
$this->_slide->getShapeCollection()->append($this);
|
||||
} else {
|
||||
if ($pOverrideOld) {
|
||||
// Remove drawing from old PHPPowerPoint_Slide
|
||||
$iterator = $this->_slide->getShapeCollection()->getIterator();
|
||||
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
|
||||
$this->_slide->getShapeCollection()->offsetUnset( $iterator->key() );
|
||||
$this->_slide = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set new PHPPowerPoint_Slide
|
||||
$this->setSlide($pValue);
|
||||
} else {
|
||||
throw new Exception("A PHPPowerPoint_Slide has already been assigned. Shapes can only exist on one PHPPowerPoint_Slide.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetX
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetX() {
|
||||
return $this->_offsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetX
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setOffsetX($pValue = 0) {
|
||||
$this->_offsetX = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OffsetY
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOffsetY() {
|
||||
return $this->_offsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OffsetY
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setOffsetY($pValue = 0) {
|
||||
$this->_offsetY = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setWidth($pValue = 0) {
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeight($pValue = 0) {
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0) {
|
||||
$this->_width = $width;
|
||||
$this->_height = $height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRotation() {
|
||||
return $this->_rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setRotation($pValue = 0) {
|
||||
$this->_rotation = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
public function getFill() {
|
||||
return $this->_fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
public function getShadow() {
|
||||
return $this->_shadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_Shadow $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setShadow(PHPPowerPoint_Shape_Shadow $pValue = null) {
|
||||
$this->_shadow = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_slide->getHashCode()
|
||||
. $this->_offsetX
|
||||
. $this->_offsetY
|
||||
. $this->_width
|
||||
. $this->_height
|
||||
. $this->_rotation
|
||||
. $this->getFill()->getHashCode()
|
||||
. $this->_shadow->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,272 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_BaseDrawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Shape_BaseDrawing extends PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Image counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_imageCounter = 0;
|
||||
|
||||
/**
|
||||
* Image index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_imageIndex = 0;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_description;
|
||||
|
||||
/**
|
||||
* Proportional resize
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_resizeProportional;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_BaseDrawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_name = '';
|
||||
$this->_description = '';
|
||||
$this->_resizeProportional = true;
|
||||
|
||||
// Set image index
|
||||
self::$_imageCounter++;
|
||||
$this->_imageIndex = self::$_imageCounter;
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImageIndex() {
|
||||
return $this->_imageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setName($pValue = '') {
|
||||
$this->_name = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setWidth($pValue = 0) {
|
||||
// Resize proportional?
|
||||
if ($this->_resizeProportional && $pValue != 0) {
|
||||
$ratio = $this->_height / $this->_width;
|
||||
$this->_height = round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set width
|
||||
$this->_width = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeight($pValue = 0) {
|
||||
// Resize proportional?
|
||||
if ($this->_resizeProportional && $pValue != 0) {
|
||||
$ratio = $this->_width / $this->_height;
|
||||
$this->_width = round($ratio * $pValue);
|
||||
}
|
||||
|
||||
// Set height
|
||||
$this->_height = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set width and height with proportional resize
|
||||
* @author Vincent@luo MSN:kele_100@hotmail.com
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @example $objDrawing->setResizeProportional(true);
|
||||
* @example $objDrawing->setWidthAndHeight(160,120);
|
||||
*/
|
||||
public function setWidthAndHeight($width = 0, $height = 0) {
|
||||
$xratio = $width / $this->_width;
|
||||
$yratio = $height / $this->_height;
|
||||
if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
|
||||
if (($xratio * $this->_height) < $height) {
|
||||
$this->_height = ceil($xratio * $this->_height);
|
||||
$this->_width = $width;
|
||||
} else {
|
||||
$this->_width = ceil($yratio * $this->_width);
|
||||
$this->_height = $height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ResizeProportional
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getResizeProportional() {
|
||||
return $this->_resizeProportional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ResizeProportional
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setResizeProportional($pValue = true) {
|
||||
$this->_resizeProportional = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_name
|
||||
. $this->_description
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape*/
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_Drawing extends PHPPowerPoint_Shape_BaseDrawing implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_path;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_Drawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_path = '';
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename() {
|
||||
return basename($this->_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename() {
|
||||
return str_replace('.' . $this->getExtension(), '', $this->getFilename()) . $this->getImageIndex() . '.' . $this->getExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension() {
|
||||
$exploded = explode(".", basename($this->_path));
|
||||
return $exploded[count($exploded) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath() {
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Path
|
||||
*
|
||||
* @param string $pValue File path
|
||||
* @param boolean $pVerifyFile Verify file
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPath($pValue = '', $pVerifyFile = true) {
|
||||
if ($pVerifyFile) {
|
||||
if (file_exists($pValue)) {
|
||||
$this->_path = $pValue;
|
||||
|
||||
if ($this->_width == 0 && $this->_height == 0) {
|
||||
// Get width/height
|
||||
list($this->_width, $this->_height) = getimagesize($pValue);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("File $pValue not found!");
|
||||
}
|
||||
} else {
|
||||
$this->_path = $pValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_path
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_MemoryDrawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_MemoryDrawing extends PHPPowerPoint_Shape_BaseDrawing implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Rendering functions */
|
||||
const RENDERING_DEFAULT = 'imagepng';
|
||||
const RENDERING_PNG = 'imagepng';
|
||||
const RENDERING_GIF = 'imagegif';
|
||||
const RENDERING_JPEG = 'imagejpeg';
|
||||
|
||||
/* MIME types */
|
||||
const MIMETYPE_DEFAULT = 'image/png';
|
||||
const MIMETYPE_PNG = 'image/png';
|
||||
const MIMETYPE_GIF = 'image/gif';
|
||||
const MIMETYPE_JPEG = 'image/jpeg';
|
||||
|
||||
/**
|
||||
* Image resource
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_imageResource;
|
||||
|
||||
/**
|
||||
* Rendering function
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_renderingFunction;
|
||||
|
||||
/**
|
||||
* Mime type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_mimeType;
|
||||
|
||||
/**
|
||||
* Unique name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_uniqueName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Slide_MemoryDrawing
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_imageResource = null;
|
||||
$this->_renderingFunction = self::RENDERING_DEFAULT;
|
||||
$this->_mimeType = self::MIMETYPE_DEFAULT;
|
||||
$this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image resource
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getImageResource() {
|
||||
return $this->_imageResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image resource
|
||||
*
|
||||
* @param $value resource
|
||||
*/
|
||||
public function setImageResource($value = null) {
|
||||
$this->_imageResource = $value;
|
||||
|
||||
if (!is_null($this->_imageResource)) {
|
||||
// Get width/height
|
||||
$this->_width = imagesx($this->_imageResource);
|
||||
$this->_height = imagesy($this->_imageResource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rendering function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRenderingFunction() {
|
||||
return $this->_renderingFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rendering function
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setRenderingFunction($value = PHPPowerPoint_Slide_MemoryDrawing::RENDERING_DEFAULT) {
|
||||
$this->_renderingFunction = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mime type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType() {
|
||||
return $this->_mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mime type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setMimeType($value = PHPPowerPoint_Slide_MemoryDrawing::MIMETYPE_DEFAULT) {
|
||||
$this->_mimeType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexed filename (using image index)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexedFilename() {
|
||||
$extension = strtolower($this->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
return $this->_uniqueName . $this->getImageIndex() . '.' . $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_renderingFunction
|
||||
. $this->_mimeType
|
||||
. $this->_uniqueName
|
||||
. parent::getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_TextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/TextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_Run */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/Run.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_Break */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/Break.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Alignment */
|
||||
require_once 'PHPPowerPoint/Style/Alignment.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText extends PHPPowerPoint_Shape implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var PHPPowerPoint_Shape_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
$this->_alignment = new PHPPowerPoint_Style_Alignment();
|
||||
|
||||
// Initialize parent
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alignment
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_RichText_ITextElement $pText Rich text element
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addText(PHPPowerPoint_Shape_RichText_ITextElement $pText = null)
|
||||
{
|
||||
$this->_richTextElements[] = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text (can not be formatted !)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPPowerPoint_Shape_RichText_TextElement
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_TextElement($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create break
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText_Break
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createBreak()
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_Break();
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run (can be formatted)
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPPowerPoint_Shape_RichText_Run
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new PHPPowerPoint_Shape_RichText_Run($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all PHPPowerPoint_Shape_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText_ITextElement[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param PHPPowerPoint_Shape_RichText_ITextElement[] $pElements Array of elements
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (is_array($pElements)) {
|
||||
$this->_richTextElements = $pElements;
|
||||
} else {
|
||||
throw new Exception("Invalid PHPPowerPoint_Shape_RichText_ITextElement[] array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$hashElements = '';
|
||||
foreach ($this->_richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$hashElements
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ($key == '_parent') continue;
|
||||
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_Break
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_Break implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_Break instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return "\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
__CLASS__
|
||||
);
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_ITextElement
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_TextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/TextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_Run
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_Run extends PHPPowerPoint_Shape_RichText_TextElement implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_Run instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->setText($pText);
|
||||
$this->_font = new PHPPowerPoint_Style_Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Font $pFont Font
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setFont(PHPPowerPoint_Style_Font $pFont = null) {
|
||||
$this->_font = $pFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getText()
|
||||
. $this->_font->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_RichText
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText_ITextElement */
|
||||
require_once 'PHPPowerPoint/Shape/RichText/ITextElement.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Font */
|
||||
require_once 'PHPPowerPoint/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_RichText_TextElement
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_RichText_TextElement implements PHPPowerPoint_Shape_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_RichText_TextElement instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
*/
|
||||
public function setText($pText = '') {
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_text
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,314 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shape_Shadow
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shape
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shape_Shadow implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Shadow alignment */
|
||||
const SHADOW_BOTTOM = 'b';
|
||||
const SHADOW_BOTTOM_LEFT = 'bl';
|
||||
const SHADOW_BOTTOM_RIGHT = 'br';
|
||||
const SHADOW_CENTER = 'ctr';
|
||||
const SHADOW_LEFT = 'l';
|
||||
const SHADOW_TOP = 't';
|
||||
const SHADOW_TOP_LEFT = 'tl';
|
||||
const SHADOW_TOP_RIGHT = 'tr';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_visible;
|
||||
|
||||
/**
|
||||
* Blur radius
|
||||
*
|
||||
* Defaults to 6
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_blurRadius;
|
||||
|
||||
/**
|
||||
* Shadow distance
|
||||
*
|
||||
* Defaults to 2
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_distance;
|
||||
|
||||
/**
|
||||
* Shadow direction (in degrees)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_direction;
|
||||
|
||||
/**
|
||||
* Shadow alignment
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Alpha
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_alpha;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shape_Shadow
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_visible = false;
|
||||
$this->_blurRadius = 6;
|
||||
$this->_distance = 2;
|
||||
$this->_direction = 0;
|
||||
$this->_alignment = self::SHADOW_BOTTOM_RIGHT;
|
||||
$this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
$this->_alpha = 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Visible
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setVisible($pValue = false) {
|
||||
$this->_visible = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Blur radius
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlurRadius() {
|
||||
return $this->_blurRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Blur radius
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setBlurRadius($pValue = 6) {
|
||||
$this->_blurRadius = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDistance() {
|
||||
return $this->_distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow distance
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDistance($pValue = 2) {
|
||||
$this->_distance = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow direction (in degrees)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDirection() {
|
||||
return $this->_direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow direction (in degrees)
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDirection($pValue = 0) {
|
||||
$this->_direction = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shadow alignment
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shadow alignment
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setAlignment($pValue = 0) {
|
||||
$this->_alignment = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_color = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alpha
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAlpha() {
|
||||
return $this->_alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alpha
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setAlpha($pValue = 0) {
|
||||
$this->_alpha = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
($this->_visible ? 't' : 'f')
|
||||
. $this->_blurRadius
|
||||
. $this->_distance
|
||||
. $this->_direction
|
||||
. $this->_alignment
|
||||
. $this->_color->getHashCode()
|
||||
. $this->_alpha
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_Drawing
|
||||
{
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points width to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 1.333333333;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_File
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_File
|
||||
{
|
||||
/**
|
||||
* Verify if a file exists
|
||||
*
|
||||
* @param string $pFilename Filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists($pFilename) {
|
||||
// Sick construction, but it seems that
|
||||
// file_exists returns strange values when
|
||||
// doing the original file_exists on ZIP archives...
|
||||
if ( strtolower(substr($pFilename, 0, 3)) == 'zip' ) {
|
||||
// Open ZIP file and verify if the file exists
|
||||
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
|
||||
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) === true) {
|
||||
$returnValue = ($zip->getFromName($archiveFile) !== false);
|
||||
$zip->close();
|
||||
return $returnValue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Regular file_exists
|
||||
return file_exists($pFilename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonicalized absolute pathname, also for ZIP archives
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return string
|
||||
*/
|
||||
public static function realpath($pFilename) {
|
||||
// Returnvalue
|
||||
$returnValue = '';
|
||||
|
||||
// Try using realpath()
|
||||
$returnValue = realpath($pFilename);
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
unset($pathArray[$i]);
|
||||
unset($pathArray[$i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$returnValue = implode('/', $pathArray);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_Font
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_Font
|
||||
{
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
* @param int $sizeInInch Font size (in inch)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function inchSizeToPixels($sizeInInch = 1) {
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
* @param int $sizeInCm Font size (in centimeters)
|
||||
* @return int Size (in pixels)
|
||||
*/
|
||||
public static function centimeterSizeToPixels($sizeInCm = 1) {
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_String
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_String
|
||||
{
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isMbstringEnabled;
|
||||
|
||||
/**
|
||||
* Is iconv extension avalable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_isIconvEnabled;
|
||||
|
||||
/**
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
self::$_controlCharacters[$find] = $replace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether mbstring extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsMbstringEnabled()
|
||||
{
|
||||
if (isset(self::$_isMbstringEnabled)) {
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isMbstringEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether iconv extension is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getIsIconvEnabled()
|
||||
{
|
||||
if (isset(self::$_isIconvEnabled)) {
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
self::$_isIconvEnabled = function_exists('iconv') ?
|
||||
true : false;
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from OpenXML escaped control character to PHP control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* That's correct, control characters are stored directly in the shared-strings table.
|
||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from PHP control character to OpenXML escaped control character
|
||||
*
|
||||
* Excel 2007 team:
|
||||
* ----------------
|
||||
* That's correct, control characters are stored directly in the shared-strings table.
|
||||
* We do encode characters that cannot be represented in XML using the following escape sequence:
|
||||
* _xHHHH_ where H represents a hexadecimal character in the character's value...
|
||||
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
|
||||
* element or in the shared string <t> element.
|
||||
*
|
||||
* @param string $value Value to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
||||
if(empty(self::$_controlCharacters)) {
|
||||
self::_buildControlCharacters();
|
||||
}
|
||||
|
||||
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF8 data
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IsUTF8($value = '') {
|
||||
return utf8_encode(utf8_decode($value)) === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a numeric value as a string for output in various output writers
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function FormatNumber($value) {
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
|
||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* although this will give wrong results for non-ASCII strings
|
||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeShort($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('CC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
|
||||
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
|
||||
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
|
||||
* although this will give wrong results for non-ASCII strings
|
||||
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
|
||||
*
|
||||
* @param string $value UTF-8 encoded string
|
||||
* @return string
|
||||
*/
|
||||
public static function UTF8toBIFF8UnicodeLong($value)
|
||||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
$data = pack('vC', $ln, $opt) . $chars;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
|
||||
* @return string
|
||||
*/
|
||||
public static function ConvertEncoding($value, $to, $from)
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$value = mb_convert_encoding($value, $to, $from);
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$value = iconv($from, $to, $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get character count. First try mbstring, then iconv, finally strlen
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $enc Encoding
|
||||
* @return int Character count
|
||||
*/
|
||||
public static function CountCharacters($value, $enc = 'UTF-8')
|
||||
{
|
||||
if (self::getIsMbstringEnabled()) {
|
||||
$count = mb_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
|
||||
if (self::getIsIconvEnabled()) {
|
||||
$count = iconv_strlen($value, $enc);
|
||||
return $count;
|
||||
}
|
||||
|
||||
// else strlen
|
||||
$count = strlen($value);
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
if (!defined('DATE_W3C')) {
|
||||
define('DATE_W3C', 'Y-m-d\TH:i:sP');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_XMLWriter
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_XMLWriter {
|
||||
/** Temporary storage method */
|
||||
const STORAGE_MEMORY = 1;
|
||||
const STORAGE_DISK = 2;
|
||||
|
||||
/**
|
||||
* Internal XMLWriter
|
||||
*
|
||||
* @var XMLWriter
|
||||
*/
|
||||
private $_xmlWriter;
|
||||
|
||||
/**
|
||||
* Temporary filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tempFileName = '';
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Shared_XMLWriter instance
|
||||
*
|
||||
* @param int $pTemporaryStorage Temporary storage location
|
||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||
*/
|
||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
|
||||
// Create internal XMLWriter
|
||||
$this->_xmlWriter = new XMLWriter();
|
||||
|
||||
// Open temporary storage
|
||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||
$this->_xmlWriter->openMemory();
|
||||
} else {
|
||||
// Create temporary filename
|
||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||
|
||||
// Open storage
|
||||
if ($this->_xmlWriter->openUri($this->_tempFileName) === false) {
|
||||
// Fallback to memory...
|
||||
$this->_xmlWriter->openMemory();
|
||||
}
|
||||
}
|
||||
|
||||
// Set default values
|
||||
$this->_xmlWriter->setIndent(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
// Desctruct XMLWriter
|
||||
unset($this->_xmlWriter);
|
||||
|
||||
// Unlink temporary files
|
||||
if ($this->_tempFileName != '') {
|
||||
@unlink($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get written data
|
||||
*
|
||||
* @return $data
|
||||
*/
|
||||
public function getData() {
|
||||
if ($this->_tempFileName == '') {
|
||||
return $this->_xmlWriter->outputMemory(true);
|
||||
} else {
|
||||
$this->_xmlWriter->flush();
|
||||
return file_get_contents($this->_tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch function calls (and pass them to internal XMLWriter)
|
||||
*
|
||||
* @param unknown_type $function
|
||||
* @param unknown_type $args
|
||||
*/
|
||||
public function __call($function, $args) {
|
||||
try {
|
||||
@call_user_func_array(array($this->_xmlWriter, $function), $args);
|
||||
} catch (Exception $ex) {
|
||||
// Do nothing!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback method for writeRaw, introduced in PHP 5.2
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function writeRaw($text)
|
||||
{
|
||||
if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) {
|
||||
return $this->_xmlWriter->writeRaw($text);
|
||||
}
|
||||
|
||||
return $this->text($text);
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** Register new zip wrapper */
|
||||
PHPPowerPoint_Shared_ZipStreamWrapper::register();
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Shared_ZipStreamWrapper
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Shared
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Shared_ZipStreamWrapper {
|
||||
/**
|
||||
* Internal ZipAcrhive
|
||||
*
|
||||
* @var ZipAcrhive
|
||||
*/
|
||||
private $_archive;
|
||||
|
||||
/**
|
||||
* Filename in ZipAcrhive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileNameInArchive = '';
|
||||
|
||||
/**
|
||||
* Position in file
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_data = '';
|
||||
|
||||
/**
|
||||
* Register wrapper
|
||||
*/
|
||||
public static function register() {
|
||||
@stream_wrapper_unregister("zip");
|
||||
@stream_wrapper_register("zip", __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open stream
|
||||
*/
|
||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
// Check for mode
|
||||
if ($mode{0} != 'r') {
|
||||
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
|
||||
}
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
$url['host'] = substr($path, strlen('zip://'));
|
||||
$url['path'] = '';
|
||||
}
|
||||
if (strpos($url['host'], '#') !== false) {
|
||||
if (!isset($url['fragment'])) {
|
||||
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
|
||||
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
|
||||
unset($url['path']);
|
||||
}
|
||||
} else {
|
||||
$url['host'] = $url['host'] . $url['path'];
|
||||
unset($url['path']);
|
||||
}
|
||||
|
||||
// Open archive
|
||||
$this->_archive = new ZipArchive();
|
||||
$this->_archive->open($url['host']);
|
||||
|
||||
$this->_fileNameInArchive = $url['fragment'];
|
||||
$this->_position = 0;
|
||||
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat stream
|
||||
*/
|
||||
public function stream_stat() {
|
||||
return $this->_archive->statName( $this->_fileNameInArchive );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count) {
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell stream
|
||||
*/
|
||||
public function stream_tell() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* EOF stream
|
||||
*/
|
||||
public function stream_eof() {
|
||||
return $this->_position >= strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek stream
|
||||
*/
|
||||
public function stream_seek($offset, $whence) {
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < strlen($this->_data) && $offset >= 0) {
|
||||
$this->_position = $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
if ($offset >= 0) {
|
||||
$this->_position += $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if (strlen($this->_data) + $offset >= 0) {
|
||||
$this->_position = strlen($this->_data) + $offset;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,261 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide_Layout */
|
||||
require_once 'PHPPowerPoint/Slide/Layout.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText */
|
||||
require_once 'PHPPowerPoint/Shape/RichText.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Font */
|
||||
require_once 'PHPPowerPoint/Shared/Font.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_String */
|
||||
require_once 'PHPPowerPoint/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Slide
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Slide implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/**
|
||||
* Parent presentation
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Collection of shapes
|
||||
*
|
||||
* @var PHPPowerPoint_Shape[]
|
||||
*/
|
||||
private $_shapeCollection = null;
|
||||
|
||||
/**
|
||||
* Slide identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_identifier;
|
||||
|
||||
/**
|
||||
* Slide layout
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_slideLayout = PHPPowerPoint_Slide_Layout::BLANK;
|
||||
|
||||
/**
|
||||
* Create a new slide
|
||||
*
|
||||
* @param PHPPowerPoint $pParent
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pParent = null)
|
||||
{
|
||||
// Set parent
|
||||
$this->_parent = $pParent;
|
||||
|
||||
// Shape collection
|
||||
$this->_shapeCollection = new ArrayObject();
|
||||
|
||||
// Set identifier
|
||||
$this->_identifier = md5(rand(0,9999) . time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of shapes
|
||||
*
|
||||
* @return PHPPowerPoint_Shape[]
|
||||
*/
|
||||
public function getShapeCollection()
|
||||
{
|
||||
return $this->_shapeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shape to slide
|
||||
*
|
||||
* @param PHPPowerPoint_Shape $shape
|
||||
*/
|
||||
public function addShape(PHPPowerPoint_Shape $shape)
|
||||
{
|
||||
$shape->setSlide($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create rich text shape
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_RichText
|
||||
*/
|
||||
public function createRichTextShape()
|
||||
{
|
||||
$shape = new PHPPowerPoint_Shape_RichText();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create drawing shape
|
||||
*
|
||||
* @return PHPPowerPoint_Shape_Drawing
|
||||
*/
|
||||
public function createDrawingShape()
|
||||
{
|
||||
$shape = new PHPPowerPoint_Shape_Drawing();
|
||||
$this->addShape($shape);
|
||||
return $shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-bind parent
|
||||
*
|
||||
* @param PHPPowerPoint $parent
|
||||
*/
|
||||
public function rebindParent(PHPPowerPoint $parent) {
|
||||
$this->_parent->removeSlideByIndex(
|
||||
$this->_parent->getIndex($this)
|
||||
);
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide layout
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSlideLayout() {
|
||||
return $this->_slideLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide layout
|
||||
*
|
||||
* @param string $layout
|
||||
*/
|
||||
public function setSlideLayout($layout = PHPPowerPoint_Slide_Layout::BLANK) {
|
||||
$this->_slideLayout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_identifier
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy slide (!= clone!)
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function copy() {
|
||||
$copied = clone $this;
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
foreach ($this as $key => $val) {
|
||||
if (is_object($val) || (is_array($val))) {
|
||||
$this->{$key} = unserialize(serialize($val));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Slide_Layout
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Slide
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Slide_Layout
|
||||
{
|
||||
/** Layout constants */
|
||||
const TITLE_SLIDE = 'Title Slide';
|
||||
const TITLE_AND_CONTENT = 'Title and Content';
|
||||
const SECTION_HEADER = 'Section Header';
|
||||
const TWO_CONTENT = 'Two Content';
|
||||
const COMPARISON = 'Comparison';
|
||||
const TITLE_ONLY = 'Title Only';
|
||||
const BLANK = 'Blank';
|
||||
const CONTENT_WITH_CAPTION = 'Content with Caption';
|
||||
const PICTURE_WITH_CAPTION = 'Picture with Caption';
|
||||
const TITLE_AND_VERTICAL_TEXT = 'Title and Vertical Text';
|
||||
const VERTICAL_TITLE_AND_TEXT = 'Vertical Title and Text';
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_SlideIterator
|
||||
*
|
||||
* Used to iterate slides in PHPPowerPoint
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_SlideIterator extends IteratorIterator
|
||||
{
|
||||
/**
|
||||
* Presentation to iterate
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Current iterator position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Create a new slide iterator
|
||||
*
|
||||
* @param PHPPowerPoint $subject
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $subject = null) {
|
||||
// Set subject
|
||||
$this->_subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
unset($this->_subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind iterator
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->_position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current PHPPowerPoint_Slide
|
||||
*
|
||||
* @return PHPPowerPoint_Slide
|
||||
*/
|
||||
public function current() {
|
||||
return $this->_subject->getSlide($this->_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next value
|
||||
*/
|
||||
public function next() {
|
||||
++$this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* More PHPPowerPoint_Slide instances available?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->_position < $this->_subject->getSlideCount();
|
||||
}
|
||||
}
|
@ -1,243 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Alignment
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Alignment implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Horizontal alignment styles */
|
||||
const HORIZONTAL_LEFT = 'l';
|
||||
const HORIZONTAL_RIGHT = 'r';
|
||||
const HORIZONTAL_CENTER = 'ctr';
|
||||
const HORIZONTAL_JUSTIFY = 'just';
|
||||
const HORIZONTAL_DISTRIBUTED = 'dist';
|
||||
|
||||
/* Vertical alignment styles */
|
||||
const VERTICAL_BASE = 'base';
|
||||
const VERTICAL_AUTO = 'auto';
|
||||
const VERTICAL_BOTTOM = 'b';
|
||||
const VERTICAL_TOP = 't';
|
||||
const VERTICAL_CENTER = 'ctr';
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
/**
|
||||
* Level
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_level;
|
||||
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Alignment
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_horizontal = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
|
||||
$this->_vertical = PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
|
||||
$this->_level = 0;
|
||||
$this->_indent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
return $this->_horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setHorizontal($pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEF) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
|
||||
}
|
||||
$this->_horizontal = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical() {
|
||||
return $this->_vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setVertical($pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
|
||||
}
|
||||
$this->_vertical = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Level
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLevel() {
|
||||
return $this->_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Level
|
||||
*
|
||||
* @param int $pValue Ranging 0 - 8
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setLevel($pValue = 0) {
|
||||
if ($pValue < 0 || $pValue > 8) {
|
||||
throw new Exception("Invalid value: shoul be range 0 - 8.");
|
||||
}
|
||||
$this->_level = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setIndent($pValue = 0) {
|
||||
if ($pValue > 0) {
|
||||
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
|
||||
$pValue = 0; // indent not supported
|
||||
}
|
||||
}
|
||||
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_horizontal
|
||||
. $this->_vertical
|
||||
. $this->_level
|
||||
. $this->_indent
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Color
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Color implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Colors */
|
||||
const COLOR_BLACK = 'FF000000';
|
||||
const COLOR_WHITE = 'FFFFFFFF';
|
||||
const COLOR_RED = 'FFFF0000';
|
||||
const COLOR_DARKRED = 'FF800000';
|
||||
const COLOR_BLUE = 'FF0000FF';
|
||||
const COLOR_DARKBLUE = 'FF000080';
|
||||
const COLOR_GREEN = 'FF00FF00';
|
||||
const COLOR_DARKGREEN = 'FF008000';
|
||||
const COLOR_YELLOW = 'FFFFFF00';
|
||||
const COLOR_DARKYELLOW = 'FF808000';
|
||||
|
||||
/**
|
||||
* ARGB - Alpha RGB
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_argb;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Color
|
||||
*
|
||||
* @param string $pARGB
|
||||
*/
|
||||
public function __construct($pARGB = PHPPowerPoint_Style_Color::COLOR_BLACK)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_argb = $pARGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ARGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getARGB() {
|
||||
return $this->_argb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ARGB
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setARGB($pValue = PHPPowerPoint_Style_Color::COLOR_BLACK) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Color::COLOR_BLACK;
|
||||
}
|
||||
$this->_argb = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RGB
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRGB() {
|
||||
return substr($this->_argb, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RGB
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setRGB($pValue = '000000') {
|
||||
if ($pValue == '') {
|
||||
$pValue = '000000';
|
||||
}
|
||||
$this->_argb = 'FF' . $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_argb
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Fill
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Fill implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Fill types */
|
||||
const FILL_NONE = 'none';
|
||||
const FILL_SOLID = 'solid';
|
||||
const FILL_GRADIENT_LINEAR = 'linear';
|
||||
const FILL_GRADIENT_PATH = 'path';
|
||||
const FILL_PATTERN_DARKDOWN = 'darkDown';
|
||||
const FILL_PATTERN_DARKGRAY = 'darkGray';
|
||||
const FILL_PATTERN_DARKGRID = 'darkGrid';
|
||||
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal';
|
||||
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis';
|
||||
const FILL_PATTERN_DARKUP = 'darkUp';
|
||||
const FILL_PATTERN_DARKVERTICAL = 'darkVertical';
|
||||
const FILL_PATTERN_GRAY0625 = 'gray0625';
|
||||
const FILL_PATTERN_GRAY125 = 'gray125';
|
||||
const FILL_PATTERN_LIGHTDOWN = 'lightDown';
|
||||
const FILL_PATTERN_LIGHTGRAY = 'lightGray';
|
||||
const FILL_PATTERN_LIGHTGRID = 'lightGrid';
|
||||
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal';
|
||||
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis';
|
||||
const FILL_PATTERN_LIGHTUP = 'lightUp';
|
||||
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical';
|
||||
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
|
||||
|
||||
/**
|
||||
* Fill type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fillType;
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var double
|
||||
*/
|
||||
private $_rotation;
|
||||
|
||||
/**
|
||||
* Start color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_startColor;
|
||||
|
||||
/**
|
||||
* End color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_endColor;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Fill
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_fillType = PHPPowerPoint_Style_Fill::FILL_NONE;
|
||||
$this->_rotation = 0;
|
||||
$this->_startColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_WHITE);
|
||||
$this->_endColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillType() {
|
||||
$this->_fillType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Type
|
||||
*
|
||||
* @param string $pValue PHPPowerPoint_Style_Fill fill type
|
||||
*/
|
||||
public function setFillType($pValue = PHPPowerPoint_Style_Fill::FILL_NONE) {
|
||||
$this->_fillType = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getRotation() {
|
||||
return $this->_rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
* @param double $pValue
|
||||
*/
|
||||
public function setRotation($pValue = 0) {
|
||||
$this->_rotation = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Start Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getStartColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->_startColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Start Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setStartColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_startColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get End Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getEndColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->_endColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set End Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setEndColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_endColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getFillType()
|
||||
. $this->getRotation()
|
||||
. $this->getStartColor()->getHashCode()
|
||||
. $this->getEndColor()->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,411 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Font
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Font implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Underline types */
|
||||
const UNDERLINE_NONE = 'none';
|
||||
const UNDERLINE_DASH = 'dash';
|
||||
const UNDERLINE_DASHHEAVY = 'dashHeavy';
|
||||
const UNDERLINE_DASHLONG = 'dashLong';
|
||||
const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
|
||||
const UNDERLINE_DOUBLE = 'dbl';
|
||||
const UNDERLINE_DOTHASH = 'dotDash';
|
||||
const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy';
|
||||
const UNDERLINE_DOTDOTDASH = 'dotDotDash';
|
||||
const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
|
||||
const UNDERLINE_DOTTED = 'dotted';
|
||||
const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
|
||||
const UNDERLINE_HEAVY = 'heavy';
|
||||
const UNDERLINE_SINGLE = 'sng';
|
||||
const UNDERLINE_WAVY = 'wavy';
|
||||
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
|
||||
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
|
||||
const UNDERLINE_WORDS = 'words';
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* Bold
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_bold;
|
||||
|
||||
/**
|
||||
* Italic
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_italic;
|
||||
|
||||
/**
|
||||
* Superscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_superScript;
|
||||
|
||||
/**
|
||||
* Subscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_subScript;
|
||||
|
||||
/**
|
||||
* Underline
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_underline;
|
||||
|
||||
/**
|
||||
* Strikethrough
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_strikethrough;
|
||||
|
||||
/**
|
||||
* Foreground color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Font
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_name = 'Calibri';
|
||||
$this->_size = 10;
|
||||
$this->_bold = false;
|
||||
$this->_italic = false;
|
||||
$this->_superScript = false;
|
||||
$this->_subScript = false;
|
||||
$this->_underline = PHPPowerPoint_Style_Font::UNDERLINE_NONE;
|
||||
$this->_strikethrough = false;
|
||||
$this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setName($pValue = 'Calibri') {
|
||||
if ($pValue == '') {
|
||||
$pValue = 'Calibri';
|
||||
}
|
||||
$this->_name = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Size
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getSize() {
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Size
|
||||
*
|
||||
* @param double $pValue
|
||||
*/
|
||||
public function setSize($pValue = 10) {
|
||||
if ($pValue == '') {
|
||||
$pValue = 10;
|
||||
}
|
||||
$this->_size = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bold
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBold() {
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bold
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setBold($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_bold = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Italic
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getItalic() {
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Italic
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setItalic($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_italic = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SuperScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSuperScript() {
|
||||
return $this->_superScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SuperScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setSuperScript($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_superScript = $pValue;
|
||||
$this->_subScript = !$pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SubScript
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSubScript() {
|
||||
return $this->_subScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SubScript
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setSubScript($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_subScript = $pValue;
|
||||
$this->_superScript = !$pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Underline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUnderline() {
|
||||
return $this->_underline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Underline
|
||||
*
|
||||
* @param string $pValue PHPPowerPoint_Style_Font underline type
|
||||
*/
|
||||
public function setUnderline($pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE;
|
||||
}
|
||||
$this->_underline = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Striketrough
|
||||
*
|
||||
* @deprecated Use getStrikethrough() instead.
|
||||
* @return boolean
|
||||
*/
|
||||
public function getStriketrough() {
|
||||
return $this->getStrikethrough();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Striketrough
|
||||
*
|
||||
* @deprecated Use setStrikethrough() instead.
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setStriketrough($pValue = false) {
|
||||
$this->setStrikethrough($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Strikethrough
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getStrikethrough() {
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Strikethrough
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setStrikethrough($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_strikethrough = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->_color = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_name
|
||||
. $this->_size
|
||||
. ($this->_bold ? 't' : 'f')
|
||||
. ($this->_italic ? 't' : 'f')
|
||||
. ($this->_superScript ? 't' : 'f')
|
||||
. ($this->_subScript ? 't' : 'f')
|
||||
. $this->_underline
|
||||
. ($this->_strikethrough ? 't' : 'f')
|
||||
. $this->_color->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,331 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Color */
|
||||
require_once 'PHPPowerPoint/Style/Color.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Border
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Border implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Border style */
|
||||
const BORDER_NONE = 'none';
|
||||
const BORDER_DASHDOT = 'dashDot';
|
||||
const BORDER_DASHDOTDOT = 'dashDotDot';
|
||||
const BORDER_DASHED = 'dashed';
|
||||
const BORDER_DOTTED = 'dotted';
|
||||
const BORDER_DOUBLE = 'double';
|
||||
const BORDER_HAIR = 'hair';
|
||||
const BORDER_MEDIUM = 'medium';
|
||||
const BORDER_MEDIUMDASHDOT = 'mediumDashDot';
|
||||
const BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot';
|
||||
const BORDER_MEDIUMDASHED = 'mediumDashed';
|
||||
const BORDER_SLANTDASHDOT = 'slantDashDot';
|
||||
const BORDER_THICK = 'thick';
|
||||
const BORDER_THIN = 'thin';
|
||||
|
||||
/**
|
||||
* Border style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderStyle;
|
||||
|
||||
/**
|
||||
* Border color
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Color
|
||||
*/
|
||||
private $_borderColor;
|
||||
|
||||
/**
|
||||
* Parent
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Parent Property Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_parentPropertyName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_borderStyle = PHPPowerPoint_Style_Border::BORDER_NONE;
|
||||
$this->_borderColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Prepare bind
|
||||
*
|
||||
* Configures this object for late binding as a property of a parent object
|
||||
*
|
||||
* @param $parent
|
||||
* @param $parentPropertyName
|
||||
*/
|
||||
public function propertyPrepareBind($parent, $parentPropertyName)
|
||||
{
|
||||
// Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object
|
||||
// is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references.
|
||||
$this->_parent = $parent;
|
||||
$this->_parentPropertyName = $parentPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Get Bound
|
||||
*
|
||||
* Returns the PHPPowerPoint_Style_Border that is actual bound to PHPPowerPoint_Style_Borders
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private function propertyGetBound() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
{
|
||||
switch($this->_parentPropertyName) // Another one is bound
|
||||
{
|
||||
case "_left":
|
||||
return $this->_parent->getLeft();
|
||||
|
||||
case "_right":
|
||||
return $this->_parent->getRight();
|
||||
|
||||
case "_top":
|
||||
return $this->_parent->getTop();
|
||||
|
||||
case "_bottom":
|
||||
return $this->_parent->getBottom();
|
||||
|
||||
case "_diagonal":
|
||||
return $this->_parent->getDiagonal();
|
||||
|
||||
case "_vertical":
|
||||
return $this->_parent->getVertical();
|
||||
|
||||
case "_horizontal":
|
||||
return $this->_parent->getHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
return $this; // No one is bound yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Begin Bind
|
||||
*
|
||||
* If no PHPPowerPoint_Style_Border has been bound to PHPPowerPoint_Style_Borders then bind this one. Return the actual bound one.
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private function propertyBeginBind() {
|
||||
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am already bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
{
|
||||
switch($this->_parentPropertyName) // Another one is already bound
|
||||
{
|
||||
case "_left":
|
||||
return $this->_parent->getLeft();
|
||||
|
||||
case "_right":
|
||||
return $this->_parent->getRight();
|
||||
|
||||
case "_top":
|
||||
return $this->_parent->getTop();
|
||||
|
||||
case "_bottom":
|
||||
return $this->_parent->getBottom();
|
||||
|
||||
case "_diagonal":
|
||||
return $this->_parent->getDiagonal();
|
||||
|
||||
case "_vertical":
|
||||
return $this->_parent->getVertical();
|
||||
|
||||
case "_horizontal":
|
||||
return $this->_parent->getHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
|
||||
$this->_parent = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
|
||||
* array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if (array_key_exists('style', $pStyles)) {
|
||||
$this->setBorderStyle($pStyles['style']);
|
||||
}
|
||||
if (array_key_exists('color', $pStyles)) {
|
||||
$this->getColor()->applyFromArray($pStyles['color']);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderStyle() {
|
||||
return $this->propertyGetBound()->_borderStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border style
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBorderStyle($pValue = PHPPowerPoint_Style_Border::BORDER_NONE) {
|
||||
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Border::BORDER_NONE;
|
||||
}
|
||||
$this->propertyBeginBind()->_borderStyle = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Border Color
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Color
|
||||
*/
|
||||
public function getColor() {
|
||||
// It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
|
||||
// So bind as an assurance.
|
||||
return $this->propertyBeginBind()->_borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Border Color
|
||||
*
|
||||
* @param PHPPowerPoint_Style_Color $pValue
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setColor(PHPPowerPoint_Style_Color $pValue = null) {
|
||||
$this->propertyBeginBind()->_borderColor = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$property = $this->propertyGetBound();
|
||||
return md5(
|
||||
$property->_borderStyle
|
||||
. $property->_borderColor->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,577 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Style_Border */
|
||||
require_once 'PHPPowerPoint/Style/Border.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Style_Borders
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Style
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Style_Borders implements PHPPowerPoint_IComparable
|
||||
{
|
||||
/* Diagonal directions */
|
||||
const DIAGONAL_NONE = 0;
|
||||
const DIAGONAL_UP = 1;
|
||||
const DIAGONAL_DOWN = 2;
|
||||
|
||||
/**
|
||||
* Left
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_left;
|
||||
|
||||
/**
|
||||
* Right
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_right;
|
||||
|
||||
/**
|
||||
* Top
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_top;
|
||||
|
||||
/**
|
||||
* Bottom
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_bottom;
|
||||
|
||||
/**
|
||||
* Diagonal
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_diagonal;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
*
|
||||
* @var PHPPowerPoint_Style_Border
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
/**
|
||||
* DiagonalDirection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_diagonalDirection;
|
||||
|
||||
/**
|
||||
* Outline, defaults to true
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_outline;
|
||||
|
||||
/**
|
||||
* Parent
|
||||
*
|
||||
* @var PHPPowerPoint_Style
|
||||
*/
|
||||
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
* @var _parentPropertyName string
|
||||
*/
|
||||
private $_parentPropertyName;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
|
||||
/**
|
||||
* The following properties are late bound. Binding is initiated by property classes when they are modified.
|
||||
*
|
||||
* _left
|
||||
* _right
|
||||
* _top
|
||||
* _bottom
|
||||
* _diagonal
|
||||
* _vertical
|
||||
* _horizontal
|
||||
*
|
||||
*/
|
||||
|
||||
$this->_diagonalDirection = PHPPowerPoint_Style_Borders::DIAGONAL_NONE;
|
||||
$this->_outline = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Prepare bind
|
||||
*
|
||||
* Configures this object for late binding as a property of a parent object
|
||||
*
|
||||
* @param $parent
|
||||
* @param $parentPropertyName
|
||||
*/
|
||||
public function propertyPrepareBind($parent, $parentPropertyName)
|
||||
{
|
||||
// Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object
|
||||
// is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references.
|
||||
$this->_parent = $parent;
|
||||
$this->_parentPropertyName = $parentPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Get Bound
|
||||
*
|
||||
* Returns the PHPPowerPoint_Style_Borders that is actual bound to PHPPowerPoint_Style
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private function propertyGetBound() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
return $this->_parent->getBorders(); // Another one is bound
|
||||
|
||||
return $this; // No one is bound yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Begin Bind
|
||||
*
|
||||
* If no PHPPowerPoint_Style_Borders has been bound to PHPPowerPoint_Style then bind this one. Return the actual bound one.
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Borders
|
||||
*/
|
||||
private function propertyBeginBind() {
|
||||
if(!isset($this->_parent))
|
||||
return $this; // I am already bound
|
||||
|
||||
if($this->_parent->propertyIsBound($this->_parentPropertyName))
|
||||
return $this->_parent->getBorders(); // Another one is already bound
|
||||
|
||||
$this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself
|
||||
$this->_parent = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Property Complete Bind
|
||||
*
|
||||
* Complete the binding process a child property object started
|
||||
*
|
||||
* @param $propertyObject
|
||||
* @param $propertyName Name of this property in the parent object
|
||||
*/
|
||||
public function propertyCompleteBind($propertyObject, $propertyName) {
|
||||
switch($propertyName) {
|
||||
case "_left":
|
||||
$this->propertyBeginBind()->_left = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_right":
|
||||
$this->propertyBeginBind()->_right = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_top":
|
||||
$this->propertyBeginBind()->_top = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_bottom":
|
||||
$this->propertyBeginBind()->_bottom = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_diagonal":
|
||||
$this->propertyBeginBind()->_diagonal = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_vertical":
|
||||
$this->propertyBeginBind()->_vertical = $propertyObject;
|
||||
break;
|
||||
|
||||
case "_horizontal":
|
||||
$this->propertyBeginBind()->_horizontal = $propertyObject;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Invalid property passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Property Is Bound
|
||||
*
|
||||
* Determines if a child property is bound to this one
|
||||
*
|
||||
* @param $propertyName Name of this property in the parent object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function propertyIsBound($propertyName) {
|
||||
switch($propertyName) {
|
||||
case "_left":
|
||||
return isset($this->propertyGetBound()->_left);
|
||||
|
||||
case "_right":
|
||||
return isset($this->propertyGetBound()->_right);
|
||||
|
||||
case "_top":
|
||||
return isset($this->propertyGetBound()->_top);
|
||||
|
||||
case "_bottom":
|
||||
return isset($this->propertyGetBound()->_bottom);
|
||||
|
||||
case "_diagonal":
|
||||
return isset($this->propertyGetBound()->_diagonal);
|
||||
|
||||
case "_vertical":
|
||||
return isset($this->propertyGetBound()->_vertical);
|
||||
|
||||
case "_horizontal":
|
||||
return isset($this->propertyGetBound()->_horizontal);
|
||||
|
||||
default:
|
||||
throw new Exception("Invalid property passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
|
||||
* array(
|
||||
* 'bottom' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* ),
|
||||
* 'top' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
* <code>
|
||||
* $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
|
||||
* array(
|
||||
* 'allborders' => array(
|
||||
* 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if (array_key_exists('allborders', $pStyles)) {
|
||||
$this->getLeft()->applyFromArray($pStyles['allborders']);
|
||||
$this->getRight()->applyFromArray($pStyles['allborders']);
|
||||
$this->getTop()->applyFromArray($pStyles['allborders']);
|
||||
$this->getBottom()->applyFromArray($pStyles['allborders']);
|
||||
}
|
||||
if (array_key_exists('left', $pStyles)) {
|
||||
$this->getLeft()->applyFromArray($pStyles['left']);
|
||||
}
|
||||
if (array_key_exists('right', $pStyles)) {
|
||||
$this->getRight()->applyFromArray($pStyles['right']);
|
||||
}
|
||||
if (array_key_exists('top', $pStyles)) {
|
||||
$this->getTop()->applyFromArray($pStyles['top']);
|
||||
}
|
||||
if (array_key_exists('bottom', $pStyles)) {
|
||||
$this->getBottom()->applyFromArray($pStyles['bottom']);
|
||||
}
|
||||
if (array_key_exists('diagonal', $pStyles)) {
|
||||
$this->getDiagonal()->applyFromArray($pStyles['diagonal']);
|
||||
}
|
||||
if (array_key_exists('vertical', $pStyles)) {
|
||||
$this->getVertical()->applyFromArray($pStyles['vertical']);
|
||||
}
|
||||
if (array_key_exists('horizontal', $pStyles)) {
|
||||
$this->getHorizontal()->applyFromArray($pStyles['horizontal']);
|
||||
}
|
||||
if (array_key_exists('diagonaldirection', $pStyles)) {
|
||||
$this->setDiagonalDirection($pStyles['diagonaldirection']);
|
||||
}
|
||||
if (array_key_exists('outline', $pStyles)) {
|
||||
$this->setOutline($pStyles['outline']);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Left
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getLeft() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_left))
|
||||
return $property->_left;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_left");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Right
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getRight() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_right))
|
||||
return $property->_right;
|
||||
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_right");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getTop() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_top))
|
||||
return $property->_top;
|
||||
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_top");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getBottom() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_bottom))
|
||||
return $property->_bottom;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_bottom");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Diagonal
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getDiagonal() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_diagonal))
|
||||
return $property->_diagonal;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_diagonal");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getVertical() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_vertical))
|
||||
return $property->_vertical;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_vertical");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return PHPPowerPoint_Style_Border
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
$property = $this->propertyGetBound();
|
||||
if(isset($property->_horizontal))
|
||||
return $property->_horizontal;
|
||||
|
||||
$property = new PHPPowerPoint_Style_Border();
|
||||
$property->propertyPrepareBind($this, "_horizontal");
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DiagonalDirection
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiagonalDirection() {
|
||||
return $this->propertyGetBound()->_diagonalDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set DiagonalDirection
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setDiagonalDirection($pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE;
|
||||
}
|
||||
$this->propertyBeginBind()->_diagonalDirection = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Outline
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOutline() {
|
||||
return $this->propertyGetBound()->_outline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Outline
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setOutline($pValue = true) {
|
||||
if ($pValue == '') {
|
||||
$pValue = true;
|
||||
}
|
||||
$this->propertyBeginBind()->_outline = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$property = $this->propertyGetBound();
|
||||
return md5(
|
||||
$property->getLeft()->getHashCode()
|
||||
. $property->getRight()->getHashCode()
|
||||
. $property->getTop()->getHashCode()
|
||||
. $property->getBottom()->getHashCode()
|
||||
. $property->getDiagonal()->getHashCode()
|
||||
. $property->getVertical()->getHashCode()
|
||||
. $property->getHorizontal()->getHashCode()
|
||||
. $property->getDiagonalDirection()
|
||||
. ($property->getOutline() ? 't' : 'f')
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_IWriter
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
interface PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null);
|
||||
}
|
@ -1,411 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_HashTable */
|
||||
require_once 'PHPPowerPoint/HashTable.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_ContentTypes */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_DocProps */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/DocProps.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Rels */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Rels.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Theme */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Theme.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Presentation */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Presentation.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Slide */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_Drawing */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_LayoutPack */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_LayoutPack_Default */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007 implements PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Office2003 compatibility
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_office2003compatibility = false;
|
||||
|
||||
/**
|
||||
* Private writer parts
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_PowerPoint2007_WriterPart[]
|
||||
*/
|
||||
private $_writerParts;
|
||||
|
||||
/**
|
||||
* Private PHPPowerPoint
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_presentation;
|
||||
|
||||
/**
|
||||
* Private unique PHPPowerPoint_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPPowerPoint_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useDiskCaching = false;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_diskCachingDirectory;
|
||||
|
||||
/**
|
||||
* Layout pack to use
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*/
|
||||
private $_layoutPack;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Writer_PowerPoint2007
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Assign PHPPowerPoint
|
||||
$this->setPHPPowerPoint($pPHPPowerPoint);
|
||||
|
||||
// Set up disk caching location
|
||||
$this->_diskCachingDirectory = './';
|
||||
|
||||
// Set layout pack
|
||||
$this->_layoutPack = new PHPPowerPoint_Writer_PowerPoint2007_LayoutPack_Default();
|
||||
|
||||
// Initialise writer parts
|
||||
$this->_writerParts['contenttypes'] = new PHPPowerPoint_Writer_PowerPoint2007_ContentTypes();
|
||||
$this->_writerParts['docprops'] = new PHPPowerPoint_Writer_PowerPoint2007_DocProps();
|
||||
$this->_writerParts['rels'] = new PHPPowerPoint_Writer_PowerPoint2007_Rels();
|
||||
$this->_writerParts['theme'] = new PHPPowerPoint_Writer_PowerPoint2007_Theme();
|
||||
$this->_writerParts['presentation'] = new PHPPowerPoint_Writer_PowerPoint2007_Presentation();
|
||||
$this->_writerParts['slide'] = new PHPPowerPoint_Writer_PowerPoint2007_Slide();
|
||||
$this->_writerParts['drawing'] = new PHPPowerPoint_Writer_PowerPoint2007_Drawing();
|
||||
|
||||
// Assign parent IWriter
|
||||
foreach ($this->_writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
}
|
||||
|
||||
// Set HashTable variables
|
||||
$this->_drawingHashTable = new PHPPowerPoint_HashTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '') {
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_presentation)) {
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam('./', 'phppttmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// Create drawing dictionary
|
||||
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_presentation) );
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add [Content_Types].xml to ZIP file
|
||||
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_presentation));
|
||||
|
||||
// Add relationships to ZIP file
|
||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_presentation));
|
||||
$objZip->addFromString('ppt/_rels/presentation.xml.rels', $this->getWriterPart('Rels')->writePresentationRelationships($this->_presentation));
|
||||
|
||||
// Add document properties to ZIP file
|
||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_presentation));
|
||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_presentation));
|
||||
|
||||
// Add theme to ZIP file
|
||||
$objZip->addFromString('ppt/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_presentation));
|
||||
|
||||
// Add slide master to ZIP file
|
||||
$masterSlide = $this->getLayoutPack()->getMasterSlide();
|
||||
$objZip->addFromString('ppt/slideMasters/_rels/slideMaster1.xml.rels', $this->getWriterPart('Rels')->writeSlideMasterRelationships());
|
||||
$objZip->addFromString('ppt/slideMasters/slideMaster1.xml', $masterSlide['body']);
|
||||
|
||||
// Add slide layouts to ZIP file
|
||||
$slideLayouts = $this->getLayoutPack()->getLayouts();
|
||||
for ($i = 0; $i < count($slideLayouts); ++$i) {
|
||||
$objZip->addFromString('ppt/slideLayouts/_rels/slideLayout' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideLayoutRelationships());
|
||||
$objZip->addFromString('ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', $slideLayouts[$i]['body']);
|
||||
}
|
||||
|
||||
// Add presentation to ZIP file
|
||||
$objZip->addFromString('ppt/presentation.xml', $this->getWriterPart('Presentation')->writePresentation($this->_presentation));
|
||||
|
||||
// Add slides (drawings, ...)
|
||||
for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) {
|
||||
// Add slide
|
||||
$objZip->addFromString('ppt/slides/slide' . ($i + 1) . '.xml', $this->getWriterPart('Slide')->writeSlide($this->_presentation->getSlide($i)));
|
||||
}
|
||||
|
||||
// Add slide relationships (drawings, ...)
|
||||
for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) {
|
||||
// Add relationships
|
||||
$objZip->addFromString('ppt/slides/_rels/slide' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideRelationships($this->_presentation->getSlide($i), ($i + 1)));
|
||||
}
|
||||
|
||||
// Add media
|
||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) {
|
||||
$imageContents = null;
|
||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||
|
||||
if (strpos($imagePath, 'zip://') !== false) {
|
||||
$imagePath = substr($imagePath, 6);
|
||||
$imagePathSplitted = explode('#', $imagePath);
|
||||
|
||||
$imageZip = new ZipArchive();
|
||||
$imageZip->open($imagePathSplitted[0]);
|
||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
} else {
|
||||
$imageContents = file_get_contents($imagePath);
|
||||
}
|
||||
|
||||
$objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
if ($originalFilename != $pFilename) {
|
||||
if (copy($pFilename, $originalFilename) === false) {
|
||||
throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||
}
|
||||
@unlink($pFilename);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("PHPPowerPoint object unassigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPPowerPoint() {
|
||||
if (!is_null($this->_presentation)) {
|
||||
return $this->_presentation;
|
||||
} else {
|
||||
throw new Exception("No PHPPowerPoint assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) {
|
||||
$this->_presentation = $pPHPPowerPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPPowerPoint_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Office2003 compatibility
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOffice2003Compatibility() {
|
||||
return $this->_office2003compatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pre-Calculate Formulas
|
||||
*
|
||||
* @param boolean $pValue Office2003 compatibility?
|
||||
*/
|
||||
public function setOffice2003Compatibility($pValue = false) {
|
||||
$this->_office2003compatibility = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching() {
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws Exception Exception when directory does not exist
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
||||
if (!is_null($pDirectory)) {
|
||||
if (is_dir($pDirectory)) {
|
||||
$this->_diskCachingDirectory = $pDirectory;
|
||||
} else {
|
||||
throw new Exception("Directory does not exist: $pDirectory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory() {
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout pack to use
|
||||
*
|
||||
* @return PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*/
|
||||
public function getLayoutPack() {
|
||||
return $this->_layoutPack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layout pack to use
|
||||
*
|
||||
* @param PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue
|
||||
*/
|
||||
public function setLayoutPack(PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue = null) {
|
||||
$this->_layoutPack = $pValue;
|
||||
}
|
||||
}
|
@ -1,219 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_File */
|
||||
require_once 'PHPPowerPoint/Shared/File.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_ContentTypes
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_ContentTypes extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write content types to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeContentTypes(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Types
|
||||
$objWriter->startElement('Types');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
);
|
||||
|
||||
// Theme
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// Presentation
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/presentation.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml'
|
||||
);
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
// Slide master
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slideMasters/slideMaster1.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml'
|
||||
);
|
||||
|
||||
// Slide layouts
|
||||
$slideLayouts = $this->getParentWriter()->getLayoutPack()->getLayouts();
|
||||
for ($i = 0; $i < count($slideLayouts); ++$i) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/ppt/slides/slide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Add media content-types
|
||||
$aMediaContentTypes = array();
|
||||
$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
|
||||
for ($i = 0; $i < $mediaCount; ++$i) {
|
||||
$extension = '';
|
||||
$mimeType = '';
|
||||
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||
}
|
||||
|
||||
if (!isset( $aMediaContentTypes[$extension]) ) {
|
||||
$aMediaContentTypes[$extension] = $mimeType;
|
||||
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, $extension, $mimeType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPPowerPoint_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_DocProps
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_DocProps extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write docProps/app.xml to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeDocPropsApp(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
|
||||
// Application
|
||||
$objWriter->writeElement('Application', 'Microsoft Office PowerPoint');
|
||||
|
||||
// Slides
|
||||
$objWriter->writeElement('Slides', $pPHPPowerPoint->getSlideCount());
|
||||
|
||||
// ScaleCrop
|
||||
$objWriter->writeElement('ScaleCrop', 'false');
|
||||
|
||||
// HeadingPairs
|
||||
$objWriter->startElement('HeadingPairs');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '4');
|
||||
$objWriter->writeAttribute('baseType', 'variant');
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Theme');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Slide Titles');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// TitlesOfParts
|
||||
$objWriter->startElement('TitlesOfParts');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '1');
|
||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||
|
||||
$objWriter->writeElement('vt:lpstr', 'Office Theme');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Company
|
||||
$objWriter->writeElement('Company', 'Microsoft Corporation');
|
||||
|
||||
// LinksUpToDate
|
||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||
|
||||
// SharedDoc
|
||||
$objWriter->writeElement('SharedDoc', 'false');
|
||||
|
||||
// HyperlinksChanged
|
||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||
|
||||
// AppVersion
|
||||
$objWriter->writeElement('AppVersion', '12.0000');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write docProps/core.xml to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeDocPropsCore(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPPowerPoint->getProperties()->getCreator());
|
||||
|
||||
// cp:lastModifiedBy
|
||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPPowerPoint->getProperties()->getLastModifiedBy());
|
||||
|
||||
// dcterms:created
|
||||
$objWriter->startElement('dcterms:created');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getCreated()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dcterms:modified
|
||||
$objWriter->startElement('dcterms:modified');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getModified()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPPowerPoint->getProperties()->getTitle());
|
||||
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPPowerPoint->getProperties()->getDescription());
|
||||
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPPowerPoint->getProperties()->getSubject());
|
||||
|
||||
// cp:keywords
|
||||
$objWriter->writeElement('cp:keywords', $pPHPPowerPoint->getProperties()->getKeywords());
|
||||
|
||||
// cp:category
|
||||
$objWriter->writeElement('cp:category', $pPHPPowerPoint->getProperties()->getCategory());
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Drawing */
|
||||
require_once 'PHPPowerPoint/Shared/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Drawing
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Drawing extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Get an array of all drawings
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return PHPPowerPoint_Slide_Drawing[] All drawings in PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function allDrawings(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Get an array of all drawings
|
||||
$aDrawings = array();
|
||||
|
||||
// Loop trough PHPPowerPoint
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
// Loop trough images and add to array
|
||||
$iterator = $pPHPPowerPoint->getSlide($i)->getShapeCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current() instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$aDrawings[] = $iterator->current();
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
return $aDrawings;
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Writer_PowerPoint2007_LayoutPack
|
||||
{
|
||||
/**
|
||||
* Master slide.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_masterSlide = array();
|
||||
|
||||
/**
|
||||
* Array of slide layouts.
|
||||
*
|
||||
* These are all an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_layouts = array();
|
||||
|
||||
/**
|
||||
* Get master slide.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMasterSlide()
|
||||
{
|
||||
return $this->_masterSlide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of slide layouts.
|
||||
*
|
||||
* These are all an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLayouts()
|
||||
{
|
||||
return $this->_layouts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find specific slide layout.
|
||||
*
|
||||
* This is an array consisting of:
|
||||
* - name (string)
|
||||
* - body (string)
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function findLayout($name = '')
|
||||
{
|
||||
foreach ($this->_layouts as $layout)
|
||||
{
|
||||
if ($layout['name'] == $name)
|
||||
{
|
||||
return $layout;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not find slide layout $name in current layout pack.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find specific slide layout index.
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function findLayoutIndex($name = '')
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($this->_layouts as $layout)
|
||||
{
|
||||
if ($layout['name'] == $name)
|
||||
{
|
||||
return $i;
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
throw new Exception("Could not find slide layout $name in current layout pack.");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,151 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Workbook
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Presentation extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write presentation to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writePresentation(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// p:presentation
|
||||
$objWriter->startElement('p:presentation');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
|
||||
|
||||
// p:sldMasterIdLst
|
||||
$objWriter->startElement('p:sldMasterIdLst');
|
||||
|
||||
// p:sldMasterId
|
||||
$objWriter->startElement('p:sldMasterId');
|
||||
$objWriter->writeAttribute('id', '2147483648');
|
||||
$objWriter->writeAttribute('r:id', 'rId1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:sldIdLst
|
||||
$objWriter->startElement('p:sldIdLst');
|
||||
$this->_writeSlides($objWriter, $pPHPPowerPoint);
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:sldSz
|
||||
$objWriter->startElement('p:sldSz');
|
||||
$objWriter->writeAttribute('cx', '9144000');
|
||||
$objWriter->writeAttribute('cy', '6858000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:notesSz
|
||||
$objWriter->startElement('p:notesSz');
|
||||
$objWriter->writeAttribute('cx', '6858000');
|
||||
$objWriter->writeAttribute('cy', '9144000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slides
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSlides(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Write slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
// p:sldId
|
||||
$this->_writeSlide(
|
||||
$objWriter,
|
||||
($i + 256),
|
||||
($i + 1 + 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pSlideId Slide id
|
||||
* @param int $pRelId Relationship ID
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSlide(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pSlideId = 1, $pRelId = 1)
|
||||
{
|
||||
// p:sldId
|
||||
$objWriter->startElement('p:sldId');
|
||||
$objWriter->writeAttribute('id', $pSlideId);
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
@ -1,347 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Rels
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Rels extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write relationships to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeRelationships(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
'docProps/app.xml'
|
||||
);
|
||||
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
'docProps/core.xml'
|
||||
);
|
||||
|
||||
// Relationship ppt/presentation.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
'ppt/presentation.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write presentation relationships to XML format
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writePresentationRelationships(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship slideMasters/slideMaster1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
|
||||
'slideMasters/slideMaster1.xml'
|
||||
);
|
||||
|
||||
// Relationship theme/theme1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationships with slides
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
($i + 1 + 2),
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide',
|
||||
'slides/slide' . ($i + 1) . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide master relationships to XML format
|
||||
*
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideMasterRelationships()
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Write slideLayout relationships
|
||||
$layoutPack = $this->getParentWriter()->getLayoutPack();
|
||||
for ($i = 0; $i < count($layoutPack->getLayouts()); ++$i) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$i + 1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout',
|
||||
'../slideLayouts/slideLayout' . ($i + 1) . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Relationship theme/theme1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
count($layoutPack->getLayouts()) + 1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'../theme/theme1.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide layout relationships to XML format
|
||||
*
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideLayoutRelationships()
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Write slideMaster relationship
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
|
||||
'../slideMasters/slideMaster1.xml'
|
||||
);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write slide relationships to XML format
|
||||
*
|
||||
* Numbering is as follows:
|
||||
* rId1 - Drawings
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pSlide
|
||||
* @param int $pSlideId
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null, $pSlideId = 1)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Starting relation id
|
||||
$relId = 1;
|
||||
|
||||
// Write slideLayout relationship
|
||||
$layoutPack = $this->getParentWriter()->getLayoutPack();
|
||||
$layoutIndex = $layoutPack->findlayoutIndex( $pSlide->getSlideLayout() );
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relId++,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout',
|
||||
'../slideLayouts/slideLayout' . ($layoutIndex + 1) . '.xml'
|
||||
);
|
||||
|
||||
// Write drawing relationships?
|
||||
if ($pSlide->getShapeCollection()->count() > 0) {
|
||||
// Loop trough images and write relationships
|
||||
$iterator = $pSlide->getShapeCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current() instanceof PHPPowerPoint_Shape_Drawing
|
||||
|| $iterator->current() instanceof PHPPowerPoint_Shape_MemoryDrawing) {
|
||||
// Write relationship for image drawing
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
|
||||
);
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
++$relId;
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pId Relationship ID. rId will be prepended!
|
||||
* @param string $pType Relationship type
|
||||
* @param string $pTarget Relationship target
|
||||
* @param string $pTargetMode Relationship target mode
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeRelationship(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', 'rId' . $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,520 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007 */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
|
||||
|
||||
/** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
|
||||
require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_Shape */
|
||||
require_once 'PHPPowerPoint/Shape.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_RichText */
|
||||
require_once 'PHPPowerPoint/Shape/RichText.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_BaseDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_Drawing */
|
||||
require_once 'PHPPowerPoint/Shape/Drawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shape_MemoryDrawing */
|
||||
require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_Font */
|
||||
require_once 'PHPPowerPoint/Shared/Font.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_String */
|
||||
require_once 'PHPPowerPoint/Shared/String.php';
|
||||
|
||||
/** PHPPowerPoint_Shared_XMLWriter */
|
||||
require_once 'PHPPowerPoint/Shared/XMLWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_Slide
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_PowerPoint2007_Slide extends PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write slide to XML format
|
||||
*
|
||||
* @param PHPPowerPoint_Slide $pSlide
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
public function writeSlide(PHPPowerPoint_Slide $pSlide = null)
|
||||
{
|
||||
// Check slide
|
||||
if (is_null($pSlide))
|
||||
throw new Exception("Invalid PHPPowerPoint_Slide object passed.");
|
||||
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// p:sld
|
||||
$objWriter->startElement('p:sld');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
|
||||
|
||||
// p:cSld
|
||||
$objWriter->startElement('p:cSld');
|
||||
|
||||
// p:spTree
|
||||
$objWriter->startElement('p:spTree');
|
||||
|
||||
// p:nvGrpSpPr
|
||||
$objWriter->startElement('p:nvGrpSpPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', '1');
|
||||
$objWriter->writeAttribute('name', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvGrpSpPr
|
||||
$objWriter->writeElement('p:cNvGrpSpPr', null);
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:grpSpPr
|
||||
$objWriter->startElement('p:grpSpPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', '0');
|
||||
$objWriter->writeAttribute('y', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', '0');
|
||||
$objWriter->writeAttribute('cy', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:chOff
|
||||
$objWriter->startElement('a:chOff');
|
||||
$objWriter->writeAttribute('x', '0');
|
||||
$objWriter->writeAttribute('y', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:chExt
|
||||
$objWriter->startElement('a:chExt');
|
||||
$objWriter->writeAttribute('cx', '0');
|
||||
$objWriter->writeAttribute('cy', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop shapes
|
||||
$shapeId = 0;
|
||||
$relationId = 1;
|
||||
$shapes = $pSlide->getShapeCollection();
|
||||
foreach ($shapes as $shape)
|
||||
{
|
||||
// Increment $shapeId
|
||||
++$shapeId;
|
||||
|
||||
// Check type
|
||||
if ($shape instanceof PHPPowerPoint_Shape_BaseDrawing)
|
||||
{
|
||||
// Picture --> $relationId
|
||||
++$relationId;
|
||||
|
||||
$this->_writePic($objWriter, $shape, $shapeId, $relationId);
|
||||
}
|
||||
else if ($shape instanceof PHPPowerPoint_Shape_RichText)
|
||||
{
|
||||
$this->_writeTxt($objWriter, $shape, $shapeId);
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:clrMapOvr
|
||||
$objWriter->startElement('p:clrMapOvr');
|
||||
|
||||
// a:masterClrMapping
|
||||
$objWriter->writeElement('a:masterClrMapping', '');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write pic
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint_Shape_BaseDrawing $shape
|
||||
* @param int $shapeId
|
||||
* @param int $relationId
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writePic(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_BaseDrawing $shape = null, $shapeId, $relationId)
|
||||
{
|
||||
// p:pic
|
||||
$objWriter->startElement('p:pic');
|
||||
|
||||
// p:nvPicPr
|
||||
$objWriter->startElement('p:nvPicPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('name', $shape->getName());
|
||||
$objWriter->writeAttribute('descr', $shape->getDescription());
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvPicPr
|
||||
$objWriter->startElement('p:cNvPicPr');
|
||||
|
||||
// a:picLocks
|
||||
$objWriter->startElement('a:picLocks');
|
||||
$objWriter->writeAttribute('noChangeAspect', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:blipFill
|
||||
$objWriter->startElement('p:blipFill');
|
||||
|
||||
// a:blip
|
||||
$objWriter->startElement('a:blip');
|
||||
$objWriter->writeAttribute('r:embed', 'rId' . $relationId);
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:stretch
|
||||
$objWriter->startElement('a:stretch');
|
||||
$objWriter->writeElement('a:fillRect', null);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:spPr
|
||||
$objWriter->startElement('p:spPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
$objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation()));
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX()));
|
||||
$objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth()));
|
||||
$objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight()));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstGeom
|
||||
$objWriter->startElement('a:prstGeom');
|
||||
$objWriter->writeAttribute('prst', 'rect');
|
||||
|
||||
// a:avLst
|
||||
$objWriter->writeElement('a:avLst', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
if ($shape->getShadow()->getVisible()) {
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius()));
|
||||
$objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance()));
|
||||
$objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection()));
|
||||
$objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment());
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB());
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write txt
|
||||
*
|
||||
* @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPPowerPoint_Shape_RichText $shape
|
||||
* @param int $shapeId
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeTxt(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_RichText $shape = null, $shapeId)
|
||||
{
|
||||
// p:sp
|
||||
$objWriter->startElement('p:sp');
|
||||
|
||||
// p:nvSpPr
|
||||
$objWriter->startElement('p:nvSpPr');
|
||||
|
||||
// p:cNvPr
|
||||
$objWriter->startElement('p:cNvPr');
|
||||
$objWriter->writeAttribute('id', $shapeId);
|
||||
$objWriter->writeAttribute('name', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:cNvSpPr
|
||||
$objWriter->startElement('p:cNvSpPr');
|
||||
$objWriter->writeAttribute('txBox', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:nvPr
|
||||
$objWriter->writeElement('p:nvPr', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:spPr
|
||||
$objWriter->startElement('p:spPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
$objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation()));
|
||||
|
||||
// a:off
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX()));
|
||||
$objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ext
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth()));
|
||||
$objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight()));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstGeom
|
||||
$objWriter->startElement('a:prstGeom');
|
||||
$objWriter->writeAttribute('prst', 'rect');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:noFill
|
||||
$objWriter->writeElement('a:noFill', null);
|
||||
|
||||
if ($shape->getShadow()->getVisible()) {
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius()));
|
||||
$objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance()));
|
||||
$objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection()));
|
||||
$objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment());
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB());
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// p:txBody
|
||||
$objWriter->startElement('p:txBody');
|
||||
|
||||
// a:bodyPr
|
||||
$objWriter->startElement('a:bodyPr');
|
||||
$objWriter->writeAttribute('wrap', 'square');
|
||||
$objWriter->writeAttribute('rtlCol', '0');
|
||||
|
||||
// a:spAutoFit
|
||||
$objWriter->writeElement('a:spAutoFit', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lstStyle
|
||||
$objWriter->writeElement('a:lstStyle', null);
|
||||
|
||||
// a:p
|
||||
$objWriter->startElement('a:p');
|
||||
|
||||
// a:pPr
|
||||
$objWriter->startElement('a:pPr');
|
||||
$objWriter->writeAttribute('algn', $shape->getAlignment()->getHorizontal());
|
||||
$objWriter->writeAttribute('fontAlgn', $shape->getAlignment()->getVertical());
|
||||
$objWriter->writeAttribute('indent', $shape->getAlignment()->getIndent());
|
||||
$objWriter->writeAttribute('lvl', $shape->getAlignment()->getLevel());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop trough rich text elements
|
||||
$elements = $shape->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPPowerPoint_Shape_RichText_Break) {
|
||||
// a:br
|
||||
$objWriter->writeElement('a:br', null);
|
||||
}
|
||||
elseif ($element instanceof PHPPowerPoint_Shape_RichText_Run
|
||||
|| $element instanceof PHPPowerPoint_Shape_RichText_TextElement)
|
||||
{
|
||||
// a:r
|
||||
$objWriter->startElement('a:r');
|
||||
|
||||
// a:rPr
|
||||
if ($element instanceof PHPPowerPoint_Shape_RichText_Run) {
|
||||
// a:rPr
|
||||
$objWriter->startElement('a:rPr');
|
||||
|
||||
// Bold
|
||||
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 'true' : 'false'));
|
||||
|
||||
// Italic
|
||||
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 'true' : 'false'));
|
||||
|
||||
// Strikethrough
|
||||
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
|
||||
|
||||
// Size
|
||||
$objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100));
|
||||
|
||||
// Underline
|
||||
$objWriter->writeAttribute('u', $element->getFont()->getUnderline());
|
||||
|
||||
// Superscript / subscript
|
||||
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||
if ($element->getFont()->getSuperScript()) {
|
||||
$objWriter->writeAttribute('baseline', '30000');
|
||||
} else if ($element->getFont()->getSubScript()) {
|
||||
$objWriter->writeAttribute('baseline', '-25000');
|
||||
}
|
||||
}
|
||||
|
||||
// Color - a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $element->getFont()->getColor()->getRGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Font - a:latin
|
||||
$objWriter->startElement('a:latin');
|
||||
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// t
|
||||
$objWriter->startElement('a:t');
|
||||
$objWriter->writeRaw(PHPPowerPoint_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($element->getText()) ));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
<a:r>
|
||||
<a:rPr lang="en-US" dirty="0" err="1" smtClean="0" />
|
||||
</a:r>
|
||||
|
||||
*/
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer_PowerPoint2007
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
abstract class PHPPowerPoint_Writer_PowerPoint2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Parent IWriter object
|
||||
*
|
||||
* @var PHPPowerPoint_Writer_IWriter
|
||||
*/
|
||||
private $_parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPPowerPoint_Writer_IWriter $pWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setParentWriter(PHPPowerPoint_Writer_IWriter $pWriter = null) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent IWriter object
|
||||
*
|
||||
* @return PHPPowerPoint_Writer_IWriter
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getParentWriter() {
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent PHPPowerPoint_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPPowerPoint
|
||||
*
|
||||
* Copyright (c) 2009 - 2010 PHPPowerPoint
|
||||
*
|
||||
* 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 PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 0.1.0, 2009-04-27
|
||||
*/
|
||||
|
||||
|
||||
/** PHPPowerPoint */
|
||||
require_once 'PHPPowerPoint.php';
|
||||
|
||||
/** PHPPowerPoint_HashTable */
|
||||
require_once 'PHPPowerPoint/HashTable.php';
|
||||
|
||||
/** PHPPowerPoint_IComparable */
|
||||
require_once 'PHPPowerPoint/IComparable.php';
|
||||
|
||||
/** PHPPowerPoint_Slide */
|
||||
require_once 'PHPPowerPoint/Slide.php';
|
||||
|
||||
/** PHPPowerPoint_IWriter */
|
||||
require_once 'PHPPowerPoint/Writer/IWriter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPPowerPoint_Writer_Serialized
|
||||
*
|
||||
* @category PHPPowerPoint
|
||||
* @package PHPPowerPoint_Writer
|
||||
* @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
|
||||
*/
|
||||
class PHPPowerPoint_Writer_Serialized implements PHPPowerPoint_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Private PHPPowerPoint
|
||||
*
|
||||
* @var PHPPowerPoint
|
||||
*/
|
||||
private $_presentation;
|
||||
|
||||
/**
|
||||
* Create a new PHPPowerPoint_Writer_Serialized
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
*/
|
||||
public function __construct(PHPPowerPoint $pPHPPowerPoint = null)
|
||||
{
|
||||
// Assign PHPPowerPoint
|
||||
$this->setPHPPowerPoint($pPHPPowerPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPPowerPoint to file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if (!is_null($this->_presentation)) {
|
||||
// Create new ZIP file and open it for writing
|
||||
$objZip = new ZipArchive();
|
||||
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) {
|
||||
if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) {
|
||||
throw new Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add media
|
||||
$slideCount = $this->_presentation->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
for ($j = 0; $j < $this->_presentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$imgTemp = $this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add PHPPowerPoint.xml to the document, which represents a PHP serialized PHPPowerPoint object
|
||||
$objZip->addFromString('PHPPowerPoint.xml', $this->_writeSerialized($this->_presentation, $pFilename));
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
throw new Exception("Could not close zip file $pFilename.");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("PHPPowerPoint object unassigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @return PHPPowerPoint
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPHPPowerPoint() {
|
||||
if (!is_null($this->_presentation)) {
|
||||
return $this->_presentation;
|
||||
} else {
|
||||
throw new Exception("No PHPPowerPoint assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPPowerPoint object
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) {
|
||||
$this->_presentation = $pPHPPowerPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize PHPPowerPoint object to XML
|
||||
*
|
||||
* @param PHPPowerPoint $pPHPPowerPoint
|
||||
* @param string $pFilename
|
||||
* @return string XML Output
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _writeSerialized(PHPPowerPoint $pPHPPowerPoint = null, $pFilename = '')
|
||||
{
|
||||
// Clone $pPHPPowerPoint
|
||||
$pPHPPowerPoint = clone $pPHPPowerPoint;
|
||||
|
||||
// Update media links
|
||||
$slideCount = $pPHPPowerPoint->getSlideCount();
|
||||
for ($i = 0; $i < $slideCount; ++$i) {
|
||||
for ($j = 0; $j < $pPHPPowerPoint->getSlide($i)->getShapeCollection()->count(); ++$j) {
|
||||
if ($pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) {
|
||||
$imgTemp =& $pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j);
|
||||
$imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create XML writer
|
||||
$objWriter = new xmlWriter();
|
||||
$objWriter->openMemory();
|
||||
$objWriter->setIndent(true);
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// PHPPowerPoint
|
||||
$objWriter->startElement('PHPPowerPoint');
|
||||
$objWriter->writeAttribute('version', '0.1.0');
|
||||
|
||||
// Comment
|
||||
$objWriter->writeComment('This file has been generated using PHPPowerPoint v0.1.0 (http://www.codeplex.com/PHPPowerPoint). It contains a base64 encoded serialized version of the PHPPowerPoint internal object.');
|
||||
|
||||
// Data
|
||||
$objWriter->startElement('data');
|
||||
$objWriter->writeCData( base64_encode(serialize($pPHPPowerPoint)) );
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->outputMemory(true);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user