From 13fac4894f752e922727c6f22c6303712e06ba12 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 1 Aug 2017 13:50:45 +0100 Subject: normalize resource locale ctor construction mechanisms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make them all the same and share std::locales more various OModuleClient, etc, classes go away Change-Id: I7e3ff01a69332eeacd22e3078f66a60318de62d5 Reviewed-on: https://gerrit.libreoffice.org/40634 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- filter/source/t602/t602filter.cxx | 29 +++++++---------- filter/source/t602/t602filter.hxx | 7 ++--- filter/source/xsltdialog/xmlfiltercommon.hxx | 1 + .../source/xsltdialog/xmlfiltersettingsdialog.cxx | 36 +++------------------- .../source/xsltdialog/xmlfiltersettingsdialog.hxx | 10 ------ filter/source/xsltdialog/xmlfiltertabdialog.cxx | 5 ++- filter/source/xsltdialog/xmlfiltertabdialog.hxx | 4 +-- 7 files changed, 23 insertions(+), 69 deletions(-) (limited to 'filter') diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx index 476d3b59cdae..902edf23e8bc 100644 --- a/filter/source/t602/t602filter.cxx +++ b/filter/source/t602/t602filter.cxx @@ -886,7 +886,8 @@ Reference< XInterface > SAL_CALL T602ImportFilter_createInstance( const Referenc } T602ImportFilterDialog::T602ImportFilterDialog() - : mpResLocale(nullptr) + : maLocale(SvtSysLocale().GetUILanguageTag()) + , maResLocale(Translate::Create("flt")) { } @@ -896,15 +897,19 @@ T602ImportFilterDialog::~T602ImportFilterDialog() // XLocalizable -void SAL_CALL T602ImportFilterDialog::setLocale( const Locale& eLocale ) +void SAL_CALL T602ImportFilterDialog::setLocale(const Locale& rLocale) { - meLocale = eLocale; - initLocale(); + LanguageTag aLocale(rLocale); + if (maLocale != aLocale) + { + maLocale = aLocale; + maResLocale = Translate::Create("flt", maLocale); + } } Locale SAL_CALL T602ImportFilterDialog::getLocale() { - return meLocale; + return maLocale.getLocale(false); } bool T602ImportFilterDialog::OptionsDlg() @@ -1088,18 +1093,6 @@ bool T602ImportFilterDialog::OptionsDlg() return ret; } -void T602ImportFilterDialog::initLocale() -{ - mpResLocale.reset(new std::locale(Translate::Create("flt", LanguageTag(meLocale)))); -} - -const std::locale* T602ImportFilterDialog::getResLocale() -{ - if (!mpResLocale) - initLocale(); - return mpResLocale.get(); -} - void SAL_CALL T602ImportFilterDialog::setTitle( const OUString& ) { } @@ -1114,7 +1107,7 @@ sal_Int16 SAL_CALL T602ImportFilterDialog::execute() OUString T602ImportFilterDialog::getResStr(const char* resid) { - return Translate::get(resid, *getResLocale()); + return Translate::get(resid, maResLocale); } uno::Sequence SAL_CALL T602ImportFilterDialog::getPropertyValues() diff --git a/filter/source/t602/t602filter.hxx b/filter/source/t602/t602filter.hxx index 8d81fb1b476a..1b407ed996e9 100644 --- a/filter/source/t602/t602filter.hxx +++ b/filter/source/t602/t602filter.hxx @@ -33,6 +33,7 @@ #include #include #include +#include namespace T602ImportFilter { @@ -82,12 +83,10 @@ class T602ImportFilterDialog : public cppu::WeakImplHelper < css::beans::XPropertyAccess > { - css::lang::Locale meLocale; - std::unique_ptr mpResLocale; + LanguageTag maLocale; + std::locale maResLocale; bool OptionsDlg(); - const std::locale* getResLocale(); OUString getResStr(const char* resid); - void initLocale(); virtual ~T602ImportFilterDialog() override; diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx index cb56b7b8ab83..4089993bb905 100644 --- a/filter/source/xsltdialog/xmlfiltercommon.hxx +++ b/filter/source/xsltdialog/xmlfiltercommon.hxx @@ -82,6 +82,7 @@ struct application_info_impl extern std::vector< application_info_impl* >& getApplicationInfos(); extern OUString getApplicationUIName( const OUString& rServiceName ); extern const application_info_impl* getApplicationInfo( const OUString& rServiceName ); +OUString XsltResId(const char* pId); #endif diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 7d6c81f6edae..7f913ad6f9fd 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -58,36 +58,10 @@ using namespace com::sun::star::util; using ::rtl::Uri; -namespace { - static std::locale* pXSLTResLocale = nullptr; - - const std::locale* getXSLTDialogResLocale() - { - return pXSLTResLocale; - } -} - -EnsureResLocale::EnsureResLocale() +OUString XsltResId(const char* pId) { - if (!pXSLTResLocale) - { - m_xResLocale.reset(new std::locale(Translate::Create("flt"))); - pXSLTResLocale = m_xResLocale.get(); - } -} - -EnsureResLocale::~EnsureResLocale() -{ - if (m_xResLocale) - pXSLTResLocale = nullptr; -} - -namespace -{ - OUString XsltResId(const char* pId) - { - return Translate::get(pId, *getXSLTDialogResLocale()); - } + static std::locale loc = Translate::Create("flt"); + return Translate::get(pId, loc); } XMLFilterSettingsDialog::XMLFilterSettingsDialog(vcl::Window* pParent, @@ -263,7 +237,7 @@ void XMLFilterSettingsDialog::onNew() aTempInfo.maDocumentService = "com.sun.star.text.TextDocument"; // execute XML Filter Dialog - ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResLocale(), mxContext, &aTempInfo ); + ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, mxContext, &aTempInfo ); if ( aDlg->Execute() == RET_OK ) { // insert the new filter @@ -282,7 +256,7 @@ void XMLFilterSettingsDialog::onEdit() filter_info_impl* pOldInfo = static_cast(pEntry->GetUserData()); // execute XML Filter Dialog - ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, *getXSLTDialogResLocale(), mxContext, pOldInfo ); + ScopedVclPtrInstance< XMLFilterTabDialog > aDlg( this, mxContext, pOldInfo ); if ( aDlg->Execute() == RET_OK ) { filter_info_impl* pNewInfo = aDlg->getNewFilterInfo(); diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx index 7dfc307ce057..072c5d4542a5 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx @@ -55,20 +55,11 @@ public: virtual bool EventNotify( NotifyEvent& rNEvt ) override; }; -class EnsureResLocale -{ - std::unique_ptr m_xResLocale; -public: - EnsureResLocale(); - ~EnsureResLocale(); -}; - class HeaderBar; class XMLFilterListBox : public SvTabListBox { private: - EnsureResLocale m_aEnsureResLocale; VclPtr m_pHeaderBar; DECL_LINK( TabBoxScrollHdl_Impl, SvTreeListBox*, void ); @@ -127,7 +118,6 @@ private: OUString createUniqueInterfaceName( const OUString& rInterfaceName ); private: - EnsureResLocale maEnsureResLocale; css::uno::Reference< css::uno::XComponentContext > mxContext; css::uno::Reference< css::container::XNameContainer > mxFilterContainer; css::uno::Reference< css::container::XNameContainer > mxTypeDetection; diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.cxx b/filter/source/xsltdialog/xmlfiltertabdialog.cxx index 624fed6ef3a1..5cdc8ad82bc0 100644 --- a/filter/source/xsltdialog/xmlfiltertabdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltertabdialog.cxx @@ -36,11 +36,10 @@ using namespace com::sun::star::container; using namespace com::sun::star::beans; using namespace com::sun::star::lang; -XMLFilterTabDialog::XMLFilterTabDialog(vcl::Window *pParent, const std::locale& rResLocale, +XMLFilterTabDialog::XMLFilterTabDialog(vcl::Window *pParent, const Reference< XComponentContext >& rxContext, const filter_info_impl* pInfo) : TabDialog(pParent, "XSLTFilterDialog","filter/ui/xsltfilterdialog.ui") , mxContext(rxContext) - , mrResLocale(rResLocale) { get(m_pOKBtn, "ok"); get(m_pTabCtrl, "tabcontrol"); @@ -250,7 +249,7 @@ bool XMLFilterTabDialog::onOk() m_pTabCtrl->SetCurPageId(nErrorPage); ActivatePageHdl(nullptr, m_pTabCtrl); - OUString aMessage(Translate::get(pErrorId, mrResLocale)); + OUString aMessage(XsltResId(pErrorId)); if( aReplace2.getLength() ) { diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.hxx b/filter/source/xsltdialog/xmlfiltertabdialog.hxx index c51656b84742..0e9b02ac2bff 100644 --- a/filter/source/xsltdialog/xmlfiltertabdialog.hxx +++ b/filter/source/xsltdialog/xmlfiltertabdialog.hxx @@ -33,7 +33,7 @@ class XMLFilterTabPageXSLT; class XMLFilterTabDialog: public TabDialog { public: - XMLFilterTabDialog(vcl::Window *pParent, const std::locale& rResLocale, const css::uno::Reference< css::uno::XComponentContext >& rxContext, const filter_info_impl* pInfo); + XMLFilterTabDialog(vcl::Window *pParent, const css::uno::Reference< css::uno::XComponentContext >& rxContext, const filter_info_impl* pInfo); virtual ~XMLFilterTabDialog() override; virtual void dispose() override; @@ -47,8 +47,6 @@ private: DECL_STATIC_LINK( XMLFilterTabDialog, ActivatePageHdl, TabControl*, void ); DECL_LINK(OkHdl, Button*, void); - const std::locale& mrResLocale; - const filter_info_impl* mpOldInfo; filter_info_impl* mpNewInfo; -- cgit