diff options
author | os <os@openoffice.org> | 2009-11-26 12:52:39 +0100 |
---|---|---|
committer | os <os@openoffice.org> | 2009-11-26 12:52:39 +0100 |
commit | 56284b565d521a25df9612e030c88452db0a7bdb (patch) | |
tree | a5fab784e6647e83a5fea7b6cbd63f5397eb1da0 /sw/source/core/fields | |
parent | 228b27a2ae12e428ba806b6b70d5a543fcb06fbb (diff) |
custom property field - add type css::util::Duration
Diffstat (limited to 'sw/source/core/fields')
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index eeec35cc3080..ece68dd6fb70 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -53,6 +53,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Duration.hpp> #include <unotools/localedatawrapper.hxx> #include <svx/unolingu.hxx> #include <comphelper/processfactory.hxx> @@ -1154,7 +1155,7 @@ String SwDocInfoField::Expand() const ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")), uno::UNO_QUERY ); util::Date aDate; util::DateTime aDateTime; - util::Time aTime; + util::Duration aDuration; if( aAny >>= aDate) { SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter(); @@ -1169,9 +1170,17 @@ String SwDocInfoField::Expand() const fDateTime += lcl_DateToDouble<util::DateTime>( aDateTime, *pNullDate ); sVal = ExpandValue( fDateTime, GetFormat(), GetLanguage()); } - else if( aAny >>= aTime ) + else if( aAny >>= aDuration ) { - sVal = ExpandValue( lcl_TimeToDouble<util::Time>( aTime ), GetFormat(), GetLanguage()); + String sText(aDuration.Negative ? '-' : '+'); + sText += ViewShell::GetShellRes()->sDurationFormat; + sText.SearchAndReplace(String::CreateFromAscii( "%1"), String::CreateFromInt32( aDuration.Years ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%2"), String::CreateFromInt32( aDuration.Months ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%3"), String::CreateFromInt32( aDuration.Days ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%4"), String::CreateFromInt32( aDuration.Hours ) ); + sText.SearchAndReplace(String::CreateFromAscii( "%5"), String::CreateFromInt32( aDuration.Minutes) ); + sText.SearchAndReplace(String::CreateFromAscii( "%6"), String::CreateFromInt32( aDuration.Seconds) ); + sVal = sText; } else { |