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/accessiblemenucomponent.hxx> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <toolkit/awt/vclxfont.hxx> 33*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 40*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 42*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 43*cdf0e10cSrcweir #include <vcl/svapp.hxx> 44*cdf0e10cSrcweir #include <vcl/window.hxx> 45*cdf0e10cSrcweir #include <vcl/menu.hxx> 46*cdf0e10cSrcweir #include <vcl/unohelp2.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 50*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 51*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 52*cdf0e10cSrcweir using namespace ::com::sun::star; 53*cdf0e10cSrcweir using namespace ::comphelper; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 57*cdf0e10cSrcweir // class OAccessibleMenuComponent 58*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir OAccessibleMenuComponent::OAccessibleMenuComponent( Menu* pMenu ) 61*cdf0e10cSrcweir :OAccessibleMenuBaseComponent( pMenu ) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir OAccessibleMenuComponent::~OAccessibleMenuComponent() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir sal_Bool OAccessibleMenuComponent::IsEnabled() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir return sal_True; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir sal_Bool OAccessibleMenuComponent::IsVisible() 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir sal_Bool bVisible = sal_False; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir if ( m_pMenu ) 85*cdf0e10cSrcweir bVisible = m_pMenu->IsMenuVisible(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir return bVisible; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void OAccessibleMenuComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if ( IsEnabled() ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ENABLED ); 97*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SENSITIVE ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir if ( IsFocused() ) 103*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if ( IsVisible() ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 108*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SHOWING ); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::OPAQUE ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 115*cdf0e10cSrcweir // OCommonAccessibleComponent 116*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir awt::Rectangle OAccessibleMenuComponent::implGetBounds() throw (RuntimeException) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir awt::Rectangle aBounds( 0, 0, 0, 0 ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir if ( m_pMenu ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 125*cdf0e10cSrcweir if ( pWindow ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir // get bounding rectangle of the window in screen coordinates 128*cdf0e10cSrcweir Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL ); 129*cdf0e10cSrcweir aBounds = AWTRectangle( aRect ); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // get position of the accessible parent in screen coordinates 132*cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 133*cdf0e10cSrcweir if ( xParent.is() ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY ); 136*cdf0e10cSrcweir if ( xParentComponent.is() ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // calculate position of the window relative to the accessible parent 141*cdf0e10cSrcweir aBounds.X -= aParentScreenLoc.X; 142*cdf0e10cSrcweir aBounds.Y -= aParentScreenLoc.Y; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir return aBounds; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 152*cdf0e10cSrcweir // XInterface 153*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleMenuComponent, OAccessibleMenuBaseComponent, OAccessibleMenuComponent_BASE ) 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 158*cdf0e10cSrcweir // XTypeProvider 159*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleMenuComponent, OAccessibleMenuBaseComponent, OAccessibleMenuComponent_BASE ) 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 164*cdf0e10cSrcweir // XAccessibleContext 165*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir sal_Int32 OAccessibleMenuComponent::getAccessibleChildCount() throw (RuntimeException) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir return GetChildCount(); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuComponent::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir if ( i < 0 || i >= GetChildCount() ) 181*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir return GetChild( i ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuComponent::getAccessibleParent( ) throw (RuntimeException) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir Reference< XAccessible > xParent; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if ( m_pMenu ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 197*cdf0e10cSrcweir if ( pWindow ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir Window* pParent = pWindow->GetAccessibleParentWindow(); 200*cdf0e10cSrcweir if ( pParent ) 201*cdf0e10cSrcweir xParent = pParent->GetAccessible(); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir return xParent; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir sal_Int16 OAccessibleMenuComponent::getAccessibleRole( ) throw (RuntimeException) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir return AccessibleRole::UNKNOWN; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuComponent::getAccessibleDescription( ) throw (RuntimeException) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir ::rtl::OUString sDescription; 224*cdf0e10cSrcweir if ( m_pMenu ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 227*cdf0e10cSrcweir if ( pWindow ) 228*cdf0e10cSrcweir sDescription = pWindow->GetAccessibleDescription(); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir return sDescription; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuComponent::getAccessibleName( ) throw (RuntimeException) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir return ::rtl::OUString(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir Reference< XAccessibleRelationSet > OAccessibleMenuComponent::getAccessibleRelationSet( ) throw (RuntimeException) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 250*cdf0e10cSrcweir Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; 251*cdf0e10cSrcweir return xSet; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir Locale OAccessibleMenuComponent::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir return Application::GetSettings().GetLocale(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 264*cdf0e10cSrcweir // XAccessibleComponent 265*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuComponent::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir return GetChildAt( rPoint ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir awt::Point OAccessibleMenuComponent::getLocationOnScreen( ) throw (RuntimeException) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir awt::Point aPos; 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir if ( m_pMenu ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 285*cdf0e10cSrcweir if ( pWindow ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL ); 288*cdf0e10cSrcweir aPos = AWTPoint( aRect.TopLeft() ); 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir return aPos; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir void OAccessibleMenuComponent::grabFocus( ) throw (RuntimeException) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir if ( m_pMenu ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 304*cdf0e10cSrcweir if ( pWindow ) 305*cdf0e10cSrcweir pWindow->GrabFocus(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir sal_Int32 OAccessibleMenuComponent::getForeground( ) throw (RuntimeException) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 316*cdf0e10cSrcweir sal_Int32 nColor = rStyleSettings.GetMenuTextColor().GetColor(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir return nColor; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir sal_Int32 OAccessibleMenuComponent::getBackground( ) throw (RuntimeException) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir return 0; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 331*cdf0e10cSrcweir // XAccessibleExtendedComponent 332*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir Reference< awt::XFont > OAccessibleMenuComponent::getFont( ) throw (RuntimeException) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir Reference< awt::XFont > xFont; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir if ( m_pMenu ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir Window* pWindow = m_pMenu->GetWindow(); 343*cdf0e10cSrcweir if ( pWindow ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY ); 346*cdf0e10cSrcweir if ( xDev.is() ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 349*cdf0e10cSrcweir VCLXFont* pVCLXFont = new VCLXFont; 350*cdf0e10cSrcweir pVCLXFont->Init( *xDev.get(), rStyleSettings.GetMenuFont() ); 351*cdf0e10cSrcweir xFont = pVCLXFont; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir return xFont; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuComponent::getTitledBorderText( ) throw (RuntimeException) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir return ::rtl::OUString(); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir ::rtl::OUString OAccessibleMenuComponent::getToolTipText( ) throw (RuntimeException) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir return ::rtl::OUString(); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 378*cdf0e10cSrcweir // XAccessibleSelection 379*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void OAccessibleMenuComponent::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= GetChildCount() ) 386*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir SelectChild( nChildIndex ); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir sal_Bool OAccessibleMenuComponent::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= GetChildCount() ) 398*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir return IsChildSelected( nChildIndex ); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir void OAccessibleMenuComponent::clearAccessibleSelection( ) throw (RuntimeException) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir DeSelectAll(); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir void OAccessibleMenuComponent::selectAllAccessibleChildren( ) throw (RuntimeException) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir // This method makes no sense in a menu, and so does nothing. 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir sal_Int32 OAccessibleMenuComponent::getSelectedAccessibleChildCount( ) throw (RuntimeException) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir sal_Int32 nRet = 0; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir for ( sal_Int32 i = 0, nCount = GetChildCount(); i < nCount; i++ ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir if ( IsChildSelected( i ) ) 430*cdf0e10cSrcweir ++nRet; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir return nRet; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir Reference< XAccessible > OAccessibleMenuComponent::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 443*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir Reference< XAccessible > xChild; 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir for ( sal_Int32 i = 0, j = 0, nCount = GetChildCount(); i < nCount; i++ ) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir if ( IsChildSelected( i ) && ( j++ == nSelectedChildIndex ) ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir xChild = GetChild( i ); 452*cdf0e10cSrcweir break; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir return xChild; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void OAccessibleMenuComponent::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir OExternalLockGuard aGuard( this ); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir if ( nChildIndex < 0 || nChildIndex >= GetChildCount() ) 466*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir DeSelectAll(); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 472