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/extended/accessiblelistbox.hxx> 31*cdf0e10cSrcweir #include <accessibility/extended/accessiblelistboxentry.hxx> 32*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 39*cdf0e10cSrcweir #include <tools/debug.hxx> 40*cdf0e10cSrcweir #include <vcl/svapp.hxx> 41*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 42*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 43*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir //........................................................................ 46*cdf0e10cSrcweir namespace accessibility 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir //........................................................................ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // class AccessibleListBox ----------------------------------------------------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 53*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 55*cdf0e10cSrcweir using namespace ::com::sun::star; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir DBG_NAME(AccessibleListBox) 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 60*cdf0e10cSrcweir // Ctor() and Dtor() 61*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 62*cdf0e10cSrcweir AccessibleListBox::AccessibleListBox( SvTreeListBox& _rListBox, const Reference< XAccessible >& _xParent ) : 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir VCLXAccessibleComponent( _rListBox.GetWindowPeer() ), 65*cdf0e10cSrcweir m_xParent( _xParent ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir DBG_CTOR( AccessibleListBox, NULL ); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70*cdf0e10cSrcweir AccessibleListBox::~AccessibleListBox() 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir DBG_DTOR( AccessibleListBox, NULL ); 73*cdf0e10cSrcweir if ( isAlive() ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir // increment ref count to prevent double call of Dtor 76*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 77*cdf0e10cSrcweir dispose(); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE) 81*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE) 82*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 83*cdf0e10cSrcweir SvTreeListBox* AccessibleListBox::getListBox() const 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir return static_cast< SvTreeListBox* >( const_cast<AccessibleListBox*>(this)->GetWindow() ); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 88*cdf0e10cSrcweir void AccessibleListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir if ( isAlive() ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir case VCLEVENT_CHECKBOX_TOGGLE : 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir if ( getListBox() && getListBox()->HasFocus() ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() ); 99*cdf0e10cSrcweir if ( !pEntry ) 100*cdf0e10cSrcweir pEntry = getListBox()->GetCurEntry(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir if ( pEntry ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir Reference< XAccessible > xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 105*cdf0e10cSrcweir uno::Any aOldValue, aNewValue; 106*cdf0e10cSrcweir aNewValue <<= xChild; 107*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir break; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT : 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir // First send an event that tells the listeners of a 116*cdf0e10cSrcweir // modified selection. The active descendant event is 117*cdf0e10cSrcweir // send after that so that the receiving AT has time to 118*cdf0e10cSrcweir // read the text or name of the active child. 119*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); 120*cdf0e10cSrcweir if ( getListBox() && getListBox()->HasFocus() ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() ); 123*cdf0e10cSrcweir if ( pEntry ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir Reference< XAccessible > xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 126*cdf0e10cSrcweir uno::Any aOldValue, aNewValue; 127*cdf0e10cSrcweir aNewValue <<= xChild; 128*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir break; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // --> OD 2009-04-01 #i92103# 134*cdf0e10cSrcweir case VCLEVENT_ITEM_EXPANDED : 135*cdf0e10cSrcweir case VCLEVENT_ITEM_COLLAPSED : 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() ); 138*cdf0e10cSrcweir if ( pEntry ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir AccessibleListBoxEntry* pAccListBoxEntry = 141*cdf0e10cSrcweir new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 142*cdf0e10cSrcweir Reference< XAccessible > xChild = pAccListBoxEntry; 143*cdf0e10cSrcweir const short nAccEvent = 144*cdf0e10cSrcweir ( rVclWindowEvent.GetId() == VCLEVENT_ITEM_EXPANDED ) 145*cdf0e10cSrcweir ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED 146*cdf0e10cSrcweir : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED; 147*cdf0e10cSrcweir uno::Any aListBoxEntry; 148*cdf0e10cSrcweir aListBoxEntry <<= xChild; 149*cdf0e10cSrcweir NotifyAccessibleEvent( nAccEvent, Any(), aListBoxEntry ); 150*cdf0e10cSrcweir if ( getListBox() && getListBox()->HasFocus() ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), aListBoxEntry ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir break; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir // <-- 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir default: 160*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 165*cdf0e10cSrcweir void AccessibleListBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW: 170*cdf0e10cSrcweir case VCLEVENT_WINDOW_HIDE: 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir default: 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowChildEvent( rVclWindowEvent ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 183*cdf0e10cSrcweir // XComponent 184*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 185*cdf0e10cSrcweir void SAL_CALL AccessibleListBox::disposing() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir VCLXAccessibleComponent::disposing(); 190*cdf0e10cSrcweir m_xParent = NULL; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 193*cdf0e10cSrcweir // XServiceInfo 194*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBox::getImplementationName() throw(RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir return getImplementationName_Static(); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 200*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL AccessibleListBox::getSupportedServiceNames() throw(RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 205*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBox::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 208*cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 209*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 210*cdf0e10cSrcweir for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 211*cdf0e10cSrcweir ; 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir return pSupported != pEnd; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 216*cdf0e10cSrcweir // XServiceInfo - static methods 217*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 218*cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleListBox::getSupportedServiceNames_Static(void) throw( RuntimeException ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(3); 221*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 222*cdf0e10cSrcweir aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 223*cdf0e10cSrcweir aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleTreeListBox") ); 224*cdf0e10cSrcweir return aSupported; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 227*cdf0e10cSrcweir ::rtl::OUString AccessibleListBox::getImplementationName_Static(void) throw( RuntimeException ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleTreeListBox") ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 232*cdf0e10cSrcweir // XAccessible 233*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 234*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleListBox::getAccessibleContext( ) throw (RuntimeException) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir ensureAlive(); 237*cdf0e10cSrcweir return this; 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 240*cdf0e10cSrcweir // XAccessibleContext 241*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 242*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBox::getAccessibleChildCount( ) throw (RuntimeException) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir ensureAlive(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir sal_Int32 nCount = 0; 249*cdf0e10cSrcweir SvTreeListBox* pSvTreeListBox = getListBox(); 250*cdf0e10cSrcweir if ( pSvTreeListBox ) 251*cdf0e10cSrcweir nCount = pSvTreeListBox->GetLevelChildCount( NULL ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir return nCount; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 256*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBox::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir ensureAlive(); 261*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry(i); 262*cdf0e10cSrcweir if ( !pEntry ) 263*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir return new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 268*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBox::getAccessibleParent( ) throw (RuntimeException) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir ensureAlive(); 273*cdf0e10cSrcweir return m_xParent; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 276*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleListBox::getAccessibleRole( ) throw (RuntimeException) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir return AccessibleRole::TREE; 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 281*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBox::getAccessibleDescription( ) throw (RuntimeException) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir ensureAlive(); 286*cdf0e10cSrcweir return getListBox()->GetAccessibleDescription(); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 289*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleListBox::getAccessibleName( ) throw (RuntimeException) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir ensureAlive(); 294*cdf0e10cSrcweir return getListBox()->GetAccessibleName(); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 297*cdf0e10cSrcweir // XAccessibleSelection 298*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 299*cdf0e10cSrcweir void SAL_CALL AccessibleListBox::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir ensureAlive(); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( nChildIndex ); 306*cdf0e10cSrcweir if ( !pEntry ) 307*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 312*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleListBox::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir ensureAlive(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( nChildIndex ); 319*cdf0e10cSrcweir if ( !pEntry ) 320*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir return getListBox()->IsSelected( pEntry ); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 325*cdf0e10cSrcweir void SAL_CALL AccessibleListBox::clearAccessibleSelection( ) throw (RuntimeException) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir ensureAlive(); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir sal_Int32 i, nCount = 0; 332*cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( NULL ); 333*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( i ); 336*cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 337*cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 341*cdf0e10cSrcweir void SAL_CALL AccessibleListBox::selectAllAccessibleChildren( ) throw (RuntimeException) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir ensureAlive(); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir sal_Int32 i, nCount = 0; 348*cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( NULL ); 349*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( i ); 352*cdf0e10cSrcweir if ( !getListBox()->IsSelected( pEntry ) ) 353*cdf0e10cSrcweir getListBox()->Select( pEntry, sal_True ); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 357*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleListBox::getSelectedAccessibleChildCount( ) throw (RuntimeException) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir ensureAlive(); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 364*cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( NULL ); 365*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( i ); 368*cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 369*cdf0e10cSrcweir ++nSelCount; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir return nSelCount; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 375*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleListBox::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir ensureAlive(); 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 382*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir Reference< XAccessible > xChild; 385*cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 386*cdf0e10cSrcweir nCount = getListBox()->GetLevelChildCount( NULL ); 387*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( i ); 390*cdf0e10cSrcweir if ( getListBox()->IsSelected( pEntry ) ) 391*cdf0e10cSrcweir ++nSelCount; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir xChild = new AccessibleListBoxEntry( *getListBox(), pEntry, this ); 396*cdf0e10cSrcweir break; 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir return xChild; 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 403*cdf0e10cSrcweir void SAL_CALL AccessibleListBox::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir ensureAlive(); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir SvLBoxEntry* pEntry = getListBox()->GetEntry( nSelectedChildIndex ); 410*cdf0e10cSrcweir if ( !pEntry ) 411*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir getListBox()->Select( pEntry, sal_False ); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 416*cdf0e10cSrcweir void AccessibleListBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); 419*cdf0e10cSrcweir if ( getListBox() && isAlive() ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 422*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 423*cdf0e10cSrcweir if ( getListBox()->GetSelectionMode() == MULTIPLE_SELECTION ) 424*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir //........................................................................ 430*cdf0e10cSrcweir }// namespace accessibility 431*cdf0e10cSrcweir //........................................................................ 432*cdf0e10cSrcweir 433