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 <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
25 #include <unotools/accessiblestatesethelper.hxx>
27 #include <vcl/svapp.hxx>
29 #include "svtools/toolbarmenu.hxx"
31 #include "toolbarmenuimp.hxx"
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::lang
;
37 using namespace ::com::sun::star::accessibility
;
45 ToolbarMenuAcc::ToolbarMenuAcc( ToolbarMenu_Impl
& rParent
)
46 : ToolbarMenuAccComponentBase(m_aMutex
)
47 , mpParent( &rParent
)
50 mpParent
->mrMenu
.AddEventListener( LINK( this, ToolbarMenuAcc
, WindowEventListener
) );
53 // -----------------------------------------------------------------------------
55 ToolbarMenuAcc::~ToolbarMenuAcc()
58 mpParent
->mrMenu
.RemoveEventListener( LINK( this, ToolbarMenuAcc
, WindowEventListener
) );
61 // -----------------------------------------------------------------------
63 IMPL_LINK( ToolbarMenuAcc
, WindowEventListener
, VclSimpleEvent
*, pEvent
)
65 DBG_ASSERT( pEvent
&& pEvent
->ISA( VclWindowEvent
), "Unknown WindowEvent!" );
67 /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper
68 * might have been destroyed by the previous VCLEventListener (if no AT tool
69 * is running), e.g. sub-toolbars in impress.
71 if ( mpParent
&& pEvent
&& pEvent
->ISA( VclWindowEvent
) && (pEvent
->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE
) )
73 DBG_ASSERT( ((VclWindowEvent
*)pEvent
)->GetWindow(), "Window???" );
74 if( !((VclWindowEvent
*)pEvent
)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent
->GetId() == VCLEVENT_OBJECT_DYING
) )
76 ProcessWindowEvent( *(VclWindowEvent
*)pEvent
);
82 // -----------------------------------------------------------------------
84 void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
86 switch ( rVclWindowEvent
.GetId() )
88 case VCLEVENT_OBJECT_DYING
:
90 mpParent
->mrMenu
.RemoveEventListener( LINK( this, ToolbarMenuAcc
, WindowEventListener
) );
95 case VCLEVENT_WINDOW_GETFOCUS
:
99 mpParent
->notifyHighlightedEntry();
104 case VCLEVENT_WINDOW_LOSEFOCUS
:
119 // -----------------------------------------------------------------------
121 void ToolbarMenuAcc::FireAccessibleEvent( short nEventId
, const Any
& rOldValue
, const Any
& rNewValue
)
125 EventListenerVector
aTmpListeners( mxEventListeners
);
126 AccessibleEventObject aEvtObject
;
128 aEvtObject
.EventId
= nEventId
;
129 aEvtObject
.Source
= static_cast<XWeak
*>(this);
130 aEvtObject
.NewValue
= rNewValue
;
131 aEvtObject
.OldValue
= rOldValue
;
133 for (EventListenerVector::const_iterator
aIter( aTmpListeners
.begin() ), aEnd( aTmpListeners
.end() );
134 aIter
!= aEnd
; ++aIter
)
138 (*aIter
)->notifyEvent( aEvtObject
);
147 // -----------------------------------------------------------------------------
149 Reference
< XAccessibleContext
> SAL_CALL
ToolbarMenuAcc::getAccessibleContext() throw (RuntimeException
)
155 // -----------------------------------------------------------------------------
157 sal_Int32 SAL_CALL
ToolbarMenuAcc::getAccessibleChildCount() throw (RuntimeException
)
159 const SolarMutexGuard aSolarGuard
;
162 return mpParent
->getAccessibleChildCount();
165 // -----------------------------------------------------------------------------
167 Reference
< XAccessible
> SAL_CALL
ToolbarMenuAcc::getAccessibleChild( sal_Int32 i
) throw (IndexOutOfBoundsException
, RuntimeException
)
169 const SolarMutexGuard aSolarGuard
;
172 return mpParent
->getAccessibleChild(i
);
175 // -----------------------------------------------------------------------------
177 Reference
< XAccessible
> SAL_CALL
ToolbarMenuAcc::getAccessibleParent() throw (RuntimeException
)
180 const SolarMutexGuard aSolarGuard
;
182 Reference
< XAccessible
> xRet
;
184 Window
* pParent
= mpParent
->mrMenu
.GetParent();
186 xRet
= pParent
->GetAccessible();
191 // -----------------------------------------------------------------------------
193 sal_Int32 SAL_CALL
ToolbarMenuAcc::getAccessibleIndexInParent() throw (RuntimeException
)
195 const SolarMutexGuard aSolarGuard
;
198 Window
* pParent
= mpParent
->mrMenu
.GetParent();
201 for( sal_uInt16 i
= 0, nCount
= pParent
->GetChildCount(); i
< nCount
; i
++ )
203 if( pParent
->GetChild( i
) == &mpParent
->mrMenu
)
211 // -----------------------------------------------------------------------------
213 sal_Int16 SAL_CALL
ToolbarMenuAcc::getAccessibleRole() throw (RuntimeException
)
216 return AccessibleRole::LIST
;
219 // -----------------------------------------------------------------------------
221 OUString SAL_CALL
ToolbarMenuAcc::getAccessibleDescription() throw (RuntimeException
)
224 return OUString( "ToolbarMenu" );
227 // -----------------------------------------------------------------------------
229 OUString SAL_CALL
ToolbarMenuAcc::getAccessibleName() throw (RuntimeException
)
232 const SolarMutexGuard aSolarGuard
;
236 aRet
= mpParent
->mrMenu
.GetAccessibleName();
240 Window
* pLabel
= mpParent
->mrMenu
.GetAccessibleRelationLabeledBy();
241 if( pLabel
&& pLabel
!= &mpParent
->mrMenu
)
242 aRet
= OutputDevice::GetNonMnemonicString( pLabel
->GetText() );
248 // -----------------------------------------------------------------------------
250 Reference
< XAccessibleRelationSet
> SAL_CALL
ToolbarMenuAcc::getAccessibleRelationSet() throw (RuntimeException
)
253 return Reference
< XAccessibleRelationSet
>();
256 // -----------------------------------------------------------------------------
258 Reference
< XAccessibleStateSet
> SAL_CALL
ToolbarMenuAcc::getAccessibleStateSet() throw (RuntimeException
)
261 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper();
264 pStateSet
->AddState (AccessibleStateType::ENABLED
);
265 pStateSet
->AddState (AccessibleStateType::SENSITIVE
);
266 pStateSet
->AddState (AccessibleStateType::SHOWING
);
267 pStateSet
->AddState (AccessibleStateType::VISIBLE
);
268 pStateSet
->AddState (AccessibleStateType::MANAGES_DESCENDANTS
);
269 pStateSet
->AddState (AccessibleStateType::FOCUSABLE
);
271 pStateSet
->AddState (AccessibleStateType::FOCUSED
);
276 // -----------------------------------------------------------------------------
278 Locale SAL_CALL
ToolbarMenuAcc::getLocale() throw (IllegalAccessibleComponentStateException
, RuntimeException
)
281 const SolarMutexGuard aSolarGuard
;
282 const OUString aEmptyStr
;
283 Reference
< XAccessible
> xParent( getAccessibleParent() );
284 Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
288 Reference
< XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
290 if( xParentContext
.is() )
291 aRet
= xParentContext
->getLocale ();
297 // -----------------------------------------------------------------------------
299 void SAL_CALL
ToolbarMenuAcc::addAccessibleEventListener( const Reference
< XAccessibleEventListener
>& rxListener
) throw (RuntimeException
)
302 ::osl::MutexGuard
aGuard(m_aMutex
);
304 if( rxListener
.is() )
306 EventListenerVector::const_iterator aIter
= mxEventListeners
.begin();
309 while( !bFound
&& ( aIter
!= mxEventListeners
.end() ) )
311 if( *aIter
== rxListener
)
318 mxEventListeners
.push_back( rxListener
);
322 // -----------------------------------------------------------------------------
324 void SAL_CALL
ToolbarMenuAcc::removeAccessibleEventListener( const Reference
< XAccessibleEventListener
>& rxListener
) throw (RuntimeException
)
327 ::osl::MutexGuard
aGuard(m_aMutex
);
329 if( rxListener
.is() )
331 EventListenerVector::iterator aIter
= std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
332 if (aIter
!= mxEventListeners
.end())
333 mxEventListeners
.erase(aIter
);
337 // -----------------------------------------------------------------------------
339 sal_Bool SAL_CALL
ToolbarMenuAcc::containsPoint( const awt::Point
& aPoint
) throw (RuntimeException
)
342 const awt::Rectangle
aRect( getBounds() );
343 const Point
aSize( aRect
.Width
, aRect
.Height
);
344 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
346 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
349 // -----------------------------------------------------------------------------
351 Reference
< XAccessible
> SAL_CALL
ToolbarMenuAcc::getAccessibleAtPoint( const awt::Point
& aPoint
) throw (RuntimeException
)
353 const SolarMutexGuard aSolarGuard
;
356 Reference
< XAccessible
> xRet
;
358 const Point
aVclPoint( aPoint
.X
, aPoint
.Y
);
360 const int nEntryCount
= mpParent
->maEntryVector
.size();
361 for( int nEntry
= 0; (nEntry
< nEntryCount
) && !xRet
.is(); nEntry
++ )
363 ToolbarMenuEntry
* pEntry
= mpParent
->maEntryVector
[nEntry
];
364 if( pEntry
&& pEntry
->maRect
.IsInside( aVclPoint
) )
366 if( pEntry
->mpControl
)
368 awt::Point
aChildPoint( aPoint
.X
- pEntry
->maRect
.Left(), aPoint
.Y
- pEntry
->maRect
.Top() );
369 Reference
< XAccessibleComponent
> xComp( pEntry
->GetAccessible(true), UNO_QUERY_THROW
);
370 xRet
= xComp
->getAccessibleAtPoint(aChildPoint
);
374 xRet
= Reference
< XAccessible
>( pEntry
->GetAccessible(true), UNO_QUERY
);
381 // -----------------------------------------------------------------------------
383 awt::Rectangle SAL_CALL
ToolbarMenuAcc::getBounds() throw (RuntimeException
)
386 const SolarMutexGuard aSolarGuard
;
387 const Point
aOutPos( mpParent
->mrMenu
.GetPosPixel() );
388 const Size
aOutSize( mpParent
->mrMenu
.GetOutputSizePixel() );
391 aRet
.X
= aOutPos
.X();
392 aRet
.Y
= aOutPos
.Y();
393 aRet
.Width
= aOutSize
.Width();
394 aRet
.Height
= aOutSize
.Height();
399 // -----------------------------------------------------------------------------
401 awt::Point SAL_CALL
ToolbarMenuAcc::getLocation() throw (RuntimeException
)
404 const SolarMutexGuard aSolarGuard
;
405 const Point
aOutPos( mpParent
->mrMenu
.GetPosPixel() );
406 return awt::Point( aOutPos
.X(), aOutPos
.Y() );
409 // -----------------------------------------------------------------------------
411 awt::Point SAL_CALL
ToolbarMenuAcc::getLocationOnScreen() throw (RuntimeException
)
414 const SolarMutexGuard aSolarGuard
;
415 const Point
aScreenPos( mpParent
->mrMenu
.OutputToAbsoluteScreenPixel( Point() ) );
416 return awt::Point( aScreenPos
.X(), aScreenPos
.Y() );
419 // -----------------------------------------------------------------------------
421 awt::Size SAL_CALL
ToolbarMenuAcc::getSize() throw (RuntimeException
)
424 const SolarMutexGuard aSolarGuard
;
425 const Size
aOutSize( mpParent
->mrMenu
.GetOutputSizePixel() );
426 return awt::Size( aOutSize
.Width(), aOutSize
.Height() );
429 // -----------------------------------------------------------------------------
431 void SAL_CALL
ToolbarMenuAcc::grabFocus() throw (RuntimeException
)
434 const SolarMutexGuard aSolarGuard
;
435 mpParent
->mrMenu
.GrabFocus();
438 // -----------------------------------------------------------------------------
440 Any SAL_CALL
ToolbarMenuAcc::getAccessibleKeyBinding() throw (RuntimeException
)
446 // -----------------------------------------------------------------------------
448 sal_Int32 SAL_CALL
ToolbarMenuAcc::getForeground() throw (RuntimeException
)
451 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor();
452 return static_cast<sal_Int32
>(nColor
);
455 // -----------------------------------------------------------------------------
457 sal_Int32 SAL_CALL
ToolbarMenuAcc::getBackground() throw (RuntimeException
)
460 sal_uInt32 nColor
= Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor();
461 return static_cast<sal_Int32
>(nColor
);
464 // -----------------------------------------------------------------------------
466 void SAL_CALL
ToolbarMenuAcc::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
468 const SolarMutexGuard aSolarGuard
;
471 mpParent
->selectAccessibleChild( nChildIndex
);
474 // -----------------------------------------------------------------------------
476 sal_Bool SAL_CALL
ToolbarMenuAcc::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
478 const SolarMutexGuard aSolarGuard
;
480 return mpParent
->isAccessibleChildSelected( nChildIndex
);
483 // -----------------------------------------------------------------------------
485 void SAL_CALL
ToolbarMenuAcc::clearAccessibleSelection() throw (RuntimeException
)
487 const SolarMutexGuard aSolarGuard
;
489 mpParent
->clearAccessibleSelection();
492 // -----------------------------------------------------------------------------
494 void SAL_CALL
ToolbarMenuAcc::selectAllAccessibleChildren() throw (RuntimeException
)
497 // unsupported due to single selection only
500 // -----------------------------------------------------------------------------
502 sal_Int32 SAL_CALL
ToolbarMenuAcc::getSelectedAccessibleChildCount() throw (RuntimeException
)
504 const SolarMutexGuard aSolarGuard
;
507 return mpParent
->mnHighlightedEntry
!= -1 ? 1 : 0;
510 // -----------------------------------------------------------------------------
512 Reference
< XAccessible
> SAL_CALL
ToolbarMenuAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
515 const SolarMutexGuard aSolarGuard
;
517 if( (mpParent
->mnHighlightedEntry
!= -1) && (nSelectedChildIndex
== 0) )
519 ToolbarMenuEntry
* pEntry
= mpParent
->maEntryVector
[ mpParent
->mnHighlightedEntry
];
522 if( pEntry
->mpControl
)
524 Reference
< XAccessibleSelection
> xSel( pEntry
->GetAccessible(true), UNO_QUERY_THROW
);
525 return xSel
->getSelectedAccessibleChild(0);
528 return Reference
< XAccessible
>( pEntry
->GetAccessible(true), UNO_QUERY
);
532 throw IndexOutOfBoundsException();
535 // -----------------------------------------------------------------------------
537 void SAL_CALL
ToolbarMenuAcc::deselectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
540 const SolarMutexGuard aSolarGuard
;
541 // Because of the single selection we can reset the whole selection when
542 // the specified child is currently selected.
543 if (isAccessibleChildSelected(nChildIndex
))
544 mpParent
->clearAccessibleSelection();
547 // -----------------------------------------------------------------------------
549 void SAL_CALL
ToolbarMenuAcc::disposing (void)
551 EventListenerVector aListenerListCopy
;
554 // Make a copy of the list and clear the original.
555 const SolarMutexGuard aSolarGuard
;
556 ::osl::MutexGuard
aGuard (m_aMutex
);
557 aListenerListCopy
= mxEventListeners
;
558 mxEventListeners
.clear();
560 // Reset the pointer to the parent. It has to be the one who has
561 // disposed us because he is dying.
565 // Inform all listeners that this objects is disposing.
566 EventListenerVector::const_iterator
aListenerIterator (aListenerListCopy
.begin());
567 EventObject
aEvent (static_cast<XAccessible
*>(this));
568 while(aListenerIterator
!= aListenerListCopy
.end())
572 (*aListenerIterator
)->disposing (aEvent
);
576 // Ignore exceptions.
583 void ToolbarMenuAcc::ThrowIfDisposed (void) throw (DisposedException
)
585 if(rBHelper
.bDisposed
|| rBHelper
.bInDispose
|| !mpParent
)
587 throw DisposedException ("object has been already disposed", static_cast<XWeak
*>(this));
591 // -----------------------
592 // - ToolbarMenuEntryAcc -
593 // -----------------------
595 ToolbarMenuEntryAcc::ToolbarMenuEntryAcc( ToolbarMenuEntry
* pParent
)
596 : ToolbarMenuEntryAccBase( m_aMutex
)
597 , mpParent( pParent
)
601 // -----------------------------------------------------------------------------
603 ToolbarMenuEntryAcc::~ToolbarMenuEntryAcc()
607 // -----------------------------------------------------------------------
609 void SAL_CALL
ToolbarMenuEntryAcc::disposing (void)
611 EventListenerVector aListenerListCopy
;
614 // Make a copy of the list and clear the original.
615 const SolarMutexGuard aSolarGuard
;
616 ::osl::MutexGuard
aGuard (m_aMutex
);
617 aListenerListCopy
= mxEventListeners
;
618 mxEventListeners
.clear();
620 // Reset the pointer to the parent. It has to be the one who has
621 // disposed us because he is dying.
625 // Inform all listeners that this objects is disposing.
626 EventListenerVector::const_iterator
aListenerIterator (aListenerListCopy
.begin());
627 EventObject
aEvent (static_cast<XAccessible
*>(this));
628 while(aListenerIterator
!= aListenerListCopy
.end())
632 (*aListenerIterator
)->disposing (aEvent
);
636 // Ignore exceptions.
642 // -----------------------------------------------------------------------------
644 Reference
< XAccessibleContext
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleContext() throw (RuntimeException
)
649 // -----------------------------------------------------------------------------
651 sal_Int32 SAL_CALL
ToolbarMenuEntryAcc::getAccessibleChildCount() throw (RuntimeException
)
656 // -----------------------------------------------------------------------------
658 Reference
< XAccessible
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleChild( sal_Int32
) throw (IndexOutOfBoundsException
, RuntimeException
)
660 throw IndexOutOfBoundsException();
663 // -----------------------------------------------------------------------------
665 Reference
< XAccessible
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleParent() throw (RuntimeException
)
667 const SolarMutexGuard aSolarGuard
;
668 Reference
< XAccessible
> xRet
;
671 xRet
= mpParent
->mrMenu
.GetAccessible();
676 // -----------------------------------------------------------------------------
678 sal_Int32 SAL_CALL
ToolbarMenuEntryAcc::getAccessibleIndexInParent() throw (RuntimeException
)
680 const SolarMutexGuard aSolarGuard
;
681 // The index defaults to -1 to indicate the child does not belong to its
683 sal_Int32 nIndexInParent
= -1;
687 Reference
< XAccessibleContext
> xParent( mpParent
->mrMenu
.GetAccessible(), UNO_QUERY
);
691 Reference
< XAccessible
> xThis( this );
693 const sal_Int32 nCount
= xParent
->getAccessibleChildCount();
694 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
696 if( xParent
->getAccessibleChild(nIndex
) == xThis
)
698 nIndexInParent
= nIndex
;
705 return nIndexInParent
;
708 // -----------------------------------------------------------------------------
710 sal_Int16 SAL_CALL
ToolbarMenuEntryAcc::getAccessibleRole() throw (RuntimeException
)
712 return AccessibleRole::LIST_ITEM
;
715 // -----------------------------------------------------------------------------
717 OUString SAL_CALL
ToolbarMenuEntryAcc::getAccessibleDescription() throw (RuntimeException
)
722 // -----------------------------------------------------------------------------
724 OUString SAL_CALL
ToolbarMenuEntryAcc::getAccessibleName() throw (RuntimeException
)
726 const SolarMutexGuard aSolarGuard
;
731 aRet
= mpParent
->maText
;
736 aRet
+= OUString::number( mpParent
->mnEntryId
);
743 // -----------------------------------------------------------------------------
745 Reference
< XAccessibleRelationSet
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleRelationSet() throw (RuntimeException
)
747 return Reference
< XAccessibleRelationSet
>();
750 // -----------------------------------------------------------------------------
752 Reference
< XAccessibleStateSet
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleStateSet() throw (RuntimeException
)
754 const SolarMutexGuard aSolarGuard
;
755 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
759 pStateSet
->AddState (AccessibleStateType::ENABLED
);
760 pStateSet
->AddState (AccessibleStateType::SENSITIVE
);
761 pStateSet
->AddState (AccessibleStateType::SHOWING
);
762 pStateSet
->AddState (AccessibleStateType::VISIBLE
);
763 pStateSet
->AddState (AccessibleStateType::TRANSIENT
);
764 if( mpParent
->mnEntryId
!= TITLE_ID
)
766 pStateSet
->AddState( AccessibleStateType::SELECTABLE
);
769 if( mpParent
->mrMenu
.getHighlightedEntryId() == mpParent
->mnEntryId
)
770 pStateSet
->AddState( AccessibleStateType::SELECTED
);
777 // -----------------------------------------------------------------------------
779 Locale SAL_CALL
ToolbarMenuEntryAcc::getLocale() throw (IllegalAccessibleComponentStateException
, RuntimeException
)
781 const OUString aEmptyStr
;
782 Locale
aRet( aEmptyStr
, aEmptyStr
, aEmptyStr
);
784 Reference
< XAccessible
> xParent( getAccessibleParent() );
787 Reference
< XAccessibleContext
> xParentContext( xParent
->getAccessibleContext() );
789 if( xParentContext
.is() )
790 aRet
= xParentContext
->getLocale();
796 // -----------------------------------------------------------------------------
798 void SAL_CALL
ToolbarMenuEntryAcc::addAccessibleEventListener( const Reference
< XAccessibleEventListener
>& rxListener
) throw (RuntimeException
)
800 const ::osl::MutexGuard
aGuard( maMutex
);
802 if( rxListener
.is() )
804 for (EventListenerVector::const_iterator
aIter( mxEventListeners
.begin() ), aEnd( mxEventListeners
.end() );
805 aIter
!= aEnd
; ++aIter
)
807 if( *aIter
== rxListener
)
810 // listener not found so add it
811 mxEventListeners
.push_back( rxListener
);
815 // -----------------------------------------------------------------------------
817 void SAL_CALL
ToolbarMenuEntryAcc::removeAccessibleEventListener( const Reference
< XAccessibleEventListener
>& rxListener
) throw (RuntimeException
)
819 const ::osl::MutexGuard
aGuard( maMutex
);
821 if( rxListener
.is() )
823 EventListenerVector::iterator aIter
= std::find(mxEventListeners
.begin(), mxEventListeners
.end(), rxListener
);
824 if (aIter
!= mxEventListeners
.end())
825 mxEventListeners
.erase(aIter
);
829 // -----------------------------------------------------------------------------
831 sal_Bool SAL_CALL
ToolbarMenuEntryAcc::containsPoint( const awt::Point
& aPoint
) throw (RuntimeException
)
833 const awt::Rectangle
aRect( getBounds() );
834 const Point
aSize( aRect
.Width
, aRect
.Height
);
835 const Point aNullPoint
, aTestPoint( aPoint
.X
, aPoint
.Y
);
837 return Rectangle( aNullPoint
, aSize
).IsInside( aTestPoint
);
840 // -----------------------------------------------------------------------------
842 Reference
< XAccessible
> SAL_CALL
ToolbarMenuEntryAcc::getAccessibleAtPoint( const awt::Point
& ) throw (RuntimeException
)
844 Reference
< XAccessible
> xRet
;
848 // -----------------------------------------------------------------------------
850 awt::Rectangle SAL_CALL
ToolbarMenuEntryAcc::getBounds() throw (RuntimeException
)
852 const SolarMutexGuard aSolarGuard
;
857 Rectangle
aRect( mpParent
->maRect
);
859 Rectangle
aParentRect( aOrigin
, mpParent
->mrMenu
.GetOutputSizePixel() );
861 aRect
.Intersection( aParentRect
);
863 aRet
.X
= aRect
.Left();
864 aRet
.Y
= aRect
.Top();
865 aRet
.Width
= aRect
.GetWidth();
866 aRet
.Height
= aRect
.GetHeight();
872 // -----------------------------------------------------------------------------
874 awt::Point SAL_CALL
ToolbarMenuEntryAcc::getLocation() throw (RuntimeException
)
876 const awt::Rectangle
aRect( getBounds() );
877 return awt::Point( aRect
.X
, aRect
.Y
);
880 // -----------------------------------------------------------------------------
882 awt::Point SAL_CALL
ToolbarMenuEntryAcc::getLocationOnScreen() throw (RuntimeException
)
884 const SolarMutexGuard aSolarGuard
;
889 const Point
aScreenPos( mpParent
->mrMenu
.OutputToAbsoluteScreenPixel( mpParent
->maRect
.TopLeft() ) );
891 aRet
.X
= aScreenPos
.X();
892 aRet
.Y
= aScreenPos
.Y();
898 // -----------------------------------------------------------------------------
900 awt::Size SAL_CALL
ToolbarMenuEntryAcc::getSize() throw (RuntimeException
)
902 const awt::Rectangle
aRect( getBounds() );
905 aRet
.Width
= aRect
.Width
;
906 aRet
.Height
= aRect
.Height
;
911 // -----------------------------------------------------------------------------
913 void SAL_CALL
ToolbarMenuEntryAcc::grabFocus() throw (RuntimeException
)
918 // -----------------------------------------------------------------------------
920 Any SAL_CALL
ToolbarMenuEntryAcc::getAccessibleKeyBinding() throw (RuntimeException
)
925 // -----------------------------------------------------------------------------
927 sal_Int32 SAL_CALL
ToolbarMenuEntryAcc::getForeground( ) throw (RuntimeException
)
929 return static_cast<sal_Int32
>(Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor());
932 // -----------------------------------------------------------------------------
934 sal_Int32 SAL_CALL
ToolbarMenuEntryAcc::getBackground( ) throw (RuntimeException
)
936 return static_cast<sal_Int32
>(Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor());
941 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */