basctl/source/basicide/basicmod.hxx | 4 ++-- basctl/source/basicide/iderdll.cxx | 5 +---- include/sfx2/module.hxx | 6 ++---- sc/source/ui/app/scmod.cxx | 2 +- sd/source/ui/app/sdmod.cxx | 2 +- sfx2/source/appl/module.cxx | 23 +++++++++++++++-------- starmath/source/smmod.cxx | 2 +- sw/source/uibase/app/swmodule.cxx | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-)
New commits: commit b37e7aa35a1c927a7154f87c7f1ce75ce5a6a229 Author: Jan Holesovsky <ke...@collabora.com> Date: Wed Jan 3 14:08:55 2018 +0100 lokdialog: Allow language switching in SfxModule(s). Change-Id: Icef0b3610c3bfa858cdd61de6ef3f5edc1e3c96b Reviewed-on: https://gerrit.libreoffice.org/47333 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/basctl/source/basicide/basicmod.hxx b/basctl/source/basicide/basicmod.hxx index ffc960cea598..ba269b7cd7e0 100644 --- a/basctl/source/basicide/basicmod.hxx +++ b/basctl/source/basicide/basicmod.hxx @@ -29,8 +29,8 @@ namespace basctl class Module : public SfxModule { public: - Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) : - SfxModule( pMgr, {pObjFact} ) + Module(const OString& rMgrName, SfxObjectFactory *pObjFact) : + SfxModule(rMgrName, {pObjFact}) { } }; diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx index 1faeb46ae634..84235af23ad1 100644 --- a/basctl/source/basicide/iderdll.cxx +++ b/basctl/source/basicide/iderdll.cxx @@ -116,10 +116,7 @@ Dll::Dll () : SfxObjectFactory* pFact = &DocShell::Factory(); (void)pFact; - ResMgr* pMgr = ResMgr::CreateResMgr( - "basctl", Application::GetSettings().GetUILanguageTag()); - - auto pModule = o3tl::make_unique<Module>( pMgr, &DocShell::Factory() ); + auto pModule = o3tl::make_unique<Module>("basctl", &DocShell::Factory()); SfxModule* pMod = pModule.get(); SfxApplication::SetModule(SfxToolsModule::Basic, std::move(pModule)); diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx index 9a01f82a94f3..77c0781bd321 100644 --- a/include/sfx2/module.hxx +++ b/include/sfx2/module.hxx @@ -53,13 +53,11 @@ namespace com { namespace sun { namespace star { namespace frame { class SFX2_DLLPUBLIC SfxModule : public SfxShell { private: - ResMgr* pResMgr; - // Warning this cannot be turned into a unique_ptr. // SfxInterface destruction in the SfxSlotPool refers again to pImpl after deletion of pImpl has commenced. See tdf#100270 SfxModule_Impl* pImpl; - SAL_DLLPRIVATE void Construct_Impl(); + SAL_DLLPRIVATE void Construct_Impl(const OString& rResName); public: SFX_DECL_INTERFACE(SFX_INTERFACE_SFXMODULE) @@ -70,7 +68,7 @@ private: public: - SfxModule( ResMgr* pMgrP, std::initializer_list<SfxObjectFactory*> pFactoryList); + SfxModule(const OString& rResName, std::initializer_list<SfxObjectFactory*> pFactoryList); virtual ~SfxModule() override; ResMgr* GetResMgr(); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index ca4793fefe29..844a2a54407f 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -133,7 +133,7 @@ void ScModule::InitInterface_Impl() } ScModule::ScModule( SfxObjectFactory* pFact ) : - SfxModule( ResMgr::CreateResMgr( "sc" ), {pFact} ), + SfxModule("sc", {pFact}), aIdleTimer("sc ScModule IdleTimer"), aSpellIdle("sc ScModule SpellIdle"), mpDragData(new ScDragData), diff --git a/sd/source/ui/app/sdmod.cxx b/sd/source/ui/app/sdmod.cxx index 3bb949c50d00..6f86e8dbc3fc 100644 --- a/sd/source/ui/app/sdmod.cxx +++ b/sd/source/ui/app/sdmod.cxx @@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl() // Ctor SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) -: SfxModule( ResMgr::CreateResMgr("sd"), {pFact1, pFact2} ), +: SfxModule("sd", {pFact1, pFact2}), pTransferClip(nullptr), pTransferDrag(nullptr), pTransferSelection(nullptr), diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 830f7eb7696a..ca784f88c735 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -53,6 +53,8 @@ public: SfxChildWinFactArr_Impl* pFactArr; ImageList* pImgListSmall; ImageList* pImgListBig; + OString maResName; + std::unique_ptr<ResMgr> mpResMgr; SfxModule_Impl(); ~SfxModule_Impl(); @@ -94,18 +96,23 @@ ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, bool bBig ) return rpList; } - SFX_IMPL_SUPERCLASS_INTERFACE(SfxModule, SfxShell) ResMgr* SfxModule::GetResMgr() { - return pResMgr; + assert(pImpl); + + const LanguageTag& rLocale = Application::GetSettings().GetUILanguageTag(); + + if (!pImpl->mpResMgr || pImpl->mpResMgr->GetLocale() != rLocale) + pImpl->mpResMgr.reset(ResMgr::CreateResMgr(pImpl->maResName.getStr(), rLocale)); + return pImpl->mpResMgr.get(); } -SfxModule::SfxModule( ResMgr* pMgrP, std::initializer_list<SfxObjectFactory*> pFactoryList ) - : pResMgr( pMgrP ), pImpl(nullptr) +SfxModule::SfxModule(const OString& rResName, std::initializer_list<SfxObjectFactory*> pFactoryList ) + : pImpl(nullptr) { - Construct_Impl(); + Construct_Impl(rResName); for (auto pFactory : pFactoryList) { if (pFactory) @@ -113,7 +120,7 @@ SfxModule::SfxModule( ResMgr* pMgrP, std::initializer_list<SfxObjectFactory*> pF } } -void SfxModule::Construct_Impl() +void SfxModule::Construct_Impl(const OString& rResName) { SfxApplication *pApp = SfxApplication::GetOrCreate(); pImpl = new SfxModule_Impl; @@ -124,6 +131,7 @@ void SfxModule::Construct_Impl() pImpl->pFactArr=nullptr; pImpl->pImgListSmall=nullptr; pImpl->pImgListBig=nullptr; + pImpl->maResName = rResName; SetPool( &pApp->GetPool() ); } @@ -132,7 +140,6 @@ void SfxModule::Construct_Impl() SfxModule::~SfxModule() { delete pImpl; - delete pResMgr; } @@ -223,7 +230,7 @@ SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const ImageList* SfxModule::GetImageList_Impl( bool bBig ) { - return pImpl->GetImageList( pResMgr, bBig ); + return pImpl->GetImageList(GetResMgr(), bBig); } VclPtr<SfxTabPage> SfxModule::CreateTabPage( sal_uInt16, vcl::Window*, const SfxItemSet& ) diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index c50cf31733be..8fc5c8d56313 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -142,7 +142,7 @@ void SmModule::InitInterface_Impl() } SmModule::SmModule(SfxObjectFactory* pObjFact) : - SfxModule(ResMgr::CreateResMgr("sm"), {pObjFact}) + SfxModule("sm", {pObjFact}) { SetName("StarMath"); diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index b43c8fd01756..48f94c8aad83 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -145,7 +145,7 @@ using namespace ::com::sun::star::uno; SwModule::SwModule( SfxObjectFactory* pWebFact, SfxObjectFactory* pFact, SfxObjectFactory* pGlobalFact ) - : SfxModule( ResMgr::CreateResMgr( "sw" ), {pWebFact, pFact, pGlobalFact} ), + : SfxModule("sw", {pWebFact, pFact, pGlobalFact}), m_pModuleConfig(nullptr), m_pUsrPref(nullptr), m_pWebUsrPref(nullptr), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits