Permalink
Browse files

External repository import. CodePlex is master from now on.

git-svn-id: https://phppowerpoint.svn.codeplex.com/svn/trunk@50866 ffd33b8c-2492-42e0-bdc5-587b920b7d6d
  • Loading branch information...
0 parents commit 34c2b94f2577382842c74ae69a9436bc461221eb @maartenba maartenba committed Aug 31, 2010
Showing with 17,364 additions and 0 deletions.
  1. +4 −0 Build/build.bat
  2. +336 −0 Build/build.php
  3. +54 −0 Build/package.xml
  4. +288 −0 Classes/PHPPowerPoint.php
  5. +51 −0 Classes/PHPPowerPoint/Autoloader.php
  6. +345 −0 Classes/PHPPowerPoint/DocumentProperties.php
  7. +216 −0 Classes/PHPPowerPoint/HashTable.php
  8. +62 −0 Classes/PHPPowerPoint/IComparable.php
  9. +189 −0 Classes/PHPPowerPoint/IOFactory.php
  10. +53 −0 Classes/PHPPowerPoint/Reader/IReader.php
  11. +127 −0 Classes/PHPPowerPoint/Reader/Serialized.php
  12. +361 −0 Classes/PHPPowerPoint/Shape.php
  13. +280 −0 Classes/PHPPowerPoint/Shape/BaseDrawing.php
  14. +177 −0 Classes/PHPPowerPoint/Shape/Drawing.php
  15. +232 −0 Classes/PHPPowerPoint/Shape/MemoryDrawing.php
  16. +303 −0 Classes/PHPPowerPoint/Shape/RichText.php
  17. +83 −0 Classes/PHPPowerPoint/Shape/RichText/Break.php
  18. +64 −0 Classes/PHPPowerPoint/Shape/RichText/ITextElement.php
  19. +316 −0 Classes/PHPPowerPoint/Shape/RichText/Paragraph.php
  20. +102 −0 Classes/PHPPowerPoint/Shape/RichText/Run.php
  21. +108 −0 Classes/PHPPowerPoint/Shape/RichText/TextElement.php
  22. +319 −0 Classes/PHPPowerPoint/Shape/Shadow.php
  23. +169 −0 Classes/PHPPowerPoint/Shape/Table.php
  24. +454 −0 Classes/PHPPowerPoint/Shape/Table/Cell.php
  25. +237 −0 Classes/PHPPowerPoint/Shape/Table/Row.php
  26. +109 −0 Classes/PHPPowerPoint/Shared/Drawing.php
  27. +98 −0 Classes/PHPPowerPoint/Shared/File.php
  28. +67 −0 Classes/PHPPowerPoint/Shared/Font.php
  29. +270 −0 Classes/PHPPowerPoint/Shared/String.php
  30. +141 −0 Classes/PHPPowerPoint/Shared/XMLWriter.php
  31. +178 −0 Classes/PHPPowerPoint/Shared/ZipStreamWrapper.php
  32. +261 −0 Classes/PHPPowerPoint/Slide.php
  33. +50 −0 Classes/PHPPowerPoint/Slide/Layout.php
  34. +111 −0 Classes/PHPPowerPoint/SlideIterator.php
  35. +318 −0 Classes/PHPPowerPoint/Style/Alignment.php
  36. +244 −0 Classes/PHPPowerPoint/Style/Border.php
  37. +211 −0 Classes/PHPPowerPoint/Style/Borders.php
  38. +298 −0 Classes/PHPPowerPoint/Style/Bullet.php
  39. +170 −0 Classes/PHPPowerPoint/Style/Color.php
  40. +246 −0 Classes/PHPPowerPoint/Style/Fill.php
  41. +423 −0 Classes/PHPPowerPoint/Style/Font.php
  42. +45 −0 Classes/PHPPowerPoint/Writer/IWriter.php
  43. +417 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007.php
  44. +244 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php
  45. +205 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php
  46. +66 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php
  47. +210 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php
  48. +3,274 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php
  49. +175 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/TemplateBased.php
  50. +135 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php
  51. +410 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/Rels.php
  52. +925 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/Slide.php
  53. +1,207 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/Theme.php
  54. +68 −0 Classes/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php
  55. +173 −0 Classes/PHPPowerPoint/Writer/Serialized.php
  56. +51 −0 Documentation/assets/ClassDiagrams/Architecture.cd
  57. +57 −0 Documentation/assets/ClassDiagrams/ClassDiagrams.csproj
  58. +20 −0 Documentation/assets/ClassDiagrams/ClassDiagrams.sln
  59. +15 −0 Documentation/assets/ClassDiagrams/Classes/IReader.cs
  60. +15 −0 Documentation/assets/ClassDiagrams/Classes/IWriter.cs
  61. +40 −0 Documentation/assets/ClassDiagrams/Classes/PHPPowerPoint.cs
  62. +41 −0 Documentation/assets/ClassDiagrams/Classes/PHPPowerPoint_IOFactory.cs
  63. +25 −0 Documentation/assets/ClassDiagrams/Classes/PHPPowerPoint_Reader_Serialized.cs
  64. +25 −0 Documentation/assets/ClassDiagrams/Classes/PHPPowerPoint_Writer_PowerPoint2007.cs
  65. +25 −0 Documentation/assets/ClassDiagrams/Classes/PHPPowerPoint_Writer_Serialized.cs
  66. +14 −0 Documentation/assets/ClassDiagrams/Classes/Slide.cs
  67. BIN Documentation/assets/ClassDiagrams/Exports/Architecture.png
  68. BIN Documentation/assets/ClassDiagrams/Exports/ReaderWriter.png
  69. +71 −0 Documentation/assets/ClassDiagrams/ReaderWriter.cd
  70. +91 −0 Tests/01simple.php
  71. +256 −0 Tests/02presentation.php
  72. +100 −0 Tests/03serialized.php
  73. +85 −0 Tests/04inmemoryimage.php
  74. +92 −0 Tests/05templated.php
  75. +120 −0 Tests/06table.php
  76. BIN Tests/images/phppowerpoint_logo.gif
  77. BIN Tests/images/realdolmen_bg.jpg
  78. BIN Tests/resources/template.pptx
  79. +58 −0 Tests/runall.php
  80. +48 −0 changelog.txt
  81. +44 −0 install.txt
  82. +344 −0 license.txt
  83. +21 −0 phpdoc-home.ini
  84. +21 −0 phpdoc.ini
  85. +5 −0 setpath.bat
  86. +1 −0 start_shell.bat
