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