update dev300-m58
[ooovba.git] / accessibility / source / standard / vclxaccessiblelistitem.cxx
blobf17ba4081724f3cb8d209d289873e8d0acadc475
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: vclxaccessiblelistitem.cxx,v $
10 * $Revision: 1.3 $
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/standard/vclxaccessiblelistitem.hxx>
34 #include <toolkit/helper/convert.hxx>
35 #include <accessibility/helper/listboxhelper.hxx>
36 #include <com/sun/star/awt/Point.hpp>
37 #include <com/sun/star/awt/Rectangle.hpp>
38 #include <com/sun/star/awt/Size.hpp>
40 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
41 #include <com/sun/star/accessibility/AccessibleRole.hpp>
42 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
43 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
44 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
45 #include <tools/debug.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/controllayout.hxx>
48 #include <vcl/unohelp2.hxx>
49 #include <toolkit/awt/vclxwindow.hxx>
50 #include <unotools/accessiblestatesethelper.hxx>
51 #include <unotools/accessiblerelationsethelper.hxx>
52 #include <cppuhelper/typeprovider.hxx>
53 #include <comphelper/sequence.hxx>
54 #include <comphelper/accessibleeventnotifier.hxx>
56 namespace
58 void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
60 if ( _nIndex < 0 || _nIndex > _sText.getLength() )
61 throw ::com::sun::star::lang::IndexOutOfBoundsException();
65 // class VCLXAccessibleListItem ------------------------------------------
67 using namespace ::com::sun::star::accessibility;
68 using namespace ::com::sun::star::uno;
69 using namespace ::com::sun::star::beans;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star;
73 DBG_NAME(VCLXAccessibleListItem)
75 // -----------------------------------------------------------------------------
76 // Ctor() and Dtor()
77 // -----------------------------------------------------------------------------
78 VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
80 VCLXAccessibleListItem_BASE ( m_aMutex ),
82 m_nIndexInParent( _nIndexInParent ),
83 m_bSelected ( sal_False ),
84 m_bVisible ( sal_False ),
85 m_nClientId ( 0 ),
86 m_pListBoxHelper( _pListBoxHelper ),
87 m_xParent ( _xParent )
90 DBG_CTOR( VCLXAccessibleListItem, NULL );
92 if ( m_xParent.is() )
93 m_xParentContext = m_xParent->getAccessibleContext();
95 if ( m_pListBoxHelper )
96 m_sEntryText = m_pListBoxHelper->GetEntry( (USHORT)_nIndexInParent );
98 // -----------------------------------------------------------------------------
99 VCLXAccessibleListItem::~VCLXAccessibleListItem()
101 DBG_DTOR( VCLXAccessibleListItem, NULL );
103 // -----------------------------------------------------------------------------
104 void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected )
106 if ( m_bSelected != _bSelected )
108 Any aOldValue;
109 Any aNewValue;
110 if ( m_bSelected )
111 aOldValue <<= AccessibleStateType::SELECTED;
112 else
113 aNewValue <<= AccessibleStateType::SELECTED;
114 m_bSelected = _bSelected;
115 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
118 // -----------------------------------------------------------------------------
119 void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible )
121 if ( m_bVisible != _bVisible )
123 Any aOldValue, aNewValue;
124 m_bVisible = _bVisible;
125 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
126 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
127 (_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
128 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
131 // -----------------------------------------------------------------------------
132 void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
133 const ::com::sun::star::uno::Any& _aOldValue,
134 const ::com::sun::star::uno::Any& _aNewValue )
136 AccessibleEventObject aEvt;
137 aEvt.Source = *this;
138 aEvt.EventId = _nEventId;
139 aEvt.OldValue = _aOldValue;
140 aEvt.NewValue = _aNewValue;
142 if (m_nClientId)
143 comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
145 // -----------------------------------------------------------------------------
146 // OCommonAccessibleText
147 // -----------------------------------------------------------------------------
148 ::rtl::OUString VCLXAccessibleListItem::implGetText()
150 return m_sEntryText;
152 // -----------------------------------------------------------------------------
153 Locale VCLXAccessibleListItem::implGetLocale()
155 return Application::GetSettings().GetLocale();
157 // -----------------------------------------------------------------------------
158 void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
160 nStartIndex = 0;
161 nEndIndex = 0;
163 // -----------------------------------------------------------------------------
164 // XInterface
165 // -----------------------------------------------------------------------------
166 Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException)
168 return VCLXAccessibleListItem_BASE::queryInterface( rType );
170 // -----------------------------------------------------------------------------
171 void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
173 VCLXAccessibleListItem_BASE::acquire();
175 // -----------------------------------------------------------------------------
176 void SAL_CALL VCLXAccessibleListItem::release() throw ()
178 VCLXAccessibleListItem_BASE::release();
180 // -----------------------------------------------------------------------------
181 // XTypeProvider
182 // -----------------------------------------------------------------------------
183 Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes( ) throw (RuntimeException)
185 return VCLXAccessibleListItem_BASE::getTypes();
187 // -----------------------------------------------------------------------------
188 Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException)
190 static ::cppu::OImplementationId* pId = NULL;
192 if ( !pId )
194 ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
196 if ( !pId )
198 static ::cppu::OImplementationId aId;
199 pId = &aId;
202 return pId->getImplementationId();
204 // -----------------------------------------------------------------------------
205 // XComponent
206 // -----------------------------------------------------------------------------
207 void SAL_CALL VCLXAccessibleListItem::disposing()
209 comphelper::AccessibleEventNotifier::TClientId nId( 0 );
210 Reference< XInterface > xEventSource;
212 ::osl::MutexGuard aGuard( m_aMutex );
214 VCLXAccessibleListItem_BASE::disposing();
215 m_sEntryText = ::rtl::OUString();
216 m_pListBoxHelper = NULL;
217 m_xParent = NULL;
218 m_xParentContext = NULL;
220 nId = m_nClientId;
221 m_nClientId = 0;
222 if ( nId )
223 xEventSource = *this;
226 // Send a disposing to all listeners.
227 if ( nId )
228 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
230 // -----------------------------------------------------------------------------
231 // XServiceInfo
232 // -----------------------------------------------------------------------------
233 ::rtl::OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException)
235 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleListItem" );
237 // -----------------------------------------------------------------------------
238 sal_Bool VCLXAccessibleListItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
240 Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
241 const ::rtl::OUString* pNames = aNames.getConstArray();
242 const ::rtl::OUString* pEnd = pNames + aNames.getLength();
243 for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
246 return pNames != pEnd;
248 // -----------------------------------------------------------------------------
249 Sequence< ::rtl::OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
251 Sequence< ::rtl::OUString > aNames(3);
252 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" );
253 aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" );
254 aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleListItem" );
255 return aNames;
257 // -----------------------------------------------------------------------------
258 // XAccessible
259 // -----------------------------------------------------------------------------
260 Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext( ) throw (RuntimeException)
262 return this;
264 // -----------------------------------------------------------------------------
265 // XAccessibleContext
266 // -----------------------------------------------------------------------------
267 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount( ) throw (RuntimeException)
269 return 0;
271 // -----------------------------------------------------------------------------
272 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException)
274 return Reference< XAccessible >();
276 // -----------------------------------------------------------------------------
277 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent( ) throw (RuntimeException)
279 ::osl::MutexGuard aGuard( m_aMutex );
281 return m_xParent;
283 // -----------------------------------------------------------------------------
284 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent( ) throw (RuntimeException)
286 ::osl::MutexGuard aGuard( m_aMutex );
287 return m_nIndexInParent;
289 // -----------------------------------------------------------------------------
290 sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole( ) throw (RuntimeException)
292 return AccessibleRole::LIST_ITEM;
293 // return AccessibleRole::LABEL;
295 // -----------------------------------------------------------------------------
296 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription( ) throw (RuntimeException)
298 // no description for every item
299 return ::rtl::OUString();
301 // -----------------------------------------------------------------------------
302 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName( ) throw (RuntimeException)
304 ::osl::MutexGuard aGuard( m_aMutex );
306 // entry text == accessible name
307 return implGetText();
309 // -----------------------------------------------------------------------------
310 Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet( ) throw (RuntimeException)
312 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
313 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
314 return xSet;
316 // -----------------------------------------------------------------------------
317 Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet( ) throw (RuntimeException)
319 ::osl::MutexGuard aGuard( m_aMutex );
321 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
322 Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
324 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
326 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
327 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
328 pStateSetHelper->AddState( AccessibleStateType::ENABLED );
329 pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
330 if ( m_bSelected )
331 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
332 if ( m_bVisible )
334 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
335 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
338 else
339 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
341 return xStateSet;
343 // -----------------------------------------------------------------------------
344 Locale SAL_CALL VCLXAccessibleListItem::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
346 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
347 ::osl::MutexGuard aGuard( m_aMutex );
349 return implGetLocale();
351 // -----------------------------------------------------------------------------
352 // XAccessibleComponent
353 // -----------------------------------------------------------------------------
354 sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException)
356 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
357 ::osl::MutexGuard aGuard( m_aMutex );
359 sal_Bool bInside = sal_False;
360 if ( m_pListBoxHelper )
362 Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ) );
363 aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
364 bInside = aRect.IsInside( VCLPoint( _aPoint ) );
366 return bInside;
368 // -----------------------------------------------------------------------------
369 Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
371 return Reference< XAccessible >();
373 // -----------------------------------------------------------------------------
374 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeException)
376 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
377 ::osl::MutexGuard aGuard( m_aMutex );
379 awt::Rectangle aRect;
380 if ( m_pListBoxHelper )
381 aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ) );
383 return aRect;
385 // -----------------------------------------------------------------------------
386 awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeException)
388 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
389 ::osl::MutexGuard aGuard( m_aMutex );
391 Point aPoint(0,0);
392 if ( m_pListBoxHelper )
394 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
395 aPoint = aRect.TopLeft();
397 return AWTPoint( aPoint );
399 // -----------------------------------------------------------------------------
400 awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (RuntimeException)
402 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
403 ::osl::MutexGuard aGuard( m_aMutex );
405 Point aPoint(0,0);
406 if ( m_pListBoxHelper )
408 Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
409 aPoint = aRect.TopLeft();
410 aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
412 return AWTPoint( aPoint );
414 // -----------------------------------------------------------------------------
415 awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException)
417 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
418 ::osl::MutexGuard aGuard( m_aMutex );
420 Size aSize;
421 if ( m_pListBoxHelper )
422 aSize = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent ).GetSize();
424 return AWTSize( aSize );
426 // -----------------------------------------------------------------------------
427 void SAL_CALL VCLXAccessibleListItem::grabFocus( ) throw (RuntimeException)
429 // no focus for each item
431 // -----------------------------------------------------------------------------
432 // XAccessibleText
433 // -----------------------------------------------------------------------------
434 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException)
436 return -1;
438 // -----------------------------------------------------------------------------
439 sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
441 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
442 ::osl::MutexGuard aGuard( m_aMutex );
444 if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
445 throw IndexOutOfBoundsException();
447 return sal_False;
449 // -----------------------------------------------------------------------------
450 sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
452 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
453 ::osl::MutexGuard aGuard( m_aMutex );
455 return OCommonAccessibleText::getCharacter( nIndex );
457 // -----------------------------------------------------------------------------
458 Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
460 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
461 ::osl::MutexGuard aGuard( m_aMutex );
463 ::rtl::OUString sText( implGetText() );
464 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
465 throw IndexOutOfBoundsException();
467 return Sequence< PropertyValue >();
469 // -----------------------------------------------------------------------------
470 awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
472 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
473 ::osl::MutexGuard aGuard( m_aMutex );
475 ::rtl::OUString sText( implGetText() );
476 if ( !implIsValidIndex( nIndex, sText.getLength() ) )
477 throw IndexOutOfBoundsException();
479 awt::Rectangle aBounds( 0, 0, 0, 0 );
480 if ( m_pListBoxHelper )
482 Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
483 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
484 aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
485 aBounds = AWTRectangle( aCharRect );
488 return aBounds;
490 // -----------------------------------------------------------------------------
491 sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException)
493 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
494 ::osl::MutexGuard aGuard( m_aMutex );
496 return OCommonAccessibleText::getCharacterCount();
498 // -----------------------------------------------------------------------------
499 sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
501 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
502 ::osl::MutexGuard aGuard( m_aMutex );
504 sal_Int32 nIndex = -1;
505 if ( m_pListBoxHelper )
507 USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
508 Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (USHORT)m_nIndexInParent );
509 Point aPnt( VCLPoint( aPoint ) );
510 aPnt += aItemRect.TopLeft();
511 sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
512 if ( nI != -1 && (USHORT)m_nIndexInParent == nPos )
513 nIndex = nI;
515 return nIndex;
517 // -----------------------------------------------------------------------------
518 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException)
520 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
521 ::osl::MutexGuard aGuard( m_aMutex );
523 return OCommonAccessibleText::getSelectedText();
525 // -----------------------------------------------------------------------------
526 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException)
528 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
529 ::osl::MutexGuard aGuard( m_aMutex );
531 return OCommonAccessibleText::getSelectionStart();
533 // -----------------------------------------------------------------------------
534 sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException)
536 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
537 ::osl::MutexGuard aGuard( m_aMutex );
539 return OCommonAccessibleText::getSelectionEnd();
541 // -----------------------------------------------------------------------------
542 sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
544 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
545 ::osl::MutexGuard aGuard( m_aMutex );
547 if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
548 throw IndexOutOfBoundsException();
550 return sal_False;
552 // -----------------------------------------------------------------------------
553 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException)
555 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
556 ::osl::MutexGuard aGuard( m_aMutex );
558 return OCommonAccessibleText::getText();
560 // -----------------------------------------------------------------------------
561 ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
563 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
564 ::osl::MutexGuard aGuard( m_aMutex );
566 return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
568 // -----------------------------------------------------------------------------
569 ::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)
571 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
572 ::osl::MutexGuard aGuard( m_aMutex );
574 return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
576 // -----------------------------------------------------------------------------
577 ::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)
579 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
580 ::osl::MutexGuard aGuard( m_aMutex );
582 return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
584 // -----------------------------------------------------------------------------
585 ::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)
587 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
588 ::osl::MutexGuard aGuard( m_aMutex );
590 return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
592 // -----------------------------------------------------------------------------
593 sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
595 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
596 ::osl::MutexGuard aGuard( m_aMutex );
598 checkIndex_Impl( nStartIndex, m_sEntryText );
599 checkIndex_Impl( nEndIndex, m_sEntryText );
601 sal_Bool bRet = sal_False;
602 if ( m_pListBoxHelper )
604 Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
605 if ( xClipboard.is() )
607 ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
608 ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
610 const sal_uInt32 nRef = Application::ReleaseSolarMutex();
611 xClipboard->setContents( pDataObj, NULL );
612 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
613 if( xFlushableClipboard.is() )
614 xFlushableClipboard->flushClipboard();
615 Application::AcquireSolarMutex( nRef );
617 bRet = sal_True;
621 return bRet;
623 // -----------------------------------------------------------------------------
624 // XAccessibleEventBroadcaster
625 // -----------------------------------------------------------------------------
626 void SAL_CALL VCLXAccessibleListItem::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
628 if (xListener.is())
630 if (!m_nClientId)
631 m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
632 comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
635 // -----------------------------------------------------------------------------
636 void SAL_CALL VCLXAccessibleListItem::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
638 if ( xListener.is() && m_nClientId )
640 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
641 if ( !nListenerCount )
643 // no listeners anymore
644 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
645 // and at least to us not firing any events anymore, in case somebody calls
646 // NotifyAccessibleEvent, again
647 if ( m_nClientId )
649 comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
650 m_nClientId = 0;
651 comphelper::AccessibleEventNotifier::revokeClient( nId );
656 // -----------------------------------------------------------------------------
660 // AF (Oct. 29 2002): Return black as constant foreground color. This is an
661 // initial implementation and has to be substituted by code that determines
662 // the color that is actually used.
663 sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void)
664 throw (::com::sun::star::uno::RuntimeException)
666 return COL_BLACK;
669 // AF (Oct. 29 2002): Return white as constant background color. This is an
670 // initial implementation and has to be substituted by code that determines
671 // the color that is actually used.
672 sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void)
673 throw (::com::sun::star::uno::RuntimeException)
675 return COL_WHITE;
677 // -----------------------------------------------------------------------------