_name = ''; $this->_description = ''; $this->_resizeProportional = true; // Set image index self::$_imageCounter++; $this->_imageIndex = self::$_imageCounter; // Initialize parent parent::__construct(); } /** * Get image index * * @return int */ public function getImageIndex() { return $this->_imageIndex; } /** * Get Name * * @return string */ public function getName() { return $this->_name; } /** * Set Name * * @param string $pValue */ public function setName($pValue = '') { $this->_name = $pValue; } /** * Get Description * * @return string */ public function getDescription() { return $this->_description; } /** * Set Description * * @param string $pValue */ public function setDescription($pValue = '') { $this->_description = $pValue; } /** * Set Width * * @param int $pValue */ public function setWidth($pValue = 0) { // Resize proportional? if ($this->_resizeProportional && $pValue != 0) { $ratio = $this->_height / $this->_width; $this->_height = round($ratio * $pValue); } // Set width $this->_width = $pValue; } /** * Set Height * * @param int $pValue */ public function setHeight($pValue = 0) { // Resize proportional? if ($this->_resizeProportional && $pValue != 0) { $ratio = $this->_width / $this->_height; $this->_width = round($ratio * $pValue); } // Set height $this->_height = $pValue; } /** * Set width and height with proportional resize * @author Vincent@luo MSN:kele_100@hotmail.com * @param int $width * @param int $height * @example $objDrawing->setResizeProportional(true); * @example $objDrawing->setWidthAndHeight(160,120); */ public function setWidthAndHeight($width = 0, $height = 0) { $xratio = $width / $this->_width; $yratio = $height / $this->_height; if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if (($xratio * $this->_height) < $height) { $this->_height = ceil($xratio * $this->_height); $this->_width = $width; } else { $this->_width = ceil($yratio * $this->_width); $this->_height = $height; } } } /** * Get ResizeProportional * * @return boolean */ public function getResizeProportional() { return $this->_resizeProportional; } /** * Set ResizeProportional * * @param boolean $pValue */ public function setResizeProportional($pValue = true) { $this->_resizeProportional = $pValue; } /** * Get hash code * * @return string Hash code */ public function getHashCode() { return md5( $this->_name . $this->_description . parent::getHashCode() . __CLASS__ ); } /** * Hash index * * @var string */ private $_hashIndex; /** * Get hash index * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @return string Hash index */ public function getHashIndex() { return $this->_hashIndex; } /** * Set hash index * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @param string $value Hash index */ public function setHashIndex($value) { $this->_hashIndex = $value; } /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ public function __clone() { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value)) { $this->$key = clone $value; } else { $this->$key = $value; } } } }