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

Source for file Slide.php

Documentation is available at Slide.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_Slide
  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 */
  30. require_once 'PHPPowerPoint.php';
  31.  
  32. /** PHPPowerPoint_Slide_Layout */
  33. require_once 'PHPPowerPoint/Slide/Layout.php';
  34.  
  35. /** PHPPowerPoint_Shape */
  36. require_once 'PHPPowerPoint/Shape.php';
  37.  
  38. /** PHPPowerPoint_Shape_RichText */
  39. require_once 'PHPPowerPoint/Shape/RichText.php';
  40.  
  41. /** PHPPowerPoint_Shape_BaseDrawing */
  42. require_once 'PHPPowerPoint/Shape/BaseDrawing.php';
  43.  
  44. /** PHPPowerPoint_Shape_Drawing */
  45. require_once 'PHPPowerPoint/Shape/Drawing.php';
  46.  
  47. /** PHPPowerPoint_Shape_MemoryDrawing */
  48. require_once 'PHPPowerPoint/Shape/MemoryDrawing.php';
  49.  
  50. /** PHPPowerPoint_IComparable */
  51. require_once 'PHPPowerPoint/IComparable.php';
  52.  
  53. /** PHPPowerPoint_Shared_Font */
  54. require_once 'PHPPowerPoint/Shared/Font.php';
  55.  
  56. /** PHPPowerPoint_Shared_String */
  57. require_once 'PHPPowerPoint/Shared/String.php';
  58.  
  59.  
  60. /**
  61.  * PHPPowerPoint_Slide
  62.  *
  63.  * @category   PHPPowerPoint
  64.  * @package    PHPPowerPoint_Slide
  65.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  66.  */
  67. class PHPPowerPoint_Slide implements PHPPowerPoint_IComparable
  68. {
  69.     /**
  70.      * Parent presentation
  71.      *
  72.      * @var PHPPowerPoint 
  73.      */
  74.     private $_parent;
  75.  
  76.     /**
  77.      * Collection of shapes
  78.      *
  79.      * @var PHPPowerPoint_Shape[] 
  80.      */
  81.     private $_shapeCollection = null;
  82.     
  83.     /**
  84.      * Slide identifier
  85.      * 
  86.      * @var string 
  87.      */
  88.     private $_identifier;
  89.     
  90.     /**
  91.      * Slide layout
  92.      * 
  93.      * @var string 
  94.      */
  95.     private $_slideLayout = PHPPowerPoint_Slide_Layout::BLANK;
  96.  
  97.     /**
  98.      * Create a new slide
  99.      *
  100.      * @param PHPPowerPoint         $pParent 
  101.      */
  102.     public function __construct(PHPPowerPoint $pParent null)
  103.     {
  104.         // Set parent
  105.         $this->_parent = $pParent;
  106.  
  107.         // Shape collection
  108.         $this->_shapeCollection = new ArrayObject();
  109.         
  110.         // Set identifier
  111.         $this->_identifier = md5(rand(0,9999time());
  112.     }
  113.  
  114.     /**
  115.      * Get collection of shapes
  116.      *
  117.      * @return PHPPowerPoint_Shape[] 
  118.      */
  119.     public function getShapeCollection()
  120.     {
  121.         return $this->_shapeCollection;
  122.     }
  123.     
  124.     /**
  125.      * Add shape to slide
  126.      * 
  127.      * @param PHPPowerPoint_Shape $shape 
  128.      */
  129.     public function addShape(PHPPowerPoint_Shape $shape)
  130.     {
  131.         $shape->setSlide($this);
  132.     }
  133.     
  134.     /**
  135.      * Create rich text shape
  136.      * 
  137.      * @return PHPPowerPoint_Shape_RichText 
  138.      */
  139.     public function createRichTextShape()
  140.     {
  141.         $shape new PHPPowerPoint_Shape_RichText();
  142.         $this->addShape($shape);
  143.         return $shape;
  144.     }
  145.     
  146.     /**
  147.      * Create drawing shape
  148.      * 
  149.      * @return PHPPowerPoint_Shape_Drawing 
  150.      */
  151.     public function createDrawingShape()
  152.     {
  153.         $shape new PHPPowerPoint_Shape_Drawing();
  154.         $this->addShape($shape);
  155.         return $shape;
  156.     }
  157.  
  158.     /**
  159.      * Get parent
  160.      *
  161.      * @return PHPPowerPoint 
  162.      */
  163.     public function getParent({
  164.         return $this->_parent;
  165.     }
  166.  
  167.     /**
  168.      * Re-bind parent
  169.      *
  170.      * @param PHPPowerPoint $parent 
  171.      */
  172.     public function rebindParent(PHPPowerPoint $parent{
  173.         $this->_parent->removeSlideByIndex(
  174.             $this->_parent->getIndex($this)
  175.         );
  176.         $this->_parent = $parent;
  177.     }
  178.     
  179.     /**
  180.      * Get slide layout
  181.      * 
  182.      * @return string 
  183.      */
  184.     public function getSlideLayout({
  185.         return $this->_slideLayout;
  186.     }
  187.     
  188.     /**
  189.      * Set slide layout
  190.      * 
  191.      * @param string $layout 
  192.      */
  193.     public function setSlideLayout($layout PHPPowerPoint_Slide_Layout::BLANK{
  194.         $this->_slideLayout = $layout;
  195.     }
  196.  
  197.     /**
  198.      * Get hash code
  199.      *
  200.      * @return string    Hash code
  201.      */
  202.     public function getHashCode({
  203.         return md5(
  204.               $this->_identifier
  205.             . __CLASS__
  206.         );
  207.     }
  208.     
  209.     /**
  210.      * Hash index
  211.      *
  212.      * @var string 
  213.      */
  214.     private $_hashIndex;
  215.     
  216.     /**
  217.      * Get hash index
  218.      * 
  219.      * Note that this index may vary during script execution! Only reliable moment is
  220.      * while doing a write of a workbook and when changes are not allowed.
  221.      *
  222.      * @return string    Hash index
  223.      */
  224.     public function getHashIndex({
  225.         return $this->_hashIndex;
  226.     }
  227.     
  228.     /**
  229.      * Set hash index
  230.      * 
  231.      * Note that this index may vary during script execution! Only reliable moment is
  232.      * while doing a write of a workbook and when changes are not allowed.
  233.      *
  234.      * @param string    $value    Hash index
  235.      */
  236.     public function setHashIndex($value{
  237.         $this->_hashIndex = $value;
  238.     }
  239.  
  240.     /**
  241.      * Copy slide (!= clone!)
  242.      *
  243.      * @return PHPPowerPoint_Slide 
  244.      */
  245.     public function copy({
  246.         $copied clone $this;
  247.  
  248.         return $copied;
  249.     }
  250.  
  251.     /**
  252.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  253.      */
  254.     public function __clone({
  255.         foreach ($this as $key => $val{
  256.             if (is_object($val|| (is_array($val))) {
  257.                 $this->{$keyunserialize(serialize($val));
  258.             }
  259.         }
  260.     }
  261. }

Documentation generated on Sat, 25 Apr 2009 11:38:05 +0200 by phpDocumentor 1.4.1