Spacing.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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\LineSpacingRule;
  19. /**
  20. * Spacing between lines and above/below paragraph style
  21. *
  22. * @see http://www.datypic.com/sc/ooxml/t-w_CT_Spacing.html
  23. * @since 0.10.0
  24. */
  25. class Spacing extends AbstractStyle
  26. {
  27. /**
  28. * Spacing above paragraph (twip)
  29. *
  30. * @var int|float
  31. */
  32. private $before;
  33. /**
  34. * Spacing below paragraph (twip)
  35. *
  36. * @var int|float
  37. */
  38. private $after;
  39. /**
  40. * Spacing between lines in paragraph (twip)
  41. *
  42. * @var int|float
  43. */
  44. private $line;
  45. /**
  46. * Type of spacing between lines
  47. *
  48. * @var string
  49. */
  50. private $lineRule = LineSpacingRule::AUTO;
  51. /**
  52. * Create a new instance
  53. *
  54. * @param array $style
  55. */
  56. public function __construct($style = array())
  57. {
  58. $this->setStyleByArray($style);
  59. }
  60. /**
  61. * Get before
  62. *
  63. * @return int|float
  64. */
  65. public function getBefore()
  66. {
  67. return $this->before;
  68. }
  69. /**
  70. * Set before
  71. *
  72. * @param int|float $value
  73. * @return self
  74. */
  75. public function setBefore($value = null)
  76. {
  77. $this->before = $this->setNumericVal($value, $this->before);
  78. return $this;
  79. }
  80. /**
  81. * Get after
  82. *
  83. * @return int|float
  84. */
  85. public function getAfter()
  86. {
  87. return $this->after;
  88. }
  89. /**
  90. * Set after
  91. *
  92. * @param int|float $value
  93. * @return self
  94. */
  95. public function setAfter($value = null)
  96. {
  97. $this->after = $this->setNumericVal($value, $this->after);
  98. return $this;
  99. }
  100. /**
  101. * Get line
  102. *
  103. * @return int|float
  104. */
  105. public function getLine()
  106. {
  107. return $this->line;
  108. }
  109. /**
  110. * Set distance
  111. *
  112. * @param int|float $value
  113. * @return self
  114. */
  115. public function setLine($value = null)
  116. {
  117. $this->line = $this->setNumericVal($value, $this->line);
  118. return $this;
  119. }
  120. /**
  121. * Get line rule
  122. *
  123. * @return string
  124. */
  125. public function getLineRule()
  126. {
  127. return $this->lineRule;
  128. }
  129. /**
  130. * Set line rule
  131. *
  132. * @param string $value
  133. * @return self
  134. */
  135. public function setLineRule($value = null)
  136. {
  137. LineSpacingRule::validate($value);
  138. $this->lineRule = $value;
  139. return $this;
  140. }
  141. /**
  142. * Get line rule
  143. *
  144. * @return string
  145. * @deprecated Use getLineRule() instead
  146. * @codeCoverageIgnore
  147. */
  148. public function getRule()
  149. {
  150. return $this->lineRule;
  151. }
  152. /**
  153. * Set line rule
  154. *
  155. * @param string $value
  156. * @return self
  157. * @deprecated Use setLineRule() instead
  158. * @codeCoverageIgnore
  159. */
  160. public function setRule($value = null)
  161. {
  162. $this->lineRule = $value;
  163. return $this;
  164. }
  165. }