diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-30 21:22:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-31 09:14:40 +0200 |
commit | af24eaef7a9a8b8e5adf297901d08273342e7e93 (patch) | |
tree | dbc3aa3722d855bf11d230d0e2edfa5cffac9be5 /sfx2 | |
parent | 48cff413e21830e3da4df8cb55540e68a4f009a6 (diff) |
flatten SfxTbxCtrlFactArr_Impl
Change-Id: I422aeeb446a49fa4449eabe0c3643f125856db12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121330
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/inc/pch/precompiled_sfx.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/appl/app.cxx | 15 | ||||
-rw-r--r-- | sfx2/source/appl/appdata.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/appinit.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appquit.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/appl/appreg.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/appl/module.cxx | 29 | ||||
-rw-r--r-- | sfx2/source/control/ctrlfactoryimpl.cxx | 42 | ||||
-rw-r--r-- | sfx2/source/inc/appdata.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/inc/ctrlfactoryimpl.hxx | 44 | ||||
-rw-r--r-- | sfx2/source/statbar/stbitem.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/toolbox/tbxitem.cxx | 57 |
13 files changed, 47 insertions, 164 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index c346bd15b336..18e25151250b 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -137,7 +137,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/asyncfunc \ sfx2/source/control/bindings \ sfx2/source/control/ctrlitem \ - sfx2/source/control/ctrlfactoryimpl \ sfx2/source/control/dispatch \ sfx2/source/control/itemdel \ sfx2/source/control/minfitem \ diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx index 3ab714967a16..c3aa00c0b06d 100644 --- a/sfx2/inc/pch/precompiled_sfx.hxx +++ b/sfx2/inc/pch/precompiled_sfx.hxx @@ -388,7 +388,6 @@ #include <appdata.hxx> #include <appopen.hxx> #include <asyncfunc.hxx> -#include <ctrlfactoryimpl.hxx> #include <eventsupplier.hxx> #include <helper.hxx> #include <helpids.h> diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index d226a03b1f6d..1e45a6ed1586 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -349,9 +349,20 @@ weld::Window* SfxApplication::GetTopWindow() const return pWindow->GetFrameWeld(); } -SfxTbxCtrlFactArr_Impl& SfxApplication::GetTbxCtrlFactories_Impl() const +SfxTbxCtrlFactory* SfxApplication::GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const { - return *pImpl->pTbxCtrlFac; + // search for a factory with the given slot id + for (auto& rFactory : pImpl->maTbxCtrlFactories) + if( rFactory.nTypeId == rSlotType && rFactory.nSlotId == nSlotID ) + return &rFactory; + + // if no factory exists for the given slot id, see if we + // have a generic factory with the correct slot type and slot id == 0 + for (auto& rFactory : pImpl->maTbxCtrlFactories) + if( rFactory.nTypeId == rSlotType && rFactory.nSlotId == 0 ) + return &rFactory; + + return nullptr; } SfxStbCtrlFactory* SfxApplication::GetStbCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 41eb91368d4d..c711266c1f86 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -21,6 +21,8 @@ #include <appdata.hxx> #include <sfxpicklist.hxx> +#include <sfx2/tbxctrl.hxx> +#include <sfx2/stbitem.hxx> #include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/doctempl.hxx> @@ -30,7 +32,6 @@ #include <sfx2/sidebar/Theme.hxx> #include <sfx2/objsh.hxx> #include <appbaslib.hxx> -#include <ctrlfactoryimpl.hxx> #include <shellimpl.hxx> #include <unoctitm.hxx> #include <svl/svdde.hxx> diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx index 228ef03ec5c3..343da98c8585 100644 --- a/sfx2/source/appl/appinit.cxx +++ b/sfx2/source/appl/appinit.cxx @@ -46,7 +46,6 @@ #include <sfx2/msgpool.hxx> #include <nochaos.hxx> #include <sfxpicklist.hxx> -#include <ctrlfactoryimpl.hxx> #include <shellimpl.hxx> using namespace ::com::sun::star::uno; @@ -209,7 +208,6 @@ void SfxApplication::Initialize_Impl() DBG_ASSERT( !pImpl->pAppDispat, "AppDispatcher already exists" ); pImpl->pAppDispat.reset(new SfxDispatcher); pImpl->pSlotPool.reset(new SfxSlotPool); - pImpl->pTbxCtrlFac.reset(new SfxTbxCtrlFactArr_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 bdd9e2cae08a..1245ef6e1c7d 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -24,6 +24,8 @@ #include <sfx2/app.hxx> #include <appdata.hxx> +#include <sfx2/tbxctrl.hxx> +#include <sfx2/stbitem.hxx> #include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/msgpool.hxx> @@ -33,7 +35,6 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/objsh.hxx> #include <appbaslib.hxx> -#include <ctrlfactoryimpl.hxx> #include <shellimpl.hxx> #include <basic/basicmanagerrepository.hxx> @@ -85,7 +86,7 @@ void SfxApplication::Deinitialize() pImpl->pSlotPool.reset(); pImpl->maFactories.clear(); - pImpl->pTbxCtrlFac.reset(); + pImpl->maTbxCtrlFactories.clear(); pImpl->maStbCtrlFactories.clear(); pImpl->pViewFrames.reset(); pImpl->pViewShells.reset(); diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx index d8dd87886cb9..5d27a45c50b8 100644 --- a/sfx2/source/appl/appreg.cxx +++ b/sfx2/source/appl/appreg.cxx @@ -31,7 +31,6 @@ #include <partwnd.hxx> #include <sfx2/sfxsids.hrc> #include <recfloat.hxx> -#include <ctrlfactoryimpl.hxx> #include <sfx2/objsh.hxx> #include <sfx2/viewsh.hxx> @@ -66,9 +65,9 @@ void SfxApplication::RegisterToolBoxControl_Impl( SfxModule *pMod, const SfxTbxC } #ifdef DBG_UTIL - for ( size_t n=0; n<pImpl->pTbxCtrlFac->size(); n++ ) + for ( size_t n=0; n<pImpl->maTbxCtrlFactories.size(); n++ ) { - SfxTbxCtrlFactory *pF = &(*pImpl->pTbxCtrlFac)[n]; + SfxTbxCtrlFactory *pF = &pImpl->maTbxCtrlFactories[n]; if ( pF->nTypeId == rFact.nTypeId && (pF->nSlotId == rFact.nSlotId || pF->nSlotId == 0) ) { @@ -77,7 +76,7 @@ void SfxApplication::RegisterToolBoxControl_Impl( SfxModule *pMod, const SfxTbxC } #endif - pImpl->pTbxCtrlFac->push_back( rFact ); + pImpl->maTbxCtrlFactories.push_back( rFact ); } diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 58a69936f17b..fe68c5e57eda 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -35,7 +35,6 @@ #define ShellClass_SfxModule #include <sfxslots.hxx> -#include <ctrlfactoryimpl.hxx> #include <optional> class SfxModule_Impl @@ -43,7 +42,7 @@ class SfxModule_Impl public: std::optional<SfxSlotPool> pSlotPool; - std::optional<SfxTbxCtrlFactArr_Impl> pTbxCtrlFac; + std::vector<SfxTbxCtrlFactory> maTbxCtrlFactories; std::vector<SfxStbCtrlFactory> maStbCtrlFactories; std::vector<SfxChildWinFactory> maFactories; OString maResName; @@ -59,7 +58,7 @@ SfxModule_Impl::SfxModule_Impl() SfxModule_Impl::~SfxModule_Impl() { pSlotPool.reset(); - pTbxCtrlFac.reset(); + maTbxCtrlFactories.clear(); maStbCtrlFactories.clear(); } @@ -126,13 +125,10 @@ void SfxModule::RegisterChildWindow(const SfxChildWinFactory& rFact) void SfxModule::RegisterToolBoxControl( const SfxTbxCtrlFactory& rFact ) { - if (!pImpl->pTbxCtrlFac) - pImpl->pTbxCtrlFac.emplace(); - #ifdef DBG_UTIL - for ( size_t n=0; n<pImpl->pTbxCtrlFac->size(); n++ ) + for ( size_t n=0; n<pImpl->maTbxCtrlFactories.size(); n++ ) { - SfxTbxCtrlFactory *pF = &(*pImpl->pTbxCtrlFac)[n]; + SfxTbxCtrlFactory *pF = &pImpl->maTbxCtrlFactories[n]; if ( pF->nTypeId == rFact.nTypeId && (pF->nSlotId == rFact.nSlotId || pF->nSlotId == 0) ) { @@ -141,7 +137,7 @@ void SfxModule::RegisterToolBoxControl( const SfxTbxCtrlFactory& rFact ) } #endif - pImpl->pTbxCtrlFac->push_back( rFact ); + pImpl->maTbxCtrlFactories.push_back( rFact ); } @@ -163,9 +159,20 @@ void SfxModule::RegisterStatusBarControl( const SfxStbCtrlFactory& rFact ) } -SfxTbxCtrlFactArr_Impl* SfxModule::GetTbxCtrlFactories_Impl() const +SfxTbxCtrlFactory* SfxModule::GetTbxCtrlFactory(const std::type_info& rSlotType, sal_uInt16 nSlotID) const { - return pImpl->pTbxCtrlFac ? &*pImpl->pTbxCtrlFac : nullptr; + // search for a factory with the given slot id + for (auto& rFactory : pImpl->maTbxCtrlFactories) + if( rFactory.nTypeId == rSlotType && rFactory.nSlotId == nSlotID ) + return &rFactory; + + // if no factory exists for the given slot id, see if we + // have a generic factory with the correct slot type and slot id == 0 + for (auto& rFactory : pImpl->maTbxCtrlFactories) + if( rFactory.nTypeId == rSlotType && rFactory.nSlotId == 0 ) + return &rFactory; + + return nullptr; } diff --git a/sfx2/source/control/ctrlfactoryimpl.cxx b/sfx2/source/control/ctrlfactoryimpl.cxx deleted file mode 100644 index 7e8846f58c12..000000000000 --- a/sfx2/source/control/ctrlfactoryimpl.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <ctrlfactoryimpl.hxx> - -const SfxTbxCtrlFactory& SfxTbxCtrlFactArr_Impl::operator []( size_t i ) const -{ - return maData[i]; -} - -SfxTbxCtrlFactory& SfxTbxCtrlFactArr_Impl::operator []( size_t i ) -{ - return maData[i]; -} - -void SfxTbxCtrlFactArr_Impl::push_back( const SfxTbxCtrlFactory& p ) -{ - maData.push_back(p); -} - -size_t SfxTbxCtrlFactArr_Impl::size() const -{ - return maData.size(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 2f15933944f2..589497b757d2 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -94,8 +94,8 @@ public: sal_uInt16 nDocModalMode; // counts documents in modal mode sal_uInt16 nRescheduleLocks; - std::unique_ptr<SfxTbxCtrlFactArr_Impl> - pTbxCtrlFac; + std::vector<SfxTbxCtrlFactory> + maTbxCtrlFactories; std::vector<SfxStbCtrlFactory> maStbCtrlFactories; std::unique_ptr<SfxViewFrameArr_Impl> diff --git a/sfx2/source/inc/ctrlfactoryimpl.hxx b/sfx2/source/inc/ctrlfactoryimpl.hxx deleted file mode 100644 index 465ddae60b2a..000000000000 --- a/sfx2/source/inc/ctrlfactoryimpl.hxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SFX2_CTRLFACTORYIMPL_HXX -#define INCLUDED_SFX2_CTRLFACTORYIMPL_HXX - -#include <sfx2/stbitem.hxx> -#include <sfx2/tbxctrl.hxx> - -#include <vector> - -class SfxTbxCtrlFactArr_Impl -{ - typedef std::vector<SfxTbxCtrlFactory> DataType; - DataType maData; - -public: - const SfxTbxCtrlFactory& operator[](size_t i) const; - SfxTbxCtrlFactory& operator[](size_t i); - - void push_back(const SfxTbxCtrlFactory&); - - size_t size() const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index 6e8f3688431a..5daf22dae11b 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -46,7 +46,6 @@ #include <svl/intitem.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/convert.hxx> -#include <ctrlfactoryimpl.hxx> using namespace ::com::sun::star; diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 2db988e1518a..ff42a28a3be0 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -55,7 +55,6 @@ #include <sfx2/app.hxx> #include <sidebar/ControllerFactory.hxx> #include <unoctitm.hxx> -#include <ctrlfactoryimpl.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -185,60 +184,16 @@ rtl::Reference<SfxToolBoxControl> SfxToolBoxControl::CreateControl( sal_uInt16 n const std::type_info* aSlotType = pSlotPool->GetSlotType( nSlotId ); if ( aSlotType ) { - rtl::Reference<SfxToolBoxControl> pCtrl; if ( pMod ) { - SfxTbxCtrlFactArr_Impl *pFactories = pMod->GetTbxCtrlFactories_Impl(); - if ( pFactories ) - { - SfxTbxCtrlFactArr_Impl &rFactories = *pFactories; - sal_uInt16 nFactory; - const sal_uInt16 nCount = rFactories.size(); - - // search for a factory with the given slot id - for( nFactory = 0; nFactory < nCount; ++nFactory ) - if( (rFactories[nFactory].nTypeId == *aSlotType) && (rFactories[nFactory].nSlotId == nSlotId) ) - break; - - if( nFactory == nCount ) - { - // if no factory exists for the given slot id, see if we - // have a generic factory with the correct slot type and slot id == 0 - for ( nFactory = 0; nFactory < nCount; ++nFactory ) - if( (rFactories[nFactory].nTypeId == *aSlotType) && (rFactories[nFactory].nSlotId == 0) ) - break; - } - - if( nFactory < nCount ) - { - pCtrl = rFactories[nFactory].pCtor( nSlotId, nTbxId, *pBox ); - return pCtrl; - } - } - } - - SfxTbxCtrlFactArr_Impl &rFactories = pApp->GetTbxCtrlFactories_Impl(); - sal_uInt16 nFactory; - const sal_uInt16 nCount = rFactories.size(); - - for( nFactory = 0; nFactory < nCount; ++nFactory ) - if( (rFactories[nFactory].nTypeId == *aSlotType) && (rFactories[nFactory].nSlotId == nSlotId) ) - break; - - if( nFactory == nCount ) - { - // if no factory exists for the given slot id, see if we - // have a generic factory with the correct slot type and slot id == 0 - for( nFactory = 0; nFactory < nCount; ++nFactory ) - if( (rFactories[nFactory].nTypeId == *aSlotType) && (rFactories[nFactory].nSlotId == 0) ) - break; + SfxTbxCtrlFactory *pFact = pMod->GetTbxCtrlFactory(*aSlotType, nSlotId); + if ( pFact ) + return pFact->pCtor( nSlotId, nTbxId, *pBox ); } - if( nFactory < nCount ) - { - pCtrl = rFactories[nFactory].pCtor( nSlotId, nTbxId, *pBox ); - return pCtrl; - } + SfxTbxCtrlFactory* pFact = pApp->GetTbxCtrlFactory(*aSlotType, nSlotId); + if (pFact) + return pFact->pCtor( nSlotId, nTbxId, *pBox ); } return nullptr; |