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