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