Outline.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. * Outline defines the line/border of the object
  20. *
  21. * @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Stroke.html
  22. * @see http://www.w3.org/TR/1998/NOTE-VML-19980513#_Toc416858395
  23. * @since 0.12.0
  24. */
  25. class Outline extends AbstractStyle
  26. {
  27. /**
  28. * Line style constants
  29. *
  30. * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeLineStyle.html
  31. * @const string
  32. */
  33. const LINE_SINGLE = 'single';
  34. const LINE_THIN_THIN = 'thinThin';
  35. const LINE_THIN_THICK = 'thinThick';
  36. const LINE_THICK_THIN = 'thickThin';
  37. const LINE_THICK_BETWEEN_THIN = 'thickBetweenThin';
  38. /**
  39. * Line style constants
  40. *
  41. * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
  42. * @const string
  43. */
  44. const ENDCAP_FLAT = 'flat';
  45. const ENDCAP_SQUARE = 'square';
  46. const ENDCAP_ROUND = 'round';
  47. /**
  48. * Arrowhead type constants
  49. *
  50. * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeArrowType.html
  51. * @const string
  52. */
  53. const ARROW_NONE = 'none';
  54. const ARROW_BLOCK = 'block';
  55. const ARROW_CLASSIC = 'classic';
  56. const ARROW_OVAL = 'oval';
  57. const ARROW_DIAMOND = 'diamond';
  58. const ARROW_OPEN = 'open';
  59. /**
  60. * Unit; No set method for now
  61. *
  62. * @var string
  63. */
  64. private $unit = 'pt';
  65. /**
  66. * Outline weight
  67. *
  68. * @var int|float
  69. */
  70. private $weight;
  71. /**
  72. * Outline color
  73. *
  74. * @var string
  75. */
  76. private $color;
  77. /**
  78. * Dash type
  79. *
  80. * @var string
  81. */
  82. private $dash;
  83. /**
  84. * Line style
  85. *
  86. * @var string
  87. */
  88. private $line;
  89. /**
  90. * End cap
  91. *
  92. * @var string
  93. * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
  94. */
  95. private $endCap;
  96. /**
  97. * Start arrow type
  98. *
  99. * @var string
  100. */
  101. private $startArrow;
  102. /**
  103. * End arrow type
  104. *
  105. * @var string
  106. */
  107. private $endArrow;
  108. /**
  109. * Create a new instance
  110. *
  111. * @param array $style
  112. */
  113. public function __construct($style = array())
  114. {
  115. $this->setStyleByArray($style);
  116. }
  117. /**
  118. * Get unit
  119. *
  120. * @return string
  121. */
  122. public function getUnit()
  123. {
  124. return $this->unit;
  125. }
  126. /**
  127. * Get weight
  128. *
  129. * @return int|float
  130. */
  131. public function getWeight()
  132. {
  133. return $this->weight;
  134. }
  135. /**
  136. * Set weight
  137. *
  138. * @param int|float $value
  139. * @return self
  140. */
  141. public function setWeight($value = null)
  142. {
  143. $this->weight = $this->setNumericVal($value, null);
  144. return $this;
  145. }
  146. /**
  147. * Get color
  148. *
  149. * @return string
  150. */
  151. public function getColor()
  152. {
  153. return $this->color;
  154. }
  155. /**
  156. * Set color
  157. *
  158. * @param string $value
  159. * @return self
  160. */
  161. public function setColor($value = null)
  162. {
  163. $this->color = $value;
  164. return $this;
  165. }
  166. /**
  167. * Get dash type
  168. *
  169. * @return string
  170. */
  171. public function getDash()
  172. {
  173. return $this->dash;
  174. }
  175. /**
  176. * Set dash type
  177. *
  178. * @param string $value
  179. * @return self
  180. */
  181. public function setDash($value = null)
  182. {
  183. $this->dash = $value;
  184. return $this;
  185. }
  186. /**
  187. * Get line style
  188. *
  189. * @return string
  190. */
  191. public function getLine()
  192. {
  193. return $this->line;
  194. }
  195. /**
  196. * Set line style
  197. *
  198. * @param string $value
  199. * @return self
  200. */
  201. public function setLine($value = null)
  202. {
  203. $enum = array(self::LINE_SINGLE, self::LINE_THIN_THIN, self::LINE_THIN_THICK,
  204. self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN, );
  205. $this->line = $this->setEnumVal($value, $enum, null);
  206. return $this;
  207. }
  208. /**
  209. * Get endCap style
  210. *
  211. * @return string
  212. */
  213. public function getEndCap()
  214. {
  215. return $this->endCap;
  216. }
  217. /**
  218. * Set endCap style
  219. *
  220. * @param string $value
  221. * @return self
  222. */
  223. public function setEndCap($value = null)
  224. {
  225. $enum = array(self::ENDCAP_FLAT, self::ENDCAP_SQUARE, self::ENDCAP_ROUND);
  226. $this->endCap = $this->setEnumVal($value, $enum, null);
  227. return $this;
  228. }
  229. /**
  230. * Get startArrow
  231. *
  232. * @return string
  233. */
  234. public function getStartArrow()
  235. {
  236. return $this->startArrow;
  237. }
  238. /**
  239. * Set pattern
  240. *
  241. * @param string $value
  242. * @return self
  243. */
  244. public function setStartArrow($value = null)
  245. {
  246. $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
  247. self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
  248. $this->startArrow = $this->setEnumVal($value, $enum, null);
  249. return $this;
  250. }
  251. /**
  252. * Get endArrow
  253. *
  254. * @return string
  255. */
  256. public function getEndArrow()
  257. {
  258. return $this->endArrow;
  259. }
  260. /**
  261. * Set pattern
  262. *
  263. * @param string $value
  264. * @return self
  265. */
  266. public function setEndArrow($value = null)
  267. {
  268. $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
  269. self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
  270. $this->endArrow = $this->setEnumVal($value, $enum, null);
  271. return $this;
  272. }
  273. }