SheetView.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. * PHPExcel_Worksheet_SheetView
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Worksheet
  32. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Worksheet_SheetView
  35. {
  36. /**
  37. * ZoomScale
  38. *
  39. * Valid values range from 10 to 400.
  40. *
  41. * @var int
  42. */
  43. private $_zoomScale = 100;
  44. /**
  45. * ZoomScaleNormal
  46. *
  47. * Valid values range from 10 to 400.
  48. *
  49. * @var int
  50. */
  51. private $_zoomScaleNormal = 100;
  52. /**
  53. * Create a new PHPExcel_Worksheet_SheetView
  54. */
  55. public function __construct()
  56. {
  57. }
  58. /**
  59. * Get ZoomScale
  60. *
  61. * @return int
  62. */
  63. public function getZoomScale() {
  64. return $this->_zoomScale;
  65. }
  66. /**
  67. * Set ZoomScale
  68. *
  69. * Valid values range from 10 to 400.
  70. *
  71. * @param int $pValue
  72. * @throws Exception
  73. * @return PHPExcel_Worksheet_SheetView
  74. */
  75. public function setZoomScale($pValue = 100) {
  76. // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
  77. // but it is apparently still able to handle any scale >= 1
  78. if (($pValue >= 1) || is_null($pValue)) {
  79. $this->_zoomScale = $pValue;
  80. } else {
  81. throw new Exception("Scale must be greater than or equal to 1.");
  82. }
  83. return $this;
  84. }
  85. /**
  86. * Get ZoomScaleNormal
  87. *
  88. * @return int
  89. */
  90. public function getZoomScaleNormal() {
  91. return $this->_zoomScaleNormal;
  92. }
  93. /**
  94. * Set ZoomScale
  95. *
  96. * Valid values range from 10 to 400.
  97. *
  98. * @param int $pValue
  99. * @throws Exception
  100. * @return PHPExcel_Worksheet_SheetView
  101. */
  102. public function setZoomScaleNormal($pValue = 100) {
  103. if (($pValue >= 1) || is_null($pValue)) {
  104. $this->_zoomScaleNormal = $pValue;
  105. } else {
  106. throw new Exception("Scale must be greater than or equal to 1.");
  107. }
  108. return $this;
  109. }
  110. /**
  111. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  112. */
  113. public function __clone() {
  114. $vars = get_object_vars($this);
  115. foreach ($vars as $key => $value) {
  116. if (is_object($value)) {
  117. $this->$key = clone $value;
  118. } else {
  119. $this->$key = $value;
  120. }
  121. }
  122. }
  123. }