Settings.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <?php
  2. /**
  3. * PHPWord
  4. *
  5. * Copyright (c) 2011 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) 010 PHPWord
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version Beta 0.6.3, 08.07.2011
  26. */
  27. /**
  28. * PHPWord_Section_Settings
  29. *
  30. * @category PHPWord
  31. * @package PHPWord_Section
  32. * @copyright Copyright (c) 2011 PHPWord
  33. */
  34. class PHPWord_Section_Settings {
  35. /**
  36. * Default Page Size Width
  37. *
  38. * @var int
  39. */
  40. private $_defaultPageSizeW = 11906;
  41. /**
  42. * Default Page Size Height
  43. *
  44. * @var int
  45. */
  46. private $_defaultPageSizeH = 16838;
  47. /**
  48. * Page Orientation
  49. *
  50. * @var string
  51. */
  52. private $_orientation;
  53. /**
  54. * Page Margin Top
  55. *
  56. * @var int
  57. */
  58. private $_marginTop;
  59. /**
  60. * Page Margin Left
  61. *
  62. * @var int
  63. */
  64. private $_marginLeft;
  65. /**
  66. * Page Margin Right
  67. *
  68. * @var int
  69. */
  70. private $_marginRight;
  71. /**
  72. * Page Margin Bottom
  73. *
  74. * @var int
  75. */
  76. private $_marginBottom;
  77. /**
  78. * Page Size Width
  79. *
  80. * @var int
  81. */
  82. private $_pageSizeW;
  83. /**
  84. * Page Size Height
  85. *
  86. * @var int
  87. */
  88. private $_pageSizeH;
  89. /**
  90. * Page Border Top Size
  91. *
  92. * @var int
  93. */
  94. private $_borderTopSize;
  95. /**
  96. * Page Border Top Color
  97. *
  98. * @var int
  99. */
  100. private $_borderTopColor;
  101. /**
  102. * Page Border Left Size
  103. *
  104. * @var int
  105. */
  106. private $_borderLeftSize;
  107. /**
  108. * Page Border Left Color
  109. *
  110. * @var int
  111. */
  112. private $_borderLeftColor;
  113. /**
  114. * Page Border Right Size
  115. *
  116. * @var int
  117. */
  118. private $_borderRightSize;
  119. /**
  120. * Page Border Right Color
  121. *
  122. * @var int
  123. */
  124. private $_borderRightColor;
  125. /**
  126. * Page Border Bottom Size
  127. *
  128. * @var int
  129. */
  130. private $_borderBottomSize;
  131. /**
  132. * Page Border Bottom Color
  133. *
  134. * @var int
  135. */
  136. private $_borderBottomColor;
  137. /**
  138. * Create new Section Settings
  139. */
  140. public function __construct() {
  141. $this->_orientation = null;
  142. $this->_marginTop = 1418;
  143. $this->_marginLeft = 1418;
  144. $this->_marginRight = 1418;
  145. $this->_marginBottom = 1134;
  146. $this->_pageSizeW = $this->_defaultPageSizeW;
  147. $this->_pageSizeH = $this->_defaultPageSizeH;
  148. $this->_borderTopSize = null;
  149. $this->_borderTopColor = null;
  150. $this->_borderLeftSize = null;
  151. $this->_borderLeftColor = null;
  152. $this->_borderRightSize = null;
  153. $this->_borderRightColor = null;
  154. $this->_borderBottomSize = null;
  155. $this->_borderBottomColor = null;
  156. }
  157. /**
  158. * Set Setting Value
  159. *
  160. * @param string $key
  161. * @param string $value
  162. */
  163. public function setSettingValue($key, $value) {
  164. if($key == '_orientation' && $value == 'landscape') {
  165. $this->setLandscape();
  166. } elseif($key == '_orientation' && is_null($value)) {
  167. $this->setPortrait();
  168. } elseif($key == '_borderSize') {
  169. $this->setBorderSize($value);
  170. } elseif($key == '_borderColor') {
  171. $this->setBorderColor($value);
  172. } else {
  173. $this->$key = $value;
  174. }
  175. }
  176. /**
  177. * Get Margin Top
  178. *
  179. * @return int
  180. */
  181. public function getMarginTop() {
  182. return $this->_marginTop;
  183. }
  184. /**
  185. * Set Margin Top
  186. *
  187. * @param int $pValue
  188. */
  189. public function setMarginTop($pValue = '') {
  190. $this->_marginTop = $pValue;
  191. return $this;
  192. }
  193. /**
  194. * Get Margin Left
  195. *
  196. * @return int
  197. */
  198. public function getMarginLeft() {
  199. return $this->_marginLeft;
  200. }
  201. /**
  202. * Set Margin Left
  203. *
  204. * @param int $pValue
  205. */
  206. public function setMarginLeft($pValue = '') {
  207. $this->_marginLeft = $pValue;
  208. return $this;
  209. }
  210. /**
  211. * Get Margin Right
  212. *
  213. * @return int
  214. */
  215. public function getMarginRight() {
  216. return $this->_marginRight;
  217. }
  218. /**
  219. * Set Margin Right
  220. *
  221. * @param int $pValue
  222. */
  223. public function setMarginRight($pValue = '') {
  224. $this->_marginRight = $pValue;
  225. return $this;
  226. }
  227. /**
  228. * Get Margin Bottom
  229. *
  230. * @return int
  231. */
  232. public function getMarginBottom() {
  233. return $this->_marginBottom;
  234. }
  235. /**
  236. * Set Margin Bottom
  237. *
  238. * @param int $pValue
  239. */
  240. public function setMarginBottom($pValue = '') {
  241. $this->_marginBottom = $pValue;
  242. return $this;
  243. }
  244. /**
  245. * Set Landscape Orientation
  246. */
  247. public function setLandscape() {
  248. $this->_orientation = 'landscape';
  249. $this->_pageSizeW = $this->_defaultPageSizeH;
  250. $this->_pageSizeH = $this->_defaultPageSizeW;
  251. }
  252. /**
  253. * Set Portrait Orientation
  254. */
  255. public function setPortrait() {
  256. $this->_orientation = null;
  257. $this->_pageSizeW = $this->_defaultPageSizeW;
  258. $this->_pageSizeH = $this->_defaultPageSizeH;
  259. }
  260. /**
  261. * Get Page Size Width
  262. *
  263. * @return int
  264. */
  265. public function getPageSizeW() {
  266. return $this->_pageSizeW;
  267. }
  268. /**
  269. * Get Page Size Height
  270. *
  271. * @return int
  272. */
  273. public function getPageSizeH() {
  274. return $this->_pageSizeH;
  275. }
  276. /**
  277. * Get Page Orientation
  278. *
  279. * @return string
  280. */
  281. public function getOrientation() {
  282. return $this->_orientation;
  283. }
  284. /**
  285. * Set Border Size
  286. *
  287. * @param int $pValue
  288. */
  289. public function setBorderSize($pValue = null) {
  290. $this->_borderTopSize = $pValue;
  291. $this->_borderLeftSize = $pValue;
  292. $this->_borderRightSize = $pValue;
  293. $this->_borderBottomSize = $pValue;
  294. }
  295. /**
  296. * Get Border Size
  297. *
  298. * @return array
  299. */
  300. public function getBorderSize() {
  301. $t = $this->getBorderTopSize();
  302. $l = $this->getBorderLeftSize();
  303. $r = $this->getBorderRightSize();
  304. $b = $this->getBorderBottomSize();
  305. return array($t, $l, $r, $b);
  306. }
  307. /**
  308. * Set Border Color
  309. *
  310. * @param string $pValue
  311. */
  312. public function setBorderColor($pValue = null) {
  313. $this->_borderTopColor = $pValue;
  314. $this->_borderLeftColor = $pValue;
  315. $this->_borderRightColor = $pValue;
  316. $this->_borderBottomColor = $pValue;
  317. }
  318. /**
  319. * Get Border Color
  320. *
  321. * @return array
  322. */
  323. public function getBorderColor() {
  324. $t = $this->getBorderTopColor();
  325. $l = $this->getBorderLeftColor();
  326. $r = $this->getBorderRightColor();
  327. $b = $this->getBorderBottomColor();
  328. return array($t, $l, $r, $b);
  329. }
  330. /**
  331. * Set Border Top Size
  332. *
  333. * @param int $pValue
  334. */
  335. public function setBorderTopSize($pValue = null) {
  336. $this->_borderTopSize = $pValue;
  337. }
  338. /**
  339. * Get Border Top Size
  340. *
  341. * @return int
  342. */
  343. public function getBorderTopSize() {
  344. return $this->_borderTopSize;
  345. }
  346. /**
  347. * Set Border Top Color
  348. *
  349. * @param string $pValue
  350. */
  351. public function setBorderTopColor($pValue = null) {
  352. $this->_borderTopColor = $pValue;
  353. }
  354. /**
  355. * Get Border Top Color
  356. *
  357. * @return string
  358. */
  359. public function getBorderTopColor() {
  360. return $this->_borderTopColor;
  361. }
  362. /**
  363. * Set Border Left Size
  364. *
  365. * @param int $pValue
  366. */
  367. public function setBorderLeftSize($pValue = null) {
  368. $this->_borderLeftSize = $pValue;
  369. }
  370. /**
  371. * Get Border Left Size
  372. *
  373. * @return int
  374. */
  375. public function getBorderLeftSize() {
  376. return $this->_borderLeftSize;
  377. }
  378. /**
  379. * Set Border Left Color
  380. *
  381. * @param string $pValue
  382. */
  383. public function setBorderLeftColor($pValue = null) {
  384. $this->_borderLeftColor = $pValue;
  385. }
  386. /**
  387. * Get Border Left Color
  388. *
  389. * @return string
  390. */
  391. public function getBorderLeftColor() {
  392. return $this->_borderLeftColor;
  393. }
  394. /**
  395. * Set Border Right Size
  396. *
  397. * @param int $pValue
  398. */
  399. public function setBorderRightSize($pValue = null) {
  400. $this->_borderRightSize = $pValue;
  401. }
  402. /**
  403. * Get Border Right Size
  404. *
  405. * @return int
  406. */
  407. public function getBorderRightSize() {
  408. return $this->_borderRightSize;
  409. }
  410. /**
  411. * Set Border Right Color
  412. *
  413. * @param string $pValue
  414. */
  415. public function setBorderRightColor($pValue = null) {
  416. $this->_borderRightColor = $pValue;
  417. }
  418. /**
  419. * Get Border Right Color
  420. *
  421. * @return string
  422. */
  423. public function getBorderRightColor() {
  424. return $this->_borderRightColor;
  425. }
  426. /**
  427. * Set Border Bottom Size
  428. *
  429. * @param int $pValue
  430. */
  431. public function setBorderBottomSize($pValue = null) {
  432. $this->_borderBottomSize = $pValue;
  433. }
  434. /**
  435. * Get Border Bottom Size
  436. *
  437. * @return int
  438. */
  439. public function getBorderBottomSize() {
  440. return $this->_borderBottomSize;
  441. }
  442. /**
  443. * Set Border Bottom Color
  444. *
  445. * @param string $pValue
  446. */
  447. public function setBorderBottomColor($pValue = null) {
  448. $this->_borderBottomColor = $pValue;
  449. }
  450. /**
  451. * Get Border Bottom Color
  452. *
  453. * @return string
  454. */
  455. public function getBorderBottomColor() {
  456. return $this->_borderBottomColor;
  457. }
  458. }
  459. ?>