PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/v1.4.0/Classes/PHPExcel/Worksheet/HeaderFooter.php

#
PHP | 379 lines | 97 code | 33 blank | 249 comment | 2 complexity | 0abcc53c21a32380c9ce9c5204599d4a MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-3.0, LGPL-3.0
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2007 PHPExcel
  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 PHPExcel
  22. * @package PHPExcel_Worksheet
  23. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/lgpl.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPExcel_Worksheet_HeaderFooter
  29. *
  30. * <code>
  31. * Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970:
  32. *
  33. * There are a number of formatting codes that can be written inline with the actual header / footer text, which
  34. * affect the formatting in the header or footer.
  35. *
  36. * Example: This example shows the text "Center Bold Header" on the first line (center section), and the date on
  37. * the second line (center section).
  38. * &CCenter &"-,Bold"Bold&"-,Regular"Header_x000A_&D
  39. *
  40. * General Rules:
  41. * There is no required order in which these codes must appear.
  42. *
  43. * The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
  44. * - strikethrough
  45. * - superscript
  46. * - subscript
  47. * Superscript and subscript cannot both be ON at same time. Whichever comes first wins and the other is ignored,
  48. * while the first is ON.
  49. * &L - code for "left section" (there are three header / footer locations, "left", "center", and "right"). When
  50. * two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the
  51. * order of appearance, and placed into the left section.
  52. * &P - code for "current page #"
  53. * &N - code for "total pages"
  54. * &font size - code for "text font size", where font size is a font size in points.
  55. * &K - code for "text font color"
  56. * RGB Color is specified as RRGGBB
  57. * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade
  58. * value, NN is the tint/shade value.
  59. * &S - code for "text strikethrough" on / off
  60. * &X - code for "text super script" on / off
  61. * &Y - code for "text subscript" on / off
  62. * &C - code for "center section". When two or more occurrences of this section marker exist, the contents
  63. * from all markers are concatenated, in the order of appearance, and placed into the center section.
  64. *
  65. * &D - code for "date"
  66. * &T - code for "time"
  67. * &G - code for "picture as background"
  68. * &U - code for "text single underline"
  69. * &E - code for "double underline"
  70. * &R - code for "right section". When two or more occurrences of this section marker exist, the contents
  71. * from all markers are concatenated, in the order of appearance, and placed into the right section.
  72. * &Z - code for "this workbook's file path"
  73. * &F - code for "this workbook's file name"
  74. * &A - code for "sheet tab name"
  75. * &+ - code for add to page #.
  76. * &- - code for subtract from page #.
  77. * &"font name,font type" - code for "text font name" and "text font type", where font name and font type
  78. * are strings specifying the name and type of the font, separated by a comma. When a hyphen appears in font
  79. * name, it means "none specified". Both of font name and font type can be localized values.
  80. * &"-,Bold" - code for "bold font style"
  81. * &B - also means "bold font style".
  82. * &"-,Regular" - code for "regular font style"
  83. * &"-,Italic" - code for "italic font style"
  84. * &I - also means "italic font style"
  85. * &"-,Bold Italic" code for "bold italic font style"
  86. * &O - code for "outline style"
  87. * &H - code for "shadow style"
  88. * </code>
  89. *
  90. * @category PHPExcel
  91. * @package PHPExcel_Worksheet
  92. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  93. */
  94. class PHPExcel_Worksheet_HeaderFooter
  95. {
  96. /**
  97. * OddHeader
  98. *
  99. * @var string
  100. */
  101. private $_oddHeader;
  102. /**
  103. * OddFooter
  104. *
  105. * @var string
  106. */
  107. private $_oddFooter;
  108. /**
  109. * EvenHeader
  110. *
  111. * @var string
  112. */
  113. private $_evenHeader;
  114. /**
  115. * EvenFooter
  116. *
  117. * @var string
  118. */
  119. private $_evenFooter;
  120. /**
  121. * FirstHeader
  122. *
  123. * @var string
  124. */
  125. private $_firstHeader;
  126. /**
  127. * FirstFooter
  128. *
  129. * @var string
  130. */
  131. private $_firstFooter;
  132. /**
  133. * Different header for Odd/Even, defaults to false
  134. *
  135. * @var boolean
  136. */
  137. private $_differentOddEven;
  138. /**
  139. * Different header for first page, defaults to false
  140. *
  141. * @var boolean
  142. */
  143. private $_differentFirst;
  144. /**
  145. * Scale with document, defaults to true
  146. *
  147. * @var boolean
  148. */
  149. private $_scaleWithDocument;
  150. /**
  151. * Align with margins, defaults to true
  152. *
  153. * @var boolean
  154. */
  155. private $_alignWithMargins;
  156. /**
  157. * Create a new PHPExcel_Worksheet_HeaderFooter
  158. */
  159. public function __construct()
  160. {
  161. // Initialise values
  162. $this->_oddHeader = '';
  163. $this->_oddFooter = '';
  164. $this->_evenHeader = '';
  165. $this->_evenFooter = '';
  166. $this->_firstHeader = '';
  167. $this->_firstFooter = '';
  168. $this->_differentOddEven = false;
  169. $this->_differentFirst = false;
  170. $this->_scaleWithDocument = true;
  171. $this->_alignWithMargins = true;
  172. }
  173. /**
  174. * Get OddHeader
  175. *
  176. * @return string
  177. */
  178. public function getOddHeader() {
  179. return $this->_oddHeader;
  180. }
  181. /**
  182. * Set OddHeader
  183. *
  184. * @param string $pValue
  185. */
  186. public function setOddHeader($pValue) {
  187. $this->_oddHeader = $pValue;
  188. }
  189. /**
  190. * Get OddFooter
  191. *
  192. * @return string
  193. */
  194. public function getOddFooter() {
  195. return $this->_oddFooter;
  196. }
  197. /**
  198. * Set OddFooter
  199. *
  200. * @param string $pValue
  201. */
  202. public function setOddFooter($pValue) {
  203. $this->_oddFooter = $pValue;
  204. }
  205. /**
  206. * Get EvenHeader
  207. *
  208. * @return string
  209. */
  210. public function getEvenHeader() {
  211. return $this->_evenHeader;
  212. }
  213. /**
  214. * Set EvenHeader
  215. *
  216. * @param string $pValue
  217. */
  218. public function setEvenHeader($pValue) {
  219. $this->_evenHeader = $pValue;
  220. }
  221. /**
  222. * Get EvenFooter
  223. *
  224. * @return string
  225. */
  226. public function getEvenFooter() {
  227. return $this->_evenFooter;
  228. }
  229. /**
  230. * Set EvenFooter
  231. *
  232. * @param string $pValue
  233. */
  234. public function setEvenFooter($pValue) {
  235. $this->_evenFooter = $pValue;
  236. }
  237. /**
  238. * Get FirstHeader
  239. *
  240. * @return string
  241. */
  242. public function getFirstHeader() {
  243. return $this->_firstHeader;
  244. }
  245. /**
  246. * Set FirstHeader
  247. *
  248. * @param string $pValue
  249. */
  250. public function setFirstHeader($pValue) {
  251. $this->_firstHeader = $pValue;
  252. }
  253. /**
  254. * Get FirstFooter
  255. *
  256. * @return string
  257. */
  258. public function getFirstFooter() {
  259. return $this->_firstFooter;
  260. }
  261. /**
  262. * Set FirstFooter
  263. *
  264. * @param string $pValue
  265. */
  266. public function setFirstFooter($pValue) {
  267. $this->_firstFooter = $pValue;
  268. }
  269. /**
  270. * Get DifferentOddEven
  271. *
  272. * @return boolean
  273. */
  274. public function getDifferentOddEven() {
  275. return $this->_differentOddEven;
  276. }
  277. /**
  278. * Set DifferentOddEven
  279. *
  280. * @param boolean $pValue
  281. */
  282. public function setDifferentOddEven($pValue = false) {
  283. $this->_differentOddEven = $pValue;
  284. }
  285. /**
  286. * Get DifferentFirst
  287. *
  288. * @return boolean
  289. */
  290. public function getDifferentFirst() {
  291. return $this->_differentFirst;
  292. }
  293. /**
  294. * Set DifferentFirst
  295. *
  296. * @param boolean $pValue
  297. */
  298. public function setDifferentFirst($pValue = false) {
  299. $this->_differentFirst = $pValue;
  300. }
  301. /**
  302. * Get ScaleWithDocument
  303. *
  304. * @return boolean
  305. */
  306. public function getScaleWithDocument() {
  307. return $this->_scaleWithDocument;
  308. }
  309. /**
  310. * Set ScaleWithDocument
  311. *
  312. * @param boolean $pValue
  313. */
  314. public function setScaleWithDocument($pValue = true) {
  315. $this->_scaleWithDocument = $pValue;
  316. }
  317. /**
  318. * Get AlignWithMargins
  319. *
  320. * @return boolean
  321. */
  322. public function getAlignWithMargins() {
  323. return $this->_alignWithMargins;
  324. }
  325. /**
  326. * Set AlignWithMargins
  327. *
  328. * @param boolean $pValue
  329. */
  330. public function setAlignWithMargins($pValue = true) {
  331. $this->_alignWithMargins = $pValue;
  332. }
  333. /**
  334. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  335. */
  336. public function __clone() {
  337. $vars = get_object_vars($this);
  338. foreach ($vars as $key => $value) {
  339. if (is_object($value)) {
  340. $this->$key = clone $value;
  341. } else {
  342. $this->$key = $value;
  343. }
  344. }
  345. }
  346. }