You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2023/02/07 18:06:17 UTC

[openoffice] 04/04: In ODF (19.679.2 of ODF 1.3), the element's 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 element, and then adds the table:number-columns-repeated attribute only if it is greater than 1. This breaks when ss:MergeAcross="0", because O [...]

This is an automated email from the ASF dual-hosted git repository.

damjan pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit d1836b62275253243e873969ddd24d2e327afc76
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Thu Jan 12 03:02:18 2023 +0200

    In ODF (19.679.2 of ODF 1.3), the <table:covered-table-cell> element's
    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
    
    (cherry picked from commit a896732bfcd282115c06407a2f1da77694fa8d19)
---
 .../import/spreadsheetml/spreadsheetml2ooo.xsl     |  2 +-
 .../Bug100989MergeAcross0AddsExtraEmptyCell.xml    | 79 ++++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index fdd38a0978..a395180667 100644
--- a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -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">
diff --git a/test/testuno/data/uno/sc/fvt/Bug100989MergeAcross0AddsExtraEmptyCell.xml b/test/testuno/data/uno/sc/fvt/Bug100989MergeAcross0AddsExtraEmptyCell.xml
new file mode 100644
index 0000000000..2149ce52c8
--- /dev/null
+++ b/test/testuno/data/uno/sc/fvt/Bug100989MergeAcross0AddsExtraEmptyCell.xml
@@ -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>