NumberingLevel.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @see https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2018 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Style;
  18. use PhpOffice\PhpWord\SimpleType\Jc;
  19. use PhpOffice\PhpWord\SimpleType\NumberFormat;
  20. /**
  21. * Numbering level definition
  22. *
  23. * @see http://www.schemacentral.com/sc/ooxml/e-w_lvl-1.html
  24. * @since 0.10.0
  25. */
  26. class NumberingLevel extends AbstractStyle
  27. {
  28. /**
  29. * Level number, 0 to 8 (total 9 levels)
  30. *
  31. * @var int
  32. */
  33. private $level = 0;
  34. /**
  35. * Starting value w:start
  36. *
  37. * @var int
  38. * @see http://www.schemacentral.com/sc/ooxml/e-w_start-1.html
  39. */
  40. private $start = 1;
  41. /**
  42. * Numbering format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat
  43. *
  44. * @var string
  45. * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_NumberFormat.html
  46. */
  47. private $format;
  48. /**
  49. * Restart numbering level symbol w:lvlRestart
  50. *
  51. * @var int
  52. * @see http://www.schemacentral.com/sc/ooxml/e-w_lvlRestart-1.html
  53. */
  54. private $restart;
  55. /**
  56. * Related paragraph style
  57. *
  58. * @var string
  59. * @see http://www.schemacentral.com/sc/ooxml/e-w_pStyle-2.html
  60. */
  61. private $pStyle;
  62. /**
  63. * Content between numbering symbol and paragraph text w:suff
  64. *
  65. * @var string tab|space|nothing
  66. * @see http://www.schemacentral.com/sc/ooxml/e-w_suff-1.html
  67. */
  68. private $suffix = 'tab';
  69. /**
  70. * Numbering level text e.g. %1 for nonbullet or bullet character
  71. *
  72. * @var string
  73. * @see http://www.schemacentral.com/sc/ooxml/e-w_lvlText-1.html
  74. */
  75. private $text;
  76. /**
  77. * Justification, w:lvlJc
  78. *
  79. * @var string, one of PhpOffice\PhpWord\SimpleType\Jc
  80. */
  81. private $alignment = '';
  82. /**
  83. * Left
  84. *
  85. * @var int
  86. */
  87. private $left;
  88. /**
  89. * Hanging
  90. *
  91. * @var int
  92. */
  93. private $hanging;
  94. /**
  95. * Tab position
  96. *
  97. * @var int
  98. */
  99. private $tabPos;
  100. /**
  101. * Font family
  102. *
  103. * @var string
  104. */
  105. private $font;
  106. /**
  107. * Hint default|eastAsia|cs
  108. *
  109. * @var string
  110. * @see http://www.schemacentral.com/sc/ooxml/a-w_hint-1.html
  111. */
  112. private $hint;
  113. /**
  114. * Get level
  115. *
  116. * @return int
  117. */
  118. public function getLevel()
  119. {
  120. return $this->level;
  121. }
  122. /**
  123. * Set level
  124. *
  125. * @param int $value
  126. * @return self
  127. */
  128. public function setLevel($value)
  129. {
  130. $this->level = $this->setIntVal($value, $this->level);
  131. return $this;
  132. }
  133. /**
  134. * Get start
  135. *
  136. * @return int
  137. */
  138. public function getStart()
  139. {
  140. return $this->start;
  141. }
  142. /**
  143. * Set start
  144. *
  145. * @param int $value
  146. * @return self
  147. */
  148. public function setStart($value)
  149. {
  150. $this->start = $this->setIntVal($value, $this->start);
  151. return $this;
  152. }
  153. /**
  154. * Get format
  155. *
  156. * @return string
  157. */
  158. public function getFormat()
  159. {
  160. return $this->format;
  161. }
  162. /**
  163. * Set format
  164. *
  165. * @param string $value
  166. * @return self
  167. */
  168. public function setFormat($value)
  169. {
  170. $this->format = $this->setEnumVal($value, NumberFormat::values(), $this->format);
  171. return $this;
  172. }
  173. /**
  174. * Get restart
  175. *
  176. * @return int
  177. */
  178. public function getRestart()
  179. {
  180. return $this->restart;
  181. }
  182. /**
  183. * Set restart
  184. *
  185. * @param int $value
  186. * @return self
  187. */
  188. public function setRestart($value)
  189. {
  190. $this->restart = $this->setIntVal($value, $this->restart);
  191. return $this;
  192. }
  193. /**
  194. * Get related paragraph style
  195. *
  196. * @return string
  197. */
  198. public function getPStyle()
  199. {
  200. return $this->pStyle;
  201. }
  202. /**
  203. * Set related paragraph style
  204. *
  205. * @param string $value
  206. * @return self
  207. */
  208. public function setPStyle($value)
  209. {
  210. $this->pStyle = $value;
  211. return $this;
  212. }
  213. /**
  214. * Get suffix
  215. *
  216. * @return string
  217. */
  218. public function getSuffix()
  219. {
  220. return $this->suffix;
  221. }
  222. /**
  223. * Set suffix
  224. *
  225. * @param string $value
  226. * @return self
  227. */
  228. public function setSuffix($value)
  229. {
  230. $enum = array('tab', 'space', 'nothing');
  231. $this->suffix = $this->setEnumVal($value, $enum, $this->suffix);
  232. return $this;
  233. }
  234. /**
  235. * Get text
  236. *
  237. * @return string
  238. */
  239. public function getText()
  240. {
  241. return $this->text;
  242. }
  243. /**
  244. * Set text
  245. *
  246. * @param string $value
  247. * @return self
  248. */
  249. public function setText($value)
  250. {
  251. $this->text = $value;
  252. return $this;
  253. }
  254. /**
  255. * @since 0.13.0
  256. *
  257. * @return string
  258. */
  259. public function getAlignment()
  260. {
  261. return $this->alignment;
  262. }
  263. /**
  264. * @since 0.13.0
  265. *
  266. * @param string $value
  267. *
  268. * @return self
  269. */
  270. public function setAlignment($value)
  271. {
  272. if (Jc::isValid($value)) {
  273. $this->alignment = $value;
  274. }
  275. return $this;
  276. }
  277. /**
  278. * @deprecated 0.13.0 Use the `getAlignment` method instead.
  279. *
  280. * @return string
  281. *
  282. * @codeCoverageIgnore
  283. */
  284. public function getAlign()
  285. {
  286. return $this->getAlignment();
  287. }
  288. /**
  289. * @deprecated 0.13.0 Use the `setAlignment` method instead.
  290. *
  291. * @param string $value
  292. *
  293. * @return self
  294. *
  295. * @codeCoverageIgnore
  296. */
  297. public function setAlign($value)
  298. {
  299. return $this->setAlignment($value);
  300. }
  301. /**
  302. * Get left
  303. *
  304. * @return int
  305. */
  306. public function getLeft()
  307. {
  308. return $this->left;
  309. }
  310. /**
  311. * Set left
  312. *
  313. * @param int $value
  314. * @return self
  315. */
  316. public function setLeft($value)
  317. {
  318. $this->left = $this->setIntVal($value, $this->left);
  319. return $this;
  320. }
  321. /**
  322. * Get hanging
  323. *
  324. * @return int
  325. */
  326. public function getHanging()
  327. {
  328. return $this->hanging;
  329. }
  330. /**
  331. * Set hanging
  332. *
  333. * @param int $value
  334. * @return self
  335. */
  336. public function setHanging($value)
  337. {
  338. $this->hanging = $this->setIntVal($value, $this->hanging);
  339. return $this;
  340. }
  341. /**
  342. * Get tab
  343. *
  344. * @return int
  345. */
  346. public function getTabPos()
  347. {
  348. return $this->tabPos;
  349. }
  350. /**
  351. * Set tab
  352. *
  353. * @param int $value
  354. * @return self
  355. */
  356. public function setTabPos($value)
  357. {
  358. $this->tabPos = $this->setIntVal($value, $this->tabPos);
  359. return $this;
  360. }
  361. /**
  362. * Get font
  363. *
  364. * @return string
  365. */
  366. public function getFont()
  367. {
  368. return $this->font;
  369. }
  370. /**
  371. * Set font
  372. *
  373. * @param string $value
  374. * @return self
  375. */
  376. public function setFont($value)
  377. {
  378. $this->font = $value;
  379. return $this;
  380. }
  381. /**
  382. * Get hint
  383. *
  384. * @return string
  385. */
  386. public function getHint()
  387. {
  388. return $this->hint;
  389. }
  390. /**
  391. * Set hint
  392. *
  393. * @param string $value
  394. * @return self
  395. */
  396. public function setHint($value = null)
  397. {
  398. $enum = array('default', 'eastAsia', 'cs');
  399. $this->hint = $this->setEnumVal($value, $enum, $this->hint);
  400. return $this;
  401. }
  402. }