Numbering.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /**
  19. * Numbering style
  20. *
  21. * @see http://www.schemacentral.com/sc/ooxml/e-w_numbering.html
  22. * @see http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html
  23. * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
  24. * @since 0.10.0
  25. */
  26. class Numbering extends AbstractStyle
  27. {
  28. /**
  29. * Numbering definition instance ID
  30. *
  31. * @var int
  32. * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
  33. */
  34. private $numId;
  35. /**
  36. * Multilevel type singleLevel|multilevel|hybridMultilevel
  37. *
  38. * @var string
  39. * @see http://www.schemacentral.com/sc/ooxml/a-w_val-67.html
  40. */
  41. private $type;
  42. /**
  43. * Numbering levels
  44. *
  45. * @var NumberingLevel[]
  46. */
  47. private $levels = array();
  48. /**
  49. * Get Id
  50. *
  51. * @return int
  52. */
  53. public function getNumId()
  54. {
  55. return $this->numId;
  56. }
  57. /**
  58. * Set Id
  59. *
  60. * @param int $value
  61. * @return self
  62. */
  63. public function setNumId($value)
  64. {
  65. $this->numId = $this->setIntVal($value, $this->numId);
  66. return $this;
  67. }
  68. /**
  69. * Get multilevel type
  70. *
  71. * @return string
  72. */
  73. public function getType()
  74. {
  75. return $this->type;
  76. }
  77. /**
  78. * Set multilevel type
  79. *
  80. * @param string $value
  81. * @return self
  82. */
  83. public function setType($value)
  84. {
  85. $enum = array('singleLevel', 'multilevel', 'hybridMultilevel');
  86. $this->type = $this->setEnumVal($value, $enum, $this->type);
  87. return $this;
  88. }
  89. /**
  90. * Get levels
  91. *
  92. * @return NumberingLevel[]
  93. */
  94. public function getLevels()
  95. {
  96. return $this->levels;
  97. }
  98. /**
  99. * Set multilevel type
  100. *
  101. * @param array $values
  102. * @return self
  103. */
  104. public function setLevels($values)
  105. {
  106. if (is_array($values)) {
  107. foreach ($values as $key => $value) {
  108. $numberingLevel = new NumberingLevel();
  109. if (is_array($value)) {
  110. $numberingLevel->setStyleByArray($value);
  111. $numberingLevel->setLevel($key);
  112. }
  113. $this->levels[$key] = $numberingLevel;
  114. }
  115. }
  116. return $this;
  117. }
  118. }