diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-07-22 17:40:36 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-07-23 20:52:44 +0200 |
commit | 19efbd8d9886e7a346b73aaabe644c56cb2a8e05 (patch) | |
tree | 3559d9d64e6347c4d61feb2391dcb1623a572fbb | |
parent | 1f47b46959267a25195d4f3f5602ca638bb14c58 (diff) |
Generic ChildWindowWrapper.
Change-Id: I7d39dabe4a271c1f29c9b829bed45e0d51abe69b
-rw-r--r-- | sc/source/ui/inc/ChildWindowWrapper.hxx | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/sc/source/ui/inc/ChildWindowWrapper.hxx b/sc/source/ui/inc/ChildWindowWrapper.hxx new file mode 100644 index 000000000000..a9bc144eabdd --- /dev/null +++ b/sc/source/ui/inc/ChildWindowWrapper.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef CHILD_WINDOW_WRAPPER_HXX +#define CHILD_WINDOW_WRAPPER_HXX + +#include <sfx2/basedlgs.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/childwin.hxx> + +#include "tabvwsh.hxx" + +template <sal_Int16 WindowID> +class ChildWindowWrapper : public SfxChildWindow +{ +public: + ChildWindowWrapper( Window* pParentP, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo ) : + SfxChildWindow(pParentP, nId) + { + ScTabViewShell* pViewShell = getTabViewShell( pBindings ); + if (!pViewShell) + pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); + OSL_ENSURE(pViewShell, "Missing view shell!"); + + if (pViewShell) + pWindow = pViewShell->CreateRefDialog( pBindings, this, pInfo, pParentP, WindowID ); + else + pWindow = NULL; + + if (pViewShell && !pWindow) + pViewShell->GetViewFrame()->SetChildWindow( nId, false ); + } + + static SfxChildWindow* CreateImpl( + Window *pParent, sal_uInt16 nId, + SfxBindings *pBindings, SfxChildWinInfo* pInfo ) + { + SfxChildWindow* pWindow = new ChildWindowWrapper(pParent, nId, pBindings, pInfo); + return pWindow; + } + + static void RegisterChildWindow ( + sal_Bool bVisible = sal_False, + SfxModule* pModule = NULL, + sal_uInt16 nFlags = 0) + { + SfxChildWinFactory* pFactory = new SfxChildWinFactory(ChildWindowWrapper::CreateImpl, WindowID, CHILDWIN_NOPOS ); + pFactory->aInfo.nFlags |= nFlags; + pFactory->aInfo.bVisible = bVisible; + SfxChildWindow::RegisterChildWindow(pModule, pFactory); + } + + virtual SfxChildWinInfo GetInfo() const + { + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); + ((SfxModelessDialog*)GetWindow())->FillInfo( aInfo ); + return aInfo; + } + + static sal_uInt16 GetChildWindowId() + { + return WindowID; + } + +private: + static ScTabViewShell* getTabViewShell( SfxBindings *pBindings ) + { + if( !pBindings ) + return NULL; + SfxDispatcher* pDispacher = pBindings ->GetDispatcher(); + if( !pDispacher ) + return NULL; + SfxViewFrame* pFrame = pDispacher->GetFrame(); + if( !pFrame ) + return NULL; + SfxViewShell* pViewShell = pFrame->GetViewShell(); + if( !pViewShell ) + return NULL; + return dynamic_cast<ScTabViewShell*>( pViewShell ); + } +}; + +#endif // CHILD_WINDOW_WRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |