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: * PHPWord_Style_Paragraph
30: */
31: class PHPWord_Style_Paragraph
32: {
33:
34: /**
35: * Paragraph alignment
36: *
37: * @var string
38: */
39: private $_align;
40:
41: /**
42: * Space before Paragraph
43: *
44: * @var int
45: */
46: private $_spaceBefore;
47:
48: /**
49: * Space after Paragraph
50: *
51: * @var int
52: */
53: private $_spaceAfter;
54:
55: /**
56: * Spacing between breaks
57: *
58: * @var int
59: */
60: private $_spacing;
61:
62: /**
63: * Set of Custom Tab Stops
64: *
65: * @var array
66: */
67: private $_tabs;
68:
69: /**
70: * Indent by how much
71: *
72: * @var int
73: */
74: private $_indent;
75:
76: /**
77: * Hanging by how much
78: *
79: * @var int
80: */
81: private $_hanging;
82:
83: /**
84: * New Paragraph Style
85: */
86: public function __construct()
87: {
88: $this->_align = null;
89: $this->_spaceBefore = null;
90: $this->_spaceAfter = null;
91: $this->_spacing = null;
92: $this->_tabs = null;
93: $this->_indent = null;
94: $this->_hanging = null;
95: }
96:
97: /**
98: * Set Style value
99: *
100: * @param string $key
101: * @param mixed $value
102: */
103: public function setStyleValue($key, $value)
104: {
105: if ($key == '_indent') {
106: $value = $value * 720; // 720 twips per indent
107: }
108: if ($key == '_hanging') {
109: $value = $value * 720;
110: }
111: if ($key == '_spacing') {
112: $value += 240; // because line height of 1 matches 240 twips
113: }
114: if ($key === '_tabs') {
115: $value = new PHPWord_Style_Tabs($value);
116: }
117: $this->$key = $value;
118: }
119:
120: /**
121: * Get Paragraph Alignment
122: *
123: * @return string
124: */
125: public function getAlign()
126: {
127: return $this->_align;
128: }
129:
130: /**
131: * Set Paragraph Alignment
132: *
133: * @param string $pValue
134: * @return PHPWord_Style_Paragraph
135: */
136: public function setAlign($pValue = null)
137: {
138: if (strtolower($pValue) == 'justify') {
139: // justify becames both
140: $pValue = 'both';
141: }
142: $this->_align = $pValue;
143: return $this;
144: }
145:
146: /**
147: * Get Space before Paragraph
148: *
149: * @return string
150: */
151: public function getSpaceBefore()
152: {
153: return $this->_spaceBefore;
154: }
155:
156: /**
157: * Set Space before Paragraph
158: *
159: * @param int $pValue
160: * @return PHPWord_Style_Paragraph
161: */
162: public function setSpaceBefore($pValue = null)
163: {
164: $this->_spaceBefore = $pValue;
165: return $this;
166: }
167:
168: /**
169: * Get Space after Paragraph
170: *
171: * @return string
172: */
173: public function getSpaceAfter()
174: {
175: return $this->_spaceAfter;
176: }
177:
178: /**
179: * Set Space after Paragraph
180: *
181: * @param int $pValue
182: * @return PHPWord_Style_Paragraph
183: */
184: public function setSpaceAfter($pValue = null)
185: {
186: $this->_spaceAfter = $pValue;
187: return $this;
188: }
189:
190: /**
191: * Get Spacing between breaks
192: *
193: * @return int
194: */
195: public function getSpacing()
196: {
197: return $this->_spacing;
198: }
199:
200: /**
201: * Set Spacing between breaks
202: *
203: * @param int $pValue
204: * @return PHPWord_Style_Paragraph
205: */
206: public function setSpacing($pValue = null)
207: {
208: $this->_spacing = $pValue;
209: return $this;
210: }
211:
212: /**
213: * Get indentation
214: *
215: * @return int
216: */
217: public function getIndent()
218: {
219: return $this->_indent;
220: }
221:
222: /**
223: * Set indentation
224: *
225: * @param int $pValue
226: * @return PHPWord_Style_Paragraph
227: */
228: public function setIndent($pValue = null)
229: {
230: $this->_indent = $pValue;
231: return $this;
232: }
233:
234: /**
235: * Set hanging
236: *
237: * @param int $pValue
238: * @return PHPWord_Style_Paragraph
239: */
240: public function setHanging($pValue = null)
241: {
242: $this->_hanging = $pValue;
243: return $this;
244: }
245:
246: /**
247: * Get hanging
248: *
249: * @return int
250: */
251: public function getHanging()
252: {
253: return $this->_hanging;
254: }
255:
256: /**
257: * Get tabs
258: *
259: * @return PHPWord_Style_Tabs
260: */
261: public function getTabs()
262: {
263: return $this->_tabs;
264: }
265: }