Completed
Push — develop ( 467115...a39d71 )
by Adrien
17:43
created

SpContainer::getSpgr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer;
4
5
/**
6
 * Copyright (c) 2006 - 2016 PhpSpreadsheet.
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 *
22
 * @category   PhpSpreadsheet
23
 *
24
 * @copyright  Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
25
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
26
 */
27
class SpContainer
28
{
29
    /**
30
     * Parent Shape Group Container.
31
     *
32
     * @var \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer
33
     */
34
    private $parent;
35
36
    /**
37
     * Is this a group shape?
38
     *
39
     * @var bool
40
     */
41
    private $spgr = false;
42
43
    /**
44
     * Shape type.
45
     *
46
     * @var int
47
     */
48
    private $spType;
49
50
    /**
51
     * Shape flag.
52
     *
53
     * @var int
54
     */
55
    private $spFlag;
56
57
    /**
58
     * Shape index (usually group shape has index 0, and the rest: 1,2,3...).
59
     *
60
     * @var int
61
     */
62
    private $spId;
63
64
    /**
65
     * Array of options.
66
     *
67
     * @var array
68
     */
69
    private $OPT;
70
71
    /**
72
     * Cell coordinates of upper-left corner of shape, e.g. 'A1'.
73
     *
74
     * @var string
75
     */
76
    private $startCoordinates;
77
78
    /**
79
     * Horizontal offset of upper-left corner of shape measured in 1/1024 of column width.
80
     *
81
     * @var int
82
     */
83
    private $startOffsetX;
84
85
    /**
86
     * Vertical offset of upper-left corner of shape measured in 1/256 of row height.
87
     *
88
     * @var int
89
     */
90
    private $startOffsetY;
91
92
    /**
93
     * Cell coordinates of bottom-right corner of shape, e.g. 'B2'.
94
     *
95
     * @var string
96
     */
97
    private $endCoordinates;
98
99
    /**
100
     * Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width.
101
     *
102
     * @var int
103
     */
104
    private $endOffsetX;
105
106
    /**
107
     * Vertical offset of bottom-right corner of shape measured in 1/256 of row height.
108
     *
109
     * @var int
110
     */
111
    private $endOffsetY;
112
113
    /**
114
     * Set parent Shape Group Container.
115
     *
116
     * @param \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer $parent
117
     */
118 10
    public function setParent($parent)
119
    {
120 10
        $this->parent = $parent;
121 10
    }
122
123
    /**
124
     * Get the parent Shape Group Container.
125
     *
126
     * @return \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer
127
     */
128 3
    public function getParent()
129
    {
130 3
        return $this->parent;
131
    }
132
133
    /**
134
     * Set whether this is a group shape.
135
     *
136
     * @param bool $value
137
     */
138 10
    public function setSpgr($value = false)
139
    {
140 10
        $this->spgr = $value;
141 10
    }
142
143
    /**
144
     * Get whether this is a group shape.
145
     *
146
     * @return bool
147
     */
148 10
    public function getSpgr()
149
    {
150 10
        return $this->spgr;
151
    }
152
153
    /**
154
     * Set the shape type.
155
     *
156
     * @param int $value
157
     */
158 10
    public function setSpType($value)
159
    {
160 10
        $this->spType = $value;
161 10
    }
162
163
    /**
164
     * Get the shape type.
165
     *
166
     * @return int
167
     */
168 10
    public function getSpType()
169
    {
170 10
        return $this->spType;
171
    }
172
173
    /**
174
     * Set the shape flag.
175
     *
176
     * @param int $value
177
     */
178 10
    public function setSpFlag($value)
179
    {
180 10
        $this->spFlag = $value;
181 10
    }
182
183
    /**
184
     * Get the shape flag.
185
     *
186
     * @return int
187
     */
188 10
    public function getSpFlag()
189
    {
190 10
        return $this->spFlag;
191
    }
192
193
    /**
194
     * Set the shape index.
195
     *
196
     * @param int $value
197
     */
198 10
    public function setSpId($value)
199
    {
200 10
        $this->spId = $value;
201 10
    }
202
203
    /**
204
     * Get the shape index.
205
     *
206
     * @return int
207
     */
208 10
    public function getSpId()
209
    {
210 10
        return $this->spId;
211
    }
212
213
    /**
214
     * Set an option for the Shape Group Container.
215
     *
216
     * @param int $property The number specifies the option
217
     * @param mixed $value
218
     */
219 10
    public function setOPT($property, $value)
220
    {
221 10
        $this->OPT[$property] = $value;
222 10
    }
223
224
    /**
225
     * Get an option for the Shape Group Container.
226
     *
227
     * @param int $property The number specifies the option
228
     *
229
     * @return mixed
230
     */
231 3
    public function getOPT($property)
232
    {
233 3
        if (isset($this->OPT[$property])) {
234 3
            return $this->OPT[$property];
235
        }
236
237
        return null;
238
    }
239
240
    /**
241
     * Get the collection of options.
242
     *
243
     * @return array
244
     */
245 10
    public function getOPTCollection()
246
    {
247 10
        return $this->OPT;
248
    }
249
250
    /**
251
     * Set cell coordinates of upper-left corner of shape.
252
     *
253
     * @param string $value
254
     */
255 10
    public function setStartCoordinates($value = 'A1')
256
    {
257 10
        $this->startCoordinates = $value;
258 10
    }
259
260
    /**
261
     * Get cell coordinates of upper-left corner of shape.
262
     *
263
     * @return string
264
     */
265 10
    public function getStartCoordinates()
266
    {
267 10
        return $this->startCoordinates;
268
    }
269
270
    /**
271
     * Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
272
     *
273
     * @param int $startOffsetX
274
     */
275 10
    public function setStartOffsetX($startOffsetX = 0)
276
    {
277 10
        $this->startOffsetX = $startOffsetX;
278 10
    }
279
280
    /**
281
     * Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
282
     *
283
     * @return int
284
     */
285 10
    public function getStartOffsetX()
286
    {
287 10
        return $this->startOffsetX;
288
    }
289
290
    /**
291
     * Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
292
     *
293
     * @param int $startOffsetY
294
     */
295 10
    public function setStartOffsetY($startOffsetY = 0)
296
    {
297 10
        $this->startOffsetY = $startOffsetY;
298 10
    }
299
300
    /**
301
     * Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
302
     *
303
     * @return int
304
     */
305 10
    public function getStartOffsetY()
306
    {
307 10
        return $this->startOffsetY;
308
    }
309
310
    /**
311
     * Set cell coordinates of bottom-right corner of shape.
312
     *
313
     * @param string $value
314
     */
315 10
    public function setEndCoordinates($value = 'A1')
316
    {
317 10
        $this->endCoordinates = $value;
318 10
    }
319
320
    /**
321
     * Get cell coordinates of bottom-right corner of shape.
322
     *
323
     * @return string
324
     */
325 10
    public function getEndCoordinates()
326
    {
327 10
        return $this->endCoordinates;
328
    }
329
330
    /**
331
     * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
332
     *
333
     * @param int $endOffsetX
334
     */
335 10
    public function setEndOffsetX($endOffsetX = 0)
336
    {
337 10
        $this->endOffsetX = $endOffsetX;
338 10
    }
339
340
    /**
341
     * Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
342
     *
343
     * @return int
344
     */
345 10
    public function getEndOffsetX()
346
    {
347 10
        return $this->endOffsetX;
348
    }
349
350
    /**
351
     * Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
352
     *
353
     * @param int $endOffsetY
354
     */
355 10
    public function setEndOffsetY($endOffsetY = 0)
356
    {
357 10
        $this->endOffsetY = $endOffsetY;
358 10
    }
359
360
    /**
361
     * Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
362
     *
363
     * @return int
364
     */
365 10
    public function getEndOffsetY()
366
    {
367 10
        return $this->endOffsetY;
368
    }
369
370
    /**
371
     * Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
372
     * the dgContainer. A value of 1 = immediately within first spgrContainer
373
     * Higher nesting level occurs if and only if spContainer is part of a shape group.
374
     *
375
     * @return int Nesting level
376
     */
377 3
    public function getNestingLevel()
378
    {
379 3
        $nestingLevel = 0;
380
381 3
        $parent = $this->getParent();
382 3
        while ($parent instanceof \PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer) {
383 3
            ++$nestingLevel;
384 3
            $parent = $parent->getParent();
385
        }
386
387 3
        return $nestingLevel;
388
    }
389
}
390