PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/phpoffice/phpexcel/Classes/PHPExcel/Cell/DataValidation.php

https://gitlab.com/techniconline/kmc
PHP | 500 lines | 199 code | 46 blank | 255 comment | 2 complexity | 301fed4afbea610f8adcc56e6bd11dee MD5 | raw file
  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. {
  163. return $this->_formula1;
  164. }
  165. /**
  166. * Set Formula 1
  167. *
  168. * @param string $value
  169. * @return PHPExcel_Cell_DataValidation
  170. */
  171. public function setFormula1($value = '')
  172. {
  173. $this->_formula1 = $value;
  174. return $this;
  175. }
  176. /**
  177. * Get Formula 2
  178. *
  179. * @return string
  180. */
  181. public function getFormula2()
  182. {
  183. return $this->_formula2;
  184. }
  185. /**
  186. * Set Formula 2
  187. *
  188. * @param string $value
  189. * @return PHPExcel_Cell_DataValidation
  190. */
  191. public function setFormula2($value = '')
  192. {
  193. $this->_formula2 = $value;
  194. return $this;
  195. }
  196. /**
  197. * Get Type
  198. *
  199. * @return string
  200. */
  201. public function getType()
  202. {
  203. return $this->_type;
  204. }
  205. /**
  206. * Set Type
  207. *
  208. * @param string $value
  209. * @return PHPExcel_Cell_DataValidation
  210. */
  211. public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
  212. {
  213. $this->_type = $value;
  214. return $this;
  215. }
  216. /**
  217. * Get Error style
  218. *
  219. * @return string
  220. */
  221. public function getErrorStyle()
  222. {
  223. return $this->_errorStyle;
  224. }
  225. /**
  226. * Set Error style
  227. *
  228. * @param string $value
  229. * @return PHPExcel_Cell_DataValidation
  230. */
  231. public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
  232. {
  233. $this->_errorStyle = $value;
  234. return $this;
  235. }
  236. /**
  237. * Get Operator
  238. *
  239. * @return string
  240. */
  241. public function getOperator()
  242. {
  243. return $this->_operator;
  244. }
  245. /**
  246. * Set Operator
  247. *
  248. * @param string $value
  249. * @return PHPExcel_Cell_DataValidation
  250. */
  251. public function setOperator($value = '')
  252. {
  253. $this->_operator = $value;
  254. return $this;
  255. }
  256. /**
  257. * Get Allow Blank
  258. *
  259. * @return boolean
  260. */
  261. public function getAllowBlank()
  262. {
  263. return $this->_allowBlank;
  264. }
  265. /**
  266. * Set Allow Blank
  267. *
  268. * @param boolean $value
  269. * @return PHPExcel_Cell_DataValidation
  270. */
  271. public function setAllowBlank($value = false)
  272. {
  273. $this->_allowBlank = $value;
  274. return $this;
  275. }
  276. /**
  277. * Get Show DropDown
  278. *
  279. * @return boolean
  280. */
  281. public function getShowDropDown()
  282. {
  283. return $this->_showDropDown;
  284. }
  285. /**
  286. * Set Show DropDown
  287. *
  288. * @param boolean $value
  289. * @return PHPExcel_Cell_DataValidation
  290. */
  291. public function setShowDropDown($value = false)
  292. {
  293. $this->_showDropDown = $value;
  294. return $this;
  295. }
  296. /**
  297. * Get Show InputMessage
  298. *
  299. * @return boolean
  300. */
  301. public function getShowInputMessage()
  302. {
  303. return $this->_showInputMessage;
  304. }
  305. /**
  306. * Set Show InputMessage
  307. *
  308. * @param boolean $value
  309. * @return PHPExcel_Cell_DataValidation
  310. */
  311. public function setShowInputMessage($value = false)
  312. {
  313. $this->_showInputMessage = $value;
  314. return $this;
  315. }
  316. /**
  317. * Get Show ErrorMessage
  318. *
  319. * @return boolean
  320. */
  321. public function getShowErrorMessage()
  322. {
  323. return $this->_showErrorMessage;
  324. }
  325. /**
  326. * Set Show ErrorMessage
  327. *
  328. * @param boolean $value
  329. * @return PHPExcel_Cell_DataValidation
  330. */
  331. public function setShowErrorMessage($value = false)
  332. {
  333. $this->_showErrorMessage = $value;
  334. return $this;
  335. }
  336. /**
  337. * Get Error title
  338. *
  339. * @return string
  340. */
  341. public function getErrorTitle()
  342. {
  343. return $this->_errorTitle;
  344. }
  345. /**
  346. * Set Error title
  347. *
  348. * @param string $value
  349. * @return PHPExcel_Cell_DataValidation
  350. */
  351. public function setErrorTitle($value = '')
  352. {
  353. $this->_errorTitle = $value;
  354. return $this;
  355. }
  356. /**
  357. * Get Error
  358. *
  359. * @return string
  360. */
  361. public function getError()
  362. {
  363. return $this->_error;
  364. }
  365. /**
  366. * Set Error
  367. *
  368. * @param string $value
  369. * @return PHPExcel_Cell_DataValidation
  370. */
  371. public function setError($value = '')
  372. {
  373. $this->_error = $value;
  374. return $this;
  375. }
  376. /**
  377. * Get Prompt title
  378. *
  379. * @return string
  380. */
  381. public function getPromptTitle()
  382. {
  383. return $this->_promptTitle;
  384. }
  385. /**
  386. * Set Prompt title
  387. *
  388. * @param string $value
  389. * @return PHPExcel_Cell_DataValidation
  390. */
  391. public function setPromptTitle($value = '')
  392. {
  393. $this->_promptTitle = $value;
  394. return $this;
  395. }
  396. /**
  397. * Get Prompt
  398. *
  399. * @return string
  400. */
  401. public function getPrompt()
  402. {
  403. return $this->_prompt;
  404. }
  405. /**
  406. * Set Prompt
  407. *
  408. * @param string $value
  409. * @return PHPExcel_Cell_DataValidation
  410. */
  411. public function setPrompt($value = '')
  412. {
  413. $this->_prompt = $value;
  414. return $this;
  415. }
  416. /**
  417. * Get hash code
  418. *
  419. * @return string Hash code
  420. */
  421. public function getHashCode()
  422. {
  423. return md5(
  424. $this->_formula1
  425. . $this->_formula2
  426. . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
  427. . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
  428. . $this->_operator
  429. . ($this->_allowBlank ? 't' : 'f')
  430. . ($this->_showDropDown ? 't' : 'f')
  431. . ($this->_showInputMessage ? 't' : 'f')
  432. . ($this->_showErrorMessage ? 't' : 'f')
  433. . $this->_errorTitle
  434. . $this->_error
  435. . $this->_promptTitle
  436. . $this->_prompt
  437. . __CLASS__
  438. );
  439. }
  440. /**
  441. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  442. */
  443. public function __clone()
  444. {
  445. $vars = get_object_vars($this);
  446. foreach ($vars as $key => $value) {
  447. if (is_object($value)) {
  448. $this->$key = clone $value;
  449. } else {
  450. $this->$key = $value;
  451. }
  452. }
  453. }
  454. }