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