update dev300-m58
[ooovba.git] / accessibility / source / extended / accessibleiconchoicectrlentry.cxx
blob4b58b967b1eca6a6e666fadee057a2da9ce412c5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibleiconchoicectrlentry.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include <accessibility/extended/accessibleiconchoicectrlentry.hxx>
34 #include <svtools/ivctrl.hxx>
35 #include <com/sun/star/awt/Point.hpp>
36 #include <com/sun/star/awt/Rectangle.hpp>
37 #include <com/sun/star/awt/Size.hpp>
38 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39 #include <com/sun/star/accessibility/AccessibleRole.hpp>
40 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41 #include <tools/debug.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/controllayout.hxx>
44 #include <toolkit/awt/vclxwindow.hxx>
45 #include <toolkit/helper/convert.hxx>
46 #include <unotools/accessiblestatesethelper.hxx>
47 #include <unotools/accessiblerelationsethelper.hxx>
48 #include <cppuhelper/typeprovider.hxx>
49 #include <comphelper/sequence.hxx>
50 #include <svtools/stringtransfer.hxx>
51 #include <comphelper/accessibleeventnotifier.hxx>
53 #define ACCESSIBLE_ACTION_COUNT 1
54 #define AID_EXPAND 0
55 #define AID_COLLAPSE 1
57 namespace
59 void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
61 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
62 // only three actions
63 throw ::com::sun::star::lang::IndexOutOfBoundsException();
67 //........................................................................
68 namespace accessibility
70 //........................................................................
71 // class ALBSolarGuard ---------------------------------------------------------
73 /** Aquire the solar mutex. */
74 class ALBSolarGuard : public ::vos::OGuard
76 public:
77 inline ALBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
80 // class AccessibleIconChoiceCtrlEntry -----------------------------------------------------
82 using namespace ::com::sun::star::accessibility;
83 using namespace ::com::sun::star::uno;
84 using namespace ::com::sun::star::lang;
85 using namespace ::com::sun::star;
87 DBG_NAME(AccessibleIconChoiceCtrlEntry)
89 // -----------------------------------------------------------------------------
90 // Ctor() and Dtor()
91 // -----------------------------------------------------------------------------
92 AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
93 ULONG _nPos,
94 const Reference< XAccessible >& _xParent ) :
96 AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ),
98 m_pIconCtrl ( &_rIconCtrl ),
99 m_nIndex ( _nPos ),
100 m_nClientId ( 0 ),
101 m_xParent ( _xParent )
104 osl_incrementInterlockedCount( &m_refCount );
106 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
107 if ( xComp.is() )
108 xComp->addEventListener( this );
110 osl_decrementInterlockedCount( &m_refCount );
112 DBG_CTOR( AccessibleIconChoiceCtrlEntry, NULL );
114 // -----------------------------------------------------------------------------
115 void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
116 throw(RuntimeException)
118 if ( _rSource.Source == m_xParent )
120 dispose();
121 DBG_ASSERT( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" );
124 // -----------------------------------------------------------------------------
125 AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
127 DBG_DTOR( AccessibleIconChoiceCtrlEntry, NULL );
129 if ( IsAlive_Impl() )
131 // increment ref count to prevent double call of Dtor
132 osl_incrementInterlockedCount( &m_refCount );
133 dispose();
136 #ifdef ACCESSIBLE_EVENT_NOTIFICATION_ENABLED
137 // (the following method is unused currently. If you need it, simply remove the #ifdef thing here and
138 // in the hxx)
139 // -----------------------------------------------------------------------------
140 void AccessibleIconChoiceCtrlEntry::NotifyAccessibleEvent( sal_Int16 _nEventId,
141 const ::com::sun::star::uno::Any& _aOldValue,
142 const ::com::sun::star::uno::Any& _aNewValue )
144 Reference< uno::XInterface > xSource( *this );
145 AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue );
147 if (m_nClientId)
148 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj );
150 #endif
151 // -----------------------------------------------------------------------------
152 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
154 Rectangle aRect;
155 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
156 if ( pEntry )
157 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
159 return aRect;
161 // -----------------------------------------------------------------------------
162 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
164 Rectangle aRect;
165 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
166 if ( pEntry )
168 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
169 Point aTopLeft = aRect.TopLeft();
170 aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
171 aRect = Rectangle( aTopLeft, aRect.GetSize() );
174 return aRect;
176 // -----------------------------------------------------------------------------
177 sal_Bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
179 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
181 // -----------------------------------------------------------------------------
182 sal_Bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
184 sal_Bool bShowing = sal_False;
185 Reference< XAccessibleContext > m_xParentContext =
186 m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
187 if( m_xParentContext.is() )
189 Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
190 if( xParentComp.is() )
191 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
194 return bShowing;
196 // -----------------------------------------------------------------------------
197 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox() throw ( lang::DisposedException )
199 ALBSolarGuard aSolarGuard;
200 ::osl::MutexGuard aGuard( m_aMutex );
202 EnsureIsAlive();
203 return GetBoundingBox_Impl();
205 // -----------------------------------------------------------------------------
206 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException )
208 ALBSolarGuard aSolarGuard;
209 ::osl::MutexGuard aGuard( m_aMutex );
211 EnsureIsAlive();
212 return GetBoundingBoxOnScreen_Impl();
214 // -----------------------------------------------------------------------------
215 void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
217 if ( !IsAlive_Impl() )
218 throw lang::DisposedException();
220 // -----------------------------------------------------------------------------
221 ::rtl::OUString AccessibleIconChoiceCtrlEntry::implGetText()
223 ::rtl::OUString sRet;
224 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
225 if ( pEntry )
226 sRet = pEntry->GetDisplayText();
227 return sRet;
229 // -----------------------------------------------------------------------------
230 Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
232 Locale aLocale;
233 aLocale = Application::GetSettings().GetUILocale();
235 return aLocale;
237 void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
239 nStartIndex = 0;
240 nEndIndex = 0;
242 // -----------------------------------------------------------------------------
243 // XTypeProvider
244 // -----------------------------------------------------------------------------
245 // -----------------------------------------------------------------------------
246 Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException)
248 static ::cppu::OImplementationId* pId = NULL;
250 if ( !pId )
252 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
254 if ( !pId )
256 static ::cppu::OImplementationId aId;
257 pId = &aId;
260 return pId->getImplementationId();
262 // -----------------------------------------------------------------------------
263 // XComponent
264 // -----------------------------------------------------------------------------
265 void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
267 ::osl::MutexGuard aGuard( m_aMutex );
269 // Send a disposing to all listeners.
270 if ( m_nClientId )
272 sal_uInt32 nId = m_nClientId;
273 m_nClientId = 0;
274 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
277 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
278 if ( xComp.is() )
279 xComp->removeEventListener( this );
281 m_pIconCtrl = NULL;
282 m_xParent = NULL;
284 // -----------------------------------------------------------------------------
285 // XServiceInfo
286 // -----------------------------------------------------------------------------
287 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException)
289 return getImplementationName_Static();
291 // -----------------------------------------------------------------------------
292 Sequence< ::rtl::OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException)
294 return getSupportedServiceNames_Static();
296 // -----------------------------------------------------------------------------
297 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
299 Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
300 const ::rtl::OUString* pSupported = aSupported.getConstArray();
301 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
302 for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
305 return pSupported != pEnd;
307 // -----------------------------------------------------------------------------
308 // XServiceInfo - static methods
309 // -----------------------------------------------------------------------------
310 Sequence< ::rtl::OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static(void) throw( RuntimeException )
312 Sequence< ::rtl::OUString > aSupported(3);
313 aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext") );
314 aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleComponent") );
315 aSupported[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.AccessibleIconChoiceControlEntry") );
316 return aSupported;
318 // -----------------------------------------------------------------------------
319 ::rtl::OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static(void) throw( RuntimeException )
321 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry") );
323 // -----------------------------------------------------------------------------
324 // XAccessible
325 // -----------------------------------------------------------------------------
326 Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) throw (RuntimeException)
328 EnsureIsAlive();
329 return this;
331 // -----------------------------------------------------------------------------
332 // XAccessibleContext
333 // -----------------------------------------------------------------------------
334 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) throw (RuntimeException)
336 return 0; // no children
338 // -----------------------------------------------------------------------------
339 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException)
341 throw IndexOutOfBoundsException();
343 // -----------------------------------------------------------------------------
344 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) throw (RuntimeException)
346 ::osl::MutexGuard aGuard( m_aMutex );
348 EnsureIsAlive();
349 return m_xParent;
351 // -----------------------------------------------------------------------------
352 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) throw (RuntimeException)
354 ::osl::MutexGuard aGuard( m_aMutex );
356 return m_nIndex;
358 // -----------------------------------------------------------------------------
359 sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) throw (RuntimeException)
361 return AccessibleRole::LABEL;
363 // -----------------------------------------------------------------------------
364 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) throw (RuntimeException)
366 // no description for every item
367 return ::rtl::OUString();
369 // -----------------------------------------------------------------------------
370 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) throw (RuntimeException)
372 ::osl::MutexGuard aGuard( m_aMutex );
374 EnsureIsAlive();
375 return implGetText();
377 // -----------------------------------------------------------------------------
378 Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) throw (RuntimeException)
380 return new utl::AccessibleRelationSetHelper;
382 // -----------------------------------------------------------------------------
383 Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) throw (RuntimeException)
385 ALBSolarGuard aSolarGuard;
386 ::osl::MutexGuard aGuard( m_aMutex );
388 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
389 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
391 if ( IsAlive_Impl() )
393 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
394 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
395 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
396 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
397 if ( IsShowing_Impl() )
399 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
400 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
403 if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
404 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
406 else
407 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
409 return xStateSet;
411 // -----------------------------------------------------------------------------
412 Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
414 ALBSolarGuard aSolarGuard;
415 ::osl::MutexGuard aGuard( m_aMutex );
417 return implGetLocale();
419 // -----------------------------------------------------------------------------
420 // XAccessibleComponent
421 // -----------------------------------------------------------------------------
422 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException)
424 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
426 // -----------------------------------------------------------------------------
427 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
429 return Reference< XAccessible >();
431 // -----------------------------------------------------------------------------
432 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) throw (RuntimeException)
434 return AWTRectangle( GetBoundingBox() );
436 // -----------------------------------------------------------------------------
437 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) throw (RuntimeException)
439 return AWTPoint( GetBoundingBox().TopLeft() );
441 // -----------------------------------------------------------------------------
442 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) throw (RuntimeException)
444 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
446 // -----------------------------------------------------------------------------
447 awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) throw (RuntimeException)
449 return AWTSize( GetBoundingBox().GetSize() );
451 // -----------------------------------------------------------------------------
452 void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) throw (RuntimeException)
454 // do nothing, because no focus for each item
456 // -----------------------------------------------------------------------------
457 sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException)
459 ALBSolarGuard aSolarGuard;
460 ::osl::MutexGuard aGuard( m_aMutex );
462 sal_Int32 nColor = 0;
463 Reference< XAccessible > xParent = getAccessibleParent();
464 if ( xParent.is() )
466 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
467 if ( xParentComp.is() )
468 nColor = xParentComp->getForeground();
471 return nColor;
473 // -----------------------------------------------------------------------------
474 sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) throw (RuntimeException)
476 ALBSolarGuard aSolarGuard;
477 ::osl::MutexGuard aGuard( m_aMutex );
479 sal_Int32 nColor = 0;
480 Reference< XAccessible > xParent = getAccessibleParent();
481 if ( xParent.is() )
483 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
484 if ( xParentComp.is() )
485 nColor = xParentComp->getBackground();
488 return nColor;
490 // -----------------------------------------------------------------------------
491 // XAccessibleText
492 // -----------------------------------------------------------------------------
493 // -----------------------------------------------------------------------------
494 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
496 ALBSolarGuard aSolarGuard;
497 ::osl::MutexGuard aGuard( m_aMutex );
499 if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
500 throw IndexOutOfBoundsException();
502 awt::Rectangle aBounds( 0, 0, 0, 0 );
503 if ( m_pIconCtrl )
505 Rectangle aItemRect = GetBoundingBox_Impl();
506 Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
507 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
508 aBounds = AWTRectangle( aCharRect );
511 return aBounds;
513 // -----------------------------------------------------------------------------
514 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
516 ALBSolarGuard aSolarGuard;
517 ::osl::MutexGuard aGuard( m_aMutex );
519 sal_Int32 nIndex = -1;
520 if ( m_pIconCtrl )
522 ::vcl::ControlLayoutData aLayoutData;
523 Rectangle aItemRect = GetBoundingBox_Impl();
524 m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
525 Point aPnt( VCLPoint( aPoint ) );
526 aPnt += aItemRect.TopLeft();
527 nIndex = aLayoutData.GetIndexForPoint( aPnt );
529 long nLen = aLayoutData.m_aUnicodeBoundRects.size();
530 for ( long i = 0; i < nLen; ++i )
532 Rectangle aRect = aLayoutData.GetCharacterBounds(i);
533 BOOL bInside = aRect.IsInside( aPnt );
535 if ( bInside )
536 break;
540 return nIndex;
542 // -----------------------------------------------------------------------------
543 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
545 ALBSolarGuard aSolarGuard;
546 ::osl::MutexGuard aGuard( m_aMutex );
548 String sText = getText();
549 if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex )
550 || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) )
551 throw IndexOutOfBoundsException();
553 sal_Int32 nLen = nEndIndex - nStartIndex + 1;
554 ::svt::OStringTransfer::CopyString( sText.Copy( (USHORT)nStartIndex, (USHORT)nLen ), m_pIconCtrl );
556 return sal_True;
558 // -----------------------------------------------------------------------------
559 // XAccessibleEventBroadcaster
560 // -----------------------------------------------------------------------------
561 void SAL_CALL AccessibleIconChoiceCtrlEntry::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
563 if (xListener.is())
565 ::osl::MutexGuard aGuard( m_aMutex );
566 if (!m_nClientId)
567 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
568 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
571 // -----------------------------------------------------------------------------
572 void SAL_CALL AccessibleIconChoiceCtrlEntry::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
574 if (xListener.is())
576 ::osl::MutexGuard aGuard( m_aMutex );
578 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
579 if ( !nListenerCount )
581 // no listeners anymore
582 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
583 // and at least to us not firing any events anymore, in case somebody calls
584 // NotifyAccessibleEvent, again
585 sal_Int32 nId = m_nClientId;
586 m_nClientId = 0;
587 comphelper::AccessibleEventNotifier::revokeClient( nId );
592 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
594 return -1;
596 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
598 ALBSolarGuard aSolarGuard;
599 ::osl::MutexGuard aGuard( m_aMutex );
600 EnsureIsAlive();
602 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
603 throw IndexOutOfBoundsException();
605 return sal_False;
607 sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
609 ALBSolarGuard aSolarGuard;
610 ::osl::MutexGuard aGuard( m_aMutex );
611 EnsureIsAlive();
612 return OCommonAccessibleText::getCharacter( nIndex );
614 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
616 ALBSolarGuard aSolarGuard;
617 ::osl::MutexGuard aGuard( m_aMutex );
618 EnsureIsAlive();
620 ::rtl::OUString sText( implGetText() );
622 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
623 throw IndexOutOfBoundsException();
625 return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
627 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
629 ALBSolarGuard aSolarGuard;
630 ::osl::MutexGuard aGuard( m_aMutex );
631 EnsureIsAlive();
632 return OCommonAccessibleText::getCharacterCount( );
635 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
637 ALBSolarGuard aSolarGuard;
638 ::osl::MutexGuard aGuard( m_aMutex );
639 EnsureIsAlive();
640 return OCommonAccessibleText::getSelectedText( );
642 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
644 ALBSolarGuard aSolarGuard;
645 ::osl::MutexGuard aGuard( m_aMutex );
646 EnsureIsAlive();
647 return OCommonAccessibleText::getSelectionStart( );
649 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
651 ALBSolarGuard aSolarGuard;
652 ::osl::MutexGuard aGuard( m_aMutex );
653 EnsureIsAlive();
654 return OCommonAccessibleText::getSelectionEnd( );
656 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
658 ALBSolarGuard aSolarGuard;
659 ::osl::MutexGuard aGuard( m_aMutex );
660 EnsureIsAlive();
662 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
663 throw IndexOutOfBoundsException();
665 return sal_False;
667 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) throw (::com::sun::star::uno::RuntimeException)
669 ALBSolarGuard aSolarGuard;
670 ::osl::MutexGuard aGuard( m_aMutex );
671 EnsureIsAlive();
672 return OCommonAccessibleText::getText( );
674 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
676 ALBSolarGuard aSolarGuard;
677 ::osl::MutexGuard aGuard( m_aMutex );
678 EnsureIsAlive();
679 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
681 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
683 ALBSolarGuard aSolarGuard;
684 ::osl::MutexGuard aGuard( m_aMutex );
685 EnsureIsAlive();
686 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
688 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
690 ALBSolarGuard aSolarGuard;
691 ::osl::MutexGuard aGuard( m_aMutex );
692 EnsureIsAlive();
693 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
695 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleIconChoiceCtrlEntry::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
697 ALBSolarGuard aSolarGuard;
698 ::osl::MutexGuard aGuard( m_aMutex );
699 EnsureIsAlive();
701 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
704 // -----------------------------------------------------------------------------
705 // XAccessibleAction
706 // -----------------------------------------------------------------------------
707 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) throw (RuntimeException)
709 ::osl::MutexGuard aGuard( m_aMutex );
711 // three actions supported
712 return ACCESSIBLE_ACTION_COUNT;
714 // -----------------------------------------------------------------------------
715 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
717 ALBSolarGuard aSolarGuard;
718 ::osl::MutexGuard aGuard( m_aMutex );
720 sal_Bool bRet = sal_False;
721 checkActionIndex_Impl( nIndex );
722 EnsureIsAlive();
724 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
725 if ( pEntry && !pEntry->IsSelected() )
727 m_pIconCtrl->SetNoSelection();
728 m_pIconCtrl->SetCursor( pEntry );
729 bRet = sal_True;
732 return bRet;
734 // -----------------------------------------------------------------------------
735 ::rtl::OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
737 ALBSolarGuard aSolarGuard;
738 ::osl::MutexGuard aGuard( m_aMutex );
740 checkActionIndex_Impl( nIndex );
741 EnsureIsAlive();
743 static const ::rtl::OUString sActionDesc( RTL_CONSTASCII_USTRINGPARAM( "Select" ) );
744 return sActionDesc;
746 // -----------------------------------------------------------------------------
747 Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
749 ::osl::MutexGuard aGuard( m_aMutex );
751 Reference< XAccessibleKeyBinding > xRet;
752 checkActionIndex_Impl( nIndex );
753 // ... which key?
754 return xRet;
756 //........................................................................
757 }// namespace accessibility
758 //........................................................................