Image.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. * Image and memory image style
  20. */
  21. class Image extends Frame
  22. {
  23. /**
  24. * Backward compatibility constants
  25. *
  26. * @const string
  27. */
  28. const WRAPPING_STYLE_INLINE = self::WRAP_INLINE;
  29. const WRAPPING_STYLE_SQUARE = self::WRAP_SQUARE;
  30. const WRAPPING_STYLE_TIGHT = self::WRAP_TIGHT;
  31. const WRAPPING_STYLE_BEHIND = self::WRAP_BEHIND;
  32. const WRAPPING_STYLE_INFRONT = self::WRAP_INFRONT;
  33. const POSITION_HORIZONTAL_LEFT = self::POS_LEFT;
  34. const POSITION_HORIZONTAL_CENTER = self::POS_CENTER;
  35. const POSITION_HORIZONTAL_RIGHT = self::POS_RIGHT;
  36. const POSITION_VERTICAL_TOP = self::POS_TOP;
  37. const POSITION_VERTICAL_CENTER = self::POS_CENTER;
  38. const POSITION_VERTICAL_BOTTOM = self::POS_BOTTOM;
  39. const POSITION_VERTICAL_INSIDE = self::POS_INSIDE;
  40. const POSITION_VERTICAL_OUTSIDE = self::POS_OUTSIDE;
  41. const POSITION_RELATIVE_TO_MARGIN = self::POS_RELTO_MARGIN;
  42. const POSITION_RELATIVE_TO_PAGE = self::POS_RELTO_PAGE;
  43. const POSITION_RELATIVE_TO_COLUMN = self::POS_RELTO_COLUMN;
  44. const POSITION_RELATIVE_TO_CHAR = self::POS_RELTO_CHAR;
  45. const POSITION_RELATIVE_TO_TEXT = self::POS_RELTO_TEXT;
  46. const POSITION_RELATIVE_TO_LINE = self::POS_RELTO_LINE;
  47. const POSITION_RELATIVE_TO_LMARGIN = self::POS_RELTO_LMARGIN;
  48. const POSITION_RELATIVE_TO_RMARGIN = self::POS_RELTO_RMARGIN;
  49. const POSITION_RELATIVE_TO_TMARGIN = self::POS_RELTO_TMARGIN;
  50. const POSITION_RELATIVE_TO_BMARGIN = self::POS_RELTO_BMARGIN;
  51. const POSITION_RELATIVE_TO_IMARGIN = self::POS_RELTO_IMARGIN;
  52. const POSITION_RELATIVE_TO_OMARGIN = self::POS_RELTO_OMARGIN;
  53. const POSITION_ABSOLUTE = self::POS_ABSOLUTE;
  54. const POSITION_RELATIVE = self::POS_RELATIVE;
  55. /**
  56. * Create new instance
  57. */
  58. public function __construct()
  59. {
  60. parent::__construct();
  61. $this->setUnit(self::UNIT_PT);
  62. // Backward compatibility setting
  63. // @todo Remove on 1.0.0
  64. $this->setWrap(self::WRAPPING_STYLE_INLINE);
  65. $this->setHPos(self::POSITION_HORIZONTAL_LEFT);
  66. $this->setHPosRelTo(self::POSITION_RELATIVE_TO_CHAR);
  67. $this->setVPos(self::POSITION_VERTICAL_TOP);
  68. $this->setVPosRelTo(self::POSITION_RELATIVE_TO_LINE);
  69. }
  70. /**
  71. * Get margin top
  72. *
  73. * @return int|float
  74. */
  75. public function getMarginTop()
  76. {
  77. return $this->getTop();
  78. }
  79. /**
  80. * Set margin top
  81. *
  82. * @ignoreScrutinizerPatch
  83. * @param int|float $value
  84. * @return self
  85. */
  86. public function setMarginTop($value = 0)
  87. {
  88. $this->setTop($value);
  89. return $this;
  90. }
  91. /**
  92. * Get margin left
  93. *
  94. * @return int|float
  95. */
  96. public function getMarginLeft()
  97. {
  98. return $this->getLeft();
  99. }
  100. /**
  101. * Set margin left
  102. *
  103. * @ignoreScrutinizerPatch
  104. * @param int|float $value
  105. * @return self
  106. */
  107. public function setMarginLeft($value = 0)
  108. {
  109. $this->setLeft($value);
  110. return $this;
  111. }
  112. /**
  113. * Get wrapping style
  114. *
  115. * @return string
  116. */
  117. public function getWrappingStyle()
  118. {
  119. return $this->getWrap();
  120. }
  121. /**
  122. * Set wrapping style
  123. *
  124. * @param string $wrappingStyle
  125. *
  126. * @throws \InvalidArgumentException
  127. *
  128. * @return self
  129. */
  130. public function setWrappingStyle($wrappingStyle)
  131. {
  132. $this->setWrap($wrappingStyle);
  133. return $this;
  134. }
  135. /**
  136. * Get positioning type
  137. *
  138. * @return string
  139. */
  140. public function getPositioning()
  141. {
  142. return $this->getPos();
  143. }
  144. /**
  145. * Set positioning type
  146. *
  147. * @param string $positioning
  148. *
  149. * @throws \InvalidArgumentException
  150. *
  151. * @return self
  152. */
  153. public function setPositioning($positioning)
  154. {
  155. $this->setPos($positioning);
  156. return $this;
  157. }
  158. /**
  159. * Get horizontal alignment
  160. *
  161. * @return string
  162. */
  163. public function getPosHorizontal()
  164. {
  165. return $this->getHPos();
  166. }
  167. /**
  168. * Set horizontal alignment
  169. *
  170. * @param string $alignment
  171. *
  172. * @throws \InvalidArgumentException
  173. *
  174. * @return self
  175. */
  176. public function setPosHorizontal($alignment)
  177. {
  178. $this->setHPos($alignment);
  179. return $this;
  180. }
  181. /**
  182. * Get vertical alignment
  183. *
  184. * @return string
  185. */
  186. public function getPosVertical()
  187. {
  188. return $this->getVPos();
  189. }
  190. /**
  191. * Set vertical alignment
  192. *
  193. * @param string $alignment
  194. *
  195. * @throws \InvalidArgumentException
  196. *
  197. * @return self
  198. */
  199. public function setPosVertical($alignment)
  200. {
  201. $this->setVPos($alignment);
  202. return $this;
  203. }
  204. /**
  205. * Get horizontal relation
  206. *
  207. * @return string
  208. */
  209. public function getPosHorizontalRel()
  210. {
  211. return $this->getHPosRelTo();
  212. }
  213. /**
  214. * Set horizontal relation
  215. *
  216. * @param string $relto
  217. *
  218. * @throws \InvalidArgumentException
  219. *
  220. * @return self
  221. */
  222. public function setPosHorizontalRel($relto)
  223. {
  224. $this->setHPosRelTo($relto);
  225. return $this;
  226. }
  227. /**
  228. * Get vertical relation
  229. *
  230. * @return string
  231. */
  232. public function getPosVerticalRel()
  233. {
  234. return $this->getVPosRelTo();
  235. }
  236. /**
  237. * Set vertical relation
  238. *
  239. * @param string $relto
  240. *
  241. * @throws \InvalidArgumentException
  242. *
  243. * @return self
  244. */
  245. public function setPosVerticalRel($relto)
  246. {
  247. $this->setVPosRelTo($relto);
  248. return $this;
  249. }
  250. }