Skip to content

Commit b6a6544

Browse files
Docx reader: add handling of vml image objects (jgm#4735) (jgm#7257)
They represent images, the same way as other images in vml format.
1 parent d14c5f9 commit b6a6544

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/Text/Pandoc/Readers/Docx/Parse.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,17 +709,24 @@ elemToParPart ns element
709709
case drawing of
710710
Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp title alt bs $ elemToExtent drawingElem)
711711
Nothing -> throwError WrongElem
712-
-- The below is an attempt to deal with images in deprecated vml format.
712+
-- The two cases below are an attempt to deal with images in deprecated vml format.
713+
-- Todo: check out title and attr for deprecated format.
713714
elemToParPart ns element
714715
| isElem ns "w" "r" element
715716
, Just _ <- findChildByName ns "w" "pict" element =
716717
let drawing = findElement (elemName ns "v" "imagedata") element
717718
>>= findAttrByName ns "r" "id"
718719
in
719720
case drawing of
720-
-- Todo: check out title and attr for deprecated format.
721721
Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp "" "" bs Nothing)
722722
Nothing -> throwError WrongElem
723+
elemToParPart ns element
724+
| isElem ns "w" "r" element
725+
, Just objectElem <- findChildByName ns "w" "object" element
726+
, Just shapeElem <- findChildByName ns "v" "shape" objectElem
727+
, Just imagedataElem <- findChildByName ns "v" "imagedata" shapeElem
728+
, Just drawingId <- findAttrByName ns "r" "id" imagedataElem
729+
= expandDrawingId drawingId >>= (\(fp, bs) -> return $ Drawing fp "" "" bs Nothing)
723730
-- Chart
724731
elemToParPart ns element
725732
| isElem ns "w" "r" element

test/Tests/Readers/Docx.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ tests = [ testGroup "document"
155155
"VML image"
156156
"docx/image_vml.docx"
157157
"docx/image_vml.native"
158+
, testCompare
159+
"VML image as object"
160+
"docx/image_vml_as_object.docx"
161+
"docx/image_vml_as_object.native"
158162
, testCompare
159163
"inline image in links"
160164
"docx/inline_images.docx"

test/docx/image_vml_as_object.docx

72.5 KB
Binary file not shown.

test/docx/image_vml_as_object.native

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Para [Str "Test",Space,Str "with",Space,Str "object",Space,Str "as",Space,Str "image:"]
2+
,Para [Image ("",[],[]) [] ("media/image1.emf","")]]

0 commit comments

Comments
 (0)