LCOV - code coverage report
Current view: top level - sc/source/ui/inc - ChildWindowWrapper.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 8 40 20.0 %
Date: 2014-11-03 Functions: 20 80 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  */
      10             : 
      11             : #ifndef INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
      12             : #define INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
      13             : 
      14             : #include <sfx2/basedlgs.hxx>
      15             : #include <sfx2/dispatch.hxx>
      16             : #include <sfx2/viewfrm.hxx>
      17             : #include <sfx2/childwin.hxx>
      18             : 
      19             : #include "tabvwsh.hxx"
      20             : 
      21             : template <sal_Int16 WindowID>
      22           0 : class ChildWindowWrapper : public SfxChildWindow
      23             : {
      24             : public:
      25           0 :     ChildWindowWrapper( vcl::Window* pParentP, sal_uInt16 nId,
      26             :                   SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
      27           0 :         SfxChildWindow(pParentP, nId)
      28             :     {
      29           0 :         ScTabViewShell* pViewShell = getTabViewShell( pBindings );
      30           0 :         if (!pViewShell)
      31           0 :             pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
      32             :         OSL_ENSURE(pViewShell, "Missing view shell!");
      33             : 
      34           0 :         if (pViewShell)
      35           0 :             pWindow = pViewShell->CreateRefDialog( pBindings, this, pInfo, pParentP, WindowID );
      36             :         else
      37           0 :             pWindow = NULL;
      38             : 
      39           0 :         if (pViewShell && !pWindow)
      40           0 :             pViewShell->GetViewFrame()->SetChildWindow( nId, false );
      41           0 :     }
      42             : 
      43           0 :     static SfxChildWindow* CreateImpl(
      44             :                 vcl::Window *pParent, sal_uInt16 nId,
      45             :                 SfxBindings *pBindings, SfxChildWinInfo* pInfo )
      46             :     {
      47           0 :         SfxChildWindow* pWindow = new ChildWindowWrapper(pParent, nId, pBindings, pInfo);
      48           0 :         return pWindow;
      49             :     }
      50             : 
      51         760 :     static void RegisterChildWindow (
      52             :                     bool   bVisible = false,
      53             :                     SfxModule* pModule  = NULL,
      54             :                     sal_uInt16 nFlags   = 0)
      55             :     {
      56         760 :         SfxChildWinFactory* pFactory = new SfxChildWinFactory(ChildWindowWrapper::CreateImpl, WindowID, CHILDWIN_NOPOS );
      57         760 :         pFactory->aInfo.nFlags |= nFlags;
      58         760 :         pFactory->aInfo.bVisible = bVisible;
      59         760 :         SfxChildWindow::RegisterChildWindow(pModule, pFactory);
      60         760 :     }
      61             : 
      62           0 :     virtual SfxChildWinInfo GetInfo() const SAL_OVERRIDE
      63             :     {
      64           0 :         SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
      65           0 :         ((SfxModelessDialog*)GetWindow())->FillInfo( aInfo );
      66           0 :         return aInfo;
      67             :     }
      68             : 
      69         760 :     static sal_uInt16 GetChildWindowId()
      70             :     {
      71         760 :         return WindowID;
      72             :     }
      73             : 
      74             : private:
      75           0 :     static ScTabViewShell* getTabViewShell( SfxBindings *pBindings )
      76             :     {
      77           0 :         if( !pBindings )
      78           0 :             return NULL;
      79           0 :         SfxDispatcher* pDispacher = pBindings ->GetDispatcher();
      80           0 :         if( !pDispacher )
      81           0 :             return NULL;
      82           0 :         SfxViewFrame* pFrame = pDispacher->GetFrame();
      83           0 :         if( !pFrame )
      84           0 :             return NULL;
      85           0 :         SfxViewShell* pViewShell = pFrame->GetViewShell();
      86           0 :         if( !pViewShell )
      87           0 :             return NULL;
      88           0 :         return dynamic_cast<ScTabViewShell*>( pViewShell );
      89             :     }
      90             : };
      91             : 
      92             : #endif // INCLUDED_SC_SOURCE_UI_INC_CHILDWINDOWWRAPPER_HXX
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10