Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / accessibility / source / extended / accessibleiconchoicectrlentry.cxx
blobfd739fb3941c634c0e6b7b16b64baded96ded0e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <accessibility/extended/accessibleiconchoicectrlentry.hxx>
21 #include <svtools/ivctrl.hxx>
22 #include <com/sun/star/awt/Point.hpp>
23 #include <com/sun/star/awt/Rectangle.hpp>
24 #include <com/sun/star/awt/Size.hpp>
25 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 #include <vcl/svapp.hxx>
29 #include <vcl/controllayout.hxx>
30 #include <toolkit/awt/vclxwindow.hxx>
31 #include <toolkit/helper/convert.hxx>
32 #include <unotools/accessiblestatesethelper.hxx>
33 #include <unotools/accessiblerelationsethelper.hxx>
34 #include <cppuhelper/supportsservice.hxx>
35 #include <cppuhelper/typeprovider.hxx>
36 #include <comphelper/sequence.hxx>
37 #include <svtools/stringtransfer.hxx>
38 #include <comphelper/accessibleeventnotifier.hxx>
40 #define ACCESSIBLE_ACTION_COUNT 1
42 namespace
44 void checkActionIndex_Impl( sal_Int32 _nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
46 if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
47 // only three actions
48 throw ::com::sun::star::lang::IndexOutOfBoundsException();
52 //........................................................................
53 namespace accessibility
56 // class AccessibleIconChoiceCtrlEntry -----------------------------------------------------
58 using namespace ::com::sun::star::accessibility;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star;
63 // -----------------------------------------------------------------------------
64 // Ctor() and Dtor()
65 // -----------------------------------------------------------------------------
66 AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
67 sal_uLong _nPos,
68 const Reference< XAccessible >& _xParent ) :
70 AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ),
72 m_pIconCtrl ( &_rIconCtrl ),
73 m_nIndex ( _nPos ),
74 m_nClientId ( 0 ),
75 m_xParent ( _xParent )
78 osl_atomic_increment( &m_refCount );
80 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
81 if ( xComp.is() )
82 xComp->addEventListener( this );
84 osl_atomic_decrement( &m_refCount );
86 // -----------------------------------------------------------------------------
87 void AccessibleIconChoiceCtrlEntry::disposing( const EventObject& _rSource )
88 throw(RuntimeException)
90 if ( _rSource.Source == m_xParent )
92 dispose();
93 OSL_ENSURE( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" );
96 // -----------------------------------------------------------------------------
97 AccessibleIconChoiceCtrlEntry::~AccessibleIconChoiceCtrlEntry()
99 if ( IsAlive_Impl() )
101 // increment ref count to prevent double call of Dtor
102 osl_atomic_increment( &m_refCount );
103 dispose();
106 // -----------------------------------------------------------------------------
107 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox_Impl() const
109 Rectangle aRect;
110 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
111 if ( pEntry )
112 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
114 return aRect;
116 // -----------------------------------------------------------------------------
117 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen_Impl() const
119 Rectangle aRect;
120 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
121 if ( pEntry )
123 aRect = m_pIconCtrl->GetBoundingBox( pEntry );
124 Point aTopLeft = aRect.TopLeft();
125 aTopLeft += m_pIconCtrl->GetWindowExtentsRelative( NULL ).TopLeft();
126 aRect = Rectangle( aTopLeft, aRect.GetSize() );
129 return aRect;
131 // -----------------------------------------------------------------------------
132 sal_Bool AccessibleIconChoiceCtrlEntry::IsAlive_Impl() const
134 return ( !rBHelper.bDisposed && !rBHelper.bInDispose && m_pIconCtrl );
136 // -----------------------------------------------------------------------------
137 sal_Bool AccessibleIconChoiceCtrlEntry::IsShowing_Impl() const
139 sal_Bool bShowing = sal_False;
140 Reference< XAccessibleContext > m_xParentContext =
141 m_xParent.is() ? m_xParent->getAccessibleContext() : Reference< XAccessibleContext >();
142 if( m_xParentContext.is() )
144 Reference< XAccessibleComponent > xParentComp( m_xParentContext, uno::UNO_QUERY );
145 if( xParentComp.is() )
146 bShowing = GetBoundingBox_Impl().IsOver( VCLRectangle( xParentComp->getBounds() ) );
149 return bShowing;
151 // -----------------------------------------------------------------------------
152 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBox() throw ( lang::DisposedException )
154 SolarMutexGuard aSolarGuard;
155 ::osl::MutexGuard aGuard( m_aMutex );
157 EnsureIsAlive();
158 return GetBoundingBox_Impl();
160 // -----------------------------------------------------------------------------
161 Rectangle AccessibleIconChoiceCtrlEntry::GetBoundingBoxOnScreen() throw ( lang::DisposedException )
163 SolarMutexGuard aSolarGuard;
164 ::osl::MutexGuard aGuard( m_aMutex );
166 EnsureIsAlive();
167 return GetBoundingBoxOnScreen_Impl();
169 // -----------------------------------------------------------------------------
170 void AccessibleIconChoiceCtrlEntry::EnsureIsAlive() const throw ( lang::DisposedException )
172 if ( !IsAlive_Impl() )
173 throw lang::DisposedException();
175 // -----------------------------------------------------------------------------
176 OUString AccessibleIconChoiceCtrlEntry::implGetText()
178 OUString sRet;
179 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
180 if ( pEntry )
181 sRet = pEntry->GetDisplayText();
182 return sRet;
184 // -----------------------------------------------------------------------------
185 Locale AccessibleIconChoiceCtrlEntry::implGetLocale()
187 Locale aLocale;
188 aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
190 return aLocale;
192 void AccessibleIconChoiceCtrlEntry::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
194 nStartIndex = 0;
195 nEndIndex = 0;
197 // -----------------------------------------------------------------------------
198 // XTypeProvider
199 // -----------------------------------------------------------------------------
200 // -----------------------------------------------------------------------------
201 Sequence< sal_Int8 > AccessibleIconChoiceCtrlEntry::getImplementationId() throw (RuntimeException)
203 static ::cppu::OImplementationId* pId = NULL;
205 if ( !pId )
207 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
209 if ( !pId )
211 static ::cppu::OImplementationId aId;
212 pId = &aId;
215 return pId->getImplementationId();
217 // -----------------------------------------------------------------------------
218 // XComponent
219 // -----------------------------------------------------------------------------
220 void SAL_CALL AccessibleIconChoiceCtrlEntry::disposing()
222 ::osl::MutexGuard aGuard( m_aMutex );
224 // Send a disposing to all listeners.
225 if ( m_nClientId )
227 sal_uInt32 nId = m_nClientId;
228 m_nClientId = 0;
229 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
232 Reference< XComponent > xComp( m_xParent, UNO_QUERY );
233 if ( xComp.is() )
234 xComp->removeEventListener( this );
236 m_pIconCtrl = NULL;
237 m_xParent = NULL;
239 // -----------------------------------------------------------------------------
240 // XServiceInfo
241 // -----------------------------------------------------------------------------
242 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getImplementationName() throw(RuntimeException)
244 return getImplementationName_Static();
246 // -----------------------------------------------------------------------------
247 Sequence< OUString > SAL_CALL AccessibleIconChoiceCtrlEntry::getSupportedServiceNames() throw(RuntimeException)
249 return getSupportedServiceNames_Static();
251 // -----------------------------------------------------------------------------
252 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
254 return cppu::supportsService(this, _rServiceName);
256 // -----------------------------------------------------------------------------
257 // XServiceInfo - static methods
258 // -----------------------------------------------------------------------------
259 Sequence< OUString > AccessibleIconChoiceCtrlEntry::getSupportedServiceNames_Static(void) throw( RuntimeException )
261 Sequence< OUString > aSupported(3);
262 aSupported[0] = "com.sun.star.accessibility.AccessibleContext";
263 aSupported[1] = "com.sun.star.accessibility.AccessibleComponent";
264 aSupported[2] = "com.sun.star.awt.AccessibleIconChoiceControlEntry";
265 return aSupported;
267 // -----------------------------------------------------------------------------
268 OUString AccessibleIconChoiceCtrlEntry::getImplementationName_Static(void) throw( RuntimeException )
270 return OUString( "com.sun.star.comp.svtools.AccessibleIconChoiceControlEntry" );
272 // -----------------------------------------------------------------------------
273 // XAccessible
274 // -----------------------------------------------------------------------------
275 Reference< XAccessibleContext > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleContext( ) throw (RuntimeException)
277 EnsureIsAlive();
278 return this;
280 // -----------------------------------------------------------------------------
281 // XAccessibleContext
282 // -----------------------------------------------------------------------------
283 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChildCount( ) throw (RuntimeException)
285 return 0; // no children
287 // -----------------------------------------------------------------------------
288 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException,RuntimeException)
290 throw IndexOutOfBoundsException();
292 // -----------------------------------------------------------------------------
293 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleParent( ) throw (RuntimeException)
295 ::osl::MutexGuard aGuard( m_aMutex );
297 EnsureIsAlive();
298 return m_xParent;
300 // -----------------------------------------------------------------------------
301 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleIndexInParent( ) throw (RuntimeException)
303 ::osl::MutexGuard aGuard( m_aMutex );
305 return m_nIndex;
307 // -----------------------------------------------------------------------------
308 sal_Int16 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRole( ) throw (RuntimeException)
310 return AccessibleRole::LABEL;
312 // -----------------------------------------------------------------------------
313 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleDescription( ) throw (RuntimeException)
315 // no description for every item
316 return OUString();
318 // -----------------------------------------------------------------------------
319 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleName( ) throw (RuntimeException)
321 ::osl::MutexGuard aGuard( m_aMutex );
323 EnsureIsAlive();
324 return implGetText();
326 // -----------------------------------------------------------------------------
327 Reference< XAccessibleRelationSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleRelationSet( ) throw (RuntimeException)
329 return new utl::AccessibleRelationSetHelper;
331 // -----------------------------------------------------------------------------
332 Reference< XAccessibleStateSet > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleStateSet( ) throw (RuntimeException)
334 SolarMutexGuard aSolarGuard;
335 ::osl::MutexGuard aGuard( m_aMutex );
337 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
338 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
340 if ( IsAlive_Impl() )
342 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
343 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
344 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
345 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
346 if ( IsShowing_Impl() )
348 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
349 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
352 if ( m_pIconCtrl && m_pIconCtrl->GetCursor() == m_pIconCtrl->GetEntry( m_nIndex ) )
353 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
355 else
356 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
358 return xStateSet;
360 // -----------------------------------------------------------------------------
361 Locale SAL_CALL AccessibleIconChoiceCtrlEntry::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
363 SolarMutexGuard aSolarGuard;
364 ::osl::MutexGuard aGuard( m_aMutex );
366 return implGetLocale();
368 // -----------------------------------------------------------------------------
369 // XAccessibleComponent
370 // -----------------------------------------------------------------------------
371 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) throw (RuntimeException)
373 return Rectangle( Point(), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
375 // -----------------------------------------------------------------------------
376 Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
378 return Reference< XAccessible >();
380 // -----------------------------------------------------------------------------
381 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) throw (RuntimeException)
383 return AWTRectangle( GetBoundingBox() );
385 // -----------------------------------------------------------------------------
386 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) throw (RuntimeException)
388 return AWTPoint( GetBoundingBox().TopLeft() );
390 // -----------------------------------------------------------------------------
391 awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) throw (RuntimeException)
393 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
395 // -----------------------------------------------------------------------------
396 awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) throw (RuntimeException)
398 return AWTSize( GetBoundingBox().GetSize() );
400 // -----------------------------------------------------------------------------
401 void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) throw (RuntimeException)
403 // do nothing, because no focus for each item
405 // -----------------------------------------------------------------------------
406 sal_Int32 AccessibleIconChoiceCtrlEntry::getForeground( ) throw (RuntimeException)
408 SolarMutexGuard aSolarGuard;
409 ::osl::MutexGuard aGuard( m_aMutex );
411 sal_Int32 nColor = 0;
412 Reference< XAccessible > xParent = getAccessibleParent();
413 if ( xParent.is() )
415 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
416 if ( xParentComp.is() )
417 nColor = xParentComp->getForeground();
420 return nColor;
422 // -----------------------------------------------------------------------------
423 sal_Int32 AccessibleIconChoiceCtrlEntry::getBackground( ) throw (RuntimeException)
425 SolarMutexGuard aSolarGuard;
426 ::osl::MutexGuard aGuard( m_aMutex );
428 sal_Int32 nColor = 0;
429 Reference< XAccessible > xParent = getAccessibleParent();
430 if ( xParent.is() )
432 Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
433 if ( xParentComp.is() )
434 nColor = xParentComp->getBackground();
437 return nColor;
439 // -----------------------------------------------------------------------------
440 // XAccessibleText
441 // -----------------------------------------------------------------------------
442 // -----------------------------------------------------------------------------
443 awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterBounds( sal_Int32 _nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
445 SolarMutexGuard aSolarGuard;
446 ::osl::MutexGuard aGuard( m_aMutex );
448 if ( ( 0 > _nIndex ) || ( getCharacterCount() <= _nIndex ) )
449 throw IndexOutOfBoundsException();
451 awt::Rectangle aBounds( 0, 0, 0, 0 );
452 if ( m_pIconCtrl )
454 Rectangle aItemRect = GetBoundingBox_Impl();
455 Rectangle aCharRect = m_pIconCtrl->GetEntryCharacterBounds( m_nIndex, _nIndex );
456 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
457 aBounds = AWTRectangle( aCharRect );
460 return aBounds;
462 // -----------------------------------------------------------------------------
463 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
465 SolarMutexGuard aSolarGuard;
466 ::osl::MutexGuard aGuard( m_aMutex );
468 sal_Int32 nIndex = -1;
469 if ( m_pIconCtrl )
471 ::vcl::ControlLayoutData aLayoutData;
472 Rectangle aItemRect = GetBoundingBox_Impl();
473 m_pIconCtrl->RecordLayoutData( &aLayoutData, aItemRect );
474 Point aPnt( VCLPoint( aPoint ) );
475 aPnt += aItemRect.TopLeft();
476 nIndex = aLayoutData.GetIndexForPoint( aPnt );
478 long nLen = aLayoutData.m_aUnicodeBoundRects.size();
479 for ( long i = 0; i < nLen; ++i )
481 Rectangle aRect = aLayoutData.GetCharacterBounds(i);
482 sal_Bool bInside = aRect.IsInside( aPnt );
484 if ( bInside )
485 break;
489 return nIndex;
491 // -----------------------------------------------------------------------------
492 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
494 SolarMutexGuard aSolarGuard;
495 ::osl::MutexGuard aGuard( m_aMutex );
497 String sText = getText();
498 if ( ( 0 > nStartIndex ) || ( sText.Len() <= nStartIndex )
499 || ( 0 > nEndIndex ) || ( sText.Len() <= nEndIndex ) )
500 throw IndexOutOfBoundsException();
502 sal_Int32 nLen = nEndIndex - nStartIndex + 1;
503 ::svt::OStringTransfer::CopyString( sText.Copy( (sal_uInt16)nStartIndex, (sal_uInt16)nLen ), m_pIconCtrl );
505 return sal_True;
507 // -----------------------------------------------------------------------------
508 // XAccessibleEventBroadcaster
509 // -----------------------------------------------------------------------------
510 void SAL_CALL AccessibleIconChoiceCtrlEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
512 if (xListener.is())
514 ::osl::MutexGuard aGuard( m_aMutex );
515 if (!m_nClientId)
516 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
517 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
520 // -----------------------------------------------------------------------------
521 void SAL_CALL AccessibleIconChoiceCtrlEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
523 if (xListener.is())
525 ::osl::MutexGuard aGuard( m_aMutex );
527 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
528 if ( !nListenerCount )
530 // no listeners anymore
531 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
532 // and at least to us not firing any events anymore, in case somebody calls
533 // NotifyAccessibleEvent, again
534 sal_Int32 nId = m_nClientId;
535 m_nClientId = 0;
536 comphelper::AccessibleEventNotifier::revokeClient( nId );
541 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
543 return -1;
545 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
547 SolarMutexGuard aSolarGuard;
548 ::osl::MutexGuard aGuard( m_aMutex );
549 EnsureIsAlive();
551 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
552 throw IndexOutOfBoundsException();
554 return sal_False;
556 sal_Unicode SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
558 SolarMutexGuard aSolarGuard;
559 ::osl::MutexGuard aGuard( m_aMutex );
560 EnsureIsAlive();
561 return OCommonAccessibleText::getCharacter( nIndex );
563 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
565 SolarMutexGuard aSolarGuard;
566 ::osl::MutexGuard aGuard( m_aMutex );
567 EnsureIsAlive();
569 OUString sText( implGetText() );
571 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
572 throw IndexOutOfBoundsException();
574 return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
576 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
578 SolarMutexGuard aSolarGuard;
579 ::osl::MutexGuard aGuard( m_aMutex );
580 EnsureIsAlive();
581 return OCommonAccessibleText::getCharacterCount( );
584 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
586 SolarMutexGuard aSolarGuard;
587 ::osl::MutexGuard aGuard( m_aMutex );
588 EnsureIsAlive();
589 return OCommonAccessibleText::getSelectedText( );
591 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
593 SolarMutexGuard aSolarGuard;
594 ::osl::MutexGuard aGuard( m_aMutex );
595 EnsureIsAlive();
596 return OCommonAccessibleText::getSelectionStart( );
598 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
600 SolarMutexGuard aSolarGuard;
601 ::osl::MutexGuard aGuard( m_aMutex );
602 EnsureIsAlive();
603 return OCommonAccessibleText::getSelectionEnd( );
605 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
607 SolarMutexGuard aSolarGuard;
608 ::osl::MutexGuard aGuard( m_aMutex );
609 EnsureIsAlive();
611 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
612 throw IndexOutOfBoundsException();
614 return sal_False;
616 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getText( ) throw (::com::sun::star::uno::RuntimeException)
618 SolarMutexGuard aSolarGuard;
619 ::osl::MutexGuard aGuard( m_aMutex );
620 EnsureIsAlive();
621 return OCommonAccessibleText::getText( );
623 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
625 SolarMutexGuard aSolarGuard;
626 ::osl::MutexGuard aGuard( m_aMutex );
627 EnsureIsAlive();
628 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
630 ::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)
632 SolarMutexGuard aSolarGuard;
633 ::osl::MutexGuard aGuard( m_aMutex );
634 EnsureIsAlive();
635 return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
637 ::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)
639 SolarMutexGuard aSolarGuard;
640 ::osl::MutexGuard aGuard( m_aMutex );
641 EnsureIsAlive();
642 return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
644 ::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)
646 SolarMutexGuard aSolarGuard;
647 ::osl::MutexGuard aGuard( m_aMutex );
648 EnsureIsAlive();
650 return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
653 // -----------------------------------------------------------------------------
654 // XAccessibleAction
655 // -----------------------------------------------------------------------------
656 sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionCount( ) throw (RuntimeException)
658 ::osl::MutexGuard aGuard( m_aMutex );
660 // three actions supported
661 return ACCESSIBLE_ACTION_COUNT;
663 // -----------------------------------------------------------------------------
664 sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::doAccessibleAction( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
666 SolarMutexGuard aSolarGuard;
667 ::osl::MutexGuard aGuard( m_aMutex );
669 sal_Bool bRet = sal_False;
670 checkActionIndex_Impl( nIndex );
671 EnsureIsAlive();
673 SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex );
674 if ( pEntry && !pEntry->IsSelected() )
676 m_pIconCtrl->SetNoSelection();
677 m_pIconCtrl->SetCursor( pEntry );
678 bRet = sal_True;
681 return bRet;
683 // -----------------------------------------------------------------------------
684 OUString SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleActionDescription( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
686 SolarMutexGuard aSolarGuard;
687 ::osl::MutexGuard aGuard( m_aMutex );
689 checkActionIndex_Impl( nIndex );
690 EnsureIsAlive();
692 static const OUString sActionDesc( "Select" );
693 return sActionDesc;
695 // -----------------------------------------------------------------------------
696 Reference< XAccessibleKeyBinding > AccessibleIconChoiceCtrlEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
698 ::osl::MutexGuard aGuard( m_aMutex );
700 Reference< XAccessibleKeyBinding > xRet;
701 checkActionIndex_Impl( nIndex );
702 // ... which key?
703 return xRet;
705 //........................................................................
706 }// namespace accessibility
707 //........................................................................
709 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */