3f9ad810629fa557199a72e21529205e5f0f39c1.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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_Cell
  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_Cell_DataValidation
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Cell
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Cell_DataValidation
  35. {
  36. /* Data validation types */
  37. const TYPE_NONE = 'none';
  38. const TYPE_CUSTOM = 'custom';
  39. const TYPE_DATE = 'date';
  40. const TYPE_DECIMAL = 'decimal';
  41. const TYPE_LIST = 'list';
  42. const TYPE_TEXTLENGTH = 'textLength';
  43. const TYPE_TIME = 'time';
  44. const TYPE_WHOLE = 'whole';
  45. /* Data validation error styles */
  46. const STYLE_STOP = 'stop';
  47. const STYLE_WARNING = 'warning';
  48. const STYLE_INFORMATION = 'information';
  49. /* Data validation operators */
  50. const OPERATOR_BETWEEN = 'between';
  51. const OPERATOR_EQUAL = 'equal';
  52. const OPERATOR_GREATERTHAN = 'greaterThan';
  53. const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
  54. const OPERATOR_LESSTHAN = 'lessThan';
  55. const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
  56. const OPERATOR_NOTBETWEEN = 'notBetween';
  57. const OPERATOR_NOTEQUAL = 'notEqual';
  58. /**
  59. * Formula 1
  60. *
  61. * @var string
  62. */
  63. private $_formula1;
  64. /**
  65. * Formula 2
  66. *
  67. * @var string
  68. */
  69. private $_formula2;
  70. /**
  71. * Type
  72. *
  73. * @var string
  74. */
  75. private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  76. /**
  77. * Error style
  78. *
  79. * @var string
  80. */
  81. private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  82. /**
  83. * Operator
  84. *
  85. * @var string
  86. */
  87. private $_operator;
  88. /**
  89. * Allow Blank
  90. *
  91. * @var boolean
  92. */
  93. private $_allowBlank;
  94. /**
  95. * Show DropDown
  96. *
  97. * @var boolean
  98. */
  99. private $_showDropDown;
  100. /**
  101. * Show InputMessage
  102. *
  103. * @var boolean
  104. */
  105. private $_showInputMessage;
  106. /**
  107. * Show ErrorMessage
  108. *
  109. * @var boolean
  110. */
  111. private $_showErrorMessage;
  112. /**
  113. * Error title
  114. *
  115. * @var string
  116. */
  117. private $_errorTitle;
  118. /**
  119. * Error
  120. *
  121. * @var string
  122. */
  123. private $_error;
  124. /**
  125. * Prompt title
  126. *
  127. * @var string
  128. */
  129. private $_promptTitle;
  130. /**
  131. * Prompt
  132. *
  133. * @var string
  134. */
  135. private $_prompt;
  136. /**
  137. * Create a new PHPExcel_Cell_DataValidation
  138. */
  139. public function __construct()
  140. {
  141. // Initialise member variables
  142. $this->_formula1 = '';
  143. $this->_formula2 = '';
  144. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  145. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  146. $this->_operator = '';
  147. $this->_allowBlank = FALSE;
  148. $this->_showDropDown = FALSE;
  149. $this->_showInputMessage = FALSE;
  150. $this->_showErrorMessage = FALSE;
  151. $this->_errorTitle = '';
  152. $this->_error = '';
  153. $this->_promptTitle = '';
  154. $this->_prompt = '';
  155. }
  156. /**
  157. * Get Formula 1
  158. *
  159. * @return string
  160. */
  161. public function getFormula1() {
  162. return $this->_formula1;
  163. }
  164. /**
  165. * Set Formula 1
  166. *
  167. * @param string $value
  168. * @return PHPExcel_Cell_DataValidation
  169. */
  170. public function setFormula1($value = '') {
  171. $this->_formula1 = $value;
  172. return $this;
  173. }
  174. /**
  175. * Get Formula 2
  176. *
  177. * @return string
  178. */
  179. public function getFormula2() {
  180. return $this->_formula2;
  181. }
  182. /**
  183. * Set Formula 2
  184. *
  185. * @param string $value
  186. * @return PHPExcel_Cell_DataValidation
  187. */
  188. public function setFormula2($value = '') {
  189. $this->_formula2 = $value;
  190. return $this;
  191. }
  192. /**
  193. * Get Type
  194. *
  195. * @return string
  196. */
  197. public function getType() {
  198. return $this->_type;
  199. }
  200. /**
  201. * Set Type
  202. *
  203. * @param string $value
  204. * @return PHPExcel_Cell_DataValidation
  205. */
  206. public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
  207. $this->_type = $value;
  208. return $this;
  209. }
  210. /**
  211. * Get Error style
  212. *
  213. * @return string
  214. */
  215. public function getErrorStyle() {
  216. return $this->_errorStyle;
  217. }
  218. /**
  219. * Set Error style
  220. *
  221. * @param string $value
  222. * @return PHPExcel_Cell_DataValidation
  223. */
  224. public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
  225. $this->_errorStyle = $value;
  226. return $this;
  227. }
  228. /**
  229. * Get Operator
  230. *
  231. * @return string
  232. */
  233. public function getOperator() {
  234. return $this->_operator;
  235. }
  236. /**
  237. * Set Operator
  238. *
  239. * @param string $value
  240. * @return PHPExcel_Cell_DataValidation
  241. */
  242. public function setOperator($value = '') {
  243. $this->_operator = $value;
  244. return $this;
  245. }
  246. /**
  247. * Get Allow Blank
  248. *
  249. * @return boolean
  250. */
  251. public function getAllowBlank() {
  252. return $this->_allowBlank;
  253. }
  254. /**
  255. * Set Allow Blank
  256. *
  257. * @param boolean $value
  258. * @return PHPExcel_Cell_DataValidation
  259. */
  260. public function setAllowBlank($value = false) {
  261. $this->_allowBlank = $value;
  262. return $this;
  263. }
  264. /**
  265. * Get Show DropDown
  266. *
  267. * @return boolean
  268. */
  269. public function getShowDropDown() {
  270. return $this->_showDropDown;
  271. }
  272. /**
  273. * Set Show DropDown
  274. *
  275. * @param boolean $value
  276. * @return PHPExcel_Cell_DataValidation
  277. */
  278. public function setShowDropDown($value = false) {
  279. $this->_showDropDown = $value;
  280. return $this;
  281. }
  282. /**
  283. * Get Show InputMessage
  284. *
  285. * @return boolean
  286. */
  287. public function getShowInputMessage() {
  288. return $this->_showInputMessage;
  289. }
  290. /**
  291. * Set Show InputMessage
  292. *
  293. * @param boolean $value
  294. * @return PHPExcel_Cell_DataValidation
  295. */
  296. public function setShowInputMessage($value = false) {
  297. $this->_showInputMessage = $value;
  298. return $this;
  299. }
  300. /**
  301. * Get Show ErrorMessage
  302. *
  303. * @return boolean
  304. */
  305. public function getShowErrorMessage() {
  306. return $this->_showErrorMessage;
  307. }
  308. /**
  309. * Set Show ErrorMessage
  310. *
  311. * @param boolean $value
  312. * @return PHPExcel_Cell_DataValidation
  313. */
  314. public function setShowErrorMessage($value = false) {
  315. $this->_showErrorMessage = $value;
  316. return $this;
  317. }
  318. /**
  319. * Get Error title
  320. *
  321. * @return string
  322. */
  323. public function getErrorTitle() {
  324. return $this->_errorTitle;
  325. }
  326. /**
  327. * Set Error title
  328. *
  329. * @param string $value
  330. * @return PHPExcel_Cell_DataValidation
  331. */
  332. public function setErrorTitle($value = '') {
  333. $this->_errorTitle = $value;
  334. return $this;
  335. }
  336. /**
  337. * Get Error
  338. *
  339. * @return string
  340. */
  341. public function getError() {
  342. return $this->_error;
  343. }
  344. /**
  345. * Set Error
  346. *
  347. * @param string $value
  348. * @return PHPExcel_Cell_DataValidation
  349. */
  350. public function setError($value = '') {
  351. $this->_error = $value;
  352. return $this;
  353. }
  354. /**
  355. * Get Prompt title
  356. *
  357. * @return string
  358. */
  359. public function getPromptTitle() {
  360. return $this->_promptTitle;
  361. }
  362. /**
  363. * Set Prompt title
  364. *
  365. * @param string $value
  366. * @return PHPExcel_Cell_DataValidation
  367. */
  368. public function setPromptTitle($value = '') {
  369. $this->_promptTitle = $value;
  370. return $this;
  371. }
  372. /**
  373. * Get Prompt
  374. *
  375. * @return string
  376. */
  377. public function getPrompt() {
  378. return $this->_prompt;
  379. }
  380. /**
  381. * Set Prompt
  382. *
  383. * @param string $value
  384. * @return PHPExcel_Cell_DataValidation
  385. */
  386. public function setPrompt($value = '') {
  387. $this->_prompt = $value;
  388. return $this;
  389. }
  390. /**
  391. * Get hash code
  392. *
  393. * @return string Hash code
  394. */
  395. public function getHashCode() {
  396. return md5(
  397. $this->_formula1
  398. . $this->_formula2
  399. . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
  400. . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
  401. . $this->_operator
  402. . ($this->_allowBlank ? 't' : 'f')
  403. . ($this->_showDropDown ? 't' : 'f')
  404. . ($this->_showInputMessage ? 't' : 'f')
  405. . ($this->_showErrorMessage ? 't' : 'f')
  406. . $this->_errorTitle
  407. . $this->_error
  408. . $this->_promptTitle
  409. . $this->_prompt
  410. . __CLASS__
  411. );
  412. }
  413. /**
  414. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  415. */
  416. public function __clone() {
  417. $vars = get_object_vars($this);
  418. foreach ($vars as $key => $value) {
  419. if (is_object($value)) {
  420. $this->$key = clone $value;
  421. } else {
  422. $this->$key = $value;
  423. }
  424. }
  425. }
  426. }