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/accessibleiconchoicectrl.hxx" 31*cdf0e10cSrcweir #include "accessibility/extended/accessibleiconchoicectrlentry.hxx" 32*cdf0e10cSrcweir #include <svtools/ivctrl.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 37*cdf0e10cSrcweir #include <tools/debug.hxx> 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir //........................................................................ 42*cdf0e10cSrcweir namespace accessibility 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir //........................................................................ 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir // class AccessibleIconChoiceCtrl ---------------------------------------------- 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 49*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 51*cdf0e10cSrcweir using namespace ::com::sun::star; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir DBG_NAME(AccessibleIconChoiceCtrl) 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 56*cdf0e10cSrcweir // Ctor() and Dtor() 57*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 58*cdf0e10cSrcweir AccessibleIconChoiceCtrl::AccessibleIconChoiceCtrl( SvtIconChoiceCtrl& _rIconCtrl, const Reference< XAccessible >& _xParent ) : 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir VCLXAccessibleComponent( _rIconCtrl.GetWindowPeer() ), 61*cdf0e10cSrcweir m_xParent ( _xParent ) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir DBG_CTOR( AccessibleIconChoiceCtrl, NULL ); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 66*cdf0e10cSrcweir AccessibleIconChoiceCtrl::~AccessibleIconChoiceCtrl() 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir DBG_DTOR( AccessibleIconChoiceCtrl, NULL ); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 71*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(AccessibleIconChoiceCtrl, VCLXAccessibleComponent, AccessibleIconChoiceCtrl_BASE) 72*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleIconChoiceCtrl, VCLXAccessibleComponent, AccessibleIconChoiceCtrl_BASE) 73*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 74*cdf0e10cSrcweir void AccessibleIconChoiceCtrl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir if ( isAlive() ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir case VCLEVENT_LISTBOX_SELECT : 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir // First send an event that tells the listeners of a 83*cdf0e10cSrcweir // modified selection. The active descendant event is 84*cdf0e10cSrcweir // send after that so that the receiving AT has time to 85*cdf0e10cSrcweir // read the text or name of the active child. 86*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); 87*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 88*cdf0e10cSrcweir if ( pCtrl && pCtrl->HasFocus() ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); 91*cdf0e10cSrcweir if ( pEntry ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir sal_uLong nPos = pCtrl->GetEntryListPos( pEntry ); 94*cdf0e10cSrcweir Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, nPos, this ); 95*cdf0e10cSrcweir uno::Any aOldValue, aNewValue; 96*cdf0e10cSrcweir aNewValue <<= xChild; 97*cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir break; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir default: 103*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowChildEvent (rVclWindowEvent); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 108*cdf0e10cSrcweir // XComponent 109*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 110*cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::disposing() 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir m_xParent = NULL; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 117*cdf0e10cSrcweir // XServiceInfo 118*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getImplementationName() throw (RuntimeException) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir return getImplementationName_Static(); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 124*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL AccessibleIconChoiceCtrl::getSupportedServiceNames() throw (RuntimeException) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 129*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleIconChoiceCtrl::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); 132*cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 133*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 134*cdf0e10cSrcweir for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported ) 135*cdf0e10cSrcweir ; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir return pSupported != pEnd; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 140*cdf0e10cSrcweir // XServiceInfo - static methods 141*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 142*cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleIconChoiceCtrl::getSupportedServiceNames_Static(void) throw (RuntimeException) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(3); 145*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") ); 146*cdf0e10cSrcweir aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") ); 147*cdf0e10cSrcweir aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleIconChoiceControl") ); 148*cdf0e10cSrcweir return aSupported; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 151*cdf0e10cSrcweir ::rtl::OUString AccessibleIconChoiceCtrl::getImplementationName_Static(void) throw (RuntimeException) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleIconChoiceControl") ); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 156*cdf0e10cSrcweir // XAccessible 157*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 158*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleContext( ) throw (RuntimeException) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir ensureAlive(); 161*cdf0e10cSrcweir return this; 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 164*cdf0e10cSrcweir // XAccessibleContext 165*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleIconChoiceCtrl::getAccessibleChildCount( ) throw (RuntimeException) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir ensureAlive(); 171*cdf0e10cSrcweir return getCtrl()->GetEntryCount(); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 174*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleChild( sal_Int32 i ) throw (RuntimeException, IndexOutOfBoundsException) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir ensureAlive(); 179*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 180*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry(i); 181*cdf0e10cSrcweir if ( !pEntry ) 182*cdf0e10cSrcweir throw RuntimeException(); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir return new AccessibleIconChoiceCtrlEntry( *pCtrl, i, this ); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 187*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getAccessibleParent( ) throw (RuntimeException) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir ensureAlive(); 192*cdf0e10cSrcweir return m_xParent; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleIconChoiceCtrl::getAccessibleRole( ) throw (RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir return AccessibleRole::TREE; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 200*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getAccessibleDescription( ) throw (RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir ensureAlive(); 205*cdf0e10cSrcweir return getCtrl()->GetAccessibleDescription(); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 208*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrl::getAccessibleName( ) throw (RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir ensureAlive(); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir ::rtl::OUString sName = getCtrl()->GetAccessibleName(); 215*cdf0e10cSrcweir if ( sName.getLength() == 0 ) 216*cdf0e10cSrcweir sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IconChoiceControl" ) ); 217*cdf0e10cSrcweir return sName; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 220*cdf0e10cSrcweir // XAccessibleSelection 221*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 222*cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ensureAlive(); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 229*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( nChildIndex ); 230*cdf0e10cSrcweir if ( !pEntry ) 231*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir pCtrl->SetCursor( pEntry ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 236*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleIconChoiceCtrl::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir ensureAlive(); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 243*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( nChildIndex ); 244*cdf0e10cSrcweir if ( !pEntry ) 245*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir return ( pCtrl->GetCursor() == pEntry ); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 250*cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::clearAccessibleSelection( ) throw (RuntimeException) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir ensureAlive(); 255*cdf0e10cSrcweir getCtrl()->SetNoSelection(); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 258*cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::selectAllAccessibleChildren( ) throw (RuntimeException) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir ensureAlive(); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir sal_Int32 i, nCount = 0; 265*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 266*cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 267*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 270*cdf0e10cSrcweir if ( pCtrl->GetCursor() != pEntry ) 271*cdf0e10cSrcweir pCtrl->SetCursor( pEntry ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 275*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChildCount( ) throw (RuntimeException) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir ensureAlive(); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 282*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 283*cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 284*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 287*cdf0e10cSrcweir if ( pCtrl->GetCursor() == pEntry ) 288*cdf0e10cSrcweir ++nSelCount; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir return nSelCount; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 294*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir ensureAlive(); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() ) 301*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir Reference< XAccessible > xChild; 304*cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 305*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 306*cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 307*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 310*cdf0e10cSrcweir if ( pCtrl->GetCursor() == pEntry ) 311*cdf0e10cSrcweir ++nSelCount; 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir if ( nSelCount == ( nSelectedChildIndex + 1 ) ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, i, this ); 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir return xChild; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 323*cdf0e10cSrcweir void SAL_CALL AccessibleIconChoiceCtrl::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir ::comphelper::OExternalLockGuard aGuard( this ); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir ensureAlive(); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getAccessibleChildCount() ) 330*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir Reference< XAccessible > xChild; 333*cdf0e10cSrcweir sal_Int32 i, nSelCount = 0, nCount = 0; 334*cdf0e10cSrcweir SvtIconChoiceCtrl* pCtrl = getCtrl(); 335*cdf0e10cSrcweir nCount = pCtrl->GetEntryCount(); 336*cdf0e10cSrcweir bool bFound = false; 337*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); 340*cdf0e10cSrcweir if ( pEntry->IsSelected() ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir ++nSelCount; 343*cdf0e10cSrcweir if ( i == nSelectedChildIndex ) 344*cdf0e10cSrcweir bFound = true; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir // if only one entry is selected and its index is choosen to deselect -> no selection anymore 349*cdf0e10cSrcweir if ( 1 == nSelCount && bFound ) 350*cdf0e10cSrcweir pCtrl->SetNoSelection(); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 353*cdf0e10cSrcweir void AccessibleIconChoiceCtrl::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); 356*cdf0e10cSrcweir if ( isAlive() ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE ); 359*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 360*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SELECTABLE ); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 364*cdf0e10cSrcweir SvtIconChoiceCtrl* AccessibleIconChoiceCtrl::getCtrl() 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir return static_cast<SvtIconChoiceCtrl*>(GetWindow()); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir //........................................................................ 370*cdf0e10cSrcweir }// namespace accessibility 371*cdf0e10cSrcweir //........................................................................ 372*cdf0e10cSrcweir 373