From 9830fd36dbdb72c79703b0c61efc027fba793c5a Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 17 Mar 2013 08:36:26 +0100 Subject: 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 --- sfx2/qa/complex/sfx2/DocumentProperties.java | 10 +++++----- sfx2/source/appl/sfxpicklist.cxx | 2 +- sfx2/source/bastyp/frmhtmlw.cxx | 4 ++-- sfx2/source/dialog/dinfdlg.cxx | 16 ++++++++-------- sfx2/source/dialog/versdlg.cxx | 2 +- sfx2/source/doc/SfxDocumentMetaData.cxx | 8 ++++---- sfx2/source/doc/objcont.cxx | 8 ++++---- sfx2/source/doc/oleprops.cxx | 6 +++--- sfx2/source/view/viewprn.cxx | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) (limited to 'sfx2') diff --git a/sfx2/qa/complex/sfx2/DocumentProperties.java b/sfx2/qa/complex/sfx2/DocumentProperties.java index 17faed72d440..5db9174d7a23 100644 --- a/sfx2/qa/complex/sfx2/DocumentProperties.java +++ b/sfx2/qa/complex/sfx2/DocumentProperties.java @@ -349,7 +349,7 @@ public class DocumentProperties dur.Hours = 777; dur.Minutes = 666; dur.Seconds = 555; - dur.MilliSeconds = 444; + dur.NanoSeconds = 444444444; udpc.addProperty("Frobnicate", PropertyAttribute.REMOVABLE, b); udpc.addProperty("FrobDuration", PropertyAttribute.REMOVABLE, dur); @@ -426,7 +426,7 @@ public class DocumentProperties // this is now a Duration! Duration t_dur = new Duration(false, (short)0, (short)0, (short)0, t.Hours, t.Minutes, t.Seconds, - (short)(10 * t.HundredthSeconds)); + t.NanoSeconds); assertTrue("UserDefined time", eqDuration(t_dur, (Duration) udps.getPropertyValue("FrobDuration2"))); assertTrue("UserDefined date", eqDate(date, (Date) @@ -476,7 +476,7 @@ public class DocumentProperties return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day && a.Hours == b.Hours && a.Minutes == b.Minutes && a.Seconds == b.Seconds - && a.HundredthSeconds == b.HundredthSeconds; + && a.NanoSeconds == b.NanoSeconds; } boolean eqDate(Date a, Date b) { @@ -486,14 +486,14 @@ public class DocumentProperties boolean eqTime(Time a, Time b) { return a.Hours == b.Hours && a.Minutes == b.Minutes && a.Seconds == b.Seconds - && a.HundredthSeconds == b.HundredthSeconds; + && a.NanoSeconds == b.NanoSeconds; } boolean eqDuration(Duration a, Duration b) { return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days && a.Hours == b.Hours && a.Minutes == b.Minutes && a.Seconds == b.Seconds - && a.MilliSeconds == b.MilliSeconds + && a.NanoSeconds == b.NanoSeconds && a.Negative == b.Negative; } diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index 1da4614d1255..f18b1db0b3da 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -365,7 +365,7 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint ) xDocProps->setAuthor( SvtUserOptions().GetFullName() ); ::DateTime now( ::DateTime::SYSTEM ); xDocProps->setCreationDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ) ); } diff --git a/sfx2/source/bastyp/frmhtmlw.cxx b/sfx2/source/bastyp/frmhtmlw.cxx index 1f24a5952288..e822d9d7dc0d 100644 --- a/sfx2/source/bastyp/frmhtmlw.cxx +++ b/sfx2/source/bastyp/frmhtmlw.cxx @@ -172,7 +172,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const String& rBaseURL, // created ::util::DateTime uDT = i_xDocProps->getCreationDate(); Date aD(uDT.Day, uDT.Month, uDT.Year); - Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds); + Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); String sOut = OUString::number(aD.GetDate()); sOut += ';'; sOut += OUString::number(aT.GetTime()); @@ -188,7 +188,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const String& rBaseURL, // changed uDT = i_xDocProps->getModificationDate(); Date aD2(uDT.Day, uDT.Month, uDT.Year); - Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds); + Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); sOut = OUString::number(aD2.GetDate()); sOut += ';'; sOut += OUString::number(aT2.GetTime()); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index b198ca24822b..e13e557241cb 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -99,7 +99,7 @@ bool operator==(const util::DateTime &i_rLeft, const util::DateTime &i_rRight) && i_rLeft.Hours == i_rRight.Hours && i_rLeft.Minutes == i_rRight.Minutes && i_rLeft.Seconds == i_rRight.Seconds - && i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds; + && i_rLeft.NanoSeconds == i_rRight.NanoSeconds; } // STATIC DATA ----------------------------------------------------------- @@ -174,7 +174,7 @@ String ConvertDateTime_Impl( const String& rName, const util::DateTime& uDT, const LocaleDataWrapper& rWrapper ) { Date aD(uDT.Day, uDT.Month, uDT.Year); - Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds); + Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); const String pDelim ( ", " ); String aStr( rWrapper.getDate( aD ) ); aStr += pDelim; @@ -352,7 +352,7 @@ void SfxDocumentInfoItem::resetUserData(const OUString & i_rAuthor) setAuthor(i_rAuthor); DateTime now( DateTime::SYSTEM ); setCreationDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ) ); setModifiedBy(OUString()); setPrintedBy(OUString()); @@ -798,7 +798,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, DeleteHdl) const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); DateTime now( DateTime::SYSTEM ); util::DateTime uDT( - now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ); m_pCreateValFt->SetText( ConvertDateTime_Impl( aName, uDT, rLocaleWrapper ) ); OUString aEmpty; @@ -1241,7 +1241,7 @@ DurationDialog_Impl::DurationDialog_Impl( aHourNF.SetValue(rDuration.Hours ); aMinuteNF.SetValue(rDuration.Minutes); aSecondNF.SetValue(rDuration.Seconds); - aMSecondNF.SetValue(rDuration.MilliSeconds); + aMSecondNF.SetValue(rDuration.NanoSeconds); } DurationDialog_Impl::~DurationDialog_Impl() @@ -1258,7 +1258,7 @@ util::Duration DurationDialog_Impl::GetDuration() const aRet.Hours = aHourNF.GetValue( ); aRet.Minutes = aMinuteNF.GetValue(); aRet.Seconds = aSecondNF.GetValue(); - aRet.MilliSeconds = aMSecondNF.GetValue(); + aRet.NanoSeconds = aMSecondNF.GetValue(); return aRet; } @@ -1752,7 +1752,7 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny ) else if ( rAny >>= aTmpDateTime ) { pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) ); - pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.HundredthSeconds ) ); + pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) ); nType = CUSTOM_TYPE_DATETIME; } @@ -1866,7 +1866,7 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() c { Date aTmpDate = pLine->m_aDateField.GetDate(); Time aTmpTime = pLine->m_aTimeField.GetTime(); - util::DateTime aDateTime(aTmpTime.Get100Sec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(), + util::DateTime aDateTime(aTmpTime.GetNanoSec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(), aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() ); aPropertiesSeq[i].Value <<= aDateTime; } diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index 25db61b2d705..41ade0fe68d1 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -105,7 +105,7 @@ SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTa pInfo->aAuthor = rInfo[n].Author; Date aDate ( rInfo[n].TimeStamp.Day, rInfo[n].TimeStamp.Month, rInfo[n].TimeStamp.Year ); - Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.HundredthSeconds ); + Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.NanoSeconds ); pInfo->aCreationDate = DateTime( aDate, aTime ); aTableList.push_back( pInfo ); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index e4a03d0be849..d83b1950dc7d 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -412,7 +412,7 @@ bool operator== (const css::util::DateTime &i_rLeft, && i_rLeft.Hours == i_rRight.Hours && i_rLeft.Minutes == i_rRight.Minutes && i_rLeft.Seconds == i_rRight.Seconds - && i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds; + && i_rLeft.NanoSeconds == i_rRight.NanoSeconds; } // NB: keep these two arrays in sync! @@ -633,7 +633,7 @@ OUString SAL_CALL durationToText(sal_Int32 i_value) throw () ud.Hours = static_cast((i_value % (24 * 3600)) / 3600); ud.Minutes = static_cast((i_value % 3600) / 60); ud.Seconds = static_cast(i_value % 60); - ud.MilliSeconds = 0; + ud.NanoSeconds = 0; return durationToText(ud); } @@ -967,7 +967,7 @@ propsToStrings(css::uno::Reference const & i_xPropSet) ud.Hours = ut.Hours; ud.Minutes = ut.Minutes; ud.Seconds = ut.Seconds; - ud.MilliSeconds = 10 * ut.HundredthSeconds; + ud.NanoSeconds = ut.NanoSeconds; values.push_back(durationToText(ud)); as.push_back(std::make_pair(vt, OUString("time"))); @@ -1837,7 +1837,7 @@ SfxDocumentMetaData::resetUserData(const OUString & the_value) bool bModified( false ); bModified |= setMetaText("meta:initial-creator", the_value); ::DateTime now( ::DateTime::SYSTEM ); - css::util::DateTime uDT(now.Get100Sec(), now.GetSec(), now.GetMin(), + css::util::DateTime uDT(now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear()); bModified |= setMetaText("meta:creation-date", dateTimeToText(uDT)); bModified |= setMetaText("dc:creator", OUString()); diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 7f3a31e5213a..86883d10e6b4 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -100,8 +100,8 @@ bool operator> (const util::DateTime& i_rLeft, const util::DateTime& i_rRight) if ( i_rLeft.Seconds != i_rRight.Seconds ) return i_rLeft.Seconds > i_rRight.Seconds; - if ( i_rLeft.HundredthSeconds != i_rRight.HundredthSeconds ) - return i_rLeft.HundredthSeconds > i_rRight.HundredthSeconds; + if ( i_rLeft.NanoSeconds != i_rRight.NanoSeconds ) + return i_rLeft.NanoSeconds > i_rRight.NanoSeconds; return sal_False; } @@ -202,7 +202,7 @@ void SfxObjectShell::UpdateDocInfoForSave() // update ModificationAuthor, revision and editing time ::DateTime now( ::DateTime::SYSTEM ); xDocProps->setModificationDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ) ); xDocProps->setModifiedBy( aUserName ); @@ -833,7 +833,7 @@ void SfxObjectShell::ResetFromTemplate( const String& rTemplateName, const Strin ::DateTime now( ::DateTime::SYSTEM ); xDocProps->setTemplateDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ) ); diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx index 48f19c324a16..6ecc27a05e84 100644 --- a/sfx2/source/doc/oleprops.cxx +++ b/sfx2/source/doc/oleprops.cxx @@ -52,7 +52,7 @@ bool operator==(const util::DateTime &i_rLeft, const util::DateTime &i_rRight) && i_rLeft.Hours == i_rRight.Hours && i_rLeft.Minutes == i_rRight.Minutes && i_rLeft.Seconds == i_rRight.Seconds - && i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds; + && i_rLeft.NanoSeconds == i_rRight.NanoSeconds; } static @@ -586,7 +586,7 @@ void SfxOleFileTimeProperty::ImplLoad( SvStream& rStrm ) maDateTime.Hours = aDateTime.GetHour(); maDateTime.Minutes = aDateTime.GetMin(); maDateTime.Seconds = aDateTime.GetSec(); - maDateTime.HundredthSeconds = aDateTime.Get100Sec(); + maDateTime.NanoSeconds = aDateTime.GetNanoSec(); } void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm ) @@ -600,7 +600,7 @@ void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm ) static_cast< sal_uIntPtr >( maDateTime.Hours ), static_cast< sal_uIntPtr >( maDateTime.Minutes ), static_cast< sal_uIntPtr >( maDateTime.Seconds ), - static_cast< sal_uIntPtr >( maDateTime.HundredthSeconds ) ) ); + static_cast< sal_uIntPtr >( maDateTime.NanoSeconds ) ) ); // invalid time stamp is not converted to UTC // heuristic to detect editing durations (which we assume to be < 1 year): // check only the year, not the entire date diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index f518bae40dbb..3c2fff7a146f 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -317,7 +317,7 @@ void SfxPrinterController::jobStarted() ::DateTime now( ::DateTime::SYSTEM ); xDocProps->setPrintDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), + now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear() ) ); SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ), mpObjectShell ) ); -- cgit v1.2.3