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/08 04:34:13 UTC

[openoffice] 02/02: When importing SpreadsheetML ss:DateTime, import the entire value, not only the first 19 characters.

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

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

commit 48b860b608609900a6c5e4cdcec7cd53e91e372e
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 14 06:58:10 2023 +0200

    When importing SpreadsheetML ss:DateTime, import the entire value, not only the
    first 19 characters.
    
    Add a test file for this bug.
    
    Fixes: #128554 - Office 2003 SpreadsheetML: fractional seconds are silently
           ignored during import
    Patch by: me
    
    (cherry picked from commit 195282cf3d8bfaa9e1cec43b093251d9df87f4ba)
---
 .../import/spreadsheetml/spreadsheetml2ooo.xsl     |   2 +-
 .../sc/fvt/Bug128554FractionalSecondsIgnored.xml   | 108 +++++++++++++++++++++
 .../source/fvt/uno/sc/formula/TestFormulaDocs.java |   9 +-
 3 files changed, 114 insertions(+), 5 deletions(-)

diff --git a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
index 10d2d1c622..767a2b66bf 100644
--- a/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
+++ b/main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
@@ -6868,7 +6868,7 @@
 				<xsl:when test="ss:Data/@ss:Type = 'DateTime'">
 					<xsl:attribute name="office:value-type">date</xsl:attribute>
 					<xsl:attribute name="office:date-value">
-						<xsl:value-of select="substring(ss:Data, 1, 19)"/>
+						<xsl:value-of select="ss:Data"/>
 					</xsl:attribute>
 				</xsl:when>
 				<xsl:when test="ss:Data/@ss:Type = 'Boolean'">
diff --git a/test/testuno/data/uno/sc/fvt/Bug128554FractionalSecondsIgnored.xml b/test/testuno/data/uno/sc/fvt/Bug128554FractionalSecondsIgnored.xml
new file mode 100644
index 0000000000..573cc4d284
--- /dev/null
+++ b/test/testuno/data/uno/sc/fvt/Bug128554FractionalSecondsIgnored.xml
@@ -0,0 +1,108 @@
+<?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>#000000</RGB>
+      </Color>
+      <Color>
+        <Index>4</Index>
+        <RGB>#c0c0c0</RGB>
+      </Color>
+      <Color>
+        <Index>5</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="Normal" ss:Name="Normal">
+      <Alignment ss:Vertical="Bottom"/>
+      <Font ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>
+    </Style>
+    <Style ss:ID="co1"/>
+    <Style ss:ID="co2"/>
+    <Style ss:ID="co3"/>
+    <Style ss:ID="co4"/>
+    <Style ss:ID="co5"/>
+    <Style ss:ID="co6"/>
+    <Style ss:ID="ta1"/>
+    <Style ss:ID="ce1">
+      <Font ss:Bold="1" ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>
+    </Style>
+    <Style ss:ID="ce2">
+      <NumberFormat ss:Format="General Date"/>
+    </Style>
+  </Styles>
+  <ss:Worksheet ss:Name="Sheet1">
+    <Table ss:StyleID="ta1">
+      <Column ss:Width="64.4904"/>
+      <Column ss:Width="134.784"/>
+      <Column ss:Width="115.5096"/>
+      <Column ss:Width="93.204"/>
+      <Column ss:Width="119.5344"/>
+      <Column ss:Width="64.4904"/>
+      <Row ss:AutoFitHeight="0" ss:Height="11.988">
+        <Cell>
+          <Data ss:Type="String">TestID</Data>
+        </Cell>
+        <Cell>
+          <Data ss:Type="String">Date/Time</Data>
+        </Cell>
+        <Cell>
+          <Data ss:Type="String">In numeric form</Data>
+        </Cell>
+        <Cell>
+          <Data ss:Type="String">Should be</Data>
+        </Cell>
+        <Cell>
+          <Data ss:Type="String">TestOK</Data>
+        </Cell>
+      </Row>
+      <Row ss:AutoFitHeight="0" ss:Height="11.988">
+        <Cell ss:StyleID="Default">
+          <Data ss:Type="String">Time</Data>
+        </Cell>
+        <Cell ss:StyleID="ce2">
+          <Data ss:Type="DateTime">2023-01-14T04:05:06.78000</Data>
+        </Cell>
+        <Cell ss:StyleID="Default" ss:Formula="=VALUE(RC[-1])">
+          <Data ss:Type="Number">44940.1702173611</Data>
+        </Cell>
+        <Cell ss:StyleID="Default">
+          <Data ss:Type="Number">44940.1702173611</Data>
+        </Cell>
+        <Cell ss:StyleID="Default" ss:Formula="=RC[-2]=RC[-1]">
+          <Data ss:Type="Boolean">1</Data>
+        </Cell>
+      </Row>
+    </Table>
+    <x:WorksheetOptions/>
+  </ss:Worksheet>
+</Workbook>
diff --git a/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java b/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
index ad14ba96a1..047f379bab 100644
--- a/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
+++ b/test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
@@ -68,10 +68,11 @@ public class TestFormulaDocs {
 		return Arrays.asList(new Object[][]{
 				// test documents
 				{"uno/sc/fvt/FormulaTest1.ods", "FormulaTest1.ods"},
-				{"uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods", "StarBasicYearMonthDateHourMinuteSecondTests.ods"},
-				{"uno/sc/fvt/StarBasicCLng.ods", "StarBasicCLng.ods"},
-				{"uno/sc/fvt/DGET on formulas.ods", "DGET on formulas.ods"},
-				{"uno/sc/fvt/Basic Line as variable and Line Input.ods", "Basic Line as variable and Line Input.ods"}
+				{"uno/sc/fvt/StarBasicYearMonthDateHourMinuteSecondTests.ods", "Basic Year Month Date Hour Minute Second Test"},
+				{"uno/sc/fvt/StarBasicCLng.ods", "Basic Convert to Long Function Test"},
+				{"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/Bug128554FractionalSecondsIgnored.xml", "Bug 100989 fractional seconds are silently ignored during import"}
 		});
 	}