LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/dialog - partwnd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 71 1.4 %
Date: 2012-12-27 Functions: 1 14 7.1 %
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/task/XStatusIndicator.hpp>
      22             : #include <com/sun/star/uno/Reference.h>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : #include <com/sun/star/util/URL.hpp>
      26             : #include <com/sun/star/frame/XFrame.hpp>
      27             : #include <com/sun/star/util/XCloseable.hpp>
      28             : #include <com/sun/star/util/CloseVetoException.hpp>
      29             : #include <com/sun/star/lang/XComponent.hpp>
      30             : #include <com/sun/star/lang/DisposedException.hpp>
      31             : #include <com/sun/star/frame/XController.hpp>
      32             : #include <com/sun/star/beans/XPropertySet.hpp>
      33             : #include <com/sun/star/awt/PosSize.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          19 : SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
      51             : 
      52           0 : SfxPartChildWnd_Impl::SfxPartChildWnd_Impl
      53             : (
      54             :     Window* pParentWnd,
      55             :     sal_uInt16 nId,
      56             :     SfxBindings* pBindings,
      57             :     SfxChildWinInfo* pInfo
      58             : )
      59           0 :     : SfxChildWindow( pParentWnd, nId )
      60             : {
      61             :     // Create Window
      62           0 :     pWindow = new SfxPartDockWnd_Impl( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK );
      63           0 :     eChildAlignment = SFX_ALIGN_TOP;
      64           0 :     if ( pInfo )
      65           0 :         pInfo->nFlags |= SFX_CHILDWIN_FORCEDOCK;
      66             : 
      67           0 :     ((SfxDockingWindow*)pWindow)->SetFloatingSize( Size( 175, 175 ) );
      68           0 :     pWindow->SetSizePixel( Size( 175, 175 ) );
      69             : 
      70           0 :     ( ( SfxDockingWindow* ) pWindow )->Initialize( pInfo );
      71           0 :     SetHideNotDelete( sal_True );
      72           0 : }
      73             : 
      74           0 : SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
      75             : {
      76           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = GetFrame();
      77             : 
      78             :     // If xFrame=NULL release pMgr! Because this window lives longer then the manager!
      79             :     // In these case we got a xFrame->dispose() call from outside ... and has release our
      80             :     // frame reference in our own DisposingListener.
      81             :     // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
      82             :     // and we need a valid pMgr for further operations ...
      83             : 
      84           0 :     SfxPartDockWnd_Impl* pWin = (SfxPartDockWnd_Impl*) pWindow;
      85             : 
      86           0 :     if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
      87           0 :         pWin->GetBindings().SetActiveFrame( NULL );
      88           0 : }
      89             : 
      90           0 : sal_Bool SfxPartChildWnd_Impl::QueryClose()
      91             : {
      92           0 :     return ( (SfxPartDockWnd_Impl*)pWindow )->QueryClose();
      93             : }
      94             : 
      95             : //****************************************************************************
      96             : // SfxPartDockWnd_Impl
      97             : //****************************************************************************
      98             : 
      99           0 : SfxPartDockWnd_Impl::SfxPartDockWnd_Impl
     100             : (
     101             :     SfxBindings* pBind,
     102             :     SfxChildWindow* pChildWin,
     103             :     Window* pParent,
     104             :     WinBits nBits
     105             : )
     106           0 :     : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
     107             : {
     108             :     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame(
     109           0 :             ::comphelper::getProcessServiceFactory()->createInstance(
     110           0 :             DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), ::com::sun::star::uno::UNO_QUERY );
     111           0 :     xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
     112             : 
     113             :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet(
     114           0 :         xFrame, ::com::sun::star::uno::UNO_QUERY );
     115             :     try
     116             :     {
     117           0 :         const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ));
     118           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xLMPropSet;
     119             : 
     120           0 :         ::com::sun::star::uno::Any a = xPropSet->getPropertyValue( aLayoutManager );
     121           0 :         if ( a >>= xLMPropSet )
     122             :         {
     123           0 :             const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" ));
     124           0 :             xLMPropSet->setPropertyValue( aAutomaticToolbars, ::com::sun::star::uno::Any( sal_False ));
     125           0 :         }
     126             :     }
     127           0 :     catch( ::com::sun::star::uno::RuntimeException& )
     128             :     {
     129           0 :         throw;
     130             :     }
     131           0 :     catch( ::com::sun::star::uno::Exception& )
     132             :     {
     133             :     }
     134             : 
     135           0 :     pChildWin->SetFrame( xFrame );
     136           0 :     if ( pBind->GetDispatcher() )
     137             :     {
     138             :         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier >
     139           0 :                 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY );
     140           0 :         if ( xSupp.is() )
     141           0 :             xSupp->getFrames()->append( xFrame );
     142             :     }
     143             :     else {
     144             :         OSL_FAIL("Bindings without Dispatcher!");
     145           0 :     }
     146           0 : }
     147             : 
     148             : //****************************************************************************
     149             : 
     150           0 : SfxPartDockWnd_Impl::~SfxPartDockWnd_Impl()
     151             : {
     152           0 : }
     153             : 
     154             : //****************************************************************************
     155             : 
     156           0 : void SfxPartDockWnd_Impl::Resize()
     157             : 
     158             : /*  [Description]
     159             : 
     160             :     Adjusting the size of the controls wrt the new window size
     161             : */
     162             : 
     163             : {
     164           0 :     SfxDockingWindow::Resize();
     165           0 : }
     166             : 
     167             : //****************************************************************************
     168             : 
     169           0 : sal_Bool SfxPartDockWnd_Impl::QueryClose()
     170             : {
     171           0 :     sal_Bool bClose = sal_True;
     172           0 :     SfxChildWindow* pChild = GetChildWindow_Impl();
     173           0 :     if( pChild )
     174             :     {
     175           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
     176           0 :         if( xFrame.is() )
     177             :         {
     178           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >  xCtrl = xFrame->getController();
     179           0 :             if( xCtrl.is() )
     180           0 :                 bClose = xCtrl->suspend( sal_True );
     181           0 :         }
     182             :     }
     183             : 
     184           0 :     return bClose;
     185             : }
     186             : 
     187             : //****************************************************************************
     188             : 
     189           0 : long SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt )
     190             : {
     191           0 :     if( rEvt.GetType() == EVENT_GETFOCUS )
     192             :     {
     193           0 :         SfxChildWindow* pChild = GetChildWindow_Impl();
     194           0 :         if( pChild )
     195             :         {
     196           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
     197           0 :             if( xFrame.is() )
     198           0 :                 xFrame->activate();
     199             :         }
     200             :     }
     201             : 
     202           0 :     return SfxDockingWindow::Notify( rEvt );
     203             : }
     204             : 
     205           0 : void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
     206             : {
     207           0 :     SfxDockingWindow::FillInfo( rInfo );
     208           0 :     rInfo.bVisible = sal_False;
     209           0 : }
     210             : 
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10