LCOV - code coverage report
Current view: top level - sfx2/source/dialog - partwnd.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 40 62 64.5 %
Date: 2015-06-13 12:38:46 Functions: 10 12 83.3 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/awt/XWindow.hpp>
      21             : #include <com/sun/star/awt/PosSize.hpp>
      22             : #include <com/sun/star/beans/PropertyValue.hpp>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/frame/Frame.hpp>
      25             : #include <com/sun/star/frame/XController.hpp>
      26             : #include <com/sun/star/lang/XComponent.hpp>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/task/XStatusIndicator.hpp>
      29             : #include <com/sun/star/uno/Reference.h>
      30             : #include <com/sun/star/uno/Sequence.hxx>
      31             : #include <com/sun/star/util/URL.hpp>
      32             : #include <com/sun/star/util/XCloseable.hpp>
      33             : #include <com/sun/star/util/CloseVetoException.hpp>
      34             : #include <comphelper/processfactory.hxx>
      35             : 
      36             : #include <toolkit/helper/vclunohelper.hxx>
      37             : 
      38             : #include <sfx2/sfxsids.hrc>
      39             : #include "partwnd.hxx"
      40             : #include <sfx2/bindings.hxx>
      41             : #include <sfx2/dispatch.hxx>
      42             : #include <sfx2/viewfrm.hxx>
      43             : #include <sfx2/frame.hxx>
      44             : #include <sfx2/sfxuno.hxx>
      45             : 
      46             : 
      47             : // SfxPartChildWnd_Impl
      48             : 
      49             : 
      50         210 : SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
      51             : 
      52           1 : SfxPartChildWnd_Impl::SfxPartChildWnd_Impl
      53             : (
      54             :     vcl::Window* pParentWnd,
      55             :     sal_uInt16 nId,
      56             :     SfxBindings* pBindings,
      57             :     SfxChildWinInfo* pInfo
      58             : )
      59           1 :     : SfxChildWindow( pParentWnd, nId )
      60             : {
      61             :     // Create Window
      62           1 :     pWindow = VclPtr<SfxPartDockWnd_Impl>::Create( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK );
      63           1 :     eChildAlignment = SfxChildAlignment::TOP;
      64             : 
      65             :     assert(pInfo);
      66           1 :     pInfo->nFlags |= SfxChildWindowFlags::FORCEDOCK;
      67             : 
      68           1 :     static_cast<SfxDockingWindow*>(pWindow.get())->SetFloatingSize( Size( 175, 175 ) );
      69           1 :     pWindow->SetSizePixel( Size( 175, 175 ) );
      70             : 
      71           1 :     static_cast<SfxDockingWindow*>(pWindow.get())->Initialize( pInfo );
      72           1 :     SetHideNotDelete( true );
      73           1 : }
      74             : 
      75           3 : SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
      76             : {
      77           1 :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = GetFrame();
      78             : 
      79             :     // If xFrame=NULL release pMgr! Because this window lives longer then the manager!
      80             :     // In these case we got a xFrame->dispose() call from outside ... and has release our
      81             :     // frame reference in our own DisposingListener.
      82             :     // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
      83             :     // and we need a valid pMgr for further operations ...
      84             : 
      85           1 :     SfxPartDockWnd_Impl* pWin = static_cast<SfxPartDockWnd_Impl*>(pWindow.get());
      86             : 
      87           1 :     if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
      88           0 :         pWin->GetBindings().SetActiveFrame( NULL );
      89           2 : }
      90             : 
      91           0 : bool SfxPartChildWnd_Impl::QueryClose()
      92             : {
      93           0 :     return static_cast<SfxPartDockWnd_Impl*>(pWindow.get())->QueryClose();
      94             : }
      95             : 
      96             : 
      97             : // SfxPartDockWnd_Impl
      98             : 
      99             : 
     100           1 : SfxPartDockWnd_Impl::SfxPartDockWnd_Impl
     101             : (
     102             :     SfxBindings* pBind,
     103             :     SfxChildWindow* pChildWin,
     104             :     vcl::Window* pParent,
     105             :     WinBits nBits
     106             : )
     107           1 :     : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
     108             : {
     109             :     css::uno::Reference < css::frame::XFrame2 > xFrame = css::frame::Frame::create(
     110           1 :             ::comphelper::getProcessComponentContext() );
     111           1 :     xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
     112             : 
     113             :     try
     114             :     {
     115           1 :         css::uno::Reference< css::beans::XPropertySet > xLMPropSet( xFrame->getLayoutManager(), css::uno::UNO_QUERY_THROW );
     116             : 
     117           2 :         const OUString aAutomaticToolbars( "AutomaticToolbars" );
     118           2 :         xLMPropSet->setPropertyValue( aAutomaticToolbars, css::uno::Any( sal_False ));
     119             :     }
     120           0 :     catch( css::uno::RuntimeException& )
     121             :     {
     122           0 :         throw;
     123             :     }
     124           0 :     catch( css::uno::Exception& )
     125             :     {
     126             :     }
     127             : 
     128           1 :     pChildWin->SetFrame( css::uno::Reference<css::frame::XFrame>(xFrame,css::uno::UNO_QUERY_THROW) );
     129           1 :     if ( pBind->GetDispatcher() )
     130             :     {
     131             :         css::uno::Reference < css::frame::XFramesSupplier >
     132           1 :                 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY );
     133           1 :         if ( xSupp.is() )
     134           1 :             xSupp->getFrames()->append( css::uno::Reference<css::frame::XFrame>(xFrame, css::uno::UNO_QUERY_THROW) );
     135             :     }
     136             :     else {
     137             :         OSL_FAIL("Bindings without Dispatcher!");
     138           1 :     }
     139           1 : }
     140             : 
     141             : 
     142             : 
     143           1 : void SfxPartDockWnd_Impl::Resize()
     144             : 
     145             : /*  [Description]
     146             : 
     147             :     Adjusting the size of the controls wrt the new window size
     148             : */
     149             : 
     150             : {
     151           1 :     SfxDockingWindow::Resize();
     152           1 : }
     153             : 
     154             : 
     155             : 
     156           0 : bool SfxPartDockWnd_Impl::QueryClose()
     157             : {
     158           0 :     bool bClose = true;
     159           0 :     SfxChildWindow* pChild = GetChildWindow_Impl();
     160           0 :     if( pChild )
     161             :     {
     162           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
     163           0 :         if( xFrame.is() )
     164             :         {
     165           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >  xCtrl = xFrame->getController();
     166           0 :             if( xCtrl.is() )
     167           0 :                 bClose = xCtrl->suspend( sal_True );
     168           0 :         }
     169             :     }
     170             : 
     171           0 :     return bClose;
     172             : }
     173             : 
     174             : 
     175             : 
     176         131 : bool SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt )
     177             : {
     178         131 :     if( rEvt.GetType() == MouseNotifyEvent::GETFOCUS )
     179             :     {
     180           0 :         SfxChildWindow* pChild = GetChildWindow_Impl();
     181           0 :         if( pChild )
     182             :         {
     183           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
     184           0 :             if( xFrame.is() )
     185           0 :                 xFrame->activate();
     186             :         }
     187             :     }
     188             : 
     189         131 :     return SfxDockingWindow::Notify( rEvt );
     190             : }
     191             : 
     192           2 : void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
     193             : {
     194           2 :     SfxDockingWindow::FillInfo( rInfo );
     195           2 :     rInfo.bVisible = false;
     196           2 : }
     197             : 
     198             : 
     199             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11