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