xref: /AOO41X/main/accessibility/source/standard/accessiblemenuitemcomponent.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_accessibility.hxx"
30*cdf0e10cSrcweir #include <accessibility/standard/accessiblemenuitemcomponent.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <accessibility/helper/accresmgr.hxx>
34*cdf0e10cSrcweir #include <accessibility/helper/accessiblestrings.hrc>
35*cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx>
36*cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
37*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
46*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
47*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
48*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
49*cdf0e10cSrcweir #include <comphelper/accessibletexthelper.hxx>
50*cdf0e10cSrcweir #include <vcl/svapp.hxx>
51*cdf0e10cSrcweir #include <vcl/window.hxx>
52*cdf0e10cSrcweir #include <vcl/menu.hxx>
53*cdf0e10cSrcweir #include <vcl/unohelp2.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
57*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
58*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
59*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
60*cdf0e10cSrcweir using namespace ::com::sun::star;
61*cdf0e10cSrcweir using namespace ::comphelper;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir // -----------------------------------------------------------------------------
65*cdf0e10cSrcweir // class OAccessibleMenuItemComponent
66*cdf0e10cSrcweir // -----------------------------------------------------------------------------
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir OAccessibleMenuItemComponent::OAccessibleMenuItemComponent( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
69*cdf0e10cSrcweir 	:OAccessibleMenuBaseComponent( pMenu )
70*cdf0e10cSrcweir 	,m_pParent( pParent )
71*cdf0e10cSrcweir 	,m_nItemPos( nItemPos )
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	m_sAccessibleName = GetAccessibleName();
74*cdf0e10cSrcweir 	m_sItemText = GetItemText();
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir // -----------------------------------------------------------------------------
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir OAccessibleMenuItemComponent::~OAccessibleMenuItemComponent()
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir // -----------------------------------------------------------------------------
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir sal_Bool OAccessibleMenuItemComponent::IsEnabled()
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	sal_Bool bEnabled = sal_False;
90*cdf0e10cSrcweir 	if ( m_pParent )
91*cdf0e10cSrcweir 		bEnabled = m_pParent->IsItemEnabled( m_pParent->GetItemId( m_nItemPos ) );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	return bEnabled;
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // -----------------------------------------------------------------------------
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir sal_Bool OAccessibleMenuItemComponent::IsVisible()
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     sal_Bool bVisible = sal_False;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	if ( m_pParent )
103*cdf0e10cSrcweir         bVisible = m_pParent->IsItemPosVisible( m_nItemPos );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     return bVisible;
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir // -----------------------------------------------------------------------------
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir void OAccessibleMenuItemComponent::Select()
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	// open the parent menu
113*cdf0e10cSrcweir 	Reference< XAccessible > xParent( getAccessibleParent() );
114*cdf0e10cSrcweir 	if ( xParent.is() )
115*cdf0e10cSrcweir 	{
116*cdf0e10cSrcweir 		OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xParent.get() );
117*cdf0e10cSrcweir 		if ( pComp && pComp->getAccessibleRole() == AccessibleRole::MENU && !pComp->IsPopupMenuOpen() )
118*cdf0e10cSrcweir 			pComp->Click();
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	// highlight the menu item
122*cdf0e10cSrcweir 	if ( m_pParent )
123*cdf0e10cSrcweir         m_pParent->HighlightItem( m_nItemPos );
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir // -----------------------------------------------------------------------------
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void OAccessibleMenuItemComponent::DeSelect()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	if ( m_pParent && IsSelected() )
131*cdf0e10cSrcweir 		m_pParent->DeHighlight();
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir // -----------------------------------------------------------------------------
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir void OAccessibleMenuItemComponent::Click()
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir     // open the parent menu
139*cdf0e10cSrcweir     Reference< XAccessible > xParent( getAccessibleParent() );
140*cdf0e10cSrcweir     if ( xParent.is() )
141*cdf0e10cSrcweir     {
142*cdf0e10cSrcweir         OAccessibleMenuBaseComponent* pComp = static_cast< OAccessibleMenuBaseComponent* >( xParent.get() );
143*cdf0e10cSrcweir         if ( pComp && pComp->getAccessibleRole() == AccessibleRole::MENU && !pComp->IsPopupMenuOpen() )
144*cdf0e10cSrcweir             pComp->Click();
145*cdf0e10cSrcweir     }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     // click the menu item
148*cdf0e10cSrcweir     if ( m_pParent )
149*cdf0e10cSrcweir     {
150*cdf0e10cSrcweir         Window* pWindow = m_pParent->GetWindow();
151*cdf0e10cSrcweir         if ( pWindow )
152*cdf0e10cSrcweir         {
153*cdf0e10cSrcweir             // #102438# Menu items are not selectable
154*cdf0e10cSrcweir             // Popup menus are executed asynchronously, triggered by a timer.
155*cdf0e10cSrcweir             // As Menu::SelectItem only works, if the corresponding menu window is
156*cdf0e10cSrcweir             // already created, we have to set the menu delay to 0, so
157*cdf0e10cSrcweir             // that the popup menus are executed synchronously.
158*cdf0e10cSrcweir             AllSettings aSettings = pWindow->GetSettings();
159*cdf0e10cSrcweir             MouseSettings aMouseSettings = aSettings.GetMouseSettings();
160*cdf0e10cSrcweir             sal_uLong nDelay = aMouseSettings.GetMenuDelay();
161*cdf0e10cSrcweir             aMouseSettings.SetMenuDelay( 0 );
162*cdf0e10cSrcweir             aSettings.SetMouseSettings( aMouseSettings );
163*cdf0e10cSrcweir             pWindow->SetSettings( aSettings );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir             m_pParent->SelectItem( m_pParent->GetItemId( m_nItemPos ) );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir             // meanwhile the window pointer may be invalid
168*cdf0e10cSrcweir             pWindow = m_pParent->GetWindow();
169*cdf0e10cSrcweir             if ( pWindow )
170*cdf0e10cSrcweir             {
171*cdf0e10cSrcweir                 // set the menu delay back to the old value
172*cdf0e10cSrcweir                 aSettings = pWindow->GetSettings();
173*cdf0e10cSrcweir                 aMouseSettings = aSettings.GetMouseSettings();
174*cdf0e10cSrcweir                 aMouseSettings.SetMenuDelay( nDelay );
175*cdf0e10cSrcweir                 aSettings.SetMouseSettings( aMouseSettings );
176*cdf0e10cSrcweir                 pWindow->SetSettings( aSettings );
177*cdf0e10cSrcweir             }
178*cdf0e10cSrcweir         }
179*cdf0e10cSrcweir     }
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir // -----------------------------------------------------------------------------
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void OAccessibleMenuItemComponent::SetItemPos( sal_uInt16 nItemPos )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	m_nItemPos = nItemPos;
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir // -----------------------------------------------------------------------------
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir void OAccessibleMenuItemComponent::SetAccessibleName( const ::rtl::OUString& sAccessibleName )
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir     if ( !m_sAccessibleName.equals( sAccessibleName ) )
194*cdf0e10cSrcweir     {
195*cdf0e10cSrcweir         Any aOldValue, aNewValue;
196*cdf0e10cSrcweir         aOldValue <<= m_sAccessibleName;
197*cdf0e10cSrcweir         aNewValue <<= sAccessibleName;
198*cdf0e10cSrcweir         m_sAccessibleName = sAccessibleName;
199*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
200*cdf0e10cSrcweir     }
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir // -----------------------------------------------------------------------------
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::GetAccessibleName()
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir 	::rtl::OUString sName;
208*cdf0e10cSrcweir 	if ( m_pParent )
209*cdf0e10cSrcweir 	{
210*cdf0e10cSrcweir 		sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
211*cdf0e10cSrcweir 		sName = m_pParent->GetAccessibleName( nItemId );
212*cdf0e10cSrcweir 		if ( sName.getLength() == 0 )
213*cdf0e10cSrcweir 			sName = m_pParent->GetItemText( nItemId );
214*cdf0e10cSrcweir 		sName = OutputDevice::GetNonMnemonicString( sName );
215*cdf0e10cSrcweir 	}
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 	return sName;
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir // -----------------------------------------------------------------------------
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir void OAccessibleMenuItemComponent::SetItemText( const ::rtl::OUString& sItemText )
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir     Any aOldValue, aNewValue;
225*cdf0e10cSrcweir     if ( OCommonAccessibleText::implInitTextChangedEvent( m_sItemText, sItemText, aOldValue, aNewValue ) )
226*cdf0e10cSrcweir     {
227*cdf0e10cSrcweir         m_sItemText = sItemText;
228*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
229*cdf0e10cSrcweir     }
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir // -----------------------------------------------------------------------------
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::GetItemText()
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir 	::rtl::OUString sText;
237*cdf0e10cSrcweir 	if ( m_pParent )
238*cdf0e10cSrcweir 		sText = OutputDevice::GetNonMnemonicString( m_pParent->GetItemText( m_pParent->GetItemId( m_nItemPos ) ) );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	return sText;
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir // -----------------------------------------------------------------------------
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir void OAccessibleMenuItemComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir 	if ( IsEnabled() )
248*cdf0e10cSrcweir     {
249*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::ENABLED );
250*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::SENSITIVE );
251*cdf0e10cSrcweir     }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     if ( IsVisible() )
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::VISIBLE );
256*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::SHOWING );
257*cdf0e10cSrcweir     }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::OPAQUE );
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir // -----------------------------------------------------------------------------
263*cdf0e10cSrcweir // OCommonAccessibleComponent
264*cdf0e10cSrcweir // -----------------------------------------------------------------------------
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir awt::Rectangle OAccessibleMenuItemComponent::implGetBounds() throw (RuntimeException)
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	if ( m_pParent )
271*cdf0e10cSrcweir 	{
272*cdf0e10cSrcweir 		// get bounding rectangle of the item relative to the containing window
273*cdf0e10cSrcweir 		aBounds = AWTRectangle( m_pParent->GetBoundingRectangle( m_nItemPos ) );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 		// get position of containing window in screen coordinates
276*cdf0e10cSrcweir 		Window* pWindow = m_pParent->GetWindow();
277*cdf0e10cSrcweir 		if ( pWindow )
278*cdf0e10cSrcweir 		{
279*cdf0e10cSrcweir 			Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
280*cdf0e10cSrcweir 			awt::Point aWindowScreenLoc = AWTPoint( aRect.TopLeft() );
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 			// get position of accessible parent in screen coordinates
283*cdf0e10cSrcweir 			Reference< XAccessible > xParent = getAccessibleParent();
284*cdf0e10cSrcweir 			if ( xParent.is() )
285*cdf0e10cSrcweir 			{
286*cdf0e10cSrcweir 				Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
287*cdf0e10cSrcweir 				if ( xParentComponent.is() )
288*cdf0e10cSrcweir 				{
289*cdf0e10cSrcweir 					awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 					// calculate bounding rectangle of the item relative to the accessible parent
292*cdf0e10cSrcweir 					aBounds.X += aWindowScreenLoc.X - aParentScreenLoc.X;
293*cdf0e10cSrcweir 					aBounds.Y += aWindowScreenLoc.Y - aParentScreenLoc.Y;
294*cdf0e10cSrcweir 				}
295*cdf0e10cSrcweir 			}
296*cdf0e10cSrcweir 		}
297*cdf0e10cSrcweir 	}
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	return aBounds;
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir // -----------------------------------------------------------------------------
303*cdf0e10cSrcweir // XComponent
304*cdf0e10cSrcweir // -----------------------------------------------------------------------------
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir void SAL_CALL OAccessibleMenuItemComponent::disposing()
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	OAccessibleMenuBaseComponent::disposing();
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	m_pParent = NULL;
311*cdf0e10cSrcweir 	m_sAccessibleName = ::rtl::OUString();
312*cdf0e10cSrcweir 	m_sItemText = ::rtl::OUString();
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir // -----------------------------------------------------------------------------
316*cdf0e10cSrcweir // XAccessibleContext
317*cdf0e10cSrcweir // -----------------------------------------------------------------------------
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir sal_Int32 OAccessibleMenuItemComponent::getAccessibleChildCount() throw (RuntimeException)
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	return 0;
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir // -----------------------------------------------------------------------------
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir 	if ( i < 0 || i >= getAccessibleChildCount() )
333*cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	return Reference< XAccessible >();
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir // -----------------------------------------------------------------------------
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleParent(  ) throw (RuntimeException)
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 	return m_pParent->GetAccessible();
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir // -----------------------------------------------------------------------------
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir sal_Int32 OAccessibleMenuItemComponent::getAccessibleIndexInParent(  ) throw (RuntimeException)
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir 	return m_nItemPos;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // -----------------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir sal_Int16 OAccessibleMenuItemComponent::getAccessibleRole(  ) throw (RuntimeException)
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 	return AccessibleRole::UNKNOWN;
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir // -----------------------------------------------------------------------------
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::getAccessibleDescription(	) throw (RuntimeException)
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	::rtl::OUString sDescription;
372*cdf0e10cSrcweir 	if ( m_pParent )
373*cdf0e10cSrcweir 		sDescription = m_pParent->GetHelpText( m_pParent->GetItemId( m_nItemPos ) );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 	return sDescription;
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir // -----------------------------------------------------------------------------
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::getAccessibleName(  ) throw (RuntimeException)
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 	return m_sAccessibleName;
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir // -----------------------------------------------------------------------------
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir Reference< XAccessibleRelationSet > OAccessibleMenuItemComponent::getAccessibleRelationSet(  ) throw (RuntimeException)
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
394*cdf0e10cSrcweir 	Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
395*cdf0e10cSrcweir     return xSet;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir // -----------------------------------------------------------------------------
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir Locale OAccessibleMenuItemComponent::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
401*cdf0e10cSrcweir {
402*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir // -----------------------------------------------------------------------------
408*cdf0e10cSrcweir // XAccessibleComponent
409*cdf0e10cSrcweir // -----------------------------------------------------------------------------
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuItemComponent::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	return Reference< XAccessible >();
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir // -----------------------------------------------------------------------------
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir void OAccessibleMenuItemComponent::grabFocus(  ) throw (RuntimeException)
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir 	// no focus for items
423*cdf0e10cSrcweir }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir // -----------------------------------------------------------------------------
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir sal_Int32 OAccessibleMenuItemComponent::getForeground(	) throw (RuntimeException)
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
432*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
433*cdf0e10cSrcweir 	if ( xParent.is() )
434*cdf0e10cSrcweir 	{
435*cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
436*cdf0e10cSrcweir 		if ( xParentComp.is() )
437*cdf0e10cSrcweir 			nColor = xParentComp->getForeground();
438*cdf0e10cSrcweir 	}
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	return nColor;
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir // -----------------------------------------------------------------------------
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir sal_Int32 OAccessibleMenuItemComponent::getBackground(  ) throw (RuntimeException)
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
450*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
451*cdf0e10cSrcweir 	if ( xParent.is() )
452*cdf0e10cSrcweir 	{
453*cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
454*cdf0e10cSrcweir 		if ( xParentComp.is() )
455*cdf0e10cSrcweir 			nColor = xParentComp->getBackground();
456*cdf0e10cSrcweir 	}
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir 	return nColor;
459*cdf0e10cSrcweir }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir // XAccessibleExtendedComponent
463*cdf0e10cSrcweir // -----------------------------------------------------------------------------
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir Reference< awt::XFont > OAccessibleMenuItemComponent::getFont(  ) throw (RuntimeException)
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 	Reference< awt::XFont > xFont;
470*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
471*cdf0e10cSrcweir 	if ( xParent.is() )
472*cdf0e10cSrcweir 	{
473*cdf0e10cSrcweir 		Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
474*cdf0e10cSrcweir 		if ( xParentComp.is() )
475*cdf0e10cSrcweir 			xFont = xParentComp->getFont();
476*cdf0e10cSrcweir 	}
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 	return xFont;
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir // -----------------------------------------------------------------------------
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::getTitledBorderText(  ) throw (RuntimeException)
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir 	return ::rtl::OUString();
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir // -----------------------------------------------------------------------------
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuItemComponent::getToolTipText(  ) throw (RuntimeException)
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	::rtl::OUString sRet;
497*cdf0e10cSrcweir 	if ( m_pParent )
498*cdf0e10cSrcweir 		sRet = m_pParent->GetTipHelpText( m_pParent->GetItemId( m_nItemPos ) );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	return sRet;
501*cdf0e10cSrcweir }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir // -----------------------------------------------------------------------------
504