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

Source for file HeaderFooterDrawing.php

Documentation is available at HeaderFooterDrawing.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.2, 2010-01-11
  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 */
  47. require_once PHPEXCEL_ROOT 'PHPExcel/Worksheet/Drawing.php';
  48.  
  49.  
  50. /**
  51.  * PHPExcel_Worksheet_HeaderFooterDrawing
  52.  *
  53.  * @category   PHPExcel
  54.  * @package    PHPExcel_Worksheet
  55.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  56.  */
  57. {    
  58.     /**
  59.      * Path
  60.      *
  61.      * @var string 
  62.      */
  63.     private $_path;
  64.     
  65.     /**
  66.      * Name
  67.      *
  68.      * @var string 
  69.      */
  70.     protected $_name;
  71.     
  72.     /**
  73.      * Offset X
  74.      *
  75.      * @var int 
  76.      */
  77.     protected $_offsetX;
  78.     
  79.     /**
  80.      * Offset Y
  81.      *
  82.      * @var int 
  83.      */
  84.     protected $_offsetY;
  85.     
  86.     /**
  87.      * Width
  88.      *
  89.      * @var int 
  90.      */
  91.     protected $_width;
  92.     
  93.     /**
  94.      * Height
  95.      *
  96.      * @var int 
  97.      */
  98.     protected $_height;
  99.     
  100.     /**
  101.      * Proportional resize
  102.      *
  103.      * @var boolean 
  104.      */
  105.     protected $_resizeProportional;
  106.     
  107.     /**
  108.      * Create a new PHPExcel_Worksheet_HeaderFooterDrawing
  109.      */
  110.     public function __construct()
  111.     {
  112.         // Initialise values
  113.         $this->_path                = '';
  114.         $this->_name                = '';
  115.         $this->_offsetX                = 0;
  116.         $this->_offsetY                = 0;
  117.         $this->_width                = 0;
  118.         $this->_height                = 0;
  119.         $this->_resizeProportional    = true;
  120.     }
  121.        
  122.     /**
  123.      * Get Name
  124.      *
  125.      * @return string 
  126.      */
  127.     public function getName({
  128.         return $this->_name;
  129.     }
  130.     
  131.     /**
  132.      * Set Name
  133.      *
  134.      * @param string $pValue 
  135.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  136.      */
  137.     public function setName($pValue ''{
  138.         $this->_name = $pValue;
  139.         return $this;
  140.     }
  141.     
  142.     /**
  143.      * Get OffsetX
  144.      *
  145.      * @return int 
  146.      */
  147.     public function getOffsetX({
  148.         return $this->_offsetX;
  149.     }
  150.     
  151.     /**
  152.      * Set OffsetX
  153.      *
  154.      * @param int $pValue 
  155.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  156.      */
  157.     public function setOffsetX($pValue 0{
  158.         $this->_offsetX = $pValue;
  159.         return $this;
  160.     }
  161.     
  162.     /**
  163.      * Get OffsetY
  164.      *
  165.      * @return int 
  166.      */
  167.     public function getOffsetY({
  168.         return $this->_offsetY;
  169.     }
  170.     
  171.     /**
  172.      * Set OffsetY
  173.      *
  174.      * @param int $pValue 
  175.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  176.      */
  177.     public function setOffsetY($pValue 0{
  178.         $this->_offsetY = $pValue;
  179.         return $this;
  180.     }
  181.     
  182.     /**
  183.      * Get Width
  184.      *
  185.      * @return int 
  186.      */
  187.     public function getWidth({
  188.         return $this->_width;
  189.     }
  190.     
  191.     /**
  192.      * Set Width
  193.      *
  194.      * @param int $pValue 
  195.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  196.      */
  197.     public function setWidth($pValue 0{
  198.         // Resize proportional?
  199.         if ($this->_resizeProportional && $pValue != 0{
  200.             $ratio $this->_width / $this->_height;            
  201.             $this->_height = round($ratio $pValue);
  202.         }
  203.         
  204.         // Set width
  205.         $this->_width = $pValue;
  206.         
  207.         return $this;
  208.     }
  209.     
  210.     /**
  211.      * Get Height
  212.      *
  213.      * @return int 
  214.      */
  215.     public function getHeight({
  216.         return $this->_height;
  217.     }
  218.     
  219.     /**
  220.      * Set Height
  221.      *
  222.      * @param int $pValue 
  223.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  224.      */
  225.     public function setHeight($pValue 0{
  226.         // Resize proportional?
  227.         if ($this->_resizeProportional && $pValue != 0{
  228.             $ratio $this->_width / $this->_height;           
  229.             $this->_width = round($ratio $pValue);
  230.         }
  231.         
  232.         // Set height
  233.         $this->_height = $pValue;
  234.         
  235.         return $this;
  236.     }
  237.     
  238.     /**
  239.      * Set width and height with proportional resize
  240.      * Example:
  241.      * <code>
  242.      * $objDrawing->setResizeProportional(true);
  243.      * $objDrawing->setWidthAndHeight(160,120);
  244.      * </code>
  245.      *
  246.      * @author Vincent@luo MSN:kele_100@hotmail.com
  247.      * @param int $width 
  248.      * @param int $height 
  249.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  250.      */
  251.     public function setWidthAndHeight($width 0$height 0{
  252.         $xratio $width $this->_width;
  253.         $yratio $height $this->_height;
  254.         if ($this->_resizeProportional && !($width == || $height == 0)) {
  255.             if (($xratio $this->_height$height{
  256.                 $this->_height = ceil($xratio $this->_height);
  257.                 $this->_width  = $width;
  258.             else {
  259.                 $this->_width    = ceil($yratio $this->_width);
  260.                 $this->_height    = $height;
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265.     
  266.     /**
  267.      * Get ResizeProportional
  268.      *
  269.      * @return boolean 
  270.      */
  271.     public function getResizeProportional({
  272.         return $this->_resizeProportional;
  273.     }
  274.     
  275.     /**
  276.      * Set ResizeProportional
  277.      *
  278.      * @param boolean $pValue 
  279.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  280.      */
  281.     public function setResizeProportional($pValue true{
  282.         $this->_resizeProportional = $pValue;
  283.         return $this;
  284.     }
  285.     
  286.     /**
  287.      * Get Filename
  288.      *
  289.      * @return string 
  290.      */
  291.     public function getFilename({
  292.         return basename($this->_path);
  293.     }
  294.     
  295.     /**
  296.      * Get Extension
  297.      *
  298.      * @return string 
  299.      */
  300.     public function getExtension({
  301.         return end(explode("."basename($this->_path)));
  302.     }
  303.     
  304.     /**
  305.      * Get Path
  306.      *
  307.      * @return string 
  308.      */
  309.     public function getPath({
  310.         return $this->_path;
  311.     }
  312.     
  313.     /**
  314.      * Set Path
  315.      *
  316.      * @param     string         $pValue            File path
  317.      * @param     boolean        $pVerifyFile    Verify file
  318.      * @throws     Exception
  319.      * @return PHPExcel_Worksheet_HeaderFooterDrawing 
  320.      */
  321.     public function setPath($pValue ''$pVerifyFile true{
  322.         if ($pVerifyFile{
  323.             if (file_exists($pValue)) {
  324.                 $this->_path = $pValue;
  325.                 
  326.                 if ($this->_width == && $this->_height == 0{
  327.                     // Get width/height
  328.                     list($this->_width$this->_heightgetimagesize($pValue);
  329.                 }
  330.             else {
  331.                 throw new Exception("File $pValue not found!");
  332.             }
  333.         else {
  334.             $this->_path = $pValue;
  335.         }
  336.         return $this;
  337.     }
  338.  
  339.     /**
  340.      * Get hash code
  341.      *
  342.      * @return string    Hash code
  343.      */    
  344.     public function getHashCode({
  345.         return md5(
  346.               $this->_path
  347.             . $this->_name
  348.             . $this->_offsetX
  349.             . $this->_offsetY
  350.             . $this->_width
  351.             . $this->_height
  352.             . __CLASS__
  353.         );
  354.     }
  355.     
  356.     /**
  357.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  358.      */
  359.     public function __clone({
  360.         $vars get_object_vars($this);
  361.         foreach ($vars as $key => $value{
  362.             if (is_object($value)) {
  363.                 $this->$key clone $value;
  364.             else {
  365.                 $this->$key $value;
  366.             }
  367.         }
  368.     }
  369. }

Documentation generated on Mon, 11 Jan 2010 08:11:19 +0100 by phpDocumentor 1.4.1