LineNumbering.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. * Line numbering style
  20. *
  21. * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_LineNumber.html
  22. * @since 0.10.0
  23. */
  24. class LineNumbering extends AbstractStyle
  25. {
  26. /** @const string Line numbering restart setting http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html */
  27. const LINE_NUMBERING_CONTINUOUS = 'continuous';
  28. const LINE_NUMBERING_NEW_PAGE = 'newPage';
  29. const LINE_NUMBERING_NEW_SECTION = 'newSection';
  30. /**
  31. * Line numbering starting value
  32. *
  33. * @var int
  34. */
  35. private $start = 1;
  36. /**
  37. * Line number increments
  38. *
  39. * @var int
  40. */
  41. private $increment = 1;
  42. /**
  43. * Distance between text and line numbering in twip
  44. *
  45. * @var int|float
  46. */
  47. private $distance;
  48. /**
  49. * Line numbering restart setting continuous|newPage|newSection
  50. *
  51. * @var string
  52. * @see http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html
  53. */
  54. private $restart;
  55. /**
  56. * Create a new instance
  57. *
  58. * @param array $style
  59. */
  60. public function __construct($style = array())
  61. {
  62. $this->setStyleByArray($style);
  63. }
  64. /**
  65. * Get start
  66. *
  67. * @return int
  68. */
  69. public function getStart()
  70. {
  71. return $this->start;
  72. }
  73. /**
  74. * Set start
  75. *
  76. * @param int $value
  77. * @return self
  78. */
  79. public function setStart($value = null)
  80. {
  81. $this->start = $this->setIntVal($value, $this->start);
  82. return $this;
  83. }
  84. /**
  85. * Get increment
  86. *
  87. * @return int
  88. */
  89. public function getIncrement()
  90. {
  91. return $this->increment;
  92. }
  93. /**
  94. * Set increment
  95. *
  96. * @param int $value
  97. * @return self
  98. */
  99. public function setIncrement($value = null)
  100. {
  101. $this->increment = $this->setIntVal($value, $this->increment);
  102. return $this;
  103. }
  104. /**
  105. * Get distance
  106. *
  107. * @return int|float
  108. */
  109. public function getDistance()
  110. {
  111. return $this->distance;
  112. }
  113. /**
  114. * Set distance
  115. *
  116. * @param int|float $value
  117. * @return self
  118. */
  119. public function setDistance($value = null)
  120. {
  121. $this->distance = $this->setNumericVal($value, $this->distance);
  122. return $this;
  123. }
  124. /**
  125. * Get restart
  126. *
  127. * @return string
  128. */
  129. public function getRestart()
  130. {
  131. return $this->restart;
  132. }
  133. /**
  134. * Set distance
  135. *
  136. * @param string $value
  137. * @return self
  138. */
  139. public function setRestart($value = null)
  140. {
  141. $enum = array(self::LINE_NUMBERING_CONTINUOUS, self::LINE_NUMBERING_NEW_PAGE, self::LINE_NUMBERING_NEW_SECTION);
  142. $this->restart = $this->setEnumVal($value, $enum, $this->restart);
  143. return $this;
  144. }
  145. }