update credits
[LibreOffice.git] / accessibility / source / standard / vclxaccessiblelistitem.cxx
blob1a9471ce967a8108fc86fd4f6574292be55c6252
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/standard/vclxaccessiblelistitem.hxx>
21 #include <toolkit/helper/convert.hxx>
22 #include <accessibility/helper/listboxhelper.hxx>
23 #include <com/sun/star/awt/Point.hpp>
24 #include <com/sun/star/awt/Rectangle.hpp>
25 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
28 #include <com/sun/star/accessibility/AccessibleRole.hpp>
29 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/controllayout.hxx>
35 #include <vcl/unohelp2.hxx>
36 #include <toolkit/awt/vclxwindow.hxx>
37 #include <unotools/accessiblestatesethelper.hxx>
38 #include <unotools/accessiblerelationsethelper.hxx>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <comphelper/sequence.hxx>
41 #include <comphelper/accessibleeventnotifier.hxx>
43 namespace
45 void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
47 if ( _nIndex < 0 || _nIndex > _sText.getLength() )
48 throw ::com::sun::star::lang::IndexOutOfBoundsException();
52 // class VCLXAccessibleListItem ------------------------------------------
54 using namespace ::com::sun::star::accessibility;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::beans;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star;
60 // -----------------------------------------------------------------------------
61 // Ctor() and Dtor()
62 // -----------------------------------------------------------------------------
63 VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
65 VCLXAccessibleListItem_BASE ( m_aMutex ),
67 m_nIndexInParent( _nIndexInParent ),
68 m_bSelected ( sal_False ),
69 m_bVisible ( sal_False ),
70 m_nClientId ( 0 ),
71 m_pListBoxHelper( _pListBoxHelper ),
72 m_xParent ( _xParent )
75 if ( m_xParent.is() )
76 m_xParentContext = m_xParent->getAccessibleContext();
78 if ( m_pListBoxHelper )
79 m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent );
81 // -----------------------------------------------------------------------------
82 VCLXAccessibleListItem::~VCLXAccessibleListItem()
85 // -----------------------------------------------------------------------------
86 void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected )
88 if ( m_bSelected != _bSelected )
90 Any aOldValue;
91 Any aNewValue;
92 if ( m_bSelected )
93 aOldValue <<= AccessibleStateType::SELECTED;
94 else
95 aNewValue <<= AccessibleStateType::SELECTED;
96 m_bSelected = _bSelected;
97 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
100 // -----------------------------------------------------------------------------
101 void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible )
103 if ( m_bVisible != _bVisible )
105 Any aOldValue, aNewValue;
106 m_bVisible = _bVisible;
107 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
108 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
109 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
110 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
113 // -----------------------------------------------------------------------------
114 void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
115 const ::com::sun::star::uno::Any& _aOldValue,
116 const ::com::sun::star::uno::Any& _aNewValue )
118 AccessibleEventObject aEvt;
119 aEvt.Source = *this;
120 aEvt.EventId = _nEventId;
121 aEvt.OldValue = _aOldValue;
122 aEvt.NewValue = _aNewValue;
124 if (m_nClientId)
125 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
127 // -----------------------------------------------------------------------------
128 // OCommonAccessibleText
129 // -----------------------------------------------------------------------------
130 OUString VCLXAccessibleListItem::implGetText()
132 return m_sEntryText;
134 // -----------------------------------------------------------------------------
135 Locale VCLXAccessibleListItem::implGetLocale()
137 return Application::GetSettings().GetLanguageTag().getLocale();
139 // -----------------------------------------------------------------------------
140 void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
142 nStartIndex = 0;
143 nEndIndex = 0;
145 // -----------------------------------------------------------------------------
146 // XInterface
147 // -----------------------------------------------------------------------------
148 Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException)
150 return VCLXAccessibleListItem_BASE::queryInterface( rType );
152 // -----------------------------------------------------------------------------
153 void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
155 VCLXAccessibleListItem_BASE::acquire();
157 // -----------------------------------------------------------------------------
158 void SAL_CALL VCLXAccessibleListItem::release() throw ()
160 VCLXAccessibleListItem_BASE::release();
162 // -----------------------------------------------------------------------------
163 // XTypeProvider
164 // -----------------------------------------------------------------------------
165 Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException)
167 return VCLXAccessibleListItem_BASE::getTypes();
169 // -----------------------------------------------------------------------------
170 Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException)
172 static ::cppu::OImplementationId* pId = NULL;
174 if ( !pId )
176 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
178 if ( !pId )
180 static ::cppu::OImplementationId aId;
181 pId = &aId;
184 return pId->getImplementationId();
186 // -----------------------------------------------------------------------------
187 // XComponent
188 // -----------------------------------------------------------------------------
189 void SAL_CALL VCLXAccessibleListItem::disposing()
191 comphelper::AccessibleEventNotifier::TClientId nId( 0 );
192 Reference< XInterface > xEventSource;
194 ::osl::MutexGuard aGuard( m_aMutex );
196 VCLXAccessibleListItem_BASE::disposing();
197 m_sEntryText = OUString();
198 m_pListBoxHelper = NULL;
199 m_xParent = NULL;
200 m_xParentContext = NULL;
202 nId = m_nClientId;
203 m_nClientId = 0;
204 if ( nId )
205 xEventSource = *this;
208 // Send a disposing to all listeners.
209 if ( nId )
210 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
212 // -----------------------------------------------------------------------------
213 // XServiceInfo
214 // -----------------------------------------------------------------------------
215 OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException)
217 return OUString( "com.sun.star.comp.toolkit.AccessibleListItem" );
219 // -----------------------------------------------------------------------------
220 sal_Bool VCLXAccessibleListItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
222 return cppu::supportsService(this, rServiceName);
224 // -----------------------------------------------------------------------------
225 Sequence< OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
227 Sequence< OUString > aNames(3);
228 aNames[0] = "com.sun.star.accessibility.AccessibleContext";
229 aNames[1] = "com.sun.star.accessibility.AccessibleComponent";
230 aNames[2] = "com.sun.star.accessibility.AccessibleListItem";
231 return aNames;
233 // -----------------------------------------------------------------------------
234 // XAccessible
235 // -----------------------------------------------------------------------------
236 Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext( ) throw (RuntimeException)
238 return this;
240 // -----------------------------------------------------------------------------
241 // XAccessibleContext
242 // -----------------------------------------------------------------------------
243 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount( ) throw (RuntimeException)
245 return 0;
247 // -----------------------------------------------------------------------------
248 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException)
250 return Reference< XAccessible >();
252 // -----------------------------------------------------------------------------
253 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent( ) throw (RuntimeException)
255 ::osl::MutexGuard aGuard( m_aMutex );
257 return m_xParent;
259 // -----------------------------------------------------------------------------
260 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent( ) throw (RuntimeException)
262 ::osl::MutexGuard aGuard( m_aMutex );
263 return m_nIndexInParent;
265 // -----------------------------------------------------------------------------
266 sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole( ) throw (RuntimeException)
268 return AccessibleRole::LIST_ITEM;
269 // return AccessibleRole::LABEL;
271 // -----------------------------------------------------------------------------
272 OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription( ) throw (RuntimeException)
274 // no description for every item
275 return OUString();
277 // -----------------------------------------------------------------------------
278 OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName( ) throw (RuntimeException)
280 ::osl::MutexGuard aGuard( m_aMutex );
282 // entry text == accessible name
283 return implGetText();
285 // -----------------------------------------------------------------------------
286 Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet( ) throw (RuntimeException)
288 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
289 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
290 return xSet;
292 // -----------------------------------------------------------------------------
293 Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet( ) throw (RuntimeException)
295 ::osl::MutexGuard aGuard( m_aMutex );
297 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
298 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
300 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
302 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
303 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
304 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
305 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
306 if ( m_bSelected )
307 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
308 if ( m_bVisible )
310 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
311 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
314 else
315 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
317 return xStateSet;
319 // -----------------------------------------------------------------------------
320 Locale SAL_CALL VCLXAccessibleListItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
322 SolarMutexGuard aSolarGuard;
323 ::osl::MutexGuard aGuard( m_aMutex );
325 return implGetLocale();
327 // -----------------------------------------------------------------------------
328 // XAccessibleComponent
329 // -----------------------------------------------------------------------------
330 sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException)
332 SolarMutexGuard aSolarGuard;
333 ::osl::MutexGuard aGuard( m_aMutex );
335 sal_Bool bInside = sal_False;
336 if ( m_pListBoxHelper )
338 Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
339 aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
340 bInside = aRect.IsInside( VCLPoint( _aPoint ) );
342 return bInside;
344 // -----------------------------------------------------------------------------
345 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
347 return Reference< XAccessible >();
349 // -----------------------------------------------------------------------------
350 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeException)
352 SolarMutexGuard aSolarGuard;
353 ::osl::MutexGuard aGuard( m_aMutex );
355 awt::Rectangle aRect;
356 if ( m_pListBoxHelper )
357 aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
359 return aRect;
361 // -----------------------------------------------------------------------------
362 awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeException)
364 SolarMutexGuard aSolarGuard;
365 ::osl::MutexGuard aGuard( m_aMutex );
367 Point aPoint(0,0);
368 if ( m_pListBoxHelper )
370 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
371 aPoint = aRect.TopLeft();
373 return AWTPoint( aPoint );
375 // -----------------------------------------------------------------------------
376 awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (RuntimeException)
378 SolarMutexGuard aSolarGuard;
379 ::osl::MutexGuard aGuard( m_aMutex );
381 Point aPoint(0,0);
382 if ( m_pListBoxHelper )
384 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
385 aPoint = aRect.TopLeft();
386 aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
388 return AWTPoint( aPoint );
390 // -----------------------------------------------------------------------------
391 awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException)
393 SolarMutexGuard aSolarGuard;
394 ::osl::MutexGuard aGuard( m_aMutex );
396 Size aSize;
397 if ( m_pListBoxHelper )
398 aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize();
400 return AWTSize( aSize );
402 // -----------------------------------------------------------------------------
403 void SAL_CALL VCLXAccessibleListItem::grabFocus( ) throw (RuntimeException)
405 // no focus for each item
407 // -----------------------------------------------------------------------------
408 // XAccessibleText
409 // -----------------------------------------------------------------------------
410 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException)
412 return -1;
414 // -----------------------------------------------------------------------------
415 sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
417 SolarMutexGuard aSolarGuard;
418 ::osl::MutexGuard aGuard( m_aMutex );
420 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
421 throw IndexOutOfBoundsException();
423 return sal_False;
425 // -----------------------------------------------------------------------------
426 sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
428 SolarMutexGuard aSolarGuard;
429 ::osl::MutexGuard aGuard( m_aMutex );
431 return OCommonAccessibleText::getCharacter( nIndex );
433 // -----------------------------------------------------------------------------
434 Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
436 SolarMutexGuard aSolarGuard;
437 ::osl::MutexGuard aGuard( m_aMutex );
439 OUString sText( implGetText() );
440 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
441 throw IndexOutOfBoundsException();
443 return Sequence< PropertyValue >();
445 // -----------------------------------------------------------------------------
446 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
448 SolarMutexGuard aSolarGuard;
449 ::osl::MutexGuard aGuard( m_aMutex );
451 OUString sText( implGetText() );
452 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
453 throw IndexOutOfBoundsException();
455 awt::Rectangle aBounds( 0, 0, 0, 0 );
456 if ( m_pListBoxHelper )
458 Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
459 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
460 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
461 aBounds = AWTRectangle( aCharRect );
464 return aBounds;
466 // -----------------------------------------------------------------------------
467 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException)
469 SolarMutexGuard aSolarGuard;
470 ::osl::MutexGuard aGuard( m_aMutex );
472 return OCommonAccessibleText::getCharacterCount();
474 // -----------------------------------------------------------------------------
475 sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
477 SolarMutexGuard aSolarGuard;
478 ::osl::MutexGuard aGuard( m_aMutex );
480 sal_Int32 nIndex = -1;
481 if ( m_pListBoxHelper )
483 sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
484 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
485 Point aPnt( VCLPoint( aPoint ) );
486 aPnt += aItemRect.TopLeft();
487 sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
488 if ( nI != -1 && (sal_uInt16)m_nIndexInParent == nPos )
489 nIndex = nI;
491 return nIndex;
493 // -----------------------------------------------------------------------------
494 OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException)
496 SolarMutexGuard aSolarGuard;
497 ::osl::MutexGuard aGuard( m_aMutex );
499 return OCommonAccessibleText::getSelectedText();
501 // -----------------------------------------------------------------------------
502 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException)
504 SolarMutexGuard aSolarGuard;
505 ::osl::MutexGuard aGuard( m_aMutex );
507 return OCommonAccessibleText::getSelectionStart();
509 // -----------------------------------------------------------------------------
510 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException)
512 SolarMutexGuard aSolarGuard;
513 ::osl::MutexGuard aGuard( m_aMutex );
515 return OCommonAccessibleText::getSelectionEnd();
517 // -----------------------------------------------------------------------------
518 sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
520 SolarMutexGuard aSolarGuard;
521 ::osl::MutexGuard aGuard( m_aMutex );
523 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
524 throw IndexOutOfBoundsException();
526 return sal_False;
528 // -----------------------------------------------------------------------------
529 OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException)
531 SolarMutexGuard aSolarGuard;
532 ::osl::MutexGuard aGuard( m_aMutex );
534 return OCommonAccessibleText::getText();
536 // -----------------------------------------------------------------------------
537 OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
539 SolarMutexGuard aSolarGuard;
540 ::osl::MutexGuard aGuard( m_aMutex );
542 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
544 // -----------------------------------------------------------------------------
545 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
547 SolarMutexGuard aSolarGuard;
548 ::osl::MutexGuard aGuard( m_aMutex );
550 return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
552 // -----------------------------------------------------------------------------
553 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
555 SolarMutexGuard aSolarGuard;
556 ::osl::MutexGuard aGuard( m_aMutex );
558 return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
560 // -----------------------------------------------------------------------------
561 ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
563 SolarMutexGuard aSolarGuard;
564 ::osl::MutexGuard aGuard( m_aMutex );
566 return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
568 // -----------------------------------------------------------------------------
569 sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
571 SolarMutexGuard aSolarGuard;
572 ::osl::MutexGuard aGuard( m_aMutex );
574 checkIndex_Impl( nStartIndex, m_sEntryText );
575 checkIndex_Impl( nEndIndex, m_sEntryText );
577 sal_Bool bRet = sal_False;
578 if ( m_pListBoxHelper )
580 Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
581 if ( xClipboard.is() )
583 OUString sText( getTextRange( nStartIndex, nEndIndex ) );
584 ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
586 const sal_uInt32 nRef = Application::ReleaseSolarMutex();
587 xClipboard->setContents( pDataObj, NULL );
588 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
589 if( xFlushableClipboard.is() )
590 xFlushableClipboard->flushClipboard();
591 Application::AcquireSolarMutex( nRef );
593 bRet = sal_True;
597 return bRet;
599 // -----------------------------------------------------------------------------
600 // XAccessibleEventBroadcaster
601 // -----------------------------------------------------------------------------
602 void SAL_CALL VCLXAccessibleListItem::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
604 if (xListener.is())
606 if (!m_nClientId)
607 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
608 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
611 // -----------------------------------------------------------------------------
612 void SAL_CALL VCLXAccessibleListItem::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
614 if ( xListener.is() && m_nClientId )
616 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
617 if ( !nListenerCount )
619 // no listeners anymore
620 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
621 // and at least to us not firing any events anymore, in case somebody calls
622 // NotifyAccessibleEvent, again
623 if ( m_nClientId )
625 comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
626 m_nClientId = 0;
627 comphelper::AccessibleEventNotifier::revokeClient( nId );
632 // -----------------------------------------------------------------------------
636 // AF (Oct. 29 2002): Return black as constant foreground color. This is an
637 // initial implementation and has to be substituted by code that determines
638 // the color that is actually used.
639 sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void)
640 throw (::com::sun::star::uno::RuntimeException)
642 return COL_BLACK;
645 // AF (Oct. 29 2002): Return white as constant background color. This is an
646 // initial implementation and has to be substituted by code that determines
647 // the color that is actually used.
648 sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void)
649 throw (::com::sun::star::uno::RuntimeException)
651 return COL_WHITE;
653 // -----------------------------------------------------------------------------
655 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */