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

Generated by: LCOV version 1.10