MDL-63044 course: add get_enrolled_courses_by_timeline_classification
[moodle.git] / lib / phpexcel / PHPExcel / Worksheet / MemoryDrawing.php
blob438ed2c58f9d7367f9ee565edcb6a518856110a9
1 <?php
3 /**
4 * PHPExcel_Worksheet_MemoryDrawing
6 * Copyright (c) 2006 - 2015 PHPExcel
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * @category PHPExcel
23 * @package PHPExcel_Worksheet
24 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 * @version ##VERSION##, ##DATE##
28 class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
30 /* Rendering functions */
31 const RENDERING_DEFAULT = 'imagepng';
32 const RENDERING_PNG = 'imagepng';
33 const RENDERING_GIF = 'imagegif';
34 const RENDERING_JPEG = 'imagejpeg';
36 /* MIME types */
37 const MIMETYPE_DEFAULT = 'image/png';
38 const MIMETYPE_PNG = 'image/png';
39 const MIMETYPE_GIF = 'image/gif';
40 const MIMETYPE_JPEG = 'image/jpeg';
42 /**
43 * Image resource
45 * @var resource
47 private $imageResource;
49 /**
50 * Rendering function
52 * @var string
54 private $renderingFunction;
56 /**
57 * Mime type
59 * @var string
61 private $mimeType;
63 /**
64 * Unique name
66 * @var string
68 private $uniqueName;
70 /**
71 * Create a new PHPExcel_Worksheet_MemoryDrawing
73 public function __construct()
75 // Initialise values
76 $this->imageResource = null;
77 $this->renderingFunction = self::RENDERING_DEFAULT;
78 $this->mimeType = self::MIMETYPE_DEFAULT;
79 $this->uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
81 // Initialize parent
82 parent::__construct();
85 /**
86 * Get image resource
88 * @return resource
90 public function getImageResource()
92 return $this->imageResource;
95 /**
96 * Set image resource
98 * @param $value resource
99 * @return PHPExcel_Worksheet_MemoryDrawing
101 public function setImageResource($value = null)
103 $this->imageResource = $value;
105 if (!is_null($this->imageResource)) {
106 // Get width/height
107 $this->width = imagesx($this->imageResource);
108 $this->height = imagesy($this->imageResource);
110 return $this;
114 * Get rendering function
116 * @return string
118 public function getRenderingFunction()
120 return $this->renderingFunction;
124 * Set rendering function
126 * @param string $value
127 * @return PHPExcel_Worksheet_MemoryDrawing
129 public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT)
131 $this->renderingFunction = $value;
132 return $this;
136 * Get mime type
138 * @return string
140 public function getMimeType()
142 return $this->mimeType;
146 * Set mime type
148 * @param string $value
149 * @return PHPExcel_Worksheet_MemoryDrawing
151 public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT)
153 $this->mimeType = $value;
154 return $this;
158 * Get indexed filename (using image index)
160 * @return string
162 public function getIndexedFilename()
164 $extension = strtolower($this->getMimeType());
165 $extension = explode('/', $extension);
166 $extension = $extension[1];
168 return $this->uniqueName . $this->getImageIndex() . '.' . $extension;
172 * Get hash code
174 * @return string Hash code
176 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()
192 $vars = get_object_vars($this);
193 foreach ($vars as $key => $value) {
194 if (is_object($value)) {
195 $this->$key = clone $value;
196 } else {
197 $this->$key = $value;