TableFull.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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_Style_TableFull
  29. *
  30. * @category PHPWord
  31. * @package PHPWord_Style
  32. * @copyright Copyright (c) 2011 PHPWord
  33. */
  34. class PHPWord_Style_TableFull {
  35. /**
  36. * Style for first row
  37. *
  38. * @var PHPWord_Style_Table
  39. */
  40. private $_firstRow = null;
  41. /**
  42. * Cell Margin Top
  43. *
  44. * @var int
  45. */
  46. private $_cellMarginTop = null;
  47. /**
  48. * Cell Margin Left
  49. *
  50. * @var int
  51. */
  52. private $_cellMarginLeft = null;
  53. /**
  54. * Cell Margin Right
  55. *
  56. * @var int
  57. */
  58. private $_cellMarginRight = null;
  59. /**
  60. * Cell Margin Bottom
  61. *
  62. * @var int
  63. */
  64. private $_cellMarginBottom = null;
  65. /**
  66. * Background-Color
  67. *
  68. * @var string
  69. */
  70. private $_bgColor;
  71. /**
  72. * Border Top Size
  73. *
  74. * @var int
  75. */
  76. private $_borderTopSize;
  77. /**
  78. * Border Top Color
  79. *
  80. * @var string
  81. */
  82. private $_borderTopColor;
  83. /**
  84. * Border Left Size
  85. *
  86. * @var int
  87. */
  88. private $_borderLeftSize;
  89. /**
  90. * Border Left Color
  91. *
  92. * @var string
  93. */
  94. private $_borderLeftColor;
  95. /**
  96. * Border Right Size
  97. *
  98. * @var int
  99. */
  100. private $_borderRightSize;
  101. /**
  102. * Border Right Color
  103. *
  104. * @var string
  105. */
  106. private $_borderRightColor;
  107. /**
  108. * Border Bottom Size
  109. *
  110. * @var int
  111. */
  112. private $_borderBottomSize;
  113. /**
  114. * Border Bottom Color
  115. *
  116. * @var string
  117. */
  118. private $_borderBottomColor;
  119. /**
  120. * Border InsideH Size
  121. *
  122. * @var int
  123. */
  124. private $_borderInsideHSize;
  125. /**
  126. * Border InsideH Color
  127. *
  128. * @var string
  129. */
  130. private $_borderInsideHColor;
  131. /**
  132. * Border InsideV Size
  133. *
  134. * @var int
  135. */
  136. private $_borderInsideVSize;
  137. /**
  138. * Border InsideV Color
  139. *
  140. * @var string
  141. */
  142. private $_borderInsideVColor;
  143. // 表格居中属性,用法:表格style数组中:'tableAlign' => 'center'
  144. private $_tableAlign = NULL;
  145. // 表格缩进属性
  146. private $_tableIndent = NULL;
  147. /**
  148. * Create a new TableFull Font
  149. */
  150. public function __construct($styleTable = null, $styleFirstRow = null, $styleLastRow = null) {
  151. if(!is_null($styleFirstRow) && is_array($styleFirstRow)) {
  152. $this->_firstRow = clone $this;
  153. unset($this->_firstRow->_firstRow);
  154. unset($this->_firstRow->_cellMarginBottom);
  155. unset($this->_firstRow->_cellMarginTop);
  156. unset($this->_firstRow->_cellMarginLeft);
  157. unset($this->_firstRow->_cellMarginRight);
  158. unset($this->_firstRow->_borderInsideVColor);
  159. unset($this->_firstRow->_borderInsideVSize);
  160. unset($this->_firstRow->_borderInsideHColor);
  161. unset($this->_firstRow->_borderInsideHSize);
  162. unset($this->_firstRow->_tableAlign);
  163. unset($this->_firstRow->_tableIndent);
  164. foreach($styleFirstRow as $key => $value) {
  165. if(substr($key, 0, 1) != '_') {
  166. $key = '_'.$key;
  167. }
  168. $this->_firstRow->setStyleValue($key, $value);
  169. }
  170. }
  171. if(!is_null($styleTable) && is_array($styleTable)) {
  172. foreach($styleTable as $key => $value) {
  173. if(substr($key, 0, 1) != '_') {
  174. $key = '_'.$key;
  175. }
  176. $this->setStyleValue($key, $value);
  177. }
  178. }
  179. }
  180. public function setTableAlign($pValue = NULL)
  181. {
  182. $this->_tableAlign = $pValue;
  183. }
  184. public function getTableAlign()
  185. {
  186. return $this->_tableAlign;
  187. }
  188. public function setTableIndent($pValue = NULL)
  189. {
  190. $this->_tableIndent = $pValue;
  191. }
  192. public function getTableIndent()
  193. {
  194. return $this->_tableIndent;
  195. }
  196. /**
  197. * Set style value
  198. *
  199. * @param string $key
  200. * @param mixed $value
  201. */
  202. public function setStyleValue($key, $value) {
  203. if($key == '_borderSize') {
  204. $this->setBorderSize($value);
  205. } elseif($key == '_borderColor') {
  206. $this->setBorderColor($value);
  207. } elseif($key == '_cellMargin') {
  208. $this->setCellMargin($value);
  209. } else {
  210. $this->$key = $value;
  211. }
  212. }
  213. /**
  214. * Get First Row Style
  215. *
  216. * @return PHPWord_Style_TableFull
  217. */
  218. public function getFirstRow() {
  219. return $this->_firstRow;
  220. }
  221. /**
  222. * Get Last Row Style
  223. *
  224. * @return PHPWord_Style_TableFull
  225. */
  226. public function getLastRow() {
  227. return $this->_lastRow;
  228. }
  229. public function getBgColor() {
  230. return $this->_bgColor;
  231. }
  232. public function setBgColor($pValue = null) {
  233. $this->_bgColor = $pValue;
  234. }
  235. /**
  236. * Set TLRBVH Border Size
  237. *
  238. * @param int $pValue
  239. */
  240. public function setBorderSize($pValue = null) {
  241. $this->_borderTopSize = $pValue;
  242. $this->_borderLeftSize = $pValue;
  243. $this->_borderRightSize = $pValue;
  244. $this->_borderBottomSize = $pValue;
  245. $this->_borderInsideHSize = $pValue;
  246. $this->_borderInsideVSize = $pValue;
  247. }
  248. /**
  249. * Get TLRBVH Border Size
  250. *
  251. * @return array
  252. */
  253. public function getBorderSize() {
  254. $t = $this->getBorderTopSize();
  255. $l = $this->getBorderLeftSize();
  256. $r = $this->getBorderRightSize();
  257. $b = $this->getBorderBottomSize();
  258. $h = $this->getBorderInsideHSize();
  259. $v = $this->getBorderInsideVSize();
  260. return array($t, $l, $r, $b, $h, $v);
  261. }
  262. /**
  263. * Set TLRBVH Border Color
  264. */
  265. public function setBorderColor($pValue = null) {
  266. $this->_borderTopColor = $pValue;
  267. $this->_borderLeftColor = $pValue;
  268. $this->_borderRightColor = $pValue;
  269. $this->_borderBottomColor = $pValue;
  270. $this->_borderInsideHColor = $pValue;
  271. $this->_borderInsideVColor = $pValue;
  272. }
  273. /**
  274. * Get TLRB Border Color
  275. *
  276. * @return array
  277. */
  278. public function getBorderColor() {
  279. $t = $this->getBorderTopColor();
  280. $l = $this->getBorderLeftColor();
  281. $r = $this->getBorderRightColor();
  282. $b = $this->getBorderBottomColor();
  283. $h = $this->getBorderInsideHColor();
  284. $v = $this->getBorderInsideVColor();
  285. return array($t, $l, $r, $b, $h, $v);
  286. }
  287. public function setBorderTopSize($pValue = null) {
  288. $this->_borderTopSize = $pValue;
  289. }
  290. public function getBorderTopSize() {
  291. return $this->_borderTopSize;
  292. }
  293. public function setBorderTopColor($pValue = null) {
  294. $this->_borderTopColor = $pValue;
  295. }
  296. public function getBorderTopColor() {
  297. return $this->_borderTopColor;
  298. }
  299. public function setBorderLeftSize($pValue = null) {
  300. $this->_borderLeftSize = $pValue;
  301. }
  302. public function getBorderLeftSize() {
  303. return $this->_borderLeftSize;
  304. }
  305. public function setBorderLeftColor($pValue = null) {
  306. $this->_borderLeftColor = $pValue;
  307. }
  308. public function getBorderLeftColor() {
  309. return $this->_borderLeftColor;
  310. }
  311. public function setBorderRightSize($pValue = null) {
  312. $this->_borderRightSize = $pValue;
  313. }
  314. public function getBorderRightSize() {
  315. return $this->_borderRightSize;
  316. }
  317. public function setBorderRightColor($pValue = null) {
  318. $this->_borderRightColor = $pValue;
  319. }
  320. public function getBorderRightColor() {
  321. return $this->_borderRightColor;
  322. }
  323. public function setBorderBottomSize($pValue = null) {
  324. $this->_borderBottomSize = $pValue;
  325. }
  326. public function getBorderBottomSize() {
  327. return $this->_borderBottomSize;
  328. }
  329. public function setBorderBottomColor($pValue = null) {
  330. $this->_borderBottomColor = $pValue;
  331. }
  332. public function getBorderBottomColor() {
  333. return $this->_borderBottomColor;
  334. }
  335. public function setBorderInsideHColor($pValue = null) {
  336. $this->_borderInsideHColor = $pValue;
  337. }
  338. public function getBorderInsideHColor() {
  339. return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
  340. }
  341. public function setBorderInsideVColor($pValue = null) {
  342. $this->_borderInsideVColor = $pValue;
  343. }
  344. public function getBorderInsideVColor() {
  345. return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
  346. }
  347. public function setBorderInsideHSize($pValue = null) {
  348. $this->_borderInsideHSize = $pValue;
  349. }
  350. public function getBorderInsideHSize() {
  351. return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
  352. }
  353. public function setBorderInsideVSize($pValue = null) {
  354. $this->_borderInsideVSize = $pValue;
  355. }
  356. public function getBorderInsideVSize() {
  357. return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
  358. }
  359. public function setCellMarginTop($pValue = null) {
  360. $this->_cellMarginTop = $pValue;
  361. }
  362. public function getCellMarginTop() {
  363. return $this->_cellMarginTop;
  364. }
  365. public function setCellMarginLeft($pValue = null) {
  366. $this->_cellMarginLeft = $pValue;
  367. }
  368. public function getCellMarginLeft() {
  369. return $this->_cellMarginLeft;
  370. }
  371. public function setCellMarginRight($pValue = null) {
  372. $this->_cellMarginRight = $pValue;
  373. }
  374. public function getCellMarginRight() {
  375. return $this->_cellMarginRight;
  376. }
  377. public function setCellMarginBottom($pValue = null) {
  378. $this->_cellMarginBottom = $pValue;
  379. }
  380. public function getCellMarginBottom() {
  381. return $this->_cellMarginBottom;
  382. }
  383. public function setCellMargin($pValue = null) {
  384. $this->_cellMarginTop = $pValue;
  385. $this->_cellMarginLeft = $pValue;
  386. $this->_cellMarginRight = $pValue;
  387. $this->_cellMarginBottom = $pValue;
  388. }
  389. public function getCellMargin() {
  390. return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);
  391. }
  392. }
  393. ?>