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/.
13 #include <sfx2/dispatch.hxx>
14 #include <sfx2/viewfrm.hxx>
15 #include <sfx2/childwin.hxx>
16 #include <osl/diagnose.h>
18 #include "tabvwsh.hxx"
20 template <sal_Int16 WindowID
>
21 class ChildControllerWrapper
: public SfxChildWindow
24 ChildControllerWrapper(vcl::Window
* pParentP
, sal_uInt16 nId
,
25 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
)
26 : SfxChildWindow(pParentP
, nId
)
28 ScTabViewShell
* pViewShell
= getTabViewShell( pBindings
);
30 pViewShell
= dynamic_cast< ScTabViewShell
*>( SfxViewShell::Current() );
31 OSL_ENSURE(pViewShell
, "Missing view shell!");
34 SetController(pViewShell
->CreateRefDialogController(pBindings
, this, pInfo
, pParentP
->GetFrameWeld(), WindowID
));
36 if (pViewShell
&& !GetController())
37 pViewShell
->GetViewFrame().SetChildWindow( nId
, false );
40 static std::unique_ptr
<SfxChildWindow
> CreateImpl(
41 vcl::Window
*pParent
, sal_uInt16 nId
,
42 SfxBindings
*pBindings
, SfxChildWinInfo
* pInfo
)
44 return std::make_unique
<ChildControllerWrapper
>(pParent
, nId
, pBindings
, pInfo
);
47 static void RegisterChildWindow (
48 bool bVisible
= false,
49 SfxModule
* pModule
= nullptr,
50 SfxChildWindowFlags nFlags
= SfxChildWindowFlags::NONE
)
52 SfxChildWinFactory
aFactory(ChildControllerWrapper::CreateImpl
, WindowID
, CHILDWIN_NOPOS
);
53 aFactory
.aInfo
.nFlags
|= nFlags
;
54 aFactory
.aInfo
.bVisible
= bVisible
;
55 SfxChildWindow::RegisterChildWindow(pModule
, aFactory
);
58 static sal_uInt16
GetChildWindowId()
64 static ScTabViewShell
* getTabViewShell( const SfxBindings
*pBindings
)
68 SfxDispatcher
* pDispacher
= pBindings
->GetDispatcher();
71 SfxViewFrame
* pFrame
= pDispacher
->GetFrame();
74 SfxViewShell
* pViewShell
= pFrame
->GetViewShell();
77 return dynamic_cast<ScTabViewShell
*>( pViewShell
);
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */