1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #ifndef INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
12 #define INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
14 #include <sfx2/basedlgs.hxx>
15 #include <sfx2/dispatch.hxx>
16 #include <sfx2/viewfrm.hxx>
17 #include <sfx2/childwin.hxx>
19 #include "tabvwsh.hxx"
21 template <sal_Int16 WindowID
>
22 class ChildControllerWrapper
: public SfxChildWindow
25 ChildControllerWrapper(vcl::Window
* pParentP
, sal_uInt16 nId
,
26 SfxBindings
* pBindings
, const SfxChildWinInfo
* pInfo
)
27 : SfxChildWindow(pParentP
, nId
)
29 ScTabViewShell
* pViewShell
= getTabViewShell( pBindings
);
31 pViewShell
= dynamic_cast< ScTabViewShell
*>( SfxViewShell::Current() );
32 OSL_ENSURE(pViewShell
, "Missing view shell!");
35 SetController(pViewShell
->CreateRefDialogController(pBindings
, this, pInfo
, pParentP
->GetFrameWeld(), WindowID
));
37 if (pViewShell
&& !GetController())
38 pViewShell
->GetViewFrame()->SetChildWindow( nId
, false );
41 static std::unique_ptr
<SfxChildWindow
> CreateImpl(
42 vcl::Window
*pParent
, sal_uInt16 nId
,
43 SfxBindings
*pBindings
, SfxChildWinInfo
* pInfo
)
45 return std::make_unique
<ChildControllerWrapper
>(pParent
, nId
, pBindings
, pInfo
);
48 static void RegisterChildWindow (
49 bool bVisible
= false,
50 SfxModule
* pModule
= nullptr,
51 SfxChildWindowFlags nFlags
= SfxChildWindowFlags::NONE
)
53 auto pFactory
= std::make_unique
<SfxChildWinFactory
>(ChildControllerWrapper::CreateImpl
, WindowID
, CHILDWIN_NOPOS
);
54 pFactory
->aInfo
.nFlags
|= nFlags
;
55 pFactory
->aInfo
.bVisible
= bVisible
;
56 SfxChildWindow::RegisterChildWindow(pModule
, std::move(pFactory
));
59 static sal_uInt16
GetChildWindowId()
65 static ScTabViewShell
* getTabViewShell( const SfxBindings
*pBindings
)
69 SfxDispatcher
* pDispacher
= pBindings
->GetDispatcher();
72 SfxViewFrame
* pFrame
= pDispacher
->GetFrame();
75 SfxViewShell
* pViewShell
= pFrame
->GetViewShell();
78 return dynamic_cast<ScTabViewShell
*>( pViewShell
);
82 #endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */