ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HeaderFooterDrawing.php
Go to the documentation of this file.
1 <?php
30 if (!defined('PHPEXCEL_ROOT')) {
34  define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
35 }
36 
38 require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
39 
41 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
42 
44 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
45 
47 require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
48 
49 
58 {
64  private $_path;
65 
71  protected $_name;
72 
78  protected $_offsetX;
79 
85  protected $_offsetY;
86 
92  protected $_width;
93 
99  protected $_height;
100 
107 
111  public function __construct()
112  {
113  // Initialise values
114  $this->_path = '';
115  $this->_name = '';
116  $this->_offsetX = 0;
117  $this->_offsetY = 0;
118  $this->_width = 0;
119  $this->_height = 0;
120  $this->_resizeProportional = true;
121  }
122 
128  public function getName() {
129  return $this->_name;
130  }
131 
138  public function setName($pValue = '') {
139  $this->_name = $pValue;
140  return $this;
141  }
142 
148  public function getOffsetX() {
149  return $this->_offsetX;
150  }
151 
158  public function setOffsetX($pValue = 0) {
159  $this->_offsetX = $pValue;
160  return $this;
161  }
162 
168  public function getOffsetY() {
169  return $this->_offsetY;
170  }
171 
178  public function setOffsetY($pValue = 0) {
179  $this->_offsetY = $pValue;
180  return $this;
181  }
182 
188  public function getWidth() {
189  return $this->_width;
190  }
191 
198  public function setWidth($pValue = 0) {
199  // Resize proportional?
200  if ($this->_resizeProportional && $pValue != 0) {
201  $ratio = $this->_width / $this->_height;
202  $this->_height = round($ratio * $pValue);
203  }
204 
205  // Set width
206  $this->_width = $pValue;
207 
208  return $this;
209  }
210 
216  public function getHeight() {
217  return $this->_height;
218  }
219 
226  public function setHeight($pValue = 0) {
227  // Resize proportional?
228  if ($this->_resizeProportional && $pValue != 0) {
229  $ratio = $this->_width / $this->_height;
230  $this->_width = round($ratio * $pValue);
231  }
232 
233  // Set height
234  $this->_height = $pValue;
235 
236  return $this;
237  }
238 
252  public function setWidthAndHeight($width = 0, $height = 0) {
253  $xratio = $width / $this->_width;
254  $yratio = $height / $this->_height;
255  if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
256  if (($xratio * $this->_height) < $height) {
257  $this->_height = ceil($xratio * $this->_height);
258  $this->_width = $width;
259  } else {
260  $this->_width = ceil($yratio * $this->_width);
261  $this->_height = $height;
262  }
263  }
264  return $this;
265  }
266 
272  public function getResizeProportional() {
274  }
275 
282  public function setResizeProportional($pValue = true) {
283  $this->_resizeProportional = $pValue;
284  return $this;
285  }
286 
292  public function getFilename() {
293  return basename($this->_path);
294  }
295 
301  public function getExtension() {
302  return end(explode(".", basename($this->_path)));
303  }
304 
310  public function getPath() {
311  return $this->_path;
312  }
313 
322  public function setPath($pValue = '', $pVerifyFile = true) {
323  if ($pVerifyFile) {
324  if (file_exists($pValue)) {
325  $this->_path = $pValue;
326 
327  if ($this->_width == 0 && $this->_height == 0) {
328  // Get width/height
329  list($this->_width, $this->_height) = getimagesize($pValue);
330  }
331  } else {
332  throw new Exception("File $pValue not found!");
333  }
334  } else {
335  $this->_path = $pValue;
336  }
337  return $this;
338  }
339 
345  public function getHashCode() {
346  return md5(
347  $this->_path
348  . $this->_name
349  . $this->_offsetX
350  . $this->_offsetY
351  . $this->_width
352  . $this->_height
353  . __CLASS__
354  );
355  }
356 
362  private $_hashIndex;
363 
372  public function getHashIndex() {
373  return $this->_hashIndex;
374  }
375 
384  public function setHashIndex($value) {
385  $this->_hashIndex = $value;
386  }
387 
391  public function __clone() {
392  $vars = get_object_vars($this);
393  foreach ($vars as $key => $value) {
394  if (is_object($value)) {
395  $this->$key = clone $value;
396  } else {
397  $this->$key = $value;
398  }
399  }
400  }
401 }