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 ChildWindowWrapper
: public SfxChildWindow
25 ChildWindowWrapper( vcl::Window
* pParentP
, sal_uInt16 nId
,
26 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
) :
27 SfxChildWindow(pParentP
, nId
)
29 ScTabViewShell
* pViewShell
= getTabViewShell( pBindings
);
31 pViewShell
= PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
32 OSL_ENSURE(pViewShell
, "Missing view shell!");
35 pWindow
= pViewShell
->CreateRefDialog( pBindings
, this, pInfo
, pParentP
, WindowID
);
39 if (pViewShell
&& !pWindow
)
40 pViewShell
->GetViewFrame()->SetChildWindow( nId
, false );
43 static SfxChildWindow
* CreateImpl(
44 vcl::Window
*pParent
, sal_uInt16 nId
,
45 SfxBindings
*pBindings
, SfxChildWinInfo
* pInfo
)
47 SfxChildWindow
* pWindow
= new ChildWindowWrapper(pParent
, nId
, pBindings
, pInfo
);
51 static void RegisterChildWindow (
52 bool bVisible
= false,
53 SfxModule
* pModule
= NULL
,
54 SfxChildWindowFlags nFlags
= SfxChildWindowFlags::NONE
)
56 SfxChildWinFactory
* pFactory
= new SfxChildWinFactory(ChildWindowWrapper::CreateImpl
, WindowID
, CHILDWIN_NOPOS
);
57 pFactory
->aInfo
.nFlags
|= nFlags
;
58 pFactory
->aInfo
.bVisible
= bVisible
;
59 SfxChildWindow::RegisterChildWindow(pModule
, pFactory
);
62 virtual SfxChildWinInfo
GetInfo() const SAL_OVERRIDE
64 SfxChildWinInfo aInfo
= SfxChildWindow::GetInfo();
65 static_cast<SfxModelessDialog
*>(GetWindow())->FillInfo( aInfo
);
69 static sal_uInt16
GetChildWindowId()
75 static ScTabViewShell
* getTabViewShell( SfxBindings
*pBindings
)
79 SfxDispatcher
* pDispacher
= pBindings
->GetDispatcher();
82 SfxViewFrame
* pFrame
= pDispacher
->GetFrame();
85 SfxViewShell
* pViewShell
= pFrame
->GetViewShell();
88 return dynamic_cast<ScTabViewShell
*>( pViewShell
);
92 #endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */