Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2390 jpm 1
<?php
2
/**
3
 * PHPExcel
4
 *
5
 * Copyright (c) 2006 - 2013 PHPExcel
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   PHPExcel
22
 * @package    PHPExcel_Writer_Excel2007
23
 * @copyright  Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
24
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
25
 * @version    ##VERSION##, ##DATE##
26
 */
27
 
28
 
29
/**
30
 * PHPExcel_Writer_Excel2007_Drawing
31
 *
32
 * @category   PHPExcel
33
 * @package    PHPExcel_Writer_Excel2007
34
 * @copyright  Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
35
 */
36
class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart
37
{
38
	/**
39
	 * Write drawings to XML format
40
	 *
41
	 * @param 	PHPExcel_Worksheet	$pWorksheet
42
	 * @param	int					&$chartRef		Chart ID
43
	 * @param	boolean				$includeCharts	Flag indicating if we should include drawing details for charts
44
	 * @return 	string 				XML Output
45
	 * @throws 	PHPExcel_Writer_Exception
46
	 */
47
	public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE)
48
	{
49
		// Create XML writer
50
		$objWriter = null;
51
		if ($this->getParentWriter()->getUseDiskCaching()) {
52
			$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
53
		} else {
54
			$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
55
		}
56
 
57
		// XML header
58
		$objWriter->startDocument('1.0','UTF-8','yes');
59
 
60
		// xdr:wsDr
61
		$objWriter->startElement('xdr:wsDr');
62
		$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
63
		$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
64
 
65
			// Loop through images and write drawings
66
			$i = 1;
67
			$iterator = $pWorksheet->getDrawingCollection()->getIterator();
68
			while ($iterator->valid()) {
69
				$this->_writeDrawing($objWriter, $iterator->current(), $i);
70
 
71
				$iterator->next();
72
				++$i;
73
			}
74
 
75
			if ($includeCharts) {
76
				$chartCount = $pWorksheet->getChartCount();
77
				// Loop through charts and write the chart position
78
				if ($chartCount > 0) {
79
					for ($c = 0; $c < $chartCount; ++$c) {
80
						$this->_writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i);
81
					}
82
				}
83
			}
84
 
85
 
86
		$objWriter->endElement();
87
 
88
		// Return
89
		return $objWriter->getData();
90
	}
91
 
92
	/**
93
	 * Write drawings to XML format
94
	 *
95
	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer
96
	 * @param 	PHPExcel_Chart				$pChart
97
	 * @param 	int							$pRelationId
98
	 * @throws 	PHPExcel_Writer_Exception
99
	 */
100
	public function _writeChart(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Chart $pChart = null, $pRelationId = -1)
101
	{
102
		$tl = $pChart->getTopLeftPosition();
103
		$tl['colRow'] = PHPExcel_Cell::coordinateFromString($tl['cell']);
104
		$br = $pChart->getBottomRightPosition();
105
		$br['colRow'] = PHPExcel_Cell::coordinateFromString($br['cell']);
106
 
107
		$objWriter->startElement('xdr:twoCellAnchor');
108
 
109
			$objWriter->startElement('xdr:from');
110
				$objWriter->writeElement('xdr:col', PHPExcel_Cell::columnIndexFromString($tl['colRow'][0]) - 1);
111
				$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($tl['xOffset']));
112
				$objWriter->writeElement('xdr:row', $tl['colRow'][1] - 1);
113
				$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($tl['yOffset']));
114
			$objWriter->endElement();
115
			$objWriter->startElement('xdr:to');
116
				$objWriter->writeElement('xdr:col', PHPExcel_Cell::columnIndexFromString($br['colRow'][0]) - 1);
117
				$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($br['xOffset']));
118
				$objWriter->writeElement('xdr:row', $br['colRow'][1] - 1);
119
				$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($br['yOffset']));
120
			$objWriter->endElement();
121
 
122
			$objWriter->startElement('xdr:graphicFrame');
123
				$objWriter->writeAttribute('macro', '');
124
				$objWriter->startElement('xdr:nvGraphicFramePr');
125
					$objWriter->startElement('xdr:cNvPr');
126
						$objWriter->writeAttribute('name', 'Chart '.$pRelationId);
127
						$objWriter->writeAttribute('id', 1025 * $pRelationId);
128
					$objWriter->endElement();
129
					$objWriter->startElement('xdr:cNvGraphicFramePr');
