10841af79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 30841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file 50841af79SAndrew Rist * distributed with this work for additional information 60841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 70841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the 80841af79SAndrew Rist * "License"); you may not use this file except in compliance 90841af79SAndrew Rist * with the License. You may obtain a copy of the License at 100841af79SAndrew Rist * 110841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 120841af79SAndrew Rist * 130841af79SAndrew Rist * Unless required by applicable law or agreed to in writing, 140841af79SAndrew Rist * software distributed under the License is distributed on an 150841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160841af79SAndrew Rist * KIND, either express or implied. See the License for the 170841af79SAndrew Rist * specific language governing permissions and limitations 180841af79SAndrew Rist * under the License. 190841af79SAndrew Rist * 200841af79SAndrew Rist *************************************************************/ 210841af79SAndrew Rist 220841af79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_accessibility.hxx" 26cdf0e10cSrcweir #include "accessibility/extended/accessibleiconchoicectrl.hxx" 27cdf0e10cSrcweir #include "accessibility/extended/accessibleiconchoicectrlentry.hxx" 28cdf0e10cSrcweir #include <svtools/ivctrl.hxx> 29cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 30cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 31cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 32cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 33cdf0e10cSrcweir #include <tools/debug.hxx> 34cdf0e10cSrcweir #include <vcl/svapp.hxx> 35cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir //........................................................................ 38cdf0e10cSrcweir namespace accessibility 39cdf0e10cSrcweir { 40cdf0e10cSrcweir //........................................................................ 41cdf0e10cSrcweir 42cdf0e10cSrcweir // class AccessibleIconChoiceCtrl ---------------------------------------------- 43cdf0e10cSrcweir 44cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 45cdf0e10cSrcweir using namespace ::com::sun::star::uno; 46cdf0e10cSrcweir using namespace ::com::sun::star::lang; 47cdf0e10cSrcweir using namespace ::com::sun::star; 48cdf0e10cSrcweir DBG_NAME(AccessibleIconChoiceCtrl)49cdf0e10cSrcweir DBG_NAME(AccessibleIconChoiceCtrl) 50cdf0e10cSrcweir 51cdf0e10cSrcweir // ----------------------------------------------------------------------------- 52cdf0e10cSrcweir // Ctor() and Dtor() 53cdf0e10cSrcweir // ----------------------------------------------------------------------------- 54cdf0e10cSrcweir AccessibleIconChoiceCtrl::AccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, const Reference< XAccessible >& _xParent ) : 55cdf0e10cSrcweir 56cdf0e10cSrcweir VCLXAccessibleComponent( _rIconCtrl.GetWindowPeer() ), 57cdf0e10cSrcweir m_xParent ( _xParent ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir DBG_CTOR( AccessibleIconChoiceCtrl, NULL ); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir // ----------------------------------------------------------------------------- ~AccessibleIconChoiceCtrl()62cdf0e10cSrcweir AccessibleIconChoiceCtrl::~AccessibleIconChoiceCtrl() 63cdf0e10cSrcweir { 64cdf0e10cSrcweir DBG_DTOR( AccessibleIconChoiceCtrl, NULL ); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2(AccessibleIconChoiceCtrl,VCLXAccessibleComponent,AccessibleIconChoiceCtrl_BASE)67cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(AccessibleIconChoiceCtrl, VCLXAccessibleComponent, AccessibleIconChoiceCtrl_BASE) 68cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleIconChoiceCtrl, VCLXAccessibleComponent, AccessibleIconChoiceCtrl_BASE) 69cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70cdf0e10cSrcweir void AccessibleIconChoiceCtrl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir if ( isAlive() ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT : 77cdf0e10cSrcweir { 78cdf0e10cSrcweir // First send an event that tells the listeners of a 79cdf0e10cSrcweir // modified selection. The active descendant event is 80cdf0e10cSrcweir // send after that so that the receiving AT has time to 81cdf0e10cSrcweir // read the text or name of the active child. 8221075d77SSteve Yin // NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); 8321075d77SSteve Yin 8421075d77SSteve Yin if ( getCtrl() && getCtrl()->HasFocus() ) 8521075d77SSteve Yin { 8621075d77SSteve Yin SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); 8721075d77SSteve Yin if ( pEntry ) 8821075d77SSteve Yin { 8921075d77SSteve Yin sal_uLong nPos = getCtrl()->GetEntryListPos( pEntry ); 9021075d77SSteve Yin Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *getCtrl(), nPos, this ); 9121075d77SSteve Yin uno::Any aOldValue, aNewValue; 9221075d77SSteve Yin aNewValue <<= xChild; 9321075d77SSteve Yin NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); 9421075d77SSteve Yin 9521075d77SSteve Yin NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); 9621075d77SSteve Yin 9721075d77SSteve Yin } 9821075d77SSteve Yin } 9921075d77SSteve Yin break; 10021075d77SSteve Yin } 10121075d77SSteve Yin case VCLEVENT_WINDOW_GETFOCUS : 10221075d77SSteve Yin { 103cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 104cdf0e10cSrcweir if ( pCtrl && pCtrl->HasFocus() ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); 10721075d77SSteve Yin if ( pEntry == NULL ) 10821075d77SSteve Yin { 10921075d77SSteve Yin sal_uLong nPos=0; 11021075d77SSteve Yin pEntry = getCtrl()->GetSelectedEntry ( nPos ); 11121075d77SSteve Yin } 112cdf0e10cSrcweir if ( pEntry ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir sal_uLong nPos = pCtrl->GetEntryListPos( pEntry ); 115cdf0e10cSrcweir Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, nPos, this ); 116cdf0e10cSrcweir uno::Any aOldValue, aNewValue; 117cdf0e10cSrcweir aNewValue <<= xChild; 118cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); 11921075d77SSteve Yin NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir } 122cdf0e10cSrcweir break; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir default: 125cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowChildEvent (rVclWindowEvent); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir } 129cdf0e10cSrcweir // ----------------------------------------------------------------------------- 130cdf0e10cSrcweir // XComponent 131cdf0e10cSrcweir // ----------------------------------------------------------------------------- disposing()132cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::disposing() 133cdf0e10cSrcweir { 134cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir m_xParent = NULL; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir // ----------------------------------------------------------------------------- 139cdf0e10cSrcweir // XServiceInfo 140cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName()141cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getImplementationName() throw (RuntimeException) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir return getImplementationName_Static(); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSupportedServiceNames()146cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL AccessibleIconChoiceCtrl::getSupportedServiceNames() throw (RuntimeException) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir return getSupportedServiceNames_Static(); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir // ----------------------------------------------------------------------------- supportsService(const::rtl::OUString & _rServiceName)151cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleIconChoiceCtrl::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 154cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 155cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 156cdf0e10cSrcweir for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 157cdf0e10cSrcweir ; 158cdf0e10cSrcweir 159cdf0e10cSrcweir return pSupported != pEnd; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir // ----------------------------------------------------------------------------- 162cdf0e10cSrcweir // XServiceInfo - static methods 163cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSupportedServiceNames_Static(void)164cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleIconChoiceCtrl::getSupportedServiceNames_Static(void) throw (RuntimeException) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(3); 167cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 168cdf0e10cSrcweir aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 169cdf0e10cSrcweir aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleIconChoiceControl") ); 170cdf0e10cSrcweir return aSupported; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName_Static(void)173cdf0e10cSrcweir ::rtl::OUString AccessibleIconChoiceCtrl::getImplementationName_Static(void) throw (RuntimeException) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleIconChoiceControl") ); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir // ----------------------------------------------------------------------------- 178cdf0e10cSrcweir // XAccessible 179cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleContext()180cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleContext( ) throw (RuntimeException) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir ensureAlive(); 183cdf0e10cSrcweir return this; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir // ----------------------------------------------------------------------------- 186cdf0e10cSrcweir // XAccessibleContext 187cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChildCount()188cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleIconChoiceCtrl::getAccessibleChildCount( ) throw (RuntimeException) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 191cdf0e10cSrcweir 192cdf0e10cSrcweir ensureAlive(); 193cdf0e10cSrcweir return getCtrl()->GetEntryCount(); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChild(sal_Int32 i)196cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleChild( sal_Int32 i ) throw (RuntimeException, IndexOutOfBoundsException) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir ensureAlive(); 201cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 202cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry(i); 203cdf0e10cSrcweir if ( !pEntry ) 204cdf0e10cSrcweir throw RuntimeException(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir return new AccessibleIconChoiceCtrlEntry( *pCtrl, i, this ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleParent()209cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleParent( ) throw (RuntimeException) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir ensureAlive(); 214cdf0e10cSrcweir return m_xParent; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleRole()217cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleIconChoiceCtrl::getAccessibleRole( ) throw (RuntimeException) 218cdf0e10cSrcweir { 21921075d77SSteve Yin //return AccessibleRole::TREE; 22021075d77SSteve Yin return AccessibleRole::LIST; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleDescription()223cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getAccessibleDescription( ) throw (RuntimeException) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir ensureAlive(); 228cdf0e10cSrcweir return getCtrl()->GetAccessibleDescription(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleName()231cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getAccessibleName( ) throw (RuntimeException) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir ensureAlive(); 236cdf0e10cSrcweir 237cdf0e10cSrcweir ::rtl::OUString sName = getCtrl()->GetAccessibleName(); 238144e4e62SHerbert Dürr if ( sName.isEmpty() ) 239cdf0e10cSrcweir sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IconChoiceControl" ) ); 240cdf0e10cSrcweir return sName; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir // ----------------------------------------------------------------------------- 243cdf0e10cSrcweir // XAccessibleSelection 244cdf0e10cSrcweir // ----------------------------------------------------------------------------- selectAccessibleChild(sal_Int32 nChildIndex)245cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 248cdf0e10cSrcweir 249cdf0e10cSrcweir ensureAlive(); 250cdf0e10cSrcweir 251cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 252cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( nChildIndex ); 253cdf0e10cSrcweir if ( !pEntry ) 254cdf0e10cSrcweir throw IndexOutOfBoundsException(); 255cdf0e10cSrcweir 256cdf0e10cSrcweir pCtrl->SetCursor( pEntry ); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir // ----------------------------------------------------------------------------- isAccessibleChildSelected(sal_Int32 nChildIndex)259cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleIconChoiceCtrl::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir ensureAlive(); 264cdf0e10cSrcweir 265cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 266cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( nChildIndex ); 267cdf0e10cSrcweir if ( !pEntry ) 268cdf0e10cSrcweir throw IndexOutOfBoundsException(); 269cdf0e10cSrcweir 270cdf0e10cSrcweir return ( pCtrl->GetCursor() == pEntry ); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir // ----------------------------------------------------------------------------- clearAccessibleSelection()273cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::clearAccessibleSelection( ) throw (RuntimeException) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 276cdf0e10cSrcweir 277cdf0e10cSrcweir ensureAlive(); 278cdf0e10cSrcweir getCtrl()->SetNoSelection(); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir // ----------------------------------------------------------------------------- selectAllAccessibleChildren()281cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::selectAllAccessibleChildren( ) throw (RuntimeException) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 284cdf0e10cSrcweir 285cdf0e10cSrcweir ensureAlive(); 286cdf0e10cSrcweir 287cdf0e10cSrcweir sal_Int32 i, nCount = 0; 288cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 289cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 290cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 293cdf0e10cSrcweir if ( pCtrl->GetCursor() != pEntry ) 294cdf0e10cSrcweir pCtrl->SetCursor( pEntry ); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir } 297cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSelectedAccessibleChildCount()298cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChildCount( ) throw (RuntimeException) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir ensureAlive(); 303cdf0e10cSrcweir 304cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 305cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 306cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 307cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 310cdf0e10cSrcweir if ( pCtrl->GetCursor() == pEntry ) 311cdf0e10cSrcweir ++nSelCount; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir return nSelCount; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir // ----------------------------------------------------------------------------- getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)317cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir ensureAlive(); 322cdf0e10cSrcweir 323cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 324cdf0e10cSrcweir throw IndexOutOfBoundsException(); 325cdf0e10cSrcweir 326cdf0e10cSrcweir Reference< XAccessible > xChild; 327cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 328cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 329cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 330cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 333cdf0e10cSrcweir if ( pCtrl->GetCursor() == pEntry ) 334cdf0e10cSrcweir ++nSelCount; 335cdf0e10cSrcweir 336cdf0e10cSrcweir if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, i, this ); 339cdf0e10cSrcweir break; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir return xChild; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir // ----------------------------------------------------------------------------- deselectAccessibleChild(sal_Int32 nSelectedChildIndex)346cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir ensureAlive(); 351cdf0e10cSrcweir 352cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getAccessibleChildCount() ) 353cdf0e10cSrcweir throw IndexOutOfBoundsException(); 354cdf0e10cSrcweir 355cdf0e10cSrcweir Reference< XAccessible > xChild; 356cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 357cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 358cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 359cdf0e10cSrcweir bool bFound = false; 360cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 363cdf0e10cSrcweir if ( pEntry->IsSelected() ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir ++nSelCount; 366cdf0e10cSrcweir if ( i == nSelectedChildIndex ) 367cdf0e10cSrcweir bFound = true; 368cdf0e10cSrcweir } 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371*07a3d7f1SPedro Giffuni // if only one entry is selected and its index is chosen to deselect -> no selection anymore 372cdf0e10cSrcweir if ( 1 == nSelCount && bFound ) 373cdf0e10cSrcweir pCtrl->SetNoSelection(); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir // ----------------------------------------------------------------------------- FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)376cdf0e10cSrcweir void AccessibleIconChoiceCtrl::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); 379cdf0e10cSrcweir if ( isAlive() ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 382cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 383cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SELECTABLE ); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir // ----------------------------------------------------------------------------- getCtrl()387cdf0e10cSrcweir SvtIconChoiceCtrl* AccessibleIconChoiceCtrl::getCtrl() 388cdf0e10cSrcweir { 389cdf0e10cSrcweir return static_cast<SvtIconChoiceCtrl*>(GetWindow()); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir //........................................................................ 393cdf0e10cSrcweir }// namespace accessibility 394cdf0e10cSrcweir //........................................................................ 395