odf2legi: ignore missing image files (#6254)

This commit is contained in:
Frédéric Péters 2015-01-08 10:13:35 +01:00
parent 056cba7288
commit 6cb4bd58cd
1 changed files with 17 additions and 15 deletions

View File

@ -326,27 +326,29 @@ def fill_inline(para, elem, invert_bg=False):
elif child.tag == '{%s}frame' % DRAW_NS:
mediaobject = ET.Element('mediaobject')
para.append(mediaobject)
fill_inline(mediaobject, child)
width = child.attrib.get('{%s}width' % SVG_NS)
height = child.attrib.get('{%s}height' % SVG_NS)
image = mediaobject.find('imageobject/imagedata')
if width:
image.attrib['width'] = width
if height:
image.attrib['depth'] = height
if image is not None:
if width:
image.attrib['width'] = width
if height:
image.attrib['depth'] = height
para.append(mediaobject)
elif child.tag == '{%s}image' % DRAW_NS:
imageobject = ET.Element('imageobject')
imagedata = ET.SubElement(imageobject, 'imagedata')
fileref = child.attrib.get('{%s}href' % XLINK_NS)
imagedata.attrib['fileref'] = os.path.basename(fileref)
if fileref.endswith('.jpg'):
imagedata.attrib['format'] = 'JPG'
elif fileref.endswith('.png'):
imagedata.attrib['format'] = 'PNG'
para.append(imageobject)
if fileref is not None:
imageobject = ET.Element('imageobject')
imagedata = ET.SubElement(imageobject, 'imagedata')
imagedata.attrib['fileref'] = os.path.basename(fileref)
if fileref.endswith('.jpg'):
imagedata.attrib['format'] = 'JPG'
elif fileref.endswith('.png'):
imagedata.attrib['format'] = 'PNG'
para.append(imageobject)
else:
print >> sys.stderr, 'W: missing image file'
elif child.tag == '{%s}text-box' % DRAW_NS:
handle_text_box(para, child)