From 7a18787eda96b2c62549b4f4ae8518a372adb2cb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 27 Jan 2016 10:08:03 +0530 Subject: [PATCH] ODT Input: Fix fallback PNG images generated by LibreOffice 4.x for SVG images not being ignored --- src/odf/odf2xhtml.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/odf/odf2xhtml.py b/src/odf/odf2xhtml.py index f596cf47fe..8ddf6f3056 100644 --- a/src/odf/odf2xhtml.py +++ b/src/odf/odf2xhtml.py @@ -358,6 +358,7 @@ class ODF2XHTML(handler.ContentHandler): def __init__(self, generate_css=True, embedable=False): # Tags self.generate_css = generate_css + self.frame_stack = [] self.elements = { (DCNS, 'title'): (self.s_processcont, self.e_dc_title), (DCNS, 'language'): (self.s_processcont, self.e_dc_contentlanguage), @@ -697,6 +698,7 @@ class ODF2XHTML(handler.ContentHandler): def s_draw_frame(self, tag, attrs): """ A is made into a
in HTML which is then styled """ + self.frame_stack.append([]) anchor_type = attrs.get((TEXTNS,'anchor-type'),'notfound') htmltag = 'div' name = "G-" + attrs.get((DRAWNS,'style-name'), "") @@ -729,6 +731,7 @@ class ODF2XHTML(handler.ContentHandler): """ End the """ self.closetag('div') + self.frame_stack.pop() def s_draw_fill_image(self, tag, attrs): name = attrs.get((DRAWNS,'name'), "NoName") @@ -745,6 +748,10 @@ class ODF2XHTML(handler.ContentHandler): def s_draw_image(self, tag, attrs): """ A becomes an element """ + if self.frame_stack: + if self.frame_stack[-1]: + return + self.frame_stack[-1].append('img') parent = self.tagstack.stackparent() anchor_type = parent.get((TEXTNS,'anchor-type')) imghref = attrs[(XLINKNS,"href")]