Updated gui for user facility settings (#1327)
[openemr.git] / vendor / phpoffice / phpexcel / Classes / PHPExcel / Worksheet / MemoryDrawing.php
blob80fc6d1f0b301c9fa9f58075e2ac1d0099fbd048
1 <?php
2 /**
3 * PHPExcel
5 * Copyright (c) 2006 - 2014 PHPExcel
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.
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.
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
21 * @category PHPExcel
22 * @package PHPExcel_Worksheet
23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
29 /**
30 * PHPExcel_Worksheet_MemoryDrawing
32 * @category PHPExcel
33 * @package PHPExcel_Worksheet
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
36 class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
38 /* Rendering functions */
39 const RENDERING_DEFAULT = 'imagepng';
40 const RENDERING_PNG = 'imagepng';
41 const RENDERING_GIF = 'imagegif';
42 const RENDERING_JPEG = 'imagejpeg';
44 /* MIME types */
45 const MIMETYPE_DEFAULT = 'image/png';
46 const MIMETYPE_PNG = 'image/png';
47 const MIMETYPE_GIF = 'image/gif';
48 const MIMETYPE_JPEG = 'image/jpeg';
50 /**
51 * Image resource
53 * @var resource
55 private $_imageResource;
57 /**
58 * Rendering function
60 * @var string
62 private $_renderingFunction;
64 /**
65 * Mime type
67 * @var string
69 private $_mimeType;
71 /**
72 * Unique name
74 * @var string
76 private $_uniqueName;
78 /**
79 * Create a new PHPExcel_Worksheet_MemoryDrawing
81 public function __construct()
83 // Initialise values
84 $this->_imageResource = null;
85 $this->_renderingFunction = self::RENDERING_DEFAULT;
86 $this->_mimeType = self::MIMETYPE_DEFAULT;
87 $this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
89 // Initialize parent
90 parent::__construct();
93 /**
94 * Get image resource
96 * @return resource
98 public function getImageResource() {
99 return $this->_imageResource;
103 * Set image resource
105 * @param $value resource
106 * @return PHPExcel_Worksheet_MemoryDrawing
108 public function setImageResource($value = null) {
109 $this->_imageResource = $value;
111 if (!is_null($this->_imageResource)) {
112 // Get width/height
113 $this->_width = imagesx($this->_imageResource);
114 $this->_height = imagesy($this->_imageResource);
116 return $this;
120 * Get rendering function
122 * @return string
124 public function getRenderingFunction() {
125 return $this->_renderingFunction;
129 * Set rendering function
131 * @param string $value
132 * @return PHPExcel_Worksheet_MemoryDrawing
134 public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT) {
135 $this->_renderingFunction = $value;
136 return $this;
140 * Get mime type
142 * @return string
144 public function getMimeType() {
145 return $this->_mimeType;
149 * Set mime type
151 * @param string $value
152 * @return PHPExcel_Worksheet_MemoryDrawing
154 public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT) {
155 $this->_mimeType = $value;
156 return $this;
160 * Get indexed filename (using image index)
162 * @return string
164 public function getIndexedFilename() {
165 $extension = strtolower($this->getMimeType());
166 $extension = explode('/', $extension);
167 $extension = $extension[1];
169 return $this->_uniqueName . $this->getImageIndex() . '.' . $extension;
173 * Get hash code
175 * @return string Hash code
177 public function getHashCode() {
178 return md5(
179 $this->_renderingFunction
180 . $this->_mimeType
181 . $this->_uniqueName
182 . parent::getHashCode()
183 . __CLASS__
188 * Implement PHP __clone to create a deep clone, not just a shallow copy.
190 public function __clone() {
191 $vars = get_object_vars($this);
192 foreach ($vars as $key => $value) {
193 if (is_object($value)) {
194 $this->$key = clone $value;
195 } else {
196 $this->$key = $value;