diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-30 20:41:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-31 08:10:47 +0200 |
commit | 1ff8e0a958685fbaf63fbc2d4c766a76869d4879 (patch) | |
tree | 84ec5d17e4618f98841dd1f3fa90e15f4714f310 /sfx2 | |
parent | d87acc9fed5fd42588f593ac5e1bfca8308499dd (diff) |
flatten SfxChildWinFactArr_Imp
it's just a vector with no additional intelligence
Change-Id: I91d014783e79130689b4f6eadb3ef6d8486227e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121324
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/appchild.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/appl/appdata.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appquit.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/appl/childwin.cxx | 65 | ||||
-rw-r--r-- | sfx2/source/appl/childwinimpl.cxx | 53 | ||||
-rw-r--r-- | sfx2/source/appl/module.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/appl/workwin.cxx | 64 | ||||
-rw-r--r-- | sfx2/source/inc/appdata.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/inc/childwinimpl.hxx | 50 |
11 files changed, 72 insertions, 208 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 39b5438c65a2..c346bd15b336 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -100,7 +100,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/appl/appserv \ sfx2/source/appl/appuno \ sfx2/source/appl/childwin \ - sfx2/source/appl/childwinimpl \ sfx2/source/appl/fileobj \ sfx2/source/appl/flatpak \ sfx2/source/appl/fwkhelper \ diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx index dc98200fdf49..3ab714967a16 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 <childwinimpl.hxx> #include <ctrlfactoryimpl.hxx> #include <eventsupplier.hxx> #include <helper.hxx> diff --git a/sfx2/source/appl/appchild.cxx b/sfx2/source/appl/appchild.cxx index 08f88191847a..4da8ad32f33a 100644 --- a/sfx2/source/appl/appchild.cxx +++ b/sfx2/source/appl/appchild.cxx @@ -24,7 +24,6 @@ #include <sfx2/app.hxx> #include <appdata.hxx> #include <workwin.hxx> -#include <childwinimpl.hxx> #include <sfx2/childwin.hxx> #include <sfx2/module.hxx> #include <sfx2/viewfrm.hxx> @@ -38,23 +37,23 @@ void SfxApplication::RegisterChildWindow_Impl( SfxModule *pMod, const SfxChildWi return; } - if (!pImpl->pFactArr) - pImpl->pFactArr.reset(new SfxChildWinFactArr_Impl); - - for (size_t nFactory=0; nFactory<pImpl->pFactArr->size(); ++nFactory) + for (size_t nFactory=0; nFactory<pImpl->maFactories.size(); ++nFactory) { - if (rFact.nId == (*pImpl->pFactArr)[nFactory].nId) + if (rFact.nId == pImpl->maFactories[nFactory].nId) { - pImpl->pFactArr->erase( pImpl->pFactArr->begin() + nFactory ); + pImpl->maFactories.erase( pImpl->maFactories.begin() + nFactory ); } } - pImpl->pFactArr->push_back( rFact ); + pImpl->maFactories.push_back( rFact ); } -SfxChildWinFactArr_Impl& SfxApplication::GetChildWinFactories_Impl() const +SfxChildWinFactory* SfxApplication::GetChildWinFactoryById(sal_uInt16 nId) const { - return ( *(pImpl->pFactArr)); + for (auto& rFactory : pImpl->maFactories) + if (rFactory.nId == nId) + return &rFactory; + return nullptr; } SfxWorkWindow* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame *pFrame) const diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 0039cdae17a5..41eb91368d4d 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -21,6 +21,7 @@ #include <appdata.hxx> #include <sfxpicklist.hxx> +#include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/doctempl.hxx> #include <sfx2/fcontnr.hxx> @@ -29,7 +30,6 @@ #include <sfx2/sidebar/Theme.hxx> #include <sfx2/objsh.hxx> #include <appbaslib.hxx> -#include <childwinimpl.hxx> #include <ctrlfactoryimpl.hxx> #include <shellimpl.hxx> #include <unoctitm.hxx> diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index d4a7fc134c66..d4716c14d66c 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -24,6 +24,7 @@ #include <sfx2/app.hxx> #include <appdata.hxx> +#include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/msgpool.hxx> #include <sfx2/fcontnr.hxx> @@ -32,7 +33,6 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/objsh.hxx> #include <appbaslib.hxx> -#include <childwinimpl.hxx> #include <ctrlfactoryimpl.hxx> #include <shellimpl.hxx> #include <basic/basicmanagerrepository.hxx> @@ -83,7 +83,7 @@ void SfxApplication::Deinitialize() pImpl->pMatcher.reset(); pImpl->pSlotPool.reset(); - pImpl->pFactArr.reset(); + pImpl->maFactories.clear(); pImpl->pTbxCtrlFac.reset(); pImpl->pStbCtrlFac.reset(); diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index a608c919638b..404d912d9d3e 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -37,7 +37,6 @@ #include <sfx2/dockwin.hxx> #include <sfx2/dispatch.hxx> #include <workwin.hxx> -#include <childwinimpl.hxx> const sal_uInt16 nVersion = 2; @@ -208,26 +207,20 @@ std::unique_ptr<SfxChildWindow> SfxChildWindow::CreateChildWindow( sal_uInt16 nI // by using ChildWindowContext SfxApplication *pApp = SfxGetpApp(); { - SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl(); - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) + pFact = pApp->GetChildWinFactoryById(nId); + if ( pFact ) { - pFact = &rFactories[nFactory]; - if ( pFact->nId == nId ) + SfxChildWinInfo& rFactInfo = pFact->aInfo; + if ( rInfo.bVisible ) { - SfxChildWinInfo& rFactInfo = pFact->aInfo; - if ( rInfo.bVisible ) - { - if ( pBindings ) - pBindings->ENTERREGISTRATIONS(); - SfxChildWinInfo aInfo = rFactInfo; - Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE ); - pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); - Application::SetSystemWindowMode( nOldMode ); - if ( pBindings ) - pBindings->LEAVEREGISTRATIONS(); - } - - break; + if ( pBindings ) + pBindings->ENTERREGISTRATIONS(); + SfxChildWinInfo aInfo = rFactInfo; + Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE ); + pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); + Application::SetSystemWindowMode( nOldMode ); + if ( pBindings ) + pBindings->LEAVEREGISTRATIONS(); } } } @@ -236,30 +229,20 @@ std::unique_ptr<SfxChildWindow> SfxChildWindow::CreateChildWindow( sal_uInt16 nI SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) : nullptr; if (!pChild && pMod) { - SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); - if ( pFactories ) + pFact = pMod->GetChildWinFactoryById(nId); + if ( pFact ) { - SfxChildWinFactArr_Impl &rFactories = *pFactories; - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) + SfxChildWinInfo& rFactInfo = pFact->aInfo; + if ( rInfo.bVisible ) { - pFact = &rFactories[nFactory]; - if ( pFact->nId == nId ) - { - SfxChildWinInfo& rFactInfo = pFact->aInfo; - if ( rInfo.bVisible ) - { - if ( pBindings ) - pBindings->ENTERREGISTRATIONS(); - SfxChildWinInfo aInfo = rFactInfo; - Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE ); - pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); - Application::SetSystemWindowMode( nOldMode ); - if ( pBindings ) - pBindings->LEAVEREGISTRATIONS(); - } - - break; - } + if ( pBindings ) + pBindings->ENTERREGISTRATIONS(); + SfxChildWinInfo aInfo = rFactInfo; + Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE ); + pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); + Application::SetSystemWindowMode( nOldMode ); + if ( pBindings ) + pBindings->LEAVEREGISTRATIONS(); } } } diff --git a/sfx2/source/appl/childwinimpl.cxx b/sfx2/source/appl/childwinimpl.cxx deleted file mode 100644 index d9974de2695c..000000000000 --- a/sfx2/source/appl/childwinimpl.cxx +++ /dev/null @@ -1,53 +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 <memory> -#include <childwinimpl.hxx> - -size_t SfxChildWinFactArr_Impl::size() const -{ - return maData.size(); -} - -const SfxChildWinFactory& SfxChildWinFactArr_Impl::operator []( size_t i ) const -{ - return maData[i]; -} - -SfxChildWinFactory& SfxChildWinFactArr_Impl::operator []( size_t i ) -{ - return maData[i]; -} - -void SfxChildWinFactArr_Impl::push_back( const SfxChildWinFactory& p ) -{ - maData.push_back(p); -} - -void SfxChildWinFactArr_Impl::erase( const iterator& it ) -{ - maData.erase(it); -} - -SfxChildWinFactArr_Impl::iterator SfxChildWinFactArr_Impl::begin() -{ - return maData.begin(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 441f87e086c8..427173897735 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -35,7 +35,6 @@ #define ShellClass_SfxModule #include <sfxslots.hxx> -#include <childwinimpl.hxx> #include <ctrlfactoryimpl.hxx> #include <optional> @@ -46,7 +45,7 @@ public: std::optional<SfxSlotPool> pSlotPool; std::optional<SfxTbxCtrlFactArr_Impl> pTbxCtrlFac; std::optional<SfxStbCtrlFactArr_Impl> pStbCtrlFac; - SfxChildWinFactArr_Impl aFactArr; + std::vector<SfxChildWinFactory> maFactories; OString maResName; SfxModule_Impl(); @@ -111,17 +110,17 @@ void SfxModule::RegisterChildWindow(const SfxChildWinFactory& rFact) { DBG_ASSERT( pImpl, "No real Module!" ); - for (size_t nFactory=0; nFactory<pImpl->aFactArr.size(); ++nFactory) + for (size_t nFactory=0; nFactory<pImpl->maFactories.size(); ++nFactory) { - if (rFact.nId == pImpl->aFactArr[nFactory].nId) + if (rFact.nId == pImpl->maFactories[nFactory].nId) { - pImpl->aFactArr.erase( pImpl->aFactArr.begin() + nFactory ); + pImpl->maFactories.erase( pImpl->maFactories.begin() + nFactory ); SAL_WARN("sfx.appl", "ChildWindow registered multiple times!"); return; } } - pImpl->aFactArr.push_back( rFact ); + pImpl->maFactories.push_back( rFact ); } @@ -178,9 +177,12 @@ SfxStbCtrlFactArr_Impl* SfxModule::GetStbCtrlFactories_Impl() const return pImpl->pStbCtrlFac ? &*pImpl->pStbCtrlFac : nullptr; } -SfxChildWinFactArr_Impl* SfxModule::GetChildWinFactories_Impl() const +SfxChildWinFactory* SfxModule::GetChildWinFactoryById(sal_uInt16 nId) const { - return &pImpl->aFactArr; + for (auto& rFactory : pImpl->maFactories) + if (rFactory.nId == nId) + return &rFactory; + return nullptr; } std::unique_ptr<SfxTabPage> SfxModule::CreateTabPage(sal_uInt16, weld::Container*, weld::DialogController*, const SfxItemSet&) diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 46e485f89062..6f6ab50f4210 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -34,7 +34,6 @@ #include <sfx2/dockwin.hxx> #include <sfx2/viewsh.hxx> #include <splitwin.hxx> -#include <childwinimpl.hxx> #include <sfx2/sfxsids.hrc> #include <sfx2/toolbarids.hxx> #include <vcl/taskpanelist.hxx> @@ -2136,42 +2135,8 @@ void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW) SfxChildWinFactory* pFact=nullptr; SfxApplication *pApp = SfxGetpApp(); { - SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl(); - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) - { - pFact = &rFactories[nFactory]; - if ( pFact->nId == pCW->nSaveId ) - { - pCW->aInfo = pFact->aInfo; - pCW->aInfo.aModule = sModule; - SfxChildWindow::InitializeChildWinFactory_Impl( - pCW->nSaveId, pCW->aInfo); - pCW->bCreate = pCW->aInfo.bVisible; - SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; - if ( nFlags & SfxChildWindowFlags::TASK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; - if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; - if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; - pFact->aInfo = pCW->aInfo; - return; - } - } - } - - if ( !pMod ) - return; - - SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); - if ( !pFactories ) - return; - - SfxChildWinFactArr_Impl &rFactories = *pFactories; - for ( size_t nFactory = 0; nFactory < rFactories.size(); ++nFactory ) - { - pFact = &rFactories[nFactory]; - if ( pFact->nId == pCW->nSaveId ) + pFact = pApp->GetChildWinFactoryById(pCW->nSaveId); + if ( pFact ) { pCW->aInfo = pFact->aInfo; pCW->aInfo.aModule = sModule; @@ -2185,12 +2150,33 @@ void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW) pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; - if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; pFact->aInfo = pCW->aInfo; return; } } + + if ( !pMod ) + return; + + pFact = pMod->GetChildWinFactoryById(pCW->nSaveId); + if ( pFact ) + { + pCW->aInfo = pFact->aInfo; + pCW->aInfo.aModule = sModule; + SfxChildWindow::InitializeChildWinFactory_Impl( + pCW->nSaveId, pCW->aInfo); + pCW->bCreate = pCW->aInfo.bVisible; + SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; + if ( nFlags & SfxChildWindowFlags::TASK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; + if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; + if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; + if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; + pFact->aInfo = pCW->aInfo; + } } SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign ) diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 3228321c66c3..f74d364dfd1a 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -71,8 +71,7 @@ public: std::unique_ptr<DdeService> pDdeService2; // single instance classes - std::unique_ptr<SfxChildWinFactArr_Impl> - pFactArr; + std::vector<SfxChildWinFactory> maFactories; std::vector<SfxFrame*> vTopFrames; // application members diff --git a/sfx2/source/inc/childwinimpl.hxx b/sfx2/source/inc/childwinimpl.hxx deleted file mode 100644 index 219632031312..000000000000 --- a/sfx2/source/inc/childwinimpl.hxx +++ /dev/null @@ -1,50 +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_CHILDWINIMPL_HXX -#define INCLUDED_SFX2_CHILDWINIMPL_HXX - -#include <sfx2/childwin.hxx> - -#include <vector> -#include <memory> - -class SfxFrame; - -class SfxChildWinFactArr_Impl -{ - typedef std::vector<SfxChildWinFactory> DataType; - DataType maData; - -public: - typedef DataType::iterator iterator; - typedef DataType::const_iterator const_iterator; - - size_t size() const; - const SfxChildWinFactory& operator[](size_t i) const; - SfxChildWinFactory& operator[](size_t i); - void push_back(const SfxChildWinFactory&); - void erase(const iterator& it); - - iterator begin(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |