64d835a80ddc2b21c486f566948cb67d66226938.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPExcel_Worksheet_SheetView
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Worksheet
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Worksheet_SheetView
  35. {
  36. /* Sheet View types */
  37. const SHEETVIEW_NORMAL = 'normal';
  38. const SHEETVIEW_PAGE_LAYOUT = 'pageLayout';
  39. const SHEETVIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview';
  40. private static $_sheetViewTypes = array(
  41. self::SHEETVIEW_NORMAL,
  42. self::SHEETVIEW_PAGE_LAYOUT,
  43. self::SHEETVIEW_PAGE_BREAK_PREVIEW,
  44. );
  45. /**
  46. * ZoomScale
  47. *
  48. * Valid values range from 10 to 400.
  49. *
  50. * @var int
  51. */
  52. private $_zoomScale = 100;
  53. /**
  54. * ZoomScaleNormal
  55. *
  56. * Valid values range from 10 to 400.
  57. *
  58. * @var int
  59. */
  60. private $_zoomScaleNormal = 100;
  61. /**
  62. * View
  63. *
  64. * Valid values range from 10 to 400.
  65. *
  66. * @var string
  67. */
  68. private $_sheetviewType = self::SHEETVIEW_NORMAL;
  69. /**
  70. * Create a new PHPExcel_Worksheet_SheetView
  71. */
  72. public function __construct()
  73. {
  74. }
  75. /**
  76. * Get ZoomScale
  77. *
  78. * @return int
  79. */
  80. public function getZoomScale() {
  81. return $this->_zoomScale;
  82. }
  83. /**
  84. * Set ZoomScale
  85. *
  86. * Valid values range from 10 to 400.
  87. *
  88. * @param int $pValue
  89. * @throws PHPExcel_Exception
  90. * @return PHPExcel_Worksheet_SheetView
  91. */
  92. public function setZoomScale($pValue = 100) {
  93. // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  94. // but it is apparently still able to handle any scale >= 1
  95. if (($pValue >= 1) || is_null($pValue)) {
  96. $this->_zoomScale = $pValue;
  97. } else {
  98. throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
  99. }
  100. return $this;
  101. }
  102. /**
  103. * Get ZoomScaleNormal
  104. *
  105. * @return int
  106. */
  107. public function getZoomScaleNormal() {
  108. return $this->_zoomScaleNormal;
  109. }
  110. /**
  111. * Set ZoomScale
  112. *
  113. * Valid values range from 10 to 400.
  114. *
  115. * @param int $pValue
  116. * @throws PHPExcel_Exception
  117. * @return PHPExcel_Worksheet_SheetView
  118. */
  119. public function setZoomScaleNormal($pValue = 100) {
  120. if (($pValue >= 1) || is_null($pValue)) {
  121. $this->_zoomScaleNormal = $pValue;
  122. } else {
  123. throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
  124. }
  125. return $this;
  126. }
  127. /**
  128. * Get View
  129. *
  130. * @return string
  131. */
  132. public function getView() {
  133. return $this->_sheetviewType;
  134. }
  135. /**
  136. * Set View
  137. *
  138. * Valid values are
  139. * 'normal' self::SHEETVIEW_NORMAL
  140. * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT
  141. * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW
  142. *
  143. * @param string $pValue
  144. * @throws PHPExcel_Exception
  145. * @return PHPExcel_Worksheet_SheetView
  146. */
  147. public function setView($pValue = NULL) {
  148. // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview'
  149. // via the user interface
  150. if ($pValue === NULL)
  151. $pValue = self::SHEETVIEW_NORMAL;
  152. if (in_array($pValue, self::$_sheetViewTypes)) {
  153. $this->_sheetviewType = $pValue;
  154. } else {
  155. throw new PHPExcel_Exception("Invalid sheetview layout type.");
  156. }
  157. return $this;
  158. }
  159. /**
  160. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  161. */
  162. public function __clone() {
  163. $vars = get_object_vars($this);
  164. foreach ($vars as $key => $value) {
  165. if (is_object($value)) {
  166. $this->$key = clone $value;
  167. } else {
  168. $this->$key = $value;
  169. }
  170. }
  171. }
  172. }