1: <?php
2: /**
3: * PHPWord
4: *
5: * Copyright (c) 2013 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) 2013 PHPWord
24: * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25: * @version 0.7.0
26: */
27:
28: /**
29: * Class PHPWord_Style_Image
30: */
31: class PHPWord_Style_Image
32: {
33: const WRAPPING_STYLE_INLINE = 'inline';
34: const WRAPPING_STYLE_SQUARE = 'square';
35: const WRAPPING_STYLE_TIGHT = 'tight';
36: const WRAPPING_STYLE_BEHIND = 'behind';
37: const WRAPPING_STYLE_INFRONT = 'infront';
38:
39: private $_width;
40: private $_height;
41: private $_align;
42: private $wrappingStyle;
43:
44: /**
45: * Margin Top
46: *
47: * @var int
48: */
49: private $_marginTop;
50:
51: /**
52: * Margin Left
53: *
54: * @var int
55: */
56: private $_marginLeft;
57:
58: public function __construct()
59: {
60: $this->_width = null;
61: $this->_height = null;
62: $this->_align = null;
63: $this->_marginTop = null;
64: $this->_marginLeft = null;
65: $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE);
66: }
67:
68: public function setStyleValue($key, $value)
69: {
70: $this->$key = $value;
71: }
72:
73: public function getWidth()
74: {
75: return $this->_width;
76: }
77:
78: public function setWidth($pValue = null)
79: {
80: $this->_width = $pValue;
81: }
82:
83: public function getHeight()
84: {
85: return $this->_height;
86: }
87:
88: public function setHeight($pValue = null)
89: {
90: $this->_height = $pValue;
91: }
92:
93: public function getAlign()
94: {
95: return $this->_align;
96: }
97:
98: public function setAlign($pValue = null)
99: {
100: $this->_align = $pValue;
101: }
102:
103: /**
104: * Get Margin Top
105: *
106: * @return int
107: */
108: public function getMarginTop()
109: {
110: return $this->_marginTop;
111: }
112:
113: /**
114: * Set Margin Top
115: *
116: * @param int $pValue
117: * @return $this
118: */
119: public function setMarginTop($pValue = null)
120: {
121: $this->_marginTop = $pValue;
122: return $this;
123: }
124:
125: /**
126: * Get Margin Left
127: *
128: * @return int
129: */
130: public function getMarginLeft()
131: {
132: return $this->_marginLeft;
133: }
134:
135: /**
136: * Set Margin Left
137: *
138: * @param int $pValue
139: * @return $this
140: */
141: public function setMarginLeft($pValue = null)
142: {
143: $this->_marginLeft = $pValue;
144: return $this;
145: }
146:
147: /**
148: * @param string $wrappingStyle
149: * @throws InvalidArgumentException
150: * @return $this
151: */
152: public function setWrappingStyle($wrappingStyle)
153: {
154: switch ($wrappingStyle) {
155: case self::WRAPPING_STYLE_BEHIND:
156: case self::WRAPPING_STYLE_INFRONT:
157: case self::WRAPPING_STYLE_INLINE:
158: case self::WRAPPING_STYLE_SQUARE:
159: case self::WRAPPING_STYLE_TIGHT:
160: $this->wrappingStyle = $wrappingStyle;
161: break;
162: default:
163: throw new InvalidArgumentException('Wrapping style does not exists');
164: break;
165: }
166: return $this;
167: }
168:
169: /**
170: * @return string
171: */
172: public function getWrappingStyle()
173: {
174: return $this->wrappingStyle;
175: }
176: }