LCOV - code coverage report
Current view: top level - framework/source/uielement - statusbarwrapper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 54 70 77.1 %
Date: 2015-06-13 12:38:46 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        3213 : StatusBarWrapper::StatusBarWrapper(
      54             :     const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
      55             :     )
      56             :  :  UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
      57        3213 :     m_xContext( rxContext )
      58             : {
      59        3213 : }
      60             : 
      61        6414 : StatusBarWrapper::~StatusBarWrapper()
      62             : {
      63        6414 : }
      64             : 
      65        3207 : void SAL_CALL StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException, std::exception)
      66             : {
      67        3207 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
      68             : 
      69        6414 :     com::sun::star::lang::EventObject aEvent( xThis );
      70        3207 :     m_aListenerContainer.disposeAndClear( aEvent );
      71             : 
      72        6414 :     SolarMutexGuard g;
      73        3207 :     if ( !m_bDisposed )
      74             :     {
      75        3207 :         if ( m_xStatusBarManager.is() )
      76        3207 :             m_xStatusBarManager->dispose();
      77        3207 :         m_xStatusBarManager.clear();
      78        3207 :         m_xConfigSource.clear();
      79        3207 :         m_xConfigData.clear();
      80        3207 :         m_xContext.clear();
      81             : 
      82        3207 :         m_bDisposed = true;
      83             :     }
      84             :     else
      85        3207 :         throw DisposedException();
      86        3207 : }
      87             : 
      88             : // XInitialization
      89        3213 : void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException, std::exception )
      90             : {
      91        3213 :     SolarMutexGuard g;
      92             : 
      93        3213 :     if ( m_bDisposed )
      94           0 :         throw DisposedException();
      95             : 
      96        3213 :     if ( !m_bInitialized )
      97             :     {
      98        3213 :         UIConfigElementWrapperBase::initialize( aArguments );
      99             : 
     100        3213 :         Reference< XFrame > xFrame( m_xWeakFrame );
     101        3213 :         if ( xFrame.is() && m_xConfigSource.is() )
     102             :         {
     103             :             // Create VCL based toolbar which will be filled with settings data
     104        3213 :             StatusBar*        pStatusBar( 0 );
     105        3213 :             StatusBarManager* pStatusBarManager( 0 );
     106             :             {
     107        3213 :                 SolarMutexGuard aSolarMutexGuard;
     108        3213 :                 vcl::Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
     109        3213 :                 if ( pWindow )
     110             :                 {
     111        3213 :                     sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
     112             : 
     113        3213 :                     pStatusBar = VclPtr<FrameworkStatusBar>::Create( pWindow, nStyles );
     114        3213 :                     pStatusBarManager = new StatusBarManager( m_xContext, xFrame, m_aResourceURL, pStatusBar );
     115        3213 :                     static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager );
     116        3213 :                     m_xStatusBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
     117        3213 :                     pStatusBar->SetUniqueId( HID_STATUSBAR );
     118        3213 :                 }
     119             :             }
     120             : 
     121             :             try
     122             :             {
     123        3213 :                 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
     124         606 :                 if ( m_xConfigData.is() && pStatusBar && pStatusBarManager )
     125             :                 {
     126             :                     // Fill statusbar with container contents
     127         606 :                     pStatusBarManager->FillStatusBar( m_xConfigData );
     128             :                 }
     129             :             }
     130        2607 :             catch ( const NoSuchElementException& )
     131             :             {
     132             :             }
     133        3213 :         }
     134        3213 :     }
     135        3213 : }
     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       69703 : Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface() throw ( RuntimeException, std::exception )
     164             : {
     165       69703 :     SolarMutexGuard g;
     166             : 
     167       69703 :     if ( m_xStatusBarManager.is() )
     168             :     {
     169       69703 :         StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
     170       69703 :         if ( pStatusBarManager )
     171             :         {
     172       69703 :             vcl::Window* pWindow = static_cast<vcl::Window *>(pStatusBarManager->GetStatusBar());
     173       69703 :             if ( pWindow )
     174       69703 :                 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.11