No Description

Image.php 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 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('px');
  62. // Backward compatilibity 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. * @throws \InvalidArgumentException
  126. * @return self
  127. */
  128. public function setWrappingStyle($wrappingStyle)
  129. {
  130. $this->setWrap($wrappingStyle);
  131. return $this;
  132. }
  133. /**
  134. * Get positioning type
  135. *
  136. * @return string
  137. */
  138. public function getPositioning()
  139. {
  140. return $this->getPos();
  141. }
  142. /**
  143. * Set positioning type
  144. *
  145. * @param string $positioning
  146. * @throws \InvalidArgumentException
  147. * @return self
  148. */
  149. public function setPositioning($positioning)
  150. {
  151. $this->setPos($positioning);
  152. return $this;
  153. }
  154. /**
  155. * Get horizontal alignment
  156. *
  157. * @return string
  158. */
  159. public function getPosHorizontal()
  160. {
  161. return $this->getHPos();
  162. }
  163. /**
  164. * Set horizontal alignment
  165. *
  166. * @param string $alignment
  167. * @throws \InvalidArgumentException
  168. * @return self
  169. */
  170. public function setPosHorizontal($alignment)
  171. {
  172. $this->setHPos($alignment);
  173. return $this;
  174. }
  175. /**
  176. * Get vertical alignment
  177. *
  178. * @return string
  179. */
  180. public function getPosVertical()
  181. {
  182. return $this->getVPos();
  183. }
  184. /**
  185. * Set vertical alignment
  186. *
  187. * @param string $alignment
  188. * @throws \InvalidArgumentException
  189. * @return self
  190. */
  191. public function setPosVertical($alignment)
  192. {
  193. $this->setVPos($alignment);
  194. return $this;
  195. }
  196. /**
  197. * Get horizontal relation
  198. *
  199. * @return string
  200. */
  201. public function getPosHorizontalRel()
  202. {
  203. return $this->getHPosRelTo();
  204. }
  205. /**
  206. * Set horizontal relation
  207. *
  208. * @param string $relto
  209. * @throws \InvalidArgumentException
  210. * @return self
  211. */
  212. public function setPosHorizontalRel($relto)
  213. {
  214. $this->setHPosRelTo($relto);
  215. return $this;
  216. }
  217. /**
  218. * Get vertical relation
  219. *
  220. * @return string
  221. */
  222. public function getPosVerticalRel()
  223. {
  224. return $this->getVPosRelTo();
  225. }
  226. /**
  227. * Set vertical relation
  228. *
  229. * @param string $relto
  230. * @throws \InvalidArgumentException
  231. * @return self
  232. */
  233. public function setPosVerticalRel($relto)
  234. {
  235. $this->setVPosRelTo($relto);
  236. return $this;
  237. }
  238. }