diff options
author | Noel Grandin <noel@peralex.com> | 2015-01-11 13:35:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-01-13 15:24:04 +0000 |
commit | c32a5a3b8e2e3a49ac9f1fd3f2872b00612676b7 (patch) | |
tree | cb2de3eab8dbbcff359d367177d91b67725e1b69 /sw | |
parent | 86db1702d72a103ffeafc69dcaa63318539c147a (diff) |
simplify Date/Time/DateTime conversion code
add constructors to Date/DateTime/Time,
that take the css::util counterparts,
to simplify code converting between these type
Change-Id: I4b03da02c63f65b6ec18cb4d6ecc3859bdef1ff7
Reviewed-on: https://gerrit.libreoffice.org/13855
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/doccomp.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/doc/docglbl.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 37 | ||||
-rw-r--r-- | sw/source/core/fields/flddat.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/unocore/unoredline.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 5 |
7 files changed, 17 insertions, 78 deletions
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 5e05f7bccd23..93282c70c3d0 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1616,14 +1616,11 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) util::DateTime uDT( 1 == xDocProps->getEditingCycles() ? xDocProps->getCreationDate() : xDocProps->getModificationDate() ); - Date d(uDT.Day, uDT.Month, uDT.Year); - tools::Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - DateTime aDT(d,t); if( !aTmp.isEmpty() ) { nAuthor = rDoc.getIDocumentRedlineAccess().InsertRedlineAuthor( aTmp ); - aTimeStamp = aDT; + aTimeStamp = DateTime(uDT); } } } diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index aa81d02924e0..017a4f5da4b6 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -282,11 +282,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties"); // the GlobalDoc is the template xDocProps->setTemplateName(OUString()); - ::util::DateTime uDT(aTmplDate.GetNanoSec(), - aTmplDate.GetSec(), aTmplDate.GetMin(), - aTmplDate.GetHour(), aTmplDate.GetDay(), - aTmplDate.GetMonth(), aTmplDate.GetYear(), - false ); + ::util::DateTime uDT = aTmplDate.GetUNODateTime(); xDocProps->setTemplateDate(uDT); xDocProps->setTemplateURL(rPath); // Set the new doc's title to the text of the "split para". diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index fecc1b801d2f..4e0355f14f05 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -931,8 +931,8 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, { OUString aName( xDocProps->getAuthor() ); util::DateTime uDT( xDocProps->getCreationDate() ); - Date aD(uDT.Day, uDT.Month, uDT.Year); - tools::Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); + Date aD(uDT); + tools::Time aT(uDT); DateTime aDate(aD,aT); if( nSub == DI_CREATE ) ; // das wars schon!! @@ -940,19 +940,13 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, { aName = xDocProps->getModifiedBy(); uDT = xDocProps->getModificationDate(); - Date bD(uDT.Day, uDT.Month, uDT.Year); - tools::Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - DateTime bDate(bD,bT); - aDate = bDate; + aDate = DateTime(uDT); } else if( nSub == DI_PRINT ) { aName = xDocProps->getPrintedBy(); uDT = xDocProps->getPrintDate(); - Date bD(uDT.Day, uDT.Month, uDT.Year); - tools::Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - DateTime bDate(bD,bT); - aDate = bDate; + aDate = DateTime(uDT); } else break; @@ -1776,24 +1770,13 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } case FIELD_PROP_DATE: { - util::Date aSetDate; - aSetDate.Day = aDateTime.GetDay(); - aSetDate.Month = aDateTime.GetMonth(); - aSetDate.Year = aDateTime.GetYear(); + css::util::Date aSetDate = aDateTime.GetUNODate(); rAny.setValue(&aSetDate, ::cppu::UnoType<util::Date>::get()); } break; case FIELD_PROP_DATE_TIME: { - util::DateTime DateTimeValue; - DateTimeValue.NanoSeconds = aDateTime.GetNanoSec(); - DateTimeValue.Seconds = aDateTime.GetSec(); - DateTimeValue.Minutes = aDateTime.GetMin(); - DateTimeValue.Hours = aDateTime.GetHour(); - DateTimeValue.Day = aDateTime.GetDay(); - DateTimeValue.Month = aDateTime.GetMonth(); - DateTimeValue.Year = aDateTime.GetYear(); - rAny <<= DateTimeValue; + rAny <<= aDateTime.GetUNODateTime(); } break; default: @@ -1839,13 +1822,7 @@ bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) util::DateTime aDateTimeValue; if(!(rAny >>= aDateTimeValue)) return false; - aDateTime.SetNanoSec(aDateTimeValue.NanoSeconds); - aDateTime.SetSec(aDateTimeValue.Seconds); - aDateTime.SetMin(aDateTimeValue.Minutes); - aDateTime.SetHour(aDateTimeValue.Hours); - aDateTime.SetDay(aDateTimeValue.Day); - aDateTime.SetMonth(aDateTimeValue.Month); - aDateTime.SetYear(aDateTimeValue.Year); + aDateTime = DateTime(aDateTimeValue); } break; default: diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx index 96c47b0ac564..2df1dd1afc53 100644 --- a/sw/source/core/fields/flddat.cxx +++ b/sw/source/core/fields/flddat.cxx @@ -178,16 +178,7 @@ bool SwDateTimeField::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const case FIELD_PROP_DATE_TIME: { DateTime aDateTime(GetDate(), GetTime()); - - util::DateTime DateTimeValue; - DateTimeValue.NanoSeconds = aDateTime.GetNanoSec(); - DateTimeValue.Seconds = aDateTime.GetSec(); - DateTimeValue.Minutes = aDateTime.GetMin(); - DateTimeValue.Hours = aDateTime.GetHour(); - DateTimeValue.Day = aDateTime.GetDay(); - DateTimeValue.Month = aDateTime.GetMonth(); - DateTimeValue.Year = aDateTime.GetYear(); - rVal <<= DateTimeValue; + rVal <<= aDateTime.GetUNODateTime(); } break; default: diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index beaa60ed47bc..e97b1d94e3ce 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -190,19 +190,6 @@ SwXRedlinePortion::~SwXRedlinePortion() { } -static util::DateTime lcl_DateTimeToUno(const DateTime& rDT) -{ - util::DateTime aRetDT; - aRetDT.Year = rDT.GetYear(); - aRetDT.Month= rDT.GetMonth(); - aRetDT.Day = rDT.GetDay(); - aRetDT.Hours = rDT.GetHour(); - aRetDT.Minutes = rDT.GetMin(); - aRetDT.Seconds = rDT.GetSec(); - aRetDT.NanoSeconds = rDT.GetNanoSec(); - return aRetDT; -} - static OUString lcl_RedlineTypeToOUString(RedlineType_t eType) { OUString sRet; @@ -231,7 +218,7 @@ static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRa // here we always need element 1 pValues[0].Value <<= rRedline.GetAuthorString(1); pValues[1].Name = UNO_NAME_REDLINE_DATE_TIME; - pValues[1].Value <<= lcl_DateTimeToUno(pNext->GetTimeStamp()); + pValues[1].Value <<= pNext->GetTimeStamp().GetUNODateTime(); pValues[2].Name = UNO_NAME_REDLINE_COMMENT; pValues[2].Value <<= pNext->GetComment(); pValues[3].Name = UNO_NAME_REDLINE_TYPE; @@ -299,7 +286,7 @@ uno::Any SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, co aRet <<= rRedline.GetAuthorString(); else if(rPropertyName == UNO_NAME_REDLINE_DATE_TIME) { - aRet <<= lcl_DateTimeToUno(rRedline.GetTimeStamp()); + aRet <<= rRedline.GetTimeStamp().GetUNODateTime(); } else if(rPropertyName == UNO_NAME_REDLINE_COMMENT) aRet <<= rRedline.GetComment(); @@ -339,7 +326,7 @@ uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties pRet[nPropIdx].Name = UNO_NAME_REDLINE_AUTHOR; pRet[nPropIdx++].Value <<= rRedline.GetAuthorString(); pRet[nPropIdx].Name = UNO_NAME_REDLINE_DATE_TIME; - pRet[nPropIdx++].Value <<= lcl_DateTimeToUno(rRedline.GetTimeStamp()); + pRet[nPropIdx++].Value <<= rRedline.GetTimeStamp().GetUNODateTime(); pRet[nPropIdx].Name = UNO_NAME_REDLINE_COMMENT; pRet[nPropIdx++].Value <<= rRedline.GetComment(); pRet[nPropIdx].Name = UNO_NAME_REDLINE_TYPE; diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index b724c243da0c..ba34ffe59959 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -394,17 +394,11 @@ static void WriteDop( WW8Export& rWrt ) else { ::util::DateTime uDT = xDocProps->getCreationDate(); - Date aD(uDT.Day, uDT.Month, uDT.Year); - tools::Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(aD,aT)); + rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(uDT)); uDT = xDocProps->getModificationDate(); - Date aD2(uDT.Day, uDT.Month, uDT.Year); - tools::Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(aD2,aT2)); + rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(uDT)); uDT = xDocProps->getPrintDate(); - Date aD3(uDT.Day, uDT.Month, uDT.Year); - tools::Time aT3(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); - rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(aD3,aT3)); + rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(uDT)); } // Also, the DocStat fields in headers, footers are not calculated correctly. diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d8421d271d20..f3c771fa7c88 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1859,10 +1859,7 @@ void SwWW8ImplReader::ImportDop() { DateTime aLastPrinted( msfilter::util::DTTM2DateTime(pWDop->dttmLastPrint)); - ::util::DateTime uDT(aLastPrinted.GetNanoSec(), - aLastPrinted.GetSec(), aLastPrinted.GetMin(), - aLastPrinted.GetHour(), aLastPrinted.GetDay(), - aLastPrinted.GetMonth(), aLastPrinted.GetYear(), false); + ::util::DateTime uDT = aLastPrinted.GetUNODateTime(); xDocuProps->setPrintDate(uDT); } |