Skip to content

Commit

Permalink
In ODF (19.679.2 of ODF 1.3), the <table:covered-table-cell> element's
Browse files Browse the repository at this point in the history
table:number-columns-repeated attribute has a default value of 1,
meaning the cell spans the cell to its right. However when the XSLT import
filter converts from SpreadsheetML's ss:MergeAcross to ODF's
table:number-columns-repeated, it always inserts a <table:covered-table-cell>
element, and then adds the table:number-columns-repeated attribute only if
it is greater than 1. This breaks when ss:MergeAcross="0", because ODF's
defaulting to 1 ends up occupying an extra empty cell to the right when it
shouldn't.

Fix this by only inserting the <table:covered-table-cell> when
ss:MergeAcross > 0.

Add a test document to prove this.

Fixes #100989 - SpreadsheetML: cell with ss:MergeAcross="0" gets an extra empty cell to the right
Patch by: me
  • Loading branch information
Damjan Jovanovic committed Jan 12, 2023
1 parent 577fe17 commit a896732
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6652,7 +6652,7 @@
</xsl:call-template>
</xsl:element>
<!-- ss:MergeAcross (column spanned) indicates a covered table-cell in Open Document XML-->
<xsl:if test="@ss:MergeAcross">
<xsl:if test="@ss:MergeAcross &gt; 0">
<xsl:element name="table:covered-table-cell">
<xsl:if test="@ss:MergeAcross &gt; 1">
<xsl:attribute name="table:number-columns-repeated">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel">
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<Colors>
<Color>
<Index>3</Index>
<RGB>#c0c0c0</RGB>
</Color>
<Color>
<Index>4</Index>
<RGB>#ff0000</RGB>
</Color>
</Colors>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9000</WindowHeight>
<WindowWidth>13860</WindowWidth>
<WindowTopX>240</WindowTopX>
<WindowTopY>75</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Default"/>
<Style ss:ID="Result" ss:Name="Result">
<Font ss:Bold="1" ss:Italic="1" ss:Underline="Single"/>
</Style>
<Style ss:ID="Result2" ss:Name="Result2">
<Font ss:Bold="1" ss:Italic="1" ss:Underline="Single"/>
<NumberFormat ss:Format="Currency"/>
</Style>
<Style ss:ID="Heading" ss:Name="Heading">
<Alignment ss:Horizontal="Center"/>
<Font ss:Bold="1" ss:Italic="1" ss:Size="16"/>
</Style>
<Style ss:ID="Heading1" ss:Name="Heading1">
<Alignment ss:Horizontal="Center" ss:Rotate="90"/>
<Font ss:Bold="1" ss:Italic="1" ss:Size="16"/>
</Style>
<Style ss:ID="co1"/>
<Style ss:ID="co2"/>
<Style ss:ID="co3"/>
<Style ss:ID="ta1"/>
<Style ss:ID="ce1"/>
</Styles>
<ss:Worksheet ss:Name="Sheet1">
<Table ss:StyleID="ta1">
<Column ss:Width="218.4408"/>
<Column ss:Width="89.9424"/>
<Column ss:Span="4" ss:Width="64.26"/>
<Row ss:Height="12.1032">
<Cell ss:StyleID="ce1">
<Data ss:Type="String">TestID</Data>
</Cell>
<Cell ss:StyleID="ce1">
<Data ss:Type="String">TestOK</Data>
</Cell>
<Cell ss:Index="7"/>
</Row>
<Row ss:Height="23.8392">
<Cell ss:StyleID="Default">
<Data ss:Type="String">A cell with ss:MergeAcross=”0”
doesn't creates an empty column to the right</Data>
</Cell>
<Cell ss:StyleID="Default" ss:Formula="=R2C6=&quot;F2&quot;">
<Data ss:Type="Boolean">0</Data>
</Cell>
<Cell ss:Index="5" ss:MergeAcross="0">
<Data ss:Type="String">E2 with ss:MergeAcross="0"</Data>
</Cell>
<Cell>
<Data ss:Type="String">F2</Data>
</Cell>
</Row>
</Table>
<x:WorksheetOptions/>
</ss:Worksheet>
</Workbook>
3 changes: 2 additions & 1 deletion test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public static Collection<Object[]> data() {
{"uno/sc/fvt/DGET on formulas.ods", "DGET on formulas Test"},
{"uno/sc/fvt/Basic Line as variable and Line Input.ods", "Basic Line as variable and Line Input Test"},
{"uno/sc/fvt/comment-in-single-line-if-then-else.ods", "Basic comment after single line if statement Test"},
{"uno/sc/fvt/Bug81233ColumnZReference.xml", "Bug 81233 column Z reference wrongly converts to column A"}
{"uno/sc/fvt/Bug81233ColumnZReference.xml", "Bug 81233 column Z reference wrongly converts to column A"},
{"uno/sc/fvt/Bug100989MergeAcross0AddsExtraEmptyCell.xml", "Bug 100989 ss:MergeCross=\"0\" adds an extra empty cell to the right"}
});
}

Expand Down

0 comments on commit a896732

Please sign in to comment.