MDL-63044 course: add get_enrolled_courses_by_timeline_classification
[moodle.git] / lib / phpexcel / PHPExcel / Worksheet / HeaderFooter.php
blob3a88923fc9aee8386e18185cf43315456f2858ac
1 <?php
2 /**
3 * PHPExcel_Worksheet_HeaderFooter
5 * Copyright (c) 2006 - 2015 PHPExcel
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.
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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not,241 write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * @category PHPExcel
22 * @package PHPExcel_Worksheet
23 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
27 * <code>
28 * Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970:
30 * There are a number of formatting codes that can be written inline with the actual header / footer text, which
31 * affect the formatting in the header or footer.
33 * Example: This example shows the text "Center Bold Header" on the first line (center section), and the date on
34 * the second line (center section).
35 * &CCenter &"-,Bold"Bold&"-,Regular"Header_x000A_&D
37 * General Rules:
38 * There is no required order in which these codes must appear.
40 * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
41 * - strikethrough
42 * - superscript
43 * - subscript
44 * Superscript and subscript cannot both be ON at same time. Whichever comes first wins and the other is ignored,
45 * while the first is ON.
46 * &L - code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
47 * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
48 * order of appearance, and placed into the left section.
49 * &P - code for "current page #"
50 * &N - code for "total pages"
51 * &font size - code for "text font size", where font size is a font size in points.
52 * &K - code for "text font color"
53 * RGB Color is specified as RRGGBB
54 * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
55 * value, NN is the tint/shade value.
56 * &S - code for "text strikethrough" on / off
57 * &X - code for "text super script" on / off
58 * &Y - code for "text subscript" on / off
59 * &C - code for "center section". When two or more occurrences of this section marker exist, the contents
60 * from all markers are concatenated, in the order of appearance, and placed into the center section.
62 * &D - code for "date"
63 * &T - code for "time"
64 * &G - code for "picture as background"
65 * &U - code for "text single underline"
66 * &E - code for "double underline"
67 * &R - code for "right section". When two or more occurrences of this section marker exist, the contents
68 * from all markers are concatenated, in the order of appearance, and placed into the right section.
69 * &Z - code for "this workbook's file path"
70 * &F - code for "this workbook's file name"
71 * &A - code for "sheet tab name"
72 * &+ - code for add to page #.
73 * &- - code for subtract from page #.
74 * &"font name,font type" - code for "text font name" and "text font type", where font name and font type
75 * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
76 * name, it means "none specified". Both of font name and font type can be localized values.
77 * &"-,Bold" - code for "bold font style"
78 * &B - also means "bold font style".
79 * &"-,Regular" - code for "regular font style"
80 * &"-,Italic" - code for "italic font style"
81 * &I - also means "italic font style"
82 * &"-,Bold Italic" code for "bold italic font style"
83 * &O - code for "outline style"
84 * &H - code for "shadow style"
85 * </code>
88 class PHPExcel_Worksheet_HeaderFooter
90 /* Header/footer image location */
91 const IMAGE_HEADER_LEFT = 'LH';
92 const IMAGE_HEADER_CENTER = 'CH';
93 const IMAGE_HEADER_RIGHT = 'RH';
94 const IMAGE_FOOTER_LEFT = 'LF';
95 const IMAGE_FOOTER_CENTER = 'CF';
96 const IMAGE_FOOTER_RIGHT = 'RF';
98 /**
99 * OddHeader
101 * @var string
103 private $oddHeader = '';
106 * OddFooter
108 * @var string
110 private $oddFooter = '';
113 * EvenHeader
115 * @var string
117 private $evenHeader = '';
120 * EvenFooter
122 * @var string
124 private $evenFooter = '';
127 * FirstHeader
129 * @var string
131 private $firstHeader = '';
134 * FirstFooter
136 * @var string
138 private $firstFooter = '';
141 * Different header for Odd/Even, defaults to false
143 * @var boolean
145 private $differentOddEven = false;
148 * Different header for first page, defaults to false
150 * @var boolean
152 private $differentFirst = false;
155 * Scale with document, defaults to true
157 * @var boolean
159 private $scaleWithDocument = true;
162 * Align with margins, defaults to true
164 * @var boolean
166 private $alignWithMargins = true;
169 * Header/footer images
171 * @var PHPExcel_Worksheet_HeaderFooterDrawing[]
173 private $headerFooterImages = array();
176 * Create a new PHPExcel_Worksheet_HeaderFooter
178 public function __construct()
183 * Get OddHeader
185 * @return string
187 public function getOddHeader()
189 return $this->oddHeader;
193 * Set OddHeader
195 * @param string $pValue
196 * @return PHPExcel_Worksheet_HeaderFooter
198 public function setOddHeader($pValue)
200 $this->oddHeader = $pValue;
201 return $this;
205 * Get OddFooter
207 * @return string
209 public function getOddFooter()
211 return $this->oddFooter;
215 * Set OddFooter
217 * @param string $pValue
218 * @return PHPExcel_Worksheet_HeaderFooter
220 public function setOddFooter($pValue)
222 $this->oddFooter = $pValue;
223 return $this;
227 * Get EvenHeader
229 * @return string
231 public function getEvenHeader()
233 return $this->evenHeader;
237 * Set EvenHeader
239 * @param string $pValue
240 * @return PHPExcel_Worksheet_HeaderFooter
242 public function setEvenHeader($pValue)
244 $this->evenHeader = $pValue;
245 return $this;
249 * Get EvenFooter
251 * @return string
253 public function getEvenFooter()
255 return $this->evenFooter;
259 * Set EvenFooter
261 * @param string $pValue
262 * @return PHPExcel_Worksheet_HeaderFooter
264 public function setEvenFooter($pValue)
266 $this->evenFooter = $pValue;
267 return $this;
271 * Get FirstHeader
273 * @return string
275 public function getFirstHeader()
277 return $this->firstHeader;
281 * Set FirstHeader
283 * @param string $pValue
284 * @return PHPExcel_Worksheet_HeaderFooter
286 public function setFirstHeader($pValue)
288 $this->firstHeader = $pValue;
289 return $this;
293 * Get FirstFooter
295 * @return string
297 public function getFirstFooter()
299 return $this->firstFooter;
303 * Set FirstFooter
305 * @param string $pValue
306 * @return PHPExcel_Worksheet_HeaderFooter
308 public function setFirstFooter($pValue)
310 $this->firstFooter = $pValue;
311 return $this;
315 * Get DifferentOddEven
317 * @return boolean
319 public function getDifferentOddEven()
321 return $this->differentOddEven;
325 * Set DifferentOddEven
327 * @param boolean $pValue
328 * @return PHPExcel_Worksheet_HeaderFooter
330 public function setDifferentOddEven($pValue = false)
332 $this->differentOddEven = $pValue;
333 return $this;
337 * Get DifferentFirst
339 * @return boolean
341 public function getDifferentFirst()
343 return $this->differentFirst;
347 * Set DifferentFirst
349 * @param boolean $pValue
350 * @return PHPExcel_Worksheet_HeaderFooter
352 public function setDifferentFirst($pValue = false)
354 $this->differentFirst = $pValue;
355 return $this;
359 * Get ScaleWithDocument
361 * @return boolean
363 public function getScaleWithDocument()
365 return $this->scaleWithDocument;
369 * Set ScaleWithDocument
371 * @param boolean $pValue
372 * @return PHPExcel_Worksheet_HeaderFooter
374 public function setScaleWithDocument($pValue = true)
376 $this->scaleWithDocument = $pValue;
377 return $this;
381 * Get AlignWithMargins
383 * @return boolean
385 public function getAlignWithMargins()
387 return $this->alignWithMargins;
391 * Set AlignWithMargins
393 * @param boolean $pValue
394 * @return PHPExcel_Worksheet_HeaderFooter
396 public function setAlignWithMargins($pValue = true)
398 $this->alignWithMargins = $pValue;
399 return $this;
403 * Add header/footer image
405 * @param PHPExcel_Worksheet_HeaderFooterDrawing $image
406 * @param string $location
407 * @throws PHPExcel_Exception
408 * @return PHPExcel_Worksheet_HeaderFooter
410 public function addImage(PHPExcel_Worksheet_HeaderFooterDrawing $image = null, $location = self::IMAGE_HEADER_LEFT)
412 $this->headerFooterImages[$location] = $image;
413 return $this;
417 * Remove header/footer image
419 * @param string $location
420 * @throws PHPExcel_Exception
421 * @return PHPExcel_Worksheet_HeaderFooter
423 public function removeImage($location = self::IMAGE_HEADER_LEFT)
425 if (isset($this->headerFooterImages[$location])) {
426 unset($this->headerFooterImages[$location]);
428 return $this;
432 * Set header/footer images
434 * @param PHPExcel_Worksheet_HeaderFooterDrawing[] $images
435 * @throws PHPExcel_Exception
436 * @return PHPExcel_Worksheet_HeaderFooter
438 public function setImages($images)
440 if (!is_array($images)) {
441 throw new PHPExcel_Exception('Invalid parameter!');
444 $this->headerFooterImages = $images;
445 return $this;
449 * Get header/footer images
451 * @return PHPExcel_Worksheet_HeaderFooterDrawing[]
453 public function getImages()
455 // Sort array
456 $images = array();
457 if (isset($this->headerFooterImages[self::IMAGE_HEADER_LEFT])) {
458 $images[self::IMAGE_HEADER_LEFT] = $this->headerFooterImages[self::IMAGE_HEADER_LEFT];
460 if (isset($this->headerFooterImages[self::IMAGE_HEADER_CENTER])) {
461 $images[self::IMAGE_HEADER_CENTER] = $this->headerFooterImages[self::IMAGE_HEADER_CENTER];
463 if (isset($this->headerFooterImages[self::IMAGE_HEADER_RIGHT])) {
464 $images[self::IMAGE_HEADER_RIGHT] = $this->headerFooterImages[self::IMAGE_HEADER_RIGHT];
466 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_LEFT])) {
467 $images[self::IMAGE_FOOTER_LEFT] = $this->headerFooterImages[self::IMAGE_FOOTER_LEFT];
469 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_CENTER])) {
470 $images[self::IMAGE_FOOTER_CENTER] = $this->headerFooterImages[self::IMAGE_FOOTER_CENTER];
472 if (isset($this->headerFooterImages[self::IMAGE_FOOTER_RIGHT])) {
473 $images[self::IMAGE_FOOTER_RIGHT] = $this->headerFooterImages[self::IMAGE_FOOTER_RIGHT];
475 $this->headerFooterImages = $images;
477 return $this->headerFooterImages;
481 * Implement PHP __clone to create a deep clone, not just a shallow copy.
483 public function __clone()
485 $vars = get_object_vars($this);
486 foreach ($vars as $key => $value) {
487 if (is_object($value)) {
488 $this->$key = clone $value;
489 } else {
490 $this->$key = $value;