LCOV - code coverage report
Current view: top level - framework/source/uielement - statusbarwrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 70 78.6 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 55 146 37.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <uielement/statusbarwrapper.hxx>
      31                 :            : 
      32                 :            : #include <threadhelp/resetableguard.hxx>
      33                 :            : #include <framework/actiontriggerhelper.hxx>
      34                 :            : #include <uielement/constitemcontainer.hxx>
      35                 :            : #include <uielement/rootitemcontainer.hxx>
      36                 :            : #include <uielement/statusbar.hxx>
      37                 :            : #include <helpid.hrc>
      38                 :            : 
      39                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      40                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      41                 :            : #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
      42                 :            : #include <com/sun/star/awt/XMenuBar.hpp>
      43                 :            : #include <com/sun/star/container/XIndexContainer.hpp>
      44                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      45                 :            : #include <com/sun/star/ui/UIElementType.hpp>
      46                 :            : 
      47                 :            : #include <comphelper/processfactory.hxx>
      48                 :            : #include <toolkit/unohlp.hxx>
      49                 :            : 
      50                 :            : #include <tools/solar.h>
      51                 :            : #include <vcl/svapp.hxx>
      52                 :            : #include <rtl/logfile.hxx>
      53                 :            : 
      54                 :            : using namespace com::sun::star::uno;
      55                 :            : using namespace com::sun::star::beans;
      56                 :            : using namespace com::sun::star::frame;
      57                 :            : using namespace com::sun::star::lang;
      58                 :            : using namespace com::sun::star::container;
      59                 :            : using namespace com::sun::star::awt;
      60                 :            : using namespace ::com::sun::star::ui;
      61                 :            : 
      62                 :            : namespace framework
      63                 :            : {
      64                 :            : 
      65                 :       1741 : StatusBarWrapper::StatusBarWrapper(
      66                 :            :     const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager
      67                 :            :     )
      68                 :       1741 :  :  UIConfigElementWrapperBase( UIElementType::STATUSBAR,xServiceManager )
      69                 :            : {
      70                 :       1741 : }
      71                 :            : 
      72                 :       1650 : StatusBarWrapper::~StatusBarWrapper()
      73                 :            : {
      74         [ -  + ]:       3300 : }
      75                 :            : 
      76                 :       1650 : void SAL_CALL StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException)
      77                 :            : {
      78         [ +  - ]:       1650 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
      79                 :            : 
      80         [ +  - ]:       1650 :     com::sun::star::lang::EventObject aEvent( xThis );
      81         [ +  - ]:       1650 :     m_aListenerContainer.disposeAndClear( aEvent );
      82                 :            : 
      83         [ +  - ]:       1650 :     ResetableGuard aLock( m_aLock );
      84         [ +  - ]:       1650 :     if ( !m_bDisposed )
      85                 :            :     {
      86         [ +  - ]:       1650 :         if ( m_xStatusBarManager.is() )
      87 [ +  - ][ +  - ]:       1650 :             m_xStatusBarManager->dispose();
      88                 :       1650 :         m_xStatusBarManager.clear();
      89                 :       1650 :         m_xConfigSource.clear();
      90                 :       1650 :         m_xConfigData.clear();
      91                 :       1650 :         m_xServiceFactory.clear();
      92                 :            : 
      93                 :       1650 :         m_bDisposed = sal_True;
      94                 :            :     }
      95                 :            :     else
      96 [ #  # ][ +  - ]:       1650 :         throw DisposedException();
                 [ +  - ]
      97                 :       1650 : }
      98                 :            : 
      99                 :            : // XInitialization
     100                 :       1741 : void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
     101                 :            : {
     102         [ +  - ]:       1741 :     ResetableGuard aLock( m_aLock );
     103                 :            : 
     104         [ -  + ]:       1741 :     if ( m_bDisposed )
     105         [ #  # ]:          0 :         throw DisposedException();
     106                 :            : 
     107         [ +  - ]:       1741 :     if ( !m_bInitialized )
     108                 :            :     {
     109         [ +  - ]:       1741 :         UIConfigElementWrapperBase::initialize( aArguments );
     110                 :            : 
     111         [ +  - ]:       1741 :         Reference< XFrame > xFrame( m_xWeakFrame );
     112 [ +  - ][ +  - ]:       1741 :         if ( xFrame.is() && m_xConfigSource.is() )
                 [ +  - ]
     113                 :            :         {
     114                 :            :             // Create VCL based toolbar which will be filled with settings data
     115                 :       1741 :             StatusBar*        pStatusBar( 0 );
     116                 :       1741 :             StatusBarManager* pStatusBarManager( 0 );
     117                 :            :             {
     118         [ +  - ]:       1741 :                 SolarMutexGuard aSolarMutexGuard;
     119 [ +  - ][ +  - ]:       1741 :                 Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
                 [ +  - ]
     120         [ +  - ]:       1741 :                 if ( pWindow )
     121                 :            :                 {
     122                 :       1741 :                     sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
     123                 :            : 
     124 [ +  - ][ +  - ]:       1741 :                     pStatusBar = new FrameworkStatusBar( pWindow, nStyles );
     125         [ +  - ]:       1741 :                     pStatusBarManager = new StatusBarManager( m_xServiceFactory, xFrame, m_aResourceURL, pStatusBar );
     126         [ +  - ]:       1741 :                     ((FrameworkStatusBar*)pStatusBar)->SetStatusBarManager( pStatusBarManager );
     127 [ +  - ][ +  - ]:       1741 :                     m_xStatusBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
                 [ +  - ]
     128         [ +  - ]:       1741 :                     pStatusBar->SetUniqueId( HID_STATUSBAR );
     129         [ +  - ]:       1741 :                 }
     130                 :            :             }
     131                 :            : 
     132                 :            :             try
     133                 :            :             {
     134 [ +  - ][ +  + ]:       1741 :                 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
         [ +  - ][ -  + ]
     135 [ +  - ][ +  - ]:       1177 :                 if ( m_xConfigData.is() && pStatusBar && pStatusBarManager )
         [ +  - ][ +  - ]
     136                 :            :                 {
     137                 :            :                     // Fill statusbar with container contents
     138         [ +  - ]:       1177 :                     pStatusBarManager->FillStatusBar( m_xConfigData );
     139                 :            :                 }
     140                 :            :             }
     141         [ +  - ]:        564 :             catch ( const NoSuchElementException& )
     142                 :            :             {
     143                 :            :             }
     144                 :       1741 :         }
     145         [ +  - ]:       1741 :     }
     146                 :       1741 : }
     147                 :            : 
     148                 :            : // XUIElementSettings
     149                 :          0 : void SAL_CALL StatusBarWrapper::updateSettings() throw ( RuntimeException )
     150                 :            : {
     151         [ #  # ]:          0 :     ResetableGuard aLock( m_aLock );
     152                 :            : 
     153         [ #  # ]:          0 :     if ( m_bDisposed )
     154         [ #  # ]:          0 :         throw DisposedException();
     155                 :            : 
     156   [ #  #  #  #  :          0 :     if ( m_bPersistent &&
           #  # ][ #  # ]
     157                 :          0 :          m_xConfigSource.is() &&
     158                 :          0 :          m_xStatusBarManager.is() )
     159                 :            :     {
     160                 :            :         try
     161                 :            :         {
     162 [ #  # ][ #  # ]:          0 :             StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :             m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
         [ #  # ][ #  # ]
     165         [ #  # ]:          0 :             if ( m_xConfigData.is() )
     166         [ #  # ]:          0 :                 pStatusBarManager->FillStatusBar( m_xConfigData );
     167                 :            :         }
     168         [ #  # ]:          0 :         catch ( const NoSuchElementException& )
     169                 :            :         {
     170                 :            :         }
     171         [ #  # ]:          0 :     }
     172                 :          0 : }
     173                 :            : 
     174                 :      53882 : Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface() throw ( RuntimeException )
     175                 :            : {
     176         [ +  - ]:      53882 :     ResetableGuard aLock( m_aLock );
     177                 :            : 
     178         [ +  - ]:      53882 :     if ( m_xStatusBarManager.is() )
     179                 :            :     {
     180 [ +  - ][ +  - ]:      53882 :         StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
     181         [ +  - ]:      53882 :         if ( pStatusBarManager )
     182                 :            :         {
     183         [ +  - ]:      53882 :             Window* pWindow = (Window *)pStatusBarManager->GetStatusBar();
     184         [ +  - ]:      53882 :             if ( pWindow )
     185 [ +  - ][ +  - ]:      53882 :                 return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
     186                 :            :         }
     187                 :            :     }
     188                 :            : 
     189         [ +  - ]:      53882 :     return Reference< XInterface >();
     190                 :            : }
     191                 :            : 
     192                 :            : } // namespace framework
     193                 :            : 
     194                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10