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

Documentation generated on Sun, 27 Feb 2011 16:32:17 -0800 by phpDocumentor 1.4.3