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 /xmloff/source/forms | |
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 'xmloff/source/forms')
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/handler/vcl_time_handler.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/forms/propertyimport.cxx | 20 |
5 files changed, 22 insertions, 18 deletions
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index bc53c1e213bb..b10fa4370ce3 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -1150,7 +1150,7 @@ namespace xmloff aDuration.Hours = aTime.GetHour(); aDuration.Minutes = aTime.GetMin(); aDuration.Seconds = aTime.GetSec(); - aDuration.MilliSeconds = nRepeatDelay % 1000; + aDuration.NanoSeconds = (nRepeatDelay % 1000) * 1000000; OUStringBuffer buf; ::sax::Converter::convertDuration(buf, aDuration); diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 9e2bb7ef6742..9d180b04e65a 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -822,7 +822,7 @@ namespace xmloff aProp.Name = PROPERTY_REPEAT_DELAY; sal_Int32 const nMS = ((aDuration.Hours * 60 + aDuration.Minutes) * 60 - + aDuration.Seconds) * 1000 + aDuration.MilliSeconds; + + aDuration.Seconds) * 1000 + aDuration.NanoSeconds/1000000; aProp.Value <<= nMS; implPushBackPropertyValue(aProp); diff --git a/xmloff/source/forms/handler/vcl_time_handler.cxx b/xmloff/source/forms/handler/vcl_time_handler.cxx index 4339ed75c791..c73392f75a14 100644 --- a/xmloff/source/forms/handler/vcl_time_handler.cxx +++ b/xmloff/source/forms/handler/vcl_time_handler.cxx @@ -64,7 +64,7 @@ namespace xmloff aDuration.Hours = aVCLTime.GetHour(); aDuration.Minutes = aVCLTime.GetMin(); aDuration.Seconds = aVCLTime.GetSec(); - aDuration.MilliSeconds = aVCLTime.Get100Sec() * 10; + aDuration.NanoSeconds = aVCLTime.GetNanoSec(); OUStringBuffer aBuffer; ::sax::Converter::convertDuration( aBuffer, aDuration ); @@ -80,7 +80,7 @@ namespace xmloff if (::sax::Converter::convertDuration( aDuration, i_attributeValue )) { ::Time aVCLTime(aDuration.Hours, aDuration.Minutes, - aDuration.Seconds, aDuration.MilliSeconds / 10); + aDuration.Seconds, aDuration.NanoSeconds); nVCLTime = aVCLTime.GetTime(); } else diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index a0de21a02029..73f5e1dddc2e 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -590,16 +590,20 @@ namespace xmloff } else if (_rValue >>= aTime) { - fValue = ((aTime.Hours * 60 + aTime.Minutes) * 60 + aTime.Seconds) * 100 + aTime.HundredthSeconds; - fValue = fValue / 8640000.0; + fValue = aTime.Hours / static_cast<double>(::Time::hourPerDay) + + aTime.Minutes / static_cast<double>(::Time::minutePerDay) + + aTime.Seconds / static_cast<double>(::Time::secondPerDay) + + aTime.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay); } else if (_rValue >>= aDateTime) { DateTime aToolsDateTime( DateTime::EMPTY ); ::utl::typeConvert(aDateTime, aToolsDateTime); // the time part (the digits behind the comma) - fValue = ((aDateTime.Hours * 60 + aDateTime.Minutes) * 60 + aDateTime.Seconds) * 100 + aDateTime.HundredthSeconds; - fValue = fValue / 8640000.0; + fValue = aTime.Hours / static_cast<double>(::Time::hourPerDay) + + aTime.Minutes / static_cast<double>(::Time::minutePerDay) + + aTime.Seconds / static_cast<double>(::Time::secondPerDay) + + aTime.NanoSeconds / static_cast<double>(::Time::nanoSecPerDay); // plus the data part (the digits in front of the comma) fValue += aToolsDateTime.GetDate(); } diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index a6c667c27166..53f249a13dd3 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -30,6 +30,7 @@ #include "callbacks.hxx" #include "xmloff/xmlnmspe.hxx" #include <tools/date.hxx> +#include <tools/time.hxx> #include <com/sun/star/util/Date.hpp> #include <com/sun/star/util/Time.hpp> #include <com/sun/star/util/DateTime.hpp> @@ -67,16 +68,15 @@ namespace ::com::sun::star::util::Time lcl_getTime(double _nValue) { ::com::sun::star::util::Time aTime; - sal_uInt32 nIntValue = sal_Int32(_nValue * 8640000); - nIntValue *= 8640000; - aTime.HundredthSeconds = (sal_uInt16)( nIntValue % 100 ); - nIntValue /= 100; - aTime.Seconds = (sal_uInt16)( nIntValue % 60 ); - nIntValue /= 60; - aTime.Minutes = (sal_uInt16)( nIntValue % 60 ); - nIntValue /= 60; + sal_uInt64 nIntValue = static_cast<sal_uInt64>(_nValue * ::Time::nanoSecPerDay); + aTime.NanoSeconds = nIntValue % ::Time::nanoSecPerSec; + nIntValue /= ::Time::nanoSecPerSec; + aTime.Seconds = nIntValue % ::Time::secondPerMinute; + nIntValue /= ::Time::secondPerMinute; + aTime.Minutes = nIntValue % ::Time::minutePerHour; + nIntValue /= ::Time::minutePerHour; OSL_ENSURE(nIntValue < 24, "lcl_getTime: more than a day?"); - aTime.Hours = static_cast< sal_uInt16 >( nIntValue ); + aTime.Hours = nIntValue; return aTime; } @@ -219,7 +219,7 @@ Any PropertyConversion::convertString( SvXMLImport& _rImporter, const ::com::sun ::com::sun::star::util::Date aDate = lcl_getDate(nValue); ::com::sun::star::util::DateTime aDateTime; - aDateTime.HundredthSeconds = aTime.HundredthSeconds; + aDateTime.NanoSeconds = aTime.NanoSeconds; aDateTime.Seconds = aTime.Seconds; aDateTime.Minutes = aTime.Minutes; aDateTime.Hours = aTime.Hours; |