[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Wed Aug 30 19:53:58 UTC 2017


 sc/source/filter/excel/xlroot.cxx |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 4b6844343cdd4c1ddbf2326eabe177b516b8d7f7
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 30 21:48:46 2017 +0200

    Restrict GetDoubleFromDateTime() and GetDateTimeFromDouble() correction
    
    ... to specific 1899-12-30 vs. 1899-12-31 nulldate. Further check is needed to
    do that only for OOXML transitional or dateCompatibility==true.
    
    Change-Id: Ieecd3a5d061f900fbdec5bd9d1bf5ac61b966004

diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 2e9588b6e769..973902fdf42f 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -325,11 +325,16 @@ sal_uInt16 XclRoot::GetBaseYear() const
     return (GetNullDate().GetYear() == 1904) ? 1904 : 1900;
 }
 
+static const DateTime theOurCompatNullDate( Date( 30, 12, 1899 ));
+static const DateTime theExcelCutOverDate( Date( 1, 3, 1900 ));
+
 double XclRoot::GetDoubleFromDateTime( const DateTime& rDateTime ) const
 {
     double fValue = rDateTime - GetNullDate();
     // adjust dates before 1900-03-01 to get correct time values in the range [0.0,1.0)
-    if( rDateTime < DateTime( Date( 1, 3, 1900 ) ) )
+    /* XXX: this is only used when reading BIFF, otherwise we'd have to check
+     * for dateCompatibility==true as mentioned below. */
+    if( rDateTime < theExcelCutOverDate && GetNullDate() == theOurCompatNullDate )
         fValue -= 1.0;
     return fValue;
 }
@@ -338,7 +343,11 @@ DateTime XclRoot::GetDateTimeFromDouble( double fValue ) const
 {
     DateTime aDateTime = GetNullDate() + fValue;
     // adjust dates before 1900-03-01 to get correct time values
-    if( aDateTime < DateTime( Date( 1, 3, 1900 ) ) )
+    /* FIXME: correction should only be done when writing BIFF or OOXML
+     * transitional with dateCompatibility==true (or absent for default true),
+     * but not if strict ISO/IEC 29500 which does not have the Excel error
+     * compatibility and the null date is the same 1899-12-30 as ours. */
+    if( aDateTime < theExcelCutOverDate && GetNullDate() == theOurCompatNullDate )
         aDateTime.AddDays(1);
     return aDateTime;
 }


More information about the Libreoffice-commits mailing list