@@ -252,7 +252,7 @@ public function testReadDrawing()
252
252
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
253
253
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
254
254
<pic:nvPicPr>
255
- <pic:cNvPr id="1" name="file_name .jpg"/>
255
+ <pic:cNvPr id="1" name="mars .jpg"/>
256
256
<pic:cNvPicPr/>
257
257
</pic:nvPicPr>
258
258
<pic:blipFill>
@@ -267,9 +267,79 @@ public function testReadDrawing()
267
267
</w:r>
268
268
</w:p> ' ;
269
269
270
- $ phpWord = $ this ->getDocumentFromString (array ('document ' => $ documentXml ));
270
+ //$resolutionXml = '<Relationship Id="rId4" Target="media/mars.jpg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>';
271
+ $ relationships = array (
272
+ 'document ' => array (
273
+ 'rId4 ' => array (
274
+ 'target ' => 'media/mars.jpg ' ,
275
+ 'type ' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image ' ,
276
+ ),
277
+ ),
278
+ );
279
+
280
+ $ media = array (
281
+ __DIR__ . '/../../_files/images/mars.jpg ' ,
282
+ );
283
+
284
+ $ phpWord = $ this ->getDocumentFromString (array ('document ' => $ documentXml ), $ relationships , $ media );
271
285
272
286
$ elements = $ phpWord ->getSection (0 )->getElements ();
273
287
$ this ->assertInstanceOf ('PhpOffice\PhpWord\Element\TextRun ' , $ elements [0 ]);
288
+
289
+ $ children = $ elements [0 ]->getElements ();
290
+ $ this ->assertInstanceOf ('PhpOffice\PhpWord\Element\Image ' , $ children [0 ]);
291
+ }
292
+
293
+ /**
294
+ * Test reading Drawing with anchors
295
+ */
296
+ public function testReadDrawingWithAnchor ()
297
+ {
298
+ $ documentXml = '<w:p>
299
+ <w:r>
300
+ <w:drawing xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
301
+ <wp:anchor allowOverlap="1" behindDoc="0" distB="0" distL="0" distR="0" distT="0" layoutInCell="1" locked="0" relativeHeight="2" simplePos="0">
302
+ <wp:extent cx="5727700" cy="6621145"/>
303
+ <wp:docPr id="1" name="Picture 1"/>
304
+ <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
305
+ <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
306
+ <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
307
+ <pic:nvPicPr>
308
+ <pic:cNvPr id="1" name="mars.jpg"/>
309
+ <pic:cNvPicPr/>
310
+ </pic:nvPicPr>
311
+ <pic:blipFill>
312
+ <a:blip r:embed="rId4" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
313
+ </a:blip>
314
+ </pic:blipFill>
315
+ </pic:pic>
316
+ </a:graphicData>
317
+ </a:graphic>
318
+ </wp:anchor>
319
+ </w:drawing>
320
+ </w:r>
321
+ </w:p> ' ;
322
+
323
+ //$resolutionXml = '<Relationship Id="rId4" Target="media/mars.jpg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"/>';
324
+ $ relationships = array (
325
+ 'document ' => array (
326
+ 'rId4 ' => array (
327
+ 'target ' => 'media/mars.jpg ' ,
328
+ 'type ' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image ' ,
329
+ ),
330
+ ),
331
+ );
332
+
333
+ $ media = array (
334
+ __DIR__ . '/../../_files/images/mars.jpg ' ,
335
+ );
336
+
337
+ $ phpWord = $ this ->getDocumentFromString (array ('document ' => $ documentXml ), $ relationships , $ media );
338
+
339
+ $ elements = $ phpWord ->getSection (0 )->getElements ();
340
+ $ this ->assertInstanceOf ('PhpOffice\PhpWord\Element\TextRun ' , $ elements [0 ]);
341
+
342
+ $ children = $ elements [0 ]->getElements ();
343
+ $ this ->assertInstanceOf ('PhpOffice\PhpWord\Element\Image ' , $ children [0 ]);
274
344
}
275
345
}
0 commit comments