Kaydet (Commit) 8fdef3e8 authored tarafından Peter Jentsch's avatar Peter Jentsch Kaydeden (comit) David Tardon

optimized handling of ConditionalFormatting elements

Removed ill-performing key definitions.
Also fixes bug with bogus expression quoting within formatting conditions.

Change-Id: Iab9b26f30ac7f780acb8a4e1397aaf2f4fa490f4
üst 8bed4206
......@@ -764,19 +764,23 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:key match="/ss:Workbook/ss:Worksheet/ss:Table" name="tableWithConditional" use="following-sibling::x:ConditionalFormatting"/>
<xsl:key match="ss:Table/ss:Row/ss:Cell/@ss:StyleID" name="tableStyleIDs" use="ancestor::ss:Table"/>
<xsl:key name="definedStyleIds" match="/ss:Workbook/ss:Styles/ss:Style/@ss:ID" use="string(.)"/>
<xsl:variable name="defaultStyle" select="/ss:Workbook/ss:Styles/ss:Style[@ss:ID='Default']/@ss:ID"></xsl:variable>
<xsl:key name="styleId" match="@ss:StyleID" use="."/>
<xsl:template name="CondFormat_automatic_style">
<!-- For each conditionalFormatting We inject a new style, which is a child of the current found style -->
<xsl:for-each select="/ss:Workbook/ss:Worksheet/x:ConditionalFormatting">
<xsl:variable name="table-pos" select="count(../preceding-sibling::ss:Worksheet)+1"/>
<xsl:variable name="conditions" select="count(preceding-sibling::x:ConditionalFormatting)+1"/>
<xsl:for-each select="/ss:Workbook/ss:Worksheet[x:ConditionalFormatting]">
<xsl:variable name="table-pos" select="count(preceding-sibling::ss:Worksheet)+1"/>
<xsl:variable name="styleIdsUsedByTable" select="$defaultStyle | key('definedStyleIds', ss:Table/ss:Row/ss:Cell/@ss:StyleID)"/>
<xsl:for-each select="x:ConditionalFormatting">
<xsl:variable name="conditions" select="position()"/>
<xsl:variable name="conditionalFormatting" select="."/>
<!-- we want to loop over the distinct styleId attribute values of all cells within the table related to the current conditional formatting. -->
<!-- We'd need to add the anonymous style id "Default" to the mix. -->
<!-- for all 'ssStyle/@ss:ID's, which are in tables connected within this conditional formatting -->
<xsl:for-each select="key('tableStyleIDs', key('tableWithConditional', .)) [generate-id(.) = generate-id(key('styleId', .)[1])] ">
<!-- sort the style ID by their naming -->
<xsl:sort select="."/>
<!-- <xsl:for-each select="key('tableStyleIDs', generate-id(preceding-sibling::ss:Table)) [generate-id(.) = generate-id(key('styleId', .)[1])] "> -->
<xsl:for-each select="$styleIdsUsedByTable">
<xsl:element name="style:style">
<xsl:attribute name="style:name">
<xsl:call-template name="encode-as-nc-name">
......@@ -877,6 +881,7 @@
</xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="translate-condition">
<xsl:param name="cell-row-pos"/>
......@@ -895,31 +900,6 @@
<xsl:variable name="qualifier" select="x:Qualifier"/>
<xsl:variable name="first-value" select="x:Value1"/>
<xsl:choose>
<xsl:when test="$qualifier = 'Equal'">
<xsl:choose>
<xsl:when test="starts-with($first-value,'&quot;')">
<xsl:value-of select="concat('cell-content()=',$address-value)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('cell-content()=[',$address-value,']')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$qualifier = 'Less'">
<xsl:value-of select="concat('cell-content()&lt;[',$address-value,']')"/>
</xsl:when>
<xsl:when test="$qualifier = 'Greater'">
<xsl:value-of select="concat('cell-content()&gt;[',$address-value,']')"/>
</xsl:when>
<xsl:when test="$qualifier = 'LessOrEqual'">
<xsl:value-of select="concat('cell-content()&lt;=[',$address-value,']')"/>
</xsl:when>
<xsl:when test="$qualifier = 'GreaterOrEqual'">
<xsl:value-of select="concat('cell-content()&gt;=[',$address-value,']')"/>
</xsl:when>
<xsl:when test="$qualifier = 'NotEqual'">
<xsl:value-of select="concat('cell-content()!=[',$address-value,']')"/>
</xsl:when>
<xsl:when test="$qualifier = 'Between'">
<xsl:variable name="second-value">
<xsl:call-template name="translate-expression">
......@@ -929,7 +909,7 @@
<xsl:with-param name="return-value" select="''"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat('cell-content-is-between([',$address-value,'],[',$second-value,'])')"/>
<xsl:value-of select="concat('cell-content-is-between(',$address-value,',',$second-value,')')"/>
</xsl:when>
<xsl:when test="$qualifier = 'NotBetween'">
<xsl:variable name="second-value">
......@@ -940,8 +920,22 @@
<xsl:with-param name="return-value" select="''"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat('cell-content-is-not-between([',$address-value,'],[',$second-value,'])')"/>
<xsl:value-of select="concat('cell-content-is-not-between(',$address-value,',',$second-value,')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="translatedQualifier">
<xsl:choose>
<xsl:when test="$qualifier = 'Equal'">=</xsl:when>
<xsl:when test="$qualifier = 'Less'">&lt;</xsl:when>
<xsl:when test="$qualifier = 'Greater'">&gt;</xsl:when>
<xsl:when test="$qualifier = 'LessOrEqual'">&lt;=</xsl:when>
<xsl:when test="$qualifier = 'GreaterOrEqual'">&gt;=</xsl:when>
<xsl:when test="$qualifier = 'NotEqual'">!=</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat('cell-content()', $translatedQualifier, $address-value)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment