https://bz.apache.org/ooo/show_bug.cgi?id=118072

--- Comment #10 from [email protected] ---
This patch will get this particular file's formula to load successfully:

---snip---
diff --git a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index fea1af2aea..bb5ec7bf75 100644
--- a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -6833,10 +6833,20 @@
                <xsl:if test="@ss:Formula">
                        <!-- formula translation from Excel to Calc -->
                        <xsl:variable name="calc-formula">
+                               <xsl:variable name="expr">
+                                       <xsl:choose>
+                                               <xsl:when
test="starts-with(@ss:Formula, '=')">
+                                                       <xsl:value-of
select="@ss:Formula"/>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of
select="concat('=',@ss:Formula)"/>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
                                <xsl:call-template name="translate-expression">
                                        <xsl:with-param name="cell-row-pos"
select="$row-pos"/>
                                        <xsl:with-param name="cell-column-pos"
select="$col-pos"/>
-                                       <xsl:with-param name="expression"
select="@ss:Formula"/>
+                                       <xsl:with-param name="expression"
select="$expr"/>
                                        <xsl:with-param name="return-value"
select="''"/>
                                </xsl:call-template>
                        </xsl:variable>
---snip---


How does it work? When parsing @ss:Formula, it checks whether the formula
starts with "=", and if not, prefixes one, before calling
"translate-expression" with it.

However, while that will fix loading this file, "translate-expression" is also
called from other places:

translate-condition when x:Qualifier is "Between" or "NotBetween".
ss:Worksheet table:table ss:Table descendant::ss:NamedRange[@ss:Name =
    'Print_Area' and contains( @ss:RefersTo, '!R')].
create-cell-table-attributes.
Names (for named ranges).
transform-advanced-filter table:database-range target-range and
    condition-range.
x:AutoFilter range.
x:DataValidation table:base-cell-address range.

Do these other places also need to handle missing '=' prefixes?

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.

Reply via email to