RowDimension.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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_RowDimension
  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_RowDimension
  35. {
  36. /**
  37. * Row index
  38. *
  39. * @var int
  40. */
  41. private $_rowIndex;
  42. /**
  43. * Row height (in pt)
  44. *
  45. * When this is set to a negative value, the row height should be ignored by IWriter
  46. *
  47. * @var double
  48. */
  49. private $_rowHeight = -1;
  50. /**
  51. * Visible?
  52. *
  53. * @var bool
  54. */
  55. private $_visible = true;
  56. /**
  57. * Outline level
  58. *
  59. * @var int
  60. */
  61. private $_outlineLevel = 0;
  62. /**
  63. * Collapsed
  64. *
  65. * @var bool
  66. */
  67. private $_collapsed = false;
  68. /**
  69. * Index to cellXf. Null value means row has no explicit cellXf format.
  70. *
  71. * @var int|null
  72. */
  73. private $_xfIndex;
  74. /**
  75. * Create a new PHPExcel_Worksheet_RowDimension
  76. *
  77. * @param int $pIndex Numeric row index
  78. */
  79. public function __construct($pIndex = 0)
  80. {
  81. // Initialise values
  82. $this->_rowIndex = $pIndex;
  83. // set row dimension as unformatted by default
  84. $this->_xfIndex = null;
  85. }
  86. /**
  87. * Get Row Index
  88. *
  89. * @return int
  90. */
  91. public function getRowIndex() {
  92. return $this->_rowIndex;
  93. }
  94. /**
  95. * Set Row Index
  96. *
  97. * @param int $pValue
  98. * @return PHPExcel_Worksheet_RowDimension
  99. */
  100. public function setRowIndex($pValue) {
  101. $this->_rowIndex = $pValue;
  102. return $this;
  103. }
  104. /**
  105. * Get Row Height
  106. *
  107. * @return double
  108. */
  109. public function getRowHeight() {
  110. return $this->_rowHeight;
  111. }
  112. /**
  113. * Set Row Height
  114. *
  115. * @param double $pValue
  116. * @return PHPExcel_Worksheet_RowDimension
  117. */
  118. public function setRowHeight($pValue = -1) {
  119. $this->_rowHeight = $pValue;
  120. return $this;
  121. }
  122. /**
  123. * Get Visible
  124. *
  125. * @return bool
  126. */
  127. public function getVisible() {
  128. return $this->_visible;
  129. }
  130. /**
  131. * Set Visible
  132. *
  133. * @param bool $pValue
  134. * @return PHPExcel_Worksheet_RowDimension
  135. */
  136. public function setVisible($pValue = true) {
  137. $this->_visible = $pValue;
  138. return $this;
  139. }
  140. /**
  141. * Get Outline Level
  142. *
  143. * @return int
  144. */
  145. public function getOutlineLevel() {
  146. return $this->_outlineLevel;
  147. }
  148. /**
  149. * Set Outline Level
  150. *
  151. * Value must be between 0 and 7
  152. *
  153. * @param int $pValue
  154. * @throws Exception
  155. * @return PHPExcel_Worksheet_RowDimension
  156. */
  157. public function setOutlineLevel($pValue) {
  158. if ($pValue < 0 || $pValue > 7) {
  159. throw new Exception("Outline level must range between 0 and 7.");
  160. }
  161. $this->_outlineLevel = $pValue;
  162. return $this;
  163. }
  164. /**
  165. * Get Collapsed
  166. *
  167. * @return bool
  168. */
  169. public function getCollapsed() {
  170. return $this->_collapsed;
  171. }
  172. /**
  173. * Set Collapsed
  174. *
  175. * @param bool $pValue
  176. * @return PHPExcel_Worksheet_RowDimension
  177. */
  178. public function setCollapsed($pValue = true) {
  179. $this->_collapsed = $pValue;
  180. return $this;
  181. }
  182. /**
  183. * Get index to cellXf
  184. *
  185. * @return int
  186. */
  187. public function getXfIndex()
  188. {
  189. return $this->_xfIndex;
  190. }
  191. /**
  192. * Set index to cellXf
  193. *
  194. * @param int $pValue
  195. * @return PHPExcel_Worksheet_RowDimension
  196. */
  197. public function setXfIndex($pValue = 0)
  198. {
  199. $this->_xfIndex = $pValue;
  200. return $this;
  201. }
  202. /**
  203. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  204. */
  205. public function __clone() {
  206. $vars = get_object_vars($this);
  207. foreach ($vars as $key => $value) {
  208. if (is_object($value)) {
  209. $this->$key = clone $value;
  210. } else {
  211. $this->$key = $value;
  212. }
  213. }
  214. }
  215. }