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
class Module : public SfxModule
{
public:
Module ( ResMgr *pMgr, SfxObjectFactory *pObjFact) :
SfxModule( pMgr, {pObjFact} )
Module(const OString& rMgrName, SfxObjectFactory *pObjFact) :
SfxModule(rMgrName, {pObjFact})
{ }
};
......
......@@ -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));
......
......@@ -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();
......
......@@ -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),
......
......@@ -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),
......
......@@ -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& )
......
......@@ -142,7 +142,7 @@ void SmModule::InitInterface_Impl()
}
SmModule::SmModule(SfxObjectFactory* pObjFact) :
SfxModule(ResMgr::CreateResMgr("sm"), {pObjFact})
SfxModule("sm", {pObjFact})
{
SetName("StarMath");
......
......@@ -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),
......
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