LCOV - code coverage report
Current view: top level - libreoffice/framework/source/uielement - statusbarmanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 324 14.5 %
Date: 2012-12-27 Functions: 11 36 30.6 %
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             : 
      21             : #include <uielement/statusbarmanager.hxx>
      22             : 
      23             : #include <threadhelp/threadhelpbase.hxx>
      24             : #include <threadhelp/resetableguard.hxx>
      25             : #include <framework/sfxhelperfunctions.hxx>
      26             : #include <macros/generic.hxx>
      27             : #include <macros/xinterface.hxx>
      28             : #include <macros/xtypeprovider.hxx>
      29             : #include <stdtypes.h>
      30             : #include "services.h"
      31             : #include "general.h"
      32             : #include "properties.h"
      33             : #include <helper/mischelper.hxx>
      34             : 
      35             : #include <com/sun/star/frame/XFrame.hpp>
      36             : #include <com/sun/star/frame/XStatusListener.hpp>
      37             : #include <com/sun/star/util/XUpdatable.hpp>
      38             : #include <com/sun/star/ui/ItemStyle.hpp>
      39             : #include <com/sun/star/ui/ItemType.hpp>
      40             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      41             : #include <com/sun/star/beans/XPropertySet.hpp>
      42             : #include <com/sun/star/awt/Command.hpp>
      43             : #include <com/sun/star/lang/DisposedException.hpp>
      44             : #include <comphelper/processfactory.hxx>
      45             : #include <toolkit/unohlp.hxx>
      46             : #include <svtools/statusbarcontroller.hxx>
      47             : 
      48             : #include <vcl/status.hxx>
      49             : #include <vcl/svapp.hxx>
      50             : #include <rtl/logfile.hxx>
      51             : 
      52             : using namespace ::com::sun::star;
      53             : 
      54             : // Property names of a menu/menu item ItemDescriptor
      55             : static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
      56             : static const char ITEM_DESCRIPTOR_HELPURL[]     = "HelpURL";
      57             : static const char ITEM_DESCRIPTOR_OFFSET[]      = "Offset";
      58             : static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
      59             : static const char ITEM_DESCRIPTOR_WIDTH[]       = "Width";
      60             : static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
      61             : 
      62             : namespace framework
      63             : {
      64             : 
      65           0 : static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle )
      66             : {
      67           0 :     sal_uInt16 nItemBits( 0 );
      68             : 
      69           0 :     if (( nStyle & ::com::sun::star::ui::ItemStyle::ALIGN_RIGHT ) == ::com::sun::star::ui::ItemStyle::ALIGN_RIGHT )
      70           0 :         nItemBits |= SIB_RIGHT;
      71           0 :     else if ( nStyle & ::com::sun::star::ui::ItemStyle::ALIGN_LEFT )
      72           0 :         nItemBits |= SIB_LEFT;
      73             :     else
      74           0 :         nItemBits |= SIB_CENTER;
      75             : 
      76           0 :     if (( nStyle & ::com::sun::star::ui::ItemStyle::DRAW_FLAT ) == ::com::sun::star::ui::ItemStyle::DRAW_FLAT )
      77           0 :         nItemBits |= SIB_FLAT;
      78           0 :     else if ( nStyle & ::com::sun::star::ui::ItemStyle::DRAW_OUT3D )
      79           0 :         nItemBits |= SIB_OUT;
      80             :     else
      81           0 :         nItemBits |= SIB_IN;
      82             : 
      83           0 :     if (( nStyle & ::com::sun::star::ui::ItemStyle::AUTO_SIZE ) == ::com::sun::star::ui::ItemStyle::AUTO_SIZE )
      84           0 :         nItemBits |= SIB_AUTOSIZE;
      85           0 :     if ( nStyle & ::com::sun::star::ui::ItemStyle::OWNER_DRAW )
      86           0 :         nItemBits |= SIB_USERDRAW;
      87             : 
      88           0 :     return nItemBits;
      89             : }
      90             : 
      91             : //*****************************************************************************************************************
      92             : //  XInterface, XTypeProvider, XServiceInfo
      93             : //*****************************************************************************************************************
      94        1322 : DEFINE_XINTERFACE_5                     (   StatusBarManager                                                        ,
      95             :                                             ::cppu::OWeakObject                                                     ,
      96             :                                             DIRECT_INTERFACE( lang::XTypeProvider                                   ),
      97             :                                             DIRECT_INTERFACE( lang::XComponent                                      ),
      98             :                                             DIRECT_INTERFACE( frame::XFrameActionListener                           ),
      99             :                                             DIRECT_INTERFACE( css::ui::XUIConfigurationListener                    ),
     100             :                                             DERIVED_INTERFACE( lang::XEventListener, frame::XFrameActionListener    )
     101             :                                         )
     102             : 
     103           0 : DEFINE_XTYPEPROVIDER_5                  (   StatusBarManager                    ,
     104             :                                             lang::XTypeProvider                 ,
     105             :                                             lang::XComponent                    ,
     106             :                                             css::ui::XUIConfigurationListener  ,
     107             :                                             frame::XFrameActionListener         ,
     108             :                                             lang::XEventListener
     109             :                                         )
     110             : 
     111         236 : StatusBarManager::StatusBarManager(
     112             :     const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
     113             :     const uno::Reference< frame::XFrame >& rFrame,
     114             :     const rtl::OUString& rResourceName,
     115             :     StatusBar* pStatusBar ) :
     116         236 :     ThreadHelpBase( &Application::GetSolarMutex() ),
     117             :     OWeakObject(),
     118             :     m_bDisposed( sal_False ),
     119             :     m_bFrameActionRegistered( sal_False ),
     120             :     m_bUpdateControllers( sal_False ),
     121             :     m_bModuleIdentified( sal_False ),
     122             :     m_pStatusBar( pStatusBar ),
     123             :     m_aResourceName( rResourceName ),
     124             :     m_xFrame( rFrame ),
     125         236 :     m_aListenerContainer( m_aLock.getShareableOslMutex() ),
     126         708 :     m_xServiceManager( rServiceManager )
     127             : {
     128             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" );
     129             : 
     130         236 :     if ( m_xServiceManager.is() )
     131             :         m_xStatusbarControllerRegistration = uno::Reference< css::frame::XUIControllerRegistration >(
     132         236 :                                                     m_xServiceManager->createInstance( SERVICENAME_STATUSBARCONTROLLERFACTORY ),
     133         236 :                                                     uno::UNO_QUERY );
     134             : 
     135         236 :     m_pStatusBar->SetClickHdl( LINK( this, StatusBarManager, Click ) );
     136         236 :     m_pStatusBar->SetDoubleClickHdl( LINK( this, StatusBarManager, DoubleClick ) );
     137         236 : }
     138             : 
     139         126 : StatusBarManager::~StatusBarManager()
     140             : {
     141         126 : }
     142             : 
     143        5020 : StatusBar* StatusBarManager::GetStatusBar() const
     144             : {
     145             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" );
     146        5020 :     ResetableGuard aGuard( m_aLock );
     147        5020 :     return m_pStatusBar;
     148             : }
     149             : 
     150           0 : void StatusBarManager::frameAction( const frame::FrameActionEvent& Action )
     151             : throw ( uno::RuntimeException )
     152             : {
     153             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" );
     154           0 :     ResetableGuard aGuard( m_aLock );
     155           0 :     if ( Action.Action == frame::FrameAction_CONTEXT_CHANGED )
     156           0 :         UpdateControllers();
     157           0 : }
     158             : 
     159           0 : void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException )
     160             : {
     161             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" );
     162             :     {
     163           0 :         ResetableGuard aGuard( m_aLock );
     164           0 :         if ( m_bDisposed )
     165           0 :             return;
     166             :     }
     167             : 
     168           0 :     RemoveControllers();
     169             : 
     170             :     {
     171           0 :         ResetableGuard aGuard( m_aLock );
     172           0 :         if ( Source.Source == uno::Reference< uno::XInterface >( m_xFrame, uno::UNO_QUERY ))
     173           0 :             m_xFrame.clear();
     174             : 
     175           0 :         m_xServiceManager.clear();
     176             :     }
     177             : }
     178             : 
     179             : // XComponent
     180          63 : void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException )
     181             : {
     182             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" );
     183             :     uno::Reference< lang::XComponent > xThis(
     184          63 :         static_cast< OWeakObject* >(this), uno::UNO_QUERY );
     185             : 
     186          63 :     lang::EventObject aEvent( xThis );
     187          63 :     m_aListenerContainer.disposeAndClear( aEvent );
     188             : 
     189             :     {
     190          63 :         ResetableGuard aGuard( m_aLock );
     191          63 :         if ( !m_bDisposed )
     192             :         {
     193          63 :             RemoveControllers();
     194             : 
     195          63 :             delete m_pStatusBar;
     196          63 :             m_pStatusBar = 0;
     197             : 
     198          63 :             if ( m_bFrameActionRegistered && m_xFrame.is() )
     199             :             {
     200             :                 try
     201             :                 {
     202           0 :                     m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(
     203             :                                                             static_cast< ::cppu::OWeakObject *>( this ),
     204           0 :                                                             uno::UNO_QUERY ));
     205             :                 }
     206           0 :                 catch ( const uno::Exception& )
     207             :                 {
     208             :                 }
     209             :             }
     210             : 
     211          63 :             m_xFrame.clear();
     212          63 :             m_xServiceManager.clear();
     213             : 
     214          63 :             m_bDisposed = sal_True;
     215          63 :         }
     216          63 :     }
     217          63 : }
     218             : 
     219           0 : void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
     220             : {
     221             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" );
     222           0 :     ResetableGuard aGuard( m_aLock );
     223             : 
     224             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     225           0 :     if ( m_bDisposed )
     226           0 :         throw lang::DisposedException();
     227             : 
     228             :     m_aListenerContainer.addInterface( ::getCppuType(
     229           0 :         ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
     230           0 : }
     231             : 
     232           0 : void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
     233             : {
     234             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" );
     235             :     m_aListenerContainer.removeInterface( ::getCppuType(
     236           0 :         ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
     237           0 : }
     238             : 
     239             : // XUIConfigurationListener
     240           0 : void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
     241             : {
     242             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
     243           0 :     ResetableGuard aGuard( m_aLock );
     244             : 
     245             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     246           0 :     if ( m_bDisposed )
     247           0 :         return;
     248             : }
     249             : 
     250           0 : void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
     251             : {
     252             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
     253           0 :     ResetableGuard aGuard( m_aLock );
     254             : 
     255             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     256           0 :     if ( m_bDisposed )
     257           0 :         return;
     258             : }
     259             : 
     260           0 : void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
     261             : {
     262             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
     263           0 :     ResetableGuard aGuard( m_aLock );
     264             : 
     265             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     266           0 :     if ( m_bDisposed )
     267           0 :         return;
     268             : }
     269             : 
     270           0 : void StatusBarManager::UpdateControllers()
     271             : {
     272             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" );
     273           0 :     if ( !m_bUpdateControllers )
     274             :     {
     275           0 :         m_bUpdateControllers = sal_True;
     276           0 :         const sal_uInt32 nCount = m_aControllerVector.size();
     277           0 :         for ( sal_uInt32 n = 0; n < nCount; n++ )
     278             :         {
     279             :             try
     280             :             {
     281           0 :                 uno::Reference< util::XUpdatable > xUpdatable( m_aControllerVector[n], uno::UNO_QUERY );
     282           0 :                 if ( xUpdatable.is() )
     283           0 :                     xUpdatable->update();
     284             :             }
     285           0 :             catch ( const uno::Exception& )
     286             :             {
     287             :             }
     288             :         }
     289             :     }
     290           0 :     m_bUpdateControllers = sal_False;
     291           0 : }
     292             : 
     293          63 : void StatusBarManager::RemoveControllers()
     294             : {
     295             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" );
     296          63 :     ResetableGuard aGuard( m_aLock );
     297             : 
     298          63 :     if ( m_bDisposed )
     299          63 :         return;
     300             : 
     301          63 :     const sal_uInt32 nCount = m_aControllerVector.size();
     302          63 :     for ( sal_uInt32 n = 0; n < nCount; n++ )
     303             :     {
     304             :         try
     305             :         {
     306             :             uno::Reference< lang::XComponent > xComponent(
     307           0 :                 m_aControllerVector[n], uno::UNO_QUERY );
     308           0 :             if ( xComponent.is() )
     309           0 :                 xComponent->dispose();
     310             :         }
     311           0 :         catch ( const uno::Exception& )
     312             :         {
     313             :         }
     314             : 
     315           0 :         m_aControllerVector[n].clear();
     316          63 :     }
     317             : }
     318             : 
     319           0 : rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL )
     320             : {
     321           0 :     return framework::RetrieveLabelFromCommand(aCmdURL, comphelper::getComponentContext(m_xServiceManager), m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Name");
     322             : }
     323             : 
     324           0 : void StatusBarManager::CreateControllers()
     325             : {
     326             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" );
     327           0 :     uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY );
     328             :     uno::Reference< uno::XComponentContext > xComponentContext(
     329           0 :         comphelper::getComponentContext( m_xServiceManager ) );
     330           0 :     uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar );
     331             : 
     332           0 :     for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ )
     333             :     {
     334           0 :         sal_uInt16 nId = m_pStatusBar->GetItemId( i );
     335           0 :         if ( nId == 0 )
     336           0 :             continue;
     337             : 
     338           0 :         rtl::OUString                            aCommandURL( m_pStatusBar->GetItemCommand( nId ));
     339           0 :         sal_Bool                                 bInit( sal_True );
     340           0 :         uno::Reference< frame::XStatusListener > xController;
     341             : 
     342           0 :         svt::StatusbarController* pController( 0 );
     343             : 
     344           0 :         if ( m_xStatusbarControllerRegistration.is() &&
     345           0 :              m_xStatusbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier ))
     346             :         {
     347           0 :             if ( xStatusbarControllerFactory.is() )
     348             :             {
     349           0 :                 uno::Sequence< uno::Any > aSeq( 5 );
     350           0 :                 beans::PropertyValue aPropValue;
     351             : 
     352           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" ));
     353           0 :                 aPropValue.Value    = uno::makeAny( m_aModuleIdentifier );
     354           0 :                 aSeq[0] = uno::makeAny( aPropValue );
     355           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
     356           0 :                 aPropValue.Value    = uno::makeAny( m_xFrame );
     357           0 :                 aSeq[1] = uno::makeAny( aPropValue );
     358           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
     359           0 :                 aPropValue.Value    = uno::makeAny( m_xServiceManager );
     360           0 :                 aSeq[2] = uno::makeAny( aPropValue );
     361           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
     362           0 :                 aPropValue.Value    = uno::makeAny( xStatusbarWindow );
     363           0 :                 aSeq[3] = uno::makeAny( aPropValue );
     364           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
     365           0 :                 aPropValue.Value    = uno::makeAny( nId );
     366           0 :                 aSeq[4] = uno::makeAny( aPropValue );
     367             : 
     368             :                 xController = uno::Reference< frame::XStatusListener >(
     369           0 :                                 xStatusbarControllerFactory->createInstanceWithArgumentsAndContext(
     370           0 :                                     aCommandURL, aSeq, xComponentContext ),
     371           0 :                                 uno::UNO_QUERY );
     372           0 :                 bInit = sal_False; // Initialization is done through the factory service
     373             :             }
     374             :         }
     375             : 
     376           0 :         if ( !xController.is() )
     377             :         {
     378           0 :             pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
     379           0 :             if ( !pController )
     380           0 :                 pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId );
     381             : 
     382           0 :             if ( pController )
     383             :                 xController = uno::Reference< frame::XStatusListener >(
     384           0 :                                 static_cast< ::cppu::OWeakObject *>( pController ),
     385           0 :                                 uno::UNO_QUERY );
     386             :         }
     387             : 
     388           0 :         m_aControllerVector.push_back( xController );
     389           0 :         uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY );
     390             : 
     391           0 :         if ( xInit.is() )
     392             :         {
     393           0 :             if ( bInit )
     394             :             {
     395           0 :                 beans::PropertyValue aPropValue;
     396           0 :                 uno::Sequence< uno::Any > aArgs( 5 );
     397           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
     398           0 :                 aPropValue.Value    = uno::makeAny( m_xFrame );
     399           0 :                 aArgs[0] = uno::makeAny( aPropValue );
     400           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ));
     401           0 :                 aPropValue.Value    = uno::makeAny( aCommandURL );
     402           0 :                 aArgs[1] = uno::makeAny( aPropValue );
     403           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
     404           0 :                 aPropValue.Value    = uno::makeAny( m_xServiceManager );
     405           0 :                 aArgs[2] = uno::makeAny( aPropValue );
     406           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
     407           0 :                 aPropValue.Value    = uno::makeAny( xStatusbarWindow );
     408           0 :                 aArgs[3] = uno::makeAny( aPropValue );
     409           0 :                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
     410           0 :                 aPropValue.Value    = uno::makeAny( nId );
     411           0 :                 aArgs[4] = uno::makeAny( aPropValue );
     412           0 :                 xInit->initialize( aArgs );
     413             :             }
     414             :         }
     415           0 :     }
     416             : 
     417           0 :     AddFrameActionListener();
     418           0 : }
     419             : 
     420           0 : void StatusBarManager::AddFrameActionListener()
     421             : {
     422             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" );
     423           0 :     if ( !m_bFrameActionRegistered && m_xFrame.is() )
     424             :     {
     425           0 :         m_bFrameActionRegistered = sal_True;
     426           0 :         m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(
     427           0 :             static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY ));
     428             :     }
     429           0 : }
     430             : 
     431           0 : void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAccess >& rItemContainer )
     432             : {
     433             :     RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::StatusBarManager::FillStatusbar" );
     434             : 
     435           0 :     ResetableGuard aGuard( m_aLock );
     436             : 
     437           0 :     if ( m_bDisposed || !m_pStatusBar )
     438           0 :         return;
     439             : 
     440           0 :     sal_uInt16         nId( 1 );
     441             : 
     442           0 :     RemoveControllers();
     443             : 
     444             :     // reset and fill command map
     445           0 :     m_pStatusBar->Clear();
     446           0 :     m_aControllerVector.clear();
     447             : 
     448           0 :     for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
     449             :     {
     450             :         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" );
     451           0 :         uno::Sequence< beans::PropertyValue >   aProp;
     452           0 :         rtl::OUString                           aCommandURL;
     453           0 :         rtl::OUString                           aHelpURL;
     454           0 :         sal_Int16                               nOffset( 0 );
     455           0 :         sal_Int16                               nStyle( 0 );
     456           0 :         sal_Int16                               nWidth( 0 );
     457           0 :         sal_uInt16                              nType( ::com::sun::star::ui::ItemType::DEFAULT );
     458             : 
     459             :         try
     460             :         {
     461           0 :             if ( rItemContainer->getByIndex( n ) >>= aProp )
     462             :             {
     463           0 :                 for ( int i = 0; i < aProp.getLength(); i++ )
     464             :                 {
     465           0 :                     if ( aProp[i].Name == ITEM_DESCRIPTOR_COMMANDURL )
     466             :                     {
     467           0 :                         aProp[i].Value >>= aCommandURL;
     468             :                     }
     469           0 :                     else if ( aProp[i].Name == ITEM_DESCRIPTOR_HELPURL )
     470             :                     {
     471           0 :                         aProp[i].Value >>= aHelpURL;
     472             :                     }
     473           0 :                     else if ( aProp[i].Name == ITEM_DESCRIPTOR_STYLE )
     474             :                     {
     475           0 :                         aProp[i].Value >>= nStyle;
     476             :                     }
     477           0 :                     else if ( aProp[i].Name == ITEM_DESCRIPTOR_TYPE )
     478             :                     {
     479           0 :                         aProp[i].Value >>= nType;
     480             :                     }
     481           0 :                     else if ( aProp[i].Name == ITEM_DESCRIPTOR_WIDTH )
     482             :                     {
     483           0 :                         aProp[i].Value >>= nWidth;
     484             :                     }
     485           0 :                     else if ( aProp[i].Name == ITEM_DESCRIPTOR_OFFSET )
     486             :                     {
     487           0 :                         aProp[i].Value >>= nOffset;
     488             :                     }
     489             :                 }
     490             : 
     491           0 :                 if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
     492             :                 {
     493           0 :                     rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
     494           0 :                     sal_uInt16        nItemBits( impl_convertItemStyleToItemBits( nStyle ));
     495             : 
     496           0 :                     m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );
     497           0 :                     m_pStatusBar->SetItemCommand( nId, aCommandURL );
     498           0 :                     m_pStatusBar->SetAccessibleName( nId, aString );
     499           0 :                     ++nId;
     500             :                 }
     501             :             }
     502             :         }
     503           0 :         catch ( const ::com::sun::star::lang::IndexOutOfBoundsException& )
     504             :         {
     505             :             break;
     506             :         }
     507           0 :     }
     508             : 
     509             :     // Create controllers
     510           0 :     CreateControllers();
     511             : 
     512             :     // Notify controllers that they are now correctly initialized and can start listening
     513           0 :     UpdateControllers();
     514             : }
     515             : 
     516         586 : void StatusBarManager::StateChanged( StateChangedType )
     517             : {
     518             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" );
     519         586 : }
     520             : 
     521          92 : void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt )
     522             : {
     523             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" );
     524          92 :     ResetableGuard aGuard( m_aLock );
     525             : 
     526         184 :     if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS         ) ||
     527           0 :          ( rDCEvt.GetType() == DATACHANGED_FONTS            ) ||
     528           0 :          ( rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION ) ||
     529           0 :          ( rDCEvt.GetType() == DATACHANGED_DISPLAY          ))  &&
     530          92 :          ( rDCEvt.GetFlags() & SETTINGS_STYLE               ))
     531             :     {
     532           0 :         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
     533           0 :         css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY );
     534           0 :         if ( xPropSet.is() )
     535           0 :             xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager;
     536           0 :         if ( xLayoutManager.is() )
     537             :         {
     538           0 :             aGuard.unlock();
     539           0 :             xLayoutManager->doLayout();
     540           0 :         }
     541          92 :     }
     542          92 : }
     543             : 
     544           0 : void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt )
     545             : {
     546             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" );
     547           0 :     ResetableGuard aGuard( m_aLock );
     548             : 
     549           0 :     if ( m_bDisposed )
     550           0 :         return;
     551             : 
     552           0 :     sal_uInt16 nId( rUDEvt.GetItemId() );
     553           0 :     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     554             :     {
     555             :         uno::Reference< frame::XStatusbarController > xController(
     556           0 :             m_aControllerVector[nId-1], uno::UNO_QUERY );
     557           0 :         if ( xController.is() && rUDEvt.GetDevice() )
     558             :         {
     559             :             uno::Reference< awt::XGraphics > xGraphics =
     560           0 :                 rUDEvt.GetDevice()->CreateUnoGraphics();
     561             : 
     562           0 :             awt::Rectangle aRect( rUDEvt.GetRect().Left(),
     563           0 :                                   rUDEvt.GetRect().Top(),
     564           0 :                                   rUDEvt.GetRect().GetWidth(),
     565           0 :                                   rUDEvt.GetRect().GetHeight() );
     566           0 :             aGuard.unlock();
     567           0 :             xController->paint( xGraphics, aRect, rUDEvt.GetItemId(), rUDEvt.GetStyle() );
     568           0 :         }
     569           0 :     }
     570             : }
     571             : 
     572           0 : void StatusBarManager::Command( const CommandEvent& rEvt )
     573             : {
     574             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" );
     575           0 :     ResetableGuard aGuard( m_aLock );
     576             : 
     577           0 :     if ( m_bDisposed )
     578           0 :         return;
     579             : 
     580           0 :     if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU )
     581             :     {
     582           0 :         sal_uInt16 nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() );
     583           0 :         if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     584             :         {
     585             :             uno::Reference< frame::XStatusbarController > xController(
     586           0 :                 m_aControllerVector[nId-1], uno::UNO_QUERY );
     587           0 :             if ( xController.is() )
     588             :             {
     589           0 :                 awt::Point aPos;
     590           0 :                 aPos.X = rEvt.GetMousePosPixel().X();
     591           0 :                 aPos.Y = rEvt.GetMousePosPixel().Y();
     592           0 :                 xController->command( aPos, awt::Command::CONTEXTMENU, sal_True, uno::Any() );
     593           0 :             }
     594             :         }
     595           0 :     }
     596             : }
     597             : 
     598           0 : void StatusBarManager::MouseMove( const MouseEvent& rMEvt )
     599             : {
     600             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" );
     601           0 :     MouseButton(rMEvt,&frame::XStatusbarController::mouseMove);
     602           0 : }
     603           0 : void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&))
     604             : {
     605             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" );
     606           0 :     ResetableGuard aGuard( m_aLock );
     607             : 
     608           0 :     if ( !m_bDisposed )
     609             :     {
     610           0 :         sal_uInt16 nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() );
     611           0 :         if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     612             :         {
     613             :             uno::Reference< frame::XStatusbarController > xController(
     614           0 :                 m_aControllerVector[nId-1], uno::UNO_QUERY );
     615           0 :             if ( xController.is() )
     616             :             {
     617           0 :                 ::com::sun::star::awt::MouseEvent aMouseEvent;
     618           0 :                 aMouseEvent.Buttons = rMEvt.GetButtons();
     619           0 :                 aMouseEvent.X = rMEvt.GetPosPixel().X();
     620           0 :                 aMouseEvent.Y = rMEvt.GetPosPixel().Y();
     621           0 :                 aMouseEvent.ClickCount = rMEvt.GetClicks();
     622           0 :                 (xController.get()->*_pMethod)( aMouseEvent);
     623           0 :             }
     624             :         } // if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     625           0 :     }
     626           0 : }
     627           0 : void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt )
     628             : {
     629             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" );
     630           0 :     MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown);
     631           0 : }
     632             : 
     633           0 : void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt )
     634             : {
     635             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" );
     636           0 :     MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp);
     637           0 : }
     638             : 
     639           0 : IMPL_LINK_NOARG(StatusBarManager, Click)
     640             : {
     641           0 :     ResetableGuard aGuard( m_aLock );
     642             : 
     643           0 :     if ( m_bDisposed )
     644           0 :         return 1;
     645             : 
     646           0 :     sal_uInt16 nId = m_pStatusBar->GetCurItemId();
     647           0 :     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     648             :     {
     649             :         uno::Reference< frame::XStatusbarController > xController(
     650           0 :             m_aControllerVector[nId-1], uno::UNO_QUERY );
     651           0 :         if ( xController.is() )
     652           0 :             xController->click();
     653             :     }
     654             : 
     655           0 :     return 1;
     656             : }
     657             : 
     658           0 : IMPL_LINK_NOARG(StatusBarManager, DoubleClick)
     659             : {
     660           0 :     ResetableGuard aGuard( m_aLock );
     661             : 
     662           0 :     if ( m_bDisposed )
     663           0 :         return 1;
     664             : 
     665           0 :     sal_uInt16 nId = m_pStatusBar->GetCurItemId();
     666           0 :     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
     667             :     {
     668             :         uno::Reference< frame::XStatusbarController > xController(
     669           0 :             m_aControllerVector[nId-1], uno::UNO_QUERY );
     670           0 :         if ( xController.is() )
     671           0 :             xController->doubleClick();
     672             :     }
     673             : 
     674           0 :     return 1;
     675             : }
     676             : 
     677             : }
     678             : 
     679             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10