Kaydet (Commit) b37e7aa3 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

lokdialog: Allow language switching in SfxModule(s).

Change-Id: Icef0b3610c3bfa858cdd61de6ef3f5edc1e3c96b
Reviewed-on: https://gerrit.libreoffice.org/47333Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst ed16e39a
...@@ -29,8 +29,8 @@ namespace basctl ...@@ -29,8 +29,8 @@ namespace basctl
class Module : public SfxModule class Module : public SfxModule
{ {
public: public:
Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) : Module(const OString& rMgrName, SfxObjectFactory *pObjFact) :
SfxModule( pMgr, {pObjFact} ) SfxModule(rMgrName, {pObjFact})
{ } { }
}; };
......
...@@ -116,10 +116,7 @@ Dll::Dll () : ...@@ -116,10 +116,7 @@ Dll::Dll () :
SfxObjectFactory* pFact = &DocShell::Factory(); SfxObjectFactory* pFact = &DocShell::Factory();
(void)pFact; (void)pFact;
ResMgr* pMgr = ResMgr::CreateResMgr( auto pModule = o3tl::make_unique<Module>("basctl", &DocShell::Factory());
"basctl", Application::GetSettings().GetUILanguageTag());
auto pModule = o3tl::make_unique<Module>( pMgr, &DocShell::Factory() );
SfxModule* pMod = pModule.get(); SfxModule* pMod = pModule.get();
SfxApplication::SetModule(SfxToolsModule::Basic, std::move(pModule)); SfxApplication::SetModule(SfxToolsModule::Basic, std::move(pModule));
......
...@@ -53,13 +53,11 @@ namespace com { namespace sun { namespace star { namespace frame { ...@@ -53,13 +53,11 @@ namespace com { namespace sun { namespace star { namespace frame {
class SFX2_DLLPUBLIC SfxModule : public SfxShell class SFX2_DLLPUBLIC SfxModule : public SfxShell
{ {
private: private:
ResMgr* pResMgr;
// Warning this cannot be turned into a unique_ptr. // 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 // SfxInterface destruction in the SfxSlotPool refers again to pImpl after deletion of pImpl has commenced. See tdf#100270
SfxModule_Impl* pImpl; SfxModule_Impl* pImpl;
SAL_DLLPRIVATE void Construct_Impl(); SAL_DLLPRIVATE void Construct_Impl(const OString& rResName);
public: public:
SFX_DECL_INTERFACE(SFX_INTERFACE_SFXMODULE) SFX_DECL_INTERFACE(SFX_INTERFACE_SFXMODULE)
...@@ -70,7 +68,7 @@ private: ...@@ -70,7 +68,7 @@ private:
public: public:
SfxModule( ResMgr* pMgrP, std::initializer_list<SfxObjectFactory*> pFactoryList); SfxModule(const OString& rResName, std::initializer_list<SfxObjectFactory*> pFactoryList);
virtual ~SfxModule() override; virtual ~SfxModule() override;
ResMgr* GetResMgr(); ResMgr* GetResMgr();
......
...@@ -133,7 +133,7 @@ void ScModule::InitInterface_Impl() ...@@ -133,7 +133,7 @@ void ScModule::InitInterface_Impl()
} }
ScModule::ScModule( SfxObjectFactory* pFact ) : ScModule::ScModule( SfxObjectFactory* pFact ) :
SfxModule( ResMgr::CreateResMgr( "sc" ), {pFact} ), SfxModule("sc", {pFact}),
aIdleTimer("sc ScModule IdleTimer"), aIdleTimer("sc ScModule IdleTimer"),
aSpellIdle("sc ScModule SpellIdle"), aSpellIdle("sc ScModule SpellIdle"),
mpDragData(new ScDragData), mpDragData(new ScDragData),
......
...@@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl() ...@@ -67,7 +67,7 @@ void SdModule::InitInterface_Impl()
// Ctor // Ctor
SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
: SfxModule( ResMgr::CreateResMgr("sd"), {pFact1, pFact2} ), : SfxModule("sd", {pFact1, pFact2}),
pTransferClip(nullptr), pTransferClip(nullptr),
pTransferDrag(nullptr), pTransferDrag(nullptr),
pTransferSelection(nullptr), pTransferSelection(nullptr),
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
SfxChildWinFactArr_Impl* pFactArr; SfxChildWinFactArr_Impl* pFactArr;
ImageList* pImgListSmall; ImageList* pImgListSmall;
ImageList* pImgListBig; ImageList* pImgListBig;
OString maResName;
std::unique_ptr<ResMgr> mpResMgr;
SfxModule_Impl(); SfxModule_Impl();
~SfxModule_Impl(); ~SfxModule_Impl();
...@@ -94,18 +96,23 @@ ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, bool bBig ) ...@@ -94,18 +96,23 @@ ImageList* SfxModule_Impl::GetImageList( ResMgr* pResMgr, bool bBig )
return rpList; return rpList;
} }
SFX_IMPL_SUPERCLASS_INTERFACE(SfxModule, SfxShell) SFX_IMPL_SUPERCLASS_INTERFACE(SfxModule, SfxShell)
ResMgr* SfxModule::GetResMgr() 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 ) SfxModule::SfxModule(const OString& rResName, std::initializer_list<SfxObjectFactory*> pFactoryList )
: pResMgr( pMgrP ), pImpl(nullptr) : pImpl(nullptr)
{ {
Construct_Impl(); Construct_Impl(rResName);
for (auto pFactory : pFactoryList) for (auto pFactory : pFactoryList)
{ {
if (pFactory) if (pFactory)
...@@ -113,7 +120,7 @@ SfxModule::SfxModule( ResMgr* pMgrP, std::initializer_list<SfxObjectFactory*> pF ...@@ -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(); SfxApplication *pApp = SfxApplication::GetOrCreate();
pImpl = new SfxModule_Impl; pImpl = new SfxModule_Impl;
...@@ -124,6 +131,7 @@ void SfxModule::Construct_Impl() ...@@ -124,6 +131,7 @@ void SfxModule::Construct_Impl()
pImpl->pFactArr=nullptr; pImpl->pFactArr=nullptr;
pImpl->pImgListSmall=nullptr; pImpl->pImgListSmall=nullptr;
pImpl->pImgListBig=nullptr; pImpl->pImgListBig=nullptr;
pImpl->maResName = rResName;
SetPool( &pApp->GetPool() ); SetPool( &pApp->GetPool() );
} }
...@@ -132,7 +140,6 @@ void SfxModule::Construct_Impl() ...@@ -132,7 +140,6 @@ void SfxModule::Construct_Impl()
SfxModule::~SfxModule() SfxModule::~SfxModule()
{ {
delete pImpl; delete pImpl;
delete pResMgr;
} }
...@@ -223,7 +230,7 @@ SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const ...@@ -223,7 +230,7 @@ SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const
ImageList* SfxModule::GetImageList_Impl( bool bBig ) 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& ) VclPtr<SfxTabPage> SfxModule::CreateTabPage( sal_uInt16, vcl::Window*, const SfxItemSet& )
......
...@@ -142,7 +142,7 @@ void SmModule::InitInterface_Impl() ...@@ -142,7 +142,7 @@ void SmModule::InitInterface_Impl()
} }
SmModule::SmModule(SfxObjectFactory* pObjFact) : SmModule::SmModule(SfxObjectFactory* pObjFact) :
SfxModule(ResMgr::CreateResMgr("sm"), {pObjFact}) SfxModule("sm", {pObjFact})
{ {
SetName("StarMath"); SetName("StarMath");
......
...@@ -145,7 +145,7 @@ using namespace ::com::sun::star::uno; ...@@ -145,7 +145,7 @@ using namespace ::com::sun::star::uno;
SwModule::SwModule( SfxObjectFactory* pWebFact, SwModule::SwModule( SfxObjectFactory* pWebFact,
SfxObjectFactory* pFact, SfxObjectFactory* pFact,
SfxObjectFactory* pGlobalFact ) SfxObjectFactory* pGlobalFact )
: SfxModule( ResMgr::CreateResMgr( "sw" ), {pWebFact, pFact, pGlobalFact} ), : SfxModule("sw", {pWebFact, pFact, pGlobalFact}),
m_pModuleConfig(nullptr), m_pModuleConfig(nullptr),
m_pUsrPref(nullptr), m_pUsrPref(nullptr),
m_pWebUsrPref(nullptr), m_pWebUsrPref(nullptr),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment