[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Worksheet/ -> SheetView.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_Worksheet_SheetView
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel_Worksheet
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_Worksheet_SheetView
  29  {
  30  
  31      /* Sheet View types */
  32      const SHEETVIEW_NORMAL             = 'normal';
  33      const SHEETVIEW_PAGE_LAYOUT        = 'pageLayout';
  34      const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview';
  35  
  36      private static $sheetViewTypes = array(
  37          self::SHEETVIEW_NORMAL,
  38          self::SHEETVIEW_PAGE_LAYOUT,
  39          self::SHEETVIEW_PAGE_BREAK_PREVIEW,
  40      );
  41  
  42      /**
  43       * ZoomScale
  44       *
  45       * Valid values range from 10 to 400.
  46       *
  47       * @var int
  48       */
  49      private $zoomScale = 100;
  50  
  51      /**
  52       * ZoomScaleNormal
  53       *
  54       * Valid values range from 10 to 400.
  55       *
  56       * @var int
  57       */
  58      private $zoomScaleNormal = 100;
  59  
  60      /**
  61       * View
  62       *
  63       * Valid values range from 10 to 400.
  64       *
  65       * @var string
  66       */
  67      private $sheetviewType = self::SHEETVIEW_NORMAL;
  68  
  69      /**
  70       * Create a new PHPExcel_Worksheet_SheetView
  71       */
  72      public function __construct()
  73      {
  74      }
  75  
  76      /**
  77       * Get ZoomScale
  78       *
  79       * @return int
  80       */
  81      public function getZoomScale()
  82      {
  83          return $this->zoomScale;
  84      }
  85  
  86      /**
  87       * Set ZoomScale
  88       *
  89       * Valid values range from 10 to 400.
  90       *
  91       * @param     int     $pValue
  92       * @throws     PHPExcel_Exception
  93       * @return PHPExcel_Worksheet_SheetView
  94       */
  95      public function setZoomScale($pValue = 100)
  96      {
  97          // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  98          // but it is apparently still able to handle any scale >= 1
  99          if (($pValue >= 1) || is_null($pValue)) {
 100              $this->zoomScale = $pValue;
 101          } else {
 102              throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
 103          }
 104          return $this;
 105      }
 106  
 107      /**
 108       * Get ZoomScaleNormal
 109       *
 110       * @return int
 111       */
 112      public function getZoomScaleNormal()
 113      {
 114          return $this->zoomScaleNormal;
 115      }
 116  
 117      /**
 118       * Set ZoomScale
 119       *
 120       * Valid values range from 10 to 400.
 121       *
 122       * @param     int     $pValue
 123       * @throws     PHPExcel_Exception
 124       * @return PHPExcel_Worksheet_SheetView
 125       */
 126      public function setZoomScaleNormal($pValue = 100)
 127      {
 128          if (($pValue >= 1) || is_null($pValue)) {
 129              $this->zoomScaleNormal = $pValue;
 130          } else {
 131              throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
 132          }
 133          return $this;
 134      }
 135  
 136      /**
 137       * Get View
 138       *
 139       * @return string
 140       */
 141      public function getView()
 142      {
 143          return $this->sheetviewType;
 144      }
 145  
 146      /**
 147       * Set View
 148       *
 149       * Valid values are
 150       *        'normal'            self::SHEETVIEW_NORMAL
 151       *        'pageLayout'        self::SHEETVIEW_PAGE_LAYOUT
 152       *        'pageBreakPreview'  self::SHEETVIEW_PAGE_BREAK_PREVIEW
 153       *
 154       * @param     string     $pValue
 155       * @throws     PHPExcel_Exception
 156       * @return PHPExcel_Worksheet_SheetView
 157       */
 158      public function setView($pValue = null)
 159      {
 160          // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface
 161          if ($pValue === null) {
 162              $pValue = self::SHEETVIEW_NORMAL;
 163          }
 164          if (in_array($pValue, self::$sheetViewTypes)) {
 165              $this->sheetviewType = $pValue;
 166          } else {
 167              throw new PHPExcel_Exception("Invalid sheetview layout type.");
 168          }
 169  
 170          return $this;
 171      }
 172  
 173      /**
 174       * Implement PHP __clone to create a deep clone, not just a shallow copy.
 175       */
 176      public function __clone()
 177      {
 178          $vars = get_object_vars($this);
 179          foreach ($vars as $key => $value) {
 180              if (is_object($value)) {
 181                  $this->$key = clone $value;
 182              } else {
 183                  $this->$key = $value;
 184              }
 185          }
 186      }
 187  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1