LCOV - code coverage report
Current view: top level - sfx2/source/dialog - partwnd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 50 71 70.4 %
Date: 2012-08-25 Functions: 12 14 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50 137 36.5 %

           Branch data     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 [ +  - ][ +  - ]:        237 : SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
                 [ +  - ]
      51                 :            : 
      52                 :          2 : SfxPartChildWnd_Impl::SfxPartChildWnd_Impl
      53                 :            : (
      54                 :            :     Window* pParentWnd,
      55                 :            :     sal_uInt16 nId,
      56                 :            :     SfxBindings* pBindings,
      57                 :            :     SfxChildWinInfo* pInfo
      58                 :            : )
      59                 :          2 :     : SfxChildWindow( pParentWnd, nId )
      60                 :            : {
      61                 :            :     // Create Window
      62 [ +  - ][ +  - ]:          2 :     pWindow = new SfxPartDockWnd_Impl( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK );
      63                 :          2 :     eChildAlignment = SFX_ALIGN_TOP;
      64         [ +  - ]:          2 :     if ( pInfo )
      65                 :          2 :         pInfo->nFlags |= SFX_CHILDWIN_FORCEDOCK;
      66                 :            : 
      67                 :          2 :     ((SfxDockingWindow*)pWindow)->SetFloatingSize( Size( 175, 175 ) );
      68         [ +  - ]:          2 :     pWindow->SetSizePixel( Size( 175, 175 ) );
      69                 :            : 
      70         [ +  - ]:          2 :     ( ( SfxDockingWindow* ) pWindow )->Initialize( pInfo );
      71         [ +  - ]:          2 :     SetHideNotDelete( sal_True );
      72                 :          2 : }
      73                 :            : 
      74                 :          2 : SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
      75                 :            : {
      76         [ +  - ]:          2 :     ::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                 :          2 :     SfxPartDockWnd_Impl* pWin = (SfxPartDockWnd_Impl*) pWindow;
      85                 :            : 
      86 [ +  - ][ +  - ]:          2 :     if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
         [ +  - ][ -  + ]
                 [ +  - ]
           [ -  +  #  # ]
      87 [ #  # ][ #  # ]:          2 :         pWin->GetBindings().SetActiveFrame( NULL );
      88         [ -  + ]:          4 : }
      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                 :          2 : SfxPartDockWnd_Impl::SfxPartDockWnd_Impl
     100                 :            : (
     101                 :            :     SfxBindings* pBind,
     102                 :            :     SfxChildWindow* pChildWin,
     103                 :            :     Window* pParent,
     104                 :            :     WinBits nBits
     105                 :            : )
     106                 :          2 :     : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
     107                 :            : {
     108                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame(
     109 [ +  - ][ +  - ]:          4 :             ::comphelper::getProcessServiceFactory()->createInstance(
     110 [ +  - ][ +  - ]:          2 :             DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), ::com::sun::star::uno::UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     111 [ +  - ][ +  - ]:          2 :     xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
                 [ +  - ]
     112                 :            : 
     113                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet(
     114         [ +  - ]:          2 :         xFrame, ::com::sun::star::uno::UNO_QUERY );
     115                 :            :     try
     116                 :            :     {
     117         [ +  - ]:          2 :         const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ));
     118                 :          2 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xLMPropSet;
     119                 :            : 
     120 [ +  - ][ +  - ]:          2 :         ::com::sun::star::uno::Any a = xPropSet->getPropertyValue( aLayoutManager );
     121 [ +  - ][ +  - ]:          2 :         if ( a >>= xLMPropSet )
     122                 :            :         {
     123         [ +  - ]:          2 :             const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" ));
     124 [ +  - ][ +  - ]:          2 :             xLMPropSet->setPropertyValue( aAutomaticToolbars, ::com::sun::star::uno::Any( sal_False ));
                 [ +  - ]
     125                 :          2 :         }
     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         [ +  - ]:          2 :     pChildWin->SetFrame( xFrame );
     136         [ +  - ]:          2 :     if ( pBind->GetDispatcher() )
     137                 :            :     {
     138                 :            :         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier >
     139 [ +  - ][ +  - ]:          2 :                 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY );
         [ +  - ][ +  - ]
     140         [ +  - ]:          2 :         if ( xSupp.is() )
     141 [ +  - ][ +  - ]:          2 :             xSupp->getFrames()->append( xFrame );
         [ +  - ][ +  - ]
     142                 :            :     }
     143                 :            :     else {
     144                 :            :         OSL_FAIL("Bindings without Dispatcher!");
     145                 :          2 :     }
     146                 :          2 : }
     147                 :            : 
     148                 :            : //****************************************************************************
     149                 :            : 
     150                 :          2 : SfxPartDockWnd_Impl::~SfxPartDockWnd_Impl()
     151                 :            : {
     152         [ -  + ]:          4 : }
     153                 :            : 
     154                 :            : //****************************************************************************
     155                 :            : 
     156                 :          2 : void SfxPartDockWnd_Impl::Resize()
     157                 :            : 
     158                 :            : /*  [Description]
     159                 :            : 
     160                 :            :     Adjusting the size of the controls wrt the new window size
     161                 :            : */
     162                 :            : 
     163                 :            : {
     164                 :          2 :     SfxDockingWindow::Resize();
     165                 :          2 : }
     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                 :        262 : long SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt )
     190                 :            : {
     191         [ -  + ]:        262 :     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                 :        262 :     return SfxDockingWindow::Notify( rEvt );
     203                 :            : }
     204                 :            : 
     205                 :          4 : void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
     206                 :            : {
     207                 :          4 :     SfxDockingWindow::FillInfo( rInfo );
     208                 :          4 :     rInfo.bVisible = sal_False;
     209                 :          4 : }
     210                 :            : 
     211                 :            : 
     212                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10