Comment.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_Comment implements PHPExcel_IComparable
  8. {
  9. /**
  10. * Author
  11. *
  12. * @var string
  13. */
  14. private $author;
  15. /**
  16. * Rich text comment
  17. *
  18. * @var PHPExcel_RichText
  19. */
  20. private $text;
  21. /**
  22. * Comment width (CSS style, i.e. XXpx or YYpt)
  23. *
  24. * @var string
  25. */
  26. private $width = '96pt';
  27. /**
  28. * Left margin (CSS style, i.e. XXpx or YYpt)
  29. *
  30. * @var string
  31. */
  32. private $marginLeft = '59.25pt';
  33. /**
  34. * Top margin (CSS style, i.e. XXpx or YYpt)
  35. *
  36. * @var string
  37. */
  38. private $marginTop = '1.5pt';
  39. /**
  40. * Visible
  41. *
  42. * @var boolean
  43. */
  44. private $visible = false;
  45. /**
  46. * Comment height (CSS style, i.e. XXpx or YYpt)
  47. *
  48. * @var string
  49. */
  50. private $height = '55.5pt';
  51. /**
  52. * Comment fill color
  53. *
  54. * @var PHPExcel_Style_Color
  55. */
  56. private $fillColor;
  57. /**
  58. * Alignment
  59. *
  60. * @var string
  61. */
  62. private $alignment;
  63. /**
  64. * Create a new PHPExcel_Comment
  65. *
  66. * @throws PHPExcel_Exception
  67. */
  68. public function __construct()
  69. {
  70. // Initialise variables
  71. $this->author = 'Author';
  72. $this->text = new PHPExcel_RichText();
  73. $this->fillColor = new PHPExcel_Style_Color('FFFFFFE1');
  74. $this->alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
  75. }
  76. /**
  77. * Get Author
  78. *
  79. * @return string
  80. */
  81. public function getAuthor()
  82. {
  83. return $this->author;
  84. }
  85. /**
  86. * Set Author
  87. *
  88. * @param string $pValue
  89. * @return PHPExcel_Comment
  90. */
  91. public function setAuthor($pValue = '')
  92. {
  93. $this->author = $pValue;
  94. return $this;
  95. }
  96. /**
  97. * Get Rich text comment
  98. *
  99. * @return PHPExcel_RichText
  100. */
  101. public function getText()
  102. {
  103. return $this->text;
  104. }
  105. /**
  106. * Set Rich text comment
  107. *
  108. * @param PHPExcel_RichText $pValue
  109. * @return PHPExcel_Comment
  110. */
  111. public function setText(PHPExcel_RichText $pValue)
  112. {
  113. $this->text = $pValue;
  114. return $this;
  115. }
  116. /**
  117. * Get comment width (CSS style, i.e. XXpx or YYpt)
  118. *
  119. * @return string
  120. */
  121. public function getWidth()
  122. {
  123. return $this->width;
  124. }
  125. /**
  126. * Set comment width (CSS style, i.e. XXpx or YYpt)
  127. *
  128. * @param string $value
  129. * @return PHPExcel_Comment
  130. */
  131. public function setWidth($value = '96pt')
  132. {
  133. $this->width = $value;
  134. return $this;
  135. }
  136. /**
  137. * Get comment height (CSS style, i.e. XXpx or YYpt)
  138. *
  139. * @return string
  140. */
  141. public function getHeight()
  142. {
  143. return $this->height;
  144. }
  145. /**
  146. * Set comment height (CSS style, i.e. XXpx or YYpt)
  147. *
  148. * @param string $value
  149. * @return PHPExcel_Comment
  150. */
  151. public function setHeight($value = '55.5pt')
  152. {
  153. $this->height = $value;
  154. return $this;
  155. }
  156. /**
  157. * Get left margin (CSS style, i.e. XXpx or YYpt)
  158. *
  159. * @return string
  160. */
  161. public function getMarginLeft()
  162. {
  163. return $this->marginLeft;
  164. }
  165. /**
  166. * Set left margin (CSS style, i.e. XXpx or YYpt)
  167. *
  168. * @param string $value
  169. * @return PHPExcel_Comment
  170. */
  171. public function setMarginLeft($value = '59.25pt')
  172. {
  173. $this->marginLeft = $value;
  174. return $this;
  175. }
  176. /**
  177. * Get top margin (CSS style, i.e. XXpx or YYpt)
  178. *
  179. * @return string
  180. */
  181. public function getMarginTop()
  182. {
  183. return $this->marginTop;
  184. }
  185. /**
  186. * Set top margin (CSS style, i.e. XXpx or YYpt)
  187. *
  188. * @param string $value
  189. * @return PHPExcel_Comment
  190. */
  191. public function setMarginTop($value = '1.5pt')
  192. {
  193. $this->marginTop = $value;
  194. return $this;
  195. }
  196. /**
  197. * Is the comment visible by default?
  198. *
  199. * @return boolean
  200. */
  201. public function getVisible()
  202. {
  203. return $this->visible;
  204. }
  205. /**
  206. * Set comment default visibility
  207. *
  208. * @param boolean $value
  209. * @return PHPExcel_Comment
  210. */
  211. public function setVisible($value = false)
  212. {
  213. $this->visible = $value;
  214. return $this;
  215. }
  216. /**
  217. * Get fill color
  218. *
  219. * @return PHPExcel_Style_Color
  220. */
  221. public function getFillColor()
  222. {
  223. return $this->fillColor;
  224. }
  225. /**
  226. * Set Alignment
  227. *
  228. * @param string $pValue
  229. * @return PHPExcel_Comment
  230. */
  231. public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
  232. {
  233. $this->alignment = $pValue;
  234. return $this;
  235. }
  236. /**
  237. * Get Alignment
  238. *
  239. * @return string
  240. */
  241. public function getAlignment()
  242. {
  243. return $this->alignment;
  244. }
  245. /**
  246. * Get hash code
  247. *
  248. * @return string Hash code
  249. */
  250. public function getHashCode()
  251. {
  252. return md5(
  253. $this->author .
  254. $this->text->getHashCode() .
  255. $this->width .
  256. $this->height .
  257. $this->marginLeft .
  258. $this->marginTop .
  259. ($this->visible ? 1 : 0) .
  260. $this->fillColor->getHashCode() .
  261. $this->alignment .
  262. __CLASS__
  263. );
  264. }
  265. /**
  266. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  267. */
  268. public function __clone()
  269. {
  270. $vars = get_object_vars($this);
  271. foreach ($vars as $key => $value) {
  272. if (is_object($value)) {
  273. $this->$key = clone $value;
  274. } else {
  275. $this->$key = $value;
  276. }
  277. }
  278. }
  279. /**
  280. * Convert to string
  281. *
  282. * @return string
  283. */
  284. public function __toString()
  285. {
  286. return $this->text->getPlainText();
  287. }
  288. }