Bump version to 5.0-14
[LibreOffice.git] / svtools / source / control / toolbarmenuacc.cxx
blob7e32cbd0848a847056b94ed619b85e2cd8327395
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <vcl/settings.hxx>
30 #include <svtools/toolbarmenu.hxx>
32 #include "toolbarmenuimp.hxx"
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::accessibility;
40 namespace svtools {
43 // - ToolbarMenuAcc -
46 ToolbarMenuAcc::ToolbarMenuAcc( ToolbarMenu_Impl& rParent )
47 : ToolbarMenuAccComponentBase(m_aMutex)
48 , mpParent( &rParent )
49 , mbIsFocused(false)
51 mpParent->mrMenu.AddEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
56 ToolbarMenuAcc::~ToolbarMenuAcc()
58 if( mpParent )
59 mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
64 IMPL_LINK( ToolbarMenuAcc, WindowEventListener, VclSimpleEvent*, pEvent )
66 DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
68 /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper
69 * might have been destroyed by the previous VCLEventListener (if no AT tool
70 * is running), e.g. sub-toolbars in impress.
72 if ( mpParent && pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE) )
74 DBG_ASSERT( static_cast<VclWindowEvent*>(pEvent)->GetWindow(), "Window???" );
75 if( !static_cast<VclWindowEvent*>(pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
77 ProcessWindowEvent( *static_cast<VclWindowEvent*>(pEvent) );
80 return 0;
85 void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
87 switch ( rVclWindowEvent.GetId() )
89 case VCLEVENT_OBJECT_DYING:
91 mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
92 mpParent = 0;
94 break;
96 case VCLEVENT_WINDOW_GETFOCUS:
98 if( !mbIsFocused )
100 mpParent->notifyHighlightedEntry();
101 mbIsFocused = true;
104 break;
105 case VCLEVENT_WINDOW_LOSEFOCUS:
107 if( mbIsFocused )
109 mbIsFocused = false;
112 break;
113 default:
116 break;
122 void ToolbarMenuAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue )
124 if( nEventId )
126 EventListenerVector aTmpListeners( mxEventListeners );
127 AccessibleEventObject aEvtObject;
129 aEvtObject.EventId = nEventId;
130 aEvtObject.Source = static_cast<XWeak*>(this);
131 aEvtObject.NewValue = rNewValue;
132 aEvtObject.OldValue = rOldValue;
134 for (EventListenerVector::const_iterator aIter( aTmpListeners.begin() ), aEnd( aTmpListeners.end() );
135 aIter != aEnd ; ++aIter)
139 (*aIter)->notifyEvent( aEvtObject );
141 catch( Exception& )
150 Reference< XAccessibleContext > SAL_CALL ToolbarMenuAcc::getAccessibleContext() throw (RuntimeException, std::exception)
152 ThrowIfDisposed();
153 return this;
158 sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleChildCount() throw (RuntimeException, std::exception)
160 const SolarMutexGuard aSolarGuard;
161 ThrowIfDisposed();
163 return mpParent->getAccessibleChildCount();
168 Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
170 const SolarMutexGuard aSolarGuard;
171 ThrowIfDisposed();
173 return mpParent->getAccessibleChild(i);
178 Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleParent() throw (RuntimeException, std::exception)
180 ThrowIfDisposed();
181 const SolarMutexGuard aSolarGuard;
183 Reference< XAccessible > xRet;
185 vcl::Window* pParent = mpParent->mrMenu.GetParent();
186 if( pParent )
187 xRet = pParent->GetAccessible();
189 return xRet;
194 sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleIndexInParent() throw (RuntimeException, std::exception)
196 const SolarMutexGuard aSolarGuard;
197 ThrowIfDisposed();
199 vcl::Window* pParent = mpParent->mrMenu.GetParent();
200 if( pParent )
202 for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); i < nCount ; i++ )
204 if( pParent->GetChild( i ) == &mpParent->mrMenu )
205 return i;
209 return 0;
214 sal_Int16 SAL_CALL ToolbarMenuAcc::getAccessibleRole() throw (RuntimeException, std::exception)
216 ThrowIfDisposed();
217 return AccessibleRole::LIST;
222 OUString SAL_CALL ToolbarMenuAcc::getAccessibleDescription() throw (RuntimeException, std::exception)
224 ThrowIfDisposed();
225 return OUString( "ToolbarMenu" );
230 OUString SAL_CALL ToolbarMenuAcc::getAccessibleName() throw (RuntimeException, std::exception)
232 ThrowIfDisposed();
233 const SolarMutexGuard aSolarGuard;
234 OUString aRet;
236 if( mpParent )
237 aRet = mpParent->mrMenu.GetAccessibleName();
239 if( aRet.isEmpty() )
241 vcl::Window* pLabel = mpParent->mrMenu.GetAccessibleRelationLabeledBy();
242 if( pLabel && pLabel != &mpParent->mrMenu )
243 aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
246 return aRet;
251 Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuAcc::getAccessibleRelationSet() throw (RuntimeException, std::exception)
253 ThrowIfDisposed();
254 return Reference< XAccessibleRelationSet >();
259 Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuAcc::getAccessibleStateSet() throw (RuntimeException, std::exception)
261 ThrowIfDisposed();
262 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
264 // Set some states.
265 pStateSet->AddState (AccessibleStateType::ENABLED);
266 pStateSet->AddState (AccessibleStateType::SENSITIVE);
267 pStateSet->AddState (AccessibleStateType::SHOWING);
268 pStateSet->AddState (AccessibleStateType::VISIBLE);
269 pStateSet->AddState (AccessibleStateType::MANAGES_DESCENDANTS);
270 pStateSet->AddState (AccessibleStateType::FOCUSABLE);
271 if (mbIsFocused)
272 pStateSet->AddState (AccessibleStateType::FOCUSED);
274 return pStateSet;
279 Locale SAL_CALL ToolbarMenuAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
281 ThrowIfDisposed();
282 const SolarMutexGuard aSolarGuard;
283 const OUString aEmptyStr;
284 Reference< XAccessible > xParent( getAccessibleParent() );
285 Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
287 if( xParent.is() )
289 Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
291 if( xParentContext.is() )
292 aRet = xParentContext->getLocale ();
295 return aRet;
300 void SAL_CALL ToolbarMenuAcc::addAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException, std::exception)
302 ThrowIfDisposed();
303 ::osl::MutexGuard aGuard(m_aMutex);
305 if( rxListener.is() )
307 EventListenerVector::const_iterator aIter = mxEventListeners.begin();
308 bool bFound = false;
310 while( !bFound && ( aIter != mxEventListeners.end() ) )
312 if( *aIter == rxListener )
313 bFound = true;
314 else
315 ++aIter;
318 if (!bFound)
319 mxEventListeners.push_back( rxListener );
325 void SAL_CALL ToolbarMenuAcc::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException, std::exception)
327 ThrowIfDisposed();
328 ::osl::MutexGuard aGuard(m_aMutex);
330 if( rxListener.is() )
332 EventListenerVector::iterator aIter = std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
333 if (aIter != mxEventListeners.end())
334 mxEventListeners.erase(aIter);
340 sal_Bool SAL_CALL ToolbarMenuAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
342 ThrowIfDisposed();
343 const awt::Rectangle aRect( getBounds() );
344 const Point aSize( aRect.Width, aRect.Height );
345 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
347 return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
352 Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleAtPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
354 const SolarMutexGuard aSolarGuard;
355 ThrowIfDisposed();
357 Reference< XAccessible > xRet;
359 const Point aVclPoint( aPoint.X, aPoint.Y );
361 const int nEntryCount = mpParent->maEntryVector.size();
362 for( int nEntry = 0; (nEntry < nEntryCount) && !xRet.is(); nEntry++ )
364 ToolbarMenuEntry* pEntry = mpParent->maEntryVector[nEntry];
365 if( pEntry && pEntry->maRect.IsInside( aVclPoint ) )
367 if( pEntry->mpControl )
369 awt::Point aChildPoint( aPoint.X - pEntry->maRect.Left(), aPoint.Y - pEntry->maRect.Top() );
370 Reference< XAccessibleComponent > xComp( pEntry->GetAccessible(true), UNO_QUERY_THROW );
371 xRet = xComp->getAccessibleAtPoint(aChildPoint);
373 else
375 xRet = Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
379 return xRet;
384 awt::Rectangle SAL_CALL ToolbarMenuAcc::getBounds() throw (RuntimeException, std::exception)
386 ThrowIfDisposed();
387 const SolarMutexGuard aSolarGuard;
388 const Point aOutPos( mpParent->mrMenu.GetPosPixel() );
389 const Size aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
390 awt::Rectangle aRet;
392 aRet.X = aOutPos.X();
393 aRet.Y = aOutPos.Y();
394 aRet.Width = aOutSize.Width();
395 aRet.Height = aOutSize.Height();
397 return aRet;
402 awt::Point SAL_CALL ToolbarMenuAcc::getLocation() throw (RuntimeException, std::exception)
404 ThrowIfDisposed();
405 const SolarMutexGuard aSolarGuard;
406 const Point aOutPos( mpParent->mrMenu.GetPosPixel() );
407 return awt::Point( aOutPos.X(), aOutPos.Y() );
412 awt::Point SAL_CALL ToolbarMenuAcc::getLocationOnScreen() throw (RuntimeException, std::exception)
414 ThrowIfDisposed();
415 const SolarMutexGuard aSolarGuard;
416 const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( Point() ) );
417 return awt::Point( aScreenPos.X(), aScreenPos.Y() );
422 awt::Size SAL_CALL ToolbarMenuAcc::getSize() throw (RuntimeException, std::exception)
424 ThrowIfDisposed();
425 const SolarMutexGuard aSolarGuard;
426 const Size aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
427 return awt::Size( aOutSize.Width(), aOutSize.Height() );
430 void SAL_CALL ToolbarMenuAcc::grabFocus() throw (RuntimeException, std::exception)
432 ThrowIfDisposed();
433 const SolarMutexGuard aSolarGuard;
434 mpParent->mrMenu.GrabFocus();
437 sal_Int32 SAL_CALL ToolbarMenuAcc::getForeground() throw (RuntimeException, std::exception)
439 ThrowIfDisposed();
440 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor();
441 return static_cast<sal_Int32>(nColor);
444 sal_Int32 SAL_CALL ToolbarMenuAcc::getBackground() throw (RuntimeException, std::exception)
446 ThrowIfDisposed();
447 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor();
448 return static_cast<sal_Int32>(nColor);
451 void SAL_CALL ToolbarMenuAcc::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
453 const SolarMutexGuard aSolarGuard;
454 ThrowIfDisposed();
456 mpParent->selectAccessibleChild( nChildIndex );
459 sal_Bool SAL_CALL ToolbarMenuAcc::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
461 const SolarMutexGuard aSolarGuard;
462 ThrowIfDisposed();
463 return mpParent->isAccessibleChildSelected( nChildIndex );
468 void SAL_CALL ToolbarMenuAcc::clearAccessibleSelection() throw (RuntimeException, std::exception)
470 const SolarMutexGuard aSolarGuard;
471 ThrowIfDisposed();
472 mpParent->clearAccessibleSelection();
477 void SAL_CALL ToolbarMenuAcc::selectAllAccessibleChildren() throw (RuntimeException, std::exception)
479 ThrowIfDisposed();
480 // unsupported due to single selection only
485 sal_Int32 SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChildCount() throw (RuntimeException, std::exception)
487 const SolarMutexGuard aSolarGuard;
488 ThrowIfDisposed();
490 return mpParent->mnHighlightedEntry != -1 ? 1 : 0;
495 Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
497 ThrowIfDisposed();
498 const SolarMutexGuard aSolarGuard;
500 if( (mpParent->mnHighlightedEntry != -1) && (nSelectedChildIndex == 0) )
502 ToolbarMenuEntry* pEntry = mpParent->maEntryVector[ mpParent->mnHighlightedEntry ];
503 if( pEntry )
505 if( pEntry->mpControl )
507 Reference< XAccessibleSelection > xSel( pEntry->GetAccessible(true), UNO_QUERY_THROW );
508 return xSel->getSelectedAccessibleChild(0);
510 else
511 return Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
515 throw IndexOutOfBoundsException();
520 void SAL_CALL ToolbarMenuAcc::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
522 ThrowIfDisposed();
523 const SolarMutexGuard aSolarGuard;
524 // Because of the single selection we can reset the whole selection when
525 // the specified child is currently selected.
526 if (isAccessibleChildSelected(nChildIndex))
527 mpParent->clearAccessibleSelection();
532 void SAL_CALL ToolbarMenuAcc::disposing()
534 EventListenerVector aListenerListCopy;
537 // Make a copy of the list and clear the original.
538 const SolarMutexGuard aSolarGuard;
539 ::osl::MutexGuard aGuard (m_aMutex);
540 aListenerListCopy = mxEventListeners;
541 mxEventListeners.clear();
543 // Reset the pointer to the parent. It has to be the one who has
544 // disposed us because he is dying.
545 mpParent = NULL;
548 // Inform all listeners that this objects is disposing.
549 EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
550 EventObject aEvent (static_cast<XAccessible*>(this));
551 while(aListenerIterator != aListenerListCopy.end())
555 (*aListenerIterator)->disposing (aEvent);
557 catch( Exception& )
559 // Ignore exceptions.
562 ++aListenerIterator;
566 void ToolbarMenuAcc::ThrowIfDisposed() throw (DisposedException)
568 if(rBHelper.bDisposed || rBHelper.bInDispose || !mpParent)
570 throw DisposedException ("object has been already disposed", static_cast<XWeak*>(this));
575 // - ToolbarMenuEntryAcc -
578 ToolbarMenuEntryAcc::ToolbarMenuEntryAcc( ToolbarMenuEntry* pParent )
579 : ToolbarMenuEntryAccBase( m_aMutex )
580 , mpParent( pParent )
586 ToolbarMenuEntryAcc::~ToolbarMenuEntryAcc()
592 void SAL_CALL ToolbarMenuEntryAcc::disposing()
594 EventListenerVector aListenerListCopy;
597 // Make a copy of the list and clear the original.
598 const SolarMutexGuard aSolarGuard;
599 ::osl::MutexGuard aGuard (m_aMutex);
600 aListenerListCopy = mxEventListeners;
601 mxEventListeners.clear();
603 // Reset the pointer to the parent. It has to be the one who has
604 // disposed us because he is dying.
605 mpParent = NULL;
608 // Inform all listeners that this objects is disposing.
609 EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
610 EventObject aEvent (static_cast<XAccessible*>(this));
611 while(aListenerIterator != aListenerListCopy.end())
615 (*aListenerIterator)->disposing (aEvent);
617 catch( Exception& )
619 // Ignore exceptions.
622 ++aListenerIterator;
627 Reference< XAccessibleContext > SAL_CALL ToolbarMenuEntryAcc::getAccessibleContext() throw (RuntimeException, std::exception)
629 return this;
634 sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleChildCount() throw (RuntimeException, std::exception)
636 return 0;
641 Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
643 throw IndexOutOfBoundsException();
648 Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleParent() throw (RuntimeException, std::exception)
650 const SolarMutexGuard aSolarGuard;
651 Reference< XAccessible > xRet;
653 if( mpParent )
654 xRet = mpParent->mrMenu.GetAccessible();
656 return xRet;
661 sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleIndexInParent() throw (RuntimeException, std::exception)
663 const SolarMutexGuard aSolarGuard;
664 // The index defaults to -1 to indicate the child does not belong to its
665 // parent.
666 sal_Int32 nIndexInParent = -1;
668 if( mpParent )
670 Reference< XAccessibleContext > xParent( mpParent->mrMenu.GetAccessible(), UNO_QUERY );
672 if( xParent.is() )
674 Reference< XAccessible > xThis( this );
676 const sal_Int32 nCount = xParent->getAccessibleChildCount();
677 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
679 if( xParent->getAccessibleChild(nIndex) == xThis )
681 nIndexInParent = nIndex;
682 break;
688 return nIndexInParent;
693 sal_Int16 SAL_CALL ToolbarMenuEntryAcc::getAccessibleRole() throw (RuntimeException, std::exception)
695 return AccessibleRole::LIST_ITEM;
700 OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleDescription() throw (RuntimeException, std::exception)
702 return OUString();
707 OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleName() throw (RuntimeException, std::exception)
709 const SolarMutexGuard aSolarGuard;
710 OUString aRet;
712 if( mpParent )
714 aRet = mpParent->maText;
716 if( aRet.isEmpty() )
718 aRet = "Item ";
719 aRet += OUString::number( mpParent->mnEntryId );
723 return aRet;
728 Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleRelationSet() throw (RuntimeException, std::exception)
730 return Reference< XAccessibleRelationSet >();
735 Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleStateSet() throw (RuntimeException, std::exception)
737 const SolarMutexGuard aSolarGuard;
738 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
740 if( mpParent )
742 pStateSet->AddState (AccessibleStateType::ENABLED);
743 pStateSet->AddState (AccessibleStateType::SENSITIVE);
744 pStateSet->AddState (AccessibleStateType::SHOWING);
745 pStateSet->AddState (AccessibleStateType::VISIBLE);
746 pStateSet->AddState (AccessibleStateType::TRANSIENT);
747 if( mpParent->mnEntryId != TITLE_ID )
749 pStateSet->AddState( AccessibleStateType::SELECTABLE );
751 // SELECTED
752 if( mpParent->mrMenu.getHighlightedEntryId() == mpParent->mnEntryId )
753 pStateSet->AddState( AccessibleStateType::SELECTED );
757 return pStateSet;
762 Locale SAL_CALL ToolbarMenuEntryAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
764 const OUString aEmptyStr;
765 Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
767 Reference< XAccessible > xParent( getAccessibleParent() );
768 if( xParent.is() )
770 Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
772 if( xParentContext.is() )
773 aRet = xParentContext->getLocale();
776 return aRet;
781 void SAL_CALL ToolbarMenuEntryAcc::addAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException, std::exception)
783 const ::osl::MutexGuard aGuard( maMutex );
785 if( rxListener.is() )
787 for (EventListenerVector::const_iterator aIter( mxEventListeners.begin() ), aEnd( mxEventListeners.end() );
788 aIter != aEnd; ++aIter )
790 if( *aIter == rxListener )
791 return;
793 // listener not found so add it
794 mxEventListeners.push_back( rxListener );
800 void SAL_CALL ToolbarMenuEntryAcc::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException, std::exception)
802 const ::osl::MutexGuard aGuard( maMutex );
804 if( rxListener.is() )
806 EventListenerVector::iterator aIter = std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
807 if (aIter != mxEventListeners.end())
808 mxEventListeners.erase(aIter);
814 sal_Bool SAL_CALL ToolbarMenuEntryAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException, std::exception)
816 const awt::Rectangle aRect( getBounds() );
817 const Point aSize( aRect.Width, aRect.Height );
818 const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
820 return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
825 Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException, std::exception)
827 Reference< XAccessible > xRet;
828 return xRet;
833 awt::Rectangle SAL_CALL ToolbarMenuEntryAcc::getBounds() throw (RuntimeException, std::exception)
835 const SolarMutexGuard aSolarGuard;
836 awt::Rectangle aRet;
838 if( mpParent )
840 Rectangle aRect( mpParent->maRect );
841 Point aOrigin;
842 Rectangle aParentRect( aOrigin, mpParent->mrMenu.GetOutputSizePixel() );
844 aRect.Intersection( aParentRect );
846 aRet.X = aRect.Left();
847 aRet.Y = aRect.Top();
848 aRet.Width = aRect.GetWidth();
849 aRet.Height = aRect.GetHeight();
852 return aRet;
857 awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocation() throw (RuntimeException, std::exception)
859 const awt::Rectangle aRect( getBounds() );
860 return awt::Point( aRect.X, aRect.Y );
865 awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocationOnScreen() throw (RuntimeException, std::exception)
867 const SolarMutexGuard aSolarGuard;
868 awt::Point aRet;
870 if( mpParent )
872 const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( mpParent->maRect.TopLeft() ) );
874 aRet.X = aScreenPos.X();
875 aRet.Y = aScreenPos.Y();
878 return aRet;
883 awt::Size SAL_CALL ToolbarMenuEntryAcc::getSize() throw (RuntimeException, std::exception)
885 const awt::Rectangle aRect( getBounds() );
886 awt::Size aRet;
888 aRet.Width = aRect.Width;
889 aRet.Height = aRect.Height;
891 return aRet;
894 void SAL_CALL ToolbarMenuEntryAcc::grabFocus() throw (RuntimeException, std::exception)
896 // nothing to do
899 sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getForeground( ) throw (RuntimeException, std::exception)
901 return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor());
904 sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getBackground( ) throw (RuntimeException, std::exception)
906 return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor());
911 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */