16d739b60SAndrew Rist /************************************************************** 2*2503e1a5SAriel Constenla-Haile * 36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 56d739b60SAndrew Rist * distributed with this work for additional information 66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 86d739b60SAndrew Rist * "License"); you may not use this file except in compliance 96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10*2503e1a5SAriel Constenla-Haile * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2503e1a5SAriel Constenla-Haile * 136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 146d739b60SAndrew Rist * software distributed under the License is distributed on an 156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166d739b60SAndrew Rist * KIND, either express or implied. See the License for the 176d739b60SAndrew Rist * specific language governing permissions and limitations 186d739b60SAndrew Rist * under the License. 19*2503e1a5SAriel Constenla-Haile * 206d739b60SAndrew Rist *************************************************************/ 216d739b60SAndrew Rist 226d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <uielement/statusbarmanager.hxx> 28*2503e1a5SAriel Constenla-Haile #include <uielement/genericstatusbarcontroller.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 31cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 32cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx> 33*2503e1a5SAriel Constenla-Haile #include <framework/addonsoptions.hxx> 34*2503e1a5SAriel Constenla-Haile #include <uielement/statusbarmerger.hxx> 35*2503e1a5SAriel Constenla-Haile #include <uielement/statusbaritem.hxx> 36cdf0e10cSrcweir #include <macros/generic.hxx> 37cdf0e10cSrcweir #include <macros/xinterface.hxx> 38cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 39cdf0e10cSrcweir #include <stdtypes.h> 40cdf0e10cSrcweir #include "services.h" 41cdf0e10cSrcweir #include "general.h" 42cdf0e10cSrcweir #include "properties.h" 43cdf0e10cSrcweir #include <helper/mischelper.hxx> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 46cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 47cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp> 48cdf0e10cSrcweir #include <com/sun/star/ui/ItemStyle.hpp> 49cdf0e10cSrcweir #include <com/sun/star/ui/ItemType.hpp> 50cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 51cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 52cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp> 53*2503e1a5SAriel Constenla-Haile #include <com/sun/star/ui/XStatusbarItem.hdl> 54cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 55cdf0e10cSrcweir 56*2503e1a5SAriel Constenla-Haile #include <toolkit/helper/vclunohelper.hxx> 57cdf0e10cSrcweir 58cdf0e10cSrcweir #include <svtools/statusbarcontroller.hxx> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include <vcl/status.hxx> 61cdf0e10cSrcweir #include <vcl/svapp.hxx> 62cdf0e10cSrcweir #include <rtl/logfile.hxx> 63cdf0e10cSrcweir 64*2503e1a5SAriel Constenla-Haile #include <functional> 65*2503e1a5SAriel Constenla-Haile 66cdf0e10cSrcweir using namespace ::com::sun::star; 67cdf0e10cSrcweir #ifndef css 68cdf0e10cSrcweir #define css ::com::sun::star 69cdf0e10cSrcweir #endif 70cdf0e10cSrcweir #ifndef css_ui 71cdf0e10cSrcweir #define css_ui ::com::sun::star::ui 72cdf0e10cSrcweir #endif 73cdf0e10cSrcweir 74cdf0e10cSrcweir const sal_Int32 HELPID_PREFIX_LENGTH = 7; 75cdf0e10cSrcweir static const char* HELPID_PREFIX = "helpid:"; 76cdf0e10cSrcweir 77cdf0e10cSrcweir // Property names of a menu/menu item ItemDescriptor 78cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; 79cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; 80cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_OFFSET[] = "Offset"; 81cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; 82cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_WIDTH[] = "Width"; 83cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; 84cdf0e10cSrcweir 85cdf0e10cSrcweir namespace framework 86cdf0e10cSrcweir { 87cdf0e10cSrcweir 88*2503e1a5SAriel Constenla-Haile namespace 89*2503e1a5SAriel Constenla-Haile { 90*2503e1a5SAriel Constenla-Haile 91*2503e1a5SAriel Constenla-Haile template< class MAP > 92*2503e1a5SAriel Constenla-Haile struct lcl_UpdateController : public std::unary_function< typename MAP::value_type, void > 93*2503e1a5SAriel Constenla-Haile { 94*2503e1a5SAriel Constenla-Haile void operator()( typename MAP::value_type &rElement ) const 95*2503e1a5SAriel Constenla-Haile { 96*2503e1a5SAriel Constenla-Haile try 97*2503e1a5SAriel Constenla-Haile { 98*2503e1a5SAriel Constenla-Haile uno::Reference< util::XUpdatable > xUpdatable( rElement.second, uno::UNO_QUERY ); 99*2503e1a5SAriel Constenla-Haile if ( xUpdatable.is() ) 100*2503e1a5SAriel Constenla-Haile xUpdatable->update(); 101*2503e1a5SAriel Constenla-Haile } 102*2503e1a5SAriel Constenla-Haile catch ( uno::Exception& ) 103*2503e1a5SAriel Constenla-Haile { 104*2503e1a5SAriel Constenla-Haile } 105*2503e1a5SAriel Constenla-Haile } 106*2503e1a5SAriel Constenla-Haile }; 107*2503e1a5SAriel Constenla-Haile 108*2503e1a5SAriel Constenla-Haile template< class MAP > 109*2503e1a5SAriel Constenla-Haile struct lcl_RemoveController : public std::unary_function< typename MAP::value_type, void > 110*2503e1a5SAriel Constenla-Haile { 111*2503e1a5SAriel Constenla-Haile void operator()( typename MAP::value_type &rElement ) const 112*2503e1a5SAriel Constenla-Haile { 113*2503e1a5SAriel Constenla-Haile try 114*2503e1a5SAriel Constenla-Haile { 115*2503e1a5SAriel Constenla-Haile uno::Reference< lang::XComponent > xComponent( rElement.second, uno::UNO_QUERY ); 116*2503e1a5SAriel Constenla-Haile if ( xComponent.is() ) 117*2503e1a5SAriel Constenla-Haile xComponent->dispose(); 118*2503e1a5SAriel Constenla-Haile } 119*2503e1a5SAriel Constenla-Haile catch ( uno::Exception& ) 120*2503e1a5SAriel Constenla-Haile { 121*2503e1a5SAriel Constenla-Haile } 122*2503e1a5SAriel Constenla-Haile } 123*2503e1a5SAriel Constenla-Haile }; 124*2503e1a5SAriel Constenla-Haile 125cdf0e10cSrcweir static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir sal_uInt16 nItemBits( 0 ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::ALIGN_RIGHT ) == css_ui::ItemStyle::ALIGN_RIGHT ) 130cdf0e10cSrcweir nItemBits |= SIB_RIGHT; 131cdf0e10cSrcweir else if ( nStyle & css_ui::ItemStyle::ALIGN_LEFT ) 132cdf0e10cSrcweir nItemBits |= SIB_LEFT; 133cdf0e10cSrcweir else 134cdf0e10cSrcweir nItemBits |= SIB_CENTER; 135cdf0e10cSrcweir 136cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::DRAW_FLAT ) == css_ui::ItemStyle::DRAW_FLAT ) 137cdf0e10cSrcweir nItemBits |= SIB_FLAT; 138cdf0e10cSrcweir else if ( nStyle & css_ui::ItemStyle::DRAW_OUT3D ) 139cdf0e10cSrcweir nItemBits |= SIB_OUT; 140cdf0e10cSrcweir else 141cdf0e10cSrcweir nItemBits |= SIB_IN; 142cdf0e10cSrcweir 143cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::AUTO_SIZE ) == css_ui::ItemStyle::AUTO_SIZE ) 144cdf0e10cSrcweir nItemBits |= SIB_AUTOSIZE; 145cdf0e10cSrcweir if ( nStyle & css_ui::ItemStyle::OWNER_DRAW ) 146cdf0e10cSrcweir nItemBits |= SIB_USERDRAW; 147cdf0e10cSrcweir 148cdf0e10cSrcweir return nItemBits; 149cdf0e10cSrcweir } 150*2503e1a5SAriel Constenla-Haile 151*2503e1a5SAriel Constenla-Haile } 152cdf0e10cSrcweir //***************************************************************************************************************** 153cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 154cdf0e10cSrcweir //***************************************************************************************************************** 155cdf0e10cSrcweir DEFINE_XINTERFACE_5 ( StatusBarManager , 156cdf0e10cSrcweir ::cppu::OWeakObject , 157cdf0e10cSrcweir DIRECT_INTERFACE( lang::XTypeProvider ), 158cdf0e10cSrcweir DIRECT_INTERFACE( lang::XComponent ), 159cdf0e10cSrcweir DIRECT_INTERFACE( frame::XFrameActionListener ), 160cdf0e10cSrcweir DIRECT_INTERFACE( css::ui::XUIConfigurationListener ), 161cdf0e10cSrcweir DERIVED_INTERFACE( lang::XEventListener, frame::XFrameActionListener ) 162cdf0e10cSrcweir ) 163cdf0e10cSrcweir 164cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_5 ( StatusBarManager , 165cdf0e10cSrcweir lang::XTypeProvider , 166cdf0e10cSrcweir lang::XComponent , 167cdf0e10cSrcweir css::ui::XUIConfigurationListener , 168cdf0e10cSrcweir frame::XFrameActionListener , 169cdf0e10cSrcweir lang::XEventListener 170cdf0e10cSrcweir ) 171cdf0e10cSrcweir 172cdf0e10cSrcweir StatusBarManager::StatusBarManager( 173cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rServiceManager, 174cdf0e10cSrcweir const uno::Reference< frame::XFrame >& rFrame, 175cdf0e10cSrcweir const rtl::OUString& rResourceName, 176cdf0e10cSrcweir StatusBar* pStatusBar ) : 177cdf0e10cSrcweir ThreadHelpBase( &Application::GetSolarMutex() ), 178cdf0e10cSrcweir OWeakObject(), 179cdf0e10cSrcweir m_bDisposed( sal_False ), 180cdf0e10cSrcweir m_bFrameActionRegistered( sal_False ), 181cdf0e10cSrcweir m_bUpdateControllers( sal_False ), 182cdf0e10cSrcweir m_bModuleIdentified( sal_False ), 183cdf0e10cSrcweir m_pStatusBar( pStatusBar ), 184cdf0e10cSrcweir m_aResourceName( rResourceName ), 185cdf0e10cSrcweir m_xFrame( rFrame ), 186cdf0e10cSrcweir m_aListenerContainer( m_aLock.getShareableOslMutex() ), 187cdf0e10cSrcweir m_xServiceManager( rServiceManager ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir if ( m_xServiceManager.is() ) 192cdf0e10cSrcweir m_xStatusbarControllerRegistration = uno::Reference< css::frame::XUIControllerRegistration >( 193cdf0e10cSrcweir m_xServiceManager->createInstance( SERVICENAME_STATUSBARCONTROLLERFACTORY ), 194cdf0e10cSrcweir uno::UNO_QUERY ); 195cdf0e10cSrcweir 196cdf0e10cSrcweir m_pStatusBar->SetClickHdl( LINK( this, StatusBarManager, Click ) ); 197cdf0e10cSrcweir m_pStatusBar->SetDoubleClickHdl( LINK( this, StatusBarManager, DoubleClick ) ); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir StatusBarManager::~StatusBarManager() 201cdf0e10cSrcweir { 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir StatusBar* StatusBarManager::GetStatusBar() const 205cdf0e10cSrcweir { 206cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" ); 207cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 208cdf0e10cSrcweir return m_pStatusBar; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir void StatusBarManager::frameAction( const frame::FrameActionEvent& Action ) 212cdf0e10cSrcweir throw ( uno::RuntimeException ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" ); 215cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 216cdf0e10cSrcweir if ( Action.Action == frame::FrameAction_CONTEXT_CHANGED ) 217cdf0e10cSrcweir UpdateControllers(); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" ); 223cdf0e10cSrcweir { 224cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 225cdf0e10cSrcweir if ( m_bDisposed ) 226cdf0e10cSrcweir return; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir RemoveControllers(); 230cdf0e10cSrcweir 231cdf0e10cSrcweir { 232cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 233cdf0e10cSrcweir if ( Source.Source == uno::Reference< uno::XInterface >( m_xFrame, uno::UNO_QUERY )) 234cdf0e10cSrcweir m_xFrame.clear(); 235cdf0e10cSrcweir 236cdf0e10cSrcweir m_xServiceManager.clear(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir // XComponent 241cdf0e10cSrcweir void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" ); 244cdf0e10cSrcweir uno::Reference< lang::XComponent > xThis( 245cdf0e10cSrcweir static_cast< OWeakObject* >(this), uno::UNO_QUERY ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir lang::EventObject aEvent( xThis ); 248cdf0e10cSrcweir m_aListenerContainer.disposeAndClear( aEvent ); 249*2503e1a5SAriel Constenla-Haile 250cdf0e10cSrcweir { 251cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 252cdf0e10cSrcweir if ( !m_bDisposed ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir RemoveControllers(); 255*2503e1a5SAriel Constenla-Haile 256*2503e1a5SAriel Constenla-Haile // destroy the item data 257*2503e1a5SAriel Constenla-Haile for ( sal_uInt16 n = 0; n < m_pStatusBar->GetItemCount(); n++ ) 258*2503e1a5SAriel Constenla-Haile { 259*2503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pUserData = static_cast< AddonStatusbarItemData *>( 260*2503e1a5SAriel Constenla-Haile m_pStatusBar->GetItemData( m_pStatusBar->GetItemId( n ) ) ); 261*2503e1a5SAriel Constenla-Haile if ( pUserData ) 262*2503e1a5SAriel Constenla-Haile delete pUserData; 263*2503e1a5SAriel Constenla-Haile } 264*2503e1a5SAriel Constenla-Haile 265cdf0e10cSrcweir delete m_pStatusBar; 266cdf0e10cSrcweir m_pStatusBar = 0; 267cdf0e10cSrcweir 268cdf0e10cSrcweir if ( m_bFrameActionRegistered && m_xFrame.is() ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir try 271cdf0e10cSrcweir { 272cdf0e10cSrcweir m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >( 273cdf0e10cSrcweir static_cast< ::cppu::OWeakObject *>( this ), 274cdf0e10cSrcweir uno::UNO_QUERY )); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir catch ( uno::Exception& ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir } 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir m_xFrame.clear(); 282cdf0e10cSrcweir m_xServiceManager.clear(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir m_bDisposed = sal_True; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir } 287cdf0e10cSrcweir } 288cdf0e10cSrcweir 289cdf0e10cSrcweir void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" ); 292cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 293cdf0e10cSrcweir 294cdf0e10cSrcweir /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 295cdf0e10cSrcweir if ( m_bDisposed ) 296cdf0e10cSrcweir throw lang::DisposedException(); 297cdf0e10cSrcweir 298cdf0e10cSrcweir m_aListenerContainer.addInterface( ::getCppuType( 299cdf0e10cSrcweir ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener ); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" ); 305cdf0e10cSrcweir m_aListenerContainer.removeInterface( ::getCppuType( 306cdf0e10cSrcweir ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir // XUIConfigurationListener 310cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" ); 313cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 314*2503e1a5SAriel Constenla-Haile 315cdf0e10cSrcweir if ( m_bDisposed ) 316cdf0e10cSrcweir return; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" ); 322cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 323*2503e1a5SAriel Constenla-Haile 324cdf0e10cSrcweir if ( m_bDisposed ) 325cdf0e10cSrcweir return; 326cdf0e10cSrcweir } 327*2503e1a5SAriel Constenla-Haile 328cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" ); 331cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 332*2503e1a5SAriel Constenla-Haile 333cdf0e10cSrcweir if ( m_bDisposed ) 334cdf0e10cSrcweir return; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir void StatusBarManager::UpdateControllers() 338cdf0e10cSrcweir { 339cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" ); 340cdf0e10cSrcweir if ( !m_bUpdateControllers ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir m_bUpdateControllers = sal_True; 343*2503e1a5SAriel Constenla-Haile std::for_each( m_aControllerMap.begin(), 344*2503e1a5SAriel Constenla-Haile m_aControllerMap.end(), 345*2503e1a5SAriel Constenla-Haile lcl_UpdateController< StatusBarControllerMap >() ); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir m_bUpdateControllers = sal_False; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir void StatusBarManager::RemoveControllers() 351cdf0e10cSrcweir { 352cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" ); 353cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir if ( m_bDisposed ) 356cdf0e10cSrcweir return; 357cdf0e10cSrcweir 358*2503e1a5SAriel Constenla-Haile std::for_each( m_aControllerMap.begin(), 359*2503e1a5SAriel Constenla-Haile m_aControllerMap.end(), 360*2503e1a5SAriel Constenla-Haile lcl_RemoveController< StatusBarControllerMap >() ); 361*2503e1a5SAriel Constenla-Haile m_aControllerMap.clear(); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir return framework::RetrieveLabelFromCommand(aCmdURL,m_xServiceManager,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Name"); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir void StatusBarManager::CreateControllers() 370cdf0e10cSrcweir { 371cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" ); 372cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY ); 373cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xComponentContext; 374cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY ); 375cdf0e10cSrcweir uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar ); 376*2503e1a5SAriel Constenla-Haile 377cdf0e10cSrcweir if ( xProps.is() ) 378cdf0e10cSrcweir xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext; 379*2503e1a5SAriel Constenla-Haile 380cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( i ); 383cdf0e10cSrcweir if ( nId == 0 ) 384cdf0e10cSrcweir continue; 385*2503e1a5SAriel Constenla-Haile 386cdf0e10cSrcweir rtl::OUString aCommandURL( m_pStatusBar->GetItemCommand( nId )); 387cdf0e10cSrcweir sal_Bool bInit( sal_True ); 388cdf0e10cSrcweir uno::Reference< frame::XStatusListener > xController; 389*2503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pItemData = static_cast< AddonStatusbarItemData *>( m_pStatusBar->GetItemData( nId ) ); 390*2503e1a5SAriel Constenla-Haile uno::Reference< ui::XStatusbarItem > xStatusbarItem( 391*2503e1a5SAriel Constenla-Haile static_cast< cppu::OWeakObject *>( new StatusbarItem( m_pStatusBar, pItemData, nId, aCommandURL ) ), 392*2503e1a5SAriel Constenla-Haile uno::UNO_QUERY ); 393*2503e1a5SAriel Constenla-Haile 394cdf0e10cSrcweir svt::StatusbarController* pController( 0 ); 395*2503e1a5SAriel Constenla-Haile 396*2503e1a5SAriel Constenla-Haile // 1º) UNO Statusbar controllers, registered in Controllers.xcu 397cdf0e10cSrcweir if ( m_xStatusbarControllerRegistration.is() && 398cdf0e10cSrcweir m_xStatusbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier )) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir if ( xStatusbarControllerFactory.is() ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir beans::PropertyValue aPropValue; 403*2503e1a5SAriel Constenla-Haile std::vector< uno::Any > aPropVector; 404*2503e1a5SAriel Constenla-Haile 405cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" )); 406cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_aModuleIdentifier ); 407*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 408*2503e1a5SAriel Constenla-Haile 409cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 410cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xFrame ); 411*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 412*2503e1a5SAriel Constenla-Haile 413*2503e1a5SAriel Constenla-Haile // TODO remove this 414cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); 415cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xServiceManager ); 416*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 417*2503e1a5SAriel Constenla-Haile 418cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); 419cdf0e10cSrcweir aPropValue.Value = uno::makeAny( xStatusbarWindow ); 420*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 421*2503e1a5SAriel Constenla-Haile 422*2503e1a5SAriel Constenla-Haile // TODO still needing with the css::ui::XStatusbarItem? 423cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" )); 424cdf0e10cSrcweir aPropValue.Value = uno::makeAny( nId ); 425*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 426cdf0e10cSrcweir 427*2503e1a5SAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" )); 428*2503e1a5SAriel Constenla-Haile aPropValue.Value <<= xStatusbarItem; 429*2503e1a5SAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 430*2503e1a5SAriel Constenla-Haile 431*2503e1a5SAriel Constenla-Haile uno::Sequence< uno::Any > aArgs( comphelper::containerToSequence( aPropVector ) ); 432cdf0e10cSrcweir xController = uno::Reference< frame::XStatusListener >( 433cdf0e10cSrcweir xStatusbarControllerFactory->createInstanceWithArgumentsAndContext( 434*2503e1a5SAriel Constenla-Haile aCommandURL, aArgs, xComponentContext ), 435cdf0e10cSrcweir uno::UNO_QUERY ); 436cdf0e10cSrcweir bInit = sal_False; // Initialization is done through the factory service 437cdf0e10cSrcweir } 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir if ( !xController.is() ) 441cdf0e10cSrcweir { 442*2503e1a5SAriel Constenla-Haile // 2º) Old SFX2 Statusbar controllers 443cdf0e10cSrcweir pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL ); 444cdf0e10cSrcweir if ( !pController ) 445*2503e1a5SAriel Constenla-Haile { 446*2503e1a5SAriel Constenla-Haile // 3º) Is Add-on? Generic statusbar controller 447*2503e1a5SAriel Constenla-Haile if ( pItemData ) 448*2503e1a5SAriel Constenla-Haile { 449*2503e1a5SAriel Constenla-Haile pController = new GenericStatusbarController( m_xServiceManager, 450*2503e1a5SAriel Constenla-Haile m_xFrame, 451*2503e1a5SAriel Constenla-Haile xStatusbarItem, 452*2503e1a5SAriel Constenla-Haile pItemData ); 453*2503e1a5SAriel Constenla-Haile } 454*2503e1a5SAriel Constenla-Haile else 455*2503e1a5SAriel Constenla-Haile { 456*2503e1a5SAriel Constenla-Haile // 4º) Default Statusbar controller 457*2503e1a5SAriel Constenla-Haile pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId ); 458*2503e1a5SAriel Constenla-Haile } 459*2503e1a5SAriel Constenla-Haile } 460*2503e1a5SAriel Constenla-Haile 461cdf0e10cSrcweir if ( pController ) 462cdf0e10cSrcweir xController = uno::Reference< frame::XStatusListener >( 463cdf0e10cSrcweir static_cast< ::cppu::OWeakObject *>( pController ), 464cdf0e10cSrcweir uno::UNO_QUERY ); 465cdf0e10cSrcweir } 466*2503e1a5SAriel Constenla-Haile 467*2503e1a5SAriel Constenla-Haile m_aControllerMap[nId] = xController; 468cdf0e10cSrcweir uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY ); 469*2503e1a5SAriel Constenla-Haile 470cdf0e10cSrcweir if ( xInit.is() ) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir if ( bInit ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir beans::PropertyValue aPropValue; 475*2503e1a5SAriel Constenla-Haile uno::Sequence< uno::Any > aArgs( 6 ); 476cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 477cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xFrame ); 478cdf0e10cSrcweir aArgs[0] = uno::makeAny( aPropValue ); 479cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); 480cdf0e10cSrcweir aPropValue.Value = uno::makeAny( aCommandURL ); 481cdf0e10cSrcweir aArgs[1] = uno::makeAny( aPropValue ); 482cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); 483cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xServiceManager ); 484cdf0e10cSrcweir aArgs[2] = uno::makeAny( aPropValue ); 485cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); 486cdf0e10cSrcweir aPropValue.Value = uno::makeAny( xStatusbarWindow ); 487cdf0e10cSrcweir aArgs[3] = uno::makeAny( aPropValue ); 488cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" )); 489cdf0e10cSrcweir aPropValue.Value = uno::makeAny( nId ); 490cdf0e10cSrcweir aArgs[4] = uno::makeAny( aPropValue ); 491*2503e1a5SAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" )); 492*2503e1a5SAriel Constenla-Haile aPropValue.Value <<= xStatusbarItem; 493*2503e1a5SAriel Constenla-Haile aArgs[5] = uno::makeAny( aPropValue ); 494cdf0e10cSrcweir xInit->initialize( aArgs ); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir } 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir AddFrameActionListener(); 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir void StatusBarManager::AddFrameActionListener() 503cdf0e10cSrcweir { 504cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" ); 505cdf0e10cSrcweir if ( !m_bFrameActionRegistered && m_xFrame.is() ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir m_bFrameActionRegistered = sal_True; 508cdf0e10cSrcweir m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >( 509cdf0e10cSrcweir static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY )); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAccess >& rItemContainer ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::StatusBarManager::FillStatusbar" ); 516cdf0e10cSrcweir 517cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 518cdf0e10cSrcweir 519cdf0e10cSrcweir if ( m_bDisposed || !m_pStatusBar ) 520cdf0e10cSrcweir return; 521cdf0e10cSrcweir 522cdf0e10cSrcweir sal_uInt16 nId( 1 ); 523cdf0e10cSrcweir rtl::OUString aHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX )); 524cdf0e10cSrcweir 525cdf0e10cSrcweir RemoveControllers(); 526cdf0e10cSrcweir 527cdf0e10cSrcweir // reset and fill command map 528cdf0e10cSrcweir m_pStatusBar->Clear(); 529*2503e1a5SAriel Constenla-Haile m_aControllerMap.clear();// TODO already done in RemoveControllers 530cdf0e10cSrcweir 531cdf0e10cSrcweir for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" ); 534cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProp; 535cdf0e10cSrcweir rtl::OUString aCommandURL; 536cdf0e10cSrcweir rtl::OUString aHelpURL; 537cdf0e10cSrcweir sal_Int16 nOffset( 0 ); 538cdf0e10cSrcweir sal_Int16 nStyle( 0 ); 539cdf0e10cSrcweir sal_Int16 nWidth( 0 ); 540cdf0e10cSrcweir sal_uInt16 nType( css_ui::ItemType::DEFAULT ); 541cdf0e10cSrcweir 542cdf0e10cSrcweir try 543cdf0e10cSrcweir { 544cdf0e10cSrcweir if ( rItemContainer->getByIndex( n ) >>= aProp ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir for ( int i = 0; i < aProp.getLength(); i++ ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL )) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir aProp[i].Value >>= aCommandURL; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL )) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir aProp[i].Value >>= aHelpURL; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE )) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir aProp[i].Value >>= nStyle; 559cdf0e10cSrcweir } 560cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE )) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir aProp[i].Value >>= nType; 563cdf0e10cSrcweir } 564cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH )) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir aProp[i].Value >>= nWidth; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_OFFSET )) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir aProp[i].Value >>= nOffset; 571cdf0e10cSrcweir } 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && ( aCommandURL.getLength() > 0 )) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL )); 577cdf0e10cSrcweir sal_uInt16 nItemBits( impl_convertItemStyleToItemBits( nStyle )); 578*2503e1a5SAriel Constenla-Haile 579cdf0e10cSrcweir m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset ); 580cdf0e10cSrcweir m_pStatusBar->SetItemCommand( nId, aCommandURL ); 581cdf0e10cSrcweir m_pStatusBar->SetAccessibleName( nId, aString ); 582cdf0e10cSrcweir ++nId; 583cdf0e10cSrcweir } 584cdf0e10cSrcweir } 585cdf0e10cSrcweir } 586cdf0e10cSrcweir catch ( ::com::sun::star::lang::IndexOutOfBoundsException& ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir break; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592*2503e1a5SAriel Constenla-Haile // Statusbar Merging 593*2503e1a5SAriel Constenla-Haile const sal_uInt16 STATUSBAR_ITEM_STARTID = 1000; 594*2503e1a5SAriel Constenla-Haile MergeStatusbarInstructionContainer aMergeInstructions = AddonsOptions().GetMergeStatusbarInstructions(); 595*2503e1a5SAriel Constenla-Haile if ( !aMergeInstructions.empty() ) 596*2503e1a5SAriel Constenla-Haile { 597*2503e1a5SAriel Constenla-Haile const sal_uInt32 nCount = aMergeInstructions.size(); 598*2503e1a5SAriel Constenla-Haile sal_uInt16 nItemId( STATUSBAR_ITEM_STARTID ); 599*2503e1a5SAriel Constenla-Haile 600*2503e1a5SAriel Constenla-Haile for ( sal_uInt32 i = 0; i < nCount; i++ ) 601*2503e1a5SAriel Constenla-Haile { 602*2503e1a5SAriel Constenla-Haile MergeStatusbarInstruction &rInstruction = aMergeInstructions[i]; 603*2503e1a5SAriel Constenla-Haile if ( !StatusbarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier ) ) 604*2503e1a5SAriel Constenla-Haile continue; 605*2503e1a5SAriel Constenla-Haile 606*2503e1a5SAriel Constenla-Haile AddonStatusbarItemContainer aItems; 607*2503e1a5SAriel Constenla-Haile StatusbarMerger::ConvertSeqSeqToVector( rInstruction.aMergeStatusbarItems, aItems ); 608*2503e1a5SAriel Constenla-Haile 609*2503e1a5SAriel Constenla-Haile sal_uInt16 nRefPos = StatusbarMerger::FindReferencePos( m_pStatusBar, rInstruction.aMergePoint ); 610*2503e1a5SAriel Constenla-Haile if ( nRefPos != STATUSBAR_ITEM_NOTFOUND ) 611*2503e1a5SAriel Constenla-Haile { 612*2503e1a5SAriel Constenla-Haile StatusbarMerger::ProcessMergeOperation( m_pStatusBar, 613*2503e1a5SAriel Constenla-Haile nRefPos, 614*2503e1a5SAriel Constenla-Haile nItemId, 615*2503e1a5SAriel Constenla-Haile m_aModuleIdentifier, 616*2503e1a5SAriel Constenla-Haile rInstruction.aMergeCommand, 617*2503e1a5SAriel Constenla-Haile rInstruction.aMergeCommandParameter, 618*2503e1a5SAriel Constenla-Haile aItems ); 619*2503e1a5SAriel Constenla-Haile } 620*2503e1a5SAriel Constenla-Haile else 621*2503e1a5SAriel Constenla-Haile { 622*2503e1a5SAriel Constenla-Haile StatusbarMerger::ProcessMergeFallback( m_pStatusBar, 623*2503e1a5SAriel Constenla-Haile nRefPos, 624*2503e1a5SAriel Constenla-Haile nItemId, 625*2503e1a5SAriel Constenla-Haile m_aModuleIdentifier, 626*2503e1a5SAriel Constenla-Haile rInstruction.aMergeCommand, 627*2503e1a5SAriel Constenla-Haile rInstruction.aMergeCommandParameter, 628*2503e1a5SAriel Constenla-Haile aItems ); 629*2503e1a5SAriel Constenla-Haile } 630*2503e1a5SAriel Constenla-Haile } 631*2503e1a5SAriel Constenla-Haile } 632*2503e1a5SAriel Constenla-Haile 633cdf0e10cSrcweir // Create controllers 634cdf0e10cSrcweir CreateControllers(); 635cdf0e10cSrcweir 636cdf0e10cSrcweir // Notify controllers that they are now correctly initialized and can start listening 637cdf0e10cSrcweir UpdateControllers(); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir void StatusBarManager::StateChanged( StateChangedType ) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" ); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir 645cdf0e10cSrcweir void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt ) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" ); 648cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 649cdf0e10cSrcweir 650cdf0e10cSrcweir if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || 651cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_FONTS ) || 652cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION ) || 653cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && 654cdf0e10cSrcweir ( rDCEvt.GetFlags() & SETTINGS_STYLE )) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; 657cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY ); 658cdf0e10cSrcweir if ( xPropSet.is() ) 659cdf0e10cSrcweir xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager; 660cdf0e10cSrcweir if ( xLayoutManager.is() ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir aGuard.unlock(); 663cdf0e10cSrcweir xLayoutManager->doLayout(); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir } 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" ); 671cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 672*2503e1a5SAriel Constenla-Haile 673cdf0e10cSrcweir if ( m_bDisposed ) 674cdf0e10cSrcweir return; 675*2503e1a5SAriel Constenla-Haile 676cdf0e10cSrcweir sal_uInt16 nId( rUDEvt.GetItemId() ); 677*2503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 678*2503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 679cdf0e10cSrcweir { 680*2503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 681cdf0e10cSrcweir if ( xController.is() && rUDEvt.GetDevice() ) 682cdf0e10cSrcweir { 683*2503e1a5SAriel Constenla-Haile uno::Reference< awt::XGraphics > xGraphics = 684cdf0e10cSrcweir rUDEvt.GetDevice()->CreateUnoGraphics(); 685cdf0e10cSrcweir 686*2503e1a5SAriel Constenla-Haile awt::Rectangle aRect( rUDEvt.GetRect().Left(), 687cdf0e10cSrcweir rUDEvt.GetRect().Top(), 688*2503e1a5SAriel Constenla-Haile rUDEvt.GetRect().GetWidth(), 689cdf0e10cSrcweir rUDEvt.GetRect().GetHeight() ); 690cdf0e10cSrcweir aGuard.unlock(); 691*2503e1a5SAriel Constenla-Haile xController->paint( xGraphics, aRect, rUDEvt.GetStyle() ); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696cdf0e10cSrcweir void StatusBarManager::Command( const CommandEvent& rEvt ) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" ); 699cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 700*2503e1a5SAriel Constenla-Haile 701cdf0e10cSrcweir if ( m_bDisposed ) 702cdf0e10cSrcweir return; 703*2503e1a5SAriel Constenla-Haile 704cdf0e10cSrcweir if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU ) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() ); 707*2503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 708*2503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 709cdf0e10cSrcweir { 710*2503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 711cdf0e10cSrcweir if ( xController.is() ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir awt::Point aPos; 714cdf0e10cSrcweir aPos.X = rEvt.GetMousePosPixel().X(); 715cdf0e10cSrcweir aPos.Y = rEvt.GetMousePosPixel().Y(); 716cdf0e10cSrcweir xController->command( aPos, awt::Command::CONTEXTMENU, sal_True, uno::Any() ); 717cdf0e10cSrcweir } 718cdf0e10cSrcweir } 719cdf0e10cSrcweir } 720cdf0e10cSrcweir } 721cdf0e10cSrcweir 722cdf0e10cSrcweir void StatusBarManager::MouseMove( const MouseEvent& rMEvt ) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" ); 725cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseMove); 726cdf0e10cSrcweir } 727*2503e1a5SAriel Constenla-Haile 728cdf0e10cSrcweir void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&)) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" ); 731cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 732*2503e1a5SAriel Constenla-Haile 733cdf0e10cSrcweir if ( !m_bDisposed ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); 736*2503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 737*2503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 738cdf0e10cSrcweir { 739*2503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 740cdf0e10cSrcweir if ( xController.is() ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir ::com::sun::star::awt::MouseEvent aMouseEvent; 743cdf0e10cSrcweir aMouseEvent.Buttons = rMEvt.GetButtons(); 744cdf0e10cSrcweir aMouseEvent.X = rMEvt.GetPosPixel().X(); 745cdf0e10cSrcweir aMouseEvent.Y = rMEvt.GetPosPixel().Y(); 746cdf0e10cSrcweir aMouseEvent.ClickCount = rMEvt.GetClicks(); 747cdf0e10cSrcweir (xController.get()->*_pMethod)( aMouseEvent); 748cdf0e10cSrcweir } 749*2503e1a5SAriel Constenla-Haile } 750cdf0e10cSrcweir } 751cdf0e10cSrcweir } 752*2503e1a5SAriel Constenla-Haile 753cdf0e10cSrcweir void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" ); 756cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown); 757cdf0e10cSrcweir } 758cdf0e10cSrcweir 759cdf0e10cSrcweir void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt ) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" ); 762cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp); 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG ) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 768*2503e1a5SAriel Constenla-Haile 769cdf0e10cSrcweir if ( m_bDisposed ) 770cdf0e10cSrcweir return 1; 771*2503e1a5SAriel Constenla-Haile 772cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetCurItemId(); 773*2503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 774*2503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 775cdf0e10cSrcweir { 776*2503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 777cdf0e10cSrcweir if ( xController.is() ) 778*2503e1a5SAriel Constenla-Haile { 779*2503e1a5SAriel Constenla-Haile const Point aVCLPos = m_pStatusBar->GetPointerPosPixel(); 780*2503e1a5SAriel Constenla-Haile const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() ); 781*2503e1a5SAriel Constenla-Haile xController->click( aAWTPoint ); 782*2503e1a5SAriel Constenla-Haile } 783cdf0e10cSrcweir } 784*2503e1a5SAriel Constenla-Haile 785cdf0e10cSrcweir return 1; 786cdf0e10cSrcweir } 787cdf0e10cSrcweir 788cdf0e10cSrcweir IMPL_LINK( StatusBarManager, DoubleClick, StatusBar*, EMPTYARG ) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 791*2503e1a5SAriel Constenla-Haile 792cdf0e10cSrcweir if ( m_bDisposed ) 793cdf0e10cSrcweir return 1; 794*2503e1a5SAriel Constenla-Haile 795cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetCurItemId(); 796*2503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 797*2503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 798cdf0e10cSrcweir { 799*2503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 800cdf0e10cSrcweir if ( xController.is() ) 801*2503e1a5SAriel Constenla-Haile { 802*2503e1a5SAriel Constenla-Haile const Point aVCLPos = m_pStatusBar->GetPointerPosPixel(); 803*2503e1a5SAriel Constenla-Haile const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() ); 804*2503e1a5SAriel Constenla-Haile xController->doubleClick( aAWTPoint ); 805*2503e1a5SAriel Constenla-Haile } 806cdf0e10cSrcweir } 807*2503e1a5SAriel Constenla-Haile 808cdf0e10cSrcweir return 1; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir } 812