PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.11
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.11
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Worksheet / HeaderFooter.php

HeaderFooter.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.11, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php

492 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Worksheet;
4
5 /**
6 * <code>
7 * Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970:.
8 *
9 * There are a number of formatting codes that can be written inline with the actual header / footer text, which
10 * affect the formatting in the header or footer.
11 *
12 * Example: This example shows the text "Center Bold Header" on the first line (center section), and the date on
13 * the second line (center section).
14 * &CCenter &"-,Bold"Bold&"-,Regular"Header_x000A_&D
15 *
16 * General Rules:
17 * There is no required order in which these codes must appear.
18 *
19 * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
20 * - strikethrough
21 * - superscript
22 * - subscript
23 * Superscript and subscript cannot both be ON at same time. Whichever comes first wins and the other is ignored,
24 * while the first is ON.
25 * &L - code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
26 * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
27 * order of appearance, and placed into the left section.
28 * &P - code for "current page #"
29 * &N - code for "total pages"
30 * &font size - code for "text font size", where font size is a font size in points.
31 * &K - code for "text font color"
32 * RGB Color is specified as RRGGBB
33 * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
34 * value, NN is the tint/shade value.
35 * &S - code for "text strikethrough" on / off
36 * &X - code for "text super script" on / off
37 * &Y - code for "text subscript" on / off
38 * &C - code for "center section". When two or more occurrences of this section marker exist, the contents
39 * from all markers are concatenated, in the order of appearance, and placed into the center section.
40 *
41 * &D - code for "date"
42 * &T - code for "time"
43 * &G - code for "picture as background"
44 * &U - code for "text single underline"
45 * &E - code for "double underline"
46 * &R - code for "right section". When two or more occurrences of this section marker exist, the contents
47 * from all markers are concatenated, in the order of appearance, and placed into the right section.
48 * &Z - code for "this workbook's file path"
49 * &F - code for "this workbook's file name"
50 * &A - code for "sheet tab name"
51 * &+ - code for add to page #.
52 * &- - code for subtract from page #.
53 * &"font name,font type" - code for "text font name" and "text font type", where font name and font type
54 * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
55 * name, it means "none specified". Both of font name and font type can be localized values.
56 * &"-,Bold" - code for "bold font style"
57 * &B - also means "bold font style".
58 * &"-,Regular" - code for "regular font style"
59 * &"-,Italic" - code for "italic font style"
60 * &I - also means "italic font style"
61 * &"-,Bold Italic" code for "bold italic font style"
62 * &O - code for "outline style"
63 * &H - code for "shadow style"
64 * </code>
65 */
66 class HeaderFooter
67 {
68 // Header/footer image location
69 const IMAGE_HEADER_LEFT = 'LH';
70 const IMAGE_HEADER_CENTER = 'CH';
71 const IMAGE_HEADER_RIGHT = 'RH';
72 const IMAGE_FOOTER_LEFT = 'LF';
73 const IMAGE_FOOTER_CENTER = 'CF';
74 const IMAGE_FOOTER_RIGHT = 'RF';
75
76 /**
77 * OddHeader.
78 *
79 * @var string
80 */
81 private $oddHeader = '';
82
83 /**
84 * OddFooter.
85 *
86 * @var string
87 */
88 private $oddFooter = '';
89
90 /**
91 * EvenHeader.
92 *
93 * @var string
94 */
95 private $evenHeader = '';
96
97 /**
98 * EvenFooter.
99 *
100 * @var string
101 */
102 private $evenFooter = '';
103
104 /**
105 * FirstHeader.
106 *
107 * @var string
108 */
109 private $firstHeader = '';
110
111 /**
112 * FirstFooter.
113 *
114 * @var string
115 */
116 private $firstFooter = '';
117
118 /**
119 * Different header for Odd/Even, defaults to false.
120 *
121 * @var bool
122 */
123 private $differentOddEven = false;
124
125 /**
126 * Different header for first page, defaults to false.
127 *
128 * @var bool
129 */
130 private $differentFirst = false;
131
132 /**
133 * Scale with document, defaults to true.
134 *
135 * @var bool
136 */
137 private $scaleWithDocument = true;
138
139 /**
140 * Align with margins, defaults to true.
141 *
142 * @var bool
143 */
144 private $alignWithMargins = true;
145
146 /**
147 * Header/footer images.
148 *
149 * @var HeaderFooterDrawing[]
150 */
151 private $headerFooterImages = [];
152
153 /**
154 * Create a new HeaderFooter.
155 */
156 public function __construct()
157 {
158 }
159
160 /**
161 * Get OddHeader.
162 *
163 * @return string
164 */
165 public function getOddHeader()
166 {
167 return $this->oddHeader;
168 }
169
170 /**
171 * Set OddHeader.
172 *
173 * @param string $pValue
174 *
175 * @return HeaderFooter
176 */
177 public function setOddHeader($pValue)
178 {
179 $this->oddHeader = $pValue;
180
181 return $this;
182 }
183
184 /**
185 * Get OddFooter.
186 *
187 * @return string
188 */
189 public function getOddFooter()
190 {
191 return $this->oddFooter;
192 }
193
194 /**
195 * Set OddFooter.
196 *
197 * @param string $pValue
198 *
199 * @return HeaderFooter
200 */
201 public function setOddFooter($pValue)
202 {
203 $this->oddFooter = $pValue;
204
205 return $this;
206 }
207
208 /**
209 * Get EvenHeader.
210 *
211 * @return string
212 */
213 public function getEvenHeader()
214 {
215 return $this->evenHeader;
216 }
217
218 /**
219 * Set EvenHeader.
220 *
221 * @param string $pValue
222 *
223 * @return HeaderFooter
224 */
225 public function setEvenHeader($pValue)
226 {
227 $this->evenHeader = $pValue;
228
229 return $this;
230 }
231
232 /**
233 * Get EvenFooter.
234 *
235 * @return string
236 */
237 public function getEvenFooter()
238 {
239 return $this->evenFooter;
240 }
241
242 /**
243 * Set EvenFooter.
244 *
245 * @param string $pValue
246 *
247 * @return HeaderFooter
248 */
249 public function setEvenFooter($pValue)
250 {
251 $this->evenFooter = $pValue;
252
253 return $this;
254 }
255
256 /**
257 * Get FirstHeader.
258 *
259 * @return string
260 */
261 public function getFirstHeader()
262 {
263 return $this->firstHeader;
264 }
265
266 /**
267 * Set FirstHeader.
268 *
269 * @param string $pValue
270 *
271 * @return HeaderFooter
272 */
273 public function setFirstHeader($pValue)
274 {
275 $this->firstHeader = $pValue;
276
277 return $this;
278 }
279
280 /**
281 * Get FirstFooter.
282 *
283 * @return string
284 */
285 public function getFirstFooter()
286 {
287 return $this->firstFooter;
288 }
289
290 /**
291 * Set FirstFooter.
292 *
293 * @param string $pValue
294 *
295 * @return HeaderFooter
296 */
297 public function setFirstFooter($pValue)
298 {
299 $this->firstFooter = $pValue;
300
301 return $this;
302 }
303
304 /**
305 * Get DifferentOddEven.
306 *
307 * @return bool
308 */
309 public function getDifferentOddEven()
310 {
311 return $this->differentOddEven;
312 }
313
314 /**
315 * Set DifferentOddEven.
316 *
317 * @param bool $pValue
318 *
319 * @return HeaderFooter
320 */
321 public function setDifferentOddEven($pValue)
322 {
323 $this->differentOddEven = $pValue;
324
325 return $this;
326 }
327
328 /**
329 * Get DifferentFirst.
330 *
331 * @return bool
332 */
333 public function getDifferentFirst()
334 {
335 return $this->differentFirst;
336 }
337
338 /**
339 * Set DifferentFirst.
340 *
341 * @param bool $pValue
342 *
343 * @return HeaderFooter
344 */
345 public function setDifferentFirst($pValue)
346 {
347 $this->differentFirst = $pValue;
348
349 return $this;
350 }
351
352 /**
353 * Get ScaleWithDocument.
354 *
355 * @return bool
356 */
357 public function getScaleWithDocument()
358 {
359 return $this->scaleWithDocument;
360 }
361
362 /**
363 * Set ScaleWithDocument.
364 *
365 * @param bool $pValue
366 *
367 * @return HeaderFooter
368 */
369 public function setScaleWithDocument($pValue)
370 {
371 $this->scaleWithDocument = $pValue;
372
373 return $this;
374 }
375
376 /**
377 * Get AlignWithMargins.
378 *
379 * @return bool
380 */
381 public function getAlignWithMargins()
382 {
383 return $this->alignWithMargins;
384 }
385
386 /**
387 * Set AlignWithMargins.
388 *
389 * @param bool $pValue
390 *
391 * @return HeaderFooter
392 */
393 public function setAlignWithMargins($pValue)
394 {
395 $this->alignWithMargins = $pValue;
396
397 return $this;
398 }
399
400 /**
401 * Add header/footer image.
402 *
403 * @param HeaderFooterDrawing $image
404 * @param string $location
405 *
406 * @return HeaderFooter
407 */
408 public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT)
409 {
410 $this->headerFooterImages[$location] = $image;
411
412 return $this;
413 }
414
415 /**
416 * Remove header/footer image.
417 *
418 * @param string $location
419 *
420 * @return HeaderFooter
421 */
422 public function removeImage($location = self::IMAGE_HEADER_LEFT)
423 {
424 if (isset($this->headerFooterImages[$location])) {
425 unset($this->headerFooterImages[$location]);
426 }
427
428 return $this;
429 }
430
431 /**
432 * Set header/footer images.
433 *
434 * @param HeaderFooterDrawing[] $images
435 *
436 * @return HeaderFooter
437 */
438 public function setImages(array $images)
439 {
440 $this->headerFooterImages = $images;
441
442 return $this;
443 }
444
445 /**
446 * Get header/footer images.
447 *
448 * @return HeaderFooterDrawing[]
449 */
450 public function getImages()
451 {
452 // Sort array
453 $images = [];
454 if (isset($this->headerFooterImages[self::IMAGE_HEADER_LEFT])) {
455 $images[self::IMAGE_HEADER_LEFT] = $this->headerFooterImages[self::IMAGE_HEADER_LEFT];
456 }
457 if (isset($this->headerFooterImages[self::IMAGE_HEADER_CENTER])) {
458 $images[self::IMAGE_HEADER_CENTER] = $this->headerFooterImages[self::IMAGE_HEADER_CENTER];
459 }
460 if (isset($this->headerFooterImages[self::IMAGE_HEADER_RIGHT])) {
461 $images[self::IMAGE_HEADER_RIGHT] = $this->headerFooterImages[self::IMAGE_HEADER_RIGHT];
462 }
463 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_LEFT])) {
464 $images[self::IMAGE_FOOTER_LEFT] = $this->headerFooterImages[self::IMAGE_FOOTER_LEFT];
465 }
466 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_CENTER])) {
467 $images[self::IMAGE_FOOTER_CENTER] = $this->headerFooterImages[self::IMAGE_FOOTER_CENTER];
468 }
469 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_RIGHT])) {
470 $images[self::IMAGE_FOOTER_RIGHT] = $this->headerFooterImages[self::IMAGE_FOOTER_RIGHT];
471 }
472 $this->headerFooterImages = $images;
473
474 return $this->headerFooterImages;
475 }
476
477 /**
478 * Implement PHP __clone to create a deep clone, not just a shallow copy.
479 */
480 public function __clone()
481 {
482 $vars = get_object_vars($this);
483 foreach ($vars as $key => $value) {
484 if (is_object($value)) {
485 $this->$key = clone $value;
486 } else {
487 $this->$key = $value;
488 }
489 }
490 }
491 }
492