Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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