LCOV - code coverage report
Current view: top level - framework/source/uielement - statusbarwrapper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 54 70 77.1 %
Date: 2014-04-11 Functions: 6 7 85.7 %
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 <uielement/statusbarwrapper.hxx>
      21             : 
      22             : #include <framework/actiontriggerhelper.hxx>
      23             : #include <uielement/constitemcontainer.hxx>
      24             : #include <uielement/rootitemcontainer.hxx>
      25             : #include <uielement/statusbar.hxx>
      26             : #include <helpid.hrc>
      27             : 
      28             : #include <com/sun/star/lang/XServiceInfo.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
      31             : #include <com/sun/star/awt/XMenuBar.hpp>
      32             : #include <com/sun/star/container/XIndexContainer.hpp>
      33             : #include <com/sun/star/container/XNameAccess.hpp>
      34             : #include <com/sun/star/ui/UIElementType.hpp>
      35             : 
      36             : #include <comphelper/processfactory.hxx>
      37             : #include <toolkit/helper/vclunohelper.hxx>
      38             : 
      39             : #include <tools/solar.h>
      40             : #include <vcl/svapp.hxx>
      41             : 
      42             : using namespace com::sun::star::uno;
      43             : using namespace com::sun::star::beans;
      44             : using namespace com::sun::star::frame;
      45             : using namespace com::sun::star::lang;
      46             : using namespace com::sun::star::container;
      47             : using namespace com::sun::star::awt;
      48             : using namespace ::com::sun::star::ui;
      49             : 
      50             : namespace framework
      51             : {
      52             : 
      53        2056 : StatusBarWrapper::StatusBarWrapper(
      54             :     const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
      55             :     )
      56             :  :  UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
      57        2056 :     m_xContext( rxContext )
      58             : {
      59        2056 : }
      60             : 
      61        4096 : StatusBarWrapper::~StatusBarWrapper()
      62             : {
      63        4096 : }
      64             : 
      65        2048 : void SAL_CALL StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException, std::exception)
      66             : {
      67        2048 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
      68             : 
      69        4096 :     com::sun::star::lang::EventObject aEvent( xThis );
      70        2048 :     m_aListenerContainer.disposeAndClear( aEvent );
      71             : 
      72        4096 :     SolarMutexGuard g;
      73        2048 :     if ( !m_bDisposed )
      74             :     {
      75        2048 :         if ( m_xStatusBarManager.is() )
      76        2048 :             m_xStatusBarManager->dispose();
      77        2048 :         m_xStatusBarManager.clear();
      78        2048 :         m_xConfigSource.clear();
      79        2048 :         m_xConfigData.clear();
      80        2048 :         m_xContext.clear();
      81             : 
      82        2048 :         m_bDisposed = true;
      83             :     }
      84             :     else
      85        2048 :         throw DisposedException();
      86        2048 : }
      87             : 
      88             : // XInitialization
      89        2056 : void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException, std::exception )
      90             : {
      91        2056 :     SolarMutexGuard g;
      92             : 
      93        2056 :     if ( m_bDisposed )
      94           0 :         throw DisposedException();
      95             : 
      96        2056 :     if ( !m_bInitialized )
      97             :     {
      98        2056 :         UIConfigElementWrapperBase::initialize( aArguments );
      99             : 
     100        2056 :         Reference< XFrame > xFrame( m_xWeakFrame );
     101        2056 :         if ( xFrame.is() && m_xConfigSource.is() )
     102             :         {
     103             :             // Create VCL based toolbar which will be filled with settings data
     104        2056 :             StatusBar*        pStatusBar( 0 );
     105        2056 :             StatusBarManager* pStatusBarManager( 0 );
     106             :             {
     107        2056 :                 SolarMutexGuard aSolarMutexGuard;
     108        2056 :                 Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
     109        2056 :                 if ( pWindow )
     110             :                 {
     111        2056 :                     sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
     112             : 
     113        2056 :                     pStatusBar = new FrameworkStatusBar( pWindow, nStyles );
     114        2056 :                     pStatusBarManager = new StatusBarManager( m_xContext, xFrame, m_aResourceURL, pStatusBar );
     115        2056 :                     ((FrameworkStatusBar*)pStatusBar)->SetStatusBarManager( pStatusBarManager );
     116        2056 :                     m_xStatusBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
     117        2056 :                     pStatusBar->SetUniqueId( HID_STATUSBAR );
     118        2056 :                 }
     119             :             }
     120             : 
     121             :             try
     122             :             {
     123        2056 :                 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
     124         675 :                 if ( m_xConfigData.is() && pStatusBar && pStatusBarManager )
     125             :                 {
     126             :                     // Fill statusbar with container contents
     127         675 :                     pStatusBarManager->FillStatusBar( m_xConfigData );
     128             :                 }
     129             :             }
     130        1381 :             catch ( const NoSuchElementException& )
     131             :             {
     132             :             }
     133        2056 :         }
     134        2056 :     }
     135        2056 : }
     136             : 
     137             : // XUIElementSettings
     138           0 : void SAL_CALL StatusBarWrapper::updateSettings() throw ( RuntimeException, std::exception )
     139             : {
     140           0 :     SolarMutexGuard g;
     141             : 
     142           0 :     if ( m_bDisposed )
     143           0 :         throw DisposedException();
     144             : 
     145           0 :     if ( m_bPersistent &&
     146           0 :          m_xConfigSource.is() &&
     147           0 :          m_xStatusBarManager.is() )
     148             :     {
     149             :         try
     150             :         {
     151           0 :             StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
     152             : 
     153           0 :             m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
     154           0 :             if ( m_xConfigData.is() )
     155           0 :                 pStatusBarManager->FillStatusBar( m_xConfigData );
     156             :         }
     157           0 :         catch ( const NoSuchElementException& )
     158             :         {
     159             :         }
     160           0 :     }
     161           0 : }
     162             : 
     163       47425 : Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface() throw ( RuntimeException, std::exception )
     164             : {
     165       47425 :     SolarMutexGuard g;
     166             : 
     167       47425 :     if ( m_xStatusBarManager.is() )
     168             :     {
     169       47425 :         StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
     170       47425 :         if ( pStatusBarManager )
     171             :         {
     172       47425 :             Window* pWindow = (Window *)pStatusBarManager->GetStatusBar();
     173       47425 :             if ( pWindow )
     174       47425 :                 return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
     175             :         }
     176             :     }
     177             : 
     178           0 :     return Reference< XInterface >();
     179             : }
     180             : 
     181             : } // namespace framework
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10