Paragraph.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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_Paragraph
  29. *
  30. * @category PHPWord
  31. * @package PHPWord_Style
  32. * @copyright Copyright (c) 2011 PHPWord
  33. */
  34. class PHPWord_Style_Paragraph {
  35. /**
  36. * Paragraph alignment
  37. *
  38. * @var string
  39. */
  40. private $_align;
  41. /**
  42. * Space before Paragraph
  43. *
  44. * @var int
  45. */
  46. private $_spaceBefore;
  47. /**
  48. * Space after Paragraph
  49. *
  50. * @var int
  51. */
  52. private $_spaceAfter;
  53. /**
  54. * Spacing between breaks
  55. *
  56. * @var int
  57. */
  58. private $_spacing;
  59. /**
  60. * New Paragraph Style
  61. */
  62. public function __construct() {
  63. $this->_align = null;
  64. $this->_spaceBefore = null;
  65. $this->_spaceAfter = null;
  66. $this->_spacing = null;
  67. }
  68. /**
  69. * Set Style value
  70. *
  71. * @param string $key
  72. * @param mixed $value
  73. */
  74. public function setStyleValue($key, $value) {
  75. if($key == '_spacing') {
  76. $value += 240; // because line height of 1 matches 240 twips
  77. }
  78. $this->$key = $value;
  79. }
  80. /**
  81. * Get Paragraph Alignment
  82. *
  83. * @return string
  84. */
  85. public function getAlign() {
  86. return $this->_align;
  87. }
  88. /**
  89. * Set Paragraph Alignment
  90. *
  91. * @param string $pValue
  92. * @return PHPWord_Style_Paragraph
  93. */
  94. public function setAlign($pValue = null) {
  95. if(strtolower($pValue) == 'justify') {
  96. // justify becames both
  97. $pValue = 'both';
  98. }
  99. $this->_align = $pValue;
  100. return $this;
  101. }
  102. /**
  103. * Get Space before Paragraph
  104. *
  105. * @return string
  106. */
  107. public function getSpaceBefore() {
  108. return $this->_spaceBefore;
  109. }
  110. /**
  111. * Set Space before Paragraph
  112. *
  113. * @param int $pValue
  114. * @return PHPWord_Style_Paragraph
  115. */
  116. public function setSpaceBefore($pValue = null) {
  117. $this->_spaceBefore = $pValue;
  118. return $this;
  119. }
  120. /**
  121. * Get Space after Paragraph
  122. *
  123. * @return string
  124. */
  125. public function getSpaceAfter() {
  126. return $this->_spaceAfter;
  127. }
  128. /**
  129. * Set Space after Paragraph
  130. *
  131. * @param int $pValue
  132. * @return PHPWord_Style_Paragraph
  133. */
  134. public function setSpaceAfter($pValue = null) {
  135. $this->_spaceAfter = $pValue;
  136. return $this;
  137. }
  138. /**
  139. * Get Spacing between breaks
  140. *
  141. * @return int
  142. */
  143. public function getSpacing() {
  144. return $this->_spacing;
  145. }
  146. /**
  147. * Set Spacing between breaks
  148. *
  149. * @param int $pValue
  150. * @return PHPWord_Style_Paragraph
  151. */
  152. public function setSpacing($pValue = null) {
  153. $this->_spacing = $pValue;
  154. return $this;
  155. }
  156. }
  157. ?>