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

Documentation generated on Mon, 05 Jan 2009 20:37:53 +0100 by phpDocumentor 1.4.1