diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2013-03-17 08:36:26 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2013-04-18 21:34:46 +0200 |
commit | 9830fd36dbdb72c79703b0c61efc027fba793c5a (patch) | |
tree | 2e9d698e6ca109dc6627adb5c84aa2b635bcfe92 /oox | |
parent | 5aaaf0694b6e3213685563fc3bc90d19b10f5c75 (diff) |
date/time IDL datatypes incompatible change
- nanosecond precision
- signed (allowed negative) year
Also: assorted improvements / bugfixes in date/time handling code.
Some factorisation of copy/pasted code.
Change-Id: I761a1b0b8731c82f19a0c37acbcf43d3c06d6cd6
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 6 | ||||
-rw-r--r-- | oox/source/dump/dumperbase.cxx | 10 | ||||
-rw-r--r-- | oox/source/ppt/comments.cxx | 24 |
3 files changed, 32 insertions, 8 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 73d223eec1bc..28d47c2374c2 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -482,10 +482,12 @@ writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const util::DateTime& rTi FSEND ); char pStr[200]; - snprintf( pStr, sizeof( pStr ), "%d-%02d-%02dT%02d:%02d:%02d.%02dZ", + // FIXME: my guess is that precision greater than millisecond in undesirable + // (forbidden by the standard???) + snprintf( pStr, sizeof( pStr ), "%d-%02d-%02dT%02d:%02d:%02d.%09dZ", rTime.Year, rTime.Month, rTime.Day, rTime.Hours, rTime.Minutes, rTime.Seconds, - rTime.HundredthSeconds ); + rTime.NanoSeconds); pDoc->write( pStr ); diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index dfa19ba4c013..867a66f1f4e3 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -2285,11 +2285,11 @@ util::DateTime InputObjectBase::dumpFileTime( const String& rName ) } // the day aDateTime.Day = static_cast< sal_uInt16 >( nDaysInYear + 1 ); - // number of 1/100 seconds in the day - sal_Int64 nTimeInDay = nFileTime % sal_Int64( 360000 * 24 ); - // 1/100 seconds - aDateTime.HundredthSeconds = static_cast< sal_uInt16 >( nTimeInDay % 100 ); - nTimeInDay /= 100; + // number of nanoseconds in the day + sal_Int64 nTimeInDay = nFileTime % sal_Int64( 86400000000000 ); + // nanoseconds + aDateTime.NanoSeconds = static_cast< sal_uInt32 >( nTimeInDay % 1000000000 ); + nTimeInDay /= 1000000000; // seconds aDateTime.Seconds = static_cast< sal_uInt16 >( nTimeInDay % 60 ); nTimeInDay /= 60; diff --git a/oox/source/ppt/comments.cxx b/oox/source/ppt/comments.cxx index 26725ffdf0f6..bf598c7e3386 100644 --- a/oox/source/ppt/comments.cxx +++ b/oox/source/ppt/comments.cxx @@ -9,6 +9,7 @@ #include "oox/ppt/comments.hxx" #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <rtl/math.hxx> namespace oox { namespace ppt { @@ -37,7 +38,28 @@ void Comment::setDateTime (OUString datetime) datetime = datetime.getToken(1,'T'); aDateTime.Hours = datetime.getToken(0,':').toInt32(); aDateTime.Minutes = datetime.getToken(1,':').toInt32(); - aDateTime.HundredthSeconds = int(datetime.getToken(2,':').toDouble() + .5); + double seconds = datetime.getToken(2,':').toDouble(); + aDateTime.Seconds = floor(seconds); + seconds -= aDateTime.Seconds; + aDateTime.NanoSeconds = ::rtl::math::round(seconds * 1000000000); + const int secondsOverFlow = (aDateTime.Seconds == 60) ? 61 : 60; + // normalise time part of aDateTime + if (aDateTime.NanoSeconds == 1000000000) + { + aDateTime.NanoSeconds = 0; + ++aDateTime.Seconds; + } + if (aDateTime.Seconds == secondsOverFlow) + { + aDateTime.Seconds = 0; + ++aDateTime.Minutes; + } + if (aDateTime.Minutes == 60) + { + aDateTime.Minutes = 0; + ++aDateTime.Hours; + } + // if overflow goes into date, I give up } OUString Comment::getAuthor ( const CommentAuthorList& list ) |