PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/v1.6.5/Classes/PHPExcel/Comment.php

#
PHP | 315 lines | 96 code | 34 blank | 185 comment | 2 complexity | aaba8a2471744a2235fa7995107f8317 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-3.0, LGPL-3.0
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2009 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
  23. * @copyright Copyright (c) 2006 - 2009 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. /** PHPExcel_RichText */
  28. require_once 'PHPExcel/RichText.php';
  29. /** PHPExcel_Style_Color */
  30. require_once 'PHPExcel/Style/Color.php';
  31. /** PHPExcel_IComparable */
  32. require_once 'PHPExcel/IComparable.php';
  33. /**
  34. * PHPExcel_Comment
  35. *
  36. * @category PHPExcel
  37. * @package PHPExcel
  38. * @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  39. */
  40. class PHPExcel_Comment implements PHPExcel_IComparable
  41. {
  42. /**
  43. * Author
  44. *
  45. * @var string
  46. */
  47. private $_author;
  48. /**
  49. * Rich text comment
  50. *
  51. * @var PHPExcel_RichText
  52. */
  53. private $_text;
  54. /**
  55. * Comment width (CSS style, i.e. XXpx or YYpt)
  56. *
  57. * @var string
  58. */
  59. private $_width = '96pt';
  60. /**
  61. * Left margin (CSS style, i.e. XXpx or YYpt)
  62. *
  63. * @var string
  64. */
  65. private $_marginLeft = '59.25pt';
  66. /**
  67. * Top margin (CSS style, i.e. XXpx or YYpt)
  68. *
  69. * @var string
  70. */
  71. private $_marginTop = '1.5pt';
  72. /**
  73. * Visible
  74. *
  75. * @var boolean
  76. */
  77. private $_visible = false;
  78. /**
  79. * Comment height (CSS style, i.e. XXpx or YYpt)
  80. *
  81. * @var string
  82. */
  83. private $_height = '55.5pt';
  84. /**
  85. * Comment fill color
  86. *
  87. * @var PHPExcel_Style_Color
  88. */
  89. private $_fillColor;
  90. /**
  91. * Create a new PHPExcel_Comment
  92. *
  93. * @throws Exception
  94. */
  95. public function __construct()
  96. {
  97. // Initialise variables
  98. $this->_author = 'Author';
  99. $this->_text = new PHPExcel_RichText();
  100. $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
  101. }
  102. /**
  103. * Get Author
  104. *
  105. * @return string
  106. */
  107. public function getAuthor() {
  108. return $this->_author;
  109. }
  110. /**
  111. * Set Author
  112. *
  113. * @param string $pValue
  114. */
  115. public function setAuthor($pValue = '') {
  116. $this->_author = $pValue;
  117. }
  118. /**
  119. * Get Rich text comment
  120. *
  121. * @return PHPExcel_RichText
  122. */
  123. public function getText() {
  124. return $this->_text;
  125. }
  126. /**
  127. * Set Rich text comment
  128. *
  129. * @param PHPExcel_RichText $pValue
  130. */
  131. public function setText(PHPExcel_RichText $pValue) {
  132. $this->_text = $pValue;
  133. }
  134. /**
  135. * Get comment width (CSS style, i.e. XXpx or YYpt)
  136. *
  137. * @return string
  138. */
  139. public function getWidth() {
  140. return $this->_width;
  141. }
  142. /**
  143. * Set comment width (CSS style, i.e. XXpx or YYpt)
  144. *
  145. * @param string $value
  146. */
  147. public function setWidth($value = '96pt') {
  148. $this->_width = $value;
  149. }
  150. /**
  151. * Get comment height (CSS style, i.e. XXpx or YYpt)
  152. *
  153. * @return string
  154. */
  155. public function getHeight() {
  156. return $this->_height;
  157. }
  158. /**
  159. * Set comment height (CSS style, i.e. XXpx or YYpt)
  160. *
  161. * @param string $value
  162. */
  163. public function setHeight($value = '55.5pt') {
  164. $this->_height = $value;
  165. }
  166. /**
  167. * Get left margin (CSS style, i.e. XXpx or YYpt)
  168. *
  169. * @return string
  170. */
  171. public function getMarginLeft() {
  172. return $this->_marginLeft;
  173. }
  174. /**
  175. * Set left margin (CSS style, i.e. XXpx or YYpt)
  176. *
  177. * @param string $value
  178. */
  179. public function setMarginLeft($value = '59.25pt') {
  180. $this->_marginLeft = $value;
  181. }
  182. /**
  183. * Get top margin (CSS style, i.e. XXpx or YYpt)
  184. *
  185. * @return string
  186. */
  187. public function getMarginTop() {
  188. return $this->_marginTop;
  189. }
  190. /**
  191. * Set top margin (CSS style, i.e. XXpx or YYpt)
  192. *
  193. * @param string $value
  194. */
  195. public function setMarginTop($value = '1.5pt') {
  196. $this->_marginTop = $value;
  197. }
  198. /**
  199. * Is the comment visible by default?
  200. *
  201. * @return boolean
  202. */
  203. public function getVisible() {
  204. return $this->_visible;
  205. }
  206. /**
  207. * Set comment default visibility
  208. *
  209. * @param boolean $value
  210. */
  211. public function setVisible($value = false) {
  212. $this->_visible = $value;
  213. }
  214. /**
  215. * Get fill color
  216. *
  217. * @return PHPExcel_Style_Color
  218. */
  219. public function getFillColor() {
  220. return $this->_fillColor;
  221. }
  222. /**
  223. * Get hash code
  224. *
  225. * @return string Hash code
  226. */
  227. public function getHashCode() {
  228. return md5(
  229. $this->_author
  230. . $this->_text->getHashCode()
  231. . $this->_width
  232. . $this->_height
  233. . $this->_marginLeft
  234. . $this->_marginTop
  235. . ($this->_visible ? 1 : 0)
  236. . $this->_fillColor->getHashCode()
  237. . __CLASS__
  238. );
  239. }
  240. /**
  241. * Hash index
  242. *
  243. * @var string
  244. */
  245. private $_hashIndex;
  246. /**
  247. * Get hash index
  248. *
  249. * Note that this index may vary during script execution! Only reliable moment is
  250. * while doing a write of a workbook and when changes are not allowed.
  251. *
  252. * @return string Hash index
  253. */
  254. public function getHashIndex() {
  255. return $this->_hashIndex;
  256. }
  257. /**
  258. * Set hash index
  259. *
  260. * Note that this index may vary during script execution! Only reliable moment is
  261. * while doing a write of a workbook and when changes are not allowed.
  262. *
  263. * @param string $value Hash index
  264. */
  265. public function setHashIndex($value) {
  266. $this->_hashIndex = $value;
  267. }
  268. /**
  269. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  270. */
  271. public function __clone() {
  272. $vars = get_object_vars($this);
  273. foreach ($vars as $key => $value) {
  274. if (is_object($value)) {
  275. $this->$key = clone $value;
  276. } else {
  277. $this->$key = $value;
  278. }
  279. }
  280. }
  281. }