xref: /AOO41X/main/accessibility/source/standard/vclxaccessiblemenuitem.cxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_accessibility.hxx"
26 #include <accessibility/standard/vclxaccessiblemenuitem.hxx>
27 #include <accessibility/helper/accresmgr.hxx>
28 #include <accessibility/helper/accessiblestrings.hrc>
29 #include <toolkit/helper/convert.hxx>
30 #include <accessibility/helper/characterattributeshelper.hxx>
31 #include <comphelper/accessiblekeybindinghelper.hxx>
32 #include <com/sun/star/awt/KeyModifier.hpp>
33 
34 #include <com/sun/star/accessibility/AccessibleRole.hpp>
35 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
37 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
38 #include <unotools/accessiblestatesethelper.hxx>
39 #include <comphelper/sequence.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/window.hxx>
42 #include <vcl/menu.hxx>
43 #include <vcl/unohelp2.hxx>
44 
45 #include <memory>
46 
47 
48 using namespace ::com::sun::star::accessibility;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::lang;
52 using namespace ::com::sun::star;
53 using namespace ::comphelper;
54 
55 
56 // -----------------------------------------------------------------------------
57 // class VCLXAccessibleMenuItem
58 // -----------------------------------------------------------------------------
59 
VCLXAccessibleMenuItem(Menu * pParent,sal_uInt16 nItemPos,Menu * pMenu)60 VCLXAccessibleMenuItem::VCLXAccessibleMenuItem( Menu* pParent, sal_uInt16 nItemPos, Menu* pMenu )
61     :OAccessibleMenuItemComponent( pParent, nItemPos, pMenu )
62 {
63 }
64 
65 // -----------------------------------------------------------------------------
66 
~VCLXAccessibleMenuItem()67 VCLXAccessibleMenuItem::~VCLXAccessibleMenuItem()
68 {
69 }
70 
71 // -----------------------------------------------------------------------------
72 
IsFocused()73 sal_Bool VCLXAccessibleMenuItem::IsFocused()
74 {
75     return IsHighlighted();
76 }
77 
78 // -----------------------------------------------------------------------------
79 
IsSelected()80 sal_Bool VCLXAccessibleMenuItem::IsSelected()
81 {
82     return IsHighlighted();
83 }
84 
85 // -----------------------------------------------------------------------------
86 
IsChecked()87 sal_Bool VCLXAccessibleMenuItem::IsChecked()
88 {
89     sal_Bool bChecked = sal_False;
90 
91     if ( m_pParent )
92     {
93         sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
94         if ( m_pParent->IsItemChecked( nItemId ) )
95             bChecked = sal_True;
96     }
97 
98     return bChecked;
99 }
100 
101 // -----------------------------------------------------------------------------
102 
IsHighlighted()103 sal_Bool VCLXAccessibleMenuItem::IsHighlighted()
104 {
105     sal_Bool bHighlighted = sal_False;
106 
107     if ( m_pParent && m_pParent->IsHighlighted( m_nItemPos ) )
108         bHighlighted = sal_True;
109 
110     return bHighlighted;
111 }
112 
113 // -----------------------------------------------------------------------------
114 
FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)115 void VCLXAccessibleMenuItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
116 {
117     OAccessibleMenuItemComponent::FillAccessibleStateSet( rStateSet );
118 
119     rStateSet.AddState( AccessibleStateType::FOCUSABLE );
120 
121     if ( IsFocused() )
122         rStateSet.AddState( AccessibleStateType::FOCUSED );
123 
124     rStateSet.AddState( AccessibleStateType::SELECTABLE );
125 
126     if ( IsSelected() )
127         rStateSet.AddState( AccessibleStateType::SELECTED );
128 
129     if ( IsChecked() )
130         rStateSet.AddState( AccessibleStateType::CHECKED );
131 }
132 
133 // -----------------------------------------------------------------------------
134 // OCommonAccessibleText
135 // -----------------------------------------------------------------------------
136 
implGetText()137 ::rtl::OUString VCLXAccessibleMenuItem::implGetText()
138 {
139     return m_sItemText;
140 }
141 
142 // -----------------------------------------------------------------------------
143 
implGetLocale()144 Locale VCLXAccessibleMenuItem::implGetLocale()
145 {
146     return Application::GetSettings().GetLocale();
147 }
148 
149 // -----------------------------------------------------------------------------
150 
implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)151 void VCLXAccessibleMenuItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
152 {
153     nStartIndex = 0;
154     nEndIndex = 0;
155 }
156 
157 // -----------------------------------------------------------------------------
158 // XInterface
159 // -----------------------------------------------------------------------------
160 
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleMenuItem,OAccessibleMenuItemComponent,VCLXAccessibleMenuItem_BASE)161 IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleMenuItem, OAccessibleMenuItemComponent, VCLXAccessibleMenuItem_BASE )
162 
163 // -----------------------------------------------------------------------------
164 // XTypeProvider
165 // -----------------------------------------------------------------------------
166 
167 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleMenuItem, OAccessibleMenuItemComponent, VCLXAccessibleMenuItem_BASE )
168 
169 // -----------------------------------------------------------------------------
170 // XServiceInfo
171 // -----------------------------------------------------------------------------
172 
173 ::rtl::OUString VCLXAccessibleMenuItem::getImplementationName() throw (RuntimeException)
174 {
175     return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleMenuItem" );
176 }
177 
178 // -----------------------------------------------------------------------------
179 
getSupportedServiceNames()180 Sequence< ::rtl::OUString > VCLXAccessibleMenuItem::getSupportedServiceNames() throw (RuntimeException)
181 {
182     Sequence< ::rtl::OUString > aNames(1);
183     aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleMenuItem" );
184     return aNames;
185 }
186 
187 // -----------------------------------------------------------------------------
188 // XAccessibleContext
189 // -----------------------------------------------------------------------------
190 
getAccessibleRole()191 sal_Int16 VCLXAccessibleMenuItem::getAccessibleRole(  ) throw (RuntimeException)
192 {
193     OExternalLockGuard aGuard( this );
194     // IA2 CWS. MT: We had the aditional roles in UAA for ever, but never used them anywhere.
195     // Looks reasonable, but need to verify in Orca and VoiceOver.
196     sal_Int16 nRole = AccessibleRole::MENU_ITEM;
197     if ( m_pParent )
198     {
199         sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
200         MenuItemBits nItemBits = m_pParent->GetItemBits(nItemId);
201         if(  nItemBits & MIB_RADIOCHECK)
202             nRole = AccessibleRole::RADIO_MENU_ITEM;
203         else if( nItemBits & MIB_CHECKABLE)
204             nRole = AccessibleRole::CHECK_MENU_ITEM;
205     }
206     return nRole;
207 }
208 
209 // -----------------------------------------------------------------------------
210 // XAccessibleText
211 // -----------------------------------------------------------------------------
212 
getCaretPosition()213 sal_Int32 VCLXAccessibleMenuItem::getCaretPosition() throw (RuntimeException)
214 {
215     OExternalLockGuard aGuard( this );
216 
217     return -1;
218 }
219 
220 // -----------------------------------------------------------------------------
221 
setCaretPosition(sal_Int32 nIndex)222 sal_Bool VCLXAccessibleMenuItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
223 {
224 
225     OExternalLockGuard aGuard( this );
226 
227     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
228         throw IndexOutOfBoundsException();
229 
230     return sal_False;
231 }
232 
233 // -----------------------------------------------------------------------------
234 
getCharacter(sal_Int32 nIndex)235 sal_Unicode VCLXAccessibleMenuItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
236 {
237     OExternalLockGuard aGuard( this );
238 
239     return OCommonAccessibleText::getCharacter( nIndex );
240 }
241 
242 // -----------------------------------------------------------------------------
243 
getCharacterAttributes(sal_Int32 nIndex,const Sequence<::rtl::OUString> & aRequestedAttributes)244 Sequence< PropertyValue > VCLXAccessibleMenuItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
245 {
246     OExternalLockGuard aGuard( this );
247 
248     Sequence< PropertyValue > aValues;
249     ::rtl::OUString sText( implGetText() );
250 
251     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
252         throw IndexOutOfBoundsException();
253 
254     Font aFont = Application::GetSettings().GetStyleSettings().GetMenuFont();
255     sal_Int32 nBackColor = getBackground();
256     sal_Int32 nColor = getForeground();
257     ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
258     aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
259 
260     return aValues;
261 }
262 
263 // -----------------------------------------------------------------------------
264 
getCharacterBounds(sal_Int32 nIndex)265 awt::Rectangle VCLXAccessibleMenuItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
266 {
267     OExternalLockGuard aGuard( this );
268 
269     if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
270         throw IndexOutOfBoundsException();
271 
272     awt::Rectangle aBounds( 0, 0, 0, 0 );
273     if ( m_pParent )
274     {
275         sal_uInt16 nItemId = m_pParent->GetItemId( m_nItemPos );
276         Rectangle aItemRect = m_pParent->GetBoundingRectangle( m_nItemPos );
277         Rectangle aCharRect = m_pParent->GetCharacterBounds( nItemId, nIndex );
278         aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
279         aBounds = AWTRectangle( aCharRect );
280     }
281 
282     return aBounds;
283 }
284 
285 // -----------------------------------------------------------------------------
286 
getCharacterCount()287 sal_Int32 VCLXAccessibleMenuItem::getCharacterCount() throw (RuntimeException)
288 {
289     OExternalLockGuard aGuard( this );
290 
291     return OCommonAccessibleText::getCharacterCount();
292 }
293 
294 // -----------------------------------------------------------------------------
295 
getIndexAtPoint(const awt::Point & aPoint)296 sal_Int32 VCLXAccessibleMenuItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
297 {
298     OExternalLockGuard aGuard( this );
299 
300     sal_Int32 nIndex = -1;
301     if ( m_pParent )
302     {
303         sal_uInt16 nItemId = 0;
304         Rectangle aItemRect = m_pParent->GetBoundingRectangle( m_nItemPos );
305         Point aPnt( VCLPoint( aPoint ) );
306         aPnt += aItemRect.TopLeft();
307         sal_Int32 nI = m_pParent->GetIndexForPoint( aPnt, nItemId );
308         if ( nI != -1 && m_pParent->GetItemId( m_nItemPos ) == nItemId )
309             nIndex = nI;
310     }
311 
312     return nIndex;
313 }
314 
315 // -----------------------------------------------------------------------------
316 
getSelectedText()317 ::rtl::OUString VCLXAccessibleMenuItem::getSelectedText() throw (RuntimeException)
318 {
319     OExternalLockGuard aGuard( this );
320 
321     return OCommonAccessibleText::getSelectedText();
322 }
323 
324 // -----------------------------------------------------------------------------
325 
getSelectionStart()326 sal_Int32 VCLXAccessibleMenuItem::getSelectionStart() throw (RuntimeException)
327 {
328     OExternalLockGuard aGuard( this );
329 
330     return OCommonAccessibleText::getSelectionStart();
331 }
332 
333 // -----------------------------------------------------------------------------
334 
getSelectionEnd()335 sal_Int32 VCLXAccessibleMenuItem::getSelectionEnd() throw (RuntimeException)
336 {
337     OExternalLockGuard aGuard( this );
338 
339     return OCommonAccessibleText::getSelectionEnd();
340 }
341 
342 // -----------------------------------------------------------------------------
343 
setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)344 sal_Bool VCLXAccessibleMenuItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
345 {
346     OExternalLockGuard aGuard( this );
347 
348     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
349         throw IndexOutOfBoundsException();
350 
351     return sal_False;
352 }
353 
354 // -----------------------------------------------------------------------------
355 
getText()356 ::rtl::OUString VCLXAccessibleMenuItem::getText() throw (RuntimeException)
357 {
358     OExternalLockGuard aGuard( this );
359 
360     return OCommonAccessibleText::getText();
361 }
362 
363 // -----------------------------------------------------------------------------
364 
getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)365 ::rtl::OUString VCLXAccessibleMenuItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
366 {
367     OExternalLockGuard aGuard( this );
368 
369     return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
370 }
371 
372 // -----------------------------------------------------------------------------
373 
getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)374 ::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
375 {
376     OExternalLockGuard aGuard( this );
377 
378     return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
379 }
380 
381 // -----------------------------------------------------------------------------
382 
getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)383 ::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
384 {
385     OExternalLockGuard aGuard( this );
386 
387     return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
388 }
389 
390 // -----------------------------------------------------------------------------
391 
getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)392 ::com::sun::star::accessibility::TextSegment VCLXAccessibleMenuItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
393 {
394     OExternalLockGuard aGuard( this );
395 
396     return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
397 }
398 
399 // -----------------------------------------------------------------------------
400 
copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)401 sal_Bool VCLXAccessibleMenuItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
402 {
403     OExternalLockGuard aGuard( this );
404 
405     sal_Bool bReturn = sal_False;
406 
407     if ( m_pParent )
408     {
409         Window* pWindow = m_pParent->GetWindow();
410         if ( pWindow )
411         {
412             Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard();
413             if ( xClipboard.is() )
414             {
415                 ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
416 
417                 ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
418                 const sal_uInt32 nRef = Application::ReleaseSolarMutex();
419                 xClipboard->setContents( pDataObj, NULL );
420 
421                 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
422                 if( xFlushableClipboard.is() )
423                     xFlushableClipboard->flushClipboard();
424 
425                 Application::AcquireSolarMutex( nRef );
426 
427                 bReturn = sal_True;
428             }
429         }
430     }
431 
432     return bReturn;
433 }
434 
435 // -----------------------------------------------------------------------------
436 // XAccessibleAction
437 // -----------------------------------------------------------------------------
438 
getAccessibleActionCount()439 sal_Int32 VCLXAccessibleMenuItem::getAccessibleActionCount( ) throw (RuntimeException)
440 {
441     OExternalLockGuard aGuard( this );
442 
443     return 1;
444 }
445 
446 // -----------------------------------------------------------------------------
447 
doAccessibleAction(sal_Int32 nIndex)448 sal_Bool VCLXAccessibleMenuItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
449 {
450     OExternalLockGuard aGuard( this );
451 
452     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
453         throw IndexOutOfBoundsException();
454 
455     Click();
456 
457     return sal_True;
458 }
459 
460 // -----------------------------------------------------------------------------
461 
getAccessibleActionDescription(sal_Int32 nIndex)462 ::rtl::OUString VCLXAccessibleMenuItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
463 {
464     OExternalLockGuard aGuard( this );
465 
466     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
467         throw IndexOutOfBoundsException();
468     return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_SELECT ) );
469 }
470 
471 // -----------------------------------------------------------------------------
472 
getAccessibleActionKeyBinding(sal_Int32 nIndex)473 Reference< XAccessibleKeyBinding > VCLXAccessibleMenuItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
474 {
475     OExternalLockGuard aGuard( this );
476 
477     if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
478         throw IndexOutOfBoundsException();
479 
480     OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
481     Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
482 
483     if ( m_pParent )
484     {
485         // create auto mnemonics
486         if ( Application::GetSettings().GetStyleSettings().GetAutoMnemonic() && !( m_pParent->GetMenuFlags() & MENU_FLAG_NOAUTOMNEMONICS ) )
487             m_pParent->CreateAutoMnemonics();
488 
489         // activation key
490         KeyEvent aKeyEvent = m_pParent->GetActivationKey( m_pParent->GetItemId( m_nItemPos ) );
491         KeyCode aKeyCode = aKeyEvent.GetKeyCode();
492         Sequence< awt::KeyStroke > aSeq1(1);
493         aSeq1[0].Modifiers = 0;
494         Reference< XAccessible > xParent( getAccessibleParent() );
495         if ( xParent.is() )
496         {
497             Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
498             if ( xParentContext.is() && xParentContext->getAccessibleRole() == AccessibleRole::MENU_BAR )
499                 aSeq1[0].Modifiers |= awt::KeyModifier::MOD2;
500         }
501         aSeq1[0].KeyCode = aKeyCode.GetCode();
502         aSeq1[0].KeyChar = aKeyEvent.GetCharCode();
503         aSeq1[0].KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
504         pKeyBindingHelper->AddKeyBinding( aSeq1 );
505 
506         // complete menu activation key sequence
507         Sequence< awt::KeyStroke > aSeq;
508         if ( xParent.is() )
509         {
510             Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
511             if ( xParentContext.is() && xParentContext->getAccessibleRole() == AccessibleRole::MENU )
512             {
513                 Reference< XAccessibleAction > xAction( xParentContext, UNO_QUERY );
514                 if ( xAction.is() && xAction->getAccessibleActionCount() > 0 )
515                 {
516                     Reference< XAccessibleKeyBinding > xKeyB( xAction->getAccessibleActionKeyBinding( 0 ) );
517                     if ( xKeyB.is() && xKeyB->getAccessibleKeyBindingCount() > 1 )
518                         aSeq = xKeyB->getAccessibleKeyBinding( 1 );
519                 }
520             }
521         }
522         Sequence< awt::KeyStroke > aSeq2 = ::comphelper::concatSequences( aSeq, aSeq1 );
523         pKeyBindingHelper->AddKeyBinding( aSeq2 );
524 
525         // accelerator key
526         KeyCode aAccelKeyCode = m_pParent->GetAccelKey( m_pParent->GetItemId( m_nItemPos ) );
527         if ( aAccelKeyCode.GetCode() != 0 )
528         {
529             Sequence< awt::KeyStroke > aSeq3(1);
530             aSeq3[0].Modifiers = 0;
531             if ( aAccelKeyCode.IsShift() )
532                 aSeq3[0].Modifiers |= awt::KeyModifier::SHIFT;
533             if ( aAccelKeyCode.IsMod1() )
534                 aSeq3[0].Modifiers |= awt::KeyModifier::MOD1;
535             if ( aAccelKeyCode.IsMod2() )
536                 aSeq3[0].Modifiers |= awt::KeyModifier::MOD2;
537             if ( aAccelKeyCode.IsMod3() )
538                 aSeq3[0].Modifiers |= awt::KeyModifier::MOD3;
539             aSeq3[0].KeyCode = aAccelKeyCode.GetCode();
540             aSeq3[0].KeyFunc = static_cast< sal_Int16 >( aAccelKeyCode.GetFunction() );
541             pKeyBindingHelper->AddKeyBinding( aSeq3 );
542         }
543     }
544 
545     return xKeyBinding;
546 }
547 
548 // -----------------------------------------------------------------------------
549 // XAccessibleValue
550 // -----------------------------------------------------------------------------
551 
getCurrentValue()552 Any VCLXAccessibleMenuItem::getCurrentValue(  ) throw (RuntimeException)
553 {
554     OExternalLockGuard aGuard( this );
555 
556     Any aValue;
557     if ( IsSelected() )
558         aValue <<= (sal_Int32) 1;
559     else
560         aValue <<= (sal_Int32) 0;
561 
562     return aValue;
563 }
564 
565 // -----------------------------------------------------------------------------
566 
setCurrentValue(const Any & aNumber)567 sal_Bool VCLXAccessibleMenuItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
568 {
569     OExternalLockGuard aGuard( this );
570 
571     sal_Bool bReturn = sal_False;
572     sal_Int32 nValue = 0;
573     OSL_VERIFY( aNumber >>= nValue );
574 
575     if ( nValue <= 0 )
576     {
577         DeSelect();
578         bReturn = sal_True;
579     }
580     else if ( nValue >= 1 )
581     {
582         Select();
583         bReturn = sal_True;
584     }
585 
586     return bReturn;
587 }
588 
589 // -----------------------------------------------------------------------------
590 
getMaximumValue()591 Any VCLXAccessibleMenuItem::getMaximumValue(  ) throw (RuntimeException)
592 {
593     OExternalLockGuard aGuard( this );
594 
595     Any aValue;
596     aValue <<= (sal_Int32) 1;
597 
598     return aValue;
599 }
600 
601 // -----------------------------------------------------------------------------
602 
getMinimumValue()603 Any VCLXAccessibleMenuItem::getMinimumValue(  ) throw (RuntimeException)
604 {
605     OExternalLockGuard aGuard( this );
606 
607     Any aValue;
608     aValue <<= (sal_Int32) 0;
609 
610     return aValue;
611 }
612 
613 // -----------------------------------------------------------------------------
614