130
						$objWriter->startElement('a:graphicFrameLocks');
131
						$objWriter->endElement();
132
					$objWriter->endElement();
133
				$objWriter->endElement();
134
 
135
				$objWriter->startElement('xdr:xfrm');
136
					$objWriter->startElement('a:off');
137
						$objWriter->writeAttribute('x', '0');
138
						$objWriter->writeAttribute('y', '0');
139
					$objWriter->endElement();
140
					$objWriter->startElement('a:ext');
141
						$objWriter->writeAttribute('cx', '0');
142
						$objWriter->writeAttribute('cy', '0');
143
					$objWriter->endElement();
144
				$objWriter->endElement();
145
 
146
				$objWriter->startElement('a:graphic');
147
					$objWriter->startElement('a:graphicData');
148
						$objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
149
						$objWriter->startElement('c:chart');
150
							$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
151
							$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
152
							$objWriter->writeAttribute('r:id', 'rId'.$pRelationId);
153
						$objWriter->endElement();
154
					$objWriter->endElement();
155
				$objWriter->endElement();
156
			$objWriter->endElement();
157
 
158
			$objWriter->startElement('xdr:clientData');
159
			$objWriter->endElement();
160
 
161
		$objWriter->endElement();
162
	}
163
 
164
	/**
165
	 * Write drawings to XML format
166
	 *
167
	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer
168
	 * @param 	PHPExcel_Worksheet_BaseDrawing		$pDrawing
169
	 * @param 	int									$pRelationId
170
	 * @throws 	PHPExcel_Writer_Exception
171
	 */
172
	public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1)
173
	{
174
		if ($pRelationId >= 0) {
175
			// xdr:oneCellAnchor
176
			$objWriter->startElement('xdr:oneCellAnchor');
177
				// Image location
178
				$aCoordinates 		= PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates());
179
				$aCoordinates[0] 	= PHPExcel_Cell::columnIndexFromString($aCoordinates[0]);
180
 
181
				// xdr:from
182
				$objWriter->startElement('xdr:from');
183
					$objWriter->writeElement('xdr:col', $aCoordinates[0] - 1);
184
					$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX()));
185
					$objWriter->writeElement('xdr:row', $aCoordinates[1] - 1);
186
					$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY()));
187
				$objWriter->endElement();
188
 
189
				// xdr:ext
190
				$objWriter->startElement('xdr:ext');
191
					$objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth()));
192
					$objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight()));
193
				$objWriter->endElement();
194
 
195
				// xdr:pic
196
				$objWriter->startElement('xdr:pic');
197
 
198
					// xdr:nvPicPr
199
					$objWriter->startElement('xdr:nvPicPr');
200
 
201
						// xdr:cNvPr
202
						$objWriter->startElement('xdr:cNvPr');
203
						$objWriter->writeAttribute('id', $pRelationId);
204
						$objWriter->writeAttribute('name', $pDrawing->getName());
205
						$objWriter->writeAttribute('descr', $pDrawing->getDescription());
206
						$objWriter->endElement();
207
 
208
						// xdr:cNvPicPr
209
						$objWriter->startElement('xdr:cNvPicPr');
210
 
211
							// a:picLocks
212
							$objWriter->startElement('a:picLocks');
213
							$objWriter->writeAttribute('noChangeAspect', '1');
214
							$objWriter->endElement();
215
 
216
						$objWriter->endElement();
217
 
218
					$objWriter->endElement();
219
 
220
					// xdr:blipFill
221
					$objWriter->startElement('xdr:blipFill');
222
 
223
						// a:blip
224
						$objWriter->startElement('a:blip');
225
						$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
226
						$objWriter->writeAttribute('r:embed', 'rId' . $pRelationId);
227
						$objWriter->endElement();
228
 
229
						// a:stretch
230
						$objWriter->startElement('a:stretch');
231
							$objWriter->writeElement('a:fillRect', null);
232
						$objWriter->endElement();
233
 
234
					$objWriter->endElement();
235
 
236
					// xdr:spPr
237
					$objWriter->startElement('xdr:spPr');
238
 
239
						// a:xfrm
240
						$objWriter->startElement('a:xfrm');
241
						$objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation()));
242
						$objWriter->endElement();
243
 
244
						// a:prstGeom
245
						$objWriter->startElement('a:prstGeom');
