PHPPowerPoint
[ class tree: PHPPowerPoint ] [ index: PHPPowerPoint ] [ all elements ]

Source for file PHPPowerpoint.php

Documentation is available at PHPPowerpoint.php

  1. <?php
  2. /**
  3.  * PHPPowerPoint
  4.  *
  5.  * Copyright (c) 2009 - 2010 PHPPowerPoint
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPPowerPoint
  22.  * @package    PHPPowerPoint
  23.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    0.1.0, 2009-04-27
  26.  */
  27.  
  28.  
  29. /** PHPPowerPoint_Slide */
  30. require_once 'PHPPowerPoint/Slide.php';
  31.  
  32. /** PHPPowerPoint_DocumentProperties */
  33. require_once 'PHPPowerPoint/DocumentProperties.php';
  34.  
  35. /** PHPPowerPoint_Shared_ZipStreamWrapper */
  36. require_once 'PHPPowerPoint/Shared/ZipStreamWrapper.php';
  37.  
  38. /** PHPPowerPoint_SlideIterator */
  39. require_once 'PHPPowerPoint/SlideIterator.php';
  40.  
  41.  
  42. /**
  43.  * PHPPowerPoint
  44.  *
  45.  * @category   PHPPowerPoint
  46.  * @package    PHPPowerPoint
  47.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  48.  */
  49. {
  50.     /**
  51.      * Document properties
  52.      *
  53.      * @var PHPPowerPoint_DocumentProperties 
  54.      */
  55.     private $_properties;
  56.  
  57.     /**
  58.      * Collection of Slide objects
  59.      *
  60.      * @var PHPPowerPoint_Slide[] 
  61.      */
  62.     private $_slideCollection = array();
  63.  
  64.     /**
  65.      * Active slide index
  66.      *
  67.      * @var int 
  68.      */
  69.     private $_activeSlideIndex = 0;
  70.  
  71.     /**
  72.      * Create a new PHPPowerPoint with one Slide
  73.      */
  74.     public function __construct()
  75.     {
  76.         // Initialise slide collection and add one slide
  77.         $this->_slideCollection = array();
  78.         $this->_slideCollection[new PHPPowerPoint_Slide($this);
  79.         $this->_activeSlideIndex = 0;
  80.  
  81.         // Create document properties
  82.         $this->_properties = new PHPPowerPoint_DocumentProperties();
  83.     }
  84.  
  85.     /**
  86.      * Get properties
  87.      *
  88.      * @return PHPPowerPoint_DocumentProperties 
  89.      */
  90.     public function getProperties()
  91.     {
  92.         return $this->_properties;
  93.     }
  94.  
  95.     /**
  96.      * Set properties
  97.      *
  98.      * @param PHPPowerPoint_DocumentProperties    $value 
  99.      */
  100.     public function setProperties(PHPPowerPoint_DocumentProperties $value)
  101.     {
  102.         $this->_properties = $value;
  103.     }
  104.  
  105.     /**
  106.      * Get active slide
  107.      *
  108.      * @return PHPPowerPoint_Slide 
  109.      */
  110.     public function getActiveSlide()
  111.     {
  112.         return $this->_slideCollection[$this->_activeSlideIndex];
  113.     }
  114.  
  115.     /**
  116.      * Create slide and add it to this presentation
  117.      *
  118.      * @return PHPPowerPoint_Slide 
  119.      */
  120.     public function createSlide()
  121.     {
  122.         $newSlide new PHPPowerPoint_Slide($this);
  123.  
  124.         $this->addSlide($newSlide);
  125.  
  126.         return $newSlide;
  127.     }
  128.  
  129.     /**
  130.      * Add slide
  131.      *
  132.      * @param PHPPowerPoint_Slide $slide 
  133.      * @throws Exception
  134.      */
  135.     public function addSlide(PHPPowerPoint_Slide $slide null)
  136.     {
  137.         $this->_slideCollection[$slide;
  138.     }
  139.  
  140.     /**
  141.      * Remove slide by index
  142.      *
  143.      * @param int $index Slide index
  144.      * @throws Exception
  145.      */
  146.     public function removeSlideByIndex($index 0)
  147.     {
  148.         if ($index count($this->_slideCollection1{
  149.             throw new Exception("Slide index is out of bounds.");
  150.         else {
  151.             array_splice($this->_slideCollection$index1);
  152.         }
  153.     }
  154.  
  155.     /**
  156.      * Get slide by index
  157.      *
  158.      * @param int $index Slide index
  159.      * @return PHPPowerPoint_Slide 
  160.      * @throws Exception
  161.      */
  162.     public function getSlide($index 0)
  163.     {
  164.         if ($index count($this->_slideCollection1{
  165.             throw new Exception("Slide index is out of bounds.");
  166.         else {
  167.             return $this->_slideCollection[$index];
  168.         }
  169.     }
  170.  
  171.     /**
  172.      * Get all slides
  173.      *
  174.      * @return PHPPowerPoint_Slide[] 
  175.      */
  176.     public function getAllSlides()
  177.     {
  178.         return $this->_slideCollection;
  179.     }
  180.  
  181.     /**
  182.      * Get index for slide
  183.      *
  184.      * @param PHPPowerPoint_Slide $slide 
  185.      * @return Slide index
  186.      * @throws Exception
  187.      */
  188.     public function getIndex(PHPPowerPoint_Slide $slide)
  189.     {
  190.         foreach ($this->_slideCollection as $key => $value{
  191.             if ($value->getHashCode(== $slide->getHashCode()) {
  192.                 return $key;
  193.             }
  194.         }
  195.     }
  196.  
  197.     /**
  198.      * Get slide count
  199.      *
  200.      * @return int 
  201.      */
  202.     public function getSlideCount()
  203.     {
  204.         return count($this->_slideCollection);
  205.     }
  206.  
  207.     /**
  208.      * Get active slide index
  209.      *
  210.      * @return int Active slide index
  211.      */
  212.     public function getActiveSlideIndex()
  213.     {
  214.         return $this->_activeSlideIndex;
  215.     }
  216.  
  217.     /**
  218.      * Set active slide index
  219.      *
  220.      * @param int $index Active slide index
  221.      * @throws Exception
  222.      */
  223.     public function setActiveSlideIndex($index 0)
  224.     {
  225.         if ($index count($this->_slideCollection1{
  226.             throw new Exception("Active slide index is out of bounds.");
  227.         else {
  228.             $this->_activeSlideIndex = $index;
  229.         }
  230.     }
  231.  
  232.     /**
  233.      * Add external slide
  234.      *
  235.      * @param PHPPowerPoint_Slide $slide External slide to add
  236.      * @throws Exception
  237.      */
  238.     public function addExternalSheet(PHPPowerPoint_Slide $slide{
  239.         $slide->rebindParent($this);
  240.         $this->addSheet($slide);
  241.     }
  242.  
  243.     /**
  244.      * Get slide iterator
  245.      *
  246.      * @return PHPPowerPoint_SlideIterator 
  247.      */
  248.     public function getSlideIterator({
  249.         return new PHPPowerPoint_SlideIterator($this);
  250.     }
  251.  
  252.     /**
  253.      * Copy presentation (!= clone!)
  254.      *
  255.      * @return PHPPowerPoint 
  256.      */
  257.     public function copy({
  258.         $copied clone $this;
  259.  
  260.         $slideCount count($this->_slideCollection);
  261.         for ($i 0$i $slideCount++$i{
  262.             $this->_slideCollection[$i$this->_slideCollection[$i]->copy();
  263.             $this->_slideCollection[$i]->rebindParent($this);
  264.         }
  265.  
  266.         return $copied;
  267.     }
  268.  
  269.     /**
  270.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  271.      */
  272.     public function __clone({
  273.         $vars get_object_vars($this);
  274.         foreach ($vars as $key => $value{
  275.             if (is_object($value)) {
  276.                 $this->$key clone $value;
  277.             else {
  278.                 $this->$key $value;
  279.             }
  280.         }
  281.     }
  282. }

Documentation generated on Sat, 25 Apr 2009 11:37:40 +0200 by phpDocumentor 1.4.1