1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <uielement/statusbarmanager.hxx>
22 #include <uielement/genericstatusbarcontroller.hxx>
24 #include <threadhelp/threadhelpbase.hxx>
25 #include <threadhelp/resetableguard.hxx>
26 #include <framework/sfxhelperfunctions.hxx>
27 #include <framework/addonsoptions.hxx>
28 #include <uielement/statusbarmerger.hxx>
29 #include <uielement/statusbaritem.hxx>
30 #include <macros/generic.hxx>
31 #include <macros/xinterface.hxx>
32 #include <macros/xtypeprovider.hxx>
36 #include "properties.h"
37 #include <helper/mischelper.hxx>
39 #include <com/sun/star/frame/XFrame.hpp>
40 #include <com/sun/star/frame/XStatusListener.hpp>
41 #include <com/sun/star/frame/StatusbarControllerFactory.hpp>
42 #include <com/sun/star/util/XUpdatable.hpp>
43 #include <com/sun/star/ui/ItemStyle.hpp>
44 #include <com/sun/star/ui/ItemType.hpp>
45 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/awt/Command.hpp>
48 #include <com/sun/star/ui/XStatusbarItem.hdl>
49 #include <comphelper/processfactory.hxx>
50 #include <toolkit/unohlp.hxx>
51 #include <toolkit/helper/vclunohelper.hxx>
52 #include <svtools/statusbarcontroller.hxx>
53 #include <comphelper/processfactory.hxx>
55 #include <vcl/status.hxx>
56 #include <vcl/svapp.hxx>
57 #include <rtl/logfile.hxx>
61 using namespace ::com::sun::star
;
63 // Property names of a menu/menu item ItemDescriptor
64 static const char ITEM_DESCRIPTOR_COMMANDURL
[] = "CommandURL";
65 static const char ITEM_DESCRIPTOR_HELPURL
[] = "HelpURL";
66 static const char ITEM_DESCRIPTOR_OFFSET
[] = "Offset";
67 static const char ITEM_DESCRIPTOR_STYLE
[] = "Style";
68 static const char ITEM_DESCRIPTOR_WIDTH
[] = "Width";
69 static const char ITEM_DESCRIPTOR_TYPE
[] = "Type";
78 struct lcl_UpdateController
: public std::unary_function
< typename
MAP::value_type
, void >
80 void operator()( typename
MAP::value_type
&rElement
) const
84 uno::Reference
< util::XUpdatable
> xUpdatable( rElement
.second
, uno::UNO_QUERY
);
85 if ( xUpdatable
.is() )
88 catch ( uno::Exception
& )
95 struct lcl_RemoveController
: public std::unary_function
< typename
MAP::value_type
, void >
97 void operator()( typename
MAP::value_type
&rElement
) const
101 uno::Reference
< lang::XComponent
> xComponent( rElement
.second
, uno::UNO_QUERY
);
102 if ( xComponent
.is() )
103 xComponent
->dispose();
105 catch ( uno::Exception
& )
111 static sal_uInt16
impl_convertItemStyleToItemBits( sal_Int16 nStyle
)
113 sal_uInt16
nItemBits( 0 );
115 if (( nStyle
& ::com::sun::star::ui::ItemStyle::ALIGN_RIGHT
) == ::com::sun::star::ui::ItemStyle::ALIGN_RIGHT
)
116 nItemBits
|= SIB_RIGHT
;
117 else if ( nStyle
& ::com::sun::star::ui::ItemStyle::ALIGN_LEFT
)
118 nItemBits
|= SIB_LEFT
;
120 nItemBits
|= SIB_CENTER
;
122 if (( nStyle
& ::com::sun::star::ui::ItemStyle::DRAW_FLAT
) == ::com::sun::star::ui::ItemStyle::DRAW_FLAT
)
123 nItemBits
|= SIB_FLAT
;
124 else if ( nStyle
& ::com::sun::star::ui::ItemStyle::DRAW_OUT3D
)
125 nItemBits
|= SIB_OUT
;
129 if (( nStyle
& ::com::sun::star::ui::ItemStyle::AUTO_SIZE
) == ::com::sun::star::ui::ItemStyle::AUTO_SIZE
)
130 nItemBits
|= SIB_AUTOSIZE
;
131 if ( nStyle
& ::com::sun::star::ui::ItemStyle::OWNER_DRAW
)
132 nItemBits
|= SIB_USERDRAW
;
138 //*****************************************************************************************************************
139 // XInterface, XTypeProvider, XServiceInfo
140 //*****************************************************************************************************************
141 DEFINE_XINTERFACE_5 ( StatusBarManager
,
142 ::cppu::OWeakObject
,
143 DIRECT_INTERFACE( lang::XTypeProvider
),
144 DIRECT_INTERFACE( lang::XComponent
),
145 DIRECT_INTERFACE( frame::XFrameActionListener
),
146 DIRECT_INTERFACE( css::ui::XUIConfigurationListener
),
147 DERIVED_INTERFACE( lang::XEventListener
, frame::XFrameActionListener
)
150 DEFINE_XTYPEPROVIDER_5 ( StatusBarManager
,
151 lang::XTypeProvider
,
153 css::ui::XUIConfigurationListener
,
154 frame::XFrameActionListener
,
158 StatusBarManager::StatusBarManager(
159 const uno::Reference
< lang::XMultiServiceFactory
>& rServiceManager
,
160 const uno::Reference
< frame::XFrame
>& rFrame
,
161 const OUString
& rResourceName
,
162 StatusBar
* pStatusBar
) :
163 ThreadHelpBase( &Application::GetSolarMutex() ),
165 m_bDisposed( sal_False
),
166 m_bFrameActionRegistered( sal_False
),
167 m_bUpdateControllers( sal_False
),
168 m_bModuleIdentified( sal_False
),
169 m_pStatusBar( pStatusBar
),
170 m_aResourceName( rResourceName
),
172 m_aListenerContainer( m_aLock
.getShareableOslMutex() ),
173 m_xServiceManager( rServiceManager
)
175 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" );
177 m_xStatusbarControllerFactory
= frame::StatusbarControllerFactory::create(
178 ::comphelper::getProcessComponentContext());
180 m_pStatusBar
->SetClickHdl( LINK( this, StatusBarManager
, Click
) );
181 m_pStatusBar
->SetDoubleClickHdl( LINK( this, StatusBarManager
, DoubleClick
) );
184 StatusBarManager::~StatusBarManager()
188 StatusBar
* StatusBarManager::GetStatusBar() const
190 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" );
191 ResetableGuard
aGuard( m_aLock
);
195 void StatusBarManager::frameAction( const frame::FrameActionEvent
& Action
)
196 throw ( uno::RuntimeException
)
198 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" );
199 ResetableGuard
aGuard( m_aLock
);
200 if ( Action
.Action
== frame::FrameAction_CONTEXT_CHANGED
)
204 void SAL_CALL
StatusBarManager::disposing( const lang::EventObject
& Source
) throw ( uno::RuntimeException
)
206 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" );
208 ResetableGuard
aGuard( m_aLock
);
216 ResetableGuard
aGuard( m_aLock
);
217 if ( Source
.Source
== uno::Reference
< uno::XInterface
>( m_xFrame
, uno::UNO_QUERY
))
220 m_xServiceManager
.clear();
225 void SAL_CALL
StatusBarManager::dispose() throw( uno::RuntimeException
)
227 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" );
228 uno::Reference
< lang::XComponent
> xThis(
229 static_cast< OWeakObject
* >(this), uno::UNO_QUERY
);
231 lang::EventObject
aEvent( xThis
);
232 m_aListenerContainer
.disposeAndClear( aEvent
);
235 ResetableGuard
aGuard( m_aLock
);
240 // destroy the item data
241 for ( sal_uInt16 n
= 0; n
< m_pStatusBar
->GetItemCount(); n
++ )
243 AddonStatusbarItemData
*pUserData
= static_cast< AddonStatusbarItemData
*>(
244 m_pStatusBar
->GetItemData( m_pStatusBar
->GetItemId( n
) ) );
252 if ( m_bFrameActionRegistered
&& m_xFrame
.is() )
256 m_xFrame
->removeFrameActionListener( uno::Reference
< frame::XFrameActionListener
>(
257 static_cast< ::cppu::OWeakObject
*>( this ),
260 catch ( const uno::Exception
& )
266 m_xServiceManager
.clear();
268 m_bDisposed
= sal_True
;
273 void SAL_CALL
StatusBarManager::addEventListener( const uno::Reference
< lang::XEventListener
>& xListener
) throw( uno::RuntimeException
)
275 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" );
276 ResetableGuard
aGuard( m_aLock
);
278 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
280 throw lang::DisposedException();
282 m_aListenerContainer
.addInterface( ::getCppuType(
283 ( const uno::Reference
< lang::XEventListener
>* ) NULL
), xListener
);
286 void SAL_CALL
StatusBarManager::removeEventListener( const uno::Reference
< lang::XEventListener
>& xListener
) throw( uno::RuntimeException
)
288 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" );
289 m_aListenerContainer
.removeInterface( ::getCppuType(
290 ( const uno::Reference
< lang::XEventListener
>* ) NULL
), xListener
);
293 // XUIConfigurationListener
294 void SAL_CALL
StatusBarManager::elementInserted( const css::ui::ConfigurationEvent
& ) throw ( uno::RuntimeException
)
296 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
297 ResetableGuard
aGuard( m_aLock
);
303 void SAL_CALL
StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent
& ) throw ( uno::RuntimeException
)
305 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
306 ResetableGuard
aGuard( m_aLock
);
312 void SAL_CALL
StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent
& ) throw ( uno::RuntimeException
)
314 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
315 ResetableGuard
aGuard( m_aLock
);
321 void StatusBarManager::UpdateControllers()
323 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" );
324 if ( !m_bUpdateControllers
)
326 m_bUpdateControllers
= sal_True
;
327 std::for_each( m_aControllerMap
.begin(),
328 m_aControllerMap
.end(),
329 lcl_UpdateController
< StatusBarControllerMap
>() );
331 m_bUpdateControllers
= sal_False
;
334 void StatusBarManager::RemoveControllers()
336 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" );
337 ResetableGuard
aGuard( m_aLock
);
342 std::for_each( m_aControllerMap
.begin(),
343 m_aControllerMap
.end(),
344 lcl_RemoveController
< StatusBarControllerMap
>() );
345 m_aControllerMap
.clear();
348 OUString
StatusBarManager::RetrieveLabelFromCommand( const OUString
& aCmdURL
)
350 return framework::RetrieveLabelFromCommand(aCmdURL
, comphelper::getComponentContext(m_xServiceManager
), m_xUICommandLabels
,m_xFrame
,m_aModuleIdentifier
,m_bModuleIdentified
,"Name");
353 void StatusBarManager::CreateControllers()
355 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" );
356 uno::Reference
< uno::XComponentContext
> xComponentContext(
357 comphelper::getComponentContext( m_xServiceManager
) );
358 uno::Reference
< awt::XWindow
> xStatusbarWindow
= VCLUnoHelper::GetInterface( m_pStatusBar
);
360 for ( sal_uInt16 i
= 0; i
< m_pStatusBar
->GetItemCount(); i
++ )
362 sal_uInt16 nId
= m_pStatusBar
->GetItemId( i
);
366 OUString
aCommandURL( m_pStatusBar
->GetItemCommand( nId
));
367 sal_Bool
bInit( sal_True
);
368 uno::Reference
< frame::XStatusListener
> xController
;
369 AddonStatusbarItemData
*pItemData
= static_cast< AddonStatusbarItemData
*>( m_pStatusBar
->GetItemData( nId
) );
370 uno::Reference
< ui::XStatusbarItem
> xStatusbarItem(
371 static_cast< cppu::OWeakObject
*>( new StatusbarItem( m_pStatusBar
, pItemData
, nId
, aCommandURL
) ),
374 svt::StatusbarController
* pController( 0 );
376 // 1º) UNO Statusbar controllers, registered in Controllers.xcu
377 if ( m_xStatusbarControllerFactory
.is() &&
378 m_xStatusbarControllerFactory
->hasController( aCommandURL
, m_aModuleIdentifier
))
380 beans::PropertyValue aPropValue
;
381 std::vector
< uno::Any
> aPropVector
;
383 aPropValue
.Name
= OUString( "ModuleIdentifier" );
384 aPropValue
.Value
= uno::makeAny( m_aModuleIdentifier
);
385 aPropVector
.push_back( uno::makeAny( aPropValue
) );
387 aPropValue
.Name
= OUString( "Frame" );
388 aPropValue
.Value
= uno::makeAny( m_xFrame
);
389 aPropVector
.push_back( uno::makeAny( aPropValue
) );
392 aPropValue
.Name
= OUString( "ServiceManager" );
393 aPropValue
.Value
= uno::makeAny( m_xServiceManager
);
394 aPropVector
.push_back( uno::makeAny( aPropValue
) );
396 aPropValue
.Name
= OUString( "ParentWindow" );
397 aPropValue
.Value
= uno::makeAny( xStatusbarWindow
);
398 aPropVector
.push_back( uno::makeAny( aPropValue
) );
400 // TODO still needing with the css::ui::XStatusbarItem?
401 aPropValue
.Name
= OUString( "Identifier" );
402 aPropValue
.Value
= uno::makeAny( nId
);
403 aPropVector
.push_back( uno::makeAny( aPropValue
) );
405 aPropValue
.Name
= OUString( "StatusbarItem" );
406 aPropValue
.Value
<<= xStatusbarItem
;
407 aPropVector
.push_back( uno::makeAny( aPropValue
) );
409 uno::Sequence
< uno::Any
> aArgs( comphelper::containerToSequence( aPropVector
) );
410 xController
= uno::Reference
< frame::XStatusListener
>(
411 m_xStatusbarControllerFactory
->createInstanceWithArgumentsAndContext(
412 aCommandURL
, aArgs
, xComponentContext
),
414 bInit
= sal_False
; // Initialization is done through the factory service
417 if ( !xController
.is() )
419 // 2º) Old SFX2 Statusbar controllers
420 pController
= CreateStatusBarController( m_xFrame
, m_pStatusBar
, nId
, aCommandURL
);
423 // 3º) Is Add-on? Generic statusbar controller
426 pController
= new GenericStatusbarController( m_xServiceManager
,
433 // 4º) Default Statusbar controller
434 pController
= new svt::StatusbarController( m_xServiceManager
, m_xFrame
, aCommandURL
, nId
);
439 xController
= uno::Reference
< frame::XStatusListener
>(
440 static_cast< ::cppu::OWeakObject
*>( pController
),
444 m_aControllerMap
[nId
] = xController
;
445 uno::Reference
< lang::XInitialization
> xInit( xController
, uno::UNO_QUERY
);
451 beans::PropertyValue aPropValue
;
452 uno::Sequence
< uno::Any
> aArgs( 6 );
453 aPropValue
.Name
= OUString( "Frame" );
454 aPropValue
.Value
= uno::makeAny( m_xFrame
);
455 aArgs
[0] = uno::makeAny( aPropValue
);
456 aPropValue
.Name
= OUString( "CommandURL" );
457 aPropValue
.Value
= uno::makeAny( aCommandURL
);
458 aArgs
[1] = uno::makeAny( aPropValue
);
459 aPropValue
.Name
= OUString( "ServiceManager" );
460 aPropValue
.Value
= uno::makeAny( m_xServiceManager
);
461 aArgs
[2] = uno::makeAny( aPropValue
);
462 aPropValue
.Name
= OUString( "ParentWindow" );
463 aPropValue
.Value
= uno::makeAny( xStatusbarWindow
);
464 aArgs
[3] = uno::makeAny( aPropValue
);
465 aPropValue
.Name
= OUString( "Identifier" );
466 aPropValue
.Value
= uno::makeAny( nId
);
467 aArgs
[4] = uno::makeAny( aPropValue
);
468 aPropValue
.Name
= OUString( "StatusbarItem" );
469 aPropValue
.Value
<<= xStatusbarItem
;
470 aArgs
[5] = uno::makeAny( aPropValue
);
471 xInit
->initialize( aArgs
);
476 AddFrameActionListener();
479 void StatusBarManager::AddFrameActionListener()
481 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" );
482 if ( !m_bFrameActionRegistered
&& m_xFrame
.is() )
484 m_bFrameActionRegistered
= sal_True
;
485 m_xFrame
->addFrameActionListener( uno::Reference
< frame::XFrameActionListener
>(
486 static_cast< ::cppu::OWeakObject
*>( this ), uno::UNO_QUERY
));
490 void StatusBarManager::FillStatusBar( const uno::Reference
< container::XIndexAccess
>& rItemContainer
)
492 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::StatusBarManager::FillStatusbar" );
494 ResetableGuard
aGuard( m_aLock
);
496 if ( m_bDisposed
|| !m_pStatusBar
)
503 // reset and fill command map
504 m_pStatusBar
->Clear();
505 m_aControllerMap
.clear();// TODO already done in RemoveControllers
507 for ( sal_Int32 n
= 0; n
< rItemContainer
->getCount(); n
++ )
509 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" );
510 uno::Sequence
< beans::PropertyValue
> aProp
;
511 OUString aCommandURL
;
513 sal_Int16
nOffset( 0 );
514 sal_Int16
nStyle( 0 );
515 sal_Int16
nWidth( 0 );
516 sal_uInt16
nType( ::com::sun::star::ui::ItemType::DEFAULT
);
520 if ( rItemContainer
->getByIndex( n
) >>= aProp
)
522 for ( int i
= 0; i
< aProp
.getLength(); i
++ )
524 if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_COMMANDURL
)
526 aProp
[i
].Value
>>= aCommandURL
;
528 else if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_HELPURL
)
530 aProp
[i
].Value
>>= aHelpURL
;
532 else if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_STYLE
)
534 aProp
[i
].Value
>>= nStyle
;
536 else if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_TYPE
)
538 aProp
[i
].Value
>>= nType
;
540 else if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_WIDTH
)
542 aProp
[i
].Value
>>= nWidth
;
544 else if ( aProp
[i
].Name
== ITEM_DESCRIPTOR_OFFSET
)
546 aProp
[i
].Value
>>= nOffset
;
550 if (( nType
== ::com::sun::star::ui::ItemType::DEFAULT
) && !aCommandURL
.isEmpty() )
552 OUString
aString( RetrieveLabelFromCommand( aCommandURL
));
553 sal_uInt16
nItemBits( impl_convertItemStyleToItemBits( nStyle
));
555 m_pStatusBar
->InsertItem( nId
, nWidth
, nItemBits
, nOffset
);
556 m_pStatusBar
->SetItemCommand( nId
, aCommandURL
);
557 m_pStatusBar
->SetAccessibleName( nId
, aString
);
562 catch ( const ::com::sun::star::lang::IndexOutOfBoundsException
& )
569 const sal_uInt16 STATUSBAR_ITEM_STARTID
= 1000;
570 MergeStatusbarInstructionContainer aMergeInstructions
= AddonsOptions().GetMergeStatusbarInstructions();
571 if ( !aMergeInstructions
.empty() )
573 const sal_uInt32 nCount
= aMergeInstructions
.size();
574 sal_uInt16
nItemId( STATUSBAR_ITEM_STARTID
);
576 for ( sal_uInt32 i
= 0; i
< nCount
; i
++ )
578 MergeStatusbarInstruction
&rInstruction
= aMergeInstructions
[i
];
579 if ( !StatusbarMerger::IsCorrectContext( rInstruction
.aMergeContext
, m_aModuleIdentifier
) )
582 AddonStatusbarItemContainer aItems
;
583 StatusbarMerger::ConvertSeqSeqToVector( rInstruction
.aMergeStatusbarItems
, aItems
);
585 sal_uInt16 nRefPos
= StatusbarMerger::FindReferencePos( m_pStatusBar
, rInstruction
.aMergePoint
);
586 if ( nRefPos
!= STATUSBAR_ITEM_NOTFOUND
)
588 StatusbarMerger::ProcessMergeOperation( m_pStatusBar
,
592 rInstruction
.aMergeCommand
,
593 rInstruction
.aMergeCommandParameter
,
598 StatusbarMerger::ProcessMergeFallback( m_pStatusBar
,
602 rInstruction
.aMergeCommand
,
603 rInstruction
.aMergeCommandParameter
,
609 // Create controllers
612 // Notify controllers that they are now correctly initialized and can start listening
616 void StatusBarManager::StateChanged( StateChangedType
)
618 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" );
621 void StatusBarManager::DataChanged( const DataChangedEvent
& rDCEvt
)
623 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" );
624 ResetableGuard
aGuard( m_aLock
);
626 if ((( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) ||
627 ( rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
628 ( rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
629 ( rDCEvt
.GetType() == DATACHANGED_DISPLAY
)) &&
630 ( rDCEvt
.GetFlags() & SETTINGS_STYLE
))
632 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager
;
633 css::uno::Reference
< css::beans::XPropertySet
> xPropSet( m_xFrame
, css::uno::UNO_QUERY
);
635 xPropSet
->getPropertyValue( OUString( "LayoutManager" )) >>= xLayoutManager
;
636 if ( xLayoutManager
.is() )
639 xLayoutManager
->doLayout();
644 void StatusBarManager::UserDraw( const UserDrawEvent
& rUDEvt
)
646 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" );
647 ResetableGuard
aGuard( m_aLock
);
652 sal_uInt16
nId( rUDEvt
.GetItemId() );
653 StatusBarControllerMap::const_iterator it
= m_aControllerMap
.find( nId
);
654 if (( nId
> 0 ) && ( it
!= m_aControllerMap
.end() ))
656 uno::Reference
< frame::XStatusbarController
> xController( it
->second
, uno::UNO_QUERY
);
657 if ( xController
.is() && rUDEvt
.GetDevice() )
659 uno::Reference
< awt::XGraphics
> xGraphics
=
660 rUDEvt
.GetDevice()->CreateUnoGraphics();
662 awt::Rectangle
aRect( rUDEvt
.GetRect().Left(),
663 rUDEvt
.GetRect().Top(),
664 rUDEvt
.GetRect().GetWidth(),
665 rUDEvt
.GetRect().GetHeight() );
667 xController
->paint( xGraphics
, aRect
, rUDEvt
.GetStyle() );
672 void StatusBarManager::Command( const CommandEvent
& rEvt
)
674 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" );
675 ResetableGuard
aGuard( m_aLock
);
680 if ( rEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
682 sal_uInt16 nId
= m_pStatusBar
->GetItemId( rEvt
.GetMousePosPixel() );
683 StatusBarControllerMap::const_iterator it
= m_aControllerMap
.find( nId
);
684 if (( nId
> 0 ) && ( it
!= m_aControllerMap
.end() ))
686 uno::Reference
< frame::XStatusbarController
> xController( it
->second
, uno::UNO_QUERY
);
687 if ( xController
.is() )
690 aPos
.X
= rEvt
.GetMousePosPixel().X();
691 aPos
.Y
= rEvt
.GetMousePosPixel().Y();
692 xController
->command( aPos
, awt::Command::CONTEXTMENU
, sal_True
, uno::Any() );
698 void StatusBarManager::MouseMove( const MouseEvent
& rMEvt
)
700 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" );
701 MouseButton(rMEvt
,&frame::XStatusbarController::mouseMove
);
704 void StatusBarManager::MouseButton( const MouseEvent
& rMEvt
,sal_Bool ( SAL_CALL
frame::XStatusbarController::*_pMethod
)(const ::com::sun::star::awt::MouseEvent
&))
706 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" );
707 ResetableGuard
aGuard( m_aLock
);
711 sal_uInt16 nId
= m_pStatusBar
->GetItemId( rMEvt
.GetPosPixel() );
712 StatusBarControllerMap::const_iterator it
= m_aControllerMap
.find( nId
);
713 if (( nId
> 0 ) && ( it
!= m_aControllerMap
.end() ))
715 uno::Reference
< frame::XStatusbarController
> xController( it
->second
, uno::UNO_QUERY
);
716 if ( xController
.is() )
718 ::com::sun::star::awt::MouseEvent aMouseEvent
;
719 aMouseEvent
.Buttons
= rMEvt
.GetButtons();
720 aMouseEvent
.X
= rMEvt
.GetPosPixel().X();
721 aMouseEvent
.Y
= rMEvt
.GetPosPixel().Y();
722 aMouseEvent
.ClickCount
= rMEvt
.GetClicks();
723 (xController
.get()->*_pMethod
)( aMouseEvent
);
729 void StatusBarManager::MouseButtonDown( const MouseEvent
& rMEvt
)
731 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" );
732 MouseButton(rMEvt
,&frame::XStatusbarController::mouseButtonDown
);
735 void StatusBarManager::MouseButtonUp( const MouseEvent
& rMEvt
)
737 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" );
738 MouseButton(rMEvt
,&frame::XStatusbarController::mouseButtonUp
);
741 IMPL_LINK_NOARG(StatusBarManager
, Click
)
743 ResetableGuard
aGuard( m_aLock
);
748 sal_uInt16 nId
= m_pStatusBar
->GetCurItemId();
749 StatusBarControllerMap::const_iterator it
= m_aControllerMap
.find( nId
);
750 if (( nId
> 0 ) && ( it
!= m_aControllerMap
.end() ))
752 uno::Reference
< frame::XStatusbarController
> xController( it
->second
, uno::UNO_QUERY
);
753 if ( xController
.is() )
755 const Point aVCLPos
= m_pStatusBar
->GetPointerPosPixel();
756 const awt::Point
aAWTPoint( aVCLPos
.X(), aVCLPos
.Y() );
757 xController
->click( aAWTPoint
);
764 IMPL_LINK_NOARG(StatusBarManager
, DoubleClick
)
766 ResetableGuard
aGuard( m_aLock
);
771 sal_uInt16 nId
= m_pStatusBar
->GetCurItemId();
772 StatusBarControllerMap::const_iterator it
= m_aControllerMap
.find( nId
);
773 if (( nId
> 0 ) && ( it
!= m_aControllerMap
.end() ))
775 uno::Reference
< frame::XStatusbarController
> xController( it
->second
, uno::UNO_QUERY
);
776 if ( xController
.is() )
778 const Point aVCLPos
= m_pStatusBar
->GetPointerPosPixel();
779 const awt::Point
aAWTPoint( aVCLPos
.X(), aVCLPos
.Y() );
780 xController
->doubleClick( aAWTPoint
);
789 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */