update dev300-m58
[ooovba.git] / framework / source / uielement / statusbarmanager.cxx
blob6c1cdf44f0d43b9df29d5c3d44d6a806d6979af5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statusbarmanager.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <uielement/statusbarmanager.hxx>
36 //_________________________________________________________________________________________________________________
37 // my own includes
38 //_________________________________________________________________________________________________________________
39 #include <threadhelp/threadhelpbase.hxx>
40 #include <threadhelp/resetableguard.hxx>
41 #include <classes/sfxhelperfunctions.hxx>
42 #include <macros/generic.hxx>
43 #include <macros/xinterface.hxx>
44 #include <macros/xtypeprovider.hxx>
45 #include <stdtypes.h>
46 #include "services.h"
47 #include "general.h"
48 #include "properties.h"
49 #include <helper/mischelper.hxx>
51 //_________________________________________________________________________________________________________________
52 // interface includes
53 //_________________________________________________________________________________________________________________
54 #include <com/sun/star/frame/XFrame.hpp>
55 #include <com/sun/star/frame/XStatusListener.hpp>
56 #include <com/sun/star/util/XUpdatable.hpp>
57 #include <com/sun/star/ui/ItemStyle.hpp>
58 #include <com/sun/star/ui/ItemType.hpp>
59 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
60 #include <com/sun/star/beans/XPropertySet.hpp>
61 #include <com/sun/star/awt/Command.hpp>
63 //_________________________________________________________________________________________________________________
64 // other includes
65 //_________________________________________________________________________________________________________________
67 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
68 #include <toolkit/unohlp.hxx>
69 #endif
70 #include <svtools/statusbarcontroller.hxx>
72 #include <vcl/status.hxx>
73 #include <vcl/svapp.hxx>
74 #include <rtl/logfile.hxx>
76 using namespace ::com::sun::star;
77 #ifndef css
78 #define css ::com::sun::star
79 #endif
80 #ifndef css_ui
81 #define css_ui ::com::sun::star::ui
82 #endif
84 const sal_Int32 HELPID_PREFIX_LENGTH = 7;
85 static const char* HELPID_PREFIX = "helpid:";
87 // Property names of a menu/menu item ItemDescriptor
88 static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
89 static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
90 static const char ITEM_DESCRIPTOR_OFFSET[] = "Offset";
91 static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
92 static const char ITEM_DESCRIPTOR_WIDTH[] = "Width";
93 static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
95 namespace framework
98 static USHORT impl_convertItemStyleToItemBits( sal_Int16 nStyle )
100 USHORT nItemBits( 0 );
102 if (( nStyle & css_ui::ItemStyle::ALIGN_RIGHT ) == css_ui::ItemStyle::ALIGN_RIGHT )
103 nItemBits |= SIB_RIGHT;
104 else if ( nStyle & css_ui::ItemStyle::ALIGN_LEFT )
105 nItemBits |= SIB_LEFT;
106 else
107 nItemBits |= SIB_CENTER;
109 if (( nStyle & css_ui::ItemStyle::DRAW_FLAT ) == css_ui::ItemStyle::DRAW_FLAT )
110 nItemBits |= SIB_FLAT;
111 else if ( nStyle & css_ui::ItemStyle::DRAW_OUT3D )
112 nItemBits |= SIB_OUT;
113 else
114 nItemBits |= SIB_IN;
116 if (( nStyle & css_ui::ItemStyle::AUTO_SIZE ) == css_ui::ItemStyle::AUTO_SIZE )
117 nItemBits |= SIB_AUTOSIZE;
118 if ( nStyle & css_ui::ItemStyle::OWNER_DRAW )
119 nItemBits |= SIB_USERDRAW;
121 return nItemBits;
124 //*****************************************************************************************************************
125 // XInterface, XTypeProvider, XServiceInfo
126 //*****************************************************************************************************************
127 DEFINE_XINTERFACE_5 ( StatusBarManager ,
128 ::cppu::OWeakObject ,
129 DIRECT_INTERFACE( lang::XTypeProvider ),
130 DIRECT_INTERFACE( lang::XComponent ),
131 DIRECT_INTERFACE( frame::XFrameActionListener ),
132 DIRECT_INTERFACE( css::ui::XUIConfigurationListener ),
133 DERIVED_INTERFACE( lang::XEventListener, frame::XFrameActionListener )
136 DEFINE_XTYPEPROVIDER_5 ( StatusBarManager ,
137 lang::XTypeProvider ,
138 lang::XComponent ,
139 css::ui::XUIConfigurationListener ,
140 frame::XFrameActionListener ,
141 lang::XEventListener
144 StatusBarManager::StatusBarManager(
145 const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
146 const uno::Reference< frame::XFrame >& rFrame,
147 const rtl::OUString& rResourceName,
148 StatusBar* pStatusBar ) :
149 ThreadHelpBase( &Application::GetSolarMutex() ),
150 OWeakObject(),
151 m_bDisposed( sal_False ),
152 m_bFrameActionRegistered( sal_False ),
153 m_bUpdateControllers( sal_False ),
154 m_bModuleIdentified( sal_False ),
155 m_pStatusBar( pStatusBar ),
156 m_aResourceName( rResourceName ),
157 m_xFrame( rFrame ),
158 m_aListenerContainer( m_aLock.getShareableOslMutex() ),
159 m_xServiceManager( rServiceManager )
161 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" );
163 if ( m_xServiceManager.is() )
164 m_xStatusbarControllerRegistration = uno::Reference< css::frame::XUIControllerRegistration >(
165 m_xServiceManager->createInstance( SERVICENAME_STATUSBARCONTROLLERFACTORY ),
166 uno::UNO_QUERY );
168 m_pStatusBar->SetClickHdl( LINK( this, StatusBarManager, Click ) );
169 m_pStatusBar->SetDoubleClickHdl( LINK( this, StatusBarManager, DoubleClick ) );
172 StatusBarManager::~StatusBarManager()
176 StatusBar* StatusBarManager::GetStatusBar() const
178 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" );
179 ResetableGuard aGuard( m_aLock );
180 return m_pStatusBar;
183 void StatusBarManager::frameAction( const frame::FrameActionEvent& Action )
184 throw ( uno::RuntimeException )
186 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" );
187 ResetableGuard aGuard( m_aLock );
188 if ( Action.Action == frame::FrameAction_CONTEXT_CHANGED )
189 UpdateControllers();
192 void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException )
194 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" );
196 ResetableGuard aGuard( m_aLock );
197 if ( m_bDisposed )
198 return;
201 RemoveControllers();
204 ResetableGuard aGuard( m_aLock );
205 if ( Source.Source == uno::Reference< uno::XInterface >( m_xFrame, uno::UNO_QUERY ))
206 m_xFrame.clear();
208 m_xServiceManager.clear();
212 // XComponent
213 void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException )
215 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" );
216 uno::Reference< lang::XComponent > xThis(
217 static_cast< OWeakObject* >(this), uno::UNO_QUERY );
219 lang::EventObject aEvent( xThis );
220 m_aListenerContainer.disposeAndClear( aEvent );
223 ResetableGuard aGuard( m_aLock );
224 if ( !m_bDisposed )
226 RemoveControllers();
228 delete m_pStatusBar;
229 m_pStatusBar = 0;
231 if ( m_bFrameActionRegistered && m_xFrame.is() )
235 m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(
236 static_cast< ::cppu::OWeakObject *>( this ),
237 uno::UNO_QUERY ));
239 catch ( uno::Exception& )
244 m_xFrame.clear();
245 m_xServiceManager.clear();
247 m_bDisposed = sal_True;
252 void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
254 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" );
255 ResetableGuard aGuard( m_aLock );
257 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
258 if ( m_bDisposed )
259 throw lang::DisposedException();
261 m_aListenerContainer.addInterface( ::getCppuType(
262 ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
265 void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
267 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" );
268 m_aListenerContainer.removeInterface( ::getCppuType(
269 ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
272 // XUIConfigurationListener
273 void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
275 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
276 ResetableGuard aGuard( m_aLock );
278 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
279 if ( m_bDisposed )
280 return;
283 void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
285 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
286 ResetableGuard aGuard( m_aLock );
288 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
289 if ( m_bDisposed )
290 return;
293 void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
295 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
296 ResetableGuard aGuard( m_aLock );
298 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
299 if ( m_bDisposed )
300 return;
303 void StatusBarManager::UpdateControllers()
305 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" );
306 if ( !m_bUpdateControllers )
308 m_bUpdateControllers = sal_True;
309 const sal_uInt32 nCount = m_aControllerVector.size();
310 for ( sal_uInt32 n = 0; n < nCount; n++ )
314 uno::Reference< util::XUpdatable > xUpdatable( m_aControllerVector[n], uno::UNO_QUERY );
315 if ( xUpdatable.is() )
316 xUpdatable->update();
318 catch ( uno::Exception& )
323 m_bUpdateControllers = sal_False;
326 void StatusBarManager::RemoveControllers()
328 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" );
329 ResetableGuard aGuard( m_aLock );
331 if ( m_bDisposed )
332 return;
334 const sal_uInt32 nCount = m_aControllerVector.size();
335 for ( sal_uInt32 n = 0; n < nCount; n++ )
339 uno::Reference< lang::XComponent > xComponent(
340 m_aControllerVector[n], uno::UNO_QUERY );
341 if ( xComponent.is() )
342 xComponent->dispose();
344 catch ( uno::Exception& )
348 m_aControllerVector[n].clear();
352 rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL )
354 return framework::RetrieveLabelFromCommand(aCmdURL,m_xServiceManager,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Name");
357 void StatusBarManager::CreateControllers()
359 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" );
360 uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY );
361 uno::Reference< uno::XComponentContext > xComponentContext;
362 uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY );
363 uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar );
365 if ( xProps.is() )
366 xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext;
368 for ( USHORT i = 0; i < m_pStatusBar->GetItemCount(); i++ )
370 USHORT nId = m_pStatusBar->GetItemId( i );
371 if ( nId == 0 )
372 continue;
374 rtl::OUString aCommandURL( m_pStatusBar->GetItemCommand( nId ));
375 sal_Bool bInit( sal_True );
376 uno::Reference< frame::XStatusListener > xController;
378 svt::StatusbarController* pController( 0 );
380 if ( m_xStatusbarControllerRegistration.is() &&
381 m_xStatusbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier ))
383 if ( xStatusbarControllerFactory.is() )
385 uno::Sequence< uno::Any > aSeq( 5 );
386 beans::PropertyValue aPropValue;
388 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" ));
389 aPropValue.Value = uno::makeAny( m_aModuleIdentifier );
390 aSeq[0] = uno::makeAny( aPropValue );
391 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
392 aPropValue.Value = uno::makeAny( m_xFrame );
393 aSeq[1] = uno::makeAny( aPropValue );
394 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
395 aPropValue.Value = uno::makeAny( m_xServiceManager );
396 aSeq[2] = uno::makeAny( aPropValue );
397 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
398 aPropValue.Value = uno::makeAny( xStatusbarWindow );
399 aSeq[3] = uno::makeAny( aPropValue );
400 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
401 aPropValue.Value = uno::makeAny( nId );
402 aSeq[4] = uno::makeAny( aPropValue );
404 xController = uno::Reference< frame::XStatusListener >(
405 xStatusbarControllerFactory->createInstanceWithArgumentsAndContext(
406 aCommandURL, aSeq, xComponentContext ),
407 uno::UNO_QUERY );
408 bInit = sal_False; // Initialization is done through the factory service
412 if ( !xController.is() )
414 pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
415 if ( !pController )
416 pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId );
418 if ( pController )
419 xController = uno::Reference< frame::XStatusListener >(
420 static_cast< ::cppu::OWeakObject *>( pController ),
421 uno::UNO_QUERY );
424 m_aControllerVector.push_back( xController );
425 uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY );
427 if ( xInit.is() )
429 if ( bInit )
431 beans::PropertyValue aPropValue;
432 uno::Sequence< uno::Any > aArgs( 5 );
433 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
434 aPropValue.Value = uno::makeAny( m_xFrame );
435 aArgs[0] = uno::makeAny( aPropValue );
436 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ));
437 aPropValue.Value = uno::makeAny( aCommandURL );
438 aArgs[1] = uno::makeAny( aPropValue );
439 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
440 aPropValue.Value = uno::makeAny( m_xServiceManager );
441 aArgs[2] = uno::makeAny( aPropValue );
442 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
443 aPropValue.Value = uno::makeAny( xStatusbarWindow );
444 aArgs[3] = uno::makeAny( aPropValue );
445 aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
446 aPropValue.Value = uno::makeAny( nId );
447 aArgs[4] = uno::makeAny( aPropValue );
448 xInit->initialize( aArgs );
453 AddFrameActionListener();
456 void StatusBarManager::AddFrameActionListener()
458 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" );
459 if ( !m_bFrameActionRegistered && m_xFrame.is() )
461 m_bFrameActionRegistered = sal_True;
462 m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(
463 static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY ));
467 void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAccess >& rItemContainer )
469 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::StatusBarManager::FillStatusbar" );
471 ResetableGuard aGuard( m_aLock );
473 if ( m_bDisposed || !m_pStatusBar )
474 return;
476 USHORT nId( 1 );
477 rtl::OUString aHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ));
479 RemoveControllers();
481 // reset and fill command map
482 m_pStatusBar->Clear();
483 m_aControllerVector.clear();
485 for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
487 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" );
488 uno::Sequence< beans::PropertyValue > aProp;
489 rtl::OUString aCommandURL;
490 rtl::OUString aHelpURL;
491 sal_Int16 nOffset( 0 );
492 sal_Int16 nStyle( 0 );
493 sal_Int16 nWidth( 0 );
494 sal_uInt16 nType( css_ui::ItemType::DEFAULT );
498 if ( rItemContainer->getByIndex( n ) >>= aProp )
500 for ( int i = 0; i < aProp.getLength(); i++ )
502 if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
504 aProp[i].Value >>= aCommandURL;
506 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
508 aProp[i].Value >>= aHelpURL;
510 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
512 aProp[i].Value >>= nStyle;
514 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
516 aProp[i].Value >>= nType;
518 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH ))
520 aProp[i].Value >>= nWidth;
522 else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_OFFSET ))
524 aProp[i].Value >>= nOffset;
528 if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && ( aCommandURL.getLength() > 0 ))
530 rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
531 USHORT nItemBits( impl_convertItemStyleToItemBits( nStyle ));
533 m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );
534 m_pStatusBar->SetItemCommand( nId, aCommandURL );
535 m_pStatusBar->SetAccessibleName( nId, aString );
536 // m_pStatusBar->SetHelpText( nId, aString );
538 if ( aHelpURL.indexOf( aHelpIdPrefix ) == 0 )
540 rtl::OUString aId( aHelpURL.copy( HELPID_PREFIX_LENGTH ));
541 sal_uInt16 nHelpId = (sal_uInt16)(aId.toInt32());
542 if ( nHelpId > 0 )
543 m_pStatusBar->SetHelpId( nId, nHelpId );
546 ++nId;
550 catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
552 break;
556 // Create controllers
557 CreateControllers();
559 // Notify controllers that they are now correctly initialized and can start listening
560 UpdateControllers();
563 void StatusBarManager::StateChanged( StateChangedType )
565 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" );
568 void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt )
570 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" );
571 ResetableGuard aGuard( m_aLock );
573 if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
574 ( rDCEvt.GetType() == DATACHANGED_FONTS ) ||
575 ( rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION ) ||
576 ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) &&
577 ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
579 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
580 css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY );
581 if ( xPropSet.is() )
582 xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager;
583 if ( xLayoutManager.is() )
585 aGuard.unlock();
586 xLayoutManager->doLayout();
591 void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt )
593 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" );
594 ResetableGuard aGuard( m_aLock );
596 if ( m_bDisposed )
597 return;
599 USHORT nId( rUDEvt.GetItemId() );
600 if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
602 uno::Reference< frame::XStatusbarController > xController(
603 m_aControllerVector[nId-1], uno::UNO_QUERY );
604 if ( xController.is() && rUDEvt.GetDevice() )
606 uno::Reference< awt::XGraphics > xGraphics =
607 rUDEvt.GetDevice()->CreateUnoGraphics();
609 awt::Rectangle aRect( rUDEvt.GetRect().Left(),
610 rUDEvt.GetRect().Top(),
611 rUDEvt.GetRect().GetWidth(),
612 rUDEvt.GetRect().GetHeight() );
613 aGuard.unlock();
614 xController->paint( xGraphics, aRect, rUDEvt.GetItemId(), rUDEvt.GetStyle() );
619 void StatusBarManager::Command( const CommandEvent& rEvt )
621 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" );
622 ResetableGuard aGuard( m_aLock );
624 if ( m_bDisposed )
625 return;
627 if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU )
629 USHORT nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() );
630 if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
632 uno::Reference< frame::XStatusbarController > xController(
633 m_aControllerVector[nId-1], uno::UNO_QUERY );
634 if ( xController.is() )
636 awt::Point aPos;
637 aPos.X = rEvt.GetMousePosPixel().X();
638 aPos.Y = rEvt.GetMousePosPixel().Y();
639 xController->command( aPos, awt::Command::CONTEXTMENU, sal_True, uno::Any() );
645 void StatusBarManager::MouseMove( const MouseEvent& rMEvt )
647 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" );
648 MouseButton(rMEvt,&frame::XStatusbarController::mouseMove);
650 void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&))
652 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" );
653 ResetableGuard aGuard( m_aLock );
655 if ( !m_bDisposed )
657 USHORT nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() );
658 if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
660 uno::Reference< frame::XStatusbarController > xController(
661 m_aControllerVector[nId-1], uno::UNO_QUERY );
662 if ( xController.is() )
664 ::com::sun::star::awt::MouseEvent aMouseEvent;
665 aMouseEvent.Buttons = rMEvt.GetButtons();
666 aMouseEvent.X = rMEvt.GetPosPixel().X();
667 aMouseEvent.Y = rMEvt.GetPosPixel().Y();
668 aMouseEvent.ClickCount = rMEvt.GetClicks();
669 (xController.get()->*_pMethod)( aMouseEvent);
671 } // if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
674 void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt )
676 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" );
677 MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown);
680 void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt )
682 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" );
683 MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp);
686 IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG )
688 ResetableGuard aGuard( m_aLock );
690 if ( m_bDisposed )
691 return 1;
693 USHORT nId = m_pStatusBar->GetCurItemId();
694 if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
696 uno::Reference< frame::XStatusbarController > xController(
697 m_aControllerVector[nId-1], uno::UNO_QUERY );
698 if ( xController.is() )
699 xController->click();
702 return 1;
705 IMPL_LINK( StatusBarManager, DoubleClick, StatusBar*, EMPTYARG )
707 ResetableGuard aGuard( m_aLock );
709 if ( m_bDisposed )
710 return 1;
712 USHORT nId = m_pStatusBar->GetCurItemId();
713 if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
715 uno::Reference< frame::XStatusbarController > xController(
716 m_aControllerVector[nId-1], uno::UNO_QUERY );
717 if ( xController.is() )
718 xController->doubleClick();
721 return 1;