TextBox.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. * TextBox style
  20. *
  21. * @since 0.11.0
  22. */
  23. class TextBox extends Image
  24. {
  25. /**
  26. * margin top
  27. *
  28. * @var int
  29. */
  30. private $innerMarginTop = null;
  31. /**
  32. * margin left
  33. *
  34. * @var int
  35. */
  36. private $innerMarginLeft = null;
  37. /**
  38. * margin right
  39. *
  40. * @var int
  41. */
  42. private $innerMarginRight = null;
  43. /**
  44. * Cell margin bottom
  45. *
  46. * @var int
  47. */
  48. private $innerMarginBottom = null;
  49. /**
  50. * border size
  51. *
  52. * @var int
  53. */
  54. private $borderSize = null;
  55. /**
  56. * border color
  57. *
  58. * @var string
  59. */
  60. private $borderColor;
  61. /**
  62. * Set margin top.
  63. *
  64. * @param int $value
  65. */
  66. public function setInnerMarginTop($value = null)
  67. {
  68. $this->innerMarginTop = $value;
  69. }
  70. /**
  71. * Get margin top
  72. *
  73. * @return int
  74. */
  75. public function getInnerMarginTop()
  76. {
  77. return $this->innerMarginTop;
  78. }
  79. /**
  80. * Set margin left.
  81. *
  82. * @param int $value
  83. */
  84. public function setInnerMarginLeft($value = null)
  85. {
  86. $this->innerMarginLeft = $value;
  87. }
  88. /**
  89. * Get margin left
  90. *
  91. * @return int
  92. */
  93. public function getInnerMarginLeft()
  94. {
  95. return $this->innerMarginLeft;
  96. }
  97. /**
  98. * Set margin right.
  99. *
  100. * @param int $value
  101. */
  102. public function setInnerMarginRight($value = null)
  103. {
  104. $this->innerMarginRight = $value;
  105. }
  106. /**
  107. * Get margin right
  108. *
  109. * @return int
  110. */
  111. public function getInnerMarginRight()
  112. {
  113. return $this->innerMarginRight;
  114. }
  115. /**
  116. * Set margin bottom.
  117. *
  118. * @param int $value
  119. */
  120. public function setInnerMarginBottom($value = null)
  121. {
  122. $this->innerMarginBottom = $value;
  123. }
  124. /**
  125. * Get margin bottom
  126. *
  127. * @return int
  128. */
  129. public function getInnerMarginBottom()
  130. {
  131. return $this->innerMarginBottom;
  132. }
  133. /**
  134. * Set TLRB cell margin.
  135. *
  136. * @param int $value Margin in twips
  137. */
  138. public function setInnerMargin($value = null)
  139. {
  140. $this->setInnerMarginTop($value);
  141. $this->setInnerMarginLeft($value);
  142. $this->setInnerMarginRight($value);
  143. $this->setInnerMarginBottom($value);
  144. }
  145. /**
  146. * Get cell margin
  147. *
  148. * @return int[]
  149. */
  150. public function getInnerMargin()
  151. {
  152. return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom);
  153. }
  154. /**
  155. * Has inner margin?
  156. *
  157. * @return bool
  158. */
  159. public function hasInnerMargins()
  160. {
  161. $hasInnerMargins = false;
  162. $margins = $this->getInnerMargin();
  163. $numMargins = count($margins);
  164. for ($i = 0; $i < $numMargins; $i++) {
  165. if ($margins[$i] !== null) {
  166. $hasInnerMargins = true;
  167. }
  168. }
  169. return $hasInnerMargins;
  170. }
  171. /**
  172. * Set border size.
  173. *
  174. * @param int $value Size in points
  175. */
  176. public function setBorderSize($value = null)
  177. {
  178. $this->borderSize = $value;
  179. }
  180. /**
  181. * Get border size
  182. *
  183. * @return int
  184. */
  185. public function getBorderSize()
  186. {
  187. return $this->borderSize;
  188. }
  189. /**
  190. * Set border color.
  191. *
  192. * @param string $value
  193. */
  194. public function setBorderColor($value = null)
  195. {
  196. $this->borderColor = $value;
  197. }
  198. /**
  199. * Get border color
  200. *
  201. * @return string
  202. */
  203. public function getBorderColor()
  204. {
  205. return $this->borderColor;
  206. }
  207. }