This is an automated email from the ASF dual-hosted git repository.
ardovm pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new 0e2453f2c6 Fix a bug in our MS Excel 2003 SpreadsheetML format which
causes importing references to columns 677 to 702 to get corrupted due to wrong
conversion of R1C1 to A1 formula format in the import filter.
0e2453f2c6 is described below
commit 0e2453f2c6aefe854791d727e39b046819f02644
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Sun Nov 16 09:30:56 2025 +0200
Fix a bug in our MS Excel 2003 SpreadsheetML format which causes
importing references to columns 677 to 702 to get corrupted
due to wrong conversion of R1C1 to A1 formula format in the import filter.
Fixes: https://bz.apache.org/ooo/show_bug.cgi?id=128623 - MS Excel 2003
SpreadsheetML import corrupts references to columns 677 to 702
Patch by: me
(cherry picked from commit d10bb11432a25a52b9533a6da97b2f19df0e5725)
---
.../import/spreadsheetml/spreadsheetml2ooo.xsl | 35 ++++++++++++----------
.../data/uno/sc/fvt/Bug81233ColumnZReference.xml | 30 +++++++++++++++++++
2 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index e906725490..d73ff59c18 100644
--- a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -8218,30 +8218,35 @@
<xsl:variable name="zero-based-column-number">
<xsl:value-of select="$column-number - 1"/>
</xsl:variable>
- <xsl:variable name="column-number1">
- <xsl:value-of select="floor( $zero-based-column-number
div 676 )"/>
+ <xsl:variable name="column-div26-minus1">
+ <xsl:value-of select="floor( $zero-based-column-number
div 26 ) - 1"/>
</xsl:variable>
- <xsl:variable name="column-remainder1">
- <xsl:value-of select="floor( $zero-based-column-number
mod 676 )"/>
+ <xsl:variable name="column-number1">
+ <xsl:value-of select="floor ( $column-div26-minus1 div
26 )"/>
</xsl:variable>
<xsl:variable name="column-number2">
- <xsl:value-of select="floor( $column-remainder1 div 26
)"/>
- </xsl:variable>
- <xsl:variable name="column-remainder2">
- <xsl:value-of select="floor( $column-remainder1 mod 26
)"/>
+ <xsl:value-of select="$column-div26-minus1 mod 26 + 1"/>
</xsl:variable>
<xsl:variable name="column-number3">
- <xsl:value-of select="( $column-remainder2 mod 26 ) +
1"/>
+ <xsl:value-of select="( $zero-based-column-number mod
26 ) + 1"/>
</xsl:variable>
<xsl:variable name="column-character1">
- <xsl:call-template name="number-to-character">
- <xsl:with-param name="number"
select="$column-number1"/>
- </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="($zero-based-column-number >
701)">
+ <xsl:call-template
name="number-to-character">
+ <xsl:with-param name="number"
select="$column-number1"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
</xsl:variable>
<xsl:variable name="column-character2">
- <xsl:call-template name="number-to-character">
- <xsl:with-param name="number"
select="$column-number2"/>
- </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="($zero-based-column-number >
25)">
+ <xsl:call-template
name="number-to-character">
+ <xsl:with-param name="number"
select="$column-number2"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
</xsl:variable>
<xsl:variable name="column-character3">
<xsl:call-template name="number-to-character">
diff --git a/test/testuno/data/uno/sc/fvt/Bug81233ColumnZReference.xml
b/test/testuno/data/uno/sc/fvt/Bug81233ColumnZReference.xml
index f37f9da884..0e10608821 100644
--- a/test/testuno/data/uno/sc/fvt/Bug81233ColumnZReference.xml
+++ b/test/testuno/data/uno/sc/fvt/Bug81233ColumnZReference.xml
@@ -64,6 +64,12 @@
<Cell>
<Data ss:Type="String">AA test</Data>
</Cell>
+ <Cell ss:Index="702">
+ <Data ss:Type="String">ZZ test</Data>
+ </Cell>
+ <Cell ss:Index="703">
+ <Data ss:Type="String">AAA test</Data>
+ </Cell>
<Cell ss:Index="1024">
<Data ss:Type="String">AMJ test</Data>
</Cell>
@@ -84,6 +90,12 @@
<Cell ss:Formula="=R[-1]C">
<Data ss:Type="String">AA test</Data>
</Cell>
+ <Cell ss:Index="702" ss:Formula="=R[-1]C">
+ <Data ss:Type="String">ZZ test</Data>
+ </Cell>
+ <Cell ss:Index="703" ss:Formula="=R[-1]C">
+ <Data ss:Type="String">AAA test</Data>
+ </Cell>
<Cell ss:Index="1024" ss:Formula="=R[-1]C">
<Data ss:Type="String">AMJ test</Data>
</Cell>
@@ -106,6 +118,24 @@
</Cell>
<Cell ss:Index="1024"/>
</Row>
+ <Row ss:Height="12.1032">
+ <Cell>
+ <Data ss:Type="String">ZZ2=ZZ1? (702nd column.)</Data>
+ </Cell>
+ <Cell ss:Formula="=R2C702=R1C702">
+ <Data ss:Type="Boolean">1</Data>
+ </Cell>
+ <Cell ss:Index="702"/>
+ </Row>
+ <Row ss:Height="13.4064">
+ <Cell>
+ <ss:Data xmlns="http://www.w3.org/TR/REC-html40"
ss:Type="String">AAA2=AAA1? (703rd column.)</ss:Data>
+ </Cell>
+ <Cell ss:Formula="=R2C703=R1C703">
+ <Data ss:Type="Boolean">1</Data>
+ </Cell>
+ <Cell ss:Index="703"/>
+ </Row>
<Row ss:Height="13.4064">
<Cell>
<ss:Data xmlns="http://www.w3.org/TR/REC-html40"
ss:Type="String">AMJ2=AMJ1? (1024th column.)</ss:Data>