4 Build/build.bat
@@ -0,0 +1,4 @@
+@set PHPINSTALLDIR=C:\php\5.2.9\;C:\php5;C:\LAMP\php;C:\LAMP\php5;D:\LAMP\php5
+@set PATH=%PHPINSTALLDIR%;%PATH%;
+cls
+php build.php
336 Build/build.php
@@ -0,0 +1,336 @@
+<?php
+/**
+ * PHPPowerPoint
+ *
+ * Copyright (c) 2006 - 2009 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
+ *
+ * @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 ##VERSION##, ##DATE##
+ */
+
+/**
+ * This file creates a build of PHPPowerPoint
+ */
+
+// Build parameters
+$sVersion = "";
+$sDate = "";
+
+// Read build parameters from STDIN
+$stdin = fopen("php://stdin", 'r');
+echo "PHPPowerPoint build script\n";
+echo "---------------------\n";
+echo "Enter the version number you want to add to the build:\t\t\t";
+$sVersion = rtrim(fread($stdin, 1024));
+
+echo "Enter the date number you want to add to the build: (YYYY-MM-DD)\t";
+$sDate = rtrim(fread($stdin, 1024));
+
+echo "\n\n";
+
+// Specify paths and files to include
+$aFilesToInclude = array('../changelog.txt', '../install.txt', '../license.txt');
+$aPathsToInclude = array('../Classes', '../Tests', '../Documentation');
+$aIgnorePatterns = array('.svn', '.settings', '.project', '.projectOptions', '.cache', 'assets');
+$sClassPath = '../Classes';
+$sPEARPath = 'C:\php\5.2.9\pear';
+$sAPIDocumentation = '../Documentation/API/';
+
+// Create API documentation folder and tell to create documentation
+@mkdir($sAPIDocumentation);
+echo "Please, generate API documentation using phpDocumentor.\r\n";
+
+$finished = '';
+while (strtolower($finished) != 'y') {
+ $finished = '';
+ echo "Has documentation generation finished? (y/n)\t";
+ $finished = rtrim(fread($stdin, 1024));
+}
+
+echo "\n\n\n";
+
+// Resulting file
+$strResultingFile = $sVersion . '.zip';
+
+// Starting build
+echo date('H:i:s') . " Starting build...\n";
+
+// Create new ZIP file and open it for writing
+echo date('H:i:s') . " Creating ZIP archive...\n";
+$objZip = new ZipArchive();
+
+// Try opening the ZIP file
+if ($objZip->open($strResultingFile, ZIPARCHIVE::OVERWRITE) !== true) {
+ throw new Exeption("Could not open " . $strResultingFile . " for writing!");
+}
+
+// Add files to include
+foreach ($aFilesToInclude as $strFile) {
+ echo date('H:i:s') . " Adding file $strFile\n";
+ addFileToZIP($strFile, $objZip, $sVersion, $sDate);
+}
+
+// Add paths to include
+foreach ($aPathsToInclude as $strPath) {
+ addPathToZIP($strPath, $objZip, $sVersion, $sDate);
+}
+
+// Set archive comment...
+echo date('H:i:s') . " Set archive comment...\n";
+$objZip->setArchiveComment('PHPPowerPoint - http://www.codeplex.com/PHPPowerPoint');
+
+// Close file
+echo date('H:i:s') . " Saving ZIP archive...\n";
+$objZip->close();
+
+// Copy classes directory
+echo date('H:i:s') . " Copying class directory...\n";
+mkdir('./tmp');
+dircopy($sClassPath, './tmp');
+
+// Create PEAR package.xml
+echo date('H:i:s') . " Creating PEAR package.xml...\n";
+$packageFile = file_get_contents('package.xml');
+$packageFile = replaceMetaData($packageFile, $sVersion, $sDate);
+
+$packageFile = str_replace('##PEAR_DIR##', addPathToPEAR('./tmp', '', $sVersion, $sDate), $packageFile);
+$fh = fopen('./tmp/package.xml', 'w');
+fwrite($fh, $packageFile);
+fclose($fh);
+
+// Create PEAR package
+echo date('H:i:s') . " Creating PEAR package...\n";
+echo shell_exec("$sPEARPath package ./tmp/package.xml");
+
+// Wait a minute (TortoiseSVN on USB stick is slow!)
+echo date('H:i:s') . " Waiting...\n";
+sleep(120);
+
+// Clean temporary files
+echo date('H:i:s') . " Cleaning temporary files...\n";
+unlink('./tmp/package.xml');
+rm('./tmp');
+
+// Finished build
+echo date('H:i:s') . " Finished build!\n";
+fclose($stdin);
+
+/**
+ * Add a specific path's files and folders to a ZIP object
+ *
+ * @param string $strPath Path to add
+ * @param ZipArchive $objZip ZipArchive object
+ * @param string $strVersion Version string
+ * @param string $strDate Date string
+ */
+function addPathToZIP($strPath, $objZip, $strVersion, $strDate) {
+ global $aIgnorePatterns;
+
+ echo date('H:i:s') . " Adding path $strPath...\n";
+
+ $currentDir = opendir($strPath);
+ while ($strFile = readdir($currentDir)) {
+ if ($strFile != '.' && $strFile != '..') {
+ if (is_file($strPath . '/' . $strFile)) {
+ addFileToZIP($strPath . '/' . $strFile, $objZip, $strVersion, $strDate);
+ } else if (is_dir($strPath . '/' . $strFile)) {
+ if (!shouldIgnore($strFile)) {
+ addPathToZIP( ($strPath . '/' . $strFile), $objZip, $strVersion, $strDate );
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Add a specific file to ZIP
+ *
+ * @param string $strFile File to add
+ * @param ZipArchive $objZip ZipArchive object
+ * @param string $strVersion Version string
+ * @param string $strDate Date string
+ */
+function addFileToZIP($strFile, $objZip, $strVersion, $strDate) {
+ if (!shouldIgnore($strFile)) {
+ $fileContents = file_get_contents($strFile);
+ $fileContents = replaceMetaData($fileContents, $strVersion, $strDate);
+
+ //$objZip->addFile($strFile, cleanFileName($strFile));
+ $objZip->addFromString( cleanFileName($strFile), $fileContents );
+ }
+}
+
+/**
+ * Cleanup a filename
+ *
+ * @param string $strFile Filename
+ * @return string Filename
+ */
+function cleanFileName($strFile) {
+ $strFile = str_replace('../', '', $strFile);
+ $strFile = str_replace('WINDOWS', '', $strFile);
+
+ while (eregi('//', $strFile)) {
+ $strFile = str_replace('//', '/', $strFile);
+ }
+
+ return $strFile;
+}
+
+/**
+ * Replace metadata in string
+ *
+ * @param string $strString String contents
+ * @param string $strVersion Version string
+ * @param string $strDate Date string
+ * @return string String contents
+ */
+function replaceMetaData($strString, $strVersion, $strDate) {
+ $strString = str_replace('##VERSION##', $strVersion, $strString);
+ $strString = str_replace('##DATE##', $strDate, $strString);
+ return $strString;
+}
+
+/**
+ * Add a specific path's files and folders to a PEAR dir list
+ *
+ * @param string $strPath Path to add
+ * @param string $strPEAR String containing PEAR dir definitions
+ * @param string $strVersion Version string
+ * @param string $strDate Date string
+ * @return string String containing PEAR dir definitions
+ */
+function addPathToPEAR($strPath, $strPEAR, $strVersion, $strDate) {
+ global $aIgnorePatterns;
+
+ $currentDir = opendir($strPath);
+ while ($strFile = readdir($currentDir)) {
+ if ($strFile != '.' && $strFile != '..') {
+ if (is_file($strPath . '/' . $strFile) && !eregi('package.xml', $strFile)) {
+ $strPEAR .= addFileToPEAR($strPath . '/' . $strFile, '', $strVersion, $strDate);
+ } else if (is_dir($strPath . '/' . $strFile)) {
+ if (!shouldIgnore($strFile)) {
+ $strPEAR .= '<dir name="' . $strFile . '">';
+ $strPEAR .= addPathToPEAR( ($strPath . '/' . $strFile), '', $strVersion, $strDate );
+ $strPEAR .= '</dir>';
+ }
+ }
+ }
+ }
+
+ return $strPEAR;
+}
+
+/**
+ * Add a specific file to a PEAR dir list
+ *
+ * @param string $strFile File to add
+ * @param string $strPEAR String containing PEAR dir definitions
+ * @param string $strVersion Version string
+ * @param string $strDate Date string
+ * @return string String containing PEAR dir definitions
+ */
+function addFileToPEAR($strFile, $strPEAR, $strVersion, $strDate) {
+ if (!shouldIgnore($strFile)) {
+ $fileContents = file_get_contents($strFile);
+ $fileContents = replaceMetaData($fileContents, $strVersion, $strDate);
+ $fh = fopen($strFile, 'w');
+ fwrite($fh, $fileContents);
+ fclose($fh);
+
+ $strPEAR .= '<file name="' . basename($strFile) . '" role="php" />';
+
+ return $strPEAR;
+ } else {
+ return '';
+ }
+}
+
+/**
+ * Copy a complete directory
+ *
+ * @param string $srcdir Source directory
+ * @param string $dstdir Destination directory
+ * @return int Number of copied files
+ */
+function dircopy($srcdir, $dstdir, $verbose = false) {
+ $num = 0;
+ if(!is_dir($dstdir) && !shouldIgnore($dstdir)) mkdir($dstdir);
+ if($curdir = opendir($srcdir)) {
+ while($file = readdir($curdir)) {
+ if($file != '.' && $file != '..') {
+ $srcfile = $srcdir . '\\' . $file;
+ $dstfile = $dstdir . '\\' . $file;
+ if(is_file($srcfile) && !shouldIgnore($srcfile)) {
+ if(is_file($dstfile)) $ow = filemtime($srcfile) - filemtime($dstfile); else $ow = 1;
+ if($ow > 0) {
+ if($verbose) echo "Copying '$srcfile' to '$dstfile'...";
+ if(copy($srcfile, $dstfile)) {
+ touch($dstfile, filemtime($srcfile)); $num++;
+ if($verbose) echo "OK\n";
+ }
+ else echo "Error: File '$srcfile' could not be copied!\n";
+ }
+ }
+ else if(is_dir($srcfile) && !shouldIgnore($srcfile)) {
+ $num += dircopy($srcfile, $dstfile, $verbose);
+ }
+ }
+ }
+ closedir($curdir);
+ }
+ return $num;
+}
+
+/**
+ * rm() -- Very Vigorously erase files and directories. Also hidden files !!!!
+ *
+ * @param $dir string
+ * be carefull to:
+ * if($obj=='.' || $obj=='..') continue;
+ * if not it will erase all the server...it happened to me ;)
+ * the function is permission dependent.
+ */
+function rm($dir) {
+ if(!$dh = @opendir($dir)) return;
+ while (($obj = readdir($dh))) {
+ if($obj=='.' || $obj=='..') continue;
+ @chmod($dir.'/'.$obj, 0777);
+ if (!@unlink($dir.'/'.$obj)) rm($dir.'/'.$obj);
+ }
+ @rmdir($dir);
+ @shell_exec('rmdir /S /Q "' . $dir . '"');
+}
+
+/**
+ * Should a file/folder be ignored?
+ *
+ * @param string $pName
+ * @return boolean
+ */
+function shouldIgnore($pName = '') {
+ global $aIgnorePatterns;
+
+ $ignore = false;
+ foreach ($aIgnorePatterns as $ignorePattern) {
+ if (eregi($ignorePattern, $pName)) {
+ $ignore = true;
+ }
+ }
+ return $ignore;
+}
54 Build/package.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
+ xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+http://pear.php.net/dtd/tasks-1.0.xsd
+http://pear.php.net/dtd/package-2.0
+http://pear.php.net/dtd/package-2.0.xsd">
+ <name>PHPPowerPoint</name>
+ <uri>http://www.codeplex.com/PHPPowerPoint/PHPPowerPoint-##VERSION##</uri>
+ <summary>PHPPowerPoint</summary>
+ <description>
+ Project providing a set of classes for the PHP programming language, which allow you to write to PowerPoint 2007 files and read from PowerPoint 2007 files.
+ </description>
+ <lead>
+ <name>Maarten Balliauw</name>
+ <user>maartenba</user>
+ <email>maarten@phpexcel.net</email>
+ <active>yes</active>
+ </lead>
+ <date>##DATE##</date>
+ <version>
+ <release>##VERSION##</release>
+ <api>##VERSION##</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt">LGPL</license>
+ <notes>This package ONLY contains the class files, not the documentation and example code. Please refer to http://www.codeplex.com/PHPExcel for those files.</notes>
+ <contents>
+ <dir name="/">
+##PEAR_DIR##
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+ <extension>
+ <name>zip</name>
+ </extension>
+ </required>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ </filelist>
+ </phprelease>
+ </package>
288 Classes/PHPPowerPoint.php
@@ -0,0 +1,288 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/** PHPExcel root directory */
+if (!defined('PHPPOWERPOINT_ROOT')) {
+ define('PHPPOWERPOINT_ROOT', dirname(__FILE__) . '/');
+ require(PHPPOWERPOINT_ROOT . 'PHPPowerPoint/Autoloader.php');
+ PHPPowerPoint_Autoloader::Register();
+ PHPPowerPoint_Shared_ZipStreamWrapper::register();
+}
+
+
+/**
+ * PHPPowerPoint
+ *
+ * @category PHPPowerPoint
+ * @package PHPPowerPoint
+ * @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
+ */
+class PHPPowerPoint
+{
+ /**
+ * Document properties
+ *
+ * @var PHPPowerPoint_DocumentProperties
+ */
+ private $_properties;
+
+ /**
+ * Collection of Slide objects
+ *
+ * @var PHPPowerPoint_Slide[]
+ */
+ private $_slideCollection = array();
+
+ /**
+ * Active slide index
+ *
+ * @var int
+ */
+ private $_activeSlideIndex = 0;
+
+ /**
+ * Create a new PHPPowerPoint with one Slide
+ */
+ public function __construct()
+ {
+ // Initialise slide collection and add one slide
+ $this->_slideCollection = array();
+ $this->_slideCollection[] = new PHPPowerPoint_Slide($this);
+ $this->_activeSlideIndex = 0;
+
+ // Create document properties
+ $this->_properties = new PHPPowerPoint_DocumentProperties();
+ }
+
+ /**
+ * Get properties
+ *
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function getProperties()
+ {
+ return $this->_properties;
+ }
+
+ /**
+ * Set properties
+ *
+ * @param PHPPowerPoint_DocumentProperties $value
+ * @return PHPPowerPoint
+ */
+ public function setProperties(PHPPowerPoint_DocumentProperties $value)
+ {
+ $this->_properties = $value;
+ return $this;
+ }
+
+ /**
+ * Get active slide
+ *
+ * @return PHPPowerPoint_Slide
+ */
+ public function getActiveSlide()
+ {
+ return $this->_slideCollection[$this->_activeSlideIndex];
+ }
+
+ /**
+ * Create slide and add it to this presentation
+ *
+ * @return PHPPowerPoint_Slide
+ */
+ public function createSlide()
+ {
+ $newSlide = new PHPPowerPoint_Slide($this);
+
+ $this->addSlide($newSlide);
+
+ return $newSlide;
+ }
+
+ /**
+ * Add slide
+ *
+ * @param PHPPowerPoint_Slide $slide
+ * @throws Exception
+ * @return PHPPowerPoint_Slide
+ */
+ public function addSlide(PHPPowerPoint_Slide $slide = null)
+ {
+ $this->_slideCollection[] = $slide;
+ return $slide;
+ }
+
+ /**
+ * Remove slide by index
+ *
+ * @param int $index Slide index
+ * @throws Exception
+ * @return PHPPowerPoint
+ */
+ public function removeSlideByIndex($index = 0)
+ {
+ if ($index > count($this->_slideCollection) - 1) {
+ throw new Exception("Slide index is out of bounds.");
+ } else {
+ array_splice($this->_slideCollection, $index, 1);
+ }
+ return $this;
+ }
+
+ /**
+ * Get slide by index
+ *
+ * @param int $index Slide index
+ * @return PHPPowerPoint_Slide
+ * @throws Exception
+ */
+ public function getSlide($index = 0)
+ {
+ if ($index > count($this->_slideCollection) - 1) {
+ throw new Exception("Slide index is out of bounds.");
+ } else {
+ return $this->_slideCollection[$index];
+ }
+ }
+
+ /**
+ * Get all slides
+ *
+ * @return PHPPowerPoint_Slide[]
+ */
+ public function getAllSlides()
+ {
+ return $this->_slideCollection;
+ }
+
+ /**
+ * Get index for slide
+ *
+ * @param PHPPowerPoint_Slide $slide
+ * @return Slide index
+ * @throws Exception
+ */
+ public function getIndex(PHPPowerPoint_Slide $slide)
+ {
+ foreach ($this->_slideCollection as $key => $value) {
+ if ($value->getHashCode() == $slide->getHashCode()) {
+ return $key;
+ }
+ }
+ }
+
+ /**
+ * Get slide count
+ *
+ * @return int
+ */
+ public function getSlideCount()
+ {
+ return count($this->_slideCollection);
+ }
+
+ /**
+ * Get active slide index
+ *
+ * @return int Active slide index
+ */
+ public function getActiveSlideIndex()
+ {
+ return $this->_activeSlideIndex;
+ }
+
+ /**
+ * Set active slide index
+ *
+ * @param int $index Active slide index
+ * @throws Exception
+ * @return PHPPowerPoint_Slide
+ */
+ public function setActiveSlideIndex($index = 0)
+ {
+ if ($index > count($this->_slideCollection) - 1) {
+ throw new Exception("Active slide index is out of bounds.");
+ } else {
+ $this->_activeSlideIndex = $index;
+ }
+ return $this->getActiveSlide();
+ }
+
+ /**
+ * Add external slide
+ *
+ * @param PHPPowerPoint_Slide $slide External slide to add
+ * @throws Exception
+ * @return PHPPowerPoint_Slide
+ */
+ public function addExternalSheet(PHPPowerPoint_Slide $slide) {
+ $slide->rebindParent($this);
+ return $this->addSheet($slide);
+ }
+
+ /**
+ * Get slide iterator
+ *
+ * @return PHPPowerPoint_SlideIterator
+ */
+ public function getSlideIterator() {
+ return new PHPPowerPoint_SlideIterator($this);
+ }
+
+ /**
+ * Copy presentation (!= clone!)
+ *
+ * @return PHPPowerPoint
+ */
+ public function copy() {
+ $copied = clone $this;
+
+ $slideCount = count($this->_slideCollection);
+ for ($i = 0; $i < $slideCount; ++$i) {
+ $this->_slideCollection[$i] = $this->_slideCollection[$i]->copy();
+ $this->_slideCollection[$i]->rebindParent($this);
+ }
+
+ return $copied;
+ }
+
+ /**
+ * 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;
+ }
+ }
+ }
+}
51 Classes/PHPPowerPoint/Autoloader.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * PHPPowerPoint
+ *
+ * Copyright (c) 2006 - 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) 2006 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+
+class PHPPowerPoint_Autoloader
+{
+ public static function Register() {
+ return spl_autoload_register(array('PHPPowerPoint_Autoloader', 'Load'));
+ } // function Register()
+
+
+ public static function Load($pObjectName){
+ if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPPowerPoint') === False)) {
+ return false;
+ }
+
+ $pObjectFilePath = PHPPOWERPOINT_ROOT.
+ str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
+ '.php';
+
+ if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
+ return false;
+ }
+
+ require($pObjectFilePath);
+ } // function Load()
+
+}
345 Classes/PHPPowerPoint/DocumentProperties.php
@@ -0,0 +1,345 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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;
+
+ /**
+ * Company
+ *
+ * @var string
+ */
+ private $_company;
+
+ /**
+ * 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 = '';
+ $this->_company = 'Microsoft Corporation';
+ }
+
+ /**
+ * Get Creator
+ *
+ * @return string
+ */
+ public function getCreator() {
+ return $this->_creator;
+ }
+
+ /**
+ * Set Creator
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setCreator($pValue = '') {
+ $this->_creator = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Last Modified By
+ *
+ * @return string
+ */
+ public function getLastModifiedBy() {
+ return $this->_lastModifiedBy;
+ }
+
+ /**
+ * Set Last Modified By
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setLastModifiedBy($pValue = '') {
+ $this->_lastModifiedBy = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Created
+ *
+ * @return datetime
+ */
+ public function getCreated() {
+ return $this->_created;
+ }
+
+ /**
+ * Set Created
+ *
+ * @param datetime $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setCreated($pValue = null) {
+ if (is_null($pValue)) {
+ $pValue = time();
+ }
+ $this->_created = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Modified
+ *
+ * @return datetime
+ */
+ public function getModified() {
+ return $this->_modified;
+ }
+
+ /**
+ * Set Modified
+ *
+ * @param datetime $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setModified($pValue = null) {
+ if (is_null($pValue)) {
+ $pValue = time();
+ }
+ $this->_modified = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Title
+ *
+ * @return string
+ */
+ public function getTitle() {
+ return $this->_title;
+ }
+
+ /**
+ * Set Title
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setTitle($pValue = '') {
+ $this->_title = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Description
+ *
+ * @return string
+ */
+ public function getDescription() {
+ return $this->_description;
+ }
+
+ /**
+ * Set Description
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setDescription($pValue = '') {
+ $this->_description = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Subject
+ *
+ * @return string
+ */
+ public function getSubject() {
+ return $this->_subject;
+ }
+
+ /**
+ * Set Subject
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setSubject($pValue = '') {
+ $this->_subject = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Keywords
+ *
+ * @return string
+ */
+ public function getKeywords() {
+ return $this->_keywords;
+ }
+
+ /**
+ * Set Keywords
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setKeywords($pValue = '') {
+ $this->_keywords = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Category
+ *
+ * @return string
+ */
+ public function getCategory() {
+ return $this->_category;
+ }
+
+ /**
+ * Set Category
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setCategory($pValue = '') {
+ $this->_category = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Company
+ *
+ * @return string
+ */
+ public function getCompany() {
+ return $this->_company;
+ }
+
+ /**
+ * Set Company
+ *
+ * @param string $pValue
+ * @return PHPPowerPoint_DocumentProperties
+ */
+ public function setCompany($pValue = '') {
+ $this->_company = $pValue;
+ return $this;
+ }
+
+ /**
+ * 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;
+ }
+ }
+ }
+}
216 Classes/PHPPowerPoint/HashTable.php
@@ -0,0 +1,216 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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;
+ }
+ }
+ }
+}
62 Classes/PHPPowerPoint/IComparable.php
@@ -0,0 +1,62 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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);
+}
189 Classes/PHPPowerPoint/IOFactory.php
@@ -0,0 +1,189 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/** PHPPowerPoint root directory */
+if (!defined('PHPPOWERPOINT_ROOT')) {
+ /**
+ * @ignore
+ */
+ define('PHPPOWERPOINT_ROOT', dirname(__FILE__) . '/../');
+ require(PHPPOWERPOINT_ROOT . 'PHPPowerPoint/Autoloader.php');
+ PHPPowerPoint_Autoloader::Register();
+ PHPPowerPoint_Shared_ZipStreamWrapper::register();
+}
+
+
+/**
+ * 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.");
+ }
+}
53 Classes/PHPPowerPoint/Reader/IReader.php
@@ -0,0 +1,53 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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);
+}
127 Classes/PHPPowerPoint/Reader/Serialized.php
@@ -0,0 +1,127 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/** PHPPowerPoint root directory */
+if (!defined('PHPPOWERPOINT_ROOT')) {
+ /**
+ * @ignore
+ */
+ define('PHPPOWERPOINT_ROOT', dirname(__FILE__) . '/../../');
+ require(PHPPOWERPOINT_ROOT . 'PHPPowerPoint/Autoloader.php');
+ PHPPowerPoint_Autoloader::Register();
+ PHPPowerPoint_Shared_ZipStreamWrapper::register();
+}
+
+
+/**
+ * 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");
+ }
+}
361 Classes/PHPPowerPoint/Shape.php
@@ -0,0 +1,361 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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
+ * @return PHPPowerPoint_Shape
+ */
+ 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.");
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get OffsetX
+ *
+ * @return int
+ */
+ public function getOffsetX() {
+ return $this->_offsetX;
+ }
+
+ /**
+ * Set OffsetX
+ *
+ * @param int $pValue
+ * @return PHPPowerPoint_Shape
+ */
+ public function setOffsetX($pValue = 0) {
+ $this->_offsetX = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get OffsetY
+ *
+ * @return int
+ */
+ public function getOffsetY() {
+ return $this->_offsetY;
+ }
+
+ /**
+ * Set OffsetY
+ *
+ * @param int $pValue
+ * @return PHPPowerPoint_Shape
+ */
+ public function setOffsetY($pValue = 0) {
+ $this->_offsetY = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Width
+ *
+ * @return int
+ */
+ public function getWidth() {
+ return $this->_width;
+ }
+
+ /**
+ * Set Width
+ *
+ * @param int $pValue
+ * @return PHPPowerPoint_Shape
+ */
+ public function setWidth($pValue = 0) {
+ $this->_width = $pValue;
+ return $this;
+ }
+
+ /**
+ * Get Height
+ *
+ * @return int
+ */
+ public function getHeight() {
+ return $this->_height;
+ }
+
+ /**
+ * Set Height
+ *
+ * @param int $pValue
+ * @return PHPPowerPoint_Shape
+ */
+ public function setHeight($pValue = 0) {
+ $this->_height = $pValue;
+ return $this;
+ }
+
+ /**
+ * Set width and height with proportional resize
+ *
+ * @param int $width
+ * @param int $height
+ * @example $objDrawing->setWidthAndHeight(160,120);
+ * @return PHPPowerPoint_Shape
+ */
+ public function setWidthAndHeight($width = 0, $height = 0) {
+ $this->_width = $width;
+ $this->_height = $height;
+ return $this;
+ }
+
+ /**
+ * Get Rotation
+ *
+ * @return int
+ */
+ public function getRotation() {
+ return $this->_rotation;
+ }
+
+ /**
+ * Set Rotation
+ *
+ * @param int $pValue
+ * @return PHPPowerPoint_Shape
+ */
+ public function setRotation($pValue = 0) {
+ $this->_rotation = $pValue;
+ return $this;
+ }
+
+ /**
+ * 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
+ * @return PHPPowerPoint_Shape
+ */
+ public function setShadow(PHPPowerPoint_Shape_Shadow $pValue = null) {
+ $this->_shadow = $pValue;
+ return $this;
+ }
+
+ /**
+ * 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;
+ }
+ }
+ }
+}
280 Classes/PHPPowerPoint/Shape/BaseDrawing.php
@@ -0,0 +1,280 @@
+<?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 ##VERSION##, ##DATE##
+ */
+
+
+/**
+ * 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
+{
+ /**
+