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

Source for file BaseDrawing.php

Documentation is available at BaseDrawing.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_Shape
  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_IComparable */
  30. require_once 'PHPPowerPoint/IComparable.php';
  31.  
  32. /** PHPPowerPoint_Shape */
  33. require_once 'PHPPowerPoint/Shape.php';
  34.  
  35. /**
  36.  * PHPPowerPoint_Shape_BaseDrawing
  37.  *
  38.  * @category   PHPPowerPoint
  39.  * @package    PHPPowerPoint_Shape
  40.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  41.  */
  42. {        
  43.     /**
  44.      * Image counter
  45.      *
  46.      * @var int 
  47.      */
  48.     private static $_imageCounter 0;
  49.     
  50.     /**
  51.      * Image index
  52.      *
  53.      * @var int 
  54.      */
  55.     private $_imageIndex = 0;
  56.     
  57.     /**
  58.      * Name
  59.      *
  60.      * @var string 
  61.      */
  62.     protected $_name;
  63.     
  64.     /**
  65.      * Description
  66.      *
  67.      * @var string 
  68.      */
  69.     protected $_description;
  70.  
  71.     /**
  72.      * Proportional resize
  73.      *
  74.      * @var boolean 
  75.      */
  76.     protected $_resizeProportional;
  77.     
  78.     /**
  79.      * Create a new PHPPowerPoint_Slide_BaseDrawing
  80.      */
  81.     public function __construct()
  82.     {
  83.         // Initialise values
  84.         $this->_name                = '';
  85.         $this->_description            = '';
  86.         $this->_resizeProportional    = true;
  87.         
  88.         // Set image index
  89.         self::$_imageCounter++;
  90.         $this->_imageIndex             = self::$_imageCounter;
  91.         
  92.         // Initialize parent
  93.         parent::__construct();
  94.     }
  95.     
  96.     /**
  97.      * Get image index
  98.      *
  99.      * @return int 
  100.      */
  101.     public function getImageIndex({
  102.         return $this->_imageIndex;
  103.     }
  104.        
  105.     /**
  106.      * Get Name
  107.      *
  108.      * @return string 
  109.      */
  110.     public function getName({
  111.         return $this->_name;
  112.     }
  113.     
  114.     /**
  115.      * Set Name
  116.      *
  117.      * @param string $pValue 
  118.      */
  119.     public function setName($pValue ''{
  120.         $this->_name = $pValue;
  121.     }
  122.     
  123.     /**
  124.      * Get Description
  125.      *
  126.      * @return string 
  127.      */
  128.     public function getDescription({
  129.         return $this->_description;
  130.     }
  131.     
  132.     /**
  133.      * Set Description
  134.      *
  135.      * @param string $pValue 
  136.      */
  137.     public function setDescription($pValue ''{
  138.         $this->_description = $pValue;
  139.     }
  140.  
  141.     /**
  142.      * Set Width
  143.      *
  144.      * @param int $pValue 
  145.      */
  146.     public function setWidth($pValue 0{
  147.         // Resize proportional?
  148.         if ($this->_resizeProportional && $pValue != 0{
  149.             $ratio $this->_height / $this->_width;            
  150.             $this->_height = round($ratio $pValue);
  151.         }
  152.         
  153.         // Set width
  154.         $this->_width = $pValue;
  155.     }
  156.     
  157.     /**
  158.      * Set Height
  159.      *
  160.      * @param int $pValue 
  161.      */
  162.     public function setHeight($pValue 0{
  163.         // Resize proportional?
  164.         if ($this->_resizeProportional && $pValue != 0{
  165.             $ratio $this->_width / $this->_height;           
  166.             $this->_width = round($ratio $pValue);
  167.         }
  168.         
  169.         // Set height
  170.         $this->_height = $pValue;
  171.     }
  172.     
  173.     /**
  174.      * Set width and height with proportional resize
  175.      * @author Vincent@luo MSN:kele_100@hotmail.com
  176.      * @param int $width 
  177.      * @param int $height 
  178.      * @example $objDrawing->setResizeProportional(true);
  179.      * @example $objDrawing->setWidthAndHeight(160,120);
  180.      */
  181.     public function setWidthAndHeight($width 0$height 0{
  182.         $xratio $width $this->_width;
  183.         $yratio $height $this->_height;
  184.         if ($this->_resizeProportional && !($width == || $height == 0)) {
  185.             if (($xratio $this->_height$height{
  186.                 $this->_height = ceil($xratio $this->_height);
  187.                 $this->_width  = $width;
  188.             else {
  189.                 $this->_width    = ceil($yratio $this->_width);
  190.                 $this->_height    = $height;
  191.             }
  192.         }
  193.     }
  194.     
  195.     /**
  196.      * Get ResizeProportional
  197.      *
  198.      * @return boolean 
  199.      */
  200.     public function getResizeProportional({
  201.         return $this->_resizeProportional;
  202.     }
  203.     
  204.     /**
  205.      * Set ResizeProportional
  206.      *
  207.      * @param boolean $pValue 
  208.      */
  209.     public function setResizeProportional($pValue true{
  210.         $this->_resizeProportional = $pValue;
  211.     }
  212.  
  213.     /**
  214.      * Get hash code
  215.      *
  216.      * @return string    Hash code
  217.      */    
  218.     public function getHashCode({
  219.         return md5(
  220.               $this->_name
  221.             . $this->_description            
  222.             . parent::getHashCode()
  223.             . __CLASS__
  224.         );
  225.     }
  226.     
  227.     /**
  228.      * Hash index
  229.      *
  230.      * @var string 
  231.      */
  232.     private $_hashIndex;
  233.     
  234.     /**
  235.      * Get hash index
  236.      * 
  237.      * Note that this index may vary during script execution! Only reliable moment is
  238.      * while doing a write of a workbook and when changes are not allowed.
  239.      *
  240.      * @return string    Hash index
  241.      */
  242.     public function getHashIndex({
  243.         return $this->_hashIndex;
  244.     }
  245.     
  246.     /**
  247.      * Set hash index
  248.      * 
  249.      * Note that this index may vary during script execution! Only reliable moment is
  250.      * while doing a write of a workbook and when changes are not allowed.
  251.      *
  252.      * @param string    $value    Hash index
  253.      */
  254.     public function setHashIndex($value{
  255.         $this->_hashIndex = $value;
  256.     }
  257.         
  258.     /**
  259.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  260.      */
  261.     public function __clone({
  262.         $vars get_object_vars($this);
  263.         foreach ($vars as $key => $value{
  264.             if (is_object($value)) {
  265.                 $this->$key clone $value;
  266.             else {
  267.                 $this->$key $value;
  268.             }
  269.         }
  270.     }
  271. }

Documentation generated on Sat, 25 Apr 2009 11:36:42 +0200 by phpDocumentor 1.4.1