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

Source for file Drawing.php

Documentation is available at Drawing.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  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   PHPExcel
  22.  * @package    PHPExcel_Worksheet_Drawing
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.0, 2009-08-10
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../');
  35. }
  36.  
  37. /** PHPExcel_IComparable */
  38. require_once PHPEXCEL_ROOT 'PHPExcel/IComparable.php';
  39.  
  40. /** PHPExcel_Worksheet */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/Worksheet.php';
  42.  
  43. /** PHPExcel_Worksheet_BaseDrawing */
  44. require_once PHPEXCEL_ROOT 'PHPExcel/Worksheet/BaseDrawing.php';
  45.  
  46. /** PHPExcel_Worksheet_Drawing_Shadow */
  47. require_once PHPEXCEL_ROOT 'PHPExcel/Worksheet/Drawing/Shadow.php';
  48.  
  49.  
  50. /**
  51.  * PHPExcel_Worksheet_Drawing
  52.  *
  53.  * @category   PHPExcel
  54.  * @package    PHPExcel_Worksheet_Drawing
  55.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  56.  */
  57. {        
  58.     /**
  59.      * Path
  60.      *
  61.      * @var string 
  62.      */
  63.     private $_path;
  64.     
  65.     /**
  66.      * Create a new PHPExcel_Worksheet_Drawing
  67.      */
  68.     public function __construct()
  69.     {
  70.         // Initialise values
  71.         $this->_path                = '';
  72.         
  73.         // Initialize parent
  74.         parent::__construct();
  75.     }
  76.     
  77.     /**
  78.      * Get Filename
  79.      *
  80.      * @return string 
  81.      */
  82.     public function getFilename({
  83.         return basename($this->_path);
  84.     }
  85.     
  86.     /**
  87.      * Get indexed filename (using image index)
  88.      *
  89.      * @return string 
  90.      */
  91.     public function getIndexedFilename({
  92.         $fileName $this->getFilename();
  93.         $fileName str_replace(' ''_'$fileName);
  94.         return str_replace('.' $this->getExtension()''$fileName$this->getImageIndex('.' $this->getExtension();
  95.     }
  96.     
  97.     /**
  98.      * Get Extension
  99.      *
  100.      * @return string 
  101.      */
  102.     public function getExtension({
  103.         $exploded explode("."basename($this->_path));
  104.         return $exploded[count($exploded1];
  105.     }
  106.     
  107.     /**
  108.      * Get Path
  109.      *
  110.      * @return string 
  111.      */
  112.     public function getPath({
  113.         return $this->_path;
  114.     }
  115.     
  116.     /**
  117.      * Set Path
  118.      *
  119.      * @param     string         $pValue            File path
  120.      * @param     boolean        $pVerifyFile    Verify file
  121.      * @throws     Exception
  122.      * @return PHPExcel_Worksheet_Drawing 
  123.      */
  124.     public function setPath($pValue ''$pVerifyFile true{
  125.         if ($pVerifyFile{
  126.             if (file_exists($pValue)) {
  127.                 $this->_path = $pValue;
  128.                 
  129.                 if ($this->_width == && $this->_height == 0{
  130.                     // Get width/height
  131.                     list($this->_width$this->_heightgetimagesize($pValue);
  132.                 }
  133.             else {
  134.                 throw new Exception("File $pValue not found!");
  135.             }
  136.         else {
  137.             $this->_path = $pValue;
  138.         }
  139.         return $this;
  140.     }
  141.  
  142.     /**
  143.      * Get hash code
  144.      *
  145.      * @return string    Hash code
  146.      */    
  147.     public function getHashCode({
  148.         return md5(
  149.               $this->_path
  150.             . parent::getHashCode()
  151.             . __CLASS__
  152.         );
  153.     }
  154.     
  155.     /**
  156.      * Hash index
  157.      *
  158.      * @var string 
  159.      */
  160.     private $_hashIndex;
  161.     
  162.     /**
  163.      * Get hash index
  164.      * 
  165.      * Note that this index may vary during script execution! Only reliable moment is
  166.      * while doing a write of a workbook and when changes are not allowed.
  167.      *
  168.      * @return string    Hash index
  169.      */
  170.     public function getHashIndex({
  171.         return $this->_hashIndex;
  172.     }
  173.     
  174.     /**
  175.      * Set hash index
  176.      * 
  177.      * Note that this index may vary during script execution! Only reliable moment is
  178.      * while doing a write of a workbook and when changes are not allowed.
  179.      *
  180.      * @param string    $value    Hash index
  181.      */
  182.     public function setHashIndex($value{
  183.         $this->_hashIndex = $value;
  184.     }
  185.         
  186.     /**
  187.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  188.      */
  189.     public function __clone({
  190.         $vars get_object_vars($this);
  191.         foreach ($vars as $key => $value{
  192.             if (is_object($value)) {
  193.                 $this->$key clone $value;
  194.             else {
  195.                 $this->$key $value;
  196.             }
  197.         }
  198.     }
  199. }

Documentation generated on Mon, 10 Aug 2009 08:03:17 +0200 by phpDocumentor 1.4.1