1: <?php
2: /**
3: * PHPWord
4: *
5: * Copyright (c) 2013 PHPWord
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 PHPWord
22: * @package PHPWord
23: * @copyright Copyright (c) 2013 PHPWord
24: * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25: * @version 0.7.0
26: */
27:
28: /**
29: * Class PHPWord_Section_Settings
30: */
31: class PHPWord_Section_Settings
32: {
33:
34: /**
35: * Default Page Size Width
36: *
37: * @var int
38: */
39: private $_defaultPageSizeW = 11906;
40:
41: /**
42: * Default Page Size Height
43: *
44: * @var int
45: */
46: private $_defaultPageSizeH = 16838;
47:
48: /**
49: * Page Orientation
50: *
51: * @var string
52: */
53: private $_orientation;
54:
55: /**
56: * Page Margin Top
57: *
58: * @var int
59: */
60: private $_marginTop;
61:
62: /**
63: * Page Margin Left
64: *
65: * @var int
66: */
67: private $_marginLeft;
68:
69: /**
70: * Page Margin Right
71: *
72: * @var int
73: */
74: private $_marginRight;
75:
76: /**
77: * Page Margin Bottom
78: *
79: * @var int
80: */
81: private $_marginBottom;
82:
83: /**
84: * Page Size Width
85: *
86: * @var int
87: */
88: private $_pageSizeW;
89:
90: /**
91: * Page Size Height
92: *
93: * @var int
94: */
95: private $_pageSizeH;
96:
97: /**
98: * Page Border Top Size
99: *
100: * @var int
101: */
102: private $_borderTopSize;
103:
104: /**
105: * Page Border Top Color
106: *
107: * @var int
108: */
109: private $_borderTopColor;
110:
111: /**
112: * Page Border Left Size
113: *
114: * @var int
115: */
116: private $_borderLeftSize;
117:
118: /**
119: * Page Border Left Color
120: *
121: * @var int
122: */
123: private $_borderLeftColor;
124:
125: /**
126: * Page Border Right Size
127: *
128: * @var int
129: */
130: private $_borderRightSize;
131:
132: /**
133: * Page Border Right Color
134: *
135: * @var int
136: */
137: private $_borderRightColor;
138:
139: /**
140: * Page Border Bottom Size
141: *
142: * @var int
143: */
144: private $_borderBottomSize;
145:
146: /**
147: * Page Border Bottom Color
148: *
149: * @var int
150: */
151: private $_borderBottomColor;
152:
153: /**
154: * Section Columns Count
155: *
156: * @var int
157: */
158: private $_colsNum;
159:
160: /**
161: * Section Spacing Between Columns
162: *
163: * @var int
164: */
165: private $_colsSpace;
166:
167: /**
168: * Section Break Type
169: *
170: * @var string
171: */
172: private $_breakType;
173:
174: /**
175: * Create new Section Settings
176: */
177: public function __construct()
178: {
179: $this->_orientation = null;
180: $this->_marginTop = 1418;
181: $this->_marginLeft = 1418;
182: $this->_marginRight = 1418;
183: $this->_marginBottom = 1134;
184: $this->_pageSizeW = $this->_defaultPageSizeW;
185: $this->_pageSizeH = $this->_defaultPageSizeH;
186: $this->_borderTopSize = null;
187: $this->_borderTopColor = null;
188: $this->_borderLeftSize = null;
189: $this->_borderLeftColor = null;
190: $this->_borderRightSize = null;
191: $this->_borderRightColor = null;
192: $this->_borderBottomSize = null;
193: $this->_borderBottomColor = null;
194: $this->_colsNum = 1;
195: $this->_colsSpace = 720;
196: $this->_breakType = null;
197: }
198:
199: /**
200: * Set Setting Value
201: *
202: * @param string $key
203: * @param string $value
204: */
205: public function setSettingValue($key, $value)
206: {
207: if ($key == '_orientation' && $value == 'landscape') {
208: $this->setLandscape();
209: } elseif ($key == '_orientation' && is_null($value)) {
210: $this->setPortrait();
211: } elseif ($key == '_borderSize') {
212: $this->setBorderSize($value);
213: } elseif ($key == '_borderColor') {
214: $this->setBorderColor($value);
215: } else {
216: $this->$key = $value;
217: }
218: }
219:
220: /**
221: * Get Margin Top
222: *
223: * @return int
224: */
225: public function getMarginTop()
226: {
227: return $this->_marginTop;
228: }
229:
230: /**
231: * Set Margin Top
232: *
233: * @param int $pValue
234: */
235: public function setMarginTop($pValue = '')
236: {
237: $this->_marginTop = $pValue;
238: return $this;
239: }
240:
241: /**
242: * Get Margin Left
243: *
244: * @return int
245: */
246: public function getMarginLeft()
247: {
248: return $this->_marginLeft;
249: }
250:
251: /**
252: * Set Margin Left
253: *
254: * @param int $pValue
255: */
256: public function setMarginLeft($pValue = '')
257: {
258: $this->_marginLeft = $pValue;
259: return $this;
260: }
261:
262: /**
263: * Get Margin Right
264: *
265: * @return int
266: */
267: public function getMarginRight()
268: {
269: return $this->_marginRight;
270: }
271:
272: /**
273: * Set Margin Right
274: *
275: * @param int $pValue
276: */
277: public function setMarginRight($pValue = '')
278: {
279: $this->_marginRight = $pValue;
280: return $this;
281: }
282:
283: /**
284: * Get Margin Bottom
285: *
286: * @return int
287: */
288: public function getMarginBottom()
289: {
290: return $this->_marginBottom;
291: }
292:
293: /**
294: * Set Margin Bottom
295: *
296: * @param int $pValue
297: */
298: public function setMarginBottom($pValue = '')
299: {
300: $this->_marginBottom = $pValue;
301: return $this;
302: }
303:
304: /**
305: * Set Landscape Orientation
306: */
307: public function setLandscape()
308: {
309: $this->_orientation = 'landscape';
310: $this->_pageSizeW = $this->_defaultPageSizeH;
311: $this->_pageSizeH = $this->_defaultPageSizeW;
312: }
313:
314: /**
315: * Set Portrait Orientation
316: */
317: public function setPortrait()
318: {
319: $this->_orientation = null;
320: $this->_pageSizeW = $this->_defaultPageSizeW;
321: $this->_pageSizeH = $this->_defaultPageSizeH;
322: }
323:
324: /**
325: * Get Page Size Width
326: *
327: * @return int
328: */
329: public function getPageSizeW()
330: {
331: return $this->_pageSizeW;
332: }
333:
334: /**
335: * Get Page Size Height
336: *
337: * @return int
338: */
339: public function getPageSizeH()
340: {
341: return $this->_pageSizeH;
342: }
343:
344: /**
345: * Get Page Orientation
346: *
347: * @return string
348: */
349: public function getOrientation()
350: {
351: return $this->_orientation;
352: }
353:
354: /**
355: * Set Border Size
356: *
357: * @param int $pValue
358: */
359: public function setBorderSize($pValue = null)
360: {
361: $this->_borderTopSize = $pValue;
362: $this->_borderLeftSize = $pValue;
363: $this->_borderRightSize = $pValue;
364: $this->_borderBottomSize = $pValue;
365: }
366:
367: /**
368: * Get Border Size
369: *
370: * @return array
371: */
372: public function getBorderSize()
373: {
374: $t = $this->getBorderTopSize();
375: $l = $this->getBorderLeftSize();
376: $r = $this->getBorderRightSize();
377: $b = $this->getBorderBottomSize();
378:
379: return array($t, $l, $r, $b);
380: }
381:
382: /**
383: * Set Border Color
384: *
385: * @param string $pValue
386: */
387: public function setBorderColor($pValue = null)
388: {
389: $this->_borderTopColor = $pValue;
390: $this->_borderLeftColor = $pValue;
391: $this->_borderRightColor = $pValue;
392: $this->_borderBottomColor = $pValue;
393: }
394:
395: /**
396: * Get Border Color
397: *
398: * @return array
399: */
400: public function getBorderColor()
401: {
402: $t = $this->getBorderTopColor();
403: $l = $this->getBorderLeftColor();
404: $r = $this->getBorderRightColor();
405: $b = $this->getBorderBottomColor();
406:
407: return array($t, $l, $r, $b);
408: }
409:
410: /**
411: * Set Border Top Size
412: *
413: * @param int $pValue
414: */
415: public function setBorderTopSize($pValue = null)
416: {
417: $this->_borderTopSize = $pValue;
418: }
419:
420: /**
421: * Get Border Top Size
422: *
423: * @return int
424: */
425: public function getBorderTopSize()
426: {
427: return $this->_borderTopSize;
428: }
429:
430: /**
431: * Set Border Top Color
432: *
433: * @param string $pValue
434: */
435: public function setBorderTopColor($pValue = null)
436: {
437: $this->_borderTopColor = $pValue;
438: }
439:
440: /**
441: * Get Border Top Color
442: *
443: * @return string
444: */
445: public function getBorderTopColor()
446: {
447: return $this->_borderTopColor;
448: }
449:
450: /**
451: * Set Border Left Size
452: *
453: * @param int $pValue
454: */
455: public function setBorderLeftSize($pValue = null)
456: {
457: $this->_borderLeftSize = $pValue;
458: }
459:
460: /**
461: * Get Border Left Size
462: *
463: * @return int
464: */
465: public function getBorderLeftSize()
466: {
467: return $this->_borderLeftSize;
468: }
469:
470: /**
471: * Set Border Left Color
472: *
473: * @param string $pValue
474: */
475: public function setBorderLeftColor($pValue = null)
476: {
477: $this->_borderLeftColor = $pValue;
478: }
479:
480: /**
481: * Get Border Left Color
482: *
483: * @return string
484: */
485: public function getBorderLeftColor()
486: {
487: return $this->_borderLeftColor;
488: }
489:
490: /**
491: * Set Border Right Size
492: *
493: * @param int $pValue
494: */
495: public function setBorderRightSize($pValue = null)
496: {
497: $this->_borderRightSize = $pValue;
498: }
499:
500: /**
501: * Get Border Right Size
502: *
503: * @return int
504: */
505: public function getBorderRightSize()
506: {
507: return $this->_borderRightSize;
508: }
509:
510: /**
511: * Set Border Right Color
512: *
513: * @param string $pValue
514: */
515: public function setBorderRightColor($pValue = null)
516: {
517: $this->_borderRightColor = $pValue;
518: }
519:
520: /**
521: * Get Border Right Color
522: *
523: * @return string
524: */
525: public function getBorderRightColor()
526: {
527: return $this->_borderRightColor;
528: }
529:
530: /**
531: * Set Border Bottom Size
532: *
533: * @param int $pValue
534: */
535: public function setBorderBottomSize($pValue = null)
536: {
537: $this->_borderBottomSize = $pValue;
538: }
539:
540: /**
541: * Get Border Bottom Size
542: *
543: * @return int
544: */
545: public function getBorderBottomSize()
546: {
547: return $this->_borderBottomSize;
548: }
549:
550: /**
551: * Set Border Bottom Color
552: *
553: * @param string $pValue
554: */
555: public function setBorderBottomColor($pValue = null)
556: {
557: $this->_borderBottomColor = $pValue;
558: }
559:
560: /**
561: * Get Border Bottom Color
562: *
563: * @return string
564: */
565: public function getBorderBottomColor()
566: {
567: return $this->_borderBottomColor;
568: }
569:
570: /**
571: * Set Section Columns Count
572: *
573: * @param in $pValue
574: */
575: public function setColsNum($pValue = '') {
576: $this->_colsNum = $pValue;
577: return $this;
578: }
579:
580: /**
581: * Get Section Columns Count
582: *
583: * @return int
584: */
585: public function getColsNum() {
586: return $this->_colsNum;
587: }
588:
589: /**
590: * Set Section Space Between Columns
591: *
592: * @param int $pValue
593: */
594: public function setColsSpace($pValue = '') {
595: $this->_colsSpace = $pValue;
596: return $this;
597: }
598:
599: /**
600: * Get Section Space Between Columns
601: *
602: * @return int
603: */
604: public function getColsSpace() {
605: return $this->_colsSpace;
606: }
607:
608: /**
609: * Set Break Type
610: *
611: * @param string $pValue
612: */
613: public function setBreakType($pValue = null) {
614: $this->_breakType = $pValue;
615: return $this;
616: }
617:
618: /**
619: * Get Break Type
620: *
621: * @return string
622: */
623: public function getBreakType() {
624: return $this->_breakType;
625: }
626: }
627: