Dimension.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * PHPExcel_Worksheet_Dimension
  4. *
  5. * Copyright (c) 2006 - 2015 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 - 2015 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. abstract class PHPExcel_Worksheet_Dimension
  28. {
  29. /**
  30. * Visible?
  31. *
  32. * @var bool
  33. */
  34. private $visible = true;
  35. /**
  36. * Outline level
  37. *
  38. * @var int
  39. */
  40. private $outlineLevel = 0;
  41. /**
  42. * Collapsed
  43. *
  44. * @var bool
  45. */
  46. private $collapsed = false;
  47. /**
  48. * Index to cellXf. Null value means row has no explicit cellXf format.
  49. *
  50. * @var int|null
  51. */
  52. private $xfIndex;
  53. /**
  54. * Create a new PHPExcel_Worksheet_Dimension
  55. *
  56. * @param int $pIndex Numeric row index
  57. */
  58. public function __construct($initialValue = null)
  59. {
  60. // set dimension as unformatted by default
  61. $this->xfIndex = $initialValue;
  62. }
  63. /**
  64. * Get Visible
  65. *
  66. * @return bool
  67. */
  68. public function getVisible()
  69. {
  70. return $this->visible;
  71. }
  72. /**
  73. * Set Visible
  74. *
  75. * @param bool $pValue
  76. * @return PHPExcel_Worksheet_Dimension
  77. */
  78. public function setVisible($pValue = true)
  79. {
  80. $this->visible = $pValue;
  81. return $this;
  82. }
  83. /**
  84. * Get Outline Level
  85. *
  86. * @return int
  87. */
  88. public function getOutlineLevel()
  89. {
  90. return $this->outlineLevel;
  91. }
  92. /**
  93. * Set Outline Level
  94. *
  95. * Value must be between 0 and 7
  96. *
  97. * @param int $pValue
  98. * @throws PHPExcel_Exception
  99. * @return PHPExcel_Worksheet_Dimension
  100. */
  101. public function setOutlineLevel($pValue)
  102. {
  103. if ($pValue < 0 || $pValue > 7) {
  104. throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
  105. }
  106. $this->outlineLevel = $pValue;
  107. return $this;
  108. }
  109. /**
  110. * Get Collapsed
  111. *
  112. * @return bool
  113. */
  114. public function getCollapsed()
  115. {
  116. return $this->collapsed;
  117. }
  118. /**
  119. * Set Collapsed
  120. *
  121. * @param bool $pValue
  122. * @return PHPExcel_Worksheet_Dimension
  123. */
  124. public function setCollapsed($pValue = true)
  125. {
  126. $this->collapsed = $pValue;
  127. return $this;
  128. }
  129. /**
  130. * Get index to cellXf
  131. *
  132. * @return int
  133. */
  134. public function getXfIndex()
  135. {
  136. return $this->xfIndex;
  137. }
  138. /**
  139. * Set index to cellXf
  140. *
  141. * @param int $pValue
  142. * @return PHPExcel_Worksheet_Dimension
  143. */
  144. public function setXfIndex($pValue = 0)
  145. {
  146. $this->xfIndex = $pValue;
  147. return $this;
  148. }
  149. /**
  150. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  151. */
  152. public function __clone()
  153. {
  154. $vars = get_object_vars($this);
  155. foreach ($vars as $key => $value) {
  156. if (is_object($value)) {
  157. $this->$key = clone $value;
  158. } else {
  159. $this->$key = $value;
  160. }
  161. }
  162. }
  163. }