| 1 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
//require_once 'functions.php';
|
|
|
4 |
require_once 'class.odt.php';
|
|
|
5 |
|
|
|
6 |
/**
|
|
|
7 |
* A Class representing the properties of a page.
|
|
|
8 |
*
|
|
|
9 |
* @author Issam RACHDI
|
|
|
10 |
*/
|
|
|
11 |
class PageStyle {
|
|
|
12 |
|
|
|
13 |
private $pageWidth = '21cm';
|
|
|
14 |
|
|
|
15 |
private $pageHeight = '29.70cm';
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* The DOMDocument representing the styles xml file
|
|
|
19 |
* @access private
|
|
|
20 |
* @var DOMDocument
|
|
|
21 |
*/
|
|
|
22 |
private $styleDocument;
|
|
|
23 |
/**
|
|
|
24 |
* The name of the style
|
|
|
25 |
* @access private
|
|
|
26 |
* @var string
|
|
|
27 |
*/
|
|
|
28 |
private $name;
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* The DOMElement representing the page layout properties
|
|
|
32 |
* @access private
|
|
|
33 |
* @var DOMElement
|
|
|
34 |
*/
|
|
|
35 |
private $pageLayoutProperties;
|
|
|
36 |
|
|
|
37 |
private $masterStyleElement;
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* The DOMElement representing the header properties
|
|
|
41 |
* @access private
|
|
|
42 |
* @var DOMElement
|
|
|
43 |
*/
|
|
|
44 |
private $headerProperties;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* The DOMElement representing the header properties
|
|
|
48 |
* @access private
|
|
|
49 |
* @var DOMElement
|
|
|
50 |
*/
|
|
|
51 |
private $footerProperties;
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* The constructor initializes the properties, then creates a <style:style>
|
|
|
55 |
* element representing this specific style, and add it to <office:styles>
|
|
|
56 |
* element
|
|
|
57 |
* @param DOMDocument $styleDoc
|
|
|
58 |
* @param string $name
|
|
|
59 |
*/
|
|
|
60 |
function __construct($name) {
|
|
|
61 |
$this->styleDocument = ODT::getInstance()->getStyleDocument();
|
|
|
62 |
$this->name = $name;
|
|
|
63 |
$pageLayoutStyleElement = $this->styleDocument->createElement('style:page-layout');
|
|
|
64 |
$this->pageLayoutProperties = $this->styleDocument->createElement('style:page-layout-properties');
|
|
|
65 |
$this->headerProperties = $this->styleDocument->createElement('style:header-footer-properties');
|
|
|
66 |
$this->footerProperties = $this->styleDocument->createElement('style:header-footer-properties');
|
|
|
67 |
$headerStyle = $this->styleDocument->createElement('style:header-style');
|
|
|
68 |
$headerStyle->appendChild($this->headerProperties);
|
|
|
69 |
$footerStyle = $this->styleDocument->createElement('style:footer-style');
|
|
|
70 |
$footerStyle->appendChild($this->footerProperties);
|
|
|
71 |
$pageLayoutStyleElement->setAttribute('style:name', $name);
|
|
|
72 |
$pageLayoutStyleElement->appendChild($this->pageLayoutProperties);
|
|
|
73 |
$pageLayoutStyleElement->appendChild($headerStyle);
|
|
|
74 |
$pageLayoutStyleElement->appendChild($footerStyle);
|
|
|
75 |
$this->styleDocument->getElementsByTagName('office:automatic-styles')->item(0)->appendChild($pageLayoutStyleElement);
|
|
|
76 |
$this->masterStyleElement = $this->styleDocument->createElement('style:master-page');
|
|
|
77 |
$this->masterStyleElement->setAttribute('style:name', 'Standard');
|
|
|
78 |
$this->masterStyleElement->setAttribute('style:page-layout-name', $name);
|
|
|
79 |
$this->styleDocument->getElementsByTagName('office:master-styles')->item(0)->appendChild($this->masterStyleElement);
|
|
|
80 |
$this->setHorizontalMargin('2cm', '2cm');
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
/**
|
|
|
84 |
* return the name of this style
|
|
|
85 |
* @return string
|
|
|
86 |
*/
|
|
|
87 |
function getStyleName() {
|
|
|
88 |
return $this->name;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
/**
|
|
|
92 |
* Specify the physical size of the page.
|
|
|
93 |
*
|
|
|
94 |
* @param integer|length $width
|
|
|
95 |
* @param integer|string $height
|
|
|
96 |
*/
|
|
|
97 |
function setPageSize($width, $height) {
|
|
|
98 |
if (!isLengthValue($width) && !isLengthValue($height)) {
|
|
|
99 |
throw new StyleException('Invalid page-height value');
|
|
|
100 |
}
|
|
|
101 |
$this->pageWidth = $width;
|
|
|
102 |
$this->pageHeight = $height;
|
|
|
103 |
$this->pageLayoutProperties->setAttribute('fo:page-width', $width);
|
|
|
104 |
$this->pageLayoutProperties->setAttribute('fo:page-height', $height);
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* Sepcifies default number format for page styles, which is used to display page numbers within headers and footers.
|
|
|
109 |
*
|
|
|
110 |
* @param string $prefix
|
|
|
111 |
* @param string $suffix
|
|
|
112 |
* @param string $format Valid values: "1", "a", "A", "i", or "I"
|
|
|
113 |
*/
|
|
|
114 |
function setPageNumberFormat($prefix, $suffix, $format) {
|
|
|
115 |
$this->pageLayoutProperties->setAttribute('style:num-prefix', $prefix);
|
|
|
116 |
$this->pageLayoutProperties->setAttribute('fo:page-suffix', $suffix);
|
|
|
117 |
switch ($format) {
|
|
|
118 |
case '1':
|
|
|
119 |
case 'a':
|
|
|
120 |
case 'A':
|
|
|
121 |
case 'i':
|
|
|
122 |
case 'I':
|
|
|
123 |
$this->pageLayoutProperties->setAttribute('fo:page-suffix', $format);break;
|
|
|
124 |
default:
|
|
|
125 |
throw new StyleException('Invalid num-format value');
|
|
|
126 |
}
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Specifies the orientation of the printed page
|
|
|
131 |
*
|
|
|
132 |
* @param integer $orientation Valid values: StyleConstants::(LANDSCAPE|PORTRAIT)
|
|
|
133 |
*/
|
|
|
134 |
function setOrientation($orientation) {
|
|
|
135 |
switch ($orientation) {
|
|
|
136 |
case StyleConstants::LANDSCAPE:
|
|
|
137 |
$orientation = 'landscape';
|
|
|
138 |
if ($this->pageWidth < $this->pageHeight) {
|
|
|
139 |
$this->setPageSize($this->pageHeight, $this->pageWidth);
|
|
|
140 |
}
|
|
|
141 |
break;
|
|
|
142 |
case StyleConstants::PORTRAIT:
|
|
|
143 |
$orientation = 'portrait';
|
|
|
144 |
if ($this->pageWidth > $this->pageHeight) {
|
|
|
145 |
$this->setPageSize($this->pageHeight, $this->pageWidth);
|
|
|
146 |
}
|
|
|
147 |
break;
|
|
|
148 |
default:
|
|
|
149 |
throw new StyleException('Invalid orientation value.');
|
|
|
150 |
}
|
|
|
151 |
$this->pageLayoutProperties->setAttribute('style:print-orientation', $orientation);
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
/**
|
|
|
155 |
* Specify the left & right margin for the page
|
|
|
156 |
*
|
|
|
157 |
* @param integer|string $leftMargin
|
|
|
158 |
* @param integer|string $rightMargin
|
|
|
159 |
*/
|
|
|
160 |
function setHorizontalMargin($leftMargin = 0, $rightMargin = 0) {
|
|
|
161 |
if (!isNumeric($leftMargin) && !isLengthValue($leftMargin)) {
|
|
|
162 |
throw new StyleException('Invalid left-margin value');
|
|
|
163 |
}
|
|
|
164 |
if (!isNumeric($rightMargin) && !isLengthValue($rightMargin)) {
|
|
|
165 |
throw new StyleException('Invalid right-margin value');
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
$this->pageLayoutProperties->setAttribute('fo:margin-left', $leftMargin);
|
|
|
169 |
$this->pageLayoutProperties->setAttribute('fo:margin-right', $rightMargin);
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
/**
|
|
|
173 |
* Specify the top & bottom margin for the page
|
|
|
174 |
*
|
|
|
175 |
* @param integer|string $topMargin
|
|
|
176 |
* @param integer|string $bottomMargin
|
|
|
177 |
*/
|
|
|
178 |
function setVerticalMargin($topMargin, $bottomMargin) {
|
|
|
179 |
if (!isNumeric($topMargin, true) && !isLengthValue($topMargin, true)) {
|
|
|
180 |
throw new StyleException('Invalid top-margin value');
|
|
|
181 |
}
|
|
|
182 |
if (!isNumeric($bottomMargin) && !isLengthValue($bottomMargin)) {
|
|
|
183 |
throw new StyleException('Invalid bottom-margin value');
|
|
|
184 |
}
|
|
|
185 |
$this->pageLayoutProperties->setAttribute('fo:margin-top', $topMargin);
|
|
|
186 |
$this->pageLayoutProperties->setAttribute('fo:margin-bottom', $bottomMargin);
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
/**
|
|
|
190 |
* Specifies the border properties for the page.
|
|
|
191 |
*
|
|
|
192 |
* @param color $borderColor Border color
|
|
|
193 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
194 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
195 |
* @param string $position Do not use this, it's for internal use only.
|
|
|
196 |
*/
|
|
|
197 |
function setBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
198 |
$borderWidth = StyleConstants::THIN, $position = '') {
|
|
|
199 |
if (!isColor($borderColor)) {
|
|
|
200 |
throw new StyleException('Invalid border-color value');
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
switch ($borderStyle) {
|
|
|
204 |
case StyleConstants::SOLID:
|
|
|
205 |
$borderStyle = 'solid';break;
|
|
|
206 |
case StyleConstants::DOUBLE:
|
|
|
207 |
$borderStyle = 'double';break;
|
|
|
208 |
default:
|
|
|
209 |
throw new StyleException('Invalid border-style value');
|
|
|
210 |
}
|
|
|
211 |
switch ($borderWidth) {
|
|
|
212 |
case StyleConstants::THIN:
|
|
|
213 |
$borderWidth = 'thin';break;
|
|
|
214 |
case StyleConstants::THICK:
|
|
|
215 |
$borderWidth = 'thick';break;
|
|
|
216 |
case StyleConstants::MEDIUM:
|
|
|
217 |
$borderWidth = 'medium';break;
|
|
|
218 |
default:
|
|
|
219 |
if (!isLengthValue($borderWidth, true)) {
|
|
|
220 |
throw new StyleException('Invalid border-width value');
|
|
|
221 |
}
|
|
|
222 |
}
|
|
|
223 |
if (!empty($position)) {
|
|
|
224 |
if (!in_array($position, array('top', 'bottom', 'left', 'right'))) {
|
|
|
225 |
$position = '';
|
|
|
226 |
} else {
|
|
|
227 |
$position = '-'.$position;
|
|
|
228 |
}
|
|
|
229 |
}
|
|
|
230 |
$this->pageLayoutProperties->setAttribute('fo:border'.$position, "$borderWidth $borderStyle $borderColor");
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
/**
|
|
|
234 |
* Specifies the top border property for pages.
|
|
|
235 |
*
|
|
|
236 |
* @param color $borderColor Border color
|
|
|
237 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
238 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
239 |
*/
|
|
|
240 |
function setTopBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
241 |
$borderWidth = StyleConstants::THIN) {
|
|
|
242 |
$this->setBorder($borderColor, $borderStyle, $borderWidth, 'top');
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
/**
|
|
|
246 |
* Specifies the bottom border property for paragraphs.
|
|
|
247 |
*
|
|
|
248 |
* @param color $borderColor Border color
|
|
|
249 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
250 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
251 |
*/
|
|
|
252 |
function setBottomBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
253 |
$borderWidth = StyleConstants::THIN) {
|
|
|
254 |
$this->setBorder($borderColor, $borderStyle, $borderWidth, 'bottom');
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
/**
|
|
|
258 |
* Specifies the left border property for pages.
|
|
|
259 |
*
|
|
|
260 |
* @param color $borderColor Border color
|
|
|
261 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
262 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
263 |
*/
|
|
|
264 |
function setLeftBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
265 |
$borderWidth = StyleConstants::THIN) {
|
|
|
266 |
$this->setBorder($borderColor, $borderStyle, $borderWidth, 'left');
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
/**
|
|
|
270 |
* Specifies the right border property for pages.
|
|
|
271 |
*
|
|
|
272 |
* @param color $borderColor Border color
|
|
|
273 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
274 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
275 |
*/
|
|
|
276 |
function setRightBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
277 |
$borderWidth = StyleConstants::THIN) {
|
|
|
278 |
$this->setBorder($borderColor, $borderStyle, $borderWidth, 'right');
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
/**
|
|
|
282 |
* Specifies the spacing around the page.
|
|
|
283 |
* Note that you must first specify the border
|
|
|
284 |
*
|
|
|
285 |
* @param length $padding
|
|
|
286 |
* @param string $position Do not use this, it's for internal use only.
|
|
|
287 |
*/
|
|
|
288 |
function setPadding($padding, $position = '') {
|
|
|
289 |
if (!isLengthValue($padding, true) && !isNumeric($padding)) {
|
|
|
290 |
throw new StyleException('Invalid padding value');
|
|
|
291 |
}
|
|
|
292 |
if (!empty($position)) {
|
|
|
293 |
if (!in_array($position, array('top', 'bottom', 'left', 'right'))) {
|
|
|
294 |
$position = '';
|
|
|
295 |
} else {
|
|
|
296 |
$position = '-'.$position;
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
$this->pageLayoutProperties->setAttribute('fo:padding'.$position, $padding);
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
/**
|
|
|
303 |
* Specifies the spacing on top of the pages.
|
|
|
304 |
*
|
|
|
305 |
* @param length $padding
|
|
|
306 |
*/
|
|
|
307 |
function setTopPadding($padding) {
|
|
|
308 |
$this->setPadding($padding, 'top');
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
/**
|
|
|
312 |
* Specifies the spacing in the bottom of the pages.
|
|
|
313 |
*
|
|
|
314 |
* @param length $padding
|
|
|
315 |
*/
|
|
|
316 |
function setBottomPadding($padding) {
|
|
|
317 |
$this->setPadding($padding, 'bottom');
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
/**
|
|
|
321 |
* Specifies the spacing in the left side of the pages.
|
|
|
322 |
*
|
|
|
323 |
* @param length $padding
|
|
|
324 |
*/
|
|
|
325 |
function setLeftPadding($padding) {
|
|
|
326 |
$this->setPadding($padding, 'left');
|
|
|
327 |
}
|
|
|
328 |
|
|
|
329 |
/**
|
|
|
330 |
* Specifies the spacing in the right side of the pages.
|
|
|
331 |
*
|
|
|
332 |
* @param length $padding
|
|
|
333 |
*/
|
|
|
334 |
function setRightPadding($padding) {
|
|
|
335 |
$this->setPadding($padding, 'right');
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
/**
|
|
|
339 |
* Specifies the background color for the page
|
|
|
340 |
*
|
|
|
341 |
* @param color $color
|
|
|
342 |
*/
|
|
|
343 |
function setBackgroundColor($color) {
|
|
|
344 |
if ($color != StyleConstants::TRANSPARENT && !isColor($color)) {
|
|
|
345 |
throw new StyleException('Invalid page background color');
|
|
|
346 |
}
|
|
|
347 |
$this->pageLayoutProperties->setAttribute('fo:background-color', $color);
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
/**
|
|
|
351 |
* Specifies the background image for the pages. Note that if you specify the position, the image
|
|
|
352 |
* will not be repeated
|
|
|
353 |
*
|
|
|
354 |
* @param string $image The image's path.
|
|
|
355 |
* @param integer $position Specifies where to position a background image in a paragraph.
|
|
|
356 |
* Valid values are StyleConstants::(LEFT|RIGHT|CENTER|TOP|BOTTOM)
|
|
|
357 |
*/
|
|
|
358 |
function setBackgroundImage($image, $repeat = StyleConstants::REPEAT,
|
|
|
359 |
$position = -1) {
|
|
|
360 |
$file = fopen($image, 'r');
|
|
|
361 |
if (!$file) {
|
|
|
362 |
throw new StyleException('Cannot open image');
|
|
|
363 |
}
|
|
|
364 |
switch($repeat) {
|
|
|
365 |
case StyleConstants::REPEAT:
|
|
|
366 |
$repeat = 'repeat';break;
|
|
|
367 |
case StyleConstants::NO_REPEAT:
|
|
|
368 |
$repeat = 'no-repeat';break;
|
|
|
369 |
case StyleConstants::STRETCH:
|
|
|
370 |
$repeat = 'stretch';break;
|
|
|
371 |
default:
|
|
|
372 |
throw new StyleException('Invalid repeat value');
|
|
|
373 |
}
|
|
|
374 |
switch($position) {
|
|
|
375 |
case -1:
|
|
|
376 |
break;
|
|
|
377 |
case StyleConstants::LEFT:
|
|
|
378 |
$position = 'left';break;
|
|
|
379 |
case StyleConstants::RIGHT:
|
|
|
380 |
$position = 'right';break;
|
|
|
381 |
case StyleConstants::CENTER:
|
|
|
382 |
$position = 'center';break;
|
|
|
383 |
case StyleConstants::TOP:
|
|
|
384 |
$position = 'top';break;
|
|
|
385 |
case StyleConstants::BOTTOM:
|
|
|
386 |
$position = 'left';break;
|
|
|
387 |
default:
|
|
|
388 |
throw new StyleException('Invalid background-position value');
|
|
|
389 |
}
|
|
|
390 |
$dataImg = fread($file, filesize($image));
|
|
|
391 |
$dateImgB64 = base64_encode($dataImg);
|
|
|
392 |
fclose($file);
|
|
|
393 |
$binaryElement = $this->styleDocument->createElement('office:binary-data', $dateImgB64);
|
|
|
394 |
$imageElement = $this->styleDocument->createElement('style:background-image');
|
|
|
395 |
$imageElement->setAttribute('style:repeat', $repeat);
|
|
|
396 |
if ($position != -1) {
|
|
|
397 |
$imageElement->setAttribute('style:position', $position);
|
|
|
398 |
}
|
|
|
399 |
$imageElement->appendChild($binaryElement);
|
|
|
400 |
$this->pageLayoutProperties->appendChild($imageElement);
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
//style:columns
|
|
|
404 |
|
|
|
405 |
|
|
|
406 |
/**
|
|
|
407 |
* Specify the number of the first page
|
|
|
408 |
*
|
|
|
409 |
* @param integer $number
|
|
|
410 |
*/
|
|
|
411 |
function setFirstPageNumber($number) {
|
|
|
412 |
if (!isNumeric($number)) {
|
|
|
413 |
throw new StyleException('Invalid first page number value.');
|
|
|
414 |
}
|
|
|
415 |
$this->pageLayoutProperties->setAttribute('style:first-page-number', $number);
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
/**
|
|
|
419 |
* Specifies the maximum amount of space on the page that a footnote can occupy.
|
|
|
420 |
*
|
|
|
421 |
* @param length $height
|
|
|
422 |
*/
|
|
|
423 |
function setMaximumFootnoteHeight($height) {
|
|
|
424 |
if (!isNumeric($height)) {
|
|
|
425 |
throw new StyleException('Invalid maximum footnote height.');
|
|
|
426 |
}
|
|
|
427 |
$this->pageLayoutProperties->setAttribute('style:footnote-max-height', $height);
|
|
|
428 |
}
|
|
|
429 |
|
|
|
430 |
/**
|
|
|
431 |
* Specify the line that separates the footnote from the body text area on a page
|
|
|
432 |
*
|
|
|
433 |
* @param length $lineWidth
|
|
|
434 |
* @param color $color
|
|
|
435 |
* @param integer $adjustment How the line is aligned on the page. Valid values: StyleConstants::(LEFT|RIGHT|CENTER)
|
|
|
436 |
* @param length $distanceBefore
|
|
|
437 |
* @param length $distanceAfter
|
|
|
438 |
* @param integer $lineStyle
|
|
|
439 |
*/
|
|
|
440 |
|
|
|
441 |
function setFootnoteSeparator($lineWidth = '1mm', $color = '#000000', $adjustment = StyleConstants::CENTER,
|
|
|
442 |
$distanceBefore = '5mm', $distanceAfter = '5mm',
|
|
|
443 |
$lineStyle = StyleConstants::SOLID) {
|
|
|
444 |
|
|
|
445 |
if (!isLengthValue($lineWidth)) {
|
|
|
446 |
throw new StyleException('Invalid line-width value');
|
|
|
447 |
}
|
|
|
448 |
if (!isColor($color)) {
|
|
|
449 |
throw new StyleException('Invalid color value');
|
|
|
450 |
}
|
|
|
451 |
switch ($adjustment) {
|
|
|
452 |
case StyleConstants::LEFT:
|
|
|
453 |
$adjustment = 'left';break;
|
|
|
454 |
case StyleConstants::RIGHT:
|
|
|
455 |
$adjustment = 'right';break;
|
|
|
456 |
case StyleConstants::CENTER:
|
|
|
457 |
$adjustment = 'center';break;
|
|
|
458 |
default:
|
|
|
459 |
throw new StyleException('Invalid adjustment value');
|
|
|
460 |
}
|
|
|
461 |
if (!isLengthValue($distanceBefore)) {
|
|
|
462 |
throw new StyleException('Invalid distance-before value');
|
|
|
463 |
}
|
|
|
464 |
if (!isLengthValue($distanceAfter)) {
|
|
|
465 |
throw new StyleException('Invalid distance-before value');
|
|
|
466 |
}
|
|
|
467 |
switch($lineStyle) {
|
|
|
468 |
case StyleConstants::NONE:
|
|
|
469 |
$lineStyle = 'none';break;
|
|
|
470 |
case StyleConstants::SOLID:
|
|
|
471 |
$lineStyle = 'solid';break;
|
|
|
472 |
case StyleConstants::DOTTED:
|
|
|
473 |
$lineStyle = 'dotted';break;
|
|
|
474 |
case StyleConstants::DASH:
|
|
|
475 |
$lineStyle = 'dash';break;
|
|
|
476 |
case StyleConstants::LONG_DASH:
|
|
|
477 |
$lineStyle = 'long-dash';break;
|
|
|
478 |
case StyleConstants::DOT_DOT_DASH:
|
|
|
479 |
$lineStyle = 'dot-dot-dash';break;
|
|
|
480 |
case StyleConstants::WAVE:
|
|
|
481 |
$lineStyle = 'wave';break;
|
|
|
482 |
default:
|
|
|
483 |
throw new StyleException('Invalid line-style value.');
|
|
|
484 |
}
|
|
|
485 |
$footNote = $this->styleDocument->createElement('style:footnote-sep');
|
|
|
486 |
$footNote->setAttribute('style:width', $lineWidth);
|
|
|
487 |
$footNote->setAttribute('style:color', $color);
|
|
|
488 |
$footNote->setAttribute('style:adjustment', $adjustment);
|
|
|
489 |
$footNote->setAttribute('style:distance-before-sep', $distanceBefore);
|
|
|
490 |
$footNote->setAttribute('style:distance-after-sep', $distanceAfter);
|
|
|
491 |
$footNote->setAttribute('style:line-style', $lineStyle);
|
|
|
492 |
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
/**
|
|
|
496 |
* Specifies the writing mode for the pages.
|
|
|
497 |
*
|
|
|
498 |
* @param integer $writingMode Valid values: StyleConstants::(LR_TB|RL_TB|TB_RL|TB_LR|RL|TB|PAGE)
|
|
|
499 |
*/
|
|
|
500 |
function setWritingMode($writingMode) {
|
|
|
501 |
switch ($writingMode) {
|
|
|
502 |
case StyleConstants::LR_TB:
|
|
|
503 |
$writingMode = 'lr-tb';break;
|
|
|
504 |
case StyleConstants::RL_TB:
|
|
|
505 |
$writingMode = 'rl-tb';break;
|
|
|
506 |
case StyleConstants::TB_RL:
|
|
|
507 |
$writingMode = 'tb-rl';break;
|
|
|
508 |
case StyleConstants::TB_LR:
|
|
|
509 |
$writingMode = 'tb-lr';break;
|
|
|
510 |
case StyleConstants::RL:
|
|
|
511 |
$writingMode = 'rl';break;
|
|
|
512 |
case StyleConstants::TB:
|
|
|
513 |
$writingMode = 'tb';break;
|
|
|
514 |
case StyleConstants::PAGE:
|
|
|
515 |
$writingMode = 'page';break;
|
|
|
516 |
default:
|
|
|
517 |
throw new StyleException('Invalid writing-mode value');
|
|
|
518 |
}
|
|
|
519 |
$this->pageLayoutProperties->setAttribute('style:writing-mode', $writingMode);
|
|
|
520 |
}
|
|
|
521 |
|
|
|
522 |
/**
|
|
|
523 |
* Specifies the height of the headers & footers
|
|
|
524 |
*
|
|
|
525 |
* @param length $height
|
|
|
526 |
*/
|
|
|
527 |
function setHeadFootHeight($element, $height) {
|
|
|
528 |
if (!isLengthValue($height)) {
|
|
|
529 |
throw new StyleException('Invalid height value.');
|
|
|
530 |
}
|
|
|
531 |
if ($element == 'header') {
|
|
|
532 |
$this->headerProperties->setAttribute('svg:height', $height);
|
|
|
533 |
} else if ($element == 'footer') {
|
|
|
534 |
$this->footerProperties->setAttribute('svg:height', $height);
|
|
|
535 |
}
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
function setHeaderHeight($height) {
|
|
|
539 |
$this->setHeadFootHeight('header', $height);
|
|
|
540 |
}
|
|
|
541 |
function setFooterHeight($height) {
|
|
|
542 |
$this->setHeadFootHeight('footer', $height);
|
|
|
543 |
}
|
|
|
544 |
|
|
|
545 |
/**
|
|
|
546 |
* Specifies the minimum height of the headers & footers
|
|
|
547 |
*
|
|
|
548 |
* @param length $height
|
|
|
549 |
*/
|
|
|
550 |
function setHeadFootMinHeight($element, $minHeight) {
|
|
|
551 |
if (!isLengthValue($minHeight)) {
|
|
|
552 |
throw new StyleException('Invalid min-height value.');
|
|
|
553 |
}
|
|
|
554 |
if ($element == 'header') {
|
|
|
555 |
$this->headerProperties->setAttribute('fo:min-height', $minHeight);
|
|
|
556 |
} else if ($element == 'footer'){
|
|
|
557 |
$this->footerProperties->setAttribute('fo:min-height', $minHeight);
|
|
|
558 |
}
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
function setHeaderMinHeight($minHeight) {
|
|
|
562 |
$this->setHeadFootMinHeight('header', $minHeight);
|
|
|
563 |
}
|
|
|
564 |
function setFooterMinHeight($minHeight) {
|
|
|
565 |
$this->setHeadFootMinHeight('footer', $minHeight);
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
/**
|
|
|
569 |
* Specify the left & right margin for headers & footers
|
|
|
570 |
*
|
|
|
571 |
* @param integer|string $leftMargin
|
|
|
572 |
* @param integer|string $rightMargin
|
|
|
573 |
*/
|
|
|
574 |
function setHeadFootHMargins($element, $leftMargin = 0, $rightMargin = 0) {
|
|
|
575 |
if (!isNumeric($leftMargin) && !isLengthValue($leftMargin)) {
|
|
|
576 |
throw new StyleException('Invalid left-margin value');
|
|
|
577 |
}
|
|
|
578 |
if (!isNumeric($rightMargin) && !isLengthValue($rightMargin)) {
|
|
|
579 |
throw new StyleException('Invalid right-margin value');
|
|
|
580 |
}
|
|
|
581 |
if ($element == 'header') {
|
|
|
582 |
$this->headerProperties->setAttribute('fo:margin-left', $leftMargin);
|
|
|
583 |
$this->headerProperties->setAttribute('fo:margin-right', $rightMargin);
|
|
|
584 |
} else if ($element == 'footer') {
|
|
|
585 |
$this->footerProperties->setAttribute('fo:margin-left', $leftMargin);
|
|
|
586 |
$this->footerProperties->setAttribute('fo:margin-right', $rightMargin);
|
|
|
587 |
}
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
function setHeaderHMargins($leftMargin = 0, $rightMargin = 0) {
|
|
|
591 |
$this->setHeadFootHMargins('header', $leftMargin, $rightMargin);
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
function setFooterHMargins($leftMargin = 0, $rightMargin = 0) {
|
|
|
595 |
$this->setHeadFootHMargins('footer', $leftMargin, $rightMargin);
|
|
|
596 |
}
|
|
|
597 |
|
|
|
598 |
/**
|
|
|
599 |
* Specify the top & bottom margin for headers & footers
|
|
|
600 |
*
|
|
|
601 |
* @param integer|string $topMargin
|
|
|
602 |
* @param integer|string $bottomMargin
|
|
|
603 |
*/
|
|
|
604 |
function setHeadFootVMargins($topMargin, $bottomMargin) {
|
|
|
605 |
if (!isNumeric($topMargin, true) && !isLengthValue($topMargin, true)) {
|
|
|
606 |
throw new StyleException('Invalid top-margin value');
|
|
|
607 |
}
|
|
|
608 |
if (!isNumeric($bottomMargin) && !isLengthValue($bottomMargin)) {
|
|
|
609 |
throw new StyleException('Invalid bottom-margin value');
|
|
|
610 |
}
|
|
|
611 |
$this->headerFooterProperties->setAttribute('fo:margin-top', $topMargin);
|
|
|
612 |
$this->headerFooterProperties->setAttribute('fo:margin-bottom', $bottomMargin);
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
function setHeaderVMargins($topMargin = 0, $bottomMargin = 0) {
|
|
|
616 |
$this->setHeadFootHMargins('header', $topMargin, $bottomMargin);
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
function setFooterVMargins($topMargin = 0, $bottomMargin = 0) {
|
|
|
620 |
$this->setHeadFootHMargins('footer', $topMargin, $bottomMargin);
|
|
|
621 |
}
|
|
|
622 |
|
|
|
623 |
/**
|
|
|
624 |
* Specifies the border properties for headers & footers.
|
|
|
625 |
*
|
|
|
626 |
* @param color $borderColor Border color
|
|
|
627 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
628 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
629 |
* @param string $position Do not use this, it's for internal use only.
|
|
|
630 |
*/
|
|
|
631 |
function setHeadFootBorder($element, $borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
632 |
$borderWidth = StyleConstants::THIN, $position = '') {
|
|
|
633 |
if (!isColor($borderColor)) {
|
|
|
634 |
throw new StyleException('Invalid border-color value');
|
|
|
635 |
}
|
|
|
636 |
|
|
|
637 |
switch ($borderStyle) {
|
|
|
638 |
case StyleConstants::SOLID:
|
|
|
639 |
$borderStyle = 'solid';break;
|
|
|
640 |
case StyleConstants::DOUBLE:
|
|
|
641 |
$borderStyle = 'double';break;
|
|
|
642 |
default:
|
|
|
643 |
throw new StyleException('Invalid border-style value');
|
|
|
644 |
}
|
|
|
645 |
switch ($borderWidth) {
|
|
|
646 |
case StyleConstants::THIN:
|
|
|
647 |
$borderWidth = 'thin';break;
|
|
|
648 |
case StyleConstants::THICK:
|
|
|
649 |
$borderWidth = 'thick';break;
|
|
|
650 |
case StyleConstants::MEDIUM:
|
|
|
651 |
$borderWidth = 'medium';break;
|
|
|
652 |
default:
|
|
|
653 |
if (!isLengthValue($borderWidth, true)) {
|
|
|
654 |
throw new StyleException('Invalid border-width value');
|
|
|
655 |
}
|
|
|
656 |
}
|
|
|
657 |
if (!empty($position)) {
|
|
|
658 |
if (!in_array($position, array('top', 'bottom', 'left', 'right'))) {
|
|
|
659 |
$position = '';
|
|
|
660 |
} else {
|
|
|
661 |
$position = '-'.$position;
|
|
|
662 |
}
|
|
|
663 |
}
|
|
|
664 |
if ($element == 'header') {
|
|
|
665 |
$this->headerProperties->setAttribute('fo:border'.$position, "$borderWidth $borderStyle $borderColor");
|
|
|
666 |
} else if ($element == 'footer') {
|
|
|
667 |
$this->footerProperties->setAttribute('fo:border'.$position, "$borderWidth $borderStyle $borderColor");
|
|
|
668 |
}
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
function setHeaderBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
672 |
$borderWidth = StyleConstants::THIN) {
|
|
|
673 |
$this->setHeadFootBorder('header', $borderColor, $borderStyle, $borderWidth);
|
|
|
674 |
}
|
|
|
675 |
function setFooterBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
676 |
$borderWidth = StyleConstants::THIN) {
|
|
|
677 |
$this->setHeadFootBorder('footer', $borderColor, $borderStyle, $borderWidth);
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
/**
|
|
|
681 |
* Specifies the border properties for headers & footers.
|
|
|
682 |
*
|
|
|
683 |
* @param color $borderColor Border color
|
|
|
684 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
685 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
686 |
*/
|
|
|
687 |
|
|
|
688 |
function setHeaderTopBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
689 |
$borderWidth = StyleConstants::THIN) {
|
|
|
690 |
$this->setHeaderBorder($borderColor, $borderStyle, $borderWidth, 'top');
|
|
|
691 |
}
|
|
|
692 |
function setFooterTopBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
693 |
$borderWidth = StyleConstants::THIN) {
|
|
|
694 |
$this->setFooterBorder($borderColor, $borderStyle, $borderWidth, 'top');
|
|
|
695 |
}
|
|
|
696 |
|
|
|
697 |
/**
|
|
|
698 |
* Specifies the border properties for headers & footers.
|
|
|
699 |
*
|
|
|
700 |
* @param color $borderColor Border color
|
|
|
701 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
702 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
703 |
*/
|
|
|
704 |
|
|
|
705 |
function setHeaderBottomBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
706 |
$borderWidth = StyleConstants::THIN) {
|
|
|
707 |
$this->setHeaderBorder($borderColor, $borderStyle, $borderWidth, 'bottom');
|
|
|
708 |
}
|
|
|
709 |
function setFooterBottomBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
710 |
$borderWidth = StyleConstants::THIN) {
|
|
|
711 |
$this->setFooterBorder($borderColor, $borderStyle, $borderWidth, 'bottom');
|
|
|
712 |
}
|
|
|
713 |
|
|
|
714 |
/**
|
|
|
715 |
* Specifies the border properties for headers & footers.
|
|
|
716 |
*
|
|
|
717 |
* @param color $borderColor Border color
|
|
|
718 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
719 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
720 |
*/
|
|
|
721 |
|
|
|
722 |
function setHeaderLeftBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
723 |
$borderWidth = StyleConstants::THIN) {
|
|
|
724 |
$this->setHeaderBorder($borderColor, $borderStyle, $borderWidth, 'left');
|
|
|
725 |
}
|
|
|
726 |
function setFooterLeftBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
727 |
$borderWidth = StyleConstants::THIN) {
|
|
|
728 |
$this->setFooterBorder($borderColor, $borderStyle, $borderWidth, 'left');
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
/**
|
|
|
732 |
* Specifies the border properties for headers & footers.
|
|
|
733 |
*
|
|
|
734 |
* @param color $borderColor Border color
|
|
|
735 |
* @param int $borderStyle Valid values: StyleConstants::(SOLID|DOUBLE)
|
|
|
736 |
* @param int|length $borderWidth Can be a length, or one of these values: StyleConstants::(THIN|THICK|MEDIUM)
|
|
|
737 |
*/
|
|
|
738 |
|
|
|
739 |
function setHeaderRightBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
740 |
$borderWidth = StyleConstants::THIN) {
|
|
|
741 |
$this->setHeaderBorder($borderColor, $borderStyle, $borderWidth, 'right');
|
|
|
742 |
}
|
|
|
743 |
function setFooterRightBorder($borderColor = '#000000', $borderStyle = StyleConstants::SOLID,
|
|
|
744 |
$borderWidth = StyleConstants::THIN) {
|
|
|
745 |
$this->setFooterBorder($borderColor, $borderStyle, $borderWidth, 'right');
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
/**
|
|
|
749 |
* Specifies the spacing around the headers & footers..
|
|
|
750 |
* Note that you must first specify the border for the padding to work
|
|
|
751 |
*
|
|
|
752 |
* @param length $padding
|
|
|
753 |
* @param string $position Do not use this, it's for internal use only.
|
|
|
754 |
*/
|
|
|
755 |
function setHeadFootPadding($element, $padding, $position = '') {
|
|
|
756 |
if (!isLengthValue($padding, true) && !isNumeric($padding)) {
|
|
|
757 |
throw new StyleException('Invalid padding value');
|
|
|
758 |
}
|
|
|
759 |
if (!empty($position)) {
|
|
|
760 |
if (!in_array($position, array('top', 'bottom', 'left', 'right'))) {
|
|
|
761 |
$position = '';
|
|
|
762 |
} else {
|
|
|
763 |
$position = '-'.$position;
|
|
|
764 |
}
|
|
|
765 |
}
|
|
|
766 |
if ($element == 'header') {
|
|
|
767 |
$this->headerProperties->setAttribute('fo:padding'.$position, $padding);
|
|
|
768 |
} else if ($element == 'footer') {
|
|
|
769 |
$this->footerProperties->setAttribute('fo:padding'.$position, $padding);
|
|
|
770 |
}
|
|
|
771 |
}
|
|
|
772 |
|
|
|
773 |
function setHeaderPadding($padding, $position = '') {
|
|
|
774 |
$this->setHeadFootPadding('header', $padding, $position);
|
|
|
775 |
}
|
|
|
776 |
function setFooterPadding($padding, $position = '') {
|
|
|
777 |
$this->setHeadFootPadding('footer', $padding, $position);
|
|
|
778 |
}
|
|
|
779 |
|
|
|
780 |
function setHeaderTopPadding($padding) {
|
|
|
781 |
$this->setHeaderPadding($padding, 'top');
|
|
|
782 |
}
|
|
|
783 |
function setFooterTopPadding($padding) {
|
|
|
784 |
$this->setFooterPadding($padding, 'top');
|
|
|
785 |
}
|
|
|
786 |
|
|
|
787 |
function setHeaderBottomPadding($padding) {
|
|
|
788 |
$this->setHeaderPadding($padding, 'bottom');
|
|
|
789 |
}
|
|
|
790 |
function setFooterBottomPadding($padding) {
|
|
|
791 |
$this->setFooterPadding($padding, 'bottom');
|
|
|
792 |
}
|
|
|
793 |
|
|
|
794 |
function setHeaderLeftPadding($padding) {
|
|
|
795 |
$this->setHeaderPadding($padding, 'left');
|
|
|
796 |
}
|
|
|
797 |
function setFooterLeftPadding($padding) {
|
|
|
798 |
$this->setFooterPadding($padding, 'left');
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
function setHeaderRightPadding($padding) {
|
|
|
802 |
$this->setHeaderPadding($padding, 'right');
|
|
|
803 |
}
|
|
|
804 |
function setFooterRightPadding($padding) {
|
|
|
805 |
$this->setFooterPadding($padding, 'right');
|
|
|
806 |
}
|
|
|
807 |
|
|
|
808 |
/**
|
|
|
809 |
* Specify the background color of the headers & footers.
|
|
|
810 |
*
|
|
|
811 |
* @param color $color
|
|
|
812 |
*/
|
|
|
813 |
function setHeadFootBackgroundColor($element, $color) {
|
|
|
814 |
if ($color != StyleConstants::TRANSPARENT && !isColor($color)) {
|
|
|
815 |
throw new StyleException('Invalid background color');
|
|
|
816 |
}
|
|
|
817 |
if ($element == 'header') {
|
|
|
818 |
$this->headerProperties->setAttribute('fo:background-color', $color);
|
|
|
819 |
} else if ($element == 'footer') {
|
|
|
820 |
$this->footerProperties->setAttribute('fo:background-color', $color);
|
|
|
821 |
}
|
|
|
822 |
}
|
|
|
823 |
|
|
|
824 |
function setHeaderBackground($color) {
|
|
|
825 |
$this->setHeadFootBackgroundColor('header', $color);
|
|
|
826 |
}
|
|
|
827 |
function setFooterBackground($color) {
|
|
|
828 |
$this->setHeadFootBackgroundColor('footer', $color);
|
|
|
829 |
}
|
|
|
830 |
|
|
|
831 |
/**
|
|
|
832 |
*
|
|
|
833 |
* @param string $image The image's path.
|
|
|
834 |
* @param integer $repeat Specifies whether a background image is repeated or stretched.
|
|
|
835 |
* Valid values are StyleConstants::(REPEAT|NO_REPEAT|STRETCH)
|
|
|
836 |
* @param integer $position Specifies where to position a background image in a paragraph.
|
|
|
837 |
* Valid values are StyleConstants::(LEFT|RIGHT|CENTER|TOP|BOTTOM)
|
|
|
838 |
*/
|
|
|
839 |
function setHeadFootBackgroundImage($element, $image, $repeat = StyleConstants::REPEAT,
|
|
|
840 |
$position = StyleConstants::CENTER) {
|
|
|
841 |
$file = fopen($image, 'r');
|
|
|
842 |
if (!$file) {
|
|
|
843 |
throw new StyleException('Cannot open image');
|
|
|
844 |
}
|
|
|
845 |
switch($repeat) {
|
|
|
846 |
case StyleConstants::REPEAT:
|
|
|
847 |
$repeat = 'repeat';break;
|
|
|
848 |
case StyleConstants::NO_REPEAT:
|
|
|
849 |
$repeat = 'no-repeat';break;
|
|
|
850 |
case StyleConstants::STRETCH:
|
|
|
851 |
$repeat = 'stretch';break;
|
|
|
852 |
default:
|
|
|
853 |
throw new StyleException('Invalid repeat value');
|
|
|
854 |
}
|
|
|
855 |
switch($position) {
|
|
|
856 |
case StyleConstants::LEFT:
|
|
|
857 |
$position = 'left';break;
|
|
|
858 |
case StyleConstants::RIGHT:
|
|
|
859 |
$position = 'right';break;
|
|
|
860 |
case StyleConstants::CENTER:
|
|
|
861 |
$position = 'center';break;
|
|
|
862 |
case StyleConstants::TOP:
|
|
|
863 |
$position = 'top';break;
|
|
|
864 |
case StyleConstants::BOTTOM:
|
|
|
865 |
$position = 'left';break;
|
|
|
866 |
default:
|
|
|
867 |
throw new StyleException('Invalid background-position value');
|
|
|
868 |
}
|
|
|
869 |
$dataImg = fread($file, filesize($image));
|
|
|
870 |
$dateImgB64 = base64_encode($dataImg);
|
|
|
871 |
fclose($file);
|
|
|
872 |
$binaryElement = $this->styleDocument->createElement('office:binary-data', $dateImgB64);
|
|
|
873 |
$imageElement = $this->styleDocument->createElement('style:background-image');
|
|
|
874 |
$imageElement->setAttribute('style:repeat', $repeat);
|
|
|
875 |
$imageElement->setAttribute('style:position', $position);
|
|
|
876 |
$imageElement->appendChild($binaryElement);
|
|
|
877 |
if ($element == 'header') {
|
|
|
878 |
$this->headerProperties->appendChild($imageElement);
|
|
|
879 |
} else if ($element == 'footer') {
|
|
|
880 |
$this->footerProperties->appendChild($imageElement);
|
|
|
881 |
}
|
|
|
882 |
}
|
|
|
883 |
|
|
|
884 |
function setHeaderBackgroundImage($image, $repeat = StyleConstants::REPEAT, $position = StyleConstants::CENTER) {
|
|
|
885 |
$this->setHeadFootBackgroundColor('header', $image, $repeat, $position);
|
|
|
886 |
}
|
|
|
887 |
function setFooterBackgroundImage($image, $repeat = StyleConstants::REPEAT, $position = StyleConstants::CENTER) {
|
|
|
888 |
$this->setHeadFootBackgroundColor('footer', $image, $repeat, $position);
|
|
|
889 |
}
|
|
|
890 |
|
|
|
891 |
function setHeadFootContent($element, $content, $paragraphStyles = null) {
|
|
|
892 |
$p = new Paragraph($paragraphStyles, false);
|
|
|
893 |
if ($content == StyleConstants::PAGE_NUMBER) {
|
|
|
894 |
$pageNumber = ODT::getInstance()->getDocumentContent()->createElement('text:page-number');
|
|
|
895 |
$pageNumber->setAttribute('text:select-page', 'current');
|
|
|
896 |
$p->getDOMElement()->appendChild($pageNumber);
|
|
|
897 |
} else if($content == StyleConstants::CURRENT_DATE) {
|
|
|
898 |
$date = ODT::getInstance()->getDocumentContent()->createElement('text:date');
|
|
|
899 |
$p->getDOMElement()->appendChild($date);
|
|
|
900 |
} else {
|
|
|
901 |
$p->addText($content);
|
|
|
902 |
}
|
|
|
903 |
$headfoot = $this->styleDocument->createElement($element);
|
|
|
904 |
$headfoot->appendChild($this->styleDocument->importNode($p->getDOMElement(), true));
|
|
|
905 |
$this->masterStyleElement->appendChild($headfoot);
|
|
|
906 |
}
|
|
|
907 |
|
|
|
908 |
function setHeaderContent($content, $paragraphStyles = null) {
|
|
|
909 |
$this->setHeadFootContent('style:header', $content, $paragraphStyles);
|
|
|
910 |
}
|
|
|
911 |
|
|
|
912 |
function setFooterContent($content, $paragraphStyles = null) {
|
|
|
913 |
$this->setHeadFootContent('style:footer', $content, $paragraphStyles);
|
|
|
914 |
}
|
|
|
915 |
}
|
|
|
916 |
?>
|