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 CHILD_WINDOW_WRAPPER_HXX
12 #define CHILD_WINDOW_WRAPPER_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( 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 Window
*pParent
, sal_uInt16 nId
,
45 SfxBindings
*pBindings
, SfxChildWinInfo
* pInfo
)
47 SfxChildWindow
* pWindow
= new ChildWindowWrapper(pParent
, nId
, pBindings
, pInfo
);
51 static void RegisterChildWindow (
52 sal_Bool bVisible
= sal_False
,
53 SfxModule
* pModule
= NULL
,
54 sal_uInt16 nFlags
= 0)
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
64 SfxChildWinInfo aInfo
= SfxChildWindow::GetInfo();
65 ((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 // CHILD_WINDOW_WRAPPER_HXX
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */