Docx reader: Be more specific in parsing images
We not only want "w:drawing", because that could also include charts. Now we specify "w:drawing"//"pic:pic". This shouldn't change behavior at all, but it's a first step toward allowing other sorts of drawing data as well.
This commit is contained in:
parent
7e5220b57c
commit
7539de0287
1 changed files with 10 additions and 6 deletions
|
@ -660,10 +660,12 @@ getTitleAndAlt ns element =
|
|||
elemToParPart :: NameSpaces -> Element -> D ParPart
|
||||
elemToParPart ns element
|
||||
| isElem ns "w" "r" element
|
||||
, Just drawingElem <- findChild (elemName ns "w" "drawing") element =
|
||||
let (title, alt) = getTitleAndAlt ns drawingElem
|
||||
, Just drawingElem <- findChild (elemName ns "w" "drawing") element
|
||||
, pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
|
||||
, Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) drawingElem
|
||||
= let (title, alt) = getTitleAndAlt ns drawingElem
|
||||
a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
drawing = findElement (QName "blip" (Just a_ns) (Just "a")) element
|
||||
drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
|
||||
>>= findAttr (elemName ns "r" "embed")
|
||||
in
|
||||
case drawing of
|
||||
|
@ -764,10 +766,12 @@ elemToExtent drawingElem =
|
|||
|
||||
childElemToRun :: NameSpaces -> Element -> D Run
|
||||
childElemToRun ns element
|
||||
| isElem ns "w" "drawing" element =
|
||||
let (title, alt) = getTitleAndAlt ns element
|
||||
| isElem ns "w" "drawing" element
|
||||
, pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
|
||||
, Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) element
|
||||
= let (title, alt) = getTitleAndAlt ns element
|
||||
a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
drawing = findElement (QName "blip" (Just a_ns) (Just "a")) element
|
||||
drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
|
||||
>>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))
|
||||
in
|
||||
case drawing of
|
||||
|
|
Loading…
Add table
Reference in a new issue