16d739b60SAndrew Rist /************************************************************** 22503e1a5SAriel 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 102503e1a5SAriel Constenla-Haile * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 122503e1a5SAriel 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. 192503e1a5SAriel 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> 282503e1a5SAriel Constenla-Haile #include <uielement/genericstatusbarcontroller.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 31cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 32cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx> 332503e1a5SAriel Constenla-Haile #include <framework/addonsoptions.hxx> 342503e1a5SAriel Constenla-Haile #include <uielement/statusbarmerger.hxx> 352503e1a5SAriel 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> 47*dccf82beSAriel Constenla-Haile #include <com/sun/star/frame/StatusbarControllerFactory.hpp> 48cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp> 49cdf0e10cSrcweir #include <com/sun/star/ui/ItemStyle.hpp> 50cdf0e10cSrcweir #include <com/sun/star/ui/ItemType.hpp> 51cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 52cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 53cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp> 542503e1a5SAriel Constenla-Haile #include <com/sun/star/ui/XStatusbarItem.hdl> 55cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 56cdf0e10cSrcweir 572503e1a5SAriel Constenla-Haile #include <toolkit/helper/vclunohelper.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include <svtools/statusbarcontroller.hxx> 60*dccf82beSAriel Constenla-Haile #include <comphelper/processfactory.hxx> 61cdf0e10cSrcweir 62cdf0e10cSrcweir #include <vcl/status.hxx> 63cdf0e10cSrcweir #include <vcl/svapp.hxx> 64cdf0e10cSrcweir #include <rtl/logfile.hxx> 65cdf0e10cSrcweir 662503e1a5SAriel Constenla-Haile #include <functional> 672503e1a5SAriel Constenla-Haile 68cdf0e10cSrcweir using namespace ::com::sun::star; 69cdf0e10cSrcweir #ifndef css 70cdf0e10cSrcweir #define css ::com::sun::star 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef css_ui 73cdf0e10cSrcweir #define css_ui ::com::sun::star::ui 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir 76cdf0e10cSrcweir const sal_Int32 HELPID_PREFIX_LENGTH = 7; 77cdf0e10cSrcweir static const char* HELPID_PREFIX = "helpid:"; 78cdf0e10cSrcweir 79cdf0e10cSrcweir // Property names of a menu/menu item ItemDescriptor 80cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; 81cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; 82cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_OFFSET[] = "Offset"; 83cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; 84cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_WIDTH[] = "Width"; 85cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; 86cdf0e10cSrcweir 87cdf0e10cSrcweir namespace framework 88cdf0e10cSrcweir { 89cdf0e10cSrcweir 902503e1a5SAriel Constenla-Haile namespace 912503e1a5SAriel Constenla-Haile { 922503e1a5SAriel Constenla-Haile 932503e1a5SAriel Constenla-Haile template< class MAP > 942503e1a5SAriel Constenla-Haile struct lcl_UpdateController : public std::unary_function< typename MAP::value_type, void > 952503e1a5SAriel Constenla-Haile { 962503e1a5SAriel Constenla-Haile void operator()( typename MAP::value_type &rElement ) const 972503e1a5SAriel Constenla-Haile { 982503e1a5SAriel Constenla-Haile try 992503e1a5SAriel Constenla-Haile { 1002503e1a5SAriel Constenla-Haile uno::Reference< util::XUpdatable > xUpdatable( rElement.second, uno::UNO_QUERY ); 1012503e1a5SAriel Constenla-Haile if ( xUpdatable.is() ) 1022503e1a5SAriel Constenla-Haile xUpdatable->update(); 1032503e1a5SAriel Constenla-Haile } 1042503e1a5SAriel Constenla-Haile catch ( uno::Exception& ) 1052503e1a5SAriel Constenla-Haile { 1062503e1a5SAriel Constenla-Haile } 1072503e1a5SAriel Constenla-Haile } 1082503e1a5SAriel Constenla-Haile }; 1092503e1a5SAriel Constenla-Haile 1102503e1a5SAriel Constenla-Haile template< class MAP > 1112503e1a5SAriel Constenla-Haile struct lcl_RemoveController : public std::unary_function< typename MAP::value_type, void > 1122503e1a5SAriel Constenla-Haile { 1132503e1a5SAriel Constenla-Haile void operator()( typename MAP::value_type &rElement ) const 1142503e1a5SAriel Constenla-Haile { 1152503e1a5SAriel Constenla-Haile try 1162503e1a5SAriel Constenla-Haile { 1172503e1a5SAriel Constenla-Haile uno::Reference< lang::XComponent > xComponent( rElement.second, uno::UNO_QUERY ); 1182503e1a5SAriel Constenla-Haile if ( xComponent.is() ) 1192503e1a5SAriel Constenla-Haile xComponent->dispose(); 1202503e1a5SAriel Constenla-Haile } 1212503e1a5SAriel Constenla-Haile catch ( uno::Exception& ) 1222503e1a5SAriel Constenla-Haile { 1232503e1a5SAriel Constenla-Haile } 1242503e1a5SAriel Constenla-Haile } 1252503e1a5SAriel Constenla-Haile }; 1262503e1a5SAriel Constenla-Haile 127cdf0e10cSrcweir static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir sal_uInt16 nItemBits( 0 ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::ALIGN_RIGHT ) == css_ui::ItemStyle::ALIGN_RIGHT ) 132cdf0e10cSrcweir nItemBits |= SIB_RIGHT; 133cdf0e10cSrcweir else if ( nStyle & css_ui::ItemStyle::ALIGN_LEFT ) 134cdf0e10cSrcweir nItemBits |= SIB_LEFT; 135cdf0e10cSrcweir else 136cdf0e10cSrcweir nItemBits |= SIB_CENTER; 137cdf0e10cSrcweir 138cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::DRAW_FLAT ) == css_ui::ItemStyle::DRAW_FLAT ) 139cdf0e10cSrcweir nItemBits |= SIB_FLAT; 140cdf0e10cSrcweir else if ( nStyle & css_ui::ItemStyle::DRAW_OUT3D ) 141cdf0e10cSrcweir nItemBits |= SIB_OUT; 142cdf0e10cSrcweir else 143cdf0e10cSrcweir nItemBits |= SIB_IN; 144cdf0e10cSrcweir 145cdf0e10cSrcweir if (( nStyle & css_ui::ItemStyle::AUTO_SIZE ) == css_ui::ItemStyle::AUTO_SIZE ) 146cdf0e10cSrcweir nItemBits |= SIB_AUTOSIZE; 147cdf0e10cSrcweir if ( nStyle & css_ui::ItemStyle::OWNER_DRAW ) 148cdf0e10cSrcweir nItemBits |= SIB_USERDRAW; 149cdf0e10cSrcweir 150cdf0e10cSrcweir return nItemBits; 151cdf0e10cSrcweir } 1522503e1a5SAriel Constenla-Haile 1532503e1a5SAriel Constenla-Haile } 154cdf0e10cSrcweir //***************************************************************************************************************** 155cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 156cdf0e10cSrcweir //***************************************************************************************************************** 157cdf0e10cSrcweir DEFINE_XINTERFACE_5 ( StatusBarManager , 158cdf0e10cSrcweir ::cppu::OWeakObject , 159cdf0e10cSrcweir DIRECT_INTERFACE( lang::XTypeProvider ), 160cdf0e10cSrcweir DIRECT_INTERFACE( lang::XComponent ), 161cdf0e10cSrcweir DIRECT_INTERFACE( frame::XFrameActionListener ), 162cdf0e10cSrcweir DIRECT_INTERFACE( css::ui::XUIConfigurationListener ), 163cdf0e10cSrcweir DERIVED_INTERFACE( lang::XEventListener, frame::XFrameActionListener ) 164cdf0e10cSrcweir ) 165cdf0e10cSrcweir 166cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_5 ( StatusBarManager , 167cdf0e10cSrcweir lang::XTypeProvider , 168cdf0e10cSrcweir lang::XComponent , 169cdf0e10cSrcweir css::ui::XUIConfigurationListener , 170cdf0e10cSrcweir frame::XFrameActionListener , 171cdf0e10cSrcweir lang::XEventListener 172cdf0e10cSrcweir ) 173cdf0e10cSrcweir 174cdf0e10cSrcweir StatusBarManager::StatusBarManager( 175cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& rServiceManager, 176cdf0e10cSrcweir const uno::Reference< frame::XFrame >& rFrame, 177cdf0e10cSrcweir const rtl::OUString& rResourceName, 178cdf0e10cSrcweir StatusBar* pStatusBar ) : 179cdf0e10cSrcweir ThreadHelpBase( &Application::GetSolarMutex() ), 180cdf0e10cSrcweir OWeakObject(), 181cdf0e10cSrcweir m_bDisposed( sal_False ), 182cdf0e10cSrcweir m_bFrameActionRegistered( sal_False ), 183cdf0e10cSrcweir m_bUpdateControllers( sal_False ), 184cdf0e10cSrcweir m_bModuleIdentified( sal_False ), 185cdf0e10cSrcweir m_pStatusBar( pStatusBar ), 186cdf0e10cSrcweir m_aResourceName( rResourceName ), 187cdf0e10cSrcweir m_xFrame( rFrame ), 188cdf0e10cSrcweir m_aListenerContainer( m_aLock.getShareableOslMutex() ), 189cdf0e10cSrcweir m_xServiceManager( rServiceManager ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" ); 192cdf0e10cSrcweir 193*dccf82beSAriel Constenla-Haile m_xStatusbarControllerFactory = frame::StatusbarControllerFactory::create( 194*dccf82beSAriel Constenla-Haile ::comphelper::getProcessComponentContext()); 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 ); 2492503e1a5SAriel Constenla-Haile 250cdf0e10cSrcweir { 251cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 252cdf0e10cSrcweir if ( !m_bDisposed ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir RemoveControllers(); 2552503e1a5SAriel Constenla-Haile 2562503e1a5SAriel Constenla-Haile // destroy the item data 2572503e1a5SAriel Constenla-Haile for ( sal_uInt16 n = 0; n < m_pStatusBar->GetItemCount(); n++ ) 2582503e1a5SAriel Constenla-Haile { 2592503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pUserData = static_cast< AddonStatusbarItemData *>( 2602503e1a5SAriel Constenla-Haile m_pStatusBar->GetItemData( m_pStatusBar->GetItemId( n ) ) ); 2612503e1a5SAriel Constenla-Haile if ( pUserData ) 2622503e1a5SAriel Constenla-Haile delete pUserData; 2632503e1a5SAriel Constenla-Haile } 2642503e1a5SAriel 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 ); 3142503e1a5SAriel 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 ); 3232503e1a5SAriel Constenla-Haile 324cdf0e10cSrcweir if ( m_bDisposed ) 325cdf0e10cSrcweir return; 326cdf0e10cSrcweir } 3272503e1a5SAriel 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 ); 3322503e1a5SAriel 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; 3432503e1a5SAriel Constenla-Haile std::for_each( m_aControllerMap.begin(), 3442503e1a5SAriel Constenla-Haile m_aControllerMap.end(), 3452503e1a5SAriel 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 3582503e1a5SAriel Constenla-Haile std::for_each( m_aControllerMap.begin(), 3592503e1a5SAriel Constenla-Haile m_aControllerMap.end(), 3602503e1a5SAriel Constenla-Haile lcl_RemoveController< StatusBarControllerMap >() ); 3612503e1a5SAriel 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< uno::XComponentContext > xComponentContext; 373cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY ); 374cdf0e10cSrcweir uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar ); 3752503e1a5SAriel Constenla-Haile 376cdf0e10cSrcweir if ( xProps.is() ) 377cdf0e10cSrcweir xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext; 3782503e1a5SAriel Constenla-Haile 379cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( i ); 382cdf0e10cSrcweir if ( nId == 0 ) 383cdf0e10cSrcweir continue; 3842503e1a5SAriel Constenla-Haile 385cdf0e10cSrcweir rtl::OUString aCommandURL( m_pStatusBar->GetItemCommand( nId )); 386cdf0e10cSrcweir sal_Bool bInit( sal_True ); 387cdf0e10cSrcweir uno::Reference< frame::XStatusListener > xController; 3882503e1a5SAriel Constenla-Haile AddonStatusbarItemData *pItemData = static_cast< AddonStatusbarItemData *>( m_pStatusBar->GetItemData( nId ) ); 3892503e1a5SAriel Constenla-Haile uno::Reference< ui::XStatusbarItem > xStatusbarItem( 3902503e1a5SAriel Constenla-Haile static_cast< cppu::OWeakObject *>( new StatusbarItem( m_pStatusBar, pItemData, nId, aCommandURL ) ), 3912503e1a5SAriel Constenla-Haile uno::UNO_QUERY ); 3922503e1a5SAriel Constenla-Haile 393cdf0e10cSrcweir svt::StatusbarController* pController( 0 ); 3942503e1a5SAriel Constenla-Haile 3952503e1a5SAriel Constenla-Haile // 1º) UNO Statusbar controllers, registered in Controllers.xcu 396*dccf82beSAriel Constenla-Haile if ( m_xStatusbarControllerFactory.is() && 397*dccf82beSAriel Constenla-Haile m_xStatusbarControllerFactory->hasController( aCommandURL, m_aModuleIdentifier )) 398cdf0e10cSrcweir { 399*dccf82beSAriel Constenla-Haile beans::PropertyValue aPropValue; 400*dccf82beSAriel Constenla-Haile std::vector< uno::Any > aPropVector; 401*dccf82beSAriel Constenla-Haile 402*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" )); 403*dccf82beSAriel Constenla-Haile aPropValue.Value = uno::makeAny( m_aModuleIdentifier ); 404*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 405*dccf82beSAriel Constenla-Haile 406*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 407*dccf82beSAriel Constenla-Haile aPropValue.Value = uno::makeAny( m_xFrame ); 408*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 409*dccf82beSAriel Constenla-Haile 410*dccf82beSAriel Constenla-Haile // TODO remove this 411*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); 412*dccf82beSAriel Constenla-Haile aPropValue.Value = uno::makeAny( m_xServiceManager ); 413*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 414*dccf82beSAriel Constenla-Haile 415*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); 416*dccf82beSAriel Constenla-Haile aPropValue.Value = uno::makeAny( xStatusbarWindow ); 417*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 418*dccf82beSAriel Constenla-Haile 419*dccf82beSAriel Constenla-Haile // TODO still needing with the css::ui::XStatusbarItem? 420*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" )); 421*dccf82beSAriel Constenla-Haile aPropValue.Value = uno::makeAny( nId ); 422*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 423*dccf82beSAriel Constenla-Haile 424*dccf82beSAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" )); 425*dccf82beSAriel Constenla-Haile aPropValue.Value <<= xStatusbarItem; 426*dccf82beSAriel Constenla-Haile aPropVector.push_back( uno::makeAny( aPropValue ) ); 427*dccf82beSAriel Constenla-Haile 428*dccf82beSAriel Constenla-Haile uno::Sequence< uno::Any > aArgs( comphelper::containerToSequence( aPropVector ) ); 429*dccf82beSAriel Constenla-Haile xController = uno::Reference< frame::XStatusListener >( 430*dccf82beSAriel Constenla-Haile m_xStatusbarControllerFactory->createInstanceWithArgumentsAndContext( 431*dccf82beSAriel Constenla-Haile aCommandURL, aArgs, xComponentContext ), 432*dccf82beSAriel Constenla-Haile uno::UNO_QUERY ); 433*dccf82beSAriel Constenla-Haile bInit = sal_False; // Initialization is done through the factory service 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir if ( !xController.is() ) 437cdf0e10cSrcweir { 4382503e1a5SAriel Constenla-Haile // 2º) Old SFX2 Statusbar controllers 439cdf0e10cSrcweir pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL ); 440cdf0e10cSrcweir if ( !pController ) 4412503e1a5SAriel Constenla-Haile { 4422503e1a5SAriel Constenla-Haile // 3º) Is Add-on? Generic statusbar controller 4432503e1a5SAriel Constenla-Haile if ( pItemData ) 4442503e1a5SAriel Constenla-Haile { 4452503e1a5SAriel Constenla-Haile pController = new GenericStatusbarController( m_xServiceManager, 4462503e1a5SAriel Constenla-Haile m_xFrame, 4472503e1a5SAriel Constenla-Haile xStatusbarItem, 4482503e1a5SAriel Constenla-Haile pItemData ); 4492503e1a5SAriel Constenla-Haile } 4502503e1a5SAriel Constenla-Haile else 4512503e1a5SAriel Constenla-Haile { 4522503e1a5SAriel Constenla-Haile // 4º) Default Statusbar controller 4532503e1a5SAriel Constenla-Haile pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId ); 4542503e1a5SAriel Constenla-Haile } 4552503e1a5SAriel Constenla-Haile } 4562503e1a5SAriel Constenla-Haile 457cdf0e10cSrcweir if ( pController ) 458cdf0e10cSrcweir xController = uno::Reference< frame::XStatusListener >( 459cdf0e10cSrcweir static_cast< ::cppu::OWeakObject *>( pController ), 460cdf0e10cSrcweir uno::UNO_QUERY ); 461cdf0e10cSrcweir } 4622503e1a5SAriel Constenla-Haile 4632503e1a5SAriel Constenla-Haile m_aControllerMap[nId] = xController; 464cdf0e10cSrcweir uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY ); 4652503e1a5SAriel Constenla-Haile 466cdf0e10cSrcweir if ( xInit.is() ) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir if ( bInit ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir beans::PropertyValue aPropValue; 4712503e1a5SAriel Constenla-Haile uno::Sequence< uno::Any > aArgs( 6 ); 472cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 473cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xFrame ); 474cdf0e10cSrcweir aArgs[0] = uno::makeAny( aPropValue ); 475cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )); 476cdf0e10cSrcweir aPropValue.Value = uno::makeAny( aCommandURL ); 477cdf0e10cSrcweir aArgs[1] = uno::makeAny( aPropValue ); 478cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" )); 479cdf0e10cSrcweir aPropValue.Value = uno::makeAny( m_xServiceManager ); 480cdf0e10cSrcweir aArgs[2] = uno::makeAny( aPropValue ); 481cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); 482cdf0e10cSrcweir aPropValue.Value = uno::makeAny( xStatusbarWindow ); 483cdf0e10cSrcweir aArgs[3] = uno::makeAny( aPropValue ); 484cdf0e10cSrcweir aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" )); 485cdf0e10cSrcweir aPropValue.Value = uno::makeAny( nId ); 486cdf0e10cSrcweir aArgs[4] = uno::makeAny( aPropValue ); 4872503e1a5SAriel Constenla-Haile aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" )); 4882503e1a5SAriel Constenla-Haile aPropValue.Value <<= xStatusbarItem; 4892503e1a5SAriel Constenla-Haile aArgs[5] = uno::makeAny( aPropValue ); 490cdf0e10cSrcweir xInit->initialize( aArgs ); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir } 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir AddFrameActionListener(); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir void StatusBarManager::AddFrameActionListener() 499cdf0e10cSrcweir { 500cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" ); 501cdf0e10cSrcweir if ( !m_bFrameActionRegistered && m_xFrame.is() ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir m_bFrameActionRegistered = sal_True; 504cdf0e10cSrcweir m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >( 505cdf0e10cSrcweir static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY )); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAccess >& rItemContainer ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::StatusBarManager::FillStatusbar" ); 512cdf0e10cSrcweir 513cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 514cdf0e10cSrcweir 515cdf0e10cSrcweir if ( m_bDisposed || !m_pStatusBar ) 516cdf0e10cSrcweir return; 517cdf0e10cSrcweir 518cdf0e10cSrcweir sal_uInt16 nId( 1 ); 519cdf0e10cSrcweir rtl::OUString aHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX )); 520cdf0e10cSrcweir 521cdf0e10cSrcweir RemoveControllers(); 522cdf0e10cSrcweir 523cdf0e10cSrcweir // reset and fill command map 524cdf0e10cSrcweir m_pStatusBar->Clear(); 5252503e1a5SAriel Constenla-Haile m_aControllerMap.clear();// TODO already done in RemoveControllers 526cdf0e10cSrcweir 527cdf0e10cSrcweir for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" ); 530cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aProp; 531cdf0e10cSrcweir rtl::OUString aCommandURL; 532cdf0e10cSrcweir rtl::OUString aHelpURL; 533cdf0e10cSrcweir sal_Int16 nOffset( 0 ); 534cdf0e10cSrcweir sal_Int16 nStyle( 0 ); 535cdf0e10cSrcweir sal_Int16 nWidth( 0 ); 536cdf0e10cSrcweir sal_uInt16 nType( css_ui::ItemType::DEFAULT ); 537cdf0e10cSrcweir 538cdf0e10cSrcweir try 539cdf0e10cSrcweir { 540cdf0e10cSrcweir if ( rItemContainer->getByIndex( n ) >>= aProp ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir for ( int i = 0; i < aProp.getLength(); i++ ) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL )) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir aProp[i].Value >>= aCommandURL; 547cdf0e10cSrcweir } 548cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL )) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir aProp[i].Value >>= aHelpURL; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE )) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir aProp[i].Value >>= nStyle; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE )) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir aProp[i].Value >>= nType; 559cdf0e10cSrcweir } 560cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH )) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir aProp[i].Value >>= nWidth; 563cdf0e10cSrcweir } 564cdf0e10cSrcweir else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_OFFSET )) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir aProp[i].Value >>= nOffset; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && ( aCommandURL.getLength() > 0 )) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL )); 573cdf0e10cSrcweir sal_uInt16 nItemBits( impl_convertItemStyleToItemBits( nStyle )); 5742503e1a5SAriel Constenla-Haile 575cdf0e10cSrcweir m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset ); 576cdf0e10cSrcweir m_pStatusBar->SetItemCommand( nId, aCommandURL ); 577cdf0e10cSrcweir m_pStatusBar->SetAccessibleName( nId, aString ); 578cdf0e10cSrcweir ++nId; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir } 582cdf0e10cSrcweir catch ( ::com::sun::star::lang::IndexOutOfBoundsException& ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir break; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir } 587cdf0e10cSrcweir 5882503e1a5SAriel Constenla-Haile // Statusbar Merging 5892503e1a5SAriel Constenla-Haile const sal_uInt16 STATUSBAR_ITEM_STARTID = 1000; 5902503e1a5SAriel Constenla-Haile MergeStatusbarInstructionContainer aMergeInstructions = AddonsOptions().GetMergeStatusbarInstructions(); 5912503e1a5SAriel Constenla-Haile if ( !aMergeInstructions.empty() ) 5922503e1a5SAriel Constenla-Haile { 5932503e1a5SAriel Constenla-Haile const sal_uInt32 nCount = aMergeInstructions.size(); 5942503e1a5SAriel Constenla-Haile sal_uInt16 nItemId( STATUSBAR_ITEM_STARTID ); 5952503e1a5SAriel Constenla-Haile 5962503e1a5SAriel Constenla-Haile for ( sal_uInt32 i = 0; i < nCount; i++ ) 5972503e1a5SAriel Constenla-Haile { 5982503e1a5SAriel Constenla-Haile MergeStatusbarInstruction &rInstruction = aMergeInstructions[i]; 5992503e1a5SAriel Constenla-Haile if ( !StatusbarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier ) ) 6002503e1a5SAriel Constenla-Haile continue; 6012503e1a5SAriel Constenla-Haile 6022503e1a5SAriel Constenla-Haile AddonStatusbarItemContainer aItems; 6032503e1a5SAriel Constenla-Haile StatusbarMerger::ConvertSeqSeqToVector( rInstruction.aMergeStatusbarItems, aItems ); 6042503e1a5SAriel Constenla-Haile 6052503e1a5SAriel Constenla-Haile sal_uInt16 nRefPos = StatusbarMerger::FindReferencePos( m_pStatusBar, rInstruction.aMergePoint ); 6062503e1a5SAriel Constenla-Haile if ( nRefPos != STATUSBAR_ITEM_NOTFOUND ) 6072503e1a5SAriel Constenla-Haile { 6082503e1a5SAriel Constenla-Haile StatusbarMerger::ProcessMergeOperation( m_pStatusBar, 6092503e1a5SAriel Constenla-Haile nRefPos, 6102503e1a5SAriel Constenla-Haile nItemId, 6112503e1a5SAriel Constenla-Haile m_aModuleIdentifier, 6122503e1a5SAriel Constenla-Haile rInstruction.aMergeCommand, 6132503e1a5SAriel Constenla-Haile rInstruction.aMergeCommandParameter, 6142503e1a5SAriel Constenla-Haile aItems ); 6152503e1a5SAriel Constenla-Haile } 6162503e1a5SAriel Constenla-Haile else 6172503e1a5SAriel Constenla-Haile { 6182503e1a5SAriel Constenla-Haile StatusbarMerger::ProcessMergeFallback( m_pStatusBar, 6192503e1a5SAriel Constenla-Haile nRefPos, 6202503e1a5SAriel Constenla-Haile nItemId, 6212503e1a5SAriel Constenla-Haile m_aModuleIdentifier, 6222503e1a5SAriel Constenla-Haile rInstruction.aMergeCommand, 6232503e1a5SAriel Constenla-Haile rInstruction.aMergeCommandParameter, 6242503e1a5SAriel Constenla-Haile aItems ); 6252503e1a5SAriel Constenla-Haile } 6262503e1a5SAriel Constenla-Haile } 6272503e1a5SAriel Constenla-Haile } 6282503e1a5SAriel Constenla-Haile 629cdf0e10cSrcweir // Create controllers 630cdf0e10cSrcweir CreateControllers(); 631cdf0e10cSrcweir 632cdf0e10cSrcweir // Notify controllers that they are now correctly initialized and can start listening 633cdf0e10cSrcweir UpdateControllers(); 634cdf0e10cSrcweir } 635cdf0e10cSrcweir 636cdf0e10cSrcweir void StatusBarManager::StateChanged( StateChangedType ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" ); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" ); 644cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 645cdf0e10cSrcweir 646cdf0e10cSrcweir if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || 647cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_FONTS ) || 648cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION ) || 649cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && 650cdf0e10cSrcweir ( rDCEvt.GetFlags() & SETTINGS_STYLE )) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; 653cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY ); 654cdf0e10cSrcweir if ( xPropSet.is() ) 655cdf0e10cSrcweir xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager; 656cdf0e10cSrcweir if ( xLayoutManager.is() ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir aGuard.unlock(); 659cdf0e10cSrcweir xLayoutManager->doLayout(); 660cdf0e10cSrcweir } 661cdf0e10cSrcweir } 662cdf0e10cSrcweir } 663cdf0e10cSrcweir 664cdf0e10cSrcweir void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt ) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" ); 667cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 6682503e1a5SAriel Constenla-Haile 669cdf0e10cSrcweir if ( m_bDisposed ) 670cdf0e10cSrcweir return; 6712503e1a5SAriel Constenla-Haile 672cdf0e10cSrcweir sal_uInt16 nId( rUDEvt.GetItemId() ); 6732503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 6742503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 675cdf0e10cSrcweir { 6762503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 677cdf0e10cSrcweir if ( xController.is() && rUDEvt.GetDevice() ) 678cdf0e10cSrcweir { 6792503e1a5SAriel Constenla-Haile uno::Reference< awt::XGraphics > xGraphics = 680cdf0e10cSrcweir rUDEvt.GetDevice()->CreateUnoGraphics(); 681cdf0e10cSrcweir 6822503e1a5SAriel Constenla-Haile awt::Rectangle aRect( rUDEvt.GetRect().Left(), 683cdf0e10cSrcweir rUDEvt.GetRect().Top(), 6842503e1a5SAriel Constenla-Haile rUDEvt.GetRect().GetWidth(), 685cdf0e10cSrcweir rUDEvt.GetRect().GetHeight() ); 686cdf0e10cSrcweir aGuard.unlock(); 6872503e1a5SAriel Constenla-Haile xController->paint( xGraphics, aRect, rUDEvt.GetStyle() ); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir } 690cdf0e10cSrcweir } 691cdf0e10cSrcweir 692cdf0e10cSrcweir void StatusBarManager::Command( const CommandEvent& rEvt ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" ); 695cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 6962503e1a5SAriel Constenla-Haile 697cdf0e10cSrcweir if ( m_bDisposed ) 698cdf0e10cSrcweir return; 6992503e1a5SAriel Constenla-Haile 700cdf0e10cSrcweir if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() ); 7032503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 7042503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 705cdf0e10cSrcweir { 7062503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 707cdf0e10cSrcweir if ( xController.is() ) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir awt::Point aPos; 710cdf0e10cSrcweir aPos.X = rEvt.GetMousePosPixel().X(); 711cdf0e10cSrcweir aPos.Y = rEvt.GetMousePosPixel().Y(); 712cdf0e10cSrcweir xController->command( aPos, awt::Command::CONTEXTMENU, sal_True, uno::Any() ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir } 715cdf0e10cSrcweir } 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir void StatusBarManager::MouseMove( const MouseEvent& rMEvt ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" ); 721cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseMove); 722cdf0e10cSrcweir } 7232503e1a5SAriel Constenla-Haile 724cdf0e10cSrcweir void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&)) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" ); 727cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 7282503e1a5SAriel Constenla-Haile 729cdf0e10cSrcweir if ( !m_bDisposed ) 730cdf0e10cSrcweir { 731cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() ); 7322503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 7332503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 734cdf0e10cSrcweir { 7352503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 736cdf0e10cSrcweir if ( xController.is() ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir ::com::sun::star::awt::MouseEvent aMouseEvent; 739cdf0e10cSrcweir aMouseEvent.Buttons = rMEvt.GetButtons(); 740cdf0e10cSrcweir aMouseEvent.X = rMEvt.GetPosPixel().X(); 741cdf0e10cSrcweir aMouseEvent.Y = rMEvt.GetPosPixel().Y(); 742cdf0e10cSrcweir aMouseEvent.ClickCount = rMEvt.GetClicks(); 743cdf0e10cSrcweir (xController.get()->*_pMethod)( aMouseEvent); 744cdf0e10cSrcweir } 7452503e1a5SAriel Constenla-Haile } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir } 7482503e1a5SAriel Constenla-Haile 749cdf0e10cSrcweir void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt ) 750cdf0e10cSrcweir { 751cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" ); 752cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown); 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt ) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" ); 758cdf0e10cSrcweir MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp); 759cdf0e10cSrcweir } 760cdf0e10cSrcweir 761cdf0e10cSrcweir IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG ) 762cdf0e10cSrcweir { 763cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 7642503e1a5SAriel Constenla-Haile 765cdf0e10cSrcweir if ( m_bDisposed ) 766cdf0e10cSrcweir return 1; 7672503e1a5SAriel Constenla-Haile 768cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetCurItemId(); 7692503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 7702503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 771cdf0e10cSrcweir { 7722503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 773cdf0e10cSrcweir if ( xController.is() ) 7742503e1a5SAriel Constenla-Haile { 7752503e1a5SAriel Constenla-Haile const Point aVCLPos = m_pStatusBar->GetPointerPosPixel(); 7762503e1a5SAriel Constenla-Haile const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() ); 7772503e1a5SAriel Constenla-Haile xController->click( aAWTPoint ); 7782503e1a5SAriel Constenla-Haile } 779cdf0e10cSrcweir } 7802503e1a5SAriel Constenla-Haile 781cdf0e10cSrcweir return 1; 782cdf0e10cSrcweir } 783cdf0e10cSrcweir 784cdf0e10cSrcweir IMPL_LINK( StatusBarManager, DoubleClick, StatusBar*, EMPTYARG ) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir ResetableGuard aGuard( m_aLock ); 7872503e1a5SAriel Constenla-Haile 788cdf0e10cSrcweir if ( m_bDisposed ) 789cdf0e10cSrcweir return 1; 7902503e1a5SAriel Constenla-Haile 791cdf0e10cSrcweir sal_uInt16 nId = m_pStatusBar->GetCurItemId(); 7922503e1a5SAriel Constenla-Haile StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId ); 7932503e1a5SAriel Constenla-Haile if (( nId > 0 ) && ( it != m_aControllerMap.end() )) 794cdf0e10cSrcweir { 7952503e1a5SAriel Constenla-Haile uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY ); 796cdf0e10cSrcweir if ( xController.is() ) 7972503e1a5SAriel Constenla-Haile { 7982503e1a5SAriel Constenla-Haile const Point aVCLPos = m_pStatusBar->GetPointerPosPixel(); 7992503e1a5SAriel Constenla-Haile const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() ); 8002503e1a5SAriel Constenla-Haile xController->doubleClick( aAWTPoint ); 8012503e1a5SAriel Constenla-Haile } 802cdf0e10cSrcweir } 8032503e1a5SAriel Constenla-Haile 804cdf0e10cSrcweir return 1; 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir } 808