diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-11-12 08:21:20 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-11-13 12:06:30 +0100 |
commit | bad2196674764d67f19b276c1f6327dc3394e01a (patch) | |
tree | 8aaf3c4c05714f0474b4e8fb71e97a55ed6730fb | |
parent | 6a23a02b2bd65a6c3db4beb7fc083528f0a006c5 (diff) |
Use shared methods instead of duplicated code
Change-Id: I42836dcd1ef3f95d90e6e8897efff9cab7cc23fd
Reviewed-on: https://gerrit.libreoffice.org/63276
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r-- | include/unotools/datetime.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 42 | ||||
-rw-r--r-- | unotools/source/misc/datetime.cxx | 9 |
3 files changed, 14 insertions, 38 deletions
diff --git a/include/unotools/datetime.hxx b/include/unotools/datetime.hxx index bd630e2ffca2..2f55faedbc2a 100644 --- a/include/unotools/datetime.hxx +++ b/include/unotools/datetime.hxx @@ -38,6 +38,7 @@ namespace utl UNOTOOLS_DLLPUBLIC const LocaleDataWrapper& GetLocaleData(); UNOTOOLS_DLLPUBLIC DateTime GetDateTime(const css::util::DateTime& _rDT); UNOTOOLS_DLLPUBLIC OUString GetDateTimeString(const css::util::DateTime& _rDT); + UNOTOOLS_DLLPUBLIC OUString GetDateTimeString(sal_Int32 _nDate, sal_Int32 _nTime); UNOTOOLS_DLLPUBLIC OUString GetDateString(const css::util::DateTime& _rDT); UNOTOOLS_DLLPUBLIC void typeConvert(const Date& _rDate, css::util::Date& _rOut); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 9f11b03295bd..9199e25ba2e5 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -24,9 +24,11 @@ #include <vcl/mnemonic.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <unotools/datetime.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/cmdoptions.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/xmlsechelper.hxx> #include <unotools/useroptions.hxx> #include <svtools/controldims.hxx> #include <svtools/imagemgr.hxx> @@ -703,42 +705,6 @@ void SfxDocumentDescPage::Reset(const SfxItemSet *rSet) } } -namespace -{ - OUString GetDateTimeString( sal_Int32 _nDate, sal_Int32 _nTime ) - { - const LocaleDataWrapper& rWrapper( Application::GetSettings().GetLocaleDataWrapper() ); - - Date aDate( _nDate ); - tools::Time aTime( _nTime * tools::Time::nanoPerCenti ); - OUString aStr = rWrapper.getDate( aDate ) - + ", " - + rWrapper.getTime( aTime ); - return aStr; - } - - // copy from xmlsecurity/source/dialog/resourcemanager.cxx - OUString GetContentPart( const OUString& _rRawString, const OUString& _rPartId ) - { - OUString s; - - sal_Int32 nContStart = _rRawString.indexOf( _rPartId ); - if ( nContStart != -1 ) - { - nContStart = nContStart + _rPartId.getLength(); - ++nContStart; // now its start of content, directly after Id - - sal_Int32 nContEnd = _rRawString.indexOf( ',', nContStart ); - if (nContEnd != -1) - s = _rRawString.copy( nContStart, nContEnd - nContStart ); - else - s = _rRawString.copy(nContStart); - } - - return s; - } -} - SfxDocumentPage::SfxDocumentPage(vcl::Window* pParent, const SfxItemSet& rItemSet) : SfxTabPage(pParent, "DocumentInfoPage", "sfx/ui/documentinfopage.ui", &rItemSet) , bEnableUseUserData( false ) @@ -888,9 +854,9 @@ void SfxDocumentPage::ImplUpdateSignatures() else if ( aInfos.getLength() == 1 ) { const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ]; - s = GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime ); + s = utl::GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime ); s += ", "; - s += GetContentPart( rInfo.Signer->getSubjectName(), "CN" ); + s += comphelper::xmlsec::GetContentPart(rInfo.Signer->getSubjectName()); } m_pSignedValFt->SetText( s ); } diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 979db79e13cd..3c2da9f6586e 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -212,6 +212,15 @@ OUString GetDateTimeString(const css::util::DateTime& _rDT) return rLoDa.getDate(aDT) + " " + rLoDa.getTime(aDT); } +OUString GetDateTimeString(sal_Int32 _nDate, sal_Int32 _nTime) +{ + const LocaleDataWrapper& rLoDa = GetLocaleData(); + + Date aDate(_nDate); + tools::Time aTime(_nTime * tools::Time::nanoPerCenti); + return rLoDa.getDate(aDate) + ", " + rLoDa.getTime(aTime); +} + OUString GetDateString(const css::util::DateTime& _rDT) { return GetLocaleData().getDate(GetDateTime(_rDT)); |