Commit a5ca2ad72d07e16ad511309ffeb0b7b4c571a164

Authored by Colomban Wendling
1 parent 1e5cc0f6
Exists in python

Try and make stripped paragraphs around frames not take vertical space

We cannot remove them entirely because their style will sometimes
affect more than just the paragraph, but we should make sure it
doesn't account for vertical space as it was likely to align with
the frames.
Showing 1 changed file with 34 additions and 1 deletions   Show diff stats
strip-frames.xsl
... ... @@ -29,6 +29,27 @@
29 29 <xsl:attribute name="fo:line-height">0</xsl:attribute>
30 30 </xsl:element>
31 31 </xsl:element>
  32 + <!-- create a derived style for each paragraph we strip from around a frame,
  33 + which should be identical but for having a 0 line height -->
  34 + <xsl:for-each select="//text:p[draw:frame]">
  35 + <xsl:element name="style:style">
  36 + <xsl:variable name="style-name" select="@text:style-name"/>
  37 +
  38 + <xsl:attribute name="style:family">paragraph</xsl:attribute>
  39 + <xsl:attribute name="style:name">
  40 + <xsl:value-of select="concat('Placeholder', $style-name)"/>
  41 + </xsl:attribute>
  42 + <xsl:attribute name="style:parent-style-name">
  43 + <xsl:value-of select="$style-name"/>
  44 + </xsl:attribute>
  45 + <!-- copy the original style:master-page-name attribute -->
  46 + <xsl:copy-of select="//office:automatic-styles/style:style[@style:name=$style-name]/@style:master-page-name"/>
  47 +
  48 + <xsl:element name="style:paragraph-properties">
  49 + <xsl:attribute name="fo:line-height">0</xsl:attribute>
  50 + </xsl:element>
  51 + </xsl:element>
  52 + </xsl:for-each>
32 53 </xsl:copy>
33 54 </xsl:template>
34 55  
... ... @@ -48,7 +69,19 @@
48 69 <xsl:template match="text:p[draw:frame]">
49 70 <xsl:comment>Removed outer text:p</xsl:comment>
50 71 <xsl:copy>
51   - <xsl:apply-templates select="@*"/>
  72 + <!-- FIXME: there's probably a better way to do that -->
  73 + <xsl:for-each select="@*">
  74 + <xsl:choose>
  75 + <xsl:when test="../@text:style-name = .">
  76 + <xsl:attribute name="text:style-name">
  77 + <xsl:value-of select="concat('Placeholder', .)"/>
  78 + </xsl:attribute>
  79 + </xsl:when>
  80 + <xsl:otherwise>
  81 + <xsl:apply-templates select="."/>
  82 + </xsl:otherwise>
  83 + </xsl:choose>
  84 + </xsl:for-each>
52 85 </xsl:copy>
53 86 <xsl:apply-templates/>
54 87 </xsl:template>
... ...