[Libreoffice-commits] core.git: Branch 'libreoffice-6-2-8' - filter/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 8 09:41:34 UTC 2019


 filter/source/xslt/odf2xhtml/export/xhtml/body.xsl |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 3e24e1a27b420d5efb83a39c7e9e71c4d7128638
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Sep 27 15:18:25 2019 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Oct 8 11:40:54 2019 +0200

    filter: XHTML: make "calc-heading-digit" a little faster
    
    Exporting OpenDocument-v1.3-csd01-part3-schema.odt to XHTML fails with:
    
    runtime error: file share/xslt/export/xhtml/body.xsl line 1404 element variable
    xsltApplySequenceConstructor: A potential infinite template recursion was detected.
    You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).
    
    Unfortunately the document contains this many headings, and the
    calc-heading-digit computes the value by recursively looking at every
    preceding heading in the document, without TCO apparently...
    
    Try to improve this by using XPath to filter early the headings that are
    effectively ignored in the 3rd xsl:when case anyway: the ones with a
    level lower than the one for which the number is requested; this limits
    the recursive calls to the number of headings on the same level.
    
    Change-Id: Iddf5a91664402a57a0138731ddc9cebb06b0a126
    Reviewed-on: https://gerrit.libreoffice.org/79720
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 86cca6b40ced4031dec4b708ac67b5cbe70cddf9)
    Reviewed-on: https://gerrit.libreoffice.org/79841
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit 059fff471b05c0e26589a1a621b467af5bc6a159)
    Reviewed-on: https://gerrit.libreoffice.org/80008
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index c21840e1689e..63357d1e9b38 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -1401,9 +1401,10 @@
         <xsl:param name="currentoutlineLevel"/>
         <xsl:param name="i" select="1"/>
 
-        <xsl:variable name="precedingoutlineLevel" select="preceding-sibling::text:h[$i]/@text:outline-level"/>
+        <xsl:variable name="precedingHeading" select="preceding-sibling::text:h[@text:outline-level <= $currentoutlineLevel][$i]"/>
+        <xsl:variable name="precedingoutlineLevel" select="$precedingHeading/@text:outline-level"/>
         <!-- tdf#107696: if text:h has attribute "is-list-header" with "true" value, it mustn't be counted for numbering -->
-        <xsl:variable name="precedingoutlineLevel-is-list-header" select="preceding-sibling::text:h[$i][@text:is-list-header='true']/@text:outline-level"/>
+        <xsl:variable name="precedingoutlineLevel-is-list-header" select="$precedingHeading[@text:is-list-header='true']/@text:outline-level"/>
         <xsl:choose>
             <xsl:when test="($currentoutlineLevel = $precedingoutlineLevel) and (not($precedingoutlineLevel-is-list-header)) ">
                 <xsl:call-template name="calc-heading-digit">
@@ -1421,11 +1422,7 @@
                 </xsl:call-template>
             </xsl:when>
             <xsl:when test="$currentoutlineLevel < $precedingoutlineLevel">
-                <xsl:call-template name="calc-heading-digit">
-                    <xsl:with-param name="value" select="$value"/>
-                    <xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
-                    <xsl:with-param name="i" select="$i + 1"/>
-                </xsl:call-template>
+                <xsl:message terminate="yes">this should not happen</xsl:message>
             </xsl:when>
             <xsl:otherwise>
                 <xsl:value-of select="$value"/>


More information about the Libreoffice-commits mailing list