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