246
						$objWriter->writeAttribute('prst', 'rect');
247
 
248
							// a:avLst
249
							$objWriter->writeElement('a:avLst', null);
250
 
251
						$objWriter->endElement();
252
 
253
//						// a:solidFill
254
//						$objWriter->startElement('a:solidFill');
255
 
256
//							// a:srgbClr
257
//							$objWriter->startElement('a:srgbClr');
258
//							$objWriter->writeAttribute('val', 'FFFFFF');
259
 
260
///* SHADE
261
//								// a:shade
262
//								$objWriter->startElement('a:shade');
263
//								$objWriter->writeAttribute('val', '85000');
264
//								$objWriter->endElement();
265
//*/
266
 
267
//							$objWriter->endElement();
268
 
269
//						$objWriter->endElement();
270
/*
271
						// a:ln
272
						$objWriter->startElement('a:ln');
273
						$objWriter->writeAttribute('w', '88900');
274
						$objWriter->writeAttribute('cap', 'sq');
275
 
276
							// a:solidFill
277
							$objWriter->startElement('a:solidFill');
278
 
279
								// a:srgbClr
280
								$objWriter->startElement('a:srgbClr');
281
								$objWriter->writeAttribute('val', 'FFFFFF');
282
								$objWriter->endElement();
283
 
284
							$objWriter->endElement();
285
 
286
							// a:miter
287
							$objWriter->startElement('a:miter');
288
							$objWriter->writeAttribute('lim', '800000');
289
							$objWriter->endElement();
290
 
291
						$objWriter->endElement();
292
*/
293
 
