PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/PHPExcel_1.7.8-with_documentation-msoffice_format/PHPExcel_1.7.8-with_documentation-msoffice_format/Classes/PHPExcel/Cell/DataValidation.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 474 lines | 171 code | 46 blank | 257 comment | 2 complexity | d633cfcbe1f4e793855c1f9d68739924 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2012 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 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.7.8, 2012-10-12
  26. */
  27. /**
  28. * PHPExcel_Cell_DataValidation
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Cell
  32. * @copyright Copyright (c) 2006 - 2012 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. * @throws Exception
  140. */
  141. public function __construct()
  142. {
  143. // Initialise member variables
  144. $this->_formula1 = '';
  145. $this->_formula2 = '';
  146. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  147. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  148. $this->_operator = '';
  149. $this->_allowBlank = false;
  150. $this->_showDropDown = false;
  151. $this->_showInputMessage = false;
  152. $this->_showErrorMessage = false;
  153. $this->_errorTitle = '';
  154. $this->_error = '';
  155. $this->_promptTitle = '';
  156. $this->_prompt = '';
  157. }
  158. /**
  159. * Get Formula 1
  160. *
  161. * @return string
  162. */
  163. public function getFormula1() {
  164. return $this->_formula1;
  165. }
  166. /**
  167. * Set Formula 1
  168. *
  169. * @param string $value
  170. * @return PHPExcel_Cell_DataValidation
  171. */
  172. public function setFormula1($value = '') {
  173. $this->_formula1 = $value;
  174. return $this;
  175. }
  176. /**
  177. * Get Formula 2
  178. *
  179. * @return string
  180. */
  181. public function getFormula2() {
  182. return $this->_formula2;
  183. }
  184. /**
  185. * Set Formula 2
  186. *
  187. * @param string $value
  188. * @return PHPExcel_Cell_DataValidation
  189. */
  190. public function setFormula2($value = '') {
  191. $this->_formula2 = $value;
  192. return $this;
  193. }
  194. /**
  195. * Get Type
  196. *
  197. * @return string
  198. */
  199. public function getType() {
  200. return $this->_type;
  201. }
  202. /**
  203. * Set Type
  204. *
  205. * @param string $value
  206. * @return PHPExcel_Cell_DataValidation
  207. */
  208. public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
  209. $this->_type = $value;
  210. return $this;
  211. }
  212. /**
  213. * Get Error style
  214. *
  215. * @return string
  216. */
  217. public function getErrorStyle() {
  218. return $this->_errorStyle;
  219. }
  220. /**
  221. * Set Error style
  222. *
  223. * @param string $value
  224. * @return PHPExcel_Cell_DataValidation
  225. */
  226. public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
  227. $this->_errorStyle = $value;
  228. return $this;
  229. }
  230. /**
  231. * Get Operator
  232. *
  233. * @return string
  234. */
  235. public function getOperator() {
  236. return $this->_operator;
  237. }
  238. /**
  239. * Set Operator
  240. *
  241. * @param string $value
  242. * @return PHPExcel_Cell_DataValidation
  243. */
  244. public function setOperator($value = '') {
  245. $this->_operator = $value;
  246. return $this;
  247. }
  248. /**
  249. * Get Allow Blank
  250. *
  251. * @return boolean
  252. */
  253. public function getAllowBlank() {
  254. return $this->_allowBlank;
  255. }
  256. /**
  257. * Set Allow Blank
  258. *
  259. * @param boolean $value
  260. * @return PHPExcel_Cell_DataValidation
  261. */
  262. public function setAllowBlank($value = false) {
  263. $this->_allowBlank = $value;
  264. return $this;
  265. }
  266. /**
  267. * Get Show DropDown
  268. *
  269. * @return boolean
  270. */
  271. public function getShowDropDown() {
  272. return $this->_showDropDown;
  273. }
  274. /**
  275. * Set Show DropDown
  276. *
  277. * @param boolean $value
  278. * @return PHPExcel_Cell_DataValidation
  279. */
  280. public function setShowDropDown($value = false) {
  281. $this->_showDropDown = $value;
  282. return $this;
  283. }
  284. /**
  285. * Get Show InputMessage
  286. *
  287. * @return boolean
  288. */
  289. public function getShowInputMessage() {
  290. return $this->_showInputMessage;
  291. }
  292. /**
  293. * Set Show InputMessage
  294. *
  295. * @param boolean $value
  296. * @return PHPExcel_Cell_DataValidation
  297. */
  298. public function setShowInputMessage($value = false) {
  299. $this->_showInputMessage = $value;
  300. return $this;
  301. }
  302. /**
  303. * Get Show ErrorMessage
  304. *
  305. * @return boolean
  306. */
  307. public function getShowErrorMessage() {
  308. return $this->_showErrorMessage;
  309. }
  310. /**
  311. * Set Show ErrorMessage
  312. *
  313. * @param boolean $value
  314. * @return PHPExcel_Cell_DataValidation
  315. */
  316. public function setShowErrorMessage($value = false) {
  317. $this->_showErrorMessage = $value;
  318. return $this;
  319. }
  320. /**
  321. * Get Error title
  322. *
  323. * @return string
  324. */
  325. public function getErrorTitle() {
  326. return $this->_errorTitle;
  327. }
  328. /**
  329. * Set Error title
  330. *
  331. * @param string $value
  332. * @return PHPExcel_Cell_DataValidation
  333. */
  334. public function setErrorTitle($value = '') {
  335. $this->_errorTitle = $value;
  336. return $this;
  337. }
  338. /**
  339. * Get Error
  340. *
  341. * @return string
  342. */
  343. public function getError() {
  344. return $this->_error;
  345. }
  346. /**
  347. * Set Error
  348. *
  349. * @param string $value
  350. * @return PHPExcel_Cell_DataValidation
  351. */
  352. public function setError($value = '') {
  353. $this->_error = $value;
  354. return $this;
  355. }
  356. /**
  357. * Get Prompt title
  358. *
  359. * @return string
  360. */
  361. public function getPromptTitle() {
  362. return $this->_promptTitle;
  363. }
  364. /**
  365. * Set Prompt title
  366. *
  367. * @param string $value
  368. * @return PHPExcel_Cell_DataValidation
  369. */
  370. public function setPromptTitle($value = '') {
  371. $this->_promptTitle = $value;
  372. return $this;
  373. }
  374. /**
  375. * Get Prompt
  376. *
  377. * @return string
  378. */
  379. public function getPrompt() {
  380. return $this->_prompt;
  381. }
  382. /**
  383. * Set Prompt
  384. *
  385. * @param string $value
  386. * @return PHPExcel_Cell_DataValidation
  387. */
  388. public function setPrompt($value = '') {
  389. $this->_prompt = $value;
  390. return $this;
  391. }
  392. /**
  393. * Get hash code
  394. *
  395. * @return string Hash code
  396. */
  397. public function getHashCode() {
  398. return md5(
  399. $this->_formula1
  400. . $this->_formula2
  401. . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
  402. . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
  403. . $this->_operator
  404. . ($this->_allowBlank ? 't' : 'f')
  405. . ($this->_showDropDown ? 't' : 'f')
  406. . ($this->_showInputMessage ? 't' : 'f')
  407. . ($this->_showErrorMessage ? 't' : 'f')
  408. . $this->_errorTitle
  409. . $this->_error
  410. . $this->_promptTitle
  411. . $this->_prompt
  412. . __CLASS__
  413. );
  414. }
  415. /**
  416. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  417. */
  418. public function __clone() {
  419. $vars = get_object_vars($this);
  420. foreach ($vars as $key => $value) {
  421. if (is_object($value)) {
  422. $this->$key = clone $value;
  423. } else {
  424. $this->$key = $value;
  425. }
  426. }
  427. }
  428. }