5e557721effd18eec5b60c846f4e3fa211f7fbca.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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_ColumnDimension
  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_ColumnDimension
  35. {
  36. /**
  37. * Column index
  38. *
  39. * @var int
  40. */
  41. private $_columnIndex;
  42. /**
  43. * Column width
  44. *
  45. * When this is set to a negative value, the column width should be ignored by IWriter
  46. *
  47. * @var double
  48. */
  49. private $_width = -1;
  50. /**
  51. * Auto size?
  52. *
  53. * @var bool
  54. */
  55. private $_autoSize = false;
  56. /**
  57. * Visible?
  58. *
  59. * @var bool
  60. */
  61. private $_visible = true;
  62. /**
  63. * Outline level
  64. *
  65. * @var int
  66. */
  67. private $_outlineLevel = 0;
  68. /**
  69. * Collapsed
  70. *
  71. * @var bool
  72. */
  73. private $_collapsed = false;
  74. /**
  75. * Index to cellXf
  76. *
  77. * @var int
  78. */
  79. private $_xfIndex;
  80. /**
  81. * Create a new PHPExcel_Worksheet_ColumnDimension
  82. *
  83. * @param string $pIndex Character column index
  84. */
  85. public function __construct($pIndex = 'A')
  86. {
  87. // Initialise values
  88. $this->_columnIndex = $pIndex;
  89. // set default index to cellXf
  90. $this->_xfIndex = 0;
  91. }
  92. /**
  93. * Get ColumnIndex
  94. *
  95. * @return string
  96. */
  97. public function getColumnIndex() {
  98. return $this->_columnIndex;
  99. }
  100. /**
  101. * Set ColumnIndex
  102. *
  103. * @param string $pValue
  104. * @return PHPExcel_Worksheet_ColumnDimension
  105. */
  106. public function setColumnIndex($pValue) {
  107. $this->_columnIndex = $pValue;
  108. return $this;
  109. }
  110. /**
  111. * Get Width
  112. *
  113. * @return double
  114. */
  115. public function getWidth() {
  116. return $this->_width;
  117. }
  118. /**
  119. * Set Width
  120. *
  121. * @param double $pValue
  122. * @return PHPExcel_Worksheet_ColumnDimension
  123. */
  124. public function setWidth($pValue = -1) {
  125. $this->_width = $pValue;
  126. return $this;
  127. }
  128. /**
  129. * Get Auto Size
  130. *
  131. * @return bool
  132. */
  133. public function getAutoSize() {
  134. return $this->_autoSize;
  135. }
  136. /**
  137. * Set Auto Size
  138. *
  139. * @param bool $pValue
  140. * @return PHPExcel_Worksheet_ColumnDimension
  141. */
  142. public function setAutoSize($pValue = false) {
  143. $this->_autoSize = $pValue;
  144. return $this;
  145. }
  146. /**
  147. * Get Visible
  148. *
  149. * @return bool
  150. */
  151. public function getVisible() {
  152. return $this->_visible;
  153. }
  154. /**
  155. * Set Visible
  156. *
  157. * @param bool $pValue
  158. * @return PHPExcel_Worksheet_ColumnDimension
  159. */
  160. public function setVisible($pValue = true) {
  161. $this->_visible = $pValue;
  162. return $this;
  163. }
  164. /**
  165. * Get Outline Level
  166. *
  167. * @return int
  168. */
  169. public function getOutlineLevel() {
  170. return $this->_outlineLevel;
  171. }
  172. /**
  173. * Set Outline Level
  174. *
  175. * Value must be between 0 and 7
  176. *
  177. * @param int $pValue
  178. * @throws PHPExcel_Exception
  179. * @return PHPExcel_Worksheet_ColumnDimension
  180. */
  181. public function setOutlineLevel($pValue) {
  182. if ($pValue < 0 || $pValue > 7) {
  183. throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
  184. }
  185. $this->_outlineLevel = $pValue;
  186. return $this;
  187. }
  188. /**
  189. * Get Collapsed
  190. *
  191. * @return bool
  192. */
  193. public function getCollapsed() {
  194. return $this->_collapsed;
  195. }
  196. /**
  197. * Set Collapsed
  198. *
  199. * @param bool $pValue
  200. * @return PHPExcel_Worksheet_ColumnDimension
  201. */
  202. public function setCollapsed($pValue = true) {
  203. $this->_collapsed = $pValue;
  204. return $this;
  205. }
  206. /**
  207. * Get index to cellXf
  208. *
  209. * @return int
  210. */
  211. public function getXfIndex()
  212. {
  213. return $this->_xfIndex;
  214. }
  215. /**
  216. * Set index to cellXf
  217. *
  218. * @param int $pValue
  219. * @return PHPExcel_Worksheet_ColumnDimension
  220. */
  221. public function setXfIndex($pValue = 0)
  222. {
  223. $this->_xfIndex = $pValue;
  224. return $this;
  225. }
  226. /**
  227. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  228. */
  229. public function __clone() {
  230. $vars = get_object_vars($this);
  231. foreach ($vars as $key => $value) {
  232. if (is_object($value)) {
  233. $this->$key = clone $value;
  234. } else {
  235. $this->$key = $value;
  236. }
  237. }
  238. }
  239. }