include/sfx2/app.hxx | 3 +-- include/sfx2/module.hxx | 3 +-- sfx2/source/appl/app.cxx | 8 ++++++-- sfx2/source/appl/appinit.cxx | 1 - sfx2/source/appl/appquit.cxx | 2 +- sfx2/source/appl/appreg.cxx | 6 +++--- sfx2/source/appl/module.cxx | 21 +++++++++++---------- sfx2/source/control/ctrlfactoryimpl.cxx | 20 -------------------- sfx2/source/inc/appdata.hxx | 4 ++-- sfx2/source/inc/ctrlfactoryimpl.hxx | 14 -------------- sfx2/source/statbar/stbitem.cxx | 22 ++++++---------------- 11 files changed, 31 insertions(+), 73 deletions(-)
New commits: commit 48cff413e21830e3da4df8cb55540e68a4f009a6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Aug 30 21:00:33 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 31 08:11:05 2021 +0200 flatten SfxStbCtrlFactArr_Impl Change-Id: I1d92a41f0f1a2610930e48b5eeaa689ac47ab7fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121329 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx index 573eef573246..541e9cf94159 100644 --- a/include/sfx2/app.hxx +++ b/include/sfx2/app.hxx @@ -45,7 +45,6 @@ class SfxObjectShellArr_Impl; class SfxObjectShellLock; class SfxProgress; class SfxSlotPool; -class SfxStbCtrlFactArr_Impl; class SfxTbxCtrlFactArr_Impl; class SfxViewFrame; class SfxViewFrameArr_Impl; @@ -174,7 +173,7 @@ public: SAL_DLLPRIVATE void RegisterStatusBarControl_Impl(SfxModule*, const SfxStbCtrlFactory&); SAL_DLLPRIVATE void RegisterToolBoxControl_Impl( SfxModule*, const SfxTbxCtrlFactory&); SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl& GetTbxCtrlFactories_Impl() const; - SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl& GetStbCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; SAL_DLLPRIVATE SfxViewFrameArr_Impl& GetViewFrames_Impl() const; SAL_DLLPRIVATE SfxViewShellArr_Impl& GetViewShells_Impl() const; diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx index 707d03cc4a25..c24d1acac4e9 100644 --- a/include/sfx2/module.hxx +++ b/include/sfx2/module.hxx @@ -37,7 +37,6 @@ struct SfxStbCtrlFactory; struct SfxTbxCtrlFactory; class SfxTabPage; class SfxTbxCtrlFactArr_Impl; -class SfxStbCtrlFactArr_Impl; namespace com::sun::star::frame { class XFrame; @@ -96,7 +95,7 @@ public: FieldUnit GetFieldUnit() const; SAL_DLLPRIVATE SfxTbxCtrlFactArr_Impl* GetTbxCtrlFactories_Impl() const; - SAL_DLLPRIVATE SfxStbCtrlFactArr_Impl* GetStbCtrlFactories_Impl() const; + SAL_DLLPRIVATE SfxStbCtrlFactory* GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const; SAL_DLLPRIVATE SfxChildWinFactory* GetChildWinFactoryById(sal_uInt16 nId) const; }; diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 6624beb2d078..d226a03b1f6d 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -354,9 +354,13 @@ SfxTbxCtrlFactArr_Impl& SfxApplication::GetTbxCtrlFactories_Impl() const return *pImpl->pTbxCtrlFac; } -SfxStbCtrlFactArr_Impl& SfxApplication::GetStbCtrlFactories_Impl() const +SfxStbCtrlFactory* SfxApplication::GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const { - return *pImpl->pStbCtrlFac; + for (auto& rFactory : pImpl->maStbCtrlFactories) + if ( rFactory.nTypeId == rSlotType && + ( rFactory.nSlotId == 0 || rFactory.nSlotId == nSlotID ) ) + return &rFactory; + return nullptr; } SfxViewFrameArr_Impl& SfxApplication::GetViewFrames_Impl() const diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index 97b85ef84a92..228ef03ec5c3 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -210,7 +210,6 @@ void SfxApplication::Initialize_Impl() pImpl->pAppDispat.reset(new SfxDispatcher); pImpl->pSlotPool.reset(new SfxSlotPool); pImpl->pTbxCtrlFac.reset(new SfxTbxCtrlFactArr_Impl); - pImpl->pStbCtrlFac.reset(new SfxStbCtrlFactArr_Impl); pImpl->pViewFrames.reset(new SfxViewFrameArr_Impl); pImpl->pViewShells.reset(new SfxViewShellArr_Impl); pImpl->pObjShells.reset(new SfxObjectShellArr_Impl); diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index d4716c14d66c..bdd9e2cae08a 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -86,7 +86,7 @@ void SfxApplication::Deinitialize() pImpl->maFactories.clear(); pImpl->pTbxCtrlFac.reset(); - pImpl->pStbCtrlFac.reset(); + pImpl->maStbCtrlFactories.clear(); pImpl->pViewFrames.reset(); pImpl->pViewShells.reset(); pImpl->pObjShells.reset(); diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx index 6c9810cbf02c..d8dd87886cb9 100644 --- a/sfx2/source/appl/appreg.cxx +++ b/sfx2/source/appl/appreg.cxx @@ -90,9 +90,9 @@ void SfxApplication::RegisterStatusBarControl_Impl( SfxModule *pMod, const SfxSt } #ifdef DBG_UTIL - for ( size_t n=0; n<pImpl->pStbCtrlFac->size(); n++ ) + for ( size_t n=0; n<pImpl->maStbCtrlFactories.size(); n++ ) { - SfxStbCtrlFactory *pF = &(*pImpl->pStbCtrlFac)[n]; + SfxStbCtrlFactory *pF = &pImpl->maStbCtrlFactories[n]; if ( pF->nTypeId == rFact.nTypeId && (pF->nSlotId == rFact.nSlotId || pF->nSlotId == 0) ) { @@ -101,7 +101,7 @@ void SfxApplication::RegisterStatusBarControl_Impl( SfxModule *pMod, const SfxSt } #endif - pImpl->pStbCtrlFac->push_back( rFact ); + pImpl->maStbCtrlFactories.push_back( rFact ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 427173897735..58a69936f17b 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -44,7 +44,7 @@ public: std::optional<SfxSlotPool> pSlotPool; std::optional<SfxTbxCtrlFactArr_Impl> pTbxCtrlFac; - std::optional<SfxStbCtrlFactArr_Impl> pStbCtrlFac; + std::vector<SfxStbCtrlFactory> maStbCtrlFactories; std::vector<SfxChildWinFactory> maFactories; OString maResName; @@ -60,7 +60,7 @@ SfxModule_Impl::~SfxModule_Impl() { pSlotPool.reset(); pTbxCtrlFac.reset(); - pStbCtrlFac.reset(); + maStbCtrlFactories.clear(); } SFX_IMPL_SUPERCLASS_INTERFACE(SfxModule, SfxShell) @@ -147,13 +147,10 @@ void SfxModule::RegisterToolBoxControl( const SfxTbxCtrlFactory& rFact ) void SfxModule::RegisterStatusBarControl( const SfxStbCtrlFactory& rFact ) { - if (!pImpl->pStbCtrlFac) - pImpl->pStbCtrlFac.emplace(); - #ifdef DBG_UTIL - for ( size_t n=0; n<pImpl->pStbCtrlFac->size(); n++ ) + for ( size_t n=0; n<pImpl->maStbCtrlFactories.size(); n++ ) { - SfxStbCtrlFactory *pF = &(*pImpl->pStbCtrlFac)[n]; + SfxStbCtrlFactory *pF = &pImpl->maStbCtrlFactories[n]; if ( pF->nTypeId == rFact.nTypeId && (pF->nSlotId == rFact.nSlotId || pF->nSlotId == 0) ) { @@ -162,7 +159,7 @@ void SfxModule::RegisterStatusBarControl( const SfxStbCtrlFactory& rFact ) } #endif - pImpl->pStbCtrlFac->push_back( rFact ); + pImpl->maStbCtrlFactories.push_back( rFact ); } @@ -172,9 +169,13 @@ SfxTbxCtrlFactArr_Impl* SfxModule::GetTbxCtrlFactories_Impl() const } -SfxStbCtrlFactArr_Impl* SfxModule::GetStbCtrlFactories_Impl() const +SfxStbCtrlFactory* SfxModule::GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const { - return pImpl->pStbCtrlFac ? &*pImpl->pStbCtrlFac : nullptr; + for (auto& rFactory : pImpl->maStbCtrlFactories) + if ( rFactory.nTypeId == rSlotType && + ( rFactory.nSlotId == 0 || rFactory.nSlotId == nSlotID ) ) + return &rFactory; + return nullptr; } SfxChildWinFactory* SfxModule::GetChildWinFactoryById(sal_uInt16 nId) const diff --git a/sfx2/source/control/ctrlfactoryimpl.cxx b/sfx2/source/control/ctrlfactoryimpl.cxx index 925ba7b75bb3..7e8846f58c12 100644 --- a/sfx2/source/control/ctrlfactoryimpl.cxx +++ b/sfx2/source/control/ctrlfactoryimpl.cxx @@ -19,26 +19,6 @@ #include <ctrlfactoryimpl.hxx> -const SfxStbCtrlFactory& SfxStbCtrlFactArr_Impl::operator []( size_t i ) const -{ - return maData[i]; -} - -SfxStbCtrlFactory& SfxStbCtrlFactArr_Impl::operator []( size_t i ) -{ - return maData[i]; -} - -void SfxStbCtrlFactArr_Impl::push_back( const SfxStbCtrlFactory& p ) -{ - maData.push_back(p); -} - -size_t SfxStbCtrlFactArr_Impl::size() const -{ - return maData.size(); -} - const SfxTbxCtrlFactory& SfxTbxCtrlFactArr_Impl::operator []( size_t i ) const { return maData[i]; diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index f74d364dfd1a..2f15933944f2 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -96,8 +96,8 @@ public: std::unique_ptr<SfxTbxCtrlFactArr_Impl> pTbxCtrlFac; - std::unique_ptr<SfxStbCtrlFactArr_Impl> - pStbCtrlFac; + std::vector<SfxStbCtrlFactory> + maStbCtrlFactories; std::unique_ptr<SfxViewFrameArr_Impl> pViewFrames; std::unique_ptr<SfxViewShellArr_Impl> diff --git a/sfx2/source/inc/ctrlfactoryimpl.hxx b/sfx2/source/inc/ctrlfactoryimpl.hxx index 4d32f1d3d298..465ddae60b2a 100644 --- a/sfx2/source/inc/ctrlfactoryimpl.hxx +++ b/sfx2/source/inc/ctrlfactoryimpl.hxx @@ -25,20 +25,6 @@ #include <vector> -class SfxStbCtrlFactArr_Impl -{ - typedef std::vector<SfxStbCtrlFactory> DataType; - DataType maData; - -public: - const SfxStbCtrlFactory& operator[](size_t i) const; - SfxStbCtrlFactory& operator[](size_t i); - - void push_back(const SfxStbCtrlFactory&); - - size_t size() const; -}; - class SfxTbxCtrlFactArr_Impl { typedef std::vector<SfxTbxCtrlFactory> DataType; diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index 6e31b10bc7b1..6e8f3688431a 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -538,24 +538,14 @@ rtl::Reference<SfxStatusBarControl> SfxStatusBarControl::CreateControl { if ( pMod ) { - SfxStbCtrlFactArr_Impl *pFactories = pMod->GetStbCtrlFactories_Impl(); - if ( pFactories ) - { - SfxStbCtrlFactArr_Impl &rFactories = *pFactories; - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) - if ( rFactories[nFactory].nTypeId == *aSlotType && - ( ( rFactories[nFactory].nSlotId == 0 ) || - ( rFactories[nFactory].nSlotId == nSlotID) ) ) - return rFactories[nFactory].pCtor( nSlotID, nStbId, *pBar ); - } + SfxStbCtrlFactory *pFact = pMod->GetStbCtrlFactory(*aSlotType, nSlotID); + if ( pFact ) + return pFact->pCtor( nSlotID, nStbId, *pBar ); } - SfxStbCtrlFactArr_Impl &rFactories = pApp->GetStbCtrlFactories_Impl(); - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) - if ( rFactories[nFactory].nTypeId == *aSlotType && - ( ( rFactories[nFactory].nSlotId == 0 ) || - ( rFactories[nFactory].nSlotId == nSlotID) ) ) - return rFactories[nFactory].pCtor( nSlotID, nStbId, *pBar ); + SfxStbCtrlFactory* pFact = pApp->GetStbCtrlFactory(*aSlotType, nSlotID); + if (pFact) + return pFact->pCtor( nSlotID, nStbId, *pBar ); } return nullptr;