legi2odf: fix handling of captions (#6132)

This commit is contained in:
Frédéric Péters 2014-12-10 15:28:45 +01:00
parent b1e8335e09
commit cbeb691a41
2 changed files with 27 additions and 1 deletions

View File

@ -336,7 +336,32 @@
</xsl:template>
<xsl:template match="mediaobject" mode="inline">
<xsl:apply-templates/>
<xsl:choose>
<xsl:when test="caption">
<draw:frame>
<xsl:attribute name="svg:width">
<xsl:value-of select="imageobject/imagedata/@width"/>
</xsl:attribute>
<draw:text-box>
<xsl:attribute name="fo:min-height">
<xsl:value-of select="imageobject/imagedata/@depth"/>
</xsl:attribute>
<text:p>
<xsl:apply-templates/>
Illustration
<text:sequence text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">
<xsl:attribute name="text:ref-name">
<xsl:value-of select="caption/@id"/>
</xsl:attribute> X </text:sequence>: <xsl:value-of select="caption"/>
</text:p>
</draw:text-box>
</draw:frame>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="imageobject">

View File

@ -1073,6 +1073,7 @@ def convert_to_legi_xml(content, metadata = None):
# authorized but people got used to do that for prefaces
if len(current_top[0].getchildren()) == 1 and offstructure is None:
offstructure = ET.SubElement(current_top[-1], 'nosection')
handle_elem(offstructure, elem)
elif len(current_top[0].getchildren()) == 2 and offstructure is not None:
handle_elem(offstructure, elem)
if len(offstructure.getchildren()) > 0 and \