294
						if ($pDrawing->getShadow()->getVisible()) {
295
							// a:effectLst
296
							$objWriter->startElement('a:effectLst');
297
 
298
								// a:outerShdw
299
								$objWriter->startElement('a:outerShdw');
300
								$objWriter->writeAttribute('blurRad', 		PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
301
								$objWriter->writeAttribute('dist',			PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
302
								$objWriter->writeAttribute('dir',			PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
303
								$objWriter->writeAttribute('algn',			$pDrawing->getShadow()->getAlignment());
304
								$objWriter->writeAttribute('rotWithShape', 	'0');
305
 
306
									// a:srgbClr
307
									$objWriter->startElement('a:srgbClr');
308
									$objWriter->writeAttribute('val',		$pDrawing->getShadow()->getColor()->getRGB());
309
 
310
										// a:alpha
311
										$objWriter->startElement('a:alpha');
312
										$objWriter->writeAttribute('val', 	$pDrawing->getShadow()->getAlpha() * 1000);
313
										$objWriter->endElement();
314
 
315
									$objWriter->endElement();
316
 
317
								$objWriter->endElement();
318
 
319
							$objWriter->endElement();
320
						}
321
/*
322
 
323
						// a:scene3d
324
						$objWriter->startElement('a:scene3d');
325
 
326
							// a:camera
327
							$objWriter->startElement('a:camera');
328
							$objWriter->writeAttribute('prst', 'orthographicFront');
329
							$objWriter->endElement();
330
 
331
							// a:lightRig
332
							$objWriter->startElement('a:lightRig');
333
							$objWriter->writeAttribute('rig', 'twoPt');
334
							$objWriter->writeAttribute('dir', 't');
335
 
336
								// a:rot
337
								$objWriter->startElement('a:rot');
338
								$objWriter->writeAttribute('lat', '0');
339
								$objWriter->writeAttribute('lon', '0');
340
								$objWriter->writeAttribute('rev', '0');
341
								$objWriter->endElement();
342
 
343
							$objWriter->endElement();
344
 
345
						$objWriter->endElement();
346
*/
347
/*
348
						// a:sp3d
349
						$objWriter->startElement('a:sp3d');
350
 
351
							// a:bevelT
352
							$objWriter->startElement('a:bevelT');
353
							$objWriter->writeAttribute('w', '25400');
354
							$objWriter->writeAttribute('h', '19050');
355
							$objWriter->endElement();
356
 
357
							// a:contourClr
358
							$objWriter->startElement('a:contourClr');
359
 
360
								// a:srgbClr
361
								$objWriter->startElement('a:srgbClr');
362
								$objWriter->writeAttribute('val', 'FFFFFF');
363
								$objWriter->endElement();
364
 
365
							$objWriter->endElement();
366
 
367
						$objWriter->endElement();
368
*/
369
					$objWriter->endElement();
370
 
371
				$objWriter->endElement();
372
 
373
				// xdr:clientData
374
				$objWriter->writeElement('xdr:clientData', null);
375
 
376
			$objWriter->endElement();
377
		} else {
378
			throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
379
		}
380
	}
381
 
382
	/**
383
	 * Write VML header/footer images to XML format
384
	 *
385
	 * @param 	PHPExcel_Worksheet				$pWorksheet
386
	 * @return 	string 								XML Output
387
	 * @throws 	PHPExcel_Writer_Exception
388
	 */
389
	public function writeVMLHeaderFooterImages(PHPExcel_Worksheet $pWorksheet = null)
390
	{
391
		// Create XML writer
392
		$objWriter = null;
393
		if ($this->getParentWriter()->getUseDiskCaching()) {
394
			$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
395
		} else {
396
			$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
397
		}
398
 
399
		// XML header
400
		$objWriter->startDocument('1.0','UTF-8','yes');
401
 
402
  		// Header/footer images
403
  		$images = $pWorksheet->getHeaderFooter()->getImages();
404
 
405
		// xml
406
		$objWriter->startElement('xml');
407
		$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
408
		$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
409
		$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
410
 
411
			// o:shapelayout
412
			$objWriter->startElement('o:shapelayout');
413
			$objWriter->writeAttribute('v:ext', 		'edit');
414
 
415
				// o:idmap
416
				$objWriter->startElement('o:idmap');
417
				$objWriter->writeAttribute('v:ext', 	'edit');
418
				$objWriter->writeAttribute('data', 		'1');
419
				$objWriter->endElement();
420
 
421
			$objWriter->endElement();
422
 
423
			// v:shapetype
424
			$objWriter->startElement('v:shapetype');
425
			$objWriter->writeAttribute('id', 					'_x0000_t75');
426
			$objWriter->writeAttribute('coordsize', 			'21600,21600');
427
			$objWriter->writeAttribute('o:spt', 				'75');
428
			$objWriter->writeAttribute('o:preferrelative', 		't');
429
			$objWriter->writeAttribute('path', 					'm@4@5l@4@11@9@11@9@5xe');
430
			$objWriter->writeAttribute('filled',		 		'f');
431
			$objWriter->writeAttribute('stroked',		 		'f');
432
 
433
				// v:stroke
434
				$objWriter->startElement('v:stroke');
435
				$objWriter->writeAttribute('joinstyle', 		'miter');
436
				$objWriter->endElement();
437
 
438
				// v:formulas
439
				$objWriter->startElement('v:formulas');
440
 
441
					// v:f
442
					$objWriter->startElement('v:f');
443
					$objWriter->writeAttribute('eqn', 		'if lineDrawn pixelLineWidth 0');
444
					$objWriter->endElement();
445
 
446
					// v:f
447
					$objWriter->startElement('v:f');
448
					$objWriter->writeAttribute('eqn', 		'sum @0 1 0');
449
					$objWriter->endElement();
450
 
451
					// v:f
452
					$objWriter->startElement('v:f');
453
					$objWriter->writeAttribute('eqn', 		'sum 0 0 @1');
454
					$objWriter->endElement();
455
 
456
					// v:f
457
					$objWriter->startElement('v:f');
458
					$objWriter->writeAttribute('eqn', 		'prod @2 1 2');
459
					$objWriter->endElement();
460
 
461
					// v:f
462
					$objWriter->startElement('v:f');
463
					$objWriter->writeAttribute('eqn', 		'prod @3 21600 pixelWidth');
464
					$objWriter->endElement();
465
 
466
					// v:f
467
					$objWriter->startElement('v:f');
468
					$objWriter->writeAttribute('eqn', 		'prod @3 21600 pixelHeight');
469
					$objWriter->endElement();
470
 
471
					// v:f
472
					$objWriter->startElement('v:f');
473
					$objWriter->writeAttribute('eqn', 		'sum @0 0 1');
474
					$objWriter->endElement();
475
 
476
					// v:f
477
					$objWriter->startElement('v:f');
478
					$objWriter->writeAttribute('eqn', 		'prod @6 1 2');
479
					$objWriter->endElement();
480
 
481
					// v:f
482
					$objWriter->startElement('v:f');
483
					$objWriter->writeAttribute('eqn', 		'prod @7 21600 pixelWidth');
484
					$objWriter->endElement();
485
 
486
					// v:f
487
					$objWriter->startElement('v:f');
488
					$objWriter->writeAttribute('eqn', 		'sum @8 21600 0');
489
					$objWriter->endElement();
490
 
491
					// v:f
492
					$objWriter->startElement('v:f');
493
					$objWriter->writeAttribute('eqn', 		'prod @7 21600 pixelHeight');
494
					$objWriter->endElement();
495
 
496
					// v:f
497
					$objWriter->startElement('v:f');
498
					$objWriter->writeAttribute('eqn', 		'sum @10 21600 0');
499
					$objWriter->endElement();
500
 
501
				$objWriter->endElement();
502
 
503
				// v:path
504
				$objWriter->startElement('v:path');
505
				$objWriter->writeAttribute('o:extrusionok', 	'f');
506
				$objWriter->writeAttribute('gradientshapeok', 	't');
507
				$objWriter->writeAttribute('o:connecttype', 	'rect');
508
				$objWriter->endElement();
509
 
510
				// o:lock
511
				$objWriter->startElement('o:lock');
512
				$objWriter->writeAttribute('v:ext', 			'edit');
513
				$objWriter->writeAttribute('aspectratio', 		't');
514
				$objWriter->endElement();
515
 
516
			$objWriter->endElement();
517
 
518
			// Loop through images
519
			foreach ($images as $key => $value) {
520
				$this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
521
			}
522
 
523
		$objWriter->endElement();
524
 
525
		// Return
526
		return $objWriter->getData();
527
	}
528
 
529
	/**
530
	 * Write VML comment to XML format
531
	 *
532
	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 			XML Writer
533
	 * @param	string							$pReference			Reference
534
	 * @param 	PHPExcel_Worksheet_HeaderFooterDrawing	$pImage		Image
535
	 * @throws 	PHPExcel_Writer_Exception
536
	 */
537
	public function _writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null)
538
	{
539
		// Calculate object id
540
		preg_match('{(\d+)}', md5($pReference), $m);
541
		$id = 1500 + (substr($m[1], 0, 2) * 1);
542
 
543
		// Calculate offset
544
		$width = $pImage->getWidth();
545
		$height = $pImage->getHeight();
546
		$marginLeft = $pImage->getOffsetX();
547
		$marginTop = $pImage->getOffsetY();
548
 
549
		// v:shape
550
		$objWriter->startElement('v:shape');
551
		$objWriter->writeAttribute('id', 			$pReference);
552
		$objWriter->writeAttribute('o:spid', 		'_x0000_s' . $id);
553
		$objWriter->writeAttribute('type', 			'#_x0000_t75');
554
		$objWriter->writeAttribute('style', 		"position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1");
555
 
556
			// v:imagedata
557
			$objWriter->startElement('v:imagedata');
558
			$objWriter->writeAttribute('o:relid', 		'rId' . $pReference);
559
			$objWriter->writeAttribute('o:title', 		$pImage->getName());
560
			$objWriter->endElement();
561
 
562
			// o:lock
563
			$objWriter->startElement('o:lock');
564
			$objWriter->writeAttribute('v:ext', 		'edit');
565
			$objWriter->writeAttribute('rotation', 		't');
566
			$objWriter->endElement();
567
 
568
		$objWriter->endElement();
569
	}
570
 
571
 
572
	/**
573
	 * Get an array of all drawings
574
	 *
575
	 * @param 	PHPExcel							$pPHPExcel
576
	 * @return 	PHPExcel_Worksheet_Drawing[]		All drawings in PHPExcel
577
	 * @throws 	PHPExcel_Writer_Exception
578
	 */
579
	public function allDrawings(PHPExcel $pPHPExcel = null)
580
	{
581
		// Get an array of all drawings
582
		$aDrawings	= array();
583
 
584
		// Loop through PHPExcel
585
		$sheetCount = $pPHPExcel->getSheetCount();
586
		for ($i = 0; $i < $sheetCount; ++$i) {
587
			// Loop through images and add to array
588
			$iterator = $pPHPExcel->getSheet($i)->getDrawingCollection()->getIterator();
589
			while ($iterator->valid()) {
590
				$aDrawings[] = $iterator->current();
591
 
592
  				$iterator->next();
593
			}
594
		}
595
 
596
		return $aDrawings;
597
	}
598
}