diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /sc/source/ui/inc/ChildWindowWrapper.hxx | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/ui/inc/ChildWindowWrapper.hxx')
-rw-r--r-- | sc/source/ui/inc/ChildWindowWrapper.hxx | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/sc/source/ui/inc/ChildWindowWrapper.hxx b/sc/source/ui/inc/ChildWindowWrapper.hxx new file mode 100644 index 000000000..dad043e22 --- /dev/null +++ b/sc/source/ui/inc/ChildWindowWrapper.hxx @@ -0,0 +1,84 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX +#define INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX + +#include <sfx2/basedlgs.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/childwin.hxx> + +#include "tabvwsh.hxx" + +template <sal_Int16 WindowID> +class ChildControllerWrapper : public SfxChildWindow +{ +public: + ChildControllerWrapper(vcl::Window* pParentP, sal_uInt16 nId, + SfxBindings* pBindings, const SfxChildWinInfo* pInfo) + : SfxChildWindow(pParentP, nId) + { + ScTabViewShell* pViewShell = getTabViewShell( pBindings ); + if (!pViewShell) + pViewShell = dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() ); + OSL_ENSURE(pViewShell, "Missing view shell!"); + + if (pViewShell) + SetController(pViewShell->CreateRefDialogController(pBindings, this, pInfo, pParentP->GetFrameWeld(), WindowID)); + + if (pViewShell && !GetController()) + pViewShell->GetViewFrame()->SetChildWindow( nId, false ); + } + + static std::unique_ptr<SfxChildWindow> CreateImpl( + vcl::Window *pParent, sal_uInt16 nId, + SfxBindings *pBindings, SfxChildWinInfo* pInfo ) + { + return std::make_unique<ChildControllerWrapper>(pParent, nId, pBindings, pInfo); + } + + static void RegisterChildWindow ( + bool bVisible = false, + SfxModule* pModule = nullptr, + SfxChildWindowFlags nFlags = SfxChildWindowFlags::NONE) + { + auto pFactory = std::make_unique<SfxChildWinFactory>(ChildControllerWrapper::CreateImpl, WindowID, CHILDWIN_NOPOS ); + pFactory->aInfo.nFlags |= nFlags; + pFactory->aInfo.bVisible = bVisible; + SfxChildWindow::RegisterChildWindow(pModule, std::move(pFactory)); + } + + static sal_uInt16 GetChildWindowId() + { + return WindowID; + } + +private: + static ScTabViewShell* getTabViewShell( const SfxBindings *pBindings ) + { + if( !pBindings ) + return nullptr; + SfxDispatcher* pDispacher = pBindings ->GetDispatcher(); + if( !pDispacher ) + return nullptr; + SfxViewFrame* pFrame = pDispacher->GetFrame(); + if( !pFrame ) + return nullptr; + SfxViewShell* pViewShell = pFrame->GetViewShell(); + if( !pViewShell ) + return nullptr; + return dynamic_cast<ScTabViewShell*>( pViewShell ); + } +}; + +#endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |