xref: /AOO41X/main/svtools/source/control/toolbarmenuacc.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <vcl/svapp.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "svtools/toolbarmenu.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "toolbarmenuimp.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using ::rtl::OUString;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace ::com::sun::star;
46*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
47*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
48*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir namespace svtools {
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir // ------------------
53*cdf0e10cSrcweir // - ToolbarMenuAcc -
54*cdf0e10cSrcweir // ------------------
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir ToolbarMenuAcc::ToolbarMenuAcc( ToolbarMenu_Impl& rParent )
57*cdf0e10cSrcweir : ToolbarMenuAccComponentBase(m_aMutex)
58*cdf0e10cSrcweir , mpParent( &rParent )
59*cdf0e10cSrcweir , mbIsFocused(false)
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	mpParent->mrMenu.AddEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir // -----------------------------------------------------------------------------
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir ToolbarMenuAcc::~ToolbarMenuAcc()
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	if( mpParent )
69*cdf0e10cSrcweir 		mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
70*cdf0e10cSrcweir }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // -----------------------------------------------------------------------
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir IMPL_LINK( ToolbarMenuAcc, WindowEventListener, VclSimpleEvent*, pEvent )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper
79*cdf0e10cSrcweir      * might have been destroyed by the previous VCLEventListener (if no AT tool
80*cdf0e10cSrcweir      * is running), e.g. sub-toolbars in impress.
81*cdf0e10cSrcweir      */
82*cdf0e10cSrcweir 	if ( mpParent && pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE) )
83*cdf0e10cSrcweir 	{
84*cdf0e10cSrcweir 		DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" );
85*cdf0e10cSrcweir         if( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
86*cdf0e10cSrcweir 		{
87*cdf0e10cSrcweir 		    ProcessWindowEvent( *(VclWindowEvent*)pEvent );
88*cdf0e10cSrcweir 		}
89*cdf0e10cSrcweir 	}
90*cdf0e10cSrcweir 	return 0;
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir // -----------------------------------------------------------------------
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	Any aOldValue, aNewValue;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	switch ( rVclWindowEvent.GetId() )
100*cdf0e10cSrcweir 	{
101*cdf0e10cSrcweir         case VCLEVENT_OBJECT_DYING:
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir 		    mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
104*cdf0e10cSrcweir 	        mpParent = 0;
105*cdf0e10cSrcweir         }
106*cdf0e10cSrcweir         break;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 		case VCLEVENT_WINDOW_GETFOCUS:
109*cdf0e10cSrcweir 		{
110*cdf0e10cSrcweir 			if( !mbIsFocused )
111*cdf0e10cSrcweir 			{
112*cdf0e10cSrcweir 				mpParent->notifyHighlightedEntry();
113*cdf0e10cSrcweir 				mbIsFocused = true;
114*cdf0e10cSrcweir 			}
115*cdf0e10cSrcweir 		}
116*cdf0e10cSrcweir 		break;
117*cdf0e10cSrcweir 		case VCLEVENT_WINDOW_LOSEFOCUS:
118*cdf0e10cSrcweir 		{
119*cdf0e10cSrcweir 			if( mbIsFocused )
120*cdf0e10cSrcweir 			{
121*cdf0e10cSrcweir 				mbIsFocused = false;
122*cdf0e10cSrcweir 			}
123*cdf0e10cSrcweir 		}
124*cdf0e10cSrcweir 		break;
125*cdf0e10cSrcweir 		default:
126*cdf0e10cSrcweir 		{
127*cdf0e10cSrcweir 		}
128*cdf0e10cSrcweir 		break;
129*cdf0e10cSrcweir 	}
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir // -----------------------------------------------------------------------
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir void ToolbarMenuAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue )
135*cdf0e10cSrcweir {
136*cdf0e10cSrcweir     if( nEventId )
137*cdf0e10cSrcweir     {
138*cdf0e10cSrcweir         EventListenerVector                  aTmpListeners( mxEventListeners );
139*cdf0e10cSrcweir         EventListenerVector::const_iterator  aIter( aTmpListeners.begin() );
140*cdf0e10cSrcweir         AccessibleEventObject aEvtObject;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         aEvtObject.EventId = nEventId;
143*cdf0e10cSrcweir         aEvtObject.Source = static_cast<XWeak*>(this);
144*cdf0e10cSrcweir         aEvtObject.NewValue = rNewValue;
145*cdf0e10cSrcweir 	    aEvtObject.OldValue = rOldValue;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		while( aIter != aTmpListeners.end() )
148*cdf0e10cSrcweir         {
149*cdf0e10cSrcweir 			try
150*cdf0e10cSrcweir 			{
151*cdf0e10cSrcweir 				(*aIter)->notifyEvent( aEvtObject );
152*cdf0e10cSrcweir 			}
153*cdf0e10cSrcweir 			catch( Exception& )
154*cdf0e10cSrcweir 			{
155*cdf0e10cSrcweir 			}
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir             aIter++;
158*cdf0e10cSrcweir         }
159*cdf0e10cSrcweir     }
160*cdf0e10cSrcweir }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir // -----------------------------------------------------------------------------
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL ToolbarMenuAcc::getAccessibleContext() throw (RuntimeException)
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     ThrowIfDisposed();
167*cdf0e10cSrcweir     return this;
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir // -----------------------------------------------------------------------------
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleChildCount() throw (RuntimeException)
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
175*cdf0e10cSrcweir     ThrowIfDisposed();
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     return mpParent->getAccessibleChildCount();
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // -----------------------------------------------------------------------------
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
185*cdf0e10cSrcweir     ThrowIfDisposed();
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	return mpParent->getAccessibleChild(i);
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir // -----------------------------------------------------------------------------
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleParent() throw (RuntimeException)
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     ThrowIfDisposed();
195*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     Window* pParent = mpParent->mrMenu.GetParent();
200*cdf0e10cSrcweir     if( pParent )
201*cdf0e10cSrcweir         xRet = pParent->GetAccessible();
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     return xRet;
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir // -----------------------------------------------------------------------------
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuAcc::getAccessibleIndexInParent() throw (RuntimeException)
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
211*cdf0e10cSrcweir     ThrowIfDisposed();
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	Window* pParent = mpParent->mrMenu.GetParent();
214*cdf0e10cSrcweir     if( pParent )
215*cdf0e10cSrcweir     {
216*cdf0e10cSrcweir         for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); i < nCount ; i++ )
217*cdf0e10cSrcweir         {
218*cdf0e10cSrcweir             if( pParent->GetChild( i ) == &mpParent->mrMenu )
219*cdf0e10cSrcweir 				return i;
220*cdf0e10cSrcweir         }
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     return 0;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir // -----------------------------------------------------------------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir sal_Int16 SAL_CALL ToolbarMenuAcc::getAccessibleRole() throw (RuntimeException)
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     ThrowIfDisposed();
231*cdf0e10cSrcweir     return AccessibleRole::LIST;
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir // -----------------------------------------------------------------------------
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir OUString SAL_CALL ToolbarMenuAcc::getAccessibleDescription() throw (RuntimeException)
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir     ThrowIfDisposed();
239*cdf0e10cSrcweir     return OUString( RTL_CONSTASCII_USTRINGPARAM( "ToolbarMenu" ) );
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir // -----------------------------------------------------------------------------
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir OUString SAL_CALL ToolbarMenuAcc::getAccessibleName() throw (RuntimeException)
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir     ThrowIfDisposed();
247*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
248*cdf0e10cSrcweir     OUString aRet;
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     if( mpParent )
251*cdf0e10cSrcweir 		aRet = mpParent->mrMenu.GetAccessibleName();
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     if( !aRet.getLength() )
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         Window* pLabel = mpParent->mrMenu.GetAccessibleRelationLabeledBy();
256*cdf0e10cSrcweir         if( pLabel && pLabel != &mpParent->mrMenu )
257*cdf0e10cSrcweir 			aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
258*cdf0e10cSrcweir     }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     return aRet;
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir // -----------------------------------------------------------------------------
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuAcc::getAccessibleRelationSet() throw (RuntimeException)
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir     ThrowIfDisposed();
268*cdf0e10cSrcweir     return Reference< XAccessibleRelationSet >();
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir // -----------------------------------------------------------------------------
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuAcc::getAccessibleStateSet() throw (RuntimeException)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     ThrowIfDisposed();
276*cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     // Set some states.
279*cdf0e10cSrcweir     pStateSet->AddState (AccessibleStateType::ENABLED);
280*cdf0e10cSrcweir     pStateSet->AddState (AccessibleStateType::SENSITIVE);
281*cdf0e10cSrcweir     pStateSet->AddState (AccessibleStateType::SHOWING);
282*cdf0e10cSrcweir     pStateSet->AddState (AccessibleStateType::VISIBLE);
283*cdf0e10cSrcweir 	pStateSet->AddState (AccessibleStateType::MANAGES_DESCENDANTS);
284*cdf0e10cSrcweir     pStateSet->AddState (AccessibleStateType::FOCUSABLE);
285*cdf0e10cSrcweir     if (mbIsFocused)
286*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::FOCUSED);
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir     return pStateSet;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir // -----------------------------------------------------------------------------
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir Locale SAL_CALL ToolbarMenuAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException)
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     ThrowIfDisposed();
296*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
297*cdf0e10cSrcweir     const ::rtl::OUString aEmptyStr;
298*cdf0e10cSrcweir     Reference< XAccessible > xParent( getAccessibleParent() );
299*cdf0e10cSrcweir     Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     if( xParent.is() )
302*cdf0e10cSrcweir     {
303*cdf0e10cSrcweir         Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir         if( xParentContext.is() )
306*cdf0e10cSrcweir             aRet = xParentContext->getLocale ();
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     return aRet;
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir // -----------------------------------------------------------------------------
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::addEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir     ThrowIfDisposed();
317*cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 	if( rxListener.is() )
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir        	EventListenerVector::const_iterator aIter = mxEventListeners.begin();
322*cdf0e10cSrcweir 		bool bFound = false;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
325*cdf0e10cSrcweir         {
326*cdf0e10cSrcweir 			if( *aIter == rxListener )
327*cdf0e10cSrcweir                 bFound = true;
328*cdf0e10cSrcweir             else
329*cdf0e10cSrcweir                 aIter++;
330*cdf0e10cSrcweir         }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 		if (!bFound)
333*cdf0e10cSrcweir             mxEventListeners.push_back( rxListener );
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir // -----------------------------------------------------------------------------
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::removeEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir     ThrowIfDisposed();
342*cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	if( rxListener.is() )
345*cdf0e10cSrcweir     {
346*cdf0e10cSrcweir        	EventListenerVector::iterator aIter = mxEventListeners.begin();
347*cdf0e10cSrcweir 		bool bFound = false;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
350*cdf0e10cSrcweir         {
351*cdf0e10cSrcweir 			if( *aIter == rxListener )
352*cdf0e10cSrcweir             {
353*cdf0e10cSrcweir                 mxEventListeners.erase( aIter );
354*cdf0e10cSrcweir                 bFound = true;
355*cdf0e10cSrcweir             }
356*cdf0e10cSrcweir             else
357*cdf0e10cSrcweir                 aIter++;
358*cdf0e10cSrcweir         }
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir // -----------------------------------------------------------------------------
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir sal_Bool SAL_CALL ToolbarMenuAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException)
365*cdf0e10cSrcweir {
366*cdf0e10cSrcweir     ThrowIfDisposed();
367*cdf0e10cSrcweir     const awt::Rectangle aRect( getBounds() );
368*cdf0e10cSrcweir     const Point aSize( aRect.Width, aRect.Height );
369*cdf0e10cSrcweir     const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
372*cdf0e10cSrcweir }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir // -----------------------------------------------------------------------------
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getAccessibleAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
379*cdf0e10cSrcweir     ThrowIfDisposed();
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 	const Point aVclPoint( aPoint.X, aPoint.Y );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir 	const int nEntryCount = mpParent->maEntryVector.size();
386*cdf0e10cSrcweir 	for( int nEntry = 0; (nEntry < nEntryCount) && !xRet.is(); nEntry++ )
387*cdf0e10cSrcweir 	{
388*cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = mpParent->maEntryVector[nEntry];
389*cdf0e10cSrcweir 		if( pEntry && pEntry->maRect.IsInside( aVclPoint ) )
390*cdf0e10cSrcweir 		{
391*cdf0e10cSrcweir 			if( pEntry->mpControl )
392*cdf0e10cSrcweir 			{
393*cdf0e10cSrcweir 				awt::Point aChildPoint( aPoint.X - pEntry->maRect.Left(), aPoint.Y - pEntry->maRect.Top() );
394*cdf0e10cSrcweir 				Reference< XAccessibleComponent > xComp( pEntry->GetAccessible(true), UNO_QUERY_THROW );
395*cdf0e10cSrcweir 				xRet = xComp->getAccessibleAtPoint(aChildPoint);
396*cdf0e10cSrcweir 			}
397*cdf0e10cSrcweir 			else
398*cdf0e10cSrcweir 			{
399*cdf0e10cSrcweir 				xRet = Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
400*cdf0e10cSrcweir 			}
401*cdf0e10cSrcweir 		}
402*cdf0e10cSrcweir 	}
403*cdf0e10cSrcweir 	return xRet;
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir // -----------------------------------------------------------------------------
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir awt::Rectangle SAL_CALL ToolbarMenuAcc::getBounds() throw (RuntimeException)
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir     ThrowIfDisposed();
411*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
412*cdf0e10cSrcweir     const Point         aOutPos( mpParent->mrMenu.GetPosPixel() );
413*cdf0e10cSrcweir     const Size          aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
414*cdf0e10cSrcweir     awt::Rectangle      aRet;
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir     aRet.X = aOutPos.X();
417*cdf0e10cSrcweir     aRet.Y = aOutPos.Y();
418*cdf0e10cSrcweir     aRet.Width = aOutSize.Width();
419*cdf0e10cSrcweir     aRet.Height = aOutSize.Height();
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir     return aRet;
422*cdf0e10cSrcweir }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir // -----------------------------------------------------------------------------
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir awt::Point SAL_CALL ToolbarMenuAcc::getLocation() throw (RuntimeException)
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir     ThrowIfDisposed();
429*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
430*cdf0e10cSrcweir     const Point aOutPos( mpParent->mrMenu.GetPosPixel() );
431*cdf0e10cSrcweir     return awt::Point( aOutPos.X(), aOutPos.Y() );
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir // -----------------------------------------------------------------------------
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir awt::Point SAL_CALL ToolbarMenuAcc::getLocationOnScreen()  throw (RuntimeException)
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir     ThrowIfDisposed();
439*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
440*cdf0e10cSrcweir     const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( Point() ) );
441*cdf0e10cSrcweir     return awt::Point( aScreenPos.X(), aScreenPos.Y() );
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir // -----------------------------------------------------------------------------
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir awt::Size SAL_CALL ToolbarMenuAcc::getSize() throw (RuntimeException)
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir     ThrowIfDisposed();
449*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
450*cdf0e10cSrcweir     const Size aOutSize( mpParent->mrMenu.GetOutputSizePixel() );
451*cdf0e10cSrcweir     return awt::Size( aOutSize.Width(), aOutSize.Height() );
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir // -----------------------------------------------------------------------------
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::grabFocus() throw (RuntimeException)
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir     ThrowIfDisposed();
459*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
460*cdf0e10cSrcweir     mpParent->mrMenu.GrabFocus();
461*cdf0e10cSrcweir }
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir // -----------------------------------------------------------------------------
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir Any SAL_CALL ToolbarMenuAcc::getAccessibleKeyBinding() throw (RuntimeException)
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     ThrowIfDisposed();
468*cdf0e10cSrcweir     return Any();
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir // -----------------------------------------------------------------------------
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuAcc::getForeground() throw (RuntimeException)
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir     ThrowIfDisposed();
476*cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor();
477*cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir // -----------------------------------------------------------------------------
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuAcc::getBackground() throw (RuntimeException)
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir     ThrowIfDisposed();
485*cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor();
486*cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
487*cdf0e10cSrcweir }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir // -----------------------------------------------------------------------------
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
492*cdf0e10cSrcweir {
493*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
494*cdf0e10cSrcweir     ThrowIfDisposed();
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	mpParent->selectAccessibleChild( nChildIndex );
497*cdf0e10cSrcweir }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir // -----------------------------------------------------------------------------
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir sal_Bool SAL_CALL ToolbarMenuAcc::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
502*cdf0e10cSrcweir {
503*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
504*cdf0e10cSrcweir     ThrowIfDisposed();
505*cdf0e10cSrcweir 	return mpParent->isAccessibleChildSelected( nChildIndex );
506*cdf0e10cSrcweir }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir // -----------------------------------------------------------------------------
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::clearAccessibleSelection() throw (RuntimeException)
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
513*cdf0e10cSrcweir     ThrowIfDisposed();
514*cdf0e10cSrcweir     mpParent->clearAccessibleSelection();
515*cdf0e10cSrcweir }
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir // -----------------------------------------------------------------------------
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::selectAllAccessibleChildren() throw (RuntimeException)
520*cdf0e10cSrcweir {
521*cdf0e10cSrcweir     ThrowIfDisposed();
522*cdf0e10cSrcweir     // unsupported due to single selection only
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir // -----------------------------------------------------------------------------
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChildCount() throw (RuntimeException)
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
530*cdf0e10cSrcweir     ThrowIfDisposed();
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 	return mpParent->mnHighlightedEntry != -1 ? 1 : 0;
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir // -----------------------------------------------------------------------------
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
538*cdf0e10cSrcweir {
539*cdf0e10cSrcweir     ThrowIfDisposed();
540*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	if( (mpParent->mnHighlightedEntry != -1) && (nSelectedChildIndex == 0) )
543*cdf0e10cSrcweir 	{
544*cdf0e10cSrcweir 		ToolbarMenuEntry* pEntry = mpParent->maEntryVector[ mpParent->mnHighlightedEntry ];
545*cdf0e10cSrcweir 		if( pEntry )
546*cdf0e10cSrcweir 		{
547*cdf0e10cSrcweir 			if( pEntry->mpControl )
548*cdf0e10cSrcweir 			{
549*cdf0e10cSrcweir 				Reference< XAccessibleSelection > xSel( pEntry->GetAccessible(true), UNO_QUERY_THROW );
550*cdf0e10cSrcweir 				return xSel->getSelectedAccessibleChild(0);
551*cdf0e10cSrcweir 			}
552*cdf0e10cSrcweir 			else
553*cdf0e10cSrcweir 				return Reference< XAccessible >( pEntry->GetAccessible(true), UNO_QUERY );
554*cdf0e10cSrcweir 		}
555*cdf0e10cSrcweir 	}
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
558*cdf0e10cSrcweir }
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir // -----------------------------------------------------------------------------
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
563*cdf0e10cSrcweir {
564*cdf0e10cSrcweir     ThrowIfDisposed();
565*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
566*cdf0e10cSrcweir     // Because of the single selection we can reset the whole selection when
567*cdf0e10cSrcweir     // the specified child is currently selected.
568*cdf0e10cSrcweir     if (isAccessibleChildSelected(nChildIndex))
569*cdf0e10cSrcweir         mpParent->clearAccessibleSelection();
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir // -----------------------------------------------------------------------------
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir void SAL_CALL ToolbarMenuAcc::disposing (void)
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir     EventListenerVector aListenerListCopy;
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir     {
579*cdf0e10cSrcweir         // Make a copy of the list and clear the original.
580*cdf0e10cSrcweir         const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
581*cdf0e10cSrcweir         ::osl::MutexGuard aGuard (m_aMutex);
582*cdf0e10cSrcweir         aListenerListCopy = mxEventListeners;
583*cdf0e10cSrcweir         mxEventListeners.clear();
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir         // Reset the pointer to the parent.  It has to be the one who has
586*cdf0e10cSrcweir         // disposed us because he is dying.
587*cdf0e10cSrcweir         mpParent = NULL;
588*cdf0e10cSrcweir     }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     // Inform all listeners that this objects is disposing.
591*cdf0e10cSrcweir     EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
592*cdf0e10cSrcweir     EventObject aEvent (static_cast<XAccessible*>(this));
593*cdf0e10cSrcweir     while(aListenerIterator != aListenerListCopy.end())
594*cdf0e10cSrcweir     {
595*cdf0e10cSrcweir         try
596*cdf0e10cSrcweir         {
597*cdf0e10cSrcweir             (*aListenerIterator)->disposing (aEvent);
598*cdf0e10cSrcweir         }
599*cdf0e10cSrcweir         catch( Exception& )
600*cdf0e10cSrcweir         {
601*cdf0e10cSrcweir             // Ignore exceptions.
602*cdf0e10cSrcweir         }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir         ++aListenerIterator;
605*cdf0e10cSrcweir     }
606*cdf0e10cSrcweir }
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir void ToolbarMenuAcc::ThrowIfDisposed (void) throw (DisposedException)
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir     if(rBHelper.bDisposed || rBHelper.bInDispose || !mpParent)
611*cdf0e10cSrcweir     {
612*cdf0e10cSrcweir         throw DisposedException ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")), static_cast<XWeak*>(this));
613*cdf0e10cSrcweir     }
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir // -----------------------
617*cdf0e10cSrcweir // - ToolbarMenuEntryAcc -
618*cdf0e10cSrcweir // -----------------------
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir ToolbarMenuEntryAcc::ToolbarMenuEntryAcc( ToolbarMenuEntry* pParent )
621*cdf0e10cSrcweir : ToolbarMenuEntryAccBase( m_aMutex )
622*cdf0e10cSrcweir , mpParent( pParent )
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir }
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir // -----------------------------------------------------------------------------
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir ToolbarMenuEntryAcc::~ToolbarMenuEntryAcc()
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir }
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir // -----------------------------------------------------------------------
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir void ToolbarMenuEntryAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue )
635*cdf0e10cSrcweir {
636*cdf0e10cSrcweir     if( nEventId )
637*cdf0e10cSrcweir     {
638*cdf0e10cSrcweir         EventListenerVector aTmpListeners( mxEventListeners );
639*cdf0e10cSrcweir         ::std::vector< Reference< XAccessibleEventListener > >::const_iterator  aIter( aTmpListeners.begin() );
640*cdf0e10cSrcweir         AccessibleEventObject aEvtObject;
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir         aEvtObject.EventId = nEventId;
643*cdf0e10cSrcweir         aEvtObject.Source = static_cast<XWeak*>(this);
644*cdf0e10cSrcweir         aEvtObject.NewValue = rNewValue;
645*cdf0e10cSrcweir 	    aEvtObject.OldValue = rOldValue;
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 		while( aIter != aTmpListeners.end() )
648*cdf0e10cSrcweir         {
649*cdf0e10cSrcweir             (*aIter)->notifyEvent( aEvtObject );
650*cdf0e10cSrcweir             aIter++;
651*cdf0e10cSrcweir         }
652*cdf0e10cSrcweir     }
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir // -----------------------------------------------------------------------------
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir void SAL_CALL ToolbarMenuEntryAcc::disposing (void)
659*cdf0e10cSrcweir {
660*cdf0e10cSrcweir     EventListenerVector aListenerListCopy;
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir     {
663*cdf0e10cSrcweir         // Make a copy of the list and clear the original.
664*cdf0e10cSrcweir         const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
665*cdf0e10cSrcweir         ::osl::MutexGuard aGuard (m_aMutex);
666*cdf0e10cSrcweir         aListenerListCopy = mxEventListeners;
667*cdf0e10cSrcweir         mxEventListeners.clear();
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir         // Reset the pointer to the parent.  It has to be the one who has
670*cdf0e10cSrcweir         // disposed us because he is dying.
671*cdf0e10cSrcweir         mpParent = NULL;
672*cdf0e10cSrcweir     }
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir     // Inform all listeners that this objects is disposing.
675*cdf0e10cSrcweir     EventListenerVector::const_iterator aListenerIterator (aListenerListCopy.begin());
676*cdf0e10cSrcweir     EventObject aEvent (static_cast<XAccessible*>(this));
677*cdf0e10cSrcweir     while(aListenerIterator != aListenerListCopy.end())
678*cdf0e10cSrcweir     {
679*cdf0e10cSrcweir         try
680*cdf0e10cSrcweir         {
681*cdf0e10cSrcweir             (*aListenerIterator)->disposing (aEvent);
682*cdf0e10cSrcweir         }
683*cdf0e10cSrcweir         catch( Exception& )
684*cdf0e10cSrcweir         {
685*cdf0e10cSrcweir             // Ignore exceptions.
686*cdf0e10cSrcweir         }
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir         ++aListenerIterator;
689*cdf0e10cSrcweir     }
690*cdf0e10cSrcweir }
691*cdf0e10cSrcweir // -----------------------------------------------------------------------------
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL ToolbarMenuEntryAcc::getAccessibleContext() throw (RuntimeException)
694*cdf0e10cSrcweir {
695*cdf0e10cSrcweir     return this;
696*cdf0e10cSrcweir }
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir // -----------------------------------------------------------------------------
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleChildCount() throw (RuntimeException)
701*cdf0e10cSrcweir {
702*cdf0e10cSrcweir     return 0;
703*cdf0e10cSrcweir }
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir // -----------------------------------------------------------------------------
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException, RuntimeException)
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir // -----------------------------------------------------------------------------
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleParent() throw (RuntimeException)
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
717*cdf0e10cSrcweir     Reference< XAccessible > xRet;
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir     if( mpParent )
720*cdf0e10cSrcweir         xRet = mpParent->mrMenu.GetAccessible();
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir     return xRet;
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir // -----------------------------------------------------------------------------
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getAccessibleIndexInParent() throw (RuntimeException)
728*cdf0e10cSrcweir {
729*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
730*cdf0e10cSrcweir     // The index defaults to -1 to indicate the child does not belong to its
731*cdf0e10cSrcweir     // parent.
732*cdf0e10cSrcweir     sal_Int32 nIndexInParent = -1;
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir     if( mpParent )
735*cdf0e10cSrcweir     {
736*cdf0e10cSrcweir 		Reference< XAccessibleContext > xParent( mpParent->mrMenu.GetAccessible(), UNO_QUERY );
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir 		if( xParent.is() )
739*cdf0e10cSrcweir 		{
740*cdf0e10cSrcweir 			Reference< XAccessible > xThis( this );
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir 			const sal_Int32 nCount = xParent->getAccessibleChildCount();
743*cdf0e10cSrcweir 			for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
744*cdf0e10cSrcweir 			{
745*cdf0e10cSrcweir 				if( xParent->getAccessibleChild(nIndex) == xThis )
746*cdf0e10cSrcweir 				{
747*cdf0e10cSrcweir 					nIndexInParent = nIndex;
748*cdf0e10cSrcweir 					break;
749*cdf0e10cSrcweir 				}
750*cdf0e10cSrcweir 			}
751*cdf0e10cSrcweir 		}
752*cdf0e10cSrcweir     }
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir     return nIndexInParent;
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir // -----------------------------------------------------------------------------
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir sal_Int16 SAL_CALL ToolbarMenuEntryAcc::getAccessibleRole() throw (RuntimeException)
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir     return AccessibleRole::LIST_ITEM;
762*cdf0e10cSrcweir }
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir // -----------------------------------------------------------------------------
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleDescription() throw (RuntimeException)
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir 	return ::rtl::OUString();
769*cdf0e10cSrcweir }
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir // -----------------------------------------------------------------------------
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ToolbarMenuEntryAcc::getAccessibleName() throw (RuntimeException)
774*cdf0e10cSrcweir {
775*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
776*cdf0e10cSrcweir     String              aRet;
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir     if( mpParent )
779*cdf0e10cSrcweir     {
780*cdf0e10cSrcweir         aRet = mpParent->maText;
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir         if( !aRet.Len() )
783*cdf0e10cSrcweir         {
784*cdf0e10cSrcweir             aRet = String( RTL_CONSTASCII_USTRINGPARAM( "Item " ) );
785*cdf0e10cSrcweir             aRet += String::CreateFromInt32( mpParent->mnEntryId );
786*cdf0e10cSrcweir         }
787*cdf0e10cSrcweir     }
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir     return aRet;
790*cdf0e10cSrcweir }
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir // -----------------------------------------------------------------------------
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleRelationSet() throw (RuntimeException)
795*cdf0e10cSrcweir {
796*cdf0e10cSrcweir     return Reference< XAccessibleRelationSet >();
797*cdf0e10cSrcweir }
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir // -----------------------------------------------------------------------------
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL ToolbarMenuEntryAcc::getAccessibleStateSet() throw (RuntimeException)
802*cdf0e10cSrcweir {
803*cdf0e10cSrcweir     const vos::OGuard                   aSolarGuard( Application::GetSolarMutex() );
804*cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir     if( mpParent )
807*cdf0e10cSrcweir     {
808*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::ENABLED);
809*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::SENSITIVE);
810*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::SHOWING);
811*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::VISIBLE);
812*cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::TRANSIENT);
813*cdf0e10cSrcweir 		if( mpParent->mnEntryId != TITLE_ID )
814*cdf0e10cSrcweir 		{
815*cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::SELECTABLE );
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 			// SELECTED
818*cdf0e10cSrcweir 			if( mpParent->mrMenu.getHighlightedEntryId() == mpParent->mnEntryId )
819*cdf0e10cSrcweir 				pStateSet->AddState( AccessibleStateType::SELECTED );
820*cdf0e10cSrcweir 		}
821*cdf0e10cSrcweir     }
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir     return pStateSet;
824*cdf0e10cSrcweir }
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir // -----------------------------------------------------------------------------
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir Locale SAL_CALL ToolbarMenuEntryAcc::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException)
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir     const ::rtl::OUString aEmptyStr;
831*cdf0e10cSrcweir     Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir 	Reference< XAccessible > xParent( getAccessibleParent() );
834*cdf0e10cSrcweir     if( xParent.is() )
835*cdf0e10cSrcweir     {
836*cdf0e10cSrcweir         Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
837*cdf0e10cSrcweir 
838*cdf0e10cSrcweir         if( xParentContext.is() )
839*cdf0e10cSrcweir             aRet = xParentContext->getLocale();
840*cdf0e10cSrcweir     }
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir     return aRet;
843*cdf0e10cSrcweir }
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir // -----------------------------------------------------------------------------
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir void SAL_CALL ToolbarMenuEntryAcc::addEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
848*cdf0e10cSrcweir {
849*cdf0e10cSrcweir     const ::vos::OGuard aGuard( maMutex );
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 	if( rxListener.is() )
852*cdf0e10cSrcweir     {
853*cdf0e10cSrcweir        	EventListenerVector::const_iterator aIter( mxEventListeners.begin() );
854*cdf0e10cSrcweir 		bool bFound = false;
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
857*cdf0e10cSrcweir         {
858*cdf0e10cSrcweir 			if( *aIter == rxListener )
859*cdf0e10cSrcweir                 bFound = true;
860*cdf0e10cSrcweir             else
861*cdf0e10cSrcweir                 aIter++;
862*cdf0e10cSrcweir         }
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir 		if (!bFound)
865*cdf0e10cSrcweir             mxEventListeners.push_back( rxListener );
866*cdf0e10cSrcweir     }
867*cdf0e10cSrcweir }
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir // -----------------------------------------------------------------------------
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir void SAL_CALL ToolbarMenuEntryAcc::removeEventListener( const Reference< XAccessibleEventListener >& rxListener ) throw (RuntimeException)
872*cdf0e10cSrcweir {
873*cdf0e10cSrcweir     const ::vos::OGuard aGuard( maMutex );
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir 	if( rxListener.is() )
876*cdf0e10cSrcweir     {
877*cdf0e10cSrcweir        	EventListenerVector::iterator aIter = mxEventListeners.begin();
878*cdf0e10cSrcweir 		bool bFound = false;
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
881*cdf0e10cSrcweir         {
882*cdf0e10cSrcweir 			if( *aIter == rxListener )
883*cdf0e10cSrcweir             {
884*cdf0e10cSrcweir                 mxEventListeners.erase( aIter );
885*cdf0e10cSrcweir                 bFound = true;
886*cdf0e10cSrcweir             }
887*cdf0e10cSrcweir             else
888*cdf0e10cSrcweir                 aIter++;
889*cdf0e10cSrcweir         }
890*cdf0e10cSrcweir     }
891*cdf0e10cSrcweir }
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir // -----------------------------------------------------------------------------
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir sal_Bool SAL_CALL ToolbarMenuEntryAcc::containsPoint( const awt::Point& aPoint ) throw (RuntimeException)
896*cdf0e10cSrcweir {
897*cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
898*cdf0e10cSrcweir     const Point             aSize( aRect.Width, aRect.Height );
899*cdf0e10cSrcweir     const Point             aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
902*cdf0e10cSrcweir }
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir // -----------------------------------------------------------------------------
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL ToolbarMenuEntryAcc::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
907*cdf0e10cSrcweir {
908*cdf0e10cSrcweir     Reference< XAccessible > xRet;
909*cdf0e10cSrcweir     return xRet;
910*cdf0e10cSrcweir }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir // -----------------------------------------------------------------------------
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir awt::Rectangle SAL_CALL ToolbarMenuEntryAcc::getBounds() throw (RuntimeException)
915*cdf0e10cSrcweir {
916*cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
917*cdf0e10cSrcweir     awt::Rectangle      aRet;
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir     if( mpParent )
920*cdf0e10cSrcweir     {
921*cdf0e10cSrcweir         Rectangle   aRect( mpParent->maRect );
922*cdf0e10cSrcweir         Point       aOrigin;
923*cdf0e10cSrcweir         Rectangle   aParentRect( aOrigin, mpParent->mrMenu.GetOutputSizePixel() );
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir         aRect.Intersection( aParentRect );
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir         aRet.X = aRect.Left();
928*cdf0e10cSrcweir         aRet.Y = aRect.Top();
929*cdf0e10cSrcweir         aRet.Width = aRect.GetWidth();
930*cdf0e10cSrcweir         aRet.Height = aRect.GetHeight();
931*cdf0e10cSrcweir     }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir     return aRet;
934*cdf0e10cSrcweir }
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir // -----------------------------------------------------------------------------
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocation() throw (RuntimeException)
939*cdf0e10cSrcweir {
940*cdf0e10cSrcweir     const awt::Rectangle aRect( getBounds() );
941*cdf0e10cSrcweir     return awt::Point( aRect.X, aRect.Y );
942*cdf0e10cSrcweir }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir // -----------------------------------------------------------------------------
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir awt::Point SAL_CALL ToolbarMenuEntryAcc::getLocationOnScreen() throw (RuntimeException)
947*cdf0e10cSrcweir {
948*cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
949*cdf0e10cSrcweir     awt::Point aRet;
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir     if( mpParent )
952*cdf0e10cSrcweir     {
953*cdf0e10cSrcweir         const Point aScreenPos( mpParent->mrMenu.OutputToAbsoluteScreenPixel( mpParent->maRect.TopLeft() ) );
954*cdf0e10cSrcweir 
955*cdf0e10cSrcweir         aRet.X = aScreenPos.X();
956*cdf0e10cSrcweir         aRet.Y = aScreenPos.Y();
957*cdf0e10cSrcweir     }
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir     return aRet;
960*cdf0e10cSrcweir }
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir // -----------------------------------------------------------------------------
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir awt::Size SAL_CALL ToolbarMenuEntryAcc::getSize() throw (RuntimeException)
965*cdf0e10cSrcweir {
966*cdf0e10cSrcweir     const awt::Rectangle aRect( getBounds() );
967*cdf0e10cSrcweir     awt::Size aRet;
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir     aRet.Width = aRect.Width;
970*cdf0e10cSrcweir     aRet.Height = aRect.Height;
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir     return aRet;
973*cdf0e10cSrcweir }
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir // -----------------------------------------------------------------------------
976*cdf0e10cSrcweir 
977*cdf0e10cSrcweir void SAL_CALL ToolbarMenuEntryAcc::grabFocus() throw (RuntimeException)
978*cdf0e10cSrcweir {
979*cdf0e10cSrcweir     // nothing to do
980*cdf0e10cSrcweir }
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir // -----------------------------------------------------------------------------
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir Any SAL_CALL ToolbarMenuEntryAcc::getAccessibleKeyBinding() throw (RuntimeException)
985*cdf0e10cSrcweir {
986*cdf0e10cSrcweir     return Any();
987*cdf0e10cSrcweir }
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir // -----------------------------------------------------------------------------
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getForeground(  ) throw (RuntimeException)
992*cdf0e10cSrcweir {
993*cdf0e10cSrcweir     return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuTextColor().GetColor());
994*cdf0e10cSrcweir }
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir // -----------------------------------------------------------------------------
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir sal_Int32 SAL_CALL ToolbarMenuEntryAcc::getBackground(  )  throw (RuntimeException)
999*cdf0e10cSrcweir {
1000*cdf0e10cSrcweir     return static_cast<sal_Int32>(Application::GetSettings().GetStyleSettings().GetMenuColor().GetColor());
1001*cdf0e10cSrcweir }
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir }
1004