Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
56 / 56 |
|
100.00% |
21 / 21 |
CRAP | |
100.00% |
1 / 1 |
TablePosition | |
100.00% |
56 / 56 |
|
100.00% |
21 / 21 |
21 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLeftFromText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLeftFromText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getRightFromText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRightFromText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getTopFromText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTopFromText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBottomFromText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBottomFromText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getVertAnchor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setVertAnchor | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
getHorzAnchor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHorzAnchor | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
getTblpXSpec | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTblpXSpec | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
getTblpX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTblpX | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getTblpYSpec | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTblpYSpec | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
getTblpY | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTblpY | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
5 | * word processing documents. |
6 | * |
7 | * PHPWord is free software distributed under the terms of the GNU Lesser |
8 | * General Public License version 3 as published by the Free Software Foundation. |
9 | * |
10 | * For the full copyright and license information, please read the LICENSE |
11 | * file that was distributed with this source code. For the full list of |
12 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
13 | * |
14 | * @see https://github.com/PHPOffice/PHPWord |
15 | * |
16 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
17 | */ |
18 | |
19 | namespace PhpOffice\PhpWord\Style; |
20 | |
21 | /** |
22 | * TablePosition style. |
23 | * |
24 | * @see http://www.datypic.com/sc/ooxml/e-w_tblpPr-1.html |
25 | */ |
26 | class TablePosition extends AbstractStyle |
27 | { |
28 | /** |
29 | * Vertical anchor constants. |
30 | * |
31 | * @const string |
32 | * |
33 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html |
34 | */ |
35 | const VANCHOR_TEXT = 'text'; // Relative to vertical text extents |
36 | const VANCHOR_MARGIN = 'margin'; // Relative to margin |
37 | const VANCHOR_PAGE = 'page'; // Relative to page |
38 | |
39 | /** |
40 | * Horizontal anchor constants. |
41 | * |
42 | * @const string |
43 | * |
44 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html |
45 | */ |
46 | const HANCHOR_TEXT = 'text'; // Relative to text extents |
47 | const HANCHOR_MARGIN = 'margin'; // Relative to margin |
48 | const HANCHOR_PAGE = 'page'; // Relative to page |
49 | |
50 | /** |
51 | * Horizontal alignment constants. |
52 | * |
53 | * @const string |
54 | * |
55 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html |
56 | */ |
57 | const XALIGN_LEFT = 'left'; // Left aligned horizontally |
58 | const XALIGN_CENTER = 'center'; // Centered horizontally |
59 | const XALIGN_RIGHT = 'right'; // Right aligned horizontally |
60 | const XALIGN_INSIDE = 'inside'; // Inside |
61 | const XALIGN_OUTSIDE = 'outside'; // Outside |
62 | |
63 | /** |
64 | * Vertical alignment constants. |
65 | * |
66 | * @const string |
67 | * |
68 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html |
69 | */ |
70 | const YALIGN_INLINE = 'inline'; // In line with text |
71 | const YALIGN_TOP = 'top'; // Top |
72 | const YALIGN_CENTER = 'center'; // Centered vertically |
73 | const YALIGN_BOTTOM = 'bottom'; // Bottom |
74 | const YALIGN_INSIDE = 'inside'; // Inside Anchor Extents |
75 | const YALIGN_OUTSIDE = 'outside'; // Centered vertically |
76 | |
77 | /** |
78 | * Distance from left of table to text. |
79 | * |
80 | * @var int |
81 | */ |
82 | private $leftFromText; |
83 | |
84 | /** |
85 | * Distance from right of table to text. |
86 | * |
87 | * @var int |
88 | */ |
89 | private $rightFromText; |
90 | |
91 | /** |
92 | * Distance from top of table to text. |
93 | * |
94 | * @var int |
95 | */ |
96 | private $topFromText; |
97 | |
98 | /** |
99 | * Distance from bottom of table to text. |
100 | * |
101 | * @var int |
102 | */ |
103 | private $bottomFromText; |
104 | |
105 | /** |
106 | * Table vertical anchor. |
107 | * |
108 | * @var string |
109 | * |
110 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html |
111 | */ |
112 | private $vertAnchor; |
113 | |
114 | /** |
115 | * Table horizontal anchor. |
116 | * |
117 | * @var string |
118 | * |
119 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html |
120 | */ |
121 | private $horzAnchor; |
122 | |
123 | /** |
124 | * Relative horizontal alignment from anchor. |
125 | * |
126 | * @var string |
127 | * |
128 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html |
129 | */ |
130 | private $tblpXSpec; |
131 | |
132 | /** |
133 | * Absolute horizontal distance from anchor. |
134 | * |
135 | * @var int |
136 | */ |
137 | private $tblpX; |
138 | |
139 | /** |
140 | * Relative vertical alignment from anchor. |
141 | * |
142 | * @var string |
143 | * |
144 | * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html |
145 | */ |
146 | private $tblpYSpec; |
147 | |
148 | /** |
149 | * Absolute vertical distance from anchor. |
150 | * |
151 | * @var int |
152 | */ |
153 | private $tblpY; |
154 | |
155 | /** |
156 | * Create a new instance. |
157 | * |
158 | * @param array $style |
159 | */ |
160 | public function __construct($style = []) |
161 | { |
162 | $this->setStyleByArray($style); |
163 | } |
164 | |
165 | /** |
166 | * Get distance from left of table to text. |
167 | * |
168 | * @return int |
169 | */ |
170 | public function getLeftFromText() |
171 | { |
172 | return $this->leftFromText; |
173 | } |
174 | |
175 | /** |
176 | * Set distance from left of table to text. |
177 | * |
178 | * @param int $value |
179 | * |
180 | * @return self |
181 | */ |
182 | public function setLeftFromText($value = null) |
183 | { |
184 | $this->leftFromText = $this->setNumericVal($value, $this->leftFromText); |
185 | |
186 | return $this; |
187 | } |
188 | |
189 | /** |
190 | * Get distance from right of table to text. |
191 | * |
192 | * @return int |
193 | */ |
194 | public function getRightFromText() |
195 | { |
196 | return $this->rightFromText; |
197 | } |
198 | |
199 | /** |
200 | * Set distance from right of table to text. |
201 | * |
202 | * @param int $value |
203 | * |
204 | * @return self |
205 | */ |
206 | public function setRightFromText($value = null) |
207 | { |
208 | $this->rightFromText = $this->setNumericVal($value, $this->rightFromText); |
209 | |
210 | return $this; |
211 | } |
212 | |
213 | /** |
214 | * Get distance from top of table to text. |
215 | * |
216 | * @return int |
217 | */ |
218 | public function getTopFromText() |
219 | { |
220 | return $this->topFromText; |
221 | } |
222 | |
223 | /** |
224 | * Set distance from top of table to text. |
225 | * |
226 | * @param int $value |
227 | * |
228 | * @return self |
229 | */ |
230 | public function setTopFromText($value = null) |
231 | { |
232 | $this->topFromText = $this->setNumericVal($value, $this->topFromText); |
233 | |
234 | return $this; |
235 | } |
236 | |
237 | /** |
238 | * Get distance from bottom of table to text. |
239 | * |
240 | * @return int |
241 | */ |
242 | public function getBottomFromText() |
243 | { |
244 | return $this->bottomFromText; |
245 | } |
246 | |
247 | /** |
248 | * Set distance from bottom of table to text. |
249 | * |
250 | * @param int $value |
251 | * |
252 | * @return self |
253 | */ |
254 | public function setBottomFromText($value = null) |
255 | { |
256 | $this->bottomFromText = $this->setNumericVal($value, $this->bottomFromText); |
257 | |
258 | return $this; |
259 | } |
260 | |
261 | /** |
262 | * Get table vertical anchor. |
263 | * |
264 | * @return string |
265 | */ |
266 | public function getVertAnchor() |
267 | { |
268 | return $this->vertAnchor; |
269 | } |
270 | |
271 | /** |
272 | * Set table vertical anchor. |
273 | * |
274 | * @param string $value |
275 | * |
276 | * @return self |
277 | */ |
278 | public function setVertAnchor($value = null) |
279 | { |
280 | $enum = [ |
281 | self::VANCHOR_TEXT, |
282 | self::VANCHOR_MARGIN, |
283 | self::VANCHOR_PAGE, |
284 | ]; |
285 | $this->vertAnchor = $this->setEnumVal($value, $enum, $this->vertAnchor); |
286 | |
287 | return $this; |
288 | } |
289 | |
290 | /** |
291 | * Get table horizontal anchor. |
292 | * |
293 | * @return string |
294 | */ |
295 | public function getHorzAnchor() |
296 | { |
297 | return $this->horzAnchor; |
298 | } |
299 | |
300 | /** |
301 | * Set table horizontal anchor. |
302 | * |
303 | * @param string $value |
304 | * |
305 | * @return self |
306 | */ |
307 | public function setHorzAnchor($value = null) |
308 | { |
309 | $enum = [ |
310 | self::HANCHOR_TEXT, |
311 | self::HANCHOR_MARGIN, |
312 | self::HANCHOR_PAGE, |
313 | ]; |
314 | $this->horzAnchor = $this->setEnumVal($value, $enum, $this->horzAnchor); |
315 | |
316 | return $this; |
317 | } |
318 | |
319 | /** |
320 | * Get relative horizontal alignment from anchor. |
321 | * |
322 | * @return string |
323 | */ |
324 | public function getTblpXSpec() |
325 | { |
326 | return $this->tblpXSpec; |
327 | } |
328 | |
329 | /** |
330 | * Set relative horizontal alignment from anchor. |
331 | * |
332 | * @param string $value |
333 | * |
334 | * @return self |
335 | */ |
336 | public function setTblpXSpec($value = null) |
337 | { |
338 | $enum = [ |
339 | self::XALIGN_LEFT, |
340 | self::XALIGN_CENTER, |
341 | self::XALIGN_RIGHT, |
342 | self::XALIGN_INSIDE, |
343 | self::XALIGN_OUTSIDE, |
344 | ]; |
345 | $this->tblpXSpec = $this->setEnumVal($value, $enum, $this->tblpXSpec); |
346 | |
347 | return $this; |
348 | } |
349 | |
350 | /** |
351 | * Get absolute horizontal distance from anchor. |
352 | * |
353 | * @return int |
354 | */ |
355 | public function getTblpX() |
356 | { |
357 | return $this->tblpX; |
358 | } |
359 | |
360 | /** |
361 | * Set absolute horizontal distance from anchor. |
362 | * |
363 | * @param int $value |
364 | * |
365 | * @return self |
366 | */ |
367 | public function setTblpX($value = null) |
368 | { |
369 | $this->tblpX = $this->setNumericVal($value, $this->tblpX); |
370 | |
371 | return $this; |
372 | } |
373 | |
374 | /** |
375 | * Get relative vertical alignment from anchor. |
376 | * |
377 | * @return string |
378 | */ |
379 | public function getTblpYSpec() |
380 | { |
381 | return $this->tblpYSpec; |
382 | } |
383 | |
384 | /** |
385 | * Set relative vertical alignment from anchor. |
386 | * |
387 | * @param string $value |
388 | * |
389 | * @return self |
390 | */ |
391 | public function setTblpYSpec($value = null) |
392 | { |
393 | $enum = [ |
394 | self::YALIGN_INLINE, |
395 | self::YALIGN_TOP, |
396 | self::YALIGN_CENTER, |
397 | self::YALIGN_BOTTOM, |
398 | self::YALIGN_INSIDE, |
399 | self::YALIGN_OUTSIDE, |
400 | ]; |
401 | $this->tblpYSpec = $this->setEnumVal($value, $enum, $this->tblpYSpec); |
402 | |
403 | return $this; |
404 | } |
405 | |
406 | /** |
407 | * Get absolute vertical distance from anchor. |
408 | * |
409 | * @return int |
410 | */ |
411 | public function getTblpY() |
412 | { |
413 | return $this->tblpY; |
414 | } |
415 | |
416 | /** |
417 | * Set absolute vertical distance from anchor. |
418 | * |
419 | * @param int $value |
420 | * |
421 | * @return self |
422 | */ |
423 | public function setTblpY($value = null) |
424 | { |
425 | $this->tblpY = $this->setNumericVal($value, $this->tblpY); |
426 | |
427 | return $this; |
428 | } |
429 | } |