fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / ChildWindowWrapper.hxx
blob48938e9ea591c634cc4dbf47b89f2e0d3f8356e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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
24 public:
25 ChildWindowWrapper( vcl::Window* pParentP, sal_uInt16 nId,
26 SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
27 SfxChildWindow(pParentP, nId)
29 ScTabViewShell* pViewShell = getTabViewShell( pBindings );
30 if (!pViewShell)
31 pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
32 OSL_ENSURE(pViewShell, "Missing view shell!");
34 if (pViewShell)
35 pWindow = pViewShell->CreateRefDialog( pBindings, this, pInfo, pParentP, WindowID );
36 else
37 pWindow = NULL;
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);
48 return pWindow;
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 );
66 return aInfo;
69 static sal_uInt16 GetChildWindowId()
71 return WindowID;
74 private:
75 static ScTabViewShell* getTabViewShell( SfxBindings *pBindings )
77 if( !pBindings )
78 return NULL;
79 SfxDispatcher* pDispacher = pBindings ->GetDispatcher();
80 if( !pDispacher )
81 return NULL;
82 SfxViewFrame* pFrame = pDispacher->GetFrame();
83 if( !pFrame )
84 return NULL;
85 SfxViewShell* pViewShell = pFrame->GetViewShell();
86 if( !pViewShell )
87 return NULL;
88 return dynamic_cast<ScTabViewShell*>( pViewShell );
92 #endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */