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

Source for file Drawing.php

Documentation is available at Drawing.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2008 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
  23.  * @copyright  Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.3, 2008-08-25
  26.  */
  27.  
  28.  
  29. /** PHPExcel_IComparable */
  30. require_once 'PHPExcel/IComparable.php';
  31.  
  32. /** PHPExcel_Worksheet */
  33. require_once 'PHPExcel/Worksheet.php';
  34.  
  35. /** PHPExcel_Worksheet_BaseDrawing */
  36. require_once 'PHPExcel/Worksheet/BaseDrawing.php';
  37.  
  38. /** PHPExcel_Worksheet_Drawing_Shadow */
  39. require_once 'PHPExcel/Worksheet/Drawing/Shadow.php';
  40.  
  41.  
  42. /**
  43.  * PHPExcel_Worksheet_Drawing
  44.  *
  45.  * @category   PHPExcel
  46.  * @package    PHPExcel_Worksheet
  47.  * @copyright  Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  48.  */
  49. {        
  50.     /**
  51.      * Path
  52.      *
  53.      * @var string 
  54.      */
  55.     private $_path;
  56.     
  57.     /**
  58.      * Create a new PHPExcel_Worksheet_Drawing
  59.      */
  60.     public function __construct()
  61.     {
  62.         // Initialise values
  63.         $this->_path                = '';
  64.         
  65.         // Initialize parent
  66.         parent::__construct();
  67.     }
  68.     
  69.     /**
  70.      * Get Filename
  71.      *
  72.      * @return string 
  73.      */
  74.     public function getFilename() {
  75.         return basename($this->_path);
  76.     }
  77.     
  78.     /**
  79.      * Get Extension
  80.      *
  81.      * @return string 
  82.      */
  83.     public function getExtension() {
  84.         $exploded = explode(".", basename($this->_path));
  85.         return $exploded[count($exploded) - 1];
  86.     }
  87.     
  88.     /**
  89.      * Get Path
  90.      *
  91.      * @return string 
  92.      */
  93.     public function getPath() {
  94.         return $this->_path;
  95.     }
  96.     
  97.     /**
  98.      * Set Path
  99.      *
  100.      * @param     string         $pValue            File path
  101.      * @param     boolean        $pVerifyFile    Verify file
  102.      * @throws     Exception
  103.      */
  104.     public function setPath($pValue = '', $pVerifyFile = true) {
  105.         if ($pVerifyFile) {
  106.             if (file_exists($pValue)) {
  107.                 $this->_path = $pValue;
  108.                 
  109.                 if ($this->_width == 0 && $this->_height == 0) {
  110.                     // Get width/height
  111.                     list($this->_width, $this->_height) = getimagesize($pValue);
  112.                 }
  113.             } else {
  114.                 throw new Exception("File $pValue not found!");
  115.             }
  116.         } else {
  117.             $this->_path = $pValue;
  118.         }
  119.     }
  120.  
  121.     /**
  122.      * Get hash code
  123.      *
  124.      * @return string    Hash code
  125.      */    
  126.     public function getHashCode() {
  127.         return md5(
  128.               $this->_path
  129.             . parent::getHashCode()
  130.             . __CLASS__
  131.         );
  132.     }
  133.         
  134.     /**
  135.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  136.      */
  137.     public function __clone() {
  138.         $vars = get_object_vars($this);
  139.         foreach ($vars as $key => $value) {
  140.             if (is_object($value)) {
  141.                 $this->$key = clone $value;
  142.             } else {
  143.                 $this->$key = $value;
  144.             }
  145.         }
  146.     }
  147. }

Documentation generated on Mon, 25 Aug 2008 13:36:24 +0200 by phpDocumentor 1.4.1