diff options
author | Eike Rathke <erack@redhat.com> | 2017-08-30 21:48:46 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-08-30 21:49:36 +0200 |
commit | 4b6844343cdd4c1ddbf2326eabe177b516b8d7f7 (patch) | |
tree | 01c988f3b8b673ffd0d059a36a2df8f62b6c028e /sc/source | |
parent | 2fdbf463f9d934bca48131df8b51caf36da2e8e5 (diff) |
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
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/excel/xlroot.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
